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
Hi, I followed the docs to enable swagger and it can load my endpoints correctly, however, when I expand any endpoint it only shows an infinite loading and throws the error Unhandled Promise Rejection: TypeError: Right side of assignment cannot be destructured. And the backend throws a warning | Invoked functions/apis/season.handler | +1442ms /Users/haoyuantang/Library/Caches/pypoetry/virtualenvs/functions-UNII4JFY-py3.12/lib/python3.12/site-packages/aws_lambda_powertools/event_handler/api_gateway.py:1682: UserWarning: You are using Pydantic v2, which is incompatible with OpenAPI schema 3.0. Forcing OpenAPI 3.1 | +1442ms spec = self.get_openapi_schema(.
Do I miss something?
Here is my backend code:
import boto3.dynamodb
import requests
from requests import Response
from aws_lambda_powertools import Logger, Tracer
from aws_lambda_powertools.event_handler import APIGatewayHttpResolver, Response
from aws_lambda_powertools.logging import correlation_paths
from aws_lambda_powertools.utilities.typing import LambdaContext
import boto3
from aws_lambda_powertools.utilities.parser import BaseModel
from pydantic import Field, AliasPath
from aws_lambda_powertools.event_handler.openapi.params import Body
from aws_lambda_powertools.shared.types import Annotated
import os
tracer = Tracer()
logger = Logger()
app = APIGatewayHttpResolver(enable_validation=True)
app.enable_swagger(path="/swagger")
dynamodb = boto3.resource("dynamodb")
seasonsTable = dynamodb.Table(os.environ.get("SEASONS_TABLE_NAME"))
class Season(BaseModel):
user_id: str
season_id: str
@app.get('/seasons')
@tracer.capture_method
def get_seasons():
seasons = seasonsTable.scan()
return seasons
@app.post("/seasons")
@tracer.capture_method
def create_season(season: Season):
seasonsTable.put_item(Item={
"userId": season.user_id,
"seasonId": season.season_id,
})
return Response(status_code=200)
# You can continue to use other utilities just as before
@logger.inject_lambda_context(correlation_id_path=correlation_paths.API_GATEWAY_HTTP)
@tracer.capture_lambda_handler
def handler(event: dict, context: LambdaContext) -> dict:
return app.resolve(event, context)
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
-
Hi, I followed the docs to enable swagger and it can load my endpoints correctly, however, when I expand any endpoint it only shows an infinite loading and throws the error
Unhandled Promise Rejection: TypeError: Right side of assignment cannot be destructured
. And the backend throws a warning| Invoked functions/apis/season.handler | +1442ms /Users/haoyuantang/Library/Caches/pypoetry/virtualenvs/functions-UNII4JFY-py3.12/lib/python3.12/site-packages/aws_lambda_powertools/event_handler/api_gateway.py:1682: UserWarning: You are using Pydantic v2, which is incompatible with OpenAPI schema 3.0. Forcing OpenAPI 3.1 | +1442ms spec = self.get_openapi_schema(
.Do I miss something?
Here is my backend code:
Beta Was this translation helpful? Give feedback.
All reactions