You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using the examples from https://docs.powertools.aws.dev/lambda/python/latest/core/event_handler/api_gateway/#lambda-function-url for a dict return value from a route, I'd like to keep that as a nested object within the body property but this always gets serialized to a JSON string.
e.g. @app.get("/timings/<year>/<month>") def get_timings_by_month_year(year: Annotated[int, Path(ge=2023,le=datetime.now().year)], month: Annotated[int, Path(le=12, ge=1)]) -> dict: return {"timings": "some timings"}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
using the examples from https://docs.powertools.aws.dev/lambda/python/latest/core/event_handler/api_gateway/#lambda-function-url for a dict return value from a route, I'd like to keep that as a nested object within the body property but this always gets serialized to a JSON string.
e.g.
@app.get("/timings/<year>/<month>") def get_timings_by_month_year(year: Annotated[int, Path(ge=2023,le=datetime.now().year)], month: Annotated[int, Path(le=12, ge=1)]) -> dict: return {"timings": "some timings"}
returns
{ "statusCode": 200, "body": "{\"timings\":\"some timings\"}", "isBase64Encoded": false, "headers": { "Content-Type": "application/json" }, "cookies": [] }
I would like it to return
{ "statusCode": 200, "body": { "timings": "some timings" }, "isBase64Encoded": false, "headers": { "Content-Type": "application/json" }, "cookies": [] }
is this possible?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions