AWS::ApiGatewayV2::Model - AWS CloudFormation

AWS::ApiGatewayV2::Model

The AWS::ApiGatewayV2::Model resource updates data model for a WebSocket API. For more information, see Model Selection Expressions in the API Gateway Developer Guide.

Syntax

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

JSON

{ "Type" : "AWS::ApiGatewayV2::Model", "Properties" : { "ApiId" : String, "ContentType" : String, "Description" : String, "Name" : String, "Schema" : Json } }

YAML

Type: AWS::ApiGatewayV2::Model Properties: ApiId: String ContentType: String Description: String Name: String Schema: Json

Properties

ApiId

The API identifier.

Required: Yes

Type: String

Update requires: Replacement

ContentType

The content-type for the model, for example, "application/json".

Required: No

Type: String

Update requires: No interruption

Description

The description of the model.

Required: No

Type: String

Update requires: No interruption

Name

The name of the model.

Required: Yes

Type: String

Update requires: No interruption

Schema

The schema for the model. For application/json models, this should be JSON schema draft 4 model.

Required: Yes

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 ID, such as abc123.

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

Fn::GetAtt

The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.

ModelId

The model ID.

Examples

Model creation example

The following example creates a model resource called MyModel for an API called MyApi.

JSON

{ "MyModel": { "Type": "AWS::ApiGatewayV2::Model", "Properties": { "Name": "ModelName", "ApiId": { "Ref": "MyApi" }, "ContentType": "application/json", "Schema": { "$schema": "http://json-schema.org/draft-04/schema#", "title": "DummySchema", "type": "object", "properties": { "id": { "type": "string" } } } } } }

YAML

MyModel: Type: 'AWS::ApiGatewayV2::Model' Properties: Name: ModelName ApiId: !Ref MyApi ContentType: application/json Schema: $schema: 'http://json-schema.org/draft-04/schema#' title: DummySchema type: object properties: id: type: string

See also

  • CreateModel in the Amazon API Gateway Version 2 API Reference