OperationId Not Unique (v3)
- Query id: c254adc4-ef25-46e1-8270-b7944adb4198
- Query name: OperationId Not Unique (v3)
- Platform: OpenAPI
- Severity: Info
- Category: Structure and Semantics
- URL: Github
Description¶
OperationId should be unique when defined
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",
"contact": {
"name": "contact",
"url": "https://google.com",
"email": "user@gmail.com"
}
},
"paths": {
"/": {
"get": {
"operationId": "operation_id",
"responses": {
"200": {
"description": "200 response",
"content": {
"application/json": {
"examples": {
"foo": {
"value": {
"versions": [
{
"status": "CURRENT",
"updated": "2011-01-21T11:33:21Z",
"id": "v2.0",
"links": [
{
"href": "http://127.0.0.1:8774/v2/",
"rel": "self"
}
]
}
]
}
}
}
}
}
}
}
},
"post": {
"operationId": "operation_id",
"responses": {
"201": {
"description": "Created"
}
}
}
}
}
}
Positive test num. 2 - yaml file
openapi: 3.0.0
info:
title: Simple API overview
version: 1.0.0
paths:
"/":
get:
operationId: op_id
responses:
"200":
description: 200 response
content:
application/json:
examples:
foo:
value:
versions:
- status: CURRENT
updated: "2011-01-21T11:33:21Z"
id: v2.0
links:
- href: http://127.0.0.1:8774/v2/
rel: self
post:
operationId: op_id
responses:
"201":
description: Created
Positive test num. 3 - json file
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0",
"contact": {
"name": "contact",
"url": "https://google.com",
"email": "user@gmail.com"
}
},
"paths": {
"/": {
"get": {
"operationId": "operation_id",
"responses": {
"200": {
"description": "200 response"
}
}
},
"post": {
"operationId": "operation_id",
"responses": {
"201": {
"description": "Created"
}
}
}
}
}
}
Positive test num. 4 - yaml file
Code samples without security vulnerabilities¶
Negative test num. 1 - json file
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0",
"contact": {
"name": "contact",
"url": "https://google.com",
"email": "user@gmail.com"
}
},
"paths": {
"/": {
"get": {
"operationId": "op_id1",
"responses": {
"200": {
"description": "200 response",
"content": {
"application/json": {
"examples": {
"foo": {
"value": {
"versions": [
{
"status": "CURRENT",
"updated": "2011-01-21T11:33:21Z",
"id": "v2.0",
"links": [
{
"href": "http://127.0.0.1:8774/v2/",
"rel": "self"
}
]
}
]
}
}
}
}
}
}
}
},
"post": {
"operationId": "op_id2",
"responses": {
"201": {
"description": "Created"
}
}
}
}
}
}
Negative test num. 2 - yaml file
openapi: 3.0.0
info:
title: Simple API overview
version: 1.0.0
paths:
"/":
get:
operationId: op_id3
responses:
"200":
description: 200 response
content:
application/json:
examples:
foo:
value:
versions:
- status: CURRENT
updated: "2011-01-21T11:33:21Z"
id: v2.0
links:
- href: http://127.0.0.1:8774/v2/
rel: self
post:
operationId: op_id4
responses:
"201":
description: Created
Negative test num. 3 - json file
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0",
"contact": {
"name": "contact",
"url": "https://google.com",
"email": "user@gmail.com"
}
},
"paths": {
"/": {
"get": {
"operationId": "op_id1",
"responses": {
"200": {
"description": "200 response"
}
}
},
"post": {
"operationId": "op_id2",
"responses": {
"201": {
"description": "Created"
}
}
}
}
}
}