Verified Commit c6addbf6 authored by Dan Jones's avatar Dan Jones
Browse files

fix: remove definitions from raw schema

This is a workaround until a new version of Flasgger
is released.
parent c69ad579
......@@ -114,10 +114,30 @@ def serve():
"""
Run as local flask app on port 5000
"""
# Replace schema route to remove invalid
# definitions: {}
# Should be fixed if Flassger 0.9.7 is released
#
# The last release of flasgger was Aug 2020
# This bug was fixed in Nov 2021
# There is a pre-release from May 2023
# Until the fix gets released we have to
# remove the invalid definitions object
# from the spec
app = Flask(__name__)
Swagger(app, config=swagger_config, merge=True)
app.run(debug=False, host=FLASK_HOST, port=FLASK_PORT)
@app.after_request
def after_request_decorator(response):
if type(response).__name__ == 'Response':
if response.content_type == 'application/json':
data = response.json
if 'definitions' in data:
del data['definitions']
response.data = json.dumps(data)
return response
app.run(debug=True, host=FLASK_HOST, port=FLASK_PORT)
def compile_schema(swagger_config):
......@@ -136,13 +156,6 @@ def compile_schema(swagger_config):
client = app.test_client()
response = client.get(route)
spec = response.json
# The last release of flasgger was Aug 2020
# This bug was fixed in Nov 2021
# There is a pre-release from May 2023
# Until the fix gets released we have to
# remove the invalid definitions object
# from the spec
del spec['definitions']
return spec
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment