Issue 1:
First Check

I added a very descriptive title to this issue.

I used the GitHub search to find a similar issue and didn't find it.

I searched the FastAPI documentation, with the integrated search.

I already searched in Google "How to X in FastAPI" and didn't find any information.

I already read and followed all the tutorial in the docs and didn't find an answer.

I already checked if it is not related to FastAPI but to Pydantic.

I already checked if it is not related to FastAPI but to Swagger UI.

I already checked if it is not related to FastAPI but to ReDoc.

Commit to Help

I commit to help with one of those options 👆

Example Code

val = 1

async def functionOne(self) -> JSONResponse:
try:
await addOne(); // adds one to value.
return JSONResponse(status_code=200, content={"message": "example"})
except ValueError as e:
return JSONResponse(status_code=400, content={"message": e.args[0]})

router.get('/example')(self.functionOne)

Description

the value of the val should be 2 but getting 3 because I am getting duplicate requests in a single hit.

Operating System

Linux

Operating System Details

Linux

FastAPI Version

0.70.1

Python Version

3.8

Additional Context

No response

Issue 2:
First check

I added a very descriptive title to this issue.

I used the GitHub search to find a similar issue and didn't find it.

I searched the FastAPI documentation, with the integrated search.

I already searched in Google "How to X in FastAPI" and didn't find any information.

I already read and followed all the tutorial in the docs and didn't find an answer.

I already checked if it is not related to FastAPI but to Pydantic.

I already checked if it is not related to FastAPI but to Swagger UI.

I already checked if it is not related to FastAPI but to ReDoc.

After submitting this, I commit to one of:

Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.

I already hit the "watch" button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future.

Implement a Pull Request for a confirmed bug.

Example

Here's a self-contained, minimal, reproducible, example with my use case:

main.py

from fastapi import FastAPI

import router1
import router2

app = FastAPI()

app.include_router(router1.router, prefix="/r1")
app.include_router(router2.router, prefix="/r2")

router1.py

from enum import Enum

from fastapi import APIRouter

class DuplicatedEnum(str, Enum):
value1 = "value1"

router = APIRouter()

@router.get("/")
async def _(type: DuplicatedEnum = DuplicatedEnum.value1):
pass

router2.py

from enum import Enum

from fastapi import APIRouter

class DuplicatedEnum(str, Enum):
value2 = "value2"

router = APIRouter()

@router.get("/")
async def _(type: DuplicatedEnum = DuplicatedEnum.value2):
pass

Description

Open the browser and call the document /redoc.

It raised error Error resolving $ref pointer "http://127.0.0.1:8000/openapi.json#/components/schemas/DuplicatedEnum". Token "DuplicatedEnum" does not exist.

After I checked openapi.json, it gives wrong parameter schema:

{
"openapi": "3.0.2",
"info": {
"title": "FastAPI",
"version": "0.1.0"
},
"paths": {
"/r1/": {
"get": {
"summary": " ",
"operationId": "__r1__get",
"parameters": [{
"required": false,
"schema": {
"allOf": [{
"$ref": "#/components/schemas/DuplicatedEnum" //should be `router1__DuplicatedEnum`
}],
"default": "value1"
},
"name": "type",
"in": "query"
}],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/r2/": {
"get": {
"summary": " ",
"operationId": "__r2__get",
"parameters": [{
"required": false,
"schema": {
"allOf": [{
"$ref": "#/components/schemas/DuplicatedEnum"
}],
"default": "value2"
},
"name": "type",
"in": "query"
}],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"HTTPValidationError": {
"title": "HTTPValidationError",
"type": "object",
"properties": {
"detail": {
"title": "Detail",
"type": "array",
"items": {
"$ref": "#/components/schemas/ValidationError"
}
}
}
},
"ValidationError": {
"title": "ValidationError",
"required": ["loc", "msg", "type"],
"type": "object",
"properties": {
"loc": {
"title": "Location",
"type": "array",
"items": {
"type": "string"
}
},
"msg": {
"title": "Message",
"type": "string"
},
"type": {
"title": "Error Type",
"type": "string"
}
}
},
"router1__DuplicatedEnum": {
"title": "DuplicatedEnum",
"enum": ["value1"],
"type": "string",
"description": "An enumeration."
},
"router2__DuplicatedEnum": {
"title": "DuplicatedEnum",
"enum": ["value2"],
"type": "string",
"description": "An enumeration."
}
}
}
}

Environment

OS: [e.g. Linux / Windows / macOS]: Linux

FastAPI Version [e.g. 0.3.0]: 0.63.0

Python version: 3.9.1