Reconcile matching schemas in root document to avoid anonymous structs #1573
Closed
percivalalb wants to merge 2 commits intooapi-codegen:mainfrom
Closed
Reconcile matching schemas in root document to avoid anonymous structs #1573percivalalb wants to merge 2 commits intooapi-codegen:mainfrom
percivalalb wants to merge 2 commits intooapi-codegen:mainfrom
Conversation
percivalalb
commented
Apr 22, 2024
Author
|
The changes needed to the kin-openapi library are present in v0.126.0, I'll wait for #1689 to be merged before completing this PR |
f662fa7 to
f71a97a
Compare
f71a97a to
ffd7e20
Compare
Author
|
This is now ready for review |
cd5c969 to
3d69a64
Compare
Member
|
Thank you for contributing, and I'm very sorry for taking so long to get to this PR. At this point, the code has changed so much that it's no longer relevant because this was blocked on an upstream kin-openapi dependency merge that was never completed, and the codebase has moved on. |
Author
|
Hi, the changes to the upstream dependancy were completed and merged in. Oapi-codegen is now using the required version of kin-openapi. I imagine this PR needs rebasing since it's been so long but it should still work fine. |
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.
For #1362
OpenAPI specifications can be spread across different files for maintainability. However this is not great for code-gen which can't recognise when two schema refs refer to the same model. This results in the code-gen using duplicating anonymous structs (which can't easily be used).
I have added a patch to kin upstream (getkin/kin-openapi#945) which identifies when a ref refers to a schema from the root #/components/schemas and makes use of the go model generated from that.
See f71a97a which shows the change codegen changes:
Note: Also adds test spec to test for regression against #1572