2
2
rororo
3
3
======
4
4
5
- .. image :: https://img.shields.io/circleci/project/github/playpauseandstop/rororo/master .svg
5
+ .. image :: https://img.shields.io/circleci/project/github/playpauseandstop/rororo/feature-openapi .svg
6
6
:target: https://circleci.com/gh/playpauseandstop/rororo
7
7
:alt: CircleCI
8
8
18
18
:target: https://github.com/playpauseandstop/rororo/blob/master/LICENSE
19
19
:alt: BSD License
20
20
21
- .. image :: https://coveralls.io/repos/playpauseandstop/rororo/badge.svg?branch=master &service=github
21
+ .. image :: https://coveralls.io/repos/playpauseandstop/rororo/badge.svg?branch=feature-openapi &service=github
22
22
:target: https://coveralls.io/github/playpauseandstop/rororo
23
23
:alt: Coverage
24
24
@@ -33,7 +33,51 @@ applications.
33
33
As well as bunch other utilities to build effective web applications with
34
34
Python 3 & ``aiohttp.web ``.
35
35
36
- * Works on Python 3.5 +
36
+ * Works on Python 3.6 +
37
37
* BSD licensed
38
38
* Source, issues, and pull requests `on GitHub
39
39
<https://github.com/playpauseandstop/rororo> `_
40
+
41
+ Quick Start
42
+ ===========
43
+
44
+ ``rororo `` relies on valid OpenAPI schema file (both JSON or YAML formats
45
+ supported).
46
+
47
+ Example below, illustrates on how to handle operation ``hello_world `` from
48
+ `openapi.yaml <https://github.com/playpauseandstop/rororo/blob/feature-openapi/tests/openapi.yaml >`_
49
+ schema file.
50
+
51
+ .. code-block :: python
52
+
53
+ from pathlib import Path
54
+
55
+ from aiohttp import web
56
+
57
+ from rororo import openapi_context, OperationTableDef, setup_openapi
58
+
59
+
60
+ operations = OperationTableDef()
61
+
62
+
63
+ @operations.register
64
+ async def hello_world (request : web.Request) -> web.Response:
65
+ with openapi_context(request) as context:
66
+ name = context.parameters.query.get(" name" , " world" )
67
+ return web.json_response({" message" : f " Hello, { name} ! " })
68
+
69
+
70
+ def create_app (argv : List[str ] = None ) -> web.Application:
71
+ app = web.Application()
72
+ setup_openapi(
73
+ app,
74
+ Path(__file__ ).parent / " openapi.yaml" ,
75
+ operations,
76
+ route_prefix = " /api"
77
+ )
78
+ return app
79
+
80
+ Check
81
+ `examples <https://github.com/playpauseandstop/rororo/tree/feature-openapi/examples >`_
82
+ folder to see other examples on how to use OpenAPI 3 schemas with aiohttp.web
83
+ applications.
0 commit comments