Created
May 27, 2013 20:36
-
-
Save dnordberg/5658957 to your computer and use it in GitHub Desktop.
Routes for Swagger json resources.
This file contains hidden or 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
from flask import Response | |
RE_API_DOCS_BASE_PATH = re.compile(r'"basePath": "(.*)\/api\/') | |
API_SANDBOX_URL = '"basePath": "http://localhost:5000/api/' | |
@app.route('/api/v1/api-docs', methods=['GET']) | |
def api_docs_index(): | |
return Response(RE_API_DOCS_BASE_PATH.sub(API_SANDBOX_URL, | |
open('./docs/api/v1/index.json').read()), | |
mimetype='application/json') | |
@app.route('/api/v1/api-docs/<resource>', methods=['GET']) | |
def api_docs(resource): | |
return Response(RE_API_DOCS_BASE_PATH.sub(API_SANDBOX_URL, | |
open('./docs/api/v1/{}.json'.format(resource)).read()), | |
mimetype='application/json') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment