Body Parameter Without Schema
- Query id: ed48229d-d43e-4da7-b453-5f98d964a57a
- Query name: Body Parameter Without Schema
- Platform: OpenAPI
- Severity: Info
- Category: Structure and Semantics
- URL: Github
Description¶
The Body Parameter Object should have the attribute 'schema' defined
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Positive test num. 1 - json file
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"parameters": [
{
"name": "limit2",
"in": "body",
"description": "max records to return",
"required": true
}
],
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response"
}
}
}
}
},
"parameters": {
"limitParam": {
"name": "limit",
"in": "body",
"description": "max records to return",
"required": true
}
}
}
Positive 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
parameters:
- name: limit2
in: body
description: max records to return
required: true
parameters:
limitParam:
name: limit
in: body
description: max records to return
required: true
Code samples without security vulnerabilities¶
Negative test num. 1 - json file
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"parameters": [
{
"name": "limit2",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer"
}
}
],
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response"
}
}
}
}
},
"parameters": {
"limitParam": {
"name": "limit",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer"
}
}
}
}
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
parameters:
- name: limit2
in: body
description: max records to return
required: true
schema:
type: object
parameters:
limitParam:
name: limit
in: body
description: max records to return
required: true
schema:
type: object