X Tutup
Skip to content

Commit 2ea7e46

Browse files
committed
IDEV-2412: Fix issue on importing openapi specs
1 parent 80b1b44 commit 2ea7e46

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

domaintools/api.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from datetime import datetime, timedelta, timezone
22
from hashlib import sha1, sha256
33
from hmac import new as hmac
4+
from pathlib import Path
45
from typing import Union
56

67
import re
78
import ssl
89
import yaml
910

11+
1012
from domaintools.constants import (
1113
Endpoint,
1214
OutputFormat,
@@ -111,17 +113,19 @@ def __init__(
111113
raise Exception("Proxy URL must be a string. For example: '127.0.0.1:8888'")
112114

113115
def _initialize_specs(self):
116+
package_root = Path(__file__).parent
114117
for spec_name, file_path in SPECS_MAPPING.items():
118+
specs_file_path = f"{package_root}/specs/{file_path}"
115119
try:
116-
with open(file_path, "r", encoding="utf-8") as f:
120+
with open(specs_file_path, "r", encoding="utf-8") as f:
117121
spec_content = yaml.safe_load(f)
118122
if not spec_content:
119123
raise ValueError("Spec file is empty or invalid.")
120124

121125
self.specs[spec_name] = spec_content
122126

123127
except Exception as e:
124-
print(f"Error loading {file_path}: {e}")
128+
print(f"Error loading {specs_file_path}: {e}")
125129

126130
def _get_ssl_default_context(self, verify_ssl: Union[str, bool]):
127131
return (

domaintools/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ class OutputFormat(Enum):
5858
}
5959

6060
SPECS_MAPPING = {
61-
"iris": "domaintools/specs/iris-openapi.yaml",
62-
# "rttf": "domaintools/specs/feeds-openapi.yaml",
61+
"iris": "iris-openapi.yaml",
62+
# "rttf": "feeds-openapi.yaml",
6363
}

0 commit comments

Comments
 (0)
X Tutup