diff --git a/generate/generate.py b/generate/generate.py index a51519169..cee33af77 100755 --- a/generate/generate.py +++ b/generate/generate.py @@ -175,6 +175,8 @@ response: Response[""" + success_type + """] = await """ + fn_name + """.asyncio f.write("from ...client import Client\n") # Import our references for responses. for ref in endoint_refs: + if ref.startswith('[') and ref.endswith(']'): + ref = ref.replace('[', '').replace(']', '') f.write( "from ...models." + camel_to_snake(ref) + @@ -1041,6 +1043,19 @@ def getEndpointRefs(endpoint: dict, data: dict) -> [str]: ref = json['$ref'].replace('#/components/schemas/', '') if ref not in refs: refs.append(ref) + elif 'type' in json: + if json['type'] == 'array': + items = json['items'] + if '$ref' in items: + ref = items['$ref'].replace( + '#/components/schemas/', '') + refs.append('[' + ref + ']') + else: + raise Exception("Unknown array type") + else: + raise Exception("Unknown type") + else: + raise Exception("Unknown type") elif '$ref' in response: schema_name = response['$ref'].replace( '#/components/responses/', '') diff --git a/kittycad/api/internal/gpu_devices.py b/kittycad/api/internal/gpu_devices.py index 87dde7e02..fbafd15b9 100644 --- a/kittycad/api/internal/gpu_devices.py +++ b/kittycad/api/internal/gpu_devices.py @@ -3,6 +3,7 @@ from typing import Any, Dict, Optional, Union import httpx from ...client import Client +from ...models.gpu_device import GPUDevice from ...models.error_message import ErrorMessage from ...types import Response @@ -23,7 +24,7 @@ def _get_kwargs( } -def _parse_response(*, response: httpx.Response) -> Optional[Union[Any, ErrorMessage]]: +def _parse_response(*, response: httpx.Response) -> Optional[Union[Any, [GPUDevice], ErrorMessage]]: if response.status_code == 200: response_200 = [ GPUDevice.from_dict(item) @@ -39,7 +40,7 @@ def _parse_response(*, response: httpx.Response) -> Optional[Union[Any, ErrorMes return None -def _build_response(*, response: httpx.Response) -> Response[Union[Any, ErrorMessage]]: +def _build_response(*, response: httpx.Response) -> Response[Union[Any, [GPUDevice], ErrorMessage]]: return Response( status_code=response.status_code, content=response.content, @@ -51,7 +52,7 @@ def _build_response(*, response: httpx.Response) -> Response[Union[Any, ErrorMes def sync_detailed( *, client: Client, -) -> Response[Union[Any, ErrorMessage]]: +) -> Response[Union[Any, [GPUDevice], ErrorMessage]]: kwargs = _get_kwargs( client=client, ) @@ -67,7 +68,7 @@ def sync_detailed( def sync( *, client: Client, -) -> Optional[Union[Any, ErrorMessage]]: +) -> Optional[Union[Any, [GPUDevice], ErrorMessage]]: """ Get information about GPU devices on this server. This is primarily used for debugging. This endpoint can only be used by specific KittyCAD employees. """ return sync_detailed( @@ -78,7 +79,7 @@ def sync( async def asyncio_detailed( *, client: Client, -) -> Response[Union[Any, ErrorMessage]]: +) -> Response[Union[Any, [GPUDevice], ErrorMessage]]: kwargs = _get_kwargs( client=client, ) @@ -92,7 +93,7 @@ async def asyncio_detailed( async def asyncio( *, client: Client, -) -> Optional[Union[Any, ErrorMessage]]: +) -> Optional[Union[Any, [GPUDevice], ErrorMessage]]: """ Get information about GPU devices on this server. This is primarily used for debugging. This endpoint can only be used by specific KittyCAD employees. """ return ( diff --git a/spec.json b/spec.json index 8a6d5da85..2f49f44dc 100644 --- a/spec.json +++ b/spec.json @@ -411,7 +411,7 @@ "libDocsLink": "https://pkg.go.dev/github.com/kittycad/kittycad.go/#InternalService.GPUDevices" }, "x-python": { - "example": "from kittycad.models import ErrorMessage\nfrom kittycad.api.internal import gpu_devices\nfrom kittycad.types import Response\n\nfc: ErrorMessage = gpu_devices.sync(client=client)\n\n# OR if you need more info (e.g. status_code)\nresponse: Response[ErrorMessage] = gpu_devices.sync_detailed(client=client)\n\n# OR run async\nfc: ErrorMessage = await gpu_devices.asyncio(client=client)\n\n# OR run async with more info\nresponse: Response[ErrorMessage] = await gpu_devices.asyncio_detailed(client=client)", + "example": "from kittycad.models import [GPUDevice]\nfrom kittycad.api.internal import gpu_devices\nfrom kittycad.types import Response\n\nfc: [GPUDevice] = gpu_devices.sync(client=client)\n\n# OR if you need more info (e.g. status_code)\nresponse: Response[[GPUDevice]] = gpu_devices.sync_detailed(client=client)\n\n# OR run async\nfc: [GPUDevice] = await gpu_devices.asyncio(client=client)\n\n# OR run async with more info\nresponse: Response[[GPUDevice]] = await gpu_devices.asyncio_detailed(client=client)", "libDocsLink": "https://python.api.docs.kittycad.io/modules/kittycad.api.internal.gpu_devices.html" } }