Project: KICS (Provisioning / Security & Compliance)
File: 40d3df21-c170-4dbe-9c02-4289b51f994f.md

title: Schema Discriminator Mismatch Defined Properties (v3) hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 40d3df21-c170-4dbe-9c02-4289b51f994f Query name: Schema Discriminator Mismatch Defined Properties (v3) Platform: OpenAPI Severity: <span style="color:#5bc0de">Info</span> Category: Structure and Semantics URL: Schema discriminator values should match defined properties.<br> ```json title="Positive test num. 1 - json file" hl_lines="53" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "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": "integer", "format": "int32" }, "message": { "type": "string" } }, "required": [ "petType" ] } } } } ``` ```json title="Positive test num. 2 - json file" hl_lines="25" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response", "content": { "application/json": { "schema": { "type": "object", "discriminator": { "propertyName": "petType" }, "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" } }, "required": [ "petType" ] }, "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" } ] } ] } } } } } } } } } } } ``` ```yaml title="Positive test num. 3 - yaml file" hl_lines="32" 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: schemas: GeneralError: type: object discriminator: propertyName: petType properties: code: type: string format: int32 message: type: string required: petType ``` <details><summary>Positive test num. 4 - yaml file</summary> ```yaml hl_lines="18" 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: object discriminator: propertyName: petType properties: code: type: string format: int32 message: type: string required: petType 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: [] ``` </details> <details><summary>Positive test num. 5 - json file</summary> ```json hl_lines="28" { "swagger": "2.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response" } } } } }, "definitions": { "GeneralError": { "type": "object", "discriminator": "petType", "properties": { "code": { "type": "string", "format": "int32" }, "message": { "type": "string" } }, "required": [ "petType" ] } } } ``` </details> <details><summary>Positive test num. 6 - yaml file</summary> ```yaml 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 definitions: GeneralError: type: object discriminator: petType properties: code: type: string format: int32 message: type: string required: petType ``` </details> <details><summary>Positive test num. 7 - json file</summary> ```json hl_lines="25" { "swagger": "2.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response", "schema": { "required": [ "petType" ], "type": "object", "discriminator": "petType", "properties": { "code": { "type": "string", "format": "int32" }, "message": { "type": "string" } } } } } } } } } ``` </details> <details><summary>Positive test num. 8 - yaml file</summary> ```yaml hl_lines="15" 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 discriminator: petType properties: code: type: string format: int32 message: type: string required: petType ``` </details> ```json title="Negative test num. 1 - json file" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "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":

"rel": "self" } ] } ] } } } } } } } } } }, "components": { "schemas": { "GeneralError": { "type": "object", "discriminator": { "propertyName": "petType" }, "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "petType": { "type": "string" } }, "required": [ "petType" ] } } } } ``` ```json title="Negative test num. 2 - json file" { "openapi": "3.0.0", "info": { "title": "Simple API Overview", "version": "1.0.0", "contact": { "name": "contact", "url": "https://www.google.com/", "email": "user@gmail.com" } }, "paths": { "/": { "get": { "operationId": "listVersionsv2", "summary": "List API versions", "responses": { "200": { "description": "200 response", "content": { "application/json": { "schema": { "type": "object", "discriminator": { "propertyName": "petType" }, "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "petType": { "type": "string" } }, "required": [ "petType" ] }, "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" } ] } ] } } } } } } } } } } } ``` ```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: "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: schemas: GeneralError: type: object discriminator: propertyName: petType properties: code: type: string format: int32 message: type: string petType: type: string required: petType ``` <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: "200": description: 200 response content: application/json: schema: type: object discriminator: propertyName: petType properties: code: type: string format: int32 message: type: string petType: type: string required: petType 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: [] ``` </details> <details><summary>Negative test num. 5 - 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 definitions: GeneralError: type: object discriminator: petType properties: code: type: string format: int32 petType: type: string required: petType ``` </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": description: 200 response schema: type: object discriminator: petType properties: code: type: string format: int32 petType: type: string required: petType ``` </details>