Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aamalev/aiohttp_apiset
Package to build routes using swagger specification
https://github.com/aamalev/aiohttp_apiset
aiohttp asyncio python
Last synced: 7 days ago
JSON representation
Package to build routes using swagger specification
- Host: GitHub
- URL: https://github.com/aamalev/aiohttp_apiset
- Owner: aamalev
- License: apache-2.0
- Created: 2015-10-05T14:06:30.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-12-19T08:58:19.000Z (20 days ago)
- Last Synced: 2024-12-25T17:05:49.362Z (14 days ago)
- Topics: aiohttp, asyncio, python
- Language: Python
- Homepage: http://aiohttp-apiset.readthedocs.io/
- Size: 584 KB
- Stars: 41
- Watchers: 5
- Forks: 9
- Open Issues: 12
-
Metadata Files:
- Readme: README.rst
- Changelog: HISTORY.rst
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
aiohttp-apiset
==============.. 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/hatchPackage 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 middlewareUsecase
-------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
-------.. code-block:: python
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=3Examples: `examples `_
Development
-----------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