Skip to content

Conversation

@czechboy0
Copy link
Contributor

Motivation

Runtime side of apple/swift-openapi-generator#205

Modifications

Added a helper function that produces the right error.

Result

Generated code can use this error to throw when an unknown case is encountered.

Test Plan

Tested together with the generator.

@czechboy0 czechboy0 merged commit ad847cb into apple:main Aug 17, 2023
@czechboy0 czechboy0 deleted the hd-close-enums-and-oneOfs branch August 17, 2023 11:01
@czechboy0 czechboy0 added the 🔨 semver/patch No public API change. label Aug 17, 2023
czechboy0 added a commit to apple/swift-openapi-generator that referenced this pull request Aug 17, 2023
### Motivation

Fixes #204.

Depends on apple/swift-openapi-runtime#40.

### Modifications

This introduces the feature flag `closedEnumsAndOneOfs` which stops
generating the `undocumented` case for enums and oneOfs (no other places
are affected, such as responses, and so on.). The default behavior in
0.1.x stays the same, but in 0.2.0 we'll stop generating `undocumented`
cases unconditionally.

This fixes our divergence from the OpenAPI specification, as we treated
enums and oneOfs as open, but they're closed by default.

I also added docs on this pattern to make it easier for adopters to know
how to create open enums and oneOfs on purpose.

### Result

We get closer to being spec-compliant.

### Test Plan

Created new snippet tests to verify the new functionality, will adapt
file-based tests when we're preparing 0.2.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants