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

OpenAPI 3.1 JSON Schema incorrect for Paths Item in Paths #3298

Closed
speakeasybot opened this issue Jun 15, 2023 · 2 comments · Fixed by #3355
Closed

OpenAPI 3.1 JSON Schema incorrect for Paths Item in Paths #3298

speakeasybot opened this issue Jun 15, 2023 · 2 comments · Fixed by #3355
Labels

Comments

@speakeasybot
Copy link

speakeasybot commented Jun 15, 2023

I believe this line https://github.com/OAI/OpenAPI-Specification/blob/main/schemas/v3.1/schema.json#L294

ie:

"$ref": "#/$defs/path-item"

should actually be

"$ref": "#/$defs/path-item-or-reference"

according to the docs https://spec.openapis.org/oas/v3.1.0#pathItemObject

as when I am trying to use a json schema validator on my OpenAPI document I am getting an error like:

OpenAPI document invalid: not allowed - https://spec.openapis.org/oas/3.1/schema/2022-10-07#/$defs/path-item/unevaluatedProperties

for the below snippet

paths:
  /vehicles/{id}/pedals/accelerator:
    $ref: "./paths/acceleratorv3.yaml"
@TristanSpeakEasy
Copy link

Sorry just wanted to say the above bug was filled by me, I was just logged into the wrong account at the time

@jdesrosiers
Copy link
Contributor

Related to #2635

Stranger6667 pushed a commit to schemathesis/schemathesis that referenced this issue Oct 5, 2024
Schemathesis uses static version of the current published version
of the OpenApi 3.1 spec metaschema
(https://spec.openapis.org/oas/3.1/schema/2022-10-07)
to validate openapi 3.1 spec documents. Unfortunately, the published
version has at least one known bug in which the schema for `paths`
references the definition of a concrete `path-item` instead of
`path-item-or-reference`, which might still be technically incorrect
when it comes handling the case of ref and sibling fields, but is
correct according to the documented definition of a pathItemObject.

This oversight has been noticed multiple times
OAI/OpenAPI-Specification#3298
OAI/OpenAPI-Specification#2635 (comment)
OAI/OpenAPI-Specification#2635 (comment)
OAI/OpenAPI-Specification#3513
OAI/OpenAPI-Specification#2657 (comment)

And finally fixed in Feb 2024
OAI/OpenAPI-Specification#3355
with a slightly bigger rework of the pathItem schema.

Sadly, due to confusion about how to release fixes in schemas
OAI/OpenAPI-Specification#151 (comment)
this change has not been published anywhere except schema.yaml in the
git repo, not even in schema.json, which appearantly only gets refreshed
once per release of the metaschema
OAI/OpenAPI-Specification#3355 (comment)

This commit updates the stored schema from the most up-to-date 3.1.0
schema.yaml from 0035208 to close the bug and make spec-valid openapi
spec files that use $ref under path finally validate correctly in
schemathesis. It also adds a corresponding regression test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants