Skip to content

Commit

Permalink
add example project
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-kleiner committed Aug 11, 2019
1 parent 0579603 commit 6685c67
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Reads an openapi spec and provides automatic routing to Falcon resources. This i

This router inherits from the default Falcon CompiledRouter class, so it supports all methods available to the default router.

Supports json files, yaml files, raw json strings, and raw yaml strings. If no params are specified the plugin will attempt to find `openapi-spec.yml` or `openapi-spec.yaml` in the same directory.
Supports json files, yaml files, raw json strings, and raw yaml strings. If no params are specified the plugin will attempt to find `openapi-spec.yml` or `openapi-spec.yaml` in the current working directory (see example for structure).

```python
import falcon
Expand Down
14 changes: 14 additions & 0 deletions example/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
falcon = "*"
gunicorn = "*"
falcon-openapi = "*"

[requires]
python_version = "3.7"
74 changes: 74 additions & 0 deletions example/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file added example/README.md
Empty file.
Empty file added example/look/__init__.py
Empty file.
Empty file added example/look/api/__init__.py
Empty file.
6 changes: 6 additions & 0 deletions example/look/api/controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from look.model.model import model1


class controller1(object):
def on_get(self, req, resp):
resp.body = "test"
11 changes: 11 additions & 0 deletions example/look/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from wsgiref import simple_server

import falcon

from falcon_openapi import OpenApiRouter

api = application = falcon.API(router=OpenApiRouter(file_path="openapi-spec.yaml"))

if __name__ == "__main__":
httpd = simple_server.make_server("127.0.0.1", 8000, api)
httpd.serve_forever()
Empty file added example/look/model/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions example/look/model/model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# just an example class to import in controller


class model1:
pass
11 changes: 11 additions & 0 deletions example/openapi-spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
openapi: "3.0.0"
info:
version: 1.0.0
title: Falcon Openapi Example
license:
name: MIT
paths:
/controller:
get:
summary: summary
operationId: api.controller.controller1.on_get

0 comments on commit 6685c67

Please sign in to comment.