Project: KICS (Provisioning / Security & Compliance)
File: c254adc4-ef25-46e1-8270-b7944adb4198.md

title: OperationId Not Unique (v3) hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: c254adc4-ef25-46e1-8270-b7944adb4198 Query name: OperationId Not Unique (v3) Platform: OpenAPI Severity: <span style="color:#5bc0de">Info</span> Category: Structure and Semantics URL: OperationId should be unique when defined<br> ```json title="Positive test num. 1 - json file" hl_lines="46 15" { "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" } } } } } } ``` ```yaml title="Positive test num. 2 - yaml file" hl_lines="8 25" 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 ``` ```json title="Positive test num. 3 - json file" hl_lines="23 15" { "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" } } } } } } ``` <details><summary>Positive test num. 4 - yaml file</summary> ```yaml hl_lines="8 13" swagger: "2.0" info: title: Simple API overview version: 1.0.0 paths: "/": get: operationId: op_id responses: "200": description: 200 response post: operationId: op_id responses: "201": description: Created ``` </details> ```json title="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" } } } } } } ``` ```yaml title="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 ``` ```json title="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" } } } } } } ``` <details><summary>Negative test num. 4 - yaml file</summary> ```yaml swagger: "2.0" info: title: Simple API overview version: 1.0.0 paths: "/": get: operationId: op_id3 responses: "200": description: 200 response post: operationId: op_id4 responses: "201": description: Created ``` </details>