Skip to content

Commit d5b109c

Browse files
committed
Fix decorator issue
1 parent e86143f commit d5b109c

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

openapi_to_sdk/sdk_automation.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,11 @@ def get_default_value_in_param(self, param):
130130

131131
def get_decorator_string(self):
132132
string = ''
133-
for decorator in self.decorators:
134-
string += "@" + decorator + '\n'
133+
for i, decorator in enumerate(self.decorators):
134+
if i == 0:
135+
string += "@" + decorator + '\n'
136+
else:
137+
string += self.add_indent() + "@" + decorator + '\n'
135138
return string
136139

137140
@property

tests/test_vectorai.py

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,38 @@
1+
# from openapi_to_sdk.sdk_automation import PythonSDKBuilder
2+
# def test_smoke():
3+
# sdk = PythonSDKBuilder(
4+
# inherited_properties=['username', 'api_key'],
5+
# decorators=['retry()'],
6+
# url='https://api.vctr.ai/'
7+
# )
8+
# sdk.to_python_file(class_name='ViAPIClient', import_strings=['from vectorai.api.utils import retry'],
9+
# include_response_parsing=False)
10+
# assert True
11+
12+
113
from openapi_to_sdk.sdk_automation import PythonSDKBuilder
214
def test_smoke():
315
sdk = PythonSDKBuilder(
16+
url="https://api.vctr.ai",
417
inherited_properties=['username', 'api_key'],
5-
decorators=['retry()'],
6-
url='https://api.vctr.ai/'
18+
decorators=[
19+
# 'retry()',
20+
"return_curl_or_response('json')"],
721
)
8-
sdk.to_python_file(class_name='ViAPIClient', import_strings=['from vectorai.api.utils import retry'],
9-
include_response_parsing=False)
10-
assert True
22+
sdk.to_python_file(
23+
class_name="ViAPIClient",
24+
filename='api.py',
25+
import_strings=['import requests', 'from vectorai.api.utils import retry, return_curl_or_response'],
26+
internal_functions=[
27+
"list_collections",
28+
"create_collection",
29+
"search"
30+
]
31+
)
32+
33+
def test_import():
34+
import api
35+
import os
36+
from api import ViAPIClient
37+
vi = ViAPIClient(os.environ['VI_USERNAME'], os.environ['VI_API_KEY'])
38+
assert len(vi._list_collections()) > 0

0 commit comments

Comments
 (0)