Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion polyapi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ def setup(args):
###########################################################################
# Generate command
generate_parser = subparsers.add_parser("generate", help="Generates Poly library")
generate_parser.add_argument("--no-types", action="store_true", help="Generate SDK without type definitions")

def generate_command(args):
initialize_config()
generate()
generate(no_types=args.no_types)

generate_parser.set_defaults(command=generate_command)

Expand Down
9 changes: 5 additions & 4 deletions polyapi/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@
path:'''


def get_specs() -> List:
def get_specs(no_types: bool = False) -> List:
api_key, api_url = get_api_key_and_url()
assert api_key
headers = get_auth_headers(api_key)
url = f"{api_url}/specs"
resp = requests.get(url, headers=headers)
params = {"noTypes": str(no_types).lower()}
resp = requests.get(url, headers=headers, params=params)
if resp.status_code == 200:
return resp.json()
else:
Expand Down Expand Up @@ -196,11 +197,11 @@ def remove_old_library():
shutil.rmtree(path)


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

specs = get_specs()
specs = get_specs(no_types=no_types)
cache_specs(specs)

limit_ids: List[str] = [] # useful for narrowing down generation to a single function to debug
Expand Down
5 changes: 3 additions & 2 deletions polyapi/rendered_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ def update_rendered_spec(spec: SpecificationDto):
assert resp.status_code == 201, (resp.text, resp.status_code)


def _get_spec(spec_id: str) -> Optional[SpecificationDto]:
def _get_spec(spec_id: str, no_types: bool = False) -> Optional[SpecificationDto]:
api_key, base_url = get_api_key_and_url()
url = f"{base_url}/specs"
headers = {"Authorization": f"Bearer {api_key}"}
resp = requests.get(url, headers=headers)
params = {"noTypes": str(no_types).lower()}
resp = requests.get(url, headers=headers, params=params)
if resp.status_code == 200:
specs = resp.json()
for spec in specs:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools>=61.2", "wheel"]

[project]
name = "polyapi-python"
version = "0.3.4.dev1"
version = "0.3.4.dev2"
description = "The Python Client for PolyAPI, the IPaaS by Developers for Developers"
authors = [{ name = "Dan Fellin", email = "dan@polyapi.io" }]
dependencies = [
Expand Down