Menu
AWS CloudFormation
User Guide (API Version 2010-05-15)

AWS::ApiGateway::Model

The AWS::ApiGateway::Model resource defines the structure of a request or response payload for an Amazon API Gateway (API Gateway) method.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

Copy
{ "Type" : "AWS::ApiGateway::Model", "Properties" : { "ContentType" : String, "Description" : String, "Name" : String, "RestApiId" : String, "Schema" : JSON object } }

YAML

Copy
Type: "AWS::ApiGateway::Model" Properties: ContentType: String Description: String Name: String RestApiId: String Schema: JSON object

Properties

ContentType

The content type for the model.

Required: Yes

Type: String

Update requires: Replacement

Description

A description that identifies this model.

Required: No

Type: String

Update requires: No interruption

Name

A name for the mode. 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 ID of a REST API with which to associate this model.

Required: Yes

Type: String

Update requires: Replacement

Schema

The schema to use to transform data to one or more output formats. Specify null ({}) if you don't want to specify a schema.

Required: Yes

Type: JSON object

Update requires: No interruption

Return Value

Ref

When the logical ID of this resource is provided to the Ref intrinsic function, Ref returns the model name, such as myModel.

For more information about using the Ref function, see Ref.

Example

The following example creates a model that transforms input data into the described schema.

JSON

Copy
"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

Copy
PetsModelNoFlatten: Type: "AWS::ApiGateway::Model" Properties: RestApiId: Ref: "RestApi" ContentType: "application/json" Description: "Schema for Pets example" Name: "PetsModelNoFlatten" Schema: Fn::Join: - "" - - "{" - " \"$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\" }" - " }" - " }" - "}"