Package: quart-openapi
Documentation can be found onhttps://factset.github.io/quart-openapi/Quart-OpenAPI is an extension forQuartthat adds support for generating a openapi.json file using openapi 3.0.
If you are familiar withQuart, this just wraps around it to add a openapi.json route similar toFlask-RESTXgenerating a swagger.json route and adds a Resource base class for building RESTful APIs.CompatibilityQuart-OpenAPI requires Python 3.6+ becauseQuartrequires it.Starting from version 1.6.0, Quart-OpenAPI requires python 3.7+ in order to avoid having to maintain multiple versions
of function definitions for compatibility with the older versions ofQuartthat supported Python 3.6.InstallationYou can install via pip$pipinstallquart-openapiIf you are developing the module and want to also be able to build the documentation, make sure
to also install the dependencies from the extras ‘doc’ package like so:$pipinstall'quart-openapi[doc]'$pythonsetup.pybuild_sphinxQuick StartIf you’re familiar withQuartthen the quick start doesn’t change much:fromquart_openapiimportPint,Resourceapp=Pint(__name__,title='Sample App')@app.route('/')classRoot(Resource):asyncdefget(self):'''Hello World Route

    This docstring will show up as the description and short-description
    for the openapi docs for this route.
    '''return"hello"This is equivalent to using the following withQuartas normal:fromquartimportQuartapp=Quart(__name__)@app.route('/')asyncdefhello():return"hello"Except that by usingPintandResourceit will also
add a route for ‘/openapi.json’ which will contain the documentation of the route and use the docstring for the
description.Unit TestsUnit tests can be run through setuptools also:$pythonsetup.pytestRequest ValidationRequest validation like you can get withFlask-RESTX!You can either create validator models on the fly or you can create a jsonschema document for base models
and then use references to it. For an on-the-fly validator:expected=app.create_validator('sample_request',{'type':'object','properties':{'foobar':{'type':'string'},'baz':{'oneOf':[{'type':'integer'},{'type':'number','format':'float'}]}}})@app.route('/')classSample(Resource):@app.expect(expected)asyncdefpost(self):# won't get here if the request didn't match the expected schemadata=awaitrequest.get_json()returnjsonify(data)The default content type is ‘application/json’, but you can specify otherwise in the decorator:{"$schema":"http://json-schema.org/schema#","id":"schema.json","components":{"schemas":{"binaryData":{"type":"string","format":"binary"}}}}app=Pint(__name__,title='Validation Example',base_model_schema='schema.json')stream=app.create_ref_validator('binaryData','schemas')@app.route('/')classBinary(Resource):@app.expect((stream,'application/octet-stream',{'description':'gzip compressed data'}))@app.response(HTTPStatus.OK,'Success')asyncdefpost(self):# if the request didn't have a 'content-type' header with a value# of 'application/octet-stream' it will be rejected as invalid.raw_data=awaitrequest.get_data(raw=True)# ... do something with the datareturn"Success!"In the example above, it’ll open, read, and json parse the fileschema.jsonand then use it as the basis
for referencing models and creating validators. Currently the validator won’t do more than validate content-type
for content-types other than ‘application/json’.