Project: KICS (Provisioning / Security & Compliance)
File: 151331e2-11f4-4bb6-bd35-9a005e695087.md

title: Components Object Fixed Field Key Improperly Named hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 151331e2-11f4-4bb6-bd35-9a005e695087 Query name: Components Object Fixed Field Key Improperly Named Platform: OpenAPI Severity: <span style="color:#5bc0de">Info</span> Category: Structure and Semantics URL: Components object fixed fields (schemas, responses, parameters, examples, requestBodies, headers, securitySchemes, links, and callbacks) should use keys that match the following REGEX: `^[a-zA-Z0-9\.\-_]+$`<br> ```json title="Positive test num. 1 - json file" hl_lines="45" { "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": { "schemas": { "General Error": { "type": "object", "discriminator": { "propertyName": "petType" }, "properties": { "code": { "type": "string", "format": "int32" }, "message": { "type": "string" } }, "required": [ "petType" ] } } } } ``` ```yaml title="Positive test num. 2 - yaml file" hl_lines="27" 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: schemas: General Error: type: object discriminator: propertyName: petType properties: code: type: string format: int32 message: type: string required: petType ``` ```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" } ] } ] } } } } } } } } } }, "components": { "schemas": { "GeneralError": { "type": "object", "discriminator": { "propertyName": "petType" }, "properties": { "code": { "type": "string", "format": "int32" }, "message": { "type": "string" } }, "required": [ "petType" ] } } } } ``` ```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 components: schemas: GeneralError: type: object discriminator: propertyName: petType properties: code: type: string format: int32 message: type: string required: petType ```