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

v3: allow extensions next to $ref in SchemaRef #900

Closed
paulmach opened this issue Jan 29, 2024 · 3 comments · Fixed by #901
Closed

v3: allow extensions next to $ref in SchemaRef #900

paulmach opened this issue Jan 29, 2024 · 3 comments · Fixed by #901

Comments

@paulmach
Copy link
Contributor

paulmach commented Jan 29, 2024

I would like to extent SchemaRef to have a Extensions or RefExtensions to capture extensions next to $ref.

For example, if I have:

type: object
properties:
 id:
   $ref: "#/components/schemas/id"
   x-order: 1
 name:
   type: string

I would like to capture the x-order: 1 within SchemaRef.Extensions["x-order"]

Looking at the code it looks like it's "if $ref only capture $ref"

I don't think the openapi v3 spec official supports this but it would be very helpful.

My use-case is specifying the x-order, a new feature added to oapi-codegen. For example:

type: object
properties:
 start_port:
   $ref: "#/components/schemas/port"
   x-order: 0
 end_port:
   $ref: "#/components/schemas/port"
   x-order: 1

It works if you specify the x-order in the referenced object, but in the above it needs to be context dependent. A change would need to be made to oapi-codegen but it looks to be blocked by this issue.

If this change is okay, I can work on the PR.

@fenollp
Copy link
Collaborator

fenollp commented Jan 29, 2024

Oh my, thanks for noticing and reporting! This is definitely a bug / not wanted!
Looking forward to your PR.

@paulmach
Copy link
Contributor Author

I created a pr to add Extension to SchemaRef. If this approach is agreed I can expand to all *Refs.

#901

@paulmach
Copy link
Contributor Author

paulmach commented Feb 1, 2024

I have verified that #901 adds the support needed to fix my use-case in oapi-codegen

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 a pull request may close this issue.

2 participants