Code Monkey home page Code Monkey logo

aiohttp_apiset's Introduction

aiohttp-apiset

image

image

image

Documentation Status

image

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
  • 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

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

aiohttp_apiset's People

Contributors

aamalev avatar pyup-bot avatar dependabot[bot] avatar abogushov avatar hh-h avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.