Skip to content

Represent "default" responses instead of crashing on them - #543

Merged
Smaug123 merged 3 commits into
mainfrom
swagger-default-responses
Jul 10, 2026
Merged

Represent "default" responses instead of crashing on them#543
Smaug123 merged 3 commits into
mainfrom
swagger-default-responses

Conversation

@Smaug123

@Smaug123 Smaug123 commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Second fix split out of #540; stacked on #542.

Swagger 2 permits a default response, but response keys were unconditionally Int32.Parsed, so any valid spec containing one 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); 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

Base automatically changed from swagger-inline-response-schemas to main July 9, 2026 23:05
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
Smaug123 force-pushed the swagger-default-responses branch from 0859f3c to a5c5159 Compare July 9, 2026 23:11
Smaug123 and others added 2 commits July 10, 2026 07:44
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>
type ResponseKey =
/// A specific HTTP status code, e.g. 200.
| Code of int
/// The catch-all "default" response.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Smaug123
Smaug123 merged commit 07e3390 into main Jul 10, 2026
20 checks passed
@Smaug123
Smaug123 deleted the swagger-default-responses branch July 10, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant