Skip to content

Commit 9c1a2a1

Browse files
P2) Update clients and specs endpoint so when generating with no-types argument all schemas get excluded (#38)
* added no type option * version updated
1 parent a6ba2f3 commit 9c1a2a1

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

polyapi/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ def setup(args):
4444
###########################################################################
4545
# Generate command
4646
generate_parser = subparsers.add_parser("generate", help="Generates Poly library")
47+
generate_parser.add_argument("--no-types", action="store_true", help="Generate SDK without type definitions")
4748

4849
def generate_command(args):
4950
initialize_config()
50-
generate()
51+
generate(no_types=args.no_types)
5152

5253
generate_parser.set_defaults(command=generate_command)
5354

polyapi/generate.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@
3636
path:'''
3737

3838

39-
def get_specs() -> List:
39+
def get_specs(no_types: bool = False) -> List:
4040
api_key, api_url = get_api_key_and_url()
4141
assert api_key
4242
headers = get_auth_headers(api_key)
4343
url = f"{api_url}/specs"
44-
resp = requests.get(url, headers=headers)
44+
params = {"noTypes": str(no_types).lower()}
45+
resp = requests.get(url, headers=headers, params=params)
4546
if resp.status_code == 200:
4647
return resp.json()
4748
else:
@@ -196,11 +197,11 @@ def remove_old_library():
196197
shutil.rmtree(path)
197198

198199

199-
def generate() -> None:
200+
def generate(no_types: bool = False) -> None:
200201
print("Generating Poly Python SDK...", end="", flush=True)
201202
remove_old_library()
202203

203-
specs = get_specs()
204+
specs = get_specs(no_types=no_types)
204205
cache_specs(specs)
205206

206207
limit_ids: List[str] = [] # useful for narrowing down generation to a single function to debug

polyapi/rendered_spec.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ def update_rendered_spec(spec: SpecificationDto):
3535
assert resp.status_code == 201, (resp.text, resp.status_code)
3636

3737

38-
def _get_spec(spec_id: str) -> Optional[SpecificationDto]:
38+
def _get_spec(spec_id: str, no_types: bool = False) -> Optional[SpecificationDto]:
3939
api_key, base_url = get_api_key_and_url()
4040
url = f"{base_url}/specs"
4141
headers = {"Authorization": f"Bearer {api_key}"}
42-
resp = requests.get(url, headers=headers)
42+
params = {"noTypes": str(no_types).lower()}
43+
resp = requests.get(url, headers=headers, params=params)
4344
if resp.status_code == 200:
4445
specs = resp.json()
4546
for spec in specs:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools>=61.2", "wheel"]
33

44
[project]
55
name = "polyapi-python"
6-
version = "0.3.4.dev1"
6+
version = "0.3.4.dev2"
77
description = "The Python Client for PolyAPI, the IPaaS by Developers for Developers"
88
authors = [{ name = "Dan Fellin", email = "dan@polyapi.io" }]
99
dependencies = [

0 commit comments

Comments
 (0)