-
Notifications
You must be signed in to change notification settings - Fork 334
Open
Labels
bugSomething isn't workingSomething isn't workingemitter:openapi3Issues for @typespec/openapi3 emitterIssues for @typespec/openapi3 emittertriaged:core
Milestone
Description
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")): {};
Checklist
- Follow our Code of Conduct
- Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingemitter:openapi3Issues for @typespec/openapi3 emitterIssues for @typespec/openapi3 emittertriaged:core