Feature request: Support types annotated with Field for event_handler validation #5953
Open
1 of 2 tasks
Labels
feature-request
feature request
Uh oh!
There was an error while loading. Please reload this page.
Use case
Hi, thank you for working on Powertools.
My Pydantic models are shared between multiple applications. For example, a client application builds an instance of a model and submits it to the API, which validates the request against the same model.
A few types I want to accept as API payloads or parameters are annotated with
Field
, mainly tagged unions.I am aware of the Powertools OpenAPI
Param
annotations, but they have downsides:Param
type (i.e.Body
,Path
, etc) per annotated type, or having to duplicate the arguments for different typesWith Powertools 3.5.0, the example code below fails:
def create_action(action: Action)
:AssertionError: Param: action can only be a request body, use Body()
def create_action(action: Annotated[Action, Body()])
:AssertionError: Only one FieldInfo can be used per parameter
It would be nice if
event_handler
would allow nestedField
annotations, so that I can applyAnnotated[some_type, Body()]
to an existing annotated type such as a tagged union.Thank you for considering.
Solution/User Experience
Alternative solutions
Acknowledgment
The text was updated successfully, but these errors were encountered: