You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Emit switch without fallback for single-case Output enums (default-only responses)
Fixes#810
OpenAPI operations that declare only a default response produced an accessor like:
switch self { case .default: return …; default: throw … }
Since the enum has a single case, the fallback was statically unreachable and triggered a compiler warning: “Default will never be executed.”
This change omits the fallback branch when the Output enum is provably single-case (default-only), eliminating the warning and keeping the accessor exhaustive. Accessor signatures remain throwing for source compatibility.
Details
- Generator: Gate the fallback default branch in [`TypesFileTranslator.translateResponseOutcomeInTypes()`](Sources/_OpenAPIGeneratorCore/Translator/Responses/translateResponseOutcome.swift:31) behind a single-case check (contains default and exactly one response outcome). Multi-case outputs remain unchanged and still throw on mismatches.
- Tests: Update default-only expected snippet to match the new, exhaustive switch without a fallback in [`SnippetBasedReferenceTests.swift`](Tests/OpenAPIGeneratorReferenceTests/SnippetBasedReferenceTests.swift:3412). No new tests added.
0 commit comments