Project: KICS (Provisioning / Security & Compliance)
File: 3a01790c-ebee-4da6-8fd3-e78657383b75.md

title: Schema with 'additionalProperties' set as Boolean hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 3a01790c-ebee-4da6-8fd3-e78657383b75 Query name: Schema with 'additionalProperties' set as Boolean Platform: OpenAPI Severity: <span style="color:#5bc0de">Info</span> Category: Best Practices URL: The value of 'additionalProperties' should be set as object instead of boolean, since swagger 2.0 does not support boolean value for it<br> ```json title="Positive test num. 1 - json file" hl_lines="28" { "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": "object", "properties": { "name": { "type": "string" }, "tag": { "type": "string" } }, "required": [ "name" ], "additionalProperties": false } } } } } } } ``` ```yaml title="Positive test num. 2 - yaml file" hl_lines="22" 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: object properties: name: type: string tag: type: string required: name additionalProperties: false definitions: User: type: object properties: name: type: string tag: type: string required: name ``` ```json title="Positive test num. 3 - json file" hl_lines="51 29" { "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": "object", "properties": { "name": { "type": "string" }, "tag": { "type": "string" } }, "required": [ "name" ], "additionalProperties": { "$ref": "#/definitions/User" } } } } } } }, "definitions": { "User": { "type": "object", "properties": { "name": { "type": "string" }, "tag": { "type": "string" } }, "required": [ "name" ], "additionalProperties": false } } } ``` <details><summary>Positive test num. 4 - yaml file</summary> ```yaml hl_lines="34 23" swagger: "2.0" info: title: Simple API Overview version:

paths: "/": get: operationId: listVersionsv2 summary: List API versions responses: "200": description: 200 response schema: type: object properties: name: type: string tag: type: string required: name additionalProperties: $ref: "#/definitions/User" definitions: User: type: object properties: name: type: string tag: type: string required: name additionalProperties: false ``` </details> ```json title="Negative test num. 1 - json 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": "object", "properties": { "name": { "type": "string" }, "tag": { "type": "string" } }, "required": [ "name" ], "additionalProperties": { "$ref": "#/definitions/User" } } } } } } }, "definitions": { "User": { "type": "object", "properties": { "name": { "type": "string" }, "tag": { "type": "string" } }, "required": [ "name" ] } } } ``` ```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: object properties: name: type: string tag: type: string required: name additionalProperties: $ref: "#/definitions/User" definitions: User: type: object properties: name: type: string tag: type: string required: name ``` ```json title="Negative test num. 3 - json 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": "object", "properties": { "name": { "type": "string" }, "tag": { "type": "string" } }, "required": [ "name" ], "additionalProperties": { "$ref": "#/definitions/User" } } } } } } }, "definitions": { "User": { "type": "object", "properties": { "name": { "type": "string" }, "tag": { "type": "string" } }, "required": [ "name" ], "additionalProperties": { "type": "string" } } } } ``` <details><summary>Negative test num. 4 - 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": description: 200 response schema: type: object properties: name: type: string tag: type: string required: name additionalProperties: $ref: "#/definitions/User" definitions: User: type: object properties: name: type: string tag: type: string required: name additionalProperties: type: string ``` </details>