Skip to content

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

@paulmach

Description

@paulmach

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions