cebe / php-openapi

Read and write OpenAPI yaml/json files and make the content accessible in PHP objects.
MIT License
464 stars 87 forks source link

Duplicate OperationIds should be considered invalid #181

Open charjr opened 1 year ago

charjr commented 1 year ago

Expected

Calling validate on a \cebe\openapi\spec\OpenApi object containing duplicate operationIds will return false.

Reasoning

OperationIds MUST be unique among all operations described in the API.

Actual

Calling validate on a \cebe\openapi\spec\OpenApi object containing duplicate operationIds returns true.

Example

$api = Reader::readFromJson(<<<JSON
{
  "openapi": "3.0.0",
  "info": {
    "title": "Test API",
    "version": "1.0.0"
  },
  "paths": {
    "/path": {
      "get": {
        "operationId": "op1",
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      },
      "post": {
        "operationId": "op1",
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    }
  }
}
JSON);

var_dump($api->validate()); // bool(true)