Response on operations that should have a body has undefined schema (v3)
- Query id: a92be1d5-d762-484a-86d6-8cd0907ba100
- Query name: Response on operations that should have a body has undefined schema (v3)
- Platform: OpenAPI
- Severity: Medium
- Category: Networking and Firewall
- URL: Github
Description¶
If a response is not head or its code is not 204 or 304, it should have a schema defined
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.com"
}
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response"
}
}
},
"delete": {
"operationId": "deleteVersion",
"summary": "Deletes API versions",
"responses": {
"204": {
"description": "no content"
}
}
}
}
},
"components": {
"schemas": {
"ApiVersion": {
"type": "object",
"discriminator": {
"propertyName": "ApiVersion"
},
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"version": {
"type": "string"
}
}
}
}
}
}
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.com"
}
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response",
"content": {
"application/json": {}
}
}
}
},
"delete": {
"operationId": "deleteVersion",
"summary": "Deletes API versions",
"responses": {
"204": {
"description": "no content"
}
}
}
}
},
"components": {
"schemas": {
"ApiVersion": {
"type": "object",
"discriminator": {
"propertyName": "ApiVersion"
},
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"version": {
"type": "string"
}
}
}
}
}
}
Postitive test num. 3 - 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/pdf": {},
"application/json": {}
}
}
}
},
"post": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiVersion"
}
}
}
}
}
},
"delete": {
"operationId": "deleteVersion",
"summary": "Deletes API versions",
"responses": {
"204": {
"description": "no content"
}
}
}
}
},
"components": {
"schemas": {
"ApiVersion": {
"type": "object",
"discriminator": {
"propertyName": "ApiVersion"
},
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"version": {
"type": "string"
}
}
}
}
}
}
Postitive test num. 4 - 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": {}
}
}
},
"delete": {
"operationId": "deleteVersion",
"summary": "Deletes API versions",
"responses": {
"204": {
"description": "no content"
}
}
}
}
},
"components": {
"schemas": {
"ApiVersion": {
"type": "object",
"discriminator": {
"propertyName": "ApiVersion"
},
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"version": {
"type": "string"
}
}
}
}
}
}
Postitive test num. 5 - yaml 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
delete:
operationId: deleteVersion
summary: Deletes API versions
responses:
"204":
description: no content
components:
schemas:
ApiVersion:
type: object
discriminator:
propertyName: ApiVersion
properties:
code:
type: integer
format: int32
version:
type: string
Postitive test num. 6 - yaml 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: {}
delete:
operationId: deleteVersion
summary: Deletes API versions
responses:
"204":
description: no content
components:
schemas:
ApiVersion:
type: object
discriminator:
propertyName: ApiVersion
properties:
code:
type: integer
format: int32
version:
type: string
Postitive test num. 7 - yaml 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/pdf: {}
application/json: {}
post:
operationId: listVersionsv2
summary: List API versions
responses:
"200":
description: 200 response
content:
application/json:
schema:
"$ref": "#/components/schemas/ApiVersion"
delete:
operationId: deleteVersion
summary: Deletes API versions
responses:
"204":
description: no content
components:
schemas:
ApiVersion:
type: object
discriminator:
propertyName: ApiVersion
properties:
code:
type: integer
format: int32
version:
type: string
Postitive test num. 8 - yaml 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: {}
delete:
operationId: deleteVersion
summary: Deletes API versions
responses:
"204":
description: no content
components:
schemas:
ApiVersion:
type: object
discriminator:
propertyName: ApiVersion
properties:
code:
type: integer
format: int32
version:
type: string
Postitive test num. 9 - json file
{
"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"
}
}
},
"delete": {
"operationId": "deleteVersion",
"summary": "Deletes API versions",
"responses": {
"204": {
"description": "no content"
}
}
}
}
}
}
Postitive test num. 10 - yaml file
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
delete:
operationId: deleteVersion
summary: Deletes API versions
responses:
"204":
description: no content
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.com"
}
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiVersion"
}
}
}
}
}
},
"delete": {
"operationId": "deleteVersion",
"summary": "Deletes API versions",
"responses": {
"204": {
"description": "no content"
}
}
}
}
},
"components": {
"schemas": {
"ApiVersion": {
"type": "object",
"discriminator": {
"propertyName": "ApiVersion"
},
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"version": {
"type": "string"
}
}
}
}
}
}
Negative test num. 2 - yaml 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:
"$ref": "#/components/schemas/ApiVersion"
delete:
operationId: deleteVersion
summary: Deletes API versions
responses:
"204":
description: no content
components:
schemas:
ApiVersion:
type: object
discriminator:
propertyName: ApiVersion
properties:
code:
type: integer
format: int32
version:
type: string
Negative test num. 3 - json file
{
"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": {
"type": "object",
"discriminator": "ApiVersion",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"version": {
"type": "string"
}
}
}
}
}
},
"delete": {
"operationId": "deleteVersion",
"summary": "Deletes API versions",
"responses": {
"204": {
"description": "no content"
}
}
}
}
}
}
Negative test num. 4 - yaml file
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:
type: object
discriminator: ApiVersion
properties:
code:
type: integer
format: int32
version:
type: string
delete:
operationId: deleteVersion
summary: Deletes API versions
responses:
"204":
description: no content