-
Notifications
You must be signed in to change notification settings - Fork 503
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
OAS: External references in path items are broken #3030
Comments
I created #3031 to fix a bug in uri creation when a path item references a path containing templates. I created Apicurio/apicurio-data-models#859 in apicurio-data-models to update the Wdyt @EricWittmann |
I agree with your approach here. The local properties should take precedent over the remote properties, for sure. +1 Also this was a big miss in our dereferencing support in data-models, so thanks for catching this and contributing a fix. I'll need to forward-port your data-models work to v2, unless you feel motivated to do that yourself. :) |
* fix: unescape json references special chars Characters '/' and '~' are escaped with respectively '~1' and '~0' cf: https://swagger.io/docs/specification/v3_0/using-ref/ and must be unescaped accordingly. * fix: handle dereference of path items see Apicurio/apicurio-studio#3030 --------- Co-authored-by: Benjamin Ledentec <[email protected]>
Oh I see now that we haven't migrated the dereferencing functionality from v1 to v2 yet, so no need to forward-port the PathItem work you've done. |
I'm releasing data-models 1.1.31 now. |
Great thanks. |
Expected Behavior
An external reference can be used on a path item with
$ref
key as specified in openapi 2+ specs :Allows for a referenced definition of this path item. The referenced structure MUST be in the form of a Path Item Object. In case a Path Item Object field appears both in the defined object and the referenced object, the behavior is undefined. See the rules for resolving Relative References.
Adding an external reference should throw no error if it references a valid path item and should be handled by apicurio dereferencer.
Actual Behavior
In source mode an issue is thrown
Path Item Reference must refer to a valid Path Item Definition
. When preview or export with dereferencement is done an error is thrown.Steps to Reproduce the Problem
Specifications
Cause
The referenced path item node can't be fetched because
/
must be unescaped from~1
to get correct path item key . (see Apicurio/apicurio-data-models#858).The second error during dereference is because the
Dereferencer
class in apicurio-data-models doesn't implement path item case. It tries to add the referenced node intocomponents
and then change originel external ref to an internal one. But path items can't be defined in components. The referenced node is supposed to be "merged" according the spec.Proposed fix
I can write a PR to fix the second issue. I propose to do a simple non recursive merge of the external path item properties into the internal one and ignore external path item properties if they are already defined in internal path item (since spec says
In case a Path Item Object field appears both in the defined object and the referenced object, the behavior is undefined
).The text was updated successfully, but these errors were encountered: