aiohttp-apiset¶
Package to build routes and validate request using swagger specification 2.0.
Features¶
- Building of the routing from specification swagger
- Using inclusions other specifications with concatenate url
- Optional output of the resulting specification and view embed swagger-ui
- Advanced router with TreeResource
- Extract specify parameters from request and validate with jsonschema
- Serialize data as response with middleware
Usecase¶
Package aiohttp_apiset allows supports several strategies:
- The foreign specification. When the specification is made and maintained by another team.
- The specification in the code. When the fragments of specification are placed in the docstrings.
- Mixed strategy. When routing are located in the specification files and operations are described in the docstrings.
Example¶
async def handler(request, pet_id):
"""
---
tags: [Pet]
description: Info about pet
parameters:
- name: pet_id
in: path
type: integer
minimum: 0
responses:
200:
description: OK
400:
description: Validation error
404:
description: Not found
"""
pet = await db.pets.find(pet_id)
if not pet:
return {'status': 404, 'msg': 'Not Found'}
return {
'pet': pet, # dict serialized inside jsonify
}
def main():
router = SwaggerRouter(
swagger_ui='/swagger/',
version_ui=2,
)
router.add_get('/pets/{pet_id}', handler=handler)
app = web.Application(
router=router,
middlewares=[jsonify],
)
web.run_app(app)
Is now available in the swagger-ui to the address http://localhost:8080/swagger/. Available both branch swagger-ui. For use branch 3.x visit http://localhost:8080/swagger/?version=3
Examples: examples
Documentation contents¶
- Installation
- Using with aiohttp application
- Directives
- Swagger router
- Operations
- History
- 0.9.4 (2018-08-09)
- 0.9.3 (2018-07-26)
- 0.9.2 (2018-07-04)
- 0.9.1 (2018-05-08)
- 0.9 (2018-03-26)
- 0.8.1 (2018-02-25)
- 0.8.0 (2018-02-22)
- 0.7.4 (2017-12-22)
- 0.7.3 (2017-11-01)
- 0.7.2 (2017-10-31)
- 0.7.1 (2017-10-31)
- 0.7.0 (2017-10-23)
- 0.6.2 (2017-08-29)
- 0.6.1 (2017-08-26)
- 0.6 (2017-08-25)
- 0.5.2 (2017-06-21)
- 0.5.1 (2017-06-20)
- 0.5.0 (2017-06-16)
- 0.4.5 (2017-05-27)
- 0.4.4 (2017-05-26)
- 0.4.3 (2017-05-26)
- 0.4.2 (2017-04-28)
- 0.4.1 (2017-03-26)
- 0.4.0 (2017-03-22)
- 0.3.4 (2016-12-20)
- 0.3.3 (2016-12-16)
- 0.3.2 (2016-12-14)
- 0.3.1 (2016-11-25)
- 0.3.0 (2016-11-24)
- 0.2.5 (2016-11-08)
- 0.2.4 (2016-11-06)
- 0.2.3 (2016-11-05)
- 0.2.2 (2016-10-28)
- 0.2.1 (2016-10-27)
- 0.2.0 (2016-10-26)
- 0.1.13 (2016-05-02)