Project: KICS (Provisioning / Security & Compliance)
File: a96bbc06-8cde-4295-ad3c-ee343a7f658e.md

title: Default Invalid (v3) hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: a96bbc06-8cde-4295-ad3c-ee343a7f658e Query name: Default Invalid (v3) Platform: OpenAPI Severity: <span style="color:#5bc0de">Info</span> Category: Structure and Semantics URL: The field 'default' of Schema Object should be consistent with the schema's type<br> ```json title="Positive test num. 1 - json file" hl_lines="21" { "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": { "schema": { "type": "integer", "format": "int32", "description": "the size of the pack the dog is from", "default": "a", "minimum": 0 } } } } } } } } } ``` ```yaml title="Positive test num. 2 - yaml file" hl_lines="17" swagger: "2.0" info: title: Simple API Overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: 200 response schema: type: array items: type: string default: { "a": "b" } ``` ```json title="Positive test num. 3 - json file" hl_lines="22" { "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": { "schema": { "type": "number", "minimum": 0, "exclusiveMinimum": true, "maximum": 50, "default": "a" } } } } } } } } } ``` <details><summary>Positive test num. 4 - json file</summary> ```json 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": { "200": { "description": "200 response", "content": { "application/json": { "schema": { "default": [ { "message": "hello", "code": 200 } ], "type": "object", "required": [ "message", "code" ], "properties": { "message": { "type": "string" }, "code": { "type": "integer", "minimum": 100, "maximum": 600 } } } } } } } } } } } ``` </details> <details><summary>Positive test num. 5 - json file</summary> ```json 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": { "200": { "description": "200 response", "content": { "application/json": { "schema": { "default": { "a": "b" }, "type": "array", "items": { "type": "string" } } } } } } } } } } ``` </details> <details><summary>Positive test num. 6 - yaml file</summary> ```yaml hl_lines="19" openapi: 3.0.0 info: title: Simple API Overview version:

paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: 200 response content: application/json: schema: type: integer format: int32 description: the size of the pack the dog is from default: "a" minimum: 0 ``` </details> <details><summary>Positive test num. 7 - yaml file</summary> ```yaml 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: "200": description: 200 response content: application/json: schema: type: number minimum: 0 exclusiveMinimum: true maximum: 50 default: "a" ``` </details> <details><summary>Positive test num. 8 - yaml file</summary> ```yaml 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: schema: type: object required: message code properties: message: type: string code: type: integer minimum: 100 maximum: 600 default: { "message": "hello", "code": 200 } ``` </details> <details><summary>Positive test num. 9 - yaml file</summary> ```yaml hl_lines="19" 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: schema: type: array items: type: string default: { "a": "b" } ``` </details> <details><summary>Positive test num. 10 - json file</summary> ```json hl_lines="16" { "swagger": "2.0", "info": { "title": "Simple API Overview", "version": "1.0.0" }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response", "schema": { "default": { "a": "b" }, "type": "array", "items": { "type": "string" } } } } } } } } ``` </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": { "schema": { "type": "integer", "format": "int32", "description": "the size of the pack the dog is from", "default": 1, "minimum": 0 } } } } } } } } } ``` ```yaml title="Negative test num. 2 - yaml file" swagger: "2.0" info: title: Simple API Overview version: 1.0.0 paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: 200 response schema: type: array items: type: string default: a ``` ```json title="Negative test num. 3 - json file" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version":

}, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response", "content": { "application/json": { "schema": { "type": "number", "minimum": 0, "exclusiveMinimum": true, "maximum": 50, "default": 5 } } } } } } } } } ``` <details><summary>Negative test num. 4 - json file</summary> ```json { "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": { "schema": { "type": "object", "required": [ "message", "code" ], "properties": { "message": { "type": "string" }, "code": { "type": "integer", "minimum": 100, "maximum": 600 } }, "default": { "message": "hello", "code": 200 } } } } } } } } } } ``` </details> <details><summary>Negative test num. 5 - json file</summary> ```json { "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": { "schema": { "type": "array", "items": { "type": "string" }, "default": [ "a" ] } } } } } } } } } ``` </details> <details><summary>Negative test num. 6 - 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: "200": description: 200 response content: application/json: schema: type: integer format: int32 description: the size of the pack the dog is from default: 1 minimum: 0 ``` </details> <details><summary>Negative test num. 7 - 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: "200": description: 200 response content: application/json: schema: type: number minimum: 0 exclusiveMinimum: true maximum: 50 default: 5 ``` </details> <details><summary>Negative test num. 8 - 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: "200": description: 200 response content: application/json: schema: type: object required: message code properties: message: type: string code: type: integer minimum: 100 maximum: 600 default: { "message": "hello", "code": 200 } ``` </details> <details><summary>Negative test num. 9 - 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: "200": description: 200 response content: application/json: schema: type: array items: type: string default: a ``` </details> <details><summary>Negative test num. 10 - 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": { "description": "200 response", "schema": { "type": "array", "items": { "type": "string" }, "default": [ "a" ] } } } } } } } ``` </details>