Callback JSON Reference Does Not Exist
- Query id: f29904c8-6041-4bca-b043-dfa0546b8079
- Query name: Callback JSON Reference Does Not Exist
- Platform: OpenAPI
- Severity: Info
- Category: Structure and Semantics
- CWE: 20
- URL: Github
Description¶
Callback reference should exist on components field
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Positive 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": {
"onProgress": {
"{$request.body#/onProgressUrl}": {
"delete": {
"responses": {
"204": {
"description": "Deleted"
}
}
}
}
}
}
}
}
Positive 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:
onProgress:
"{$request.body#/onProgressUrl}":
delete:
responses:
'204':
description: Deleted
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}": {
"delete": {
"responses": {
"204": {
"description": "Deleted"
}
}
}
}
}
}
}
}
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}":
delete:
responses:
'204':
description: Deleted