-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganized core app to be more modular, allows for FileField swagger
- Loading branch information
Showing
6 changed files
with
61 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Setup API docs and Swagger | ||
from .core import app | ||
from .auth import add_auth_to_swagger | ||
from apispec import APISpec | ||
from flask_apispec.extension import FlaskApiSpec | ||
import webargs as wa | ||
from apispec.ext.marshmallow import MarshmallowPlugin | ||
|
||
file_plugin = MarshmallowPlugin() | ||
spec = APISpec( | ||
title='neuroscout', | ||
version='v1', | ||
plugins=[file_plugin], | ||
openapi_version='2.0' | ||
) | ||
app.config.update({ | ||
'APISPEC_SPEC': spec}) | ||
add_auth_to_swagger(spec) | ||
|
||
docs = FlaskApiSpec(app) | ||
|
||
|
||
@file_plugin.map_to_openapi_type('file', None) | ||
class FileField(wa.fields.Raw): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from .. import resources | ||
from ..models import * | ||
|
||
|
||
def route_factory(app, docs, pairings, prepend='/api/'): | ||
""" Create API routes and add to app """ | ||
for res_name, route in pairings: | ||
res = getattr(resources, res_name) | ||
app.add_url_rule(prepend + route, | ||
view_func=res.as_view(res_name.lower())) | ||
docs.register(res) |