Skip to content

Commit c2460b9

Browse files
committed
Add openapi docs
1 parent e1bed92 commit c2460b9

File tree

8 files changed

+91
-23
lines changed

8 files changed

+91
-23
lines changed

sanic-api/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ Run the applicaton,
3030
$ python run.py
3131
```
3232

33-
Then vist [http://127.0.0.1:5000](http://127.0.0.1:5000).
33+
Then visit [http://127.0.0.1:8000](http://127.0.0.1:8000).
34+
35+
36+
The API docs visit [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs).
3437

3538
Happy Coding!

sanic-api/app/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from sanic import Sanic
22

33
from .config import get_config
4-
from .routes import setup_routes
54

65
from . import blueprints
76

@@ -11,6 +10,8 @@ def create_app(env):
1110
config = get_config(env)
1211
app.update_config(config)
1312

13+
app.config.OAS_URL_PREFIX = "/docs"
14+
1415
app.blueprint(blueprints.auth.bp, url_prefix='/auth/')
1516
app.blueprint(blueprints.hello.bp, url_prefix='/api/')
1617

sanic-api/app/config/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ class BaseConfig:
44
DEBUG = False
55
TESTING = False
66
DATABASE_URI = 'sqlite:///:memory:'
7+
OAS_URL_PREFIX = '/docs'
8+

sanic-api/app/routes.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

sanic-api/app/views.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

sanic-api/poetry.lock

Lines changed: 80 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sanic-api/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ readme = "README.md"
88

99
[tool.poetry.dependencies]
1010
python = "^3.12"
11-
sanic = "^23.12.1"
11+
sanic = {extras = ["ext"], version = "^23.12.1"}
1212
setuptools = "^70.0.0"
1313

1414

sanic-api/run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77

88
if __name__ == '__main__':
99
if env == 'production':
10-
app.run(host='127.0.0.1', port=5000)
10+
app.run(host='127.0.0.1', port=8000)
1111
else:
12-
app.run(host='127.0.0.1', port=5000, debug=True)
12+
app.run(host='127.0.0.1', port=8000, debug=True)

0 commit comments

Comments
 (0)