-
Notifications
You must be signed in to change notification settings - Fork 336
Description
Describe the bug
When defining a response with an enum in TypeSpec, the example value specified for that enum is not correctly translated into the generated OpenAPI spec. Instead of including the example value, the generated OpenAPI spec embeds it as an empty JSON object {}.
This issue occurs in both TypeSpec 1.3 , and persists even after upgrading When defining a response with an enum in TypeSpec, the example value specified for that enum is not correctly translated into the generated OpenAPI spec. Instead of including the example value, the generated OpenAPI spec embeds it as an empty JSON object {}.
This issue occurs in both TypeSpec 1.3, and persists even after upgrading to latest 1.7.
Reproduction
Steps to Reproduce:
Define a TypeSpec model with an enum in a response, and specify an example value.
Export the service to OpenAPI.
Observe that the example in the OpenAPI spec is {} instead of the enum example.
In this example, Version 1 uses an enum and includes an example, but when we check the generated OpenAPI spec, the example appears as {} instead of the actual value. In contrast, Version 2 includes an example without using an enum, and it is correctly translated into the OpenAPI spec.
Link to Playground with example:
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.