小编Ray*_*oyd的帖子

API Gateway 请求验证器是否支持格式属性?

我已经在我的 API Gateway swagger 文件 (OAS 3.0) 中添加了一个请求验证器。当我通过传入无效的请求正文来测试验证时,我收到的错误消息包含我不理解的错误。重现步骤如下。

  1. 使用以下招摇创建一个新的 api 网关:
openapi: 3.0.0
info:
  version: "1"
  title: Request Validation Example
  description: |
    ## Request Validation
    Minimal swagger to reproduce request validation errors.

x-amazon-apigateway-request-validators: 
  all:
    validateRequestBody: true
    validateRequestParameters: true
x-amazon-apigateway-gateway-responses:
  BAD_REQUEST_BODY:
    statusCode: 400
    responseTemplates:
      application/json: |
        {
          message: $context.error.messageString
          errors: $context.error.validationErrorString
        }
paths:
  /employee:
    post:
      x-amazon-apigateway-request-validator: all
      summary: Create a new Employee
      operationId: CreateEmployee
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Employee"
        required: true
      responses:
        "201":
          description: Created
          $ref: "#/components/responses/200"
components:
  responses:
    "200": …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services aws-api-gateway

7
推荐指数
1
解决办法
850
查看次数