-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a structured object enum fallback
- Loading branch information
1 parent
d21d8fc
commit 84a0d37
Showing
4 changed files
with
257 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
tests/codegen/snapshot/snapshots/test_unknown_enum/enumService/needsEnumObject.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
# ruff: noqa | ||
# Code generated by river.codegen. DO NOT EDIT. | ||
from collections.abc import AsyncIterable, AsyncIterator | ||
import datetime | ||
from typing import ( | ||
Any, | ||
Callable, | ||
Dict, | ||
List, | ||
Literal, | ||
Optional, | ||
Mapping, | ||
NewType, | ||
NotRequired, | ||
Union, | ||
Tuple, | ||
TypedDict, | ||
) | ||
|
||
from pydantic import BaseModel, Field, TypeAdapter | ||
from replit_river.error_schema import RiverError | ||
|
||
import replit_river as river | ||
|
||
|
||
encode_NeedsenumobjectInputOneOf_in_first: Callable[ | ||
["NeedsenumobjectInputOneOf_in_first"], Any | ||
] = lambda x: { | ||
k: v | ||
for (k, v) in ( | ||
{ | ||
"$kind": x.get("kind"), | ||
"value": x.get("value"), | ||
} | ||
).items() | ||
if v is not None | ||
} | ||
|
||
|
||
class NeedsenumobjectInputOneOf_in_first(TypedDict): | ||
kind: Literal["in_first"] | ||
value: str | ||
|
||
|
||
encode_NeedsenumobjectInputOneOf_in_second: Callable[ | ||
["NeedsenumobjectInputOneOf_in_second"], Any | ||
] = lambda x: { | ||
k: v | ||
for (k, v) in ( | ||
{ | ||
"$kind": x.get("kind"), | ||
"bleep": x.get("bleep"), | ||
} | ||
).items() | ||
if v is not None | ||
} | ||
|
||
|
||
class NeedsenumobjectInputOneOf_in_second(TypedDict): | ||
kind: Literal["in_second"] | ||
bleep: int | ||
|
||
|
||
NeedsenumobjectInput = ( | ||
NeedsenumobjectInputOneOf_in_first | NeedsenumobjectInputOneOf_in_second | ||
) | ||
|
||
encode_NeedsenumobjectInput: Callable[["NeedsenumobjectInput"], Any] = ( | ||
lambda x: encode_NeedsenumobjectInputOneOf_in_first(x) | ||
if x["kind"] == "in_first" | ||
else encode_NeedsenumobjectInputOneOf_in_second(x) | ||
) | ||
|
||
|
||
class NeedsenumobjectOutputFooOneOf_out_first(BaseModel): | ||
kind: Literal["out_first"] = Field( | ||
"out_first", | ||
alias="$kind", # type: ignore | ||
) | ||
|
||
foo: int | ||
|
||
|
||
class NeedsenumobjectOutputFooOneOf_out_second(BaseModel): | ||
kind: Literal["out_second"] = Field( | ||
"out_second", | ||
alias="$kind", # type: ignore | ||
) | ||
|
||
bar: int | ||
|
||
|
||
NeedsenumobjectOutputFooAnyOf__Unknown = NewType( | ||
"NeedsenumobjectOutputFooAnyOf__Unknown", object | ||
) | ||
NeedsenumobjectOutputFoo = ( | ||
NeedsenumobjectOutputFooOneOf_out_first | ||
| NeedsenumobjectOutputFooOneOf_out_second | ||
| NeedsenumobjectOutputFooAnyOf__Unknown | ||
) | ||
|
||
|
||
class NeedsenumobjectOutput(BaseModel): | ||
foo: Optional[NeedsenumobjectOutputFoo] = None | ||
|
||
|
||
class NeedsenumobjectErrorsFooAnyOf_0(RiverError): | ||
beep: Optional[Literal["err_first"]] = None | ||
|
||
|
||
class NeedsenumobjectErrorsFooAnyOf_1(RiverError): | ||
borp: Optional[Literal["err_second"]] = None | ||
|
||
|
||
NeedsenumobjectErrorsFooAnyOf__Unknown = NewType( | ||
"NeedsenumobjectErrorsFooAnyOf__Unknown", object | ||
) | ||
NeedsenumobjectErrorsFoo = ( | ||
NeedsenumobjectErrorsFooAnyOf_0 | ||
| NeedsenumobjectErrorsFooAnyOf_1 | ||
| NeedsenumobjectErrorsFooAnyOf__Unknown | ||
) | ||
|
||
|
||
class NeedsenumobjectErrors(RiverError): | ||
foo: Optional[NeedsenumobjectErrorsFoo] = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters