Код: Выделить всё
type: block_actions
container:
type: view
...
Код: Выделить всё
type: block_actions
container:
type: message
...
Код: Выделить всё
type: view_submission
...
Код: Выделить всё
class MessageContainer(BaseModel):
type: Literal["message"]
...
class ViewContainer(BaseModel):
type: Literal["view"]
...
class MessageActions(ActionsBase):
type: Literal["block_actions"]
container: MessageContainer
...
class ViewActions(ActionsBase):
type: Literal["block_actions"]
container: ViewContainer
...
class ViewSubmission(BaseModel):
type: Literal["view_submission"]
...
Код: Выделить всё
BlockActions = Annotated[
MessageActions | ViewActions,
Field(discriminator="container.type"),
]
SlackInteraction = Annotated[
ViewSubmission | BlockActions,
Field(discriminator="type"),
]
SlackInteractionAdapter = TypeAdapter(SlackInteraction)
Нужно ли мне отправлять их вручную или есть способ решить эту проблему с помощью Pydantic?
Подробнее здесь: https://stackoverflow.com/questions/793 ... ydantic-v2