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

Meta schema 3.1 is wrong for path / pathItem #3513

Closed
LasneF opened this issue Jan 22, 2024 · 3 comments
Closed

Meta schema 3.1 is wrong for path / pathItem #3513

LasneF opened this issue Jan 22, 2024 · 3 comments

Comments

@LasneF
Copy link
Member

LasneF commented Jan 22, 2024

Accordinf to https://spec.openapis.org/oas/latest.html#fixed-fields-6

Path item Object should support $ref as in the snippet below

paths:
    /orders:
         $ref: paths/orders.yaml

it looks not supported in the meta schema
https://github.com/OAI/OpenAPI-Specification/blob/main/schemas/v3.1/schema.yaml#L211

to me the line 209 is wrong

      '^/':
        $ref: '#/$defs/path-item'

but should be

      '^/':
        $ref: '#/$defs/path-item-or-reference:'

this has been found here : daveshanley/vacuum#422

@LasneF LasneF changed the title Meta schema 3.1 on $pathItem Meta schema 3.1 is wrong for path / pathItem Jan 22, 2024
@handrews
Copy link
Member

Thanks, @LasneF. This is a dup of #3298 and is addressed by PR #3355, which (like all not-yet-deployed schema PRs — technically only the Schema Object portion is a metaschema) is awaiting proper resolution to #151 (comment). Which we expect to actually have fairly soon as it's part of the big clean-up we're doing on the issue/PR/process backlog as discussed in the TDC calls this month.

@LasneF
Copy link
Member Author

LasneF commented Jan 22, 2024

not 100 % sure read the PR correctly path-item-or-reference: is removed
so does it means

  • that $ref syntax provided is not be supported , ie having path item definition in dedicated files is forbidden
    using $ref more or less like an include the targeted files containing only content of path-item

or

  • the $ref is by default supported no need to have dedicated syntax for it

should the docuementation https://spec.openapis.org/oas/latest.html#fixed-fields-6 being updated ?

@handrews
Copy link
Member

@LasneF PathItem is a special case for referencing which uses a different syntax/semantics for adjacent properties. So PR #3355 deletes #/$defs/path-item-or-references, adds $ref directly to #/$defs/path-item, and replaces #/$defs/path-item-or-reference with #/$defs/path-item wherever it had appeared.

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
None yet
Projects
None yet
Development

No branches or pull requests

2 participants