Add warning when @defaultResponse is used on model with status code or @error#10555
Draft
Add warning when @defaultResponse is used on model with status code or @error#10555
Conversation
4 tasks
…code or @error Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/2d6ca218-090a-4b98-8bfd-f31ddb57b9c9 Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix duplicate $ref in return type union for defaultResponse model
Add warning when @defaultResponse is used on model with status code or @error
Apr 29, 2026
commit: |
Member
|
@copilot fix lint |
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/8c4a27ca-8f4c-44aa-ab49-14c858ae2835 Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Using
@defaultResponseon a model that already has@statusCodeor@errorproduces duplicate$refentries in OpenAPI output (e.g.,anyOfwith two identical refs). Rather than silently generating invalid output, emit a diagnostic warning at the source.Changes
packages/openapi/src/lib.ts— Newdefault-response-with-status-codediagnostic withstatusCodeanderrormessage variantspackages/openapi/src/decorators.ts—$defaultResponsenow checks the target model for existing@statusCodeproperties and@errordecoration before setting the wildcard status codepackages/openapi/test/decorators.test.ts— Tests for both warning cases and the clean no-warning pathExample