[Python] How to expose Enum to FastAPI OpenAPI schema?

Discussão em 'Python' iniciado por Stack, Agosto 6, 2025.

  1. Stack

    Stack Membro Participativo

    When using Literal[MyEnum.CONSTANT] in BaseModel definition, MyEnum is not correctly provided to the openapi.json definition.

    We are using OpenAPI to expose backend types to our front-end UI.

    In this case, the Enum is not properly shared with the front-end.

    How can one force FastAPI to expose it?

    Continue reading...

Compartilhe esta Página