wso2 / carbon-apimgt

Apache License 2.0
166 stars 626 forks source link

Add swagger validation for paths with trailing slash #12458

Closed chashikajw closed 2 months ago

chashikajw commented 4 months ago

Purpose

This PR add a swagger validation to validate resource path names. If there are two resource paths with the same name, one with and one without trailing slashes, it will be considered an error since those are considered as one resource in the API deployment.

With this fix, following internal REST APIs provide 400 Bad request in such cases

PUT https://localhost:9443/api/am/publisher/v4/apis/<apiId>/swagger

Response:

{
    "code": 900754,
    "message": "Error while parsing OpenAPI definition",
    "description": "Multiple GET operations with the same resource path /menu found in the openapi definition",
    "moreInfo": "",
    "error": []
}

This validation executes in,

  1. API creation
  2. API update
  3. Import swagger file

Fixes