Project: KICS (Provisioning / Security & Compliance)
File: 0220e1c5-65d1-49dd-b7c2-cef6d6cb5283.md

title: Schema Object Incorrect Ref (v2) hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 0220e1c5-65d1-49dd-b7c2-cef6d6cb5283 Query name: Schema Object Incorrect Ref (v2) Platform: OpenAPI Severity: <span style="color:#5bc0de">Info</span> Category: Structure and Semantics URL: Schema Object reference must always point to '#/definitions'<br> ```json title="Positive test num. 1 - json file" hl_lines="29" { "swagger": "2.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "$ref": "#/responses/Success" } }, "parameters": [ { "$ref": "#/parameters/limitParam" } ] } } }, "responses": { "Success": { "description": "An array with users", "schema": { "$ref": "#/responses/Success" } } }, "parameters": { "limitParam": { "name": "limit", "in": "body", "description": "max records to return", "required": true, "schema": { "type": "integer" } } }, "definitions": { "User": { "type": "object", "required": [ "id", "name" ], "properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" } } } } } ``` ```yaml title="Positive test num. 2 - yaml file" hl_lines="19" swagger: '2.0' info: title: Simple API Overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: '200': "$ref": "#/responses/Success" parameters: "$ref": "#/parameters/limitParam" responses: Success: description: An array with users schema: "$ref": "#/responses/Success" parameters: limitParam: name: limit in: body description: max records to return required: true schema: type: integer definitions: User: type: object required: id name properties: id: type: integer format: int64 name: type: string ``` ```json title="Negative test num. 1 - json file" { "swagger": "2.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "$ref": "#/responses/Success" } }, "parameters": [ { "$ref": "#/parameters/limitParam" } ] } } }, "responses": { "Success": { "description": "An array with users", "schema": { "$ref": "#/definitions/User" } } }, "parameters": { "limitParam": { "name": "limit", "in": "body", "description": "max records to return", "required": true, "schema": { "type": "integer" } } }, "definitions": { "User": { "type": "object", "required": [ "id", "name" ], "properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" } } } } } ``` ```yaml title="Negative test num. 2 - yaml file" swagger: '2.0' info: title: Simple API Overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: '200': "$ref": "#/responses/Success" parameters: "$ref": "#/parameters/limitParam" responses: Success: description: An array with users schema: "$ref": "#/definitions/User" parameters: limitParam: name: limit in: body description: max records to return required: true schema: type: integer definitions: User: type: object required: id name properties: id: type: integer format: int64 name: type: string ```