Skip to content
Discussion options

You must be logged in to vote

The reason is because your dependency isnt taking an Enum any more it is taking a string so the openapi generator reflects that.

A better approach might be to write a custom exception handler to handle the exception from pydantic to return what you would prefer.

You can read some in the docs here https://fastapi.tiangolo.com/tutorial/handling-errors/#override-request-validation-exceptions

Then you wont need the dependency and your endpoint can simply list the enum type like you do with name_valid_representation.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@vicente23
Comment options

Answer selected by vicente23
Comment options

You must be logged in to vote
2 replies
@jgould22
Comment options

@smarie
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
3 participants