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

Allow properties on $ref objects for OpenAPI 3.1. #958

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

luhn
Copy link
Contributor

@luhn luhn commented Nov 23, 2024

JSON Schema draft 5 (OpenAPI 3.0.4), it specifically says additional properties on a $ref object are ignored.

All other properties in a "$ref" object MUST be ignored.

https://datatracker.ietf.org/doc/html/draft-wright-json-schema-00#section-7

However, draft 2020-12 (OpenAPI 3.1.0) seems to have changed its tune:

Its results are the results of the referenced schema. [[CREF5: Note
that this definition of how the results are determined means that other
keywords can appear alongside of "$ref" in the same schema object. ]]

https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.3.1

So if I'm understanding correctly, things like this are now valid and meaningful:

{
            "$ref": "#/components/schemas/Child",
            "description": "A category",
            "x-extension": "A great extension",
 }

JSON Schema draft 5 (OpenAPI 3.0.4), it specifically says additional
properties on a $ref object are ignored.

> All other properties in a "$ref" object MUST be ignored.

https://datatracker.ietf.org/doc/html/draft-wright-json-schema-00#section-7

However, draft 2020-12 seems to have changed its tune:

> Its results are the results of the referenced schema.  [[CREF5: Note
> that this definition of how the results are determined means that other
> keywords can appear alongside of "$ref" in the same schema object.  ]]

https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.3.1

If I'm interpreting this correctly, $ref now allows properties alongside
it.
Copy link
Member

@lafrech lafrech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I have a minor nit about the test. I'll address that later.

@lafrech lafrech merged commit a52e7bc into marshmallow-code:dev Dec 2, 2024
7 checks passed
@lafrech
Copy link
Member

lafrech commented Dec 2, 2024

I merged you PRs and released 6.8.0.

Thanks again!

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.

2 participants