AWS CloudFormation
User Guide (Version )

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

A description that identifies this 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 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: 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