Skip to content

Commit

Permalink
feat: provide simple default openapi spec
Browse files Browse the repository at this point in the history
  • Loading branch information
e-cloud committed Aug 12, 2019
1 parent 224dbf4 commit 09f16f9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ $env:FLASK_APP="application.py" # or set the var in `.env`
python -m flask run #(use -p to specify binding port)
```

NOTE: the swagger docs is at http://localhost:5000/docs/swagger

## Todo List

Expand Down
3 changes: 3 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import logging
import os

from tools.openapi_default import SPEC_OPTIONS

log = logging.getLogger(__name__)


Expand All @@ -21,6 +23,7 @@ class Config:
OPENAPI_URL_PREFIX = '/docs'
OPENAPI_SWAGGER_UI_PATH = '/swagger'
OPENAPI_SWAGGER_UI_VERSION = '3.23.4'
API_SPEC_OPTIONS = SPEC_OPTIONS

PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))

Expand Down
10 changes: 10 additions & 0 deletions tools/openapi_default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SPEC_OPTIONS = {
'info': {'description': 'Server API document'},
'servers': [
{
'url': 'http://localhost:{port}/',
'description': 'The development API server',
'variables': {'port': {'enum': ['5000', '8888'], 'default': '5000'}},
}
],
}

0 comments on commit 09f16f9

Please sign in to comment.