Project: KICS (Provisioning / Security & Compliance)
File: 8db5544e-4874-4baa-9322-e9f75a2d219e.md

title: Field 'securityScheme' On Components Is Undefined hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 8db5544e-4874-4baa-9322-e9f75a2d219e Query name: Field 'securityScheme' On Components Is Undefined Platform: OpenAPI Severity: <span style="color:#ff7213">Medium</span> Category: Access Control URL: Components' securityScheme field must have a valid scheme<br> ```json title="Positive test num. 1 - json file" hl_lines="2" { "openapi": "3.0.0", "info": { "title": "Simple API overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "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="Positive test num. 2 - json file" hl_lines="43" { "openapi": "3.0.0", "info": { "title": "Simple API overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "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" } ] } ] } } } } } } } } } }, "components": {} } ``` ```json title="Positive test num. 3 - json file" hl_lines="44" { "openapi": "3.0.0", "info": { "title": "Simple API overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "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" } ] } ] } } } } } } } } } }, "components": { "securitySchemes": {} } } ``` <details><summary>Positive test

4 - yaml file</summary> ```yaml hl_lines="1" openapi: 3.0.0 info: title: Simple API overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions 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 ``` </details> <details><summary>Positive test num. 5 - yaml file</summary> ```yaml hl_lines="25" openapi: 3.0.0 info: title: Simple API overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions 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 components: {} ``` </details> <details><summary>Positive test num. 6 - yaml file</summary> ```yaml hl_lines="26" openapi: 3.0.0 info: title: Simple API overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions 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 components: securitySchemes: {} ``` </details> ```json title="Negative test num. 1 - json file" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "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" } ] } ] } } } } } } } } } }, "security": [ { "exampleSecurity": [] } ], "components": { "securitySchemes": { "exampleSecurity": { "type": "http", "scheme": "basic" } } } } ``` ```yaml title="Negative test num. 2 - yaml file" openapi: 3.0.0 info: title: Simple API Overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions 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 security: exampleSecurity: [] components: securitySchemes: exampleSecurity: type: http scheme: basic ```