Add support for top-level oneOf/union schemas in OpenAPI spec#62
Open
tomasweigenast wants to merge 10 commits intomasreplay:mainfrom
Open
Add support for top-level oneOf/union schemas in OpenAPI spec#62tomasweigenast wants to merge 10 commits intomasreplay:mainfrom
tomasweigenast wants to merge 10 commits intomasreplay:mainfrom
Conversation
Co-authored-by: tomasweigenast <31850785+tomasweigenast@users.noreply.github.com>
Co-authored-by: tomasweigenast <31850785+tomasweigenast@users.noreply.github.com>
Co-authored-by: tomasweigenast <31850785+tomasweigenast@users.noreply.github.com>
…eezed toJson generation Co-authored-by: tomasweigenast <31850785+tomasweigenast@users.noreply.github.com>
…using wrapper value parameter Co-authored-by: tomasweigenast <31850785+tomasweigenast@users.noreply.github.com>
…lasses Co-authored-by: tomasweigenast <31850785+tomasweigenast@users.noreply.github.com>
…d-parser Add support for top-level oneOf/union schemas in OpenAPI spec
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.
Disclaimer
This pull request was fully generated using GitHub Agent. I reviewed all the changes, validated the approach, and tested the implementation with my own examples. No code in this PR was written manually by me; the agent produced all of it. This was my first time using GitHub Agent, and the results were satisfactory based on the tests performed :)
Summary
This PR adds support for parsing and generating Dart/freezed code from top-level
oneOfschemas in OpenAPI specifications. Previously,oneOfwas only supported when nested inside another schema's property. Check out #58Problem
The generator did not support this OpenAPI pattern:
Solution
oneOfanddiscriminatorfields toOpenApiSchemasclassModelGeneratorto detect top-level oneOf schemasbuildFromTopLevelSchemamethod inUnionModelStrategyGenerated Output Example
Summary
I’m not sure whether this will be merged or if additional work is required (for example, adding tests), but I ran into this issue and needed a solution. I’m sharing it in case it’s useful to others.