Skip to content

MEP 2 - Building a Flask <> Pydantic autogeneration tool

  • Author: Rodda John
  • Status: Adopted
  • Adopted: 2023-10-15

Decision

We chose to build a library (currently in utils/api) that:

  • Uses route type annotations to parse args and construct responses
  • Uses route type annotations to generate OpenAPI spec

Alternatives

  • flask-pydantic
  • spectree
  • flask-pydantic-spec
  • FastAPI

flask-pydantic

  • Does not generate OpenAPI spec
  • Much of the interface and some of the implementation is ripped from here

spectree & flask-pydantic-spec

  • flask-pydantic-spec is a fork of spectree
  • Few (< 500) stars on Github; limited community + support

FastAPI

  • Flask is considerably more trusted + long-lived
    • Patrick & Rodda's experience is with Flask
  • Reversible: can embed Flask routes within FastAPI
    • Perhaps important for async support