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