Global Responses Definition Not Being Used
- Query id: 0b76d993-ee52-43e0-8b39-3787d2ddabf1
- Query name: Global Responses Definition Not Being Used
- Platform: OpenAPI
- Severity: Info
- Category: Best Practices
- URL: Github
Description¶
All global responses definitions should be in use
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Postitive 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": {
"$ref": "#/responses/Success"
}
},
"parameters": [
{
"name": "limit2",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "string"
},
"desc": {
"type": "string"
}
}
]
}
}
},
"responses": {
"Success": {
"description": "200 response"
},
"IllegalInput": {
"description": "Illegal input for operation."
},
"GeneralError": {
"description": "General Error"
}
}
}
Postitive 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":
$ref: "#/responses/Success"
parameters:
- name: limit2
in: body
description: max records to return
required: true
schema:
type: string
desc:
type: string
responses:
Success:
description: "200 response"
IllegalInput:
description: Illegal input for operation.
GeneralError:
description: General Error
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": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"$ref": "#/responses/Success"
}
},
"parameters": [
{
"name": "limit2",
"in": "body",
"description": "max records to return",
"required": true,
"schema": {
"type": "string"
},
"desc": {
"type": "string"
}
}
]
}
}
},
"responses": {
"Success": {
"description": "200 response"
}
}
}
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":
$ref: "#/responses/Success"
parameters:
- name: limit2
in: body
description: max records to return
required: true
schema:
type: string
desc:
type: string
responses:
Success:
description: "200 response"