Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to check if a schema matches one in root document #945

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

percivalalb
Copy link

@percivalalb percivalalb commented Apr 22, 2024

It does this by keeping track of the source file paths of schemas in multi-file'd specs.

This enables the amalgamation of schemas which reference the same underlying model which removes very annoying to use anonymous structs in generated models when using codegen tools like oapi-codegen.

TODO: add MR in oapi-codegen displaying improved model generation. deepmap/oapi-codegen#1573

Note: currently this is built on v0.123 as v0.124 is not compatible with oapi-codegen at the moment.

It does this by keeping track of the source file paths of schemas in
multi-file'd specs.

This enables the amalgamation of schemas which reference the same underlying
model which removes *very annoying* to use anonymous structs in generated
models when using codegen tools like oapi-codegen.
@fenollp
Copy link
Collaborator

fenollp commented Apr 29, 2024

Hello!
How about a func that, given a doc and a Schema, returns a *SchemaRef (a ptr under doc) or nil? Would this not cover your use case?

Note: the refs.go file is generated.

@percivalalb
Copy link
Author

Hello!

How about a func that, given a doc and a Schema, returns a *SchemaRef (a ptr under doc) or nil? Would this not cover your use case?

Note: the refs.go file is generated.

Yes, if it also returned the name in the #components/schemas/...

Input: doc, Schema
Output: name, SchemaRef

I'll have a look at moving it out of the gen'ed file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants