aide icon indicating copy to clipboard operation
aide copied to clipboard

Multiple path parameters from tuple are ignored

Open tomas789 opened this issue 4 months ago • 2 comments

When the path has multiple parameters, Axum supports two ways of passing them to the handler. First is to make a struct which is then parsed. This use case works well. Second is to accept it as tuple. Both cases presented in Axum documentation.

The tuple-based path is not handled properly by Aide. I have made a small change to the example to demonstrate the issue.

I defined two new handlers using both approaches. The function depends_on_todo_struct has its OpenAPI spec as follows

    "/todo/{id}/depends-on-with-struct/{depends_on_id}": {
      "put": {
        "description": "Todo depends on another Todo.",
        "parameters": [
          {
            "in": "path",
            "name": "depends_on_id",
            "description": "The ID of the Todo that this Todo depends on.",
            "required": true,
            "schema": {
              "description": "The ID of the Todo that this Todo depends on.",
              "type": "string",
              "format": "uuid"
            },
            "style": "simple"
          },
          {
            "in": "path",
            "name": "id",
            "description": "The ID of the Todo.",
            "required": true,
            "schema": {
              "description": "The ID of the Todo.",
              "type": "string",
              "format": "uuid"
            },
            "style": "simple"
          }
        ],
        "responses": {
          "...": "..."
        }
      }
    },

The function is missing the parameters field completely

    "/todo/{id}/depends-on/{depends_on_id}": {
      "put": {
        "description": "Todo depends on another Todo.",
        "responses": {
          "...": "..."
        }
      }
    },

tomas789 avatar Feb 13 '24 13:02 tomas789