Encoding Map Key Mismatch Schema Defined Properties
- Query id: cd7a52cf-8d7f-4cfe-bbeb-6306d23f576b
- Query name: Encoding Map Key Mismatch Schema Defined Properties
- Platform: OpenAPI
- Severity: Info
- Category: Structure and Semantics
- URL: Github
Description¶
Encoding Map Key should be set in schema defined properties
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Postitive 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.c"
}
},
"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": {
"responses": {
"ResponseExample": {
"description": "200 response",
"content": {
"application/json": {
"schema": {
"discriminator": {
"propertyName": "petType"
},
"properties": {
"code": {
"type": "string",
"format": "binary"
},
"message": {
"type": "string"
}
},
"type": "object"
},
"encoding": {
"profileImage": {
"contentType": "image/png, image/jpeg"
}
}
}
}
}
}
}
}
Postitive 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.c"
}
},
"paths": {
"/": {
"get": {
"responses": {
"200": {
"description": "200 response",
"content": {
"application/json": {
"schema": {
"type": "object",
"discriminator": {
"propertyName": "petType"
},
"properties": {
"code": {
"type": "string",
"format": "binary"
},
"message": {
"type": "string"
}
}
},
"encoding": {
"profileImage": {
"contentType": "image/png, image/jpeg"
}
}
}
}
}
},
"operationId": "listVersionsv2",
"summary": "List API versions"
}
}
}
}
Postitive 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
components:
responses:
ResponseExample:
description: 200 response
content:
application/json:
schema:
type: object
discriminator:
propertyName: petType
properties:
code:
type: string
format: binary
message:
type: string
encoding:
profileImage:
contentType: image/png, image/jpeg
Postitive test num. 4 - 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:
schema:
type: object
discriminator:
propertyName: petType
properties:
code:
type: string
format: binary
message:
type: string
encoding:
profileImage:
contentType: image/png, image/jpeg
Code samples without security vulnerabilities¶
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.c"
}
},
"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": {
"responses": {
"ResponseExample": {
"description": "200 response",
"content": {
"application/json": {
"schema": {
"discriminator": {
"propertyName": "petType"
},
"properties": {
"code": {
"type": "string",
"format": "binary"
},
"message": {
"type": "string"
}
},
"type": "object"
},
"encoding": {
"code": {
"contentType": "image/png, image/jpeg"
}
}
}
}
}
}
}
}
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.c"
}
},
"paths": {
"/": {
"get": {
"responses": {
"200": {
"description": "200 response",
"content": {
"application/json": {
"schema": {
"type": "object",
"discriminator": {
"propertyName": "petType"
},
"properties": {
"code": {
"type": "string",
"format": "binary"
},
"message": {
"type": "string"
}
}
},
"encoding": {
"code": {
"contentType": "image/png, image/jpeg"
}
}
}
}
}
},
"operationId": "listVersionsv2",
"summary": "List API versions"
}
}
}
}
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
components:
responses:
ResponseExample:
description: 200 response
content:
application/json:
schema:
type: object
discriminator:
propertyName: petType
properties:
code:
type: string
format: binary
message:
type: string
encoding:
code:
contentType: image/png, image/jpeg
Negative test num. 4 - 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:
schema:
type: object
discriminator:
propertyName: petType
properties:
code:
type: string
format: binary
message:
type: string
encoding:
code:
contentType: image/png, image/jpeg