Project: KICS (Provisioning / Security & Compliance)
File: 03856cb2-e46c-4daf-bfbf-214ec93c882b.md

title: Schema Enum Invalid (v3) hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 03856cb2-e46c-4daf-bfbf-214ec93c882b Query name: Schema Enum Invalid (v3) Platform: OpenAPI Severity: <span style="color:#5bc0de">Info</span> Category: Structure and Semantics URL: The field 'enum' of Schema Object should be consistent with the schema's type<br> ```json title="Positive test num. 1 - json file" hl_lines="20" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "201": { "description": "201 response", "content": { "text/html": { "schema": { "type": "number", "enum": [ "black" ] } } } } } } } } } ``` ```json title="Positive test num. 2 - json file" hl_lines="20" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "201": { "description": "201 response", "content": { "text/html": { "schema": { "type": "integer", "enum": [ "black" ] } } } } } } } } } ``` ```yaml title="Positive test num. 3 - yaml file" hl_lines="18" openapi: 3.0.0 info: title: Simple API Overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "201": description: 201 response content: "text/html": schema: type: number enum: black ``` <details><summary>Positive test num. 4 - yaml file</summary> ```yaml hl_lines="18" openapi: 3.0.0 info: title: Simple API Overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "201": description: 201 response content: "text/html": schema: type: integer enum: black ``` </details> <details><summary>Positive test num. 5 - json file</summary> ```json hl_lines="50 14" { "swagger": "2.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "$ref": "#/definitions/User" } }, "parameters": [ { "$ref": "#/parameters/limitParam" } ] } } }, "parameters": { "limitParam": { "name": "limit", "in": "body", "description": "max records to return", "required": true, "schema": { "type": "integer" } } }, "definitions": { "User": { "type": "object", "required": [ "id", "name" ], "properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string", "enum": [ "kics", 1 ] } } } } } ``` </details> <details><summary>Positive test num. 6 - yaml file</summary> ```yaml hl_lines="35 12" swagger: "2.0" info: title: Simple API Overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": "$ref": "#/definitions/User" parameters:

"#/parameters/limitParam" parameters: limitParam: name: limit in: body description: max records to return required: true schema: type: integer definitions: User: type: object required: id name properties: id: type: integer format: int64 name: type: string enum: kics 1 ``` </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": { "201": { "description": "201 response", "content": { "text/html": { "schema": { "type": "number", "enum": [ 1, 2, 3, 4, 5 ] } } } } } } } } } ``` ```json title="Negative test num. 2 - json file" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "201": { "description": "201 response", "content": { "text/html": { "schema": { "type": "integer", "enum": [ 1, 2, 3, 4, 5 ] } } } } } } } } } ``` ```yaml title="Negative test num. 3 - yaml file" openapi: 3.0.0 info: title: Simple API Overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "201": description: 201 response content: "text/html": schema: type: number enum: 1 2 3 4 5 ``` <details><summary>Negative test num. 4 - yaml file</summary> ```yaml openapi: 3.0.0 info: title: Simple API Overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "201": description: 201 response content: "text/html": schema: type: integer enum: 1 2 3 4 5 ``` </details> <details><summary>Negative test num. 5 - json file</summary> ```json { "swagger": "2.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "$ref": "#/definitions/User" } }, "parameters": [ { "$ref": "#/parameters/limitParam" } ] } } }, "parameters": { "limitParam": { "name": "limit", "in": "body", "description": "max records to return", "required": true, "schema": { "type": "integer" } } }, "definitions": { "User": { "type": "object", "required": [ "id", "name" ], "properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string", "enum": [ "kics", "checkmarx" ] } } } } } ``` </details> <details><summary>Negative test num. 6 - yaml file</summary> ```yaml swagger: "2.0" info: title: Simple API Overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": "$ref": "#/definitions/User" parameters: "$ref": "#/parameters/limitParam" parameters: limitParam: name: limit in: body description: max records to return required: true schema: type: integer definitions: User: type: object required: id name properties: id: type: integer format: int64 name: type: string enum: kics checkmarx ``` </details>