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
9 changes: 1 addition & 8 deletions reflectapi-demo/clients/python/api_client/myapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

class MyapiHealthCheckFail(BaseModel):
model_config = ConfigDict(
extra="ignore", populate_by_name=True, protected_namespaces=()
extra="ignore", populate_by_name=True, protected_namespaces=(), defer_build=True
)


Expand All @@ -61,11 +61,4 @@ class MyapiHealthCheckFail(BaseModel):
from . import model
from . import proto

try:
from .._rebuild import rebuild_models as _rebuild_models

_rebuild_models()
except ImportError:
pass

__all__ = ["HealthCheckFail", "MyapiHealthCheckFail", "model", "proto"]
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MyapiModelBehaviorAggressiveVariant(BaseModel):
"""Aggressive variant"""

model_config = ConfigDict(
extra="ignore", populate_by_name=True, protected_namespaces=()
extra="ignore", populate_by_name=True, protected_namespaces=(), defer_build=True
)

field_0: float = Field(description="aggressiveness level")
Expand All @@ -64,7 +64,7 @@ class MyapiModelBehaviorOtherVariant(BaseModel):
"""Other variant"""

model_config = ConfigDict(
extra="ignore", populate_by_name=True, protected_namespaces=()
extra="ignore", populate_by_name=True, protected_namespaces=(), defer_build=True
)

description: str = Field(description="Custom provided description of a behavior")
Expand Down Expand Up @@ -125,7 +125,7 @@ class MyapiModelKindDog(BaseModel):
"""A dog"""

model_config = ConfigDict(
extra="ignore", populate_by_name=True, protected_namespaces=()
extra="ignore", populate_by_name=True, protected_namespaces=(), defer_build=True
)

type: Literal["dog"] = Field(default="dog", description="Discriminator field")
Expand All @@ -136,7 +136,7 @@ class MyapiModelKindCat(BaseModel):
"""A cat"""

model_config = ConfigDict(
extra="ignore", populate_by_name=True, protected_namespaces=()
extra="ignore", populate_by_name=True, protected_namespaces=(), defer_build=True
)

type: Literal["cat"] = Field(default="cat", description="Discriminator field")
Expand All @@ -147,7 +147,7 @@ class MyapiModelKindBird(BaseModel):
"""Test for unit variants in internally tagged enums"""

model_config = ConfigDict(
extra="ignore", populate_by_name=True, protected_namespaces=()
extra="ignore", populate_by_name=True, protected_namespaces=(), defer_build=True
)

type: Literal["bird"] = Field(default="bird", description="Discriminator field")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

class MyapiModelInputPet(BaseModel):
model_config = ConfigDict(
extra="ignore", populate_by_name=True, protected_namespaces=()
extra="ignore", populate_by_name=True, protected_namespaces=(), defer_build=True
)

name: str = Field(description="identity")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

class MyapiModelOutputPet(BaseModel):
model_config = ConfigDict(
extra="ignore", populate_by_name=True, protected_namespaces=()
extra="ignore", populate_by_name=True, protected_namespaces=(), defer_build=True
)

name: str = Field(description="identity")
Expand Down
34 changes: 20 additions & 14 deletions reflectapi-demo/clients/python/api_client/myapi/proto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
T = TypeVar("T")


import sys
from ... import myapi

myapi.proto = sys.modules[__name__]

# External type definitions
StdNumNonZeroU32 = Annotated[int, "Rust NonZero u32 type"]
StdNumNonZeroU64 = Annotated[int, "Rust NonZero u64 type"]
Expand All @@ -51,23 +56,23 @@

class MyapiProtoHeaders(BaseModel):
model_config = ConfigDict(
extra="ignore", populate_by_name=True, protected_namespaces=()
extra="ignore", populate_by_name=True, protected_namespaces=(), defer_build=True
)

authorization: str = Field(description="Authorization header")


class MyapiProtoInternalError(BaseModel):
model_config = ConfigDict(
extra="ignore", populate_by_name=True, protected_namespaces=()
extra="ignore", populate_by_name=True, protected_namespaces=(), defer_build=True
)

message: str


class MyapiProtoPaginated(BaseModel, Generic[T]):
model_config = ConfigDict(
extra="ignore", populate_by_name=True, protected_namespaces=()
extra="ignore", populate_by_name=True, protected_namespaces=(), defer_build=True
)

items: list[T] = Field(description="slice of a collection")
Expand All @@ -76,7 +81,7 @@ class MyapiProtoPaginated(BaseModel, Generic[T]):

class MyapiProtoPetsListRequest(BaseModel):
model_config = ConfigDict(
extra="ignore", populate_by_name=True, protected_namespaces=()
extra="ignore", populate_by_name=True, protected_namespaces=(), defer_build=True
)

limit: int | None = None
Expand All @@ -85,7 +90,7 @@ class MyapiProtoPetsListRequest(BaseModel):

class MyapiProtoPetsRemoveRequest(BaseModel):
model_config = ConfigDict(
extra="ignore", populate_by_name=True, protected_namespaces=()
extra="ignore", populate_by_name=True, protected_namespaces=(), defer_build=True
)

name: str = Field(description="identity")
Expand All @@ -97,6 +102,7 @@ class MyapiProtoPetsUpdateRequest(ReflectapiPartialModel):
populate_by_name=True,
validate_assignment=True,
protected_namespaces=(),
defer_build=True,
)

name: str = Field(description="identity")
Expand All @@ -113,7 +119,7 @@ class MyapiProtoPetsUpdateRequest(ReflectapiPartialModel):

class MyapiProtoValidationA(BaseModel):
model_config = ConfigDict(
extra="ignore", populate_by_name=True, protected_namespaces=()
extra="ignore", populate_by_name=True, protected_namespaces=(), defer_build=True
)

message: str
Expand All @@ -123,7 +129,7 @@ class MyapiProtoPetsCreateErrorInvalidIdentityVariant(BaseModel):
"""InvalidIdentity variant"""

model_config = ConfigDict(
extra="ignore", populate_by_name=True, protected_namespaces=()
extra="ignore", populate_by_name=True, protected_namespaces=(), defer_build=True
)

message: str
Expand Down Expand Up @@ -179,7 +185,7 @@ def _serialize(self):

class MyapiProtoPetsListErrorInvalidCursor(BaseModel):
model_config = ConfigDict(
extra="ignore", populate_by_name=True, protected_namespaces=()
extra="ignore", populate_by_name=True, protected_namespaces=(), defer_build=True
)

kind: Literal["InvalidCursor"] = Field(
Expand All @@ -189,7 +195,7 @@ class MyapiProtoPetsListErrorInvalidCursor(BaseModel):

class MyapiProtoPetsListErrorUnauthorized(BaseModel):
model_config = ConfigDict(
extra="ignore", populate_by_name=True, protected_namespaces=()
extra="ignore", populate_by_name=True, protected_namespaces=(), defer_build=True
)

kind: Literal["Unauthorized"] = Field(
Expand All @@ -199,7 +205,7 @@ class MyapiProtoPetsListErrorUnauthorized(BaseModel):

class MyapiProtoPetsListErrorInternal(BaseModel):
model_config = ConfigDict(
extra="ignore", populate_by_name=True, protected_namespaces=()
extra="ignore", populate_by_name=True, protected_namespaces=(), defer_build=True
)

kind: Literal["Internal"] = Field(
Expand Down Expand Up @@ -228,10 +234,10 @@ class MyapiProtoPetsUpdateErrorValidationVariant(BaseModel):
"""Validation variant"""

model_config = ConfigDict(
extra="ignore", populate_by_name=True, protected_namespaces=()
extra="ignore", populate_by_name=True, protected_namespaces=(), defer_build=True
)

field_0: list[myapi.proto.ValidationError]
field_0: list[ValidationError]


# Externally tagged enum using RootModel
Expand Down Expand Up @@ -284,10 +290,10 @@ class MyapiProtoValidationErrorValidationAVariant(BaseModel):
"""ValidationA variant"""

model_config = ConfigDict(
extra="ignore", populate_by_name=True, protected_namespaces=()
extra="ignore", populate_by_name=True, protected_namespaces=(), defer_build=True
)

field_0: myapi.proto.ValidationA
field_0: ValidationA


# Externally tagged enum using RootModel
Expand Down
7 changes: 5 additions & 2 deletions reflectapi-demo/clients/typescript/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ export { ClientInstance };
export type { Client, RequestOptions };

type IsAny<T> = 0 extends 1 & T ? true : false;
export type NullToEmptyObject<T> =
IsAny<T> extends true ? unknown : T extends null ? {} : T;
export type NullToEmptyObject<T> = IsAny<T> extends true
? unknown
: T extends null
? {}
: T;

export type AsyncResult<T, E> = Promise<Result<T, Err<E>>>;

Expand Down
Loading
Loading