Metadata-Version: 2.4
Name: aiohttp-apiset
Version: 0.9.17
Summary: Build routes using swagger specification
Project-URL: Homepage, https://github.com/aamalev/aiohttp_apiset/
Project-URL: Documentation, http://aiohttp-apiset.readthedocs.io/en/latest/?badge=latest
Project-URL: Issues, https://github.com/aamalev/aiohttp-apiset/issues
Project-URL: Source, https://github.com/aamalev/aiohttp-apiset
Author-email: Alexander Malev <malev@somedev.ru>
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: aiohttp,apiset
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Internet :: WWW/HTTP
Requires-Python: >=3.5.3
Requires-Dist: aiohttp<4,>=3
Requires-Dist: jsonschema
Requires-Dist: pyyaml
Provides-Extra: dev-lint
Requires-Dist: black==23.3.0; extra == 'dev-lint'
Requires-Dist: isort==5.12.0; extra == 'dev-lint'
Requires-Dist: mypy==1.3.0; extra == 'dev-lint'
Requires-Dist: ruff==0.0.270; extra == 'dev-lint'
Requires-Dist: types-jsonschema; extra == 'dev-lint'
Requires-Dist: types-pyyaml; extra == 'dev-lint'
Provides-Extra: dev-test
Requires-Dist: pytest; extra == 'dev-test'
Requires-Dist: pytest-aiohttp<1; extra == 'dev-test'
Requires-Dist: pytest-cov; extra == 'dev-test'
Requires-Dist: pytest-mock; extra == 'dev-test'
Provides-Extra: docs
Requires-Dist: sphinx-rtd-theme; extra == 'docs'
Requires-Dist: sphinx>=1.4.8; extra == 'docs'
Provides-Extra: jinja2
Requires-Dist: aiohttp-jinja2; extra == 'jinja2'
Description-Content-Type: text/x-rst

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/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/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.

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 <https://github.com/swagger-api/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
-------

.. 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=3


Examples: `examples <https://github.com/aamalev/aiohttp_apiset/tree/master/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
