-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from MinaFoundation/disallow-query-params
Specify swagger UI version and disallow query params
- Loading branch information
Showing
2 changed files
with
23 additions
and
3 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*_test.env | ||
*_test*.env | ||
|
||
.env | ||
env.sh |
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 |
---|---|---|
|
@@ -50,16 +50,25 @@ def get_snark_conn(): | |
}, | ||
"host": BaseConfig.SWAGGER_HOST, # overrides localhost:500 | ||
"basePath": "/uptimescore", # base bash for blueprint registration | ||
"schemes": ["https", "http" ], | ||
"schemes": ["https", "http"], | ||
"operationId": "uptimescore", | ||
} | ||
|
||
swagger_config = Swagger.DEFAULT_CONFIG | ||
swagger_config["swagger_ui_bundle_js"] = ( | ||
"//unpkg.com/[email protected]/swagger-ui-bundle.js" | ||
) | ||
swagger_config["swagger_ui_standalone_preset_js"] = ( | ||
"//unpkg.com/[email protected]/swagger-ui-standalone-preset.js" | ||
) | ||
swagger_config["jquery_js"] = "//unpkg.com/[email protected]/dist/jquery.min.js" | ||
swagger_config["swagger_ui_css"] = "//unpkg.com/[email protected]/swagger-ui.css" | ||
|
||
# create app instance | ||
app = Flask(__name__) | ||
app.config.from_mapping(config) | ||
cache = Cache(app) | ||
swagger = Swagger(app, template=template) | ||
swagger = Swagger(app, template=template, config=swagger_config) | ||
|
||
|
||
# 1 | ||
|
@@ -285,5 +294,15 @@ def handle_exception(e): | |
return jsonify(response), 500 | ||
|
||
|
||
@app.before_request | ||
def disallow_all_get_params(): | ||
if request.args: | ||
response = { | ||
"error": "Query parameters are not allowed", | ||
"error_message": "This application does not support query parameters in requests.", | ||
} | ||
return jsonify(response), 400 | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run(host=BaseConfig.API_HOST, port=BaseConfig.API_PORT, debug=BaseConfig.DEBUG) |