How can I define Enum into request model?
class Processors(enum.Enum):
Python = 'python'
class PostRepository(BaseModel):
file: str
processor: Processors
I have such endpoint:
@app.post('/repositories', status_code=201)
async def post_repositories(request: PostRepository):
pass
After starting application, FastAPI don't take Enum field:

The SwaggerUI I find often has trouble displaying Enums. Try the redoc docs at /redoc instead of /docs to see if it's displayed. You can also check the /openapi.json document directly to make sure your Enum is included.
You can still test the endpoint using your enum value, SwaggerUI just doesn't include it in the body for some reason. Might be fixed once Pydantic starts declaring enums as schemas in the next version? Not sure.
Could you try this?
class Processors(str, enum.Enum):
Python = 'python'
class PostRepository(BaseModel):
file: str
processor: Processors
Thanks for the help here everyone! :clap: :bow:
I imagine you solved your problem, so thanks for closing the issue :+1: