我想通过无服务器设置 API 网关的请求验证器。我为请求验证器尝试了两种不同的设置。但是,这两种方法都失败了。我已经总结了我所做的,所以如果有什么问题,请告诉我。
sls deploy使用下面的swagger.yaml和之后serverless.yml,没有将 中描述的验证模式x-amazon-apigateway-request-validators添加到请求验证器选项中。
https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-request-validator.htmlswagger.yaml 在下面:
openapi: 3.0.0
info:
description: xxx
version: '0.1'
title: xxx API
x-amazon-apigateway-request-validators:
body-only:
validateRequestBody: true,
validateRequestParameters: false
except-body:
validateRequestBody: false,
validateRequestParameters: true
all:
validateRequestBody: true,
validateRequestParameters: true
tags:
- name: auth
description: xxx
paths:
/login:
post:
tags:
- auth
summary: xxx
description: ''
x-amazon-apigateway-request-validator: all
responses:
'200':
description: success
content:
application/json:
schema:
$ref: '#/components/schemas/AuthResponse'
'400':
description: fail
content:
application/json …Run Code Online (Sandbox Code Playgroud) swagger aws-api-gateway serverless-framework serverless aws-serverless
表达{ a: 1 }不是问题
但 Rubocop 的 point( Lint/Syntax: unexpected token tCOLON(Using Ruby 3.1 parser; configure using TargetRubyVersion parameter, under AllCops)) 出现在表达式 中
puts { a: 1 }。
有谁知道为什么这个声明违反规则?如果您有参考资料,请给我它的网址,我将不胜感激。
我使用 rubocop 版本 1.24.1 并设置TargetRubyVersion在.rubocop.yml. ruby 版本 2.7、3.0 和 3.1 均经过测试,结果相同。