Describe the bug
I am using TypeSpec v1.8.0 and node v22.21.0. When plainDate.now() is used as the default value for a query string, the emitter "@typespec/openapi3" crashes with the following error output:
TypeSpec compiler v1.8.0
✔ Compiling
× Running @typespec/openapi3...
Emitter "@typespec/openapi3" crashed! This is a bug.
Please file an issue at https://github.com/microsoft/typespec/issues
TypeError: Cannot read properties of undefined (reading 'value')
at serializeScalarValueAsJson ({home}/node_modules/@typespec/compiler/dist/src/lib/examples.js:117:68)
at serializeValueAsJson ({home}/node_modules/@typespec/compiler/dist/src/lib/examples.js:31:20)
at serializeValueAsJson ({home}/node_modules/@typespec/compiler/dist/src/lib/examples.js:12:16)
at getDefaultValue ({home}/node_modules/@typespec/openapi3/dist/src/util.js:106:12)
at getOpenAPIParameterBase ({home}/node_modules/@typespec/openapi3/dist/src/openapi.js:1121:30)
at getParameter ({home}/node_modules/@typespec/openapi3/dist/src/openapi.js:1000:16)
at getParameterOrRef ({home}/node_modules/@typespec/openapi3/dist/src/openapi.js:1106:23)
at getEndpointParameters ({home}/node_modules/@typespec/openapi3/dist/src/openapi.js:1028:27)
at getOperation ({home}/node_modules/@typespec/openapi3/dist/src/openapi.js:632:25)
at getOperationOrSharedOperation ({home}/node_modules/@typespec/openapi3/dist/src/openapi.js:553:20)
--------------------------------------------------
Library Version 1.8.0
TypeSpec Compiler Version 1.8.0
--------------------------------------------------
As an example of expected behavior:
import "@typespec/http";
using Http;
// op example(@query date?: plainDate = plainDate.now()): {};
op example(@query date?: plainDate = plainDate.fromISO("2024-05-06")): {};
When a fromISO() string is provided, the emitter outputs just as expected. However, if the two operation comments are inverted, the emitter crashes. You can view this behavior in this playground link
Reproduction
Crashing:
import "@typespec/http";
using Http;
op example(@query date?: plainDate = plainDate.now()): {};
Working:
import "@typespec/http";
using Http;
op example(@query date?: plainDate = plainDate.fromISO("2024-05-06")): {};
Playground Link
Checklist
Describe the bug
I am using TypeSpec v1.8.0 and node v22.21.0. When
plainDate.now()is used as the default value for a query string, the emitter "@typespec/openapi3" crashes with the following error output:As an example of expected behavior:
When a
fromISO()string is provided, the emitter outputs just as expected. However, if the two operation comments are inverted, the emitter crashes. You can view this behavior in this playground linkReproduction
Crashing:
Working:
Playground Link
Checklist