Skip to content

Flask-RESTX Models Re-Design #59

Open
@SteadBytes

Description

@SteadBytes

For quite some time there have been significant issues around data models, request
parsing and response marshalling in flask-restx (carried over from
flask-restplus). The most obvious of which is the deprecation warning
about the reqparse module in the documentation that has been in place for far
too long
. These changes have been put off for various reasons which I won't
discuss here, however now the new fork is steadily underway I (and no doubt others) would like
to start addressing this.

Since this digs quite deep into the architecture of flask-restx there will be
significant (and likely breaking) changes required. As such, this issue is to
serve as a discussion around the API we would like to provide and some initial
ideas
of how to best proceed. This is not intended to be the starting point of
hacking something together which makes things worse!

I will set out my current thoughts on the topic, please contribute by adding
more points and expanding on mine with more discussion.

High Level Goals:

  • Uniform API for request parsing and response marshalling
    • e.g. remove the separation between reqparse and models
  • Generate correct and valid Swagger/OpenAPI Specifications
  • Validation of input and output data should conform to the generated
    Swagger/OpenAPI Specifications
    • e.g. If the Swagger/OpenAPI spec considers a value valid, the model should too.
  • Define models using JSON Schema
    • Supported already, but with numerous issues (@j5awry has been battling for some time)
  • OpenAPI 3 support

General Issues/Discussion Points

  • What should the API look like?
    • Continue with the api.marshal , api.doc decorator style?
    • How to define models?
      • Do we force direct usage of another library e.g. Marshmallow or wrap in
        some other API and use the library for the "under the hood" work?
  • Model validation
    • External libraries e.g. Marshmallow
  • Schema Generation
    • External libraries e.g. Marshmallow
  • Backwards compatibility
    • Continue to support reqparse and existing models interface?
    • Swagger 2.0 vs OpenAPI 3.0
      • IMO generating both should be a goal if possible

Resources/Notable Libraries

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions