cebe / php-openapi

Read and write OpenAPI yaml/json files and make the content accessible in PHP objects.
MIT License
466 stars 88 forks source link

Resolve external value #95

Closed rv1971 closed 3 years ago

rv1971 commented 3 years ago

When resolving references, relative URIs in externalValue properties are adjusted just the same way as in $ref properties.

cebe commented 3 years ago

thanks for the suggestion, however external values should not be included like references, see:

http://spec.openapis.org/oas/v3.0.3#fixed-fields-15

[...]
externalValue string A URL that points to the literal example. This provides the capability to reference examples that cannot easily be included in JSON or YAML documents. The value field and externalValue field are mutually exclusive.
rv1971 commented 3 years ago

I'm afraid you misunderstood the point.

Example: you have a path item p which is a reference to an external file p.json in a subdirectory s. The file p.json contains an externalValue whose value is a relative URI pointing to an external example file, say example.xml. When resolving the reference in p, the URI in externalValue must be adjusted to s/example.xml. It is a bug not to adjust it.

Fortunately you have already solved exactly the same problem for references. Any reference in p.json which is a relative URI is correctly adjusted. It is sufficient to do exactly the same for externalValue properties.

Pls let me know if anything is unclear.

cebe commented 3 years ago

thanks for the explanation, will check it again.

cebe commented 3 years ago

FIxed, thanks for reporting!