Project: KICS (Provisioning / Security & Compliance)
File: 86e3702f-c868-44b2-b61d-ea5316c18110.md

title: Default Response Undefined On Operations (v3) hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 86e3702f-c868-44b2-b61d-ea5316c18110 Query name: Default Response Undefined On Operations (v3) Platform: OpenAPI Severity: <span style="color:#edd57e">Low</span> Category: Networking and Firewall URL: Operations responses should have a default response defined<br> ```json title="Positive test num. 1 - json file" hl_lines="12" { "openapi": "3.0.0", "info": { "title": "Simple API", "version": "1.0.0" }, "paths": { "/item": { "patch": { "operationId": "updateItem", "summary": "Updated item", "responses": { "204": { "description": "Item deleted successfully" } } } } }, "components": { "schemas": { "Error": { "type": "object", "properties": { "code": { "type": "string" }, "message": { "type": "string" } }, "required": [ "code", "message" ] } } } } ``` ```json title="Positive test num. 2 - json file" hl_lines="12 21" { "openapi": "3.0.0", "info": { "title": "Simple API", "version": "1.0.0" }, "paths": { "/item": { "delete": { "operationId": "deleteItem", "summary": "Delete item", "responses": { "204": { "description": "Item deleted successfully" } } }, "patch": { "operationId": "updateItem", "summary": "Update item", "responses": { "204": { "description": "Item updated successfully" } } } } }, "components": { "schemas": { "Error": { "type": "object", "properties": { "code": { "type": "string" }, "message": { "type": "string" } }, "required": [ "code", "message" ] } } } } ``` ```yaml title="Positive test num. 3 - yaml file" hl_lines="10" openapi: 3.0.0 info: title: Simple API version: 1.0.0 paths: "/item": patch: operationId: updateItem summary: Updated item responses: '204': description: Item deleted successfully components: schemas: Error: type: object properties: code: type: string message: type: string required: code message ``` <details><summary>Positive test num. 4 - yaml file</summary> ```yaml hl_lines="16 10" openapi: 3.0.0 info: title: Simple API version: 1.0.0 paths: "/item": delete: operationId: deleteItem summary: Delete item responses: '204': description: Item deleted successfully patch: operationId: updateItem summary: Update item responses: '204': description: Item updated successfully components: schemas: Error: type: object properties: code: type: string message: type: string required: code message ``` </details> <details><summary>Positive test

5 - json file</summary> ```json hl_lines="12 21" { "swagger": "20", "info": { "title": "Simple API", "version": "1.0.0" }, "paths": { "/item": { "delete": { "operationId": "deleteItem", "summary": "Delete item", "responses": { "204": { "description": "Item deleted successfully" } } }, "patch": { "operationId": "updateItem", "summary": "Update item", "responses": { "204": { "description": "Item updated successfully" } } } } } } ``` </details> <details><summary>Positive test num. 6 - yaml file</summary> ```yaml hl_lines="16 10" swagger: "2.0" info: title: Simple API version: 1.0.0 paths: "/item": delete: operationId: deleteItem summary: Delete item responses: "204": description: Item deleted successfully patch: operationId: updateItem summary: Update item responses: "204": description: Item updated successfully ``` </details> ```json title="Negative test num. 1 - json file" { "openapi": "3.0.0", "info": { "title": "Simple API", "version": "1.0.0" }, "paths": { "/item": { "delete": { "operationId": "deleteItem", "summary": "Delete item", "responses": { "204": { "description": "Item deleted successfully" }, "default": { "description": "Error" } } }, "patch": { "operationId": "updateItem", "summary": "Update item", "responses": { "204": { "description": "Item updated successfully" }, "default": { "description": "Error" } } } } } } ``` ```yaml title="Negative test num. 2 - yaml file" openapi: 3.0.0 info: title: Simple API version: 1.0.0 paths: "/item": delete: operationId: deleteItem summary: Delete item responses: "204": description: Item deleted successfully default: description: Error patch: operationId: updateItem summary: Update item responses: "204": description: Item updated successfully default: description: Error ``` ```json title="Negative test num. 3 - json file" { "swagger": "2.0", "info": { "title": "Simple API", "version": "1.0.0" }, "paths": { "/item": { "delete": { "operationId": "deleteItem", "summary": "Delete item", "responses": { "204": { "description": "Item deleted successfully" }, "default": { "description": "Error" } } }, "patch": { "operationId": "updateItem", "summary": "Update item", "responses": { "204": { "description": "Item updated successfully" }, "default": { "description": "Error" } } } } } } ``` <details><summary>Negative test num. 4 - yaml file</summary> ```yaml swagger: "2.0" info: title: Simple API version: 1.0.0 paths: "/item": delete: operationId: deleteItem summary: Delete item responses: "204": description: Item deleted successfully default: description: Error patch: operationId: updateItem summary: Update item responses: "204": description: Item updated successfully default: description: Error ``` </details>