From 677524dd30b879a3b20e445871fce4fbc80ad26d Mon Sep 17 00:00:00 2001 From: Reece Date: Tue, 14 Feb 2023 02:10:13 +0000 Subject: [PATCH 1/2] DISABLE_SWAGGER_UI option --- CONFIG.py | 2 ++ HELPERS.py | 3 +-- rest.py | 8 +++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CONFIG.py b/CONFIG.py index 6121dff..85b03cb 100644 --- a/CONFIG.py +++ b/CONFIG.py @@ -81,6 +81,8 @@ def get_config_file(filename: str): OPEN_API = f"{REST_URL}/static/openapi.yml" +DISABLE_SWAGGER_UI = getenv("DISABLE_SWAGGER_UI", "false").lower().startswith("t") + # Security RPC_LISTEN_ADDRESS = getenv("RPC_LISTEN_ADDRESS", "") NODE_MONIKER = getenv("NODE_MONIKER", "") diff --git a/HELPERS.py b/HELPERS.py index daf7e3d..434d506 100644 --- a/HELPERS.py +++ b/HELPERS.py @@ -1,9 +1,8 @@ import re from os import getenv -import httpx - import CONFIG +import httpx from CONFIG import REDIS_DB from HELPERS_TYPES import CallType, Mode diff --git a/rest.py b/rest.py index 93bf0b0..da394ef 100644 --- a/rest.py +++ b/rest.py @@ -2,11 +2,10 @@ import json -from flask import Flask, jsonify, request -from flask_cors import CORS, cross_origin - import CONFIG as CONFIG from CONFIG import REDIS_DB +from flask import Flask, jsonify, request +from flask_cors import CORS, cross_origin from HELPERS import ( Mode, download_openapi_locally, @@ -46,6 +45,9 @@ def before_first_request(): def root(): global REST_SWAGGER_HTML + if CONFIG.DISABLE_SWAGGER_UI: + return jsonify({"code": 12, "message": "Not Implemented", "details": []}) + if len(REST_SWAGGER_HTML) > 0: return REST_SWAGGER_HTML From c6371571fb841f81eefea87bc3ef57dcfee7d649 Mon Sep 17 00:00:00 2001 From: Reece Date: Tue, 14 Feb 2023 02:10:52 +0000 Subject: [PATCH 2/2] .env DISABLE_SWAGGER_UI=false --- configs/.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/.env b/configs/.env index 4bed052..cfa5ae3 100644 --- a/configs/.env +++ b/configs/.env @@ -25,7 +25,7 @@ RPC_WEBSOCKET="ws://15.204.143.232:26657/websocket" # REST API REST_URL="http://127.0.0.1:1317" BACKUP_REST_URL="https://api.juno.strange.love" - +DISABLE_SWAGGER_UI=false # === Security === # Hides value in the /status endpoint of the RPC