Project: KICS (Provisioning / Security & Compliance)
File: 0f6cd0ab-c366-4595-84fc-fbd8b9901e4d.md

title: Request Body With Incorrect Ref hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 0f6cd0ab-c366-4595-84fc-fbd8b9901e4d Query name: Request Body With Incorrect Ref Platform: OpenAPI Severity: <span style="color:#5bc0de">Info</span> Category: Structure and Semantics URL: Request Body reference must always point to '#/components/RequestBodies'<br> ```json title="Positive test num. 1 - json file" hl_lines="30" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "components": { "requestBodies": { "List": { "description": "id of api version", "content": { "text/plain": { "schema": { "type": "array", "items": { "type": "integer" } } } } } } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "requestBody": { "$ref": "#/components/schemas/List" }, "responses": { "200": { "description": "200 response", "content": { "application/json": { "examples": { "foo": { "value": { "versions": [ { "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "id": "v2.0", "links": [ { "href": "http://127.0.0.1:8774/v2/", "rel": "self" } ] } ] } } } } } } } } } } } ``` ```yaml title="Positive test num. 2 - yaml file" hl_lines="22" openapi: 3.0.0 info: title: Simple API Overview version: 1.0.0 components: requestBodies: List: description: id of api version required: true content: text/plain: schema: type: array items: type: integer paths: "/": get: operationId: listVersionsv2 summary: List API versions requestBody: $ref: "#/components/schemas/List" responses: "200": description: 200 response content: application/json: examples: foo: value: versions: status: CURRENT updated: "2011-01-21T11:33:21Z" id: v2.0 links: href: http://127.0.0.1:8774/v2/ rel: self ``` ```json title="Negative test num. 1 - json file" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "components": { "requestBodies": { "List": { "description": "id of api version", "content": { "text/plain": { "schema": { "type": "array", "items": { "type": "integer" } } } } } } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "requestBody": { "$ref": "#/components/requestBodies/List" }, "responses": { "200": { "description": "200 response", "content": { "application/json": { "examples": { "foo": { "value": { "versions": [ { "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "id": "v2.0", "links": [ { "href": "http://127.0.0.1:8774/v2/", "rel": "self" } ] } ] } } } } } } } } } } } ``` ```yaml title="Negative test num. 2 - yaml file" openapi: 3.0.0 info: title: Simple API Overview version: 1.0.0 components: requestBodies: List: description: id of api version required: true content: text/plain: schema: type: array items: type: integer paths: "/": get: operationId: listVersionsv2 summary: List API versions requestBody: $ref: "#/components/requestBodies/List" responses: "200": description: 200 response content: application/json: examples: foo: value: versions: status: CURRENT updated: "2011-01-21T11:33:21Z" id: v2.0 links: href: http://127.0.0.1:8774/v2/ rel: self ```