Update api spec (#212)
* YOYO NEW API SPEC! * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * I have generated the latest API! --------- Signed-off-by: Jess Frazelle <github@jessfraz.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
committed by
GitHub
parent
38801b52a7
commit
64e8aa2816
@ -1270,7 +1270,7 @@ def generateAnyOfType(path: str, name: str, schema: dict, data: dict):
|
||||
f.write("from ." + camel_to_snake(ref_name) + " import " + ref_name + "\n")
|
||||
all_options.append(ref_name)
|
||||
|
||||
if isNestedObjectOneOf(schema):
|
||||
if isNestedObjectAnyOf(schema):
|
||||
# We want to write each of the nested objects.
|
||||
for any_of in schema["anyOf"]:
|
||||
# Get the nested object.
|
||||
@ -1326,6 +1326,47 @@ def generateAnyOfType(path: str, name: str, schema: dict, data: dict):
|
||||
f.write(object_code)
|
||||
f.write("\n")
|
||||
all_options.append(object_name)
|
||||
else:
|
||||
# We want to write each of the nested objects.
|
||||
for any_of in schema["anyOf"]:
|
||||
# Get the nested object.
|
||||
if "properties" in any_of:
|
||||
for prop_name in any_of["properties"]:
|
||||
nested_object = any_of["properties"][prop_name]
|
||||
if nested_object == {}:
|
||||
f.write("from typing import Any\n")
|
||||
f.write(prop_name + " = Any\n")
|
||||
f.write("\n")
|
||||
all_options.append(prop_name)
|
||||
elif "$ref" in nested_object:
|
||||
ref = nested_object["$ref"]
|
||||
ref_name = ref[ref.rfind("/") + 1 :]
|
||||
f.write(
|
||||
"from ."
|
||||
+ camel_to_snake(ref_name)
|
||||
+ " import "
|
||||
+ ref_name
|
||||
+ "\n"
|
||||
)
|
||||
f.write("\n")
|
||||
if prop_name != ref_name:
|
||||
f.write(prop_name + " = " + ref_name + "\n")
|
||||
f.write("\n")
|
||||
all_options.append(prop_name)
|
||||
else:
|
||||
object_code = generateObjectTypeCode(
|
||||
prop_name, nested_object, "object", data, None, None
|
||||
)
|
||||
f.write(object_code)
|
||||
f.write("\n")
|
||||
all_options.append(prop_name)
|
||||
elif "type" in any_of and any_of["type"] == "string":
|
||||
enum_code = generateEnumTypeCode(
|
||||
any_of["enum"][0], any_of, "string", []
|
||||
)
|
||||
f.write(enum_code)
|
||||
f.write("\n")
|
||||
all_options.append(any_of["enum"][0])
|
||||
|
||||
# Write the sum type.
|
||||
description = getAnyOfDescription(schema)
|
||||
@ -1953,6 +1994,40 @@ def getOneOfRefType(schema: dict) -> str:
|
||||
raise Exception("Cannot get oneOf ref type for schema: ", schema)
|
||||
|
||||
|
||||
def isNestedObjectAnyOf(schema: dict) -> bool:
|
||||
if "anyOf" not in schema:
|
||||
return False
|
||||
|
||||
is_nested_object = False
|
||||
for any_of in schema["anyOf"]:
|
||||
# Check if each are an object w 1 property in it.
|
||||
if (
|
||||
"type" in any_of
|
||||
and any_of["type"] == "object"
|
||||
and "properties" in any_of
|
||||
and len(any_of["properties"]) == 1
|
||||
):
|
||||
for prop_name in any_of["properties"]:
|
||||
nested_object = any_of["properties"][prop_name]
|
||||
if "type" in nested_object and nested_object["type"] == "object":
|
||||
is_nested_object = True
|
||||
else:
|
||||
is_nested_object = False
|
||||
break
|
||||
elif (
|
||||
"type" in any_of
|
||||
and any_of["type"] == "string"
|
||||
and "enum" in any_of
|
||||
and len(any_of["enum"]) == 1
|
||||
):
|
||||
is_nested_object = True
|
||||
else:
|
||||
is_nested_object = False
|
||||
break
|
||||
|
||||
return is_nested_object
|
||||
|
||||
|
||||
def isNestedObjectOneOf(schema: dict) -> bool:
|
||||
if "oneOf" not in schema:
|
||||
return False
|
||||
@ -1961,7 +2036,8 @@ def isNestedObjectOneOf(schema: dict) -> bool:
|
||||
for one_of in schema["oneOf"]:
|
||||
# Check if each are an object w 1 property in it.
|
||||
if (
|
||||
one_of["type"] == "object"
|
||||
"type" in one_of
|
||||
and one_of["type"] == "object"
|
||||
and "properties" in one_of
|
||||
and len(one_of["properties"]) == 1
|
||||
):
|
||||
@ -1973,7 +2049,10 @@ def isNestedObjectOneOf(schema: dict) -> bool:
|
||||
is_nested_object = False
|
||||
break
|
||||
elif (
|
||||
one_of["type"] == "string" and "enum" in one_of and len(one_of["enum"]) == 1
|
||||
"type" in one_of
|
||||
and one_of["type"] == "string"
|
||||
and "enum" in one_of
|
||||
and len(one_of["enum"]) == 1
|
||||
):
|
||||
is_nested_object = True
|
||||
else:
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -31,6 +31,7 @@ from .async_api_call_type import AsyncApiCallType
|
||||
from .auth_callback import AuthCallback
|
||||
from .axis import Axis
|
||||
from .axis_direction_pair import AxisDirectionPair
|
||||
from .batch_response import BatchResponse
|
||||
from .billing_info import BillingInfo
|
||||
from .block_reason import BlockReason
|
||||
from .cache_metadata import CacheMetadata
|
||||
|
24
kittycad/models/batch_response.py
Normal file
24
kittycad/models/batch_response.py
Normal file
@ -0,0 +1,24 @@
|
||||
from typing import Union
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, RootModel
|
||||
|
||||
|
||||
|
||||
class response(BaseModel):
|
||||
"""Response to the modeling command."""
|
||||
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
||||
|
||||
class errors(BaseModel):
|
||||
"""Errors that occurred during the modeling command."""
|
||||
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
||||
|
||||
BatchResponse = RootModel[
|
||||
Union[
|
||||
response,
|
||||
errors,
|
||||
]
|
||||
]
|
@ -1,8 +1,9 @@
|
||||
from typing import List, Literal, Union
|
||||
from typing import Dict, List, Literal, Union
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, RootModel
|
||||
from typing_extensions import Annotated
|
||||
|
||||
from ..models.batch_response import BatchResponse
|
||||
from ..models.ice_server import IceServer
|
||||
from ..models.ok_modeling_cmd_response import OkModelingCmdResponse
|
||||
from ..models.raw_file import RawFile
|
||||
@ -82,6 +83,24 @@ class modeling(BaseModel):
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
||||
|
||||
class ModelingBatchData(BaseModel):
|
||||
""""""
|
||||
|
||||
responses: Dict[str, BatchResponse]
|
||||
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
||||
|
||||
class modeling_batch(BaseModel):
|
||||
"""Response to a ModelingBatch."""
|
||||
|
||||
data: ModelingBatchData
|
||||
|
||||
type: Literal["modeling_batch"] = "modeling_batch"
|
||||
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
|
||||
|
||||
class ExportData(BaseModel):
|
||||
""""""
|
||||
|
||||
@ -139,6 +158,7 @@ OkWebSocketResponseData = RootModel[
|
||||
trickle_ice,
|
||||
sdp_answer,
|
||||
modeling,
|
||||
modeling_batch,
|
||||
export,
|
||||
metrics_request,
|
||||
pong,
|
||||
|
@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "kittycad"
|
||||
version = "0.6.11"
|
||||
version = "0.6.12"
|
||||
description = "A client library for accessing KittyCAD"
|
||||
|
||||
authors = []
|
||||
|
69
spec.json
69
spec.json
@ -14257,6 +14257,44 @@
|
||||
"direction"
|
||||
]
|
||||
},
|
||||
"BatchResponse": {
|
||||
"description": "Websocket responses can either be successful or unsuccessful. Slightly different schemas in either case.",
|
||||
"anyOf": [
|
||||
{
|
||||
"description": "Response sent when a request succeeded.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"response": {
|
||||
"description": "Response to the modeling command.",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/components/schemas/OkModelingCmdResponse"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"response"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Response sent when a request did not succeed.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"errors": {
|
||||
"description": "Errors that occurred during the modeling command.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/ApiError"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"errors"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"BillingInfo": {
|
||||
"description": "The billing information for payments.",
|
||||
"type": "object",
|
||||
@ -22467,6 +22505,37 @@
|
||||
"type"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "Response to a ModelingBatch.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"responses": {
|
||||
"description": "For each request in the batch, maps its ID to the request's outcome.",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"$ref": "#/components/schemas/BatchResponse"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"responses"
|
||||
]
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"modeling_batch"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"data",
|
||||
"type"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "The exported files.",
|
||||
"type": "object",
|
||||
|
Reference in New Issue
Block a user