RequestModel
为特定 Api+Path+ 方法配置请求模型。
语法
要在您的 AWS Serverless Application Model (AWS SAM) 模板中声明此实体,请使用以下语法。
YAML
Model:StringRequired:BooleanValidateBody:BooleanValidateParameters:Boolean
属性
-
Model -
在 AWS::Serverless::Api Models 属性中定义的模型的名称。
类型:字符串
必需:是
CloudFormation 兼容性:此属性为 AWS SAM 独有,没有 CloudFormation 等效属性。
-
Required -
在给定 API 端点的 OpenAPI 定义的参数部分中添加一个
required属性。类型:布尔值
必需:否
CloudFormation 兼容性:此属性为 AWS SAM 独有,没有 CloudFormation 等效属性。
-
ValidateBody -
指定 API Gateway 是否使用
Model验证请求正文。有关更多信息,请参阅《API Gateway 开发人员指南》中的在 API Gateway 中启用请求验证。类型:布尔值
必需:否
CloudFormation 兼容性:此属性为 AWS SAM 独有,没有 CloudFormation 等效属性。
-
ValidateParameters -
指定 API Gateway 是否使用
Model验证请求路径参数、查询字符串和标头。有关更多信息,请参阅《API Gateway 开发人员指南》中的在 API Gateway 中启用请求验证。类型:布尔值
必需:否
CloudFormation 兼容性:此属性为 AWS SAM 独有,没有 CloudFormation 等效属性。
示例
请求模型
请求模型示例
YAML
RequestModel: Model: User Required: true ValidateBody: true ValidateParameters: true