Link object with operationRef is not validated correctly
See original GitHub issueLink objects with operationRef properties do not have $ref properties, yet oas-validator complains that they do.
Checklist
- Conversion: I have checked my source definition is valid OpenAPI 2.0
- Conversion: On valid OpenAPI 2.0 input, the conversion looks wrong
- Validation: I believe my source definition is valid OpenAPI 3.0.x but the validator complains
- Validation: I believe my source definition is invalid OpenAPI 3.0.x but the validator does not complain
- Linting issue
- Resolver issue
Detailed Description
Here is what my link object looks like:
"ReviewsWithOperationRef": {
"operationRef": "#/paths/~1products~1{id}~1reviews/get",
"parameters": {
"id": "$request.path.product-id",
"product-tag": "$request.query.product-tag"
}
}
And when I try to validate my OAS, I get the following message:
status: false
message: |-
Failed OpenAPI3 schema validation: [
{
"keyword": "required",
"dataPath": "/components/links/ReviewsWithOperationRef",
"schemaPath": "#/required",
"params": {
"missingProperty": "$ref"
},
"message": "should have required property '$ref'",
"schema": {
"$ref": {
"type": "string",
"format": "uriref"
}
},
"parentSchema": {
"type": "object",
"required": [
"$ref"
],
"properties": {
"$ref": {
"type": "string",
"format": "uriref"
}
},
"description": "A simple object to allow referencing other components in the specification, internally and externally. The Reference Object is defined by JSON Reference and follows the same structure, behavior and rules. For this specification, reference resolution is done as defined by the JSON Reference specification and not by the JSON Schema specification."
},
"data": {
"operationRef": "#/paths/~1products~1{id}~1reviews/get",
"parameters": {
"id": "$request.path.product-id",
"product-tag": "$request.query.product-tag"
}
}
},
...
]
context: '#/'
When I try to add the $ref property as suggested like in the following:
"ReviewsWithOperationRef": {
"$ref" : "blah",
"operationRef": "#/paths/~1products~1{id}~1reviews/get",
"parameters": {
"id": "$request.path.product-id",
"product-tag": "$request.query.product-tag"
}
}
… oas-validator gives the thumbs up.
However, link objects with operationRef properties do not have $ref properties.
Here is the link object documentation link again for easy reference.
Thanks!
Other stuff
Just a note, I have the exact same link object but with an operationId property instead of an operationRef property and oas-validator does not complain that it is missing a $ref property.
I am working with the latest version of oas-validator, version 1.1.7.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
URL-encoding for operationRef · Issue #1677 - GitHub
I was under the impression that operationRef does not need URL-encoding. ... Link object with operationRef is not validated correctly ...
Read more >OpenAPI Specification - Version 3.0.3 - Swagger
If the servers property is not provided, or is an empty array, the default value would be a Server Object with a url...
Read more >OpenApiSpex.Link — open_api_spex v3.16.0 - HexDocs
The Link object represents a possible design-time link for a response. The presence of a link does not guarantee the caller's ability to...
Read more >OpenAPI Specification v3.1.0 | Introduction, Definitions, & More
The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs.
Read more >How should be open api v3.0.0 links implemented in the ...
Should it include nested object with direct links to that created user? ... Based how this concept is defined, it's not supposed to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thanks for the detailed report. I’ll take a look.
I filed an issue! Here’s a link. Hopefully we will hear back soon.