Releases: apiflask/apiflask
Version 0.10.1
Bugfix release:
- Fix missing headers for JSON error responses when catching Werkzeug exceptions (issue #173).
Version 0.10.0
Features:
- Add parameter
extra_data
toabort
andHTTPError
, 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 thedoc
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
, andSchema
in APIFlask. - Remove the
status_code
field from the default error response (#124).
Version 0.9.0
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
Version 0.8.0
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
(andapp.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
Version 0.7.0
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 fromAPIFlask(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
Version 0.6.3
Improve static request dispatch (#54).
Version 0.6.2
Fix static request dispatch issue for Flask 2.0 (#52).
Version 0.6.1
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
Version 0.6.0
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.
Version 0.5.2
A bugfix release.
- Allow returning a
Response
object in a view function decorated withoutput
decorator. In this case, APIFlask will do nothing but return it directly. - Skip Flask's
Blueprint
objects when generating the OpenAPI spec