All Projects → hh-h → aiohttp-swagger3

hh-h / aiohttp-swagger3

Licence: Apache-2.0 license
Library for swagger documentation browsing and validating aiohttp requests using swagger specification 3.0

Programming Languages

python
139335 projects - #7 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to aiohttp-swagger3

aio-openapi
A python module for building OpenAPI compliant asynchronous Rest Servers. Auto documentation, serialization and validation in the same unified API.
Stars: ✭ 27 (-50%)
Mutual labels:  aiohttp, openapi3
Rororo
Implement aiohttp.web OpenAPI 3 server applications with schema first approach.
Stars: ✭ 95 (+75.93%)
Mutual labels:  aiohttp, openapi3
aioScrapy
基于asyncio与aiohttp的异步协程爬虫框架 欢迎Star
Stars: ✭ 34 (-37.04%)
Mutual labels:  aiohttp
python-logi-circle
Python 3.6+ API for Logi Circle cameras
Stars: ✭ 23 (-57.41%)
Mutual labels:  aiohttp
megadlbot oss
Megatron was a telegram file management bot that helped a lot of users, specially movie channel managers to upload their files to telegram by just providing a link to it. The project initially started as roanuedhuru_bot which lately retired and came back as Megatron which was a side project of the famous Maldivian Telegram community - @baivaru u…
Stars: ✭ 151 (+179.63%)
Mutual labels:  aiohttp
opg
Rust OpenAPI 3.0 docs generator
Stars: ✭ 30 (-44.44%)
Mutual labels:  openapi3
Pyro-FileStreamBot
Stream Telegram files to web
Stars: ✭ 38 (-29.63%)
Mutual labels:  aiohttp
whook
Build strong and efficient REST web services.
Stars: ✭ 18 (-66.67%)
Mutual labels:  openapi3
fizz
🍋 Gin wrapper with OpenAPI 3 spec generation
Stars: ✭ 139 (+157.41%)
Mutual labels:  openapi3
yutto
🧊 一个可爱且任性的 B 站视频下载器(bilili V2)
Stars: ✭ 383 (+609.26%)
Mutual labels:  aiohttp
OpenAlchemy
Define SQLAlchemy models using the OpenAPI specification.
Stars: ✭ 39 (-27.78%)
Mutual labels:  openapi3
Pyaiodl
A python Asynchronous Downloader - Pyaiodl
Stars: ✭ 40 (-25.93%)
Mutual labels:  aiohttp
aioneo4j
asyncio client for neo4j
Stars: ✭ 29 (-46.3%)
Mutual labels:  aiohttp
go-types
Library providing opanapi3 and Go types for store/validation and transfer of ISO-4217, ISO-3166, and other types.
Stars: ✭ 14 (-74.07%)
Mutual labels:  openapi3
aiohttp-three-template
Project template for Python aiohttp three-tier web applications
Stars: ✭ 20 (-62.96%)
Mutual labels:  aiohttp
python3-concurrency
Python3爬虫系列的理论验证,首先研究I/O模型,分别用Python实现了blocking I/O、nonblocking I/O、I/O multiplexing各模型下的TCP服务端和客户端。然后,研究同步I/O操作(依序下载、多进程并发、多线程并发)和异步I/O(asyncio)之间的效率差别
Stars: ✭ 49 (-9.26%)
Mutual labels:  aiohttp
openapi-generator-go
An opinionated OpenAPI v3 code generator for Go. Use this to generate API models and router scaffolding.
Stars: ✭ 42 (-22.22%)
Mutual labels:  openapi3
oas
OpenAPI Spec builder in go
Stars: ✭ 15 (-72.22%)
Mutual labels:  openapi3
HibiAPI
一个实现了多种常用站点的易用化API的程序 / A program that implements easy-to-use APIs for a variety of commonly used sites.
Stars: ✭ 427 (+690.74%)
Mutual labels:  openapi3
tomodachi
💻 Microservice library / framework using Python's asyncio event loop with full support for HTTP + WebSockets, AWS SNS+SQS, RabbitMQ / AMQP, middleware, etc. Extendable for GraphQL, protobuf, gRPC, among other technologies.
Stars: ✭ 170 (+214.81%)
Mutual labels:  aiohttp

aiohttp-swagger3

https://travis-ci.com/hh-h/aiohttp-swagger3.svg?branch=master https://img.shields.io/codecov/c/github/hh-h/aiohttp-swagger3/master.svg?style=flat

About

Package for displaying swagger docs via different UI backends and optionally validating/parsing aiohttp requests using swagger specification 3.0, known as OpenAPI3.

Supported UI backends

Multiple UI backends can be used or UI backend can be disabled at all if only needed validation without being able to view documentation.

Documentation

https://aiohttp-swagger3.readthedocs.io/en/latest/

Disable validation

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

Requirements

  • python >= 3.7
  • aiohttp >= 3.5.4
  • pyyaml >= 5.3
  • attrs >= 19.3.0
  • python-fastjsonschema >= 2.14.3
  • strict_rfc3339 == 0.7

Limitations

  • only application/json and application/x-www-form-urlencoded supported for now, but you can create own handler
  • header/query parameters only supported simple/form array serialization, e.g. 1,2,3,4
  • see TODO below

Installation

pip install aiohttp-swagger3

Example

from aiohttp import web
from aiohttp_swagger3 import SwaggerDocs, 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/"),
        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

How it helps

https://raw.githubusercontent.com/hh-h/aiohttp-swagger3/master/docs/_static/comparison.png

Features

  • application/json
  • application/x-www-form-urlencoded (except array and object)
  • items
  • properties
  • pattern
  • required
  • enum
  • minimum, maximum
  • exclusiveMinimum, exclusiveMaximum
  • minLength, maxLength
  • minItems, maxItems
  • uniqueItems
  • minProperties, maxProperties
  • default (only primitives)
  • additionalProperties
  • nullable
  • readOnly
  • allOf, oneOf, anyOf
  • string formats: date, date-time, byte, email, uuid, hostname, ipv4, ipv6
  • custom string format validators

TODO (raise an issue if needed)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].