-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Ambiguity between Reference Object and PathItem Object #2635
Comments
I didn't notice this before. The schema doesn't validate this properly. It only allows for a Path Item Object (with no Reference Object properties) OR a Reference Object. A Path Item Object with Reference Object properties would fail validation. What is the reason for including Reference Object properties in Path Item Object as opposed to just using a Reference Object? It's the only type that does that. It also doesn't seem very well specified. It doesn't specify how a reference works in this context, but implies that there differences from a normal Reference Object. A Reference Object has rules for merging "summary" and "description", but other properties are not merged in the referenced object. Path Item Object implies that some merging takes place, but doesn't specify how (e.g. deep or shallow merge). Is it assumed that Reference Object behaviors apply here unless otherwise specified? Do the merging rules for "summary" and "description" in a Reference Object apply? As a workaround, I think you can always treat a |
@jdesrosiers it's an old remnant of version 2.0, where we allowed the reference without knowing back then that it cannot live alongside other properties. So back then (and now), it allows siblings and does not ignore them. |
So this technically means that if Object looks like a Reference Object, it will always be considered a Reference Object.
As @webron mentioned it's a remnant from older specifications, where
As the merging rules as
Acoording to this:
This would contradict the current schema validation. IMHO better way and possibly more forward compatible one would be to stay with the current validation and consider everything that looks like a Reference Object a Reference Object.
So if I understand this correctly, whenever there there is a choice between I still think that this is problematic and opens door for unnecessary interpretations. In order to reduce the complexity and eliminate the ambiguity I propose following:
This small change will make things right in backward compatible manner. |
Yes. If it has a
References in a Schema Object don't do any merging (not in any version of JSON Schema). Reference Object doesn't expressly specify a shallow merge, but I think the term "override" does imply a shallow merge.
Right. This workaround only works if the tooling uses similar merging rules to Reference Object.
I'm sure everyone can agree with that. I completely agree with your proposed changes. |
Right, there is only section of 7.7.1.1 which kind of defines what the behavior could be, and that behavior is aligned with OAS 3.1 Reference Object.
Should I push this forward by creating a PR with a proposed change? Thank you for your time and all the answers! |
From TDC call: 3.1.1 : 1) Remove the use of reference Object for WebHooks and Components/PathItems Should we continue to support "merging" PathItems? |
@darrelmiller IMHO 3.1.1 The aim here is provide clarification to limit ambiguity
3.2.0 The aim here is to have only one referencing mechanism iwithing OAS 3.2 spec (reducing complexity) -
|
I've scanned ~200,000 OpenAPI documents and apart from my test file, I've found precisely 3 occurrences of a All three files are exactly the same and are in test folders of the pyswagger/pyopenapi projects:
|
During the next week I should have some numbers from SwaggerHub as well. |
This change provides a clarification to limit ambiguity between Path Item Object and Reference Object. Signed-off-by: Vladimir Gorej <vladimir.gorej@gmail.com>
This change provides a clarification to limit ambiguity between Path Item Object and Reference Object. Signed-off-by: Vladimir Gorej <vladimir.gorej@gmail.com>
This change provides a clarification to limit ambiguity between Path Item Object and Reference Object. Signed-off-by: Vladimir Gorej <vladimir.gorej@gmail.com>
The field has been deprecated in favor of using Reference Object in OAS 3.2.0 and forward. Signed-off-by: Vladimir Gorej <vladimir.gorej@gmail.com>
Signed-off-by: Vladimir Gorej <vladimir.gorej@gmail.com>
As discussed and agreed on TDC, I've issued a 3 PRs that fix the ambiguity in progressive steps between 3.1.1 and 3.2.: |
It's worse than that... the json schema does not allow for this document at all:
Because the top level (which is exactly what @char0n proposed in #2635 (comment).) |
Would a PR to this effect be accepted? I am encountering tooling errors when trying to use a $ref for a path-item that exactly duplicates another path-item (except for a different path template), because the schema document does not accept this, and the tool uses schema validation to parse the document. |
Hello. When OAI 3.2.0 is released, could I use Reference Objects($ref) in Paths Object like below? paths:
$ref: foo.yaml
$ref: bar.yaml |
@gimbimloki whenever 3.2.0 is released, any syntax change won't involve duplicate keys as per your example, which have undefined behaviour in both JSON and YAML. |
What's the status of this? It appears to have stalled just before execution of all the action items listed. |
I think that change would cover any real use cases, but I don't think it completely brings the schema in line with the spec. That change would not allow properties next to The get the specified behavior, I think we'd have to add |
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
Hi everybody, not sure if this is the right place to ask this, but I've intercepted an ambiguity while building tooling for OAS 3.1
Given following document, pathItem1 can be interpreted either as Reference Object or Path Item Object. It's hard to tell what the author intended. He could have intended for pathItem1 to be a Reference Object. Or he may have intended pathItem1 to be a Path Item Object. As Path Item Object can have exactly the same shape as Reference Object the intention of the author is lost.
Can you please advice how to approach that?
Instead of having this ambiguity and
$ref
field in Path Item Object, wouldn't it be cleaner to use Reference Object explicitly in every place where Path Item Object is allowed?Current workaround could be assert the presence of
$ref
field and one of the other fixed fields from Path Item Object (likeget
,post
, etc...). If assertion like that passes, we can say with limited certainty that author intended to define a Path Item Object.The text was updated successfully, but these errors were encountered: