fastapi-code-generator icon indicating copy to clipboard operation
fastapi-code-generator copied to clipboard

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

Open Aedial opened this issue 2 years ago • 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.

Aedial avatar Nov 23 '22 20:11 Aedial

Minimal working example :

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

Aedial avatar Nov 23 '22 20:11 Aedial

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

harryjubb avatar Jul 03 '23 10:07 harryjubb