Refactor OpenAPI fetcher for improved clarity and robustness
Reorganized and enhanced the OpenAPI fetch logic for better maintainability and error handling. Key updates include improved environment variable validation, more detailed error messages, streamlined configuration loading, and additional safety checks for file paths and directories. Added proper logging and ensured the process flow is easy to trace.
This commit is contained in:
parent
f80e111f3b
commit
c77e579799
@ -168,9 +168,13 @@ if __name__ == "__main__":
|
||||
print(f"[INFO] Starting server in {environment} environment...")
|
||||
print(f"[INFO] SSL Certificate Path: {cert_path}")
|
||||
print(f"[INFO] SSL Key Path: {key_path}")
|
||||
port = int(
|
||||
config.get("PORT", os.getenv("PORT", 8000))
|
||||
) # Fetch port from config or environment
|
||||
port = config.get("PORT", os.getenv("PORT"))
|
||||
if not port:
|
||||
print(
|
||||
"[ERROR] No port defined in config or environment variables. Aborting!"
|
||||
)
|
||||
sys.exit(1) # Exit if no port is defined
|
||||
port = int(port)
|
||||
print(f"[INFO] Running on port {port}")
|
||||
uvicorn.run(
|
||||
app,
|
||||
|
@ -4,6 +4,7 @@
|
||||
"OPENAPI_URL": "https://mx-aare-test.psi.ch:1492/openapi.json",
|
||||
"SCHEMA_PATH": "./src/openapi.json",
|
||||
"OUTPUT_DIRECTORY": "./openapi",
|
||||
"PORT": 1492,
|
||||
"SSL_KEY_PATH": "/home/jungfrau/heidi-v2/backend/ssl/mx-aare-test.psi.ch.key",
|
||||
"SSL_CERT_PATH": "/home/jungfrau/heidi-v2/backend/ssl/mx-aare-test.psi.ch.pem"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user