Responses JSON Reference Does Not Exists (v2)
- Query id: e9db5fb4-6a84-4abb-b4af-3b94fbdace6d
- Query name: Responses JSON Reference Does Not Exists (v2)
- Platform: OpenAPI
- Severity: Info
- Category: Structure and Semantics
- URL: Github
Description¶
Responses reference should exist on responses definition field
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/Succes"
}
}
}
}
},
"responses": {
"Success": {
"description": "An array with users",
"schema": {
"$ref": "#/definitions/User"
}
}
},
"definitions": {
"User": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}
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/Succes"
responses:
Success:
description: An array with users
schema:
"$ref": "#/definitions/User"
definitions:
User:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
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"
}
}
}
}
},
"responses": {
"Success": {
"description": "An array with users",
"schema": {
"$ref": "#/definitions/User"
}
}
},
"definitions": {
"User": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}
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"
responses:
Success:
description: An array with users
schema:
"$ref": "#/definitions/User"
definitions:
User:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string