Project: KICS (Provisioning / Security & Compliance)
File: b9db8a10-020c-49ca-88c6-780e5fdb4328.md

title: Link Object Incorrect Ref hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: b9db8a10-020c-49ca-88c6-780e5fdb4328 Query name: Link Object Incorrect Ref Platform: OpenAPI Severity: <span style="color:#5bc0de">Info</span> Category: Structure and Semantics URL: Link object reference must always point to '#/components/links'<br> ```json title="Positive test num. 1 - json file" hl_lines="52" { "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" } } } } } } } } } }, "components": { "schemas": { "Pet": { "$ref": "../models/pet.yaml" }, "User": { "$ref": "https://api.example.com/v2/openapi.yaml#/components/schemas/User" } }, "responses": { "NotFound": { "description": "The specified resource was not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }, "links": { "l": { "$ref": "#components/linfks/address" } } } }, "links": { "address": { "operationId": "getUssssserAddress", "parameters": { "userId": "$request.path.id" } } } } } ``` ```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": { "content": { "application/json": { "schema": { "type": "object", "properties": { "uuid": { "type": "string", "format": "uuid" } } } } }, "links": { "l": { "$ref": "#components/linfks/address" } }, "description": "the user being returned" } } } } }, "components": { "responses": { "GenericError": { "$ref": "../template-api.yaml#/components/responses/GenericError" } }, "links": { "address": { "operationId": "getUssssserAddress", "parameters": { "userId": "$request.path.id" } } }, "schemas": { "Pet": { "$ref": "../models/pet.yaml" }, "User": { "$ref": "https://api.example.com/v2/openapi.yaml#/components/schemas/User" } } } } ``` ```yaml title="Positive test num. 3 - yaml file" hl_lines="34" 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 components: schemas: Pet: $ref: "../models/pet.yaml" User: $ref: "https://api.example.com/v2/openapi.yaml#/components/schemas/User" responses: NotFound: description: The specified resource was not found content: application/json: schema: $ref: "#/components/schemas/Error" links: l: $ref: "#components/linfks/address" links: address: operationId: getUssssserAddress parameters: userId: $request.path.id ``` <details><summary>Positive test num. 4 - yaml file</summary> ```yaml hl_lines="21" 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: type: string format: uuid links: l: $ref: "#components/linfks/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: getUssssserAddress 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" } } } } } } } } } }, "components": { "schemas": { "Pet": { "$ref": "../models/pet.yaml" }, "User": { "$ref": "https://api.example.com/v2/openapi.yaml#/components/schemas/User" } }, "responses": { "NotFound": { "description": "The specified resource was not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }, "links": { "l": { "$ref": "#/components/links/address" } } } }, "links": { "address": { "operationId": "getUssssserAddress", "parameters": { "userId": "$request.path.id" } } } } } ``` ```json title="Negative test num. 2 - json file" { "openapi": "3.0.0", "info": { "title": "Simple API overview", "version": "1.0.0" }, "paths": { "/": { "get": { "responses": { "200": { "content": { "application/json": { "schema": { "type": "object", "properties": { "uuid": { "type": "string", "format": "uuid" } } } } }, "links": { "l": { "$ref": "#/components/links/address" } }, "description": "the user being returned" } } } } }, "components": { "responses": { "GenericError": { "$ref": "../template-api.yaml#/components/responses/GenericError" } }, "links": { "address": { "operationId": "getUssssserAddress", "parameters": { "userId": "$request.path.id" } } }, "schemas": { "Pet": { "$ref": "../models/pet.yaml" }, "User": { "$ref": "https://api.example.com/v2/openapi.yaml#/components/schemas/User" } } } } ``` ```yaml title="Negative test num. 3 - yaml 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 components: schemas: Pet: $ref: "../models/pet.yaml" User: $ref: "https://api.example.com/v2/openapi.yaml#/components/schemas/User" responses: NotFound: description: The specified resource was not found content: application/json: schema: $ref: "#/components/schemas/Error" links: l: $ref: "#/components/links/address" links: address: operationId: getUssssserAddress 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 links: l: $ref: "#/components/links/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: getUssssserAddress parameters: userId: $request.path.id ``` </details>