Skip to content

Conversation

@percivalalb
Copy link

@percivalalb percivalalb commented Apr 22, 2024

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:

image

Note: Also adds test spec to test for regression against #1572

@percivalalb
Copy link
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

@percivalalb percivalalb force-pushed the alb/reconsole-schema-refs branch from f662fa7 to f71a97a Compare July 9, 2024 10:03
@percivalalb percivalalb requested a review from a team as a code owner July 9, 2024 10:03
@percivalalb percivalalb changed the title Reconcile references to remote schemas to models from the root spec Reconcile matching schemas in root document to avoid anonymous structs Jul 9, 2024
@percivalalb percivalalb force-pushed the alb/reconsole-schema-refs branch from f71a97a to ffd7e20 Compare July 9, 2024 10:11
@percivalalb
Copy link
Author

This is now ready for review

@jamietanna jamietanna added bug Something isn't working area:external-refs Anything related to external references (referencing other file(s) within a spec) area:*of `oneOf`/`anyOf`/`allOf` labels Sep 29, 2024
@jamietanna jamietanna added this to the v2.5.0 milestone Sep 29, 2024
@percivalalb percivalalb force-pushed the alb/reconsole-schema-refs branch from cd5c969 to 3d69a64 Compare April 26, 2025 11:38
@jamietanna jamietanna modified the milestones: v2.5.0, v2.6.0 May 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:external-refs Anything related to external references (referencing other file(s) within a spec) area:*of `oneOf`/`anyOf`/`allOf` awaiting reply bug Something isn't working upstream

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants