AWS::ApiGateway::Model
The AWS::ApiGateway::Model
resource defines the structure of a request or response payload for an API method.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::ApiGateway::Model", "Properties" : { "ContentType" :
String
, "Description" :String
, "Name" :String
, "RestApiId" :String
, "Schema" :Json
} }
YAML
Type: AWS::ApiGateway::Model Properties: ContentType:
String
Description:String
Name:String
RestApiId:String
Schema:Json
Properties
ContentType
-
The content-type for the model.
Required: No
Type: String
Update requires: Replacement
Description
-
The description of the model.
Required: No
Type: String
Update requires: No interruption
Name
-
A name for the model. If you don't specify a name, AWS CloudFormation generates a unique physical ID and uses that ID for the model name. For more information, see Name Type.
Important
If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name.
Required: No
Type: String
Update requires: Replacement
RestApiId
-
The string identifier of the associated RestApi.
Required: Yes
Type: String
Update requires: Replacement
Schema
-
The schema for the model. For
application/json
models, this should be JSON schema draft 4 model. Do not include "\*/" characters in the description of any properties because such "\*/" characters may be interpreted as the closing marker for comments in some languages, such as Java or JavaScript, causing the installation of your API's SDK generated by API Gateway to fail.Required: No
Type: Json
Update requires: No interruption
Return values
Ref
When you pass the logical ID of this resource to the intrinsic Ref
function, Ref
returns the model name, such as myModel
.
For more information about using the Ref
function, see Ref
.
Examples
Create model
The following example creates a model that transforms input data into the described schema.
JSON
{ "PetsModelNoFlatten": { "Type": "AWS::ApiGateway::Model", "Properties": { "RestApiId": { "Ref": "RestApi" }, "ContentType": "application/json", "Description": "Schema for Pets example", "Name": "PetsModelNoFlatten", "Schema": { "$schema": "http://json-schema.org/draft-04/schema#", "title": "PetsModelNoFlatten", "type": "array", "items": { "type": "object", "properties": { "number": { "type": "integer" }, "class": { "type": "string" }, "salesPrice": { "type": "number" } } } } } } }
YAML
PetsModelNoFlatten: Type: 'AWS::ApiGateway::Model' Properties: RestApiId: !Ref RestApi ContentType: application/json Description: Schema for Pets example Name: PetsModelNoFlatten Schema: $schema: 'http://json-schema.org/draft-04/schema#' title: PetsModelNoFlatten type: array items: type: object properties: number: type: integer class: type: string salesPrice: type: number
See also
-
model:create in the Amazon API Gateway REST API Reference