Components Callback Definition Is Unused
- Query id: d15db953-a553-4b8a-9a14-a3d62ea3d79d
- Query name: Components Callback Definition Is Unused
- Platform: OpenAPI
- Severity: Info
- Category: Best Practices
- URL: Github
Description¶
Components callbacks definitions should be referenced or removed from Open API definition
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"
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"$ref": "#/components/schemas/Success"
}
}
}
}
},
"components": {
"callbacks": {
"inProgress": {
"{$request.body#/inProgressUrl}": {
"post": {
"requestBody": {
"$ref": "#/components/requestBodies/callbackMessage1"
},
"responses": {
"200": {
"description": "OK"
}
}
}
}
}
}
}
}
Postitive test num. 2 - 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':
"$ref": "#/components/schemas/Success"
components:
callbacks:
inProgress:
"{$request.body#/inProgressUrl}":
post:
requestBody:
"$ref": "#/components/requestBodies/callbackMessage1"
responses:
'200':
description: OK
Code samples without security vulnerabilities¶
Negative test num. 1 - json file
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"$ref": "#/components/schemas/Success"
}
},
"callbacks": {
"myEvent": {
"$ref": "#/components/callbacks/inProgress"
}
}
}
}
},
"components": {
"callbacks": {
"inProgress": {
"{$request.body#/inProgressUrl}": {
"post": {
"requestBody": {
"$ref": "#/components/requestBodies/callbackMessage1"
},
"responses": {
"200": {
"description": "OK"
}
}
}
}
}
}
}
}
Negative test num. 2 - 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":
$ref: "#/components/schemas/Success"
callbacks:
myEvent:
$ref: "#/components/callbacks/inProgress"
components:
callbacks:
inProgress:
"{$request.body#/inProgressUrl}":
post:
requestBody:
$ref: "#/components/requestBodies/callbackMessage1"
responses:
"200":
description: OK