API Gateway REST API Request Body Validations not working when created from Serverless template

0

update: My first question here and it's been flagged. I re-read the community guidelines, so if this question - related to AWS API Gateway - violates some guideline I'm missing, please let me know.

Referencing this post and the Serverless docs, I've appeared to have configured request body validation correctly in my serverless template (and verified as much in the AWS API Gateway dashboard), however, the request body validations I've configured are not firing when calling the invoke url.

API settings in my root serverless.yml are as follows:

provider:
  name: aws
  runtime: nodejs18.x
  region: us-west-2
  profile: myApplication
  environment: 
    LOGGING_SVC_FUNC: !Sub myApplication-api-gateway-${sls:stage}-loggingService
    MOESIF_APP_ID: ${param:moesif-app-id}
    # ${file(env.${sls:stage}.json)}
  apiName: myApplication-api-gateway-${sls:stage}
  endpointType: EDGE
  logs:
    restApi:
      accessLogging: true
      executionLogging: false
      format: '{"apiId": "$context.apiId","requestId": "$context.requestId","requestTime": "$context.requestTime","protocol": "$context.protocol","httpMethod": "$context.httpMethod","resourcePath": "$context.path","requestHostHeader": "$context.domainName","requestUserAgentHeader": "$context.identity.userAgent","ip": "$context.identity.sourceIp","status": "$context.status","responseLength": "$context.responseLength","durationMs": "$context.responseLatency","caller": "$context.identity.caller","user": "$context.authorizer.client_id","principalId": "$context.authorizer.principalId","cognitoIdentityId": "$context.identity.cognitoIdentityId","userArn": "$context.identity.userArn","apiKey": "$context.identity.apiKey","apiKeyId": "$context.identity.apiKeyId"}'
  apiGateway:
    binaryMediaTypes: 
      - '*/*'
    apiKeySourceType: AUTHORIZER
    description: myApplication partner API
    disableDefaultEndpoint: true

While my actual validation model varies from this, the request body validation fails even when using the following template or templates pulled directly from AWS' site:

	
{
  "definitions": {},
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "title": "The Root Schema",
  "required": [
    "username"
  ],
  "properties": {
    "username": {
      "type": "string",
      "title": "The Foo Schema",
      "default": "",
      "pattern": "^[a-zA-Z0-9]+$"
    }
  }
}

Note that I am using a custom lambda authorizer and the custom access logging as defined above.

Anyone else experiencing this issue? Thanks much.

답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인