Project: KICS (Provisioning / Security & Compliance)
File: 60fb6621-9f02-473b-9424-ba9a825747d3.md

title: Link Object With Both 'operationId' And 'operationRef' hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 60fb6621-9f02-473b-9424-ba9a825747d3 Query name: Link Object With Both 'operationId' And 'operationRef' Platform: OpenAPI Severity: <span style="color:#5bc0de">Info</span> Category: Structure and Semantics URL: Link object 'OperationId' should not have both 'operationId' and 'operationRef' defined since they are mutually exclusive.<br> ```json title="Positive test num. 1 - json file" hl_lines="70" { "openapi": "3.0.0", "info": { "title": "Simple API overview", "version": "1.0.0" }, "paths": { "/": { "get": { "responses": { "200": { "description": "the user being returned", "content": { "application/json": { "schema": { "type": "object", "properties": { "uuid": { "type": "string", "format": "uuid" } } } } } } } } }, "/users/{userid}/address": { "parameters": [ { "name": "userid", "in": "path", "required": true, "description": "the user identifier, as userId", "schema": { "type": "string" } } ], "get": { "operationId": "getUserAddress", "responses": { "200": { "description": "the user's address" } } } } }, "components": { "responses": { "200": { "description": "the user being returned", "content": { "application/json": { "schema": { "type": "object", "properties": { "uuid": { "type": "string", "format": "uuid" } } } } }, "links": { "address": { "operationId": "getUserAddress", "operationRef": "/", "parameters": { "userId": "$request.path.id" } } } } }, "schemas": { "Pet": { "$ref": "../models/pet.yaml" }, "User": { "$ref": "https://api.example.com/v2/openapi.yaml#/components/schemas/User" } } } } ``` ```json title="Positive test num. 2 - json file" hl_lines="27" { "openapi": "3.0.0", "info": { "title": "Simple API overview", "version": "1.0.0" }, "paths": { "/": { "get": { "responses": { "200": { "description": "the user being returned", "content": { "application/json": { "schema": { "type": "object", "properties": { "uuid": { "format": "uuid", "type": "string" } } } } }, "links": { "address": { "operationId": "getUserAddress", "operationRef": "/", "parameters": { "userId": "$request.path.id" } } } } } } }, "/users/{userid}/address": { "parameters": [ { "name": "userid", "in": "path", "required": true, "description": "the user identifier, as userId", "schema": { "type": "string" } } ], "get": { "operationId": "getUserAddress", "responses": { "200": { "description": "the user's address" } } } } } } ``` ```json title="Positive test num. 3 - json file" hl_lines="67" { "openapi": "3.0.0", "info": { "title": "Simple API overview", "version": "1.0.0" }, "paths": { "/": { "get": { "responses": { "200": { "description": "the user being returned", "content": { "application/json": { "schema": { "type": "object", "properties": { "uuid": { "type": "string", "format": "uuid" } } } } } } } } }, "/users/{userid}/address": { "parameters": [ { "name": "userid", "in": "path", "required": true, "description": "the user identifier, as userId", "schema": { "type": "string" } } ], "get": { "operationId": "getUserAddress", "responses": { "200": { "description": "the user's address" } } } } }, "components": { "schemas": { "Pet": { "$ref": "../models/pet.yaml" }, "User": { "$ref": "https://api.example.com/v2/openapi.yaml#/components/schemas/User" } }, "responses": { "GenericError": {

"../template-api.yaml#/components/responses/GenericError" } }, "links": { "address": { "operationId": "getUserAddress", "operationRef": "/", "parameters": { "userId": "$request.path.id" } } } } } ``` <details><summary>Positive test num. 4 - yaml file</summary> ```yaml hl_lines="50" openapi: 3.0.0 info: title: Simple API overview version: 1.0.0 paths: "/": get: responses: "200": description: the user being returned content: application/json: schema: type: object properties: uuid: type: string format: uuid "/users/{userid}/address": parameters: name: userid in: path required: true description: the user identifier, as userId schema: type: string get: operationId: getUserAddress responses: "200": description: the user's address components: schemas: Pet: $ref: "../models/pet.yaml" User: $ref: "https://api.example.com/v2/openapi.yaml#/components/schemas/User" responses: "200": description: the user being returned content: application/json: schema: type: object properties: uuid: type: string format: uuid links: address: operationId: getUserAddress operationRef: / parameters: userId: $request.path.id ``` </details> <details><summary>Positive test num. 5 - yaml file</summary> ```yaml hl_lines="20" openapi: 3.0.0 info: title: Simple API overview version: 1.0.0 paths: "/": get: responses: "200": description: the user being returned content: application/json: schema: type: object properties: uuid: type: string format: uuid links: address: operationId: getUserAddress operationRef: / parameters: userId: $request.path.id "/users/{userid}/address": parameters: name: userid in: path required: true description: the user identifier, as userId schema: type: string get: operationId: getUserAddress responses: "200": description: the user's address ``` </details> <details><summary>Positive test num. 6 - yaml file</summary> ```yaml hl_lines="42" openapi: 3.0.0 info: title: Simple API overview version: 1.0.0 paths: "/": get: responses: "200": description: the user being returned content: application/json: schema: type: object properties: uuid: type: string format: uuid "/users/{userid}/address": parameters: name: userid in: path required: true description: the user identifier, as userId schema: type: string get: operationId: getUserAddress responses: "200": description: the user's address components: schemas: Pet: $ref: "../models/pet.yaml" User: $ref: "https://api.example.com/v2/openapi.yaml#/components/schemas/User" responses: GenericError: $ref: "../template-api.yaml#/components/responses/GenericError" links: address: operationId: getUserAddress operationRef: / parameters: userId: $request.path.id ``` </details> ```json title="Negative test num. 1 - json file" { "openapi": "3.0.0", "info": { "title": "Simple API overview", "version": "1.0.0" }, "paths": { "/": { "get": { "responses": { "200": { "description": "the user being returned", "content": { "application/json": { "schema": { "type": "object", "properties": { "uuid": { "type": "string", "format": "uuid" } } } } } } } } }, "/users/{userid}/address": { "parameters": [ { "name": "userid", "in": "path", "required": true, "description": "the user identifier, as userId", "schema": { "type": "string" } } ], "get": { "operationId": "getUserAddress", "responses": { "200": { "description": "the user's address" } } } } }, "components": { "responses": { "200": { "description": "the user being returned", "content": { "application/json": { "schema": { "type": "object", "properties": { "uuid": { "type": "string", "format": "uuid" } } } } }, "links": { "address": { "operationId": "getUserAddress", "parameters": { "userId": "$request.path.id" } } } } }, "schemas": { "Pet": { "$ref": "../models/pet.yaml" }, "User": { "$ref": "https://api.example.com/v2/openapi.yaml#/components/schemas/User" } } } } ``` ```json title="Negative test num. 2 - json file" { "openapi": "3.0.0", "info": { "title": "Simple API overview", "version":

}, "paths": { "/": { "get": { "responses": { "200": { "description": "the user being returned", "content": { "application/json": { "schema": { "type": "object", "properties": { "uuid": { "format": "uuid", "type": "string" } } } } }, "links": { "address": { "operationId": "getUserAddress", "parameters": { "userId": "$request.path.id" } } } } } } }, "/users/{userid}/address": { "parameters": [ { "name": "userid", "in": "path", "required": true, "description": "the user identifier, as userId", "schema": { "type": "string" } } ], "get": { "operationId": "getUserAddress", "responses": { "200": { "description": "the user's address" } } } } } } ``` ```json title="Negative test num. 3 - json file" { "openapi": "3.0.0", "info": { "title": "Simple API overview", "version": "1.0.0" }, "paths": { "/": { "get": { "responses": { "200": { "description": "the user being returned", "content": { "application/json": { "schema": { "type": "object", "properties": { "uuid": { "type": "string", "format": "uuid" } } } } } } } } }, "/users/{userid}/address": { "parameters": [ { "name": "userid", "in": "path", "required": true, "description": "the user identifier, as userId", "schema": { "type": "string" } } ], "get": { "operationId": "getUserAddress", "responses": { "200": { "description": "the user's address" } } } } }, "components": { "schemas": { "Pet": { "$ref": "../models/pet.yaml" }, "User": { "$ref": "https://api.example.com/v2/openapi.yaml#/components/schemas/User" } }, "responses": { "GenericError": { "$ref": "../template-api.yaml#/components/responses/GenericError" } }, "links": { "address": { "operationId": "getUserAddress", "parameters": { "userId": "$request.path.id" } } } } } ``` <details><summary>Negative test num. 4 - yaml file</summary> ```yaml openapi: 3.0.0 info: title: Simple API overview version: 1.0.0 paths: "/": get: responses: "200": description: the user being returned content: application/json: schema: type: object properties: uuid: type: string format: uuid "/users/{userid}/address": parameters: name: userid in: path required: true description: the user identifier, as userId schema: type: string get: operationId: getUserAddress responses: "200": description: the user's address components: schemas: Pet: $ref: "../models/pet.yaml" User: $ref: "https://api.example.com/v2/openapi.yaml#/components/schemas/User" responses: "200": description: the user being returned content: application/json: schema: type: object properties: uuid: type: string format: uuid links: address: operationId: getUserAddress parameters: userId: $request.path.id ``` </details> <details><summary>Negative test num. 5 - yaml file</summary> ```yaml openapi: 3.0.0 info: title: Simple API overview version: 1.0.0 paths: "/": get: responses: "200": description: the user being returned content: application/json: schema: type: object properties: uuid: type: string format: uuid links: address: operationId: getUserAddress parameters: userId: $request.path.id "/users/{userid}/address": parameters: name: userid in: path required: true description: the user identifier, as userId schema: type: string get: operationId: getUserAddress responses: "200": description: the user's address ``` </details> <details><summary>Negative test num. 6 - yaml file</summary> ```yaml openapi: 3.0.0 info: title: Simple API overview version: 1.0.0 paths: "/": get: responses: "200": description: the user being returned content: application/json: schema: type: object properties: uuid: type: string format: uuid "/users/{userid}/address": parameters: name: userid in: path required: true description: the user identifier, as userId schema: type: string get: operationId: getUserAddress responses: "200": description: the user's address components: schemas: Pet: $ref: "../models/pet.yaml" User: $ref: "https://api.example.com/v2/openapi.yaml#/components/schemas/User" responses: GenericError: $ref: "../template-api.yaml#/components/responses/GenericError" links: address: operationId: getUserAddress parameters: userId: $request.path.id ``` </details>