koxudaxi/fastapi-code-generator

Path '#-datamodel-code-generator-#-root-#-special-#' is added to the '/' endpoint

Aedial opened this issue · 2 comments

When generating from a schema with a '/' endpoint, the root path ('#-datamodel-code-generator-#-root-#-special-#') is added to the endpoint, transforming it into '/#-datamodel-code-generator-#-root-#-special-#'.
When used as a fastapi endpoint, '/' returns 404, showing that the it broke the endpoint. The endpoint responds normally when the root path is removed manually.

Minimal working example :

{
  "paths": {
    "/": {
      "get": {
        "operationId": "GetRoot",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          }
        }
      }
    }
  }
}

I'm also hitting this bug. Any reason why this is happening, and is there anything that can be done to avoid it?