Project: KICS (Provisioning / Security & Compliance)
File: b2f275be-7d64-4064-b418-be6b431363a7.md

title: Success Response Code Undefined for Get Operation (v3) hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: b2f275be-7d64-4064-b418-be6b431363a7 Query name: Success Response Code Undefined for Get Operation (v3) Platform: OpenAPI Severity: <span style="color:#edd57e">Low</span> Category: Networking and Firewall URL: Get should define at least one success response (200 or 202)<br> ```json title="Positive test num. 1 - json file" hl_lines="12" { "swagger": "2.0", "info": { "title": "Simple API", "version": "1.0.0" }, "paths": { "/item": { "get": { "operationId": "getItem", "summary": "Get item", "responses": { "default": { "description": "Error" } } } } } } ``` ```yaml title="Positive test num. 2 - yaml file" hl_lines="10" swagger: "2.0" info: title: Simple API version: 1.0.0 paths: "/item": get: operationId: getItem summary: Get item responses: default: description: Error ``` ```json title="Positive test num. 3 - json file" hl_lines="12" { "openapi": "3.0.0", "info": { "title": "Simple API", "version": "1.0.0" }, "paths": { "/item": { "get": { "operationId": "getItem", "summary": "Get item", "responses": { "default": { "description": "Error" } } } } } } ``` <details><summary>Positive test num. 4 - yaml file</summary> ```yaml hl_lines="10" openapi: 3.0.0 info: title: Simple API version: 1.0.0 paths: "/item": get: operationId: getItem summary: Get item responses: default: description: Error ``` </details> ```json title="Negative test num. 1 - json file" { "swagger": "2.0", "info": { "title": "Simple API", "version": "1.0.0" }, "paths": { "/item": { "get": { "operationId": "getItem", "summary": "Get item", "responses": { "200": { "description": "success" }, "default": { "description": "Success" } } }, "patch": { "operationId": "updateItem", "summary": "Update item", "responses": { "default": { "description": "Error" } } } } } } ``` ```yaml title="Negative test num. 2 - yaml file" swagger: "2.0" info: title: Simple API version: 1.0.0 paths: "/item": get: operationId: getItem summary: Get item responses: "200": description: success default: description: Success patch: operationId: updateItem summary: Update item responses: default: description: Error ``` ```json title="Negative test num. 3 - json file" { "openapi": "3.0.0", "info": { "title": "Simple API", "version": "1.0.0" }, "paths": { "/item": { "get": { "operationId": "getItem", "summary": "Get item", "responses": { "200": { "description": "success" }, "default": { "description": "Success" } } }, "patch": { "operationId": "updateItem", "summary": "Update item", "responses": { "default": { "description": "Error" } } } } } } ``` <details><summary>Negative test num. 4 - yaml file</summary> ```yaml openapi: 3.0.0 info: title: Simple API version: 1.0.0 paths: "/item": get: operationId: getItem summary: Get item responses: "200": description: success default: description: Success patch: operationId: updateItem summary: Update item responses: default: description: Error ``` </details> <details><summary>Negative test num. 5 - json file</summary> ```json { "swagger": "2.0", "info": { "title": "Simple API", "version": "1.0.0" }, "paths": { "/item": { "get": { "operationId": "getItem", "summary": "get item", "responses": { "2XX": { "description": "Item getd successfully" }, "default": { "description": "Error" } } }, "patch": { "operationId": "updateItem", "summary": "Update item", "responses": { "default": { "description": "Error" } } } } } } ``` </details> <details><summary>Negative test num. 6 - yaml file</summary> ```yaml swagger: "2.0" info: title: Simple API version: 1.0.0 paths: "/item": get: operationId: getItem summary: get item responses: "2XX": description: Item getd successfully default: description: Error patch: operationId: updateItem summary: Update item responses: default: description: Error ``` </details>