Project: KICS (Provisioning / Security & Compliance)
File: a92be1d5-d762-484a-86d6-8cd0907ba100.md

title: Response on operations that should have a body has undefined schema (v3) hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: a92be1d5-d762-484a-86d6-8cd0907ba100 Query name: Response on operations that should have a body has undefined schema (v3) Platform: OpenAPI Severity: <span style="color:#ff7213">Medium</span> Category: Networking and Firewall URL: If a response is not head or its code is not 204 or 304, it should have a schema defined<br> ```json title="Positive test num. 1 - json file" hl_lines="18" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response" } } }, "delete": { "operationId": "deleteVersion", "summary": "Deletes API versions", "responses": { "204": { "description": "no content" } } } } }, "components": { "schemas": { "ApiVersion": { "type": "object", "discriminator": { "propertyName": "ApiVersion" }, "properties": { "code": { "type": "integer", "format": "int32" }, "version": { "type": "string" } } } } } } ``` ```yaml title="Positive test num. 2 - yaml file" hl_lines="15" swagger: "2.0" info: title: Simple API Overview version: 1.0.0 contact: name: contact url: https://www.google.com/ email: user@gmail.com paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: 200 response delete: operationId: deleteVersion summary: Deletes API versions responses: "204": description: no content ``` ```json title="Positive test num. 3 - json file" hl_lines="21" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response", "content": { "application/json": {} } } } }, "delete": { "operationId": "deleteVersion", "summary": "Deletes API versions", "responses": { "204": { "description": "no content" } } } } }, "components": { "schemas": { "ApiVersion": { "type": "object", "discriminator": { "propertyName": "ApiVersion" }, "properties": { "code": { "type": "integer", "format": "int32" }, "version": { "type": "string" } } } } } } ``` <details><summary>Positive test num. 4 - json file</summary> ```json hl_lines="21 22" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response", "content": { "application/pdf": {}, "application/json": {} } } } }, "post": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response", "content": { "application/json": { "schema": {

"#/components/schemas/ApiVersion" } } } } } }, "delete": { "operationId": "deleteVersion", "summary": "Deletes API versions", "responses": { "204": { "description": "no content" } } } } }, "components": { "schemas": { "ApiVersion": { "type": "object", "discriminator": { "propertyName": "ApiVersion" }, "properties": { "code": { "type": "integer", "format": "int32" }, "version": { "type": "string" } } } } } } ``` </details> <details><summary>Positive test num. 5 - json file</summary> ```json hl_lines="20" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response", "content": {} } } }, "delete": { "operationId": "deleteVersion", "summary": "Deletes API versions", "responses": { "204": { "description": "no content" } } } } }, "components": { "schemas": { "ApiVersion": { "type": "object", "discriminator": { "propertyName": "ApiVersion" }, "properties": { "code": { "type": "integer", "format": "int32" }, "version": { "type": "string" } } } } } } ``` </details> <details><summary>Positive test num. 6 - yaml file</summary> ```yaml hl_lines="15" openapi: 3.0.0 info: title: Simple API Overview version: 1.0.0 contact: name: contact url: https://www.google.com/ email: user@gmail.com paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: 200 response delete: operationId: deleteVersion summary: Deletes API versions responses: "204": description: no content components: schemas: ApiVersion: type: object discriminator: propertyName: ApiVersion properties: code: type: integer format: int32 version: type: string ``` </details> <details><summary>Positive test num. 7 - yaml file</summary> ```yaml hl_lines="18" openapi: 3.0.0 info: title: Simple API Overview version: 1.0.0 contact: name: contact url: https://www.google.com/ email: user@gmail.com paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: 200 response content: application/json: {} delete: operationId: deleteVersion summary: Deletes API versions responses: "204": description: no content components: schemas: ApiVersion: type: object discriminator: propertyName: ApiVersion properties: code: type: integer format: int32 version: type: string ``` </details> <details><summary>Positive test num. 8 - yaml file</summary> ```yaml hl_lines="18 19" openapi: 3.0.0 info: title: Simple API Overview version: 1.0.0 contact: name: contact url: https://www.google.com/ email: user@gmail.com paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: 200 response content: application/pdf: {} application/json: {} post: operationId: listVersionsv2 summary: List API versions responses: "200": description: 200 response content: application/json: schema: "$ref": "#/components/schemas/ApiVersion" delete: operationId: deleteVersion summary: Deletes API versions responses: "204": description: no content components: schemas: ApiVersion: type: object discriminator: propertyName: ApiVersion properties: code: type: integer format: int32 version: type: string ``` </details> <details><summary>Positive test num. 9 - yaml file</summary> ```yaml hl_lines="17" openapi: 3.0.0 info: title: Simple API Overview version: 1.0.0 contact: name: contact url: https://www.google.com/ email:

paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: 200 response content: {} delete: operationId: deleteVersion summary: Deletes API versions responses: "204": description: no content components: schemas: ApiVersion: type: object discriminator: propertyName: ApiVersion properties: code: type: integer format: int32 version: type: string ``` </details> <details><summary>Positive test num. 10 - json file</summary> ```json hl_lines="18" { "swagger": "2.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response" } } }, "delete": { "operationId": "deleteVersion", "summary": "Deletes API versions", "responses": { "204": { "description": "no content" } } } } } } ``` </details> ```json title="Negative test num. 1 - json file" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiVersion" } } } } } }, "delete": { "operationId": "deleteVersion", "summary": "Deletes API versions", "responses": { "204": { "description": "no content" } } } } }, "components": { "schemas": { "ApiVersion": { "type": "object", "discriminator": { "propertyName": "ApiVersion" }, "properties": { "code": { "type": "integer", "format": "int32" }, "version": { "type": "string" } } } } } } ``` ```yaml title="Negative test num. 2 - yaml file" openapi: 3.0.0 info: title: Simple API Overview version: 1.0.0 contact: name: contact url: https://www.google.com/ email: user@gmail.com paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: 200 response content: application/json: schema: "$ref": "#/components/schemas/ApiVersion" delete: operationId: deleteVersion summary: Deletes API versions responses: "204": description: no content components: schemas: ApiVersion: type: object discriminator: propertyName: ApiVersion properties: code: type: integer format: int32 version: type: string ``` ```json title="Negative test num. 3 - json file" { "swagger": "2.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response", "schema": { "type": "object", "discriminator": "ApiVersion", "properties": { "code": { "type": "integer", "format": "int32" }, "version": { "type": "string" } } } } } }, "delete": { "operationId": "deleteVersion", "summary": "Deletes API versions", "responses": { "204": { "description": "no content" } } } } } } ``` <details><summary>Negative test num. 4 - yaml file</summary> ```yaml swagger: "2.0" info: title: Simple API Overview version: 1.0.0 contact: name: contact url: https://www.google.com/ email: user@gmail.com paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: 200 response schema: type: object discriminator: ApiVersion properties: code: type: integer format: int32 version: type: string delete: operationId: deleteVersion summary: Deletes API versions responses: "204": description: no content ``` </details>