This commit is contained in:
dgtlmoon
2025-10-17 11:00:17 +02:00
parent 76b5b0c959
commit d93dcf9c2a
+3 -10
View File
@@ -36,18 +36,11 @@ def get_openapi_spec():
import yaml # Lazy import - only loaded when API validation is actually used
from openapi_core import OpenAPI # Lazy import - saves ~10.7 MB on startup
# Try multiple paths to find the API spec file since the package structure differs
# between Docker builds (source tree) and PyPI/pip installations (site-packages)
# 1. Relative path for Docker/development environment where docs/ is in the source tree
spec_path = os.path.join(os.path.dirname(__file__), '../../docs/api-spec.yaml')
# 2. For PyPI/pip installations, use importlib.resources to find the installed file
if not os.path.exists(spec_path):
try:
from importlib.resources import files
spec_path = files('changedetectionio').joinpath('../docs/api-spec.yaml')
except Exception:
pass
# Possibly for pip3 packages (will be shipped with the package)
spec_path = os.path.join(os.path.dirname(__file__), '../docs/api-spec.yaml')
# 3. Last resort: check if it's in the package root for pip/PyPI installations
if not os.path.exists(spec_path):