apiflask

A lightweight Python web API framework.

MIT License

Downloads
114K
Stars
977
Committers
48

Bot releases are hidden (Show)

apiflask - Version 0.10.1

Published by greyli almost 3 years ago

Bugfix release:

  • Fix missing headers for JSON error responses when catching Werkzeug exceptions (issue #173).
apiflask - Version 0.10.0

Published by greyli about 3 years ago

Features:

  • Add parameter extra_data to abort and HTTPError, it accepts a dict that will be added
    to the error response (#125).
from apiflask import abort

@app.get('/')
def missing():
    abort(404, message='nothing', extra_data={'code': '123', 'status': 'not_found'})
  • Support passing operation_id in the doc decorator (docs).
@app.get('/')
@doc(operation_id='myCustomHello')
def hello():
    pass
  • Support setting response links via @output(links=...) (docs).
pet_links = {
    'getAddressByUserId': {
        'operationId': 'getUserAddress',
        'parameters': {
            'userId': '$request.path.id'
        }
    }
}

@app.post('/pets')
@output(PetOutSchem, links=pet_links)
def new_pet(data):
    pass
  • Support using add_url_rule method on view classes.

Undocumented breaking changes:

  • Only expose marshmallow fields, validators, and Schema in APIFlask.
  • Remove the status_code field from the default error response (#124).
apiflask - Version 0.9.0

Published by greyli about 3 years ago

Breaking change:

  • Custom error processor now should accept an HTTPError object instead of individual error information:
@app.error_processor
def my_error_processor(error):
    return {
        'status_code': error.status_code,
        'message': error.message,
        'errors': error.detail
    }, error.status_code, error.headers

Features:

  • Support base response schema customization (docs). See a full example at here.
  • Support setting custom schema name resolver via the APIFlask.schema_name_resolver attribute (docs).
  • Support to config Redoc via the configuration variable REDOC_CONFIG:
app.config['REDOC_CONFIG'] = {'disableSearch': True, 'hideLoading': True}

There are also some improvements on error handling, see the full changelog for more details: https://apiflask.com/changelog/#version-090

apiflask - Version 0.8.0

Published by greyli over 3 years ago

This is the first stable version. From this version, all breaking changes will start with a deprecated warning.

Some major changes in this version:

  • Automatically add a 404 response in OpenAPI spec for routes contains URL
    variables:
@app.get('/pets/<id>')
def get_pet(id):
    pass

So user don't need to set a 404 response manually:

@app.get('/pets/<id>')
@doc(responses=[404])
def get_pet(id):
    pass
  • The app.spec property now will always return the latest spec instead of the cached one (docs):
>>> from apiflask import APIFlask
>>> app = APIFlask(__name__)
>>> app.spec
{'info': {'title': 'APIFlask', 'version': '0.1.0'}, 'tags': [], 'paths': OrderedDict(), 'openapi': '3.0.3'}
>>> @app.get('/')
... def hello():
...     return {'message': 'Hello'}
...
>>> app.spec
{'info': {'title': 'APIFlask', 'version': '0.1.0'}, 'tags': [], 'paths': OrderedDict([('/', {'get': {'parameters': [], 'responses': OrderedDict([('200', {'content': {'application/json': {'schema': {}}}, 'description': 'Successful response'})]), 'summary': 'Hello'}})]), 'openapi': '3.0.3'}
>>>
  • Add configration variable INFO (and app.info attribute), it can be used to set the following info fields: description, termsOfService, contact, license (docs):
app.info = {
    'description': '...',
    'termsOfService': 'http://example.com',
    'contact': {
        'name': 'API Support',
        'url': 'http://www.example.com/support',
        'email': '[email protected]'
    },
    'license': {
        'name': 'Apache 2.0',
        'url': 'http://www.apache.org/licenses/LICENSE-2.0.html'
    }
}

  • Rename the following configuration variables:
    • AUTO_PATH_SUMMARY -> AUTO_OPERATION_SUMMARY
    • AUTO_PATH_DESCRIPTION -> AUTO_OPERATION_DESCRIPTION

See details in the changelog: https://github.com/greyli/apiflask/blob/main/CHANGES.md#version-080

apiflask - Version 0.7.0

Published by greyli over 3 years ago

Some major changes in this version:

  • Add a flask spec command to output the OpenAPI spec to stdout or a file (docs).
  • Support keeping the local spec in sync automatically (docs).
  • Re-add the SPEC_FORMAT config. Remove the auto-detection of the format from APIFlask(spec_path=...) (docs).
  • Fix auto-tag support for nesting blueprint.
  • Add a new docs chapter for OpenAPI generating: https://apiflask.com/openapi/

See more in the changelog: https://github.com/greyli/apiflask/blob/main/CHANGES.md#version-070

apiflask - Version 0.6.3

Published by greyli over 3 years ago

Improve static request dispatch (https://github.com/greyli/apiflask/pull/54).

apiflask - Version 0.6.2

Published by greyli over 3 years ago

Fix static request dispatch issue for Flask 2.0 (https://github.com/greyli/apiflask/issues/52).

apiflask - Version 0.6.1

Published by greyli over 3 years ago

A bugfix release for Flask 2.0:

  • Fix various type annotation issues.
  • Fix async support.

See the changelog for the details:

https://github.com/greyli/apiflask/blob/master/CHANGES.md#version-061

apiflask - Version 0.6.0

Published by greyli over 3 years ago

This release is mainly for Flask 2.0.

  • Support using async def that comes in Flask 2.0.
  • Add some helpers for pagination (example application).

Seet the changelog for more details.

apiflask - Version 0.5.2

Published by greyli over 3 years ago

A bugfix release.

  • Allow returning a Response object in a view function decorated with output decorator. In this case, APIFlask will do nothing but return it directly.
  • Skip Flask's Blueprint objects when generating the OpenAPI spec
apiflask - Version 0.5.1

Published by greyli over 3 years ago

A bugfix release.

apiflask - Version 0.5.0

Published by greyli over 3 years ago

The core feature added in this version is class-based views support. Check out the example application or documentation for more details.

This version also introduces some breaking changes:

  • Remove the configuration variable DOCS_HIDE_BLUEPRINTS, add APIBlueprint.enable_openapi
    as a replacement.
  • Remove the support to generate info.description and tag description from the module
    docstring, and also remove the AUTO_DESCRIPTION config.
  • No longer support mix the use of flask.Bluerpint and apiflask.APIBluerpint.

See the changelog for more details.

0.5.0 Changelog: https://github.com/greyli/apiflask/blob/master/CHANGES.md#version-050

apiflask - Version 0.4.0

Published by greyli over 3 years ago

This version introduces some breaking changes:

  • Rename abort_json() to abort().
  • Some undocumented configuration variables were deleted.

There are also some bug fixes and new features. Check out the changelog for the details.

0.4.0 Changelog: https://github.com/greyli/apiflask/blob/master/CHANGES.md#version-040

apiflask - Version 0.3.0

Published by greyli over 3 years ago

This is the first public version.

This version has some API change, public API changes including:

  • Rename function api_abort() to abort_json().
  • Change decorator attribute @doc(tags) to @doc(tag).

Besides, this version has basic type annotations for the package, the tests will be updated in the next version.

Check out the changelog for the details.

0.3.0 Changelog: https://github.com/greyli/apiflask/blob/master/CHANGES.md#version-030

apiflask - Version 0.2.0

Published by greyli over 3 years ago

From version 0.2.0, this project became a framework instead of a Flask extension. It provided two classes to replace the one in Flask:

  • flask.Flask -> apiflask.APIFlask
  • flask.Blueprint -> apiflask.APIBlueprint

This version also added some more useful features, a bunch of configuration variables, and changed almost all the APIs. Check out the changelog for the details.

Changelog: https://github.com/greyli/apiflask/blob/master/CHANGES.md#version-020

apiflask - Version 0.1.0

Published by greyli over 3 years ago

Based on APIFairy 0.6.3dev, version 0.1.0 added some useful features, check out the changelog for the details.

Package Rankings
Top 3.03% on Pypi.org
Badges
Extracted from project README's
Build status codecov
Related Projects