.. image:: https://github.com/aamalev/aiohttp_apiset/workflows/Tests/badge.svg :target: https://github.com/aamalev/aiohttp_apiset/actions?query=workflow%3ATests
.. image:: https://codecov.io/gh/aamalev/aiohttp_apiset/branch/master/graph/badge.svg :target: https://codecov.io/gh/aamalev/aiohttp_apiset :alt: Coverage
.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v0.json :target: https://github.com/charliermarsh/ruff :alt: Code style: ruff
.. image:: https://img.shields.io/badge/types-Mypy-blue.svg :target: https://github.com/python/mypy :alt: Code style: Mypy
.. image:: https://img.shields.io/pypi/v/aiohttp_apiset.svg :target: https://pypi.python.org/pypi/aiohttp_apiset
.. image:: https://readthedocs.org/projects/aiohttp-apiset/badge/?version=latest :target: http://aiohttp-apiset.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status
.. image:: https://img.shields.io/pypi/pyversions/aiohttp_apiset.svg :target: https://pypi.python.org/pypi/aiohttp_apiset
.. image:: https://img.shields.io/pypi/dm/aiohttp-apiset.svg :target: https://pypi.org/project/aiohttp-apiset
.. image:: https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg :alt: Hatch project :target: https://github.com/pypa/hatch
Package to build routes and validate request using swagger specification 2.0.
swagger-ui <https://github.com/swagger-api/swagger-ui>
_Package aiohttp_apiset allows supports several strategies:
.. code-block:: python
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 <https://github.com/aamalev/aiohttp_apiset/tree/master/examples>
_
Check code:
.. code-block:: shell
hatch run lint:all
Format code:
.. code-block:: shell
hatch run lint:fmt
Run tests:
.. code-block:: shell
hatch run pytest
Run tests with coverage:
.. code-block:: shell
hatch run cov