Represent "default" responses instead of crashing on them - #543
Merged
Conversation
This was referenced Jul 9, 2026
Response keys were unconditionally Int32.Parsed, so any valid Swagger 2 spec containing a "default" response aborted generation with a FormatException. Responses are now keyed by a ResponseKey DU (Code of int | Default), and the client generator explicitly ignores Default when selecting the success response: it describes the status codes not otherwise listed, which in practice means errors. No generated output changes: Gitea declares no default responses. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Smaug123
force-pushed
the
swagger-default-responses
branch
from
July 9, 2026 23:11
0859f3c to
a5c5159
Compare
The previous commit named this behaviour but did not implement it: a response map containing only "default" still hit the "got no successful response results" failure. Factor the decision out into `successResponse` and cover it with property tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Smaug123
commented
Jul 10, 2026
| type ResponseKey = | ||
| /// A specific HTTP status code, e.g. 200. | ||
| | Code of int | ||
| /// The catch-all "default" response. |
Owner
Author
There was a problem hiding this comment.
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.
Second fix split out of #540; stacked on #542.
Swagger 2 permits a
defaultresponse, but response keys were unconditionallyInt32.Parsed, so any valid spec containing one aborted generation with aFormatException. Responses are now keyed by aResponseKeyDU (Code of int | Default), and the client generator explicitly ignoresDefaultwhen selecting the success response — it describes the status codes not otherwise listed, which in practice means errors.No generated output changes (Gitea declares no default responses); the test was written first and observed failing to compile against the old int-keyed API, with the runtime defect being the
Int32.Parse "default"throw.🤖 Generated with Claude Code