
Product
Introducing Webhook Events for Pull Request Scans
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
aiohttp-swagger3
Advanced tools
.. image:: https://github.com/hh-h/aiohttp-swagger3/actions/workflows/ci.yaml/badge.svg?branch=master :target: https://github.com/hh-h/aiohttp-swagger3/actions .. image:: https://img.shields.io/codecov/c/github/hh-h/aiohttp-swagger3/master.svg?style=flat :target: https://codecov.io/github/hh-h/aiohttp-swagger3?branch=master .. image:: https://badge.fury.io/py/aiohttp-swagger3.svg :target: https://badge.fury.io/py/aiohttp-swagger3 .. image:: https://img.shields.io/badge/python-3.7%2B-brightgreen.svg :target: https://img.shields.io/badge/python-3.7%2B-brightgreen.svg .. image:: https://img.shields.io/badge/code%20style-black-black.svg :target: https://github.com/ambv/black .. image:: https://img.shields.io/pypi/l/aiohttp-swagger3.svg :target: https://www.apache.org/licenses/LICENSE-2.0
Package for displaying swagger docs via different UI backends and optionally validating/parsing aiohttp requests using swagger specification 3.0, known as OpenAPI3.
Multiple UI backends can be used or UI backend can be disabled at all if only needed validation without being able to view documentation.
https://aiohttp-swagger3.readthedocs.io/en/latest/
| Pass validate=False
to SwaggerDocs
/SwaggerFile
class, the default is True
| Also, sometimes validation has to be disabled for a route,
to do this you have to pass validate=False
during the initialization of the route.
| ex. web.post("/route", handler, validate=False)
, the default is True
handler <https://github.com/hh-h/aiohttp-swagger3/tree/master/examples/custom_handler>
__pip install aiohttp-swagger3
.. code:: python
from aiohttp import web
from aiohttp_swagger3 import SwaggerDocs, SwaggerInfo, SwaggerUiSettings
async def get_one_pet(request: web.Request, pet_id: int) -> web.Response:
"""
Optional route description
---
summary: Info for a specific pet
tags:
- pets
parameters:
- name: pet_id
in: path
required: true
description: The id of the pet to retrieve
schema:
type: integer
format: int32
responses:
'200':
description: Expected response to a valid request
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
"""
if pet_id not in request.app['storage']:
raise web.HTTPNotFound()
return web.json_response(request.app['storage'][pet_id])
def main():
app = web.Application()
swagger = SwaggerDocs(
app,
swagger_ui_settings=SwaggerUiSettings(path="/docs/"),
info=SwaggerInfo(
title="Swagger Petstore",
version="1.0.0",
),
components="components.yaml"
)
swagger.add_routes([
web.get("/pets/{pet_id}", get_one_pet),
])
app['storage'] = {}
web.run_app(app)
More examples <https://github.com/hh-h/aiohttp-swagger3/tree/master/examples>
_
.. image:: https://raw.githubusercontent.com/hh-h/aiohttp-swagger3/master/docs/_static/comparison.png
FAQs
validation for aiohttp swagger openAPI 3
We found that aiohttp-swagger3 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.
Product
A single platform for static analysis, secrets detection, container scanning, and CVE checks—built on trusted open source tools, ready to run out of the box.