Giter Site home page Giter Site logo

quantmind / aio-openapi Goto Github PK

View Code? Open in Web Editor NEW
35.0 35.0 3.0 1.47 MB

A python module for building OpenAPI compliant asynchronous Rest Servers. Auto documentation, serialization and validation in the same unified API.

Home Page: https://aio-openapi.readthedocs.io

License: BSD 3-Clause "New" or "Revised" License

Shell 0.23% Python 98.84% Mako 0.38% Makefile 0.55%
aiohttp asyncio database dataclasses openapi-documentation openapi3 postgresql rest-api validation-library websockets

aio-openapi's People

Contributors

conorstevenson avatar daniloaf avatar jklepatch avatar krotkiewicz avatar lsbardel avatar markharley avatar qmbot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

aio-openapi's Issues

InvalidSpecException: Missing tag "Index" description

I am trying to create a basic web app without a database and i keep getting a error openapi.spec.exceptions.InvalidSpecException: Missing tag "Index" description

If i comment out validate_docs=True, it all works but that would defeat the purpose of OpenAPI

Any idea what is wrong, hopefully I am just missing something.

The full trace is

thughes@krypton [0] $ python example.py --verbose serve
======== Running on http://0.0.0.0:8080 ========
(Press CTRL+C to quit)
Error handling request
Traceback (most recent call last):
  File "/home/thughes/.local/share/virtualenvs/xopenapi-1bFmqCwq/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/home/thughes/.local/share/virtualenvs/xopenapi-1bFmqCwq/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/home/thughes/.local/share/virtualenvs/xopenapi-1bFmqCwq/lib/python3.7/site-packages/openapi/spec/spec.py", line 435, in spec_root
    app['spec_doc'] = app['spec'].build(app)
  File "/home/thughes/.local/share/virtualenvs/xopenapi-1bFmqCwq/lib/python3.7/site-packages/openapi/spec/spec.py", line 239, in build
    self._build_paths(app, public, private)
  File "/home/thughes/.local/share/virtualenvs/xopenapi-1bFmqCwq/lib/python3.7/site-packages/openapi/spec/spec.py", line 284, in _build_paths
    self._validate_tags()
  File "/home/thughes/.local/share/virtualenvs/xopenapi-1bFmqCwq/lib/python3.7/site-packages/openapi/spec/spec.py", line 292, in _validate_tags
    f'Missing tag "{tag_name}" description'
openapi.spec.exceptions.InvalidSpecException: Missing tag "Index" description
INFO: openapi: 127.0.0.1 [04/Mar/2019:22:53:25 +0000] "GET /v1/spec HTTP/1.1" 500 334 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0"

Here is my cutdown example

#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8

from aiohttp import web
from openapi.rest import rest
from openapi.spec import op
from openapi.spec.path import ApiPath


def create_app():
    return rest(
        openapi=dict(
            title='A REST API',
        ),
        base_path='/v1',
        allowed_tags=[],
        validate_docs=True,
        setup_app=setup_app,
        commands=[]
    )


def setup_app(app):
    app.router.add_routes([
        web.view('/', Index)
        ])
    return app


class Index(ApiPath):
    """
    ---
    summary: Index
    description: Index page
    tags:
        - Index
    """

    @op()
    async def index(self):
        """
        ---
        summary: Get Index
        description: Displays the Index
        responses:
            200:
                description: Index page
        """
        return {}


if __name__ == '__main__':
    create_app().main()

As a side note, having a bunch of working examples would be very useful. Feel free to use this one once it is working.

Validation with items missing field name

The following dataclass

@dataclass
class Permission:
    methods: List[str] = fields.data_field(
        description="Http methods affected by this permission",
        items=fields.str_field(
            description="Http method",
            validator=fields.Choice(ALL_HTTP_METHODS),
        ),
    )
    path: str = fields.str_field(description="api path", required=True)
    action: str = fields.str_field(
        validator=fields.Choice(("allow", "deny")), default="allow"
    )

raise the following validation error when methods has wrong values.

{'errors': [{'field': 'permissions', 'message': {'null': 'foo not valid'}}]}

the field is missing and null is inserted instead

`update_one` fails with empty body

sqlalchemy lets us generate invalid SQL when no values are passed to update (UPDATE <table> SET;), and we don't catch the resulting exception.

Add search by column

We want to be able to search (postgres ilike style). Let's start with one column with intent to extend to multicolumn search

Support filter operations

We want to specify available operations as an argument to the field constructors, and have this reflected in both the spec filter utilities and the rendered spec itself.

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.