Skip to content

Link object with operationRef is not validated correctly  #85

@Alan-Cha

Description

@Alan-Cha

Link 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions