Fix OpenAPI endpoint path handling for Docker environment
This commit is contained in:
parent
be8be95d8b
commit
df92bd9017
18
app.py
18
app.py
@ -217,12 +217,24 @@ def get_openapi():
|
|||||||
"""Serve the OpenAPI specification file"""
|
"""Serve the OpenAPI specification file"""
|
||||||
try:
|
try:
|
||||||
# Read the openapi.json file from the filesystem
|
# Read the openapi.json file from the filesystem
|
||||||
with open('openapi.json', 'r') as f:
|
# Try multiple locations to handle Docker vs local execution
|
||||||
import json
|
import os
|
||||||
|
import json
|
||||||
|
|
||||||
|
# Check if we're in Docker (working directory is /app)
|
||||||
|
current_dir = os.getcwd()
|
||||||
|
if current_dir == '/app':
|
||||||
|
# In Docker, the file should be in /app
|
||||||
|
file_path = '/app/openapi.json'
|
||||||
|
else:
|
||||||
|
# Local execution
|
||||||
|
file_path = 'openapi.json'
|
||||||
|
|
||||||
|
with open(file_path, 'r') as f:
|
||||||
spec = json.load(f)
|
spec = json.load(f)
|
||||||
return jsonify(spec)
|
return jsonify(spec)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({"error": "OpenAPI specification not found"}), 404
|
return jsonify({"error": f"OpenAPI specification not found: {str(e)}"}), 404
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Fix the port issue by using a different port
|
# Fix the port issue by using a different port
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user