Table of Contents

Class ModelOptions

Namespace
Amazon.CDK.AWS.APIGateway
Assembly
Amazon.CDK.AWS.APIGateway.dll
public class ModelOptions : IModelOptions
Inheritance
ModelOptions
Implements
Inherited Members

Examples

RestApi api;


            // We define the JSON Schema for the transformed valid response
            var responseModel = api.AddModel("ResponseModel", new ModelOptions {
                ContentType = "application/json",
                ModelName = "ResponseModel",
                Schema = new JsonSchema {
                    Schema = JsonSchemaVersion.DRAFT4,
                    Title = "pollResponse",
                    Type = JsonSchemaType.OBJECT,
                    Properties = new Dictionary<string, JsonSchema> {
                        { "state", new JsonSchema { Type = JsonSchemaType.STRING } },
                        { "greeting", new JsonSchema { Type = JsonSchemaType.STRING } }
                    }
                }
            });

            // We define the JSON Schema for the transformed error response
            var errorResponseModel = api.AddModel("ErrorResponseModel", new ModelOptions {
                ContentType = "application/json",
                ModelName = "ErrorResponseModel",
                Schema = new JsonSchema {
                    Schema = JsonSchemaVersion.DRAFT4,
                    Title = "errorResponse",
                    Type = JsonSchemaType.OBJECT,
                    Properties = new Dictionary<string, JsonSchema> {
                        { "state", new JsonSchema { Type = JsonSchemaType.STRING } },
                        { "message", new JsonSchema { Type = JsonSchemaType.STRING } }
                    }
                }
            });

Remarks

ExampleMetadata: infused

Constructors

ModelOptions()

public ModelOptions()

Properties

ContentType

The content type for the model.

public string? ContentType { get; set; }

Property Value

string

Remarks

You can also force a content type in the request or response model mapping.

Default: 'application/json'

Description

A description that identifies this model.

public string? Description { get; set; }

Property Value

string

Remarks

Default: None

ModelName

public string? ModelName { get; set; }

Property Value

string

Schema

The schema to use to transform data to one or more output formats.

public IJsonSchema Schema { get; set; }

Property Value

IJsonSchema

Remarks

Specify null ({}) if you don't want to specify a schema.