Parameter JSON Reference Does Not Exist (v3)
- Query id: 2e275f16-b627-4d3f-ae73-a6153a23ae8f
- Query name: Parameter JSON Reference Does Not Exist (v3)
- Platform: OpenAPI
- Severity: Info
- Category: Structure and Semantics
- CWE: 20
- URL: Github
Description¶
Parameter 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"
}
},
"parameters": [
{
"$ref": "#/components/parameters/wrongParameter"
}
]
}
}
},
"components": {
"parameters": {
"limitParam": {
"name": "limit",
"in": "query",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer"
}
}
}
}
}
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"
parameters:
- "$ref": "#/components/parameters/wrongParameter"
components:
parameters:
limitParam:
name: limit
in: query
description: max records to return
required: true
schema:
type: integer
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"
}
},
"parameters": [
{
"$ref": "#/components/parameters/limitParam"
}
]
}
}
},
"components": {
"parameters": {
"limitParam": {
"name": "limit",
"in": "query",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer"
}
}
}
}
}
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"
parameters:
- "$ref": "#/components/parameters/limitParam"
components:
parameters:
limitParam:
name: limit
in: query
description: max records to return
required: true
schema:
type: integer