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

Feature Request: Allow sibling elements with $ref that overrides the references definition #2744

Closed
juzerali opened this issue Oct 11, 2021 · 3 comments

Comments

@juzerali
Copy link

Currently I can either specify a $ref or the complete property description. However there are use cases where refenced definition needs to be overridden, particularly description.

components:
    schemas:
        Money:
            description: Represents monetary value
            properties:
                currency:
                    type: string
                amount:
                    type: integer
properties:
    minimum_amount_value:
        $ref: '#/components/schemas/Money'
        description: Minimum amount required to make a transaction

In the above example, I can't both reuse Money model and explain it's property semantics. It shouldn't be this way. I believe all the properties in $ref should be overridable, but at the very least description should be.

@hkosova
Copy link
Contributor

hkosova commented Oct 11, 2021

$ref siblings as in your 2nd example are already supported in OpenAPI 3.1 / JSON Schema 2020-12.

Schema $refs support any sibling keywords. Outside of schemas (e.g. in parameters or responses), $refs only support sibling summary and description.

@jdesrosiers
Copy link
Contributor

It's important to note that although JSON Schema 2020-12 allows $ref to have siblings, the sibling keywords do not override the keywords in the referenced schema, they add to them. In the given example, both values for description apply the /properties/minimum_amount_value schema.

However, for meta-data keywords, such as description, that don't effect validation, the spec allows for implementations to choose one or the other. So, in the given example, the second description might override the first, but it depends on the implementation.

https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.7.7.1.1

@MikeRalphson
Copy link
Member

Please chase if the above didn't answer your question (I see the OP's thumbs up).

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

No branches or pull requests

4 participants