You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JSON Schema does not define a concept of $ref usage in data values, neither it provides a way to ensure if resolved data value is valid. Nevertheless using $ref in data is popular and is used in OpenAPI.
If it is not possible to validate the resolved value, we can at least have best effort validation that reference leads to a correct place.
OpenAPI spec since v3 has a pre-defined place to store some kinds of referenced values: components.
Such restriction (pattern: '#/components/responses/') could also be employed for external references, though it may have too much of negative impact on flexibility.
The text was updated successfully, but these errors were encountered:
References within the Schema Object - these are defined by JSON Schema, not OpenAPI
References outside of the Schema Object - these are already required to point to the right type of object
Enforcing reference target types through schema validation of the OpenAPI Description - we have generally avoided trying to do such complex validation in the schema
The OASComply project will eventually validate this sort of referential integrity, and there are plenty of linters that I believe can also do this. Non-JSON Schema referencing will be completely revamped in OAS 4 Moonwalk in a way that I believe will make this moot.
Since we've already declined to enforce this more strictly in OAS 3 in the past, and it's moot in OAS 4, I'm going to close this.
JSON Schema does not define a concept of
$ref
usage in data values, neither it provides a way to ensure if resolved data value is valid. Nevertheless using$ref
in data is popular and is used in OpenAPI.If it is not possible to validate the resolved value, we can at least have best effort validation that reference leads to a correct place.
OpenAPI spec since
v3
has a pre-defined place to store some kinds of referenced values:components
.For example
responses
are defined as follows:The problem here is that current schema allows
$ref
to lead to any place, not only to#/components/responses/...
.Semantically incorrect (but valid) schema with confused references:
We can make it harder to go wrong by restricting local references of schema components, for example
ResponseReference
:Such restriction (
pattern: '#/components/responses/'
) could also be employed for external references, though it may have too much of negative impact on flexibility.The text was updated successfully, but these errors were encountered: