Skip to content
This repository has been archived by the owner on Mar 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #163 from lendingblock/master
Browse files Browse the repository at this point in the history
1.2.5
  • Loading branch information
lsbardel authored Jan 24, 2019
2 parents c49fa5c + 47c9027 commit 0992d24
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
2 changes: 1 addition & 1 deletion openapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Minimal OpenAPI asynchronous server application"""

__version__ = '1.2.4'
__version__ = '1.2.5'
5 changes: 3 additions & 2 deletions openapi/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ def rest(
base_path: str = None,
commands: typing.List = None,
allowed_tags: typing.Set = None,
validate_docs: bool = False
validate_docs: bool = False,
OpenApiSpecClass: typing.ClassVar = OpenApiSpec
):
"""Create the OpenApi application server
"""
return OpenApiClient(
OpenApiSpec(
OpenApiSpecClass(
OpenApi(**(openapi or {})),
allowed_tags=allowed_tags,
validate_docs=validate_docs
Expand Down
6 changes: 4 additions & 2 deletions openapi/spec/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,15 @@ def build(self, app, public=True, private=False):
))
return doc

def routes(self, app):
return app.router.routes()

def _build_paths(self, app, public, private):
"""Loop through app paths and add
schemas, parameters and paths objects to the spec
"""
paths = self.paths
routes = app.router.routes()
for route in routes:
for route in self.routes(app):
route_info = route.get_info()
path = route_info.get('path', route_info.get('formatter', None))
handler = route.handler
Expand Down
29 changes: 29 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,35 @@ pytest --cov
* Asynchronous DB interaction with [asyncpg](https://github.com/MagicStack/asyncpg)
* Migrations with [alembic](http://alembic.zzzcomputing.com/en/latest/)
* SqlAlchemy tables as python dataclasses
* [Click](https://github.com/pallets/click) command line interface

## Web App

to create an openapi RESTful application:
```python
def create_app():
app = rest(
openapi=dict(
title='A REST API',
...
),
base_path='/v1,
allowed_tags=[...],
validate_docs=True,
setup_app=setup_app,
commands=[...]
)
return app


def setup_app(app):
app.router.add_routes(...)
return app


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

## Websockets

Expand Down

0 comments on commit 0992d24

Please sign in to comment.