We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This schema with custom type name in metadata field:
{ "discriminator": "eventType", "mapping": { "USER_CREATED": { "metadata": { "typescriptType": "UserCreatedEvent", "pythonType": "UserCreatedEvent" }, "properties": { "id": { "type": "string" } } }, "USER_DELETED": { "properties": { "id": { "type": "string" }, "softDelete": { "type": "boolean" } } } } }
does not generate discriminated variant USER_CREATED:
USER_CREATED
export type Test = TestUserCreated | TestUserDeleted; export interface TestUserDeleted { eventType: "USER_DELETED"; id: string; softDelete: boolean; }
@dataclass class Test: event_type: 'str' @classmethod def from_json_data(cls, data: Any) -> 'Test': variants: Dict[str, Type[Test]] = { "USER_CREATED": TestUserCreated, "USER_DELETED": TestUserDeleted, } return variants[data["eventType"]].from_json_data(data) # ... @dataclass class TestUserDeleted(Test): id: 'str' soft_delete: 'bool' # ...
The text was updated successfully, but these errors were encountered:
No branches or pull requests
This schema with custom type name in metadata field:
does not generate discriminated variant
USER_CREATED
:The text was updated successfully, but these errors were encountered: