You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@app.get("/pets/<int:pet_id>")@app.input(Accept, location="headers")@app.output(PetOut) # still have a main response of media type 'application/json'@app.doc(responses={200: {'description': 'Return the resource in either JSON or HTML','content': {'text/html': {} # have an additional media type for the main response } }})defget_pet(pet_id, headers_data):
pet=pets[pet_id]
# depending on the content of the `Accept` header we may return JSON or HTMLif"html"inheaders_data.get('accept'):
result=render_template('pets/pet-detail.j2.html', pet=pet)
else:
result=petreturnresult
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Major features
Support adding decorators to the openapi endpoints
by @FarmerChillax in #508
You can the newly added config keys to add auth protect to the OpenAPI endpoints:
See the complete example here: https://github.com/apiflask/apiflask/blob/main/examples/openapi/custom_decorators/app.py
Allow adding multiple media types for a response
by @ricardogsilva in #495
Support adding response headers schema
by @uncle-lv in #511
The
app.output
decorator now accepts aheaders
argument:Add file validators
FileSize
andFileType
for File fieldby @uncle-lv in #485
See the complete example here: https://github.com/apiflask/apiflask/blob/main/examples/file_upload/app.py
What's Changed
New Contributors
Full Changelog: 2.0.2...2.1.0
This discussion was created from the release Version 2.1.0.
Beta Was this translation helpful? Give feedback.
All reactions