Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Jess Frazelle <[email protected]>
  • Loading branch information
jessfraz committed Nov 29, 2023
1 parent 243ed32 commit d9d7352
Show file tree
Hide file tree
Showing 72 changed files with 800 additions and 374 deletions.
2 changes: 1 addition & 1 deletion generate/functions-ws.py.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class WebSocket:

"""
for message in self.ws:
return {{response_type}}.from_dict(json.loads(message))
yield {{response_type}}.from_dict(json.loads(message))

def send(self, data:{% for arg in args %}{%if arg.name == "body" %}{{arg.type}}{% endif %}{% endfor %}):
"""Send data to the websocket."""
Expand Down
22 changes: 17 additions & 5 deletions generate/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1518,9 +1518,8 @@ def generateObjectTypeCode(
)
# We only want .to_dict on nested objects.
if "$ref" in property_schema:
actual_schema = data["components"]["schemas"][
property_schema["$ref"].replace("#/components/schemas/", "")
]
ref = property_schema["$ref"].replace("#/components/schemas/", "")
actual_schema = data["components"]["schemas"][ref]
is_enum = isEnumWithDocsOneOf(actual_schema)
if (
"properties" in actual_schema
Expand All @@ -1529,10 +1528,21 @@ def generateObjectTypeCode(
or "allOf" in actual_schema
) and not is_enum:
f.write(
"\t\t\tfield_dict['"
"\t\t\t_"
+ property_name
+ "'] = "
+ ": "
+ ref
+ " = cast("
+ ref
+ ", "
+ clean_parameter_name(property_name)
+ ")\n"
)
f.write(
"\t\t\tfield_dict['"
+ property_name
+ "'] = _"
+ property_name
+ ".to_dict()\n"
)
else:
Expand Down Expand Up @@ -1849,6 +1859,7 @@ def renderTypeToDict(f, property_name: str, property_schema: dict, data: dict):
)
elif "$ref" in property_schema:
ref = property_schema["$ref"].replace("#/components/schemas/", "")
f.write("\t\t" + property_name + ": Union[Unset, " + ref + "] = UNSET\n")
f.write(
"\t\tif not isinstance(self."
+ clean_parameter_name(property_name)
Expand All @@ -1869,6 +1880,7 @@ def renderTypeToDict(f, property_name: str, property_schema: dict, data: dict):
return renderTypeToDict(
f, property_name, data["components"]["schemas"][ref], data
)
f.write("\t\t" + property_name + ": Union[Unset, " + ref + "] = UNSET\n")
f.write(
"\t\tif not isinstance(self."
+ clean_parameter_name(property_name)
Expand Down
438 changes: 219 additions & 219 deletions kittycad.py.patch.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion kittycad/api/modeling/modeling_commands_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def __iter__(self) -> Iterator[WebSocketResponse]:
"""
for message in self.ws:
return WebSocketResponse.from_dict(json.loads(message))
yield WebSocketResponse.from_dict(json.loads(message))

def send(self, data: WebSocketRequest):
"""Send data to the websocket."""
Expand Down
3 changes: 2 additions & 1 deletion kittycad/client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,5 +316,6 @@ def test_ws():

# Get the messages.
while True:
websocket.recv()
message = websocket.recv()
print(json.dumps(message.to_dict()))
break
1 change: 1 addition & 0 deletions kittycad/models/ai_plugin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class AiPluginApi:

def to_dict(self) -> Dict[str, Any]:
is_user_authenticated = self.is_user_authenticated
type: Union[Unset, AiPluginApiType] = UNSET
if not isinstance(self.type, Unset):
type = self.type
url = self.url
Expand Down
2 changes: 2 additions & 0 deletions kittycad/models/ai_plugin_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ class AiPluginAuth:
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)

def to_dict(self) -> Dict[str, Any]:
authorization_type: Union[Unset, AiPluginHttpAuthType] = UNSET
if not isinstance(self.authorization_type, Unset):
authorization_type = self.authorization_type
type: Union[Unset, AiPluginAuthType] = UNSET
if not isinstance(self.type, Unset):
type = self.type

Expand Down
10 changes: 7 additions & 3 deletions kittycad/models/ai_plugin_manifest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, List, Type, TypeVar, Union
from typing import Any, Dict, List, Type, TypeVar, Union, cast

import attr

Expand Down Expand Up @@ -30,8 +30,10 @@ class AiPluginManifest:
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)

def to_dict(self) -> Dict[str, Any]:
api: Union[Unset, AiPluginApi] = UNSET
if not isinstance(self.api, Unset):
api = self.api
auth: Union[Unset, AiPluginAuth] = UNSET
if not isinstance(self.auth, Unset):
auth = self.auth
contact_email = self.contact_email
Expand All @@ -47,9 +49,11 @@ def to_dict(self) -> Dict[str, Any]:
field_dict.update(self.additional_properties)
field_dict.update({})
if api is not UNSET:
field_dict["api"] = api.to_dict()
_api: AiPluginApi = cast(AiPluginApi, api)
field_dict["api"] = _api.to_dict()
if auth is not UNSET:
field_dict["auth"] = auth.to_dict()
_auth: AiPluginAuth = cast(AiPluginAuth, auth)
field_dict["auth"] = _auth.to_dict()
if contact_email is not UNSET:
field_dict["contact_email"] = contact_email
if description_for_human is not UNSET:
Expand Down
4 changes: 4 additions & 0 deletions kittycad/models/ai_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ def to_dict(self) -> Dict[str, Any]:
if not isinstance(self.created_at, Unset):
created_at = self.created_at.isoformat()
error = self.error
feedback: Union[Unset, AiFeedback] = UNSET
if not isinstance(self.feedback, Unset):
feedback = self.feedback
id: Union[Unset, UuidBinary] = UNSET
if not isinstance(self.id, Unset):
id = self.id
metadata = self.metadata
Expand All @@ -54,8 +56,10 @@ def to_dict(self) -> Dict[str, Any]:
started_at: Union[Unset, str] = UNSET
if not isinstance(self.started_at, Unset):
started_at = self.started_at.isoformat()
status: Union[Unset, ApiCallStatus] = UNSET
if not isinstance(self.status, Unset):
status = self.status
type: Union[Unset, AiPromptType] = UNSET
if not isinstance(self.type, Unset):
type = self.type
updated_at: Union[Unset, str] = UNSET
Expand Down
1 change: 1 addition & 0 deletions kittycad/models/angle.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Angle:
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)

def to_dict(self) -> Dict[str, Any]:
unit: Union[Unset, UnitAngle] = UNSET
if not isinstance(self.unit, Unset):
unit = self.unit
value = self.value
Expand Down
2 changes: 2 additions & 0 deletions kittycad/models/annotation_line_end_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ class AnnotationLineEndOptions:
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)

def to_dict(self) -> Dict[str, Any]:
end: Union[Unset, AnnotationLineEnd] = UNSET
if not isinstance(self.end, Unset):
end = self.end
start: Union[Unset, AnnotationLineEnd] = UNSET
if not isinstance(self.start, Unset):
start = self.start

Expand Down
20 changes: 15 additions & 5 deletions kittycad/models/annotation_options.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, List, Type, TypeVar, Union
from typing import Any, Dict, List, Type, TypeVar, Union, cast

import attr

Expand All @@ -24,29 +24,39 @@ class AnnotationOptions:
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)

def to_dict(self) -> Dict[str, Any]:
color: Union[Unset, Color] = UNSET
if not isinstance(self.color, Unset):
color = self.color
line_ends: Union[Unset, AnnotationLineEndOptions] = UNSET
if not isinstance(self.line_ends, Unset):
line_ends = self.line_ends
line_width = self.line_width
position: Union[Unset, Point3d] = UNSET
if not isinstance(self.position, Unset):
position = self.position
text: Union[Unset, AnnotationTextOptions] = UNSET
if not isinstance(self.text, Unset):
text = self.text

field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
if color is not UNSET:
field_dict["color"] = color.to_dict()
_color: Color = cast(Color, color)
field_dict["color"] = _color.to_dict()
if line_ends is not UNSET:
field_dict["line_ends"] = line_ends.to_dict()
_line_ends: AnnotationLineEndOptions = cast(
AnnotationLineEndOptions, line_ends
)
field_dict["line_ends"] = _line_ends.to_dict()
if line_width is not UNSET:
field_dict["line_width"] = line_width
if position is not UNSET:
field_dict["position"] = position.to_dict()
_position: Point3d = cast(Point3d, position)
field_dict["position"] = _position.to_dict()
if text is not UNSET:
field_dict["text"] = text.to_dict()
_text: AnnotationTextOptions = cast(AnnotationTextOptions, text)
field_dict["text"] = _text.to_dict()

return field_dict

Expand Down
2 changes: 2 additions & 0 deletions kittycad/models/annotation_text_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ class AnnotationTextOptions:
def to_dict(self) -> Dict[str, Any]:
point_size = self.point_size
text = self.text
x: Union[Unset, AnnotationTextAlignmentX] = UNSET
if not isinstance(self.x, Unset):
x = self.x
y: Union[Unset, AnnotationTextAlignmentY] = UNSET
if not isinstance(self.y, Unset):
y = self.y

Expand Down
1 change: 1 addition & 0 deletions kittycad/models/api_call_with_price.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def to_dict(self) -> Dict[str, Any]:
id = self.id
ip_address = self.ip_address
litterbox = self.litterbox
method: Union[Unset, Method] = UNSET
if not isinstance(self.method, Unset):
method = self.method
minutes = self.minutes
Expand Down
1 change: 1 addition & 0 deletions kittycad/models/api_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ApiError:
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)

def to_dict(self) -> Dict[str, Any]:
error_code: Union[Unset, ErrorCode] = UNSET
if not isinstance(self.error_code, Unset):
error_code = self.error_code
message = self.message
Expand Down
2 changes: 2 additions & 0 deletions kittycad/models/async_api_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ def to_dict(self) -> Dict[str, Any]:
started_at: Union[Unset, str] = UNSET
if not isinstance(self.started_at, Unset):
started_at = self.started_at.isoformat()
status: Union[Unset, ApiCallStatus] = UNSET
if not isinstance(self.status, Unset):
status = self.status
type: Union[Unset, AsyncApiCallType] = UNSET
if not isinstance(self.type, Unset):
type = self.type
updated_at: Union[Unset, str] = UNSET
Expand Down
Loading

1 comment on commit d9d7352

@vercel
Copy link

@vercel vercel bot commented on d9d7352 Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.