Interface IModelOptions
- Namespace
- Amazon.CDK.AWS.APIGateway
- Assembly
- Amazon.CDK.AWS.APIGateway.dll
public interface IModelOptions
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
Properties
ContentType
The content type for the model.
string? ContentType { get; }
Property Value
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.
string? Description { get; }
Property Value
Remarks
Default: None
ModelName
string? ModelName { get; }
Property Value
Schema
The schema to use to transform data to one or more output formats.
IJsonSchema Schema { get; }
Property Value
Remarks
Specify null ({}) if you don't want to specify a schema.