Class Model
Inherited Members
Namespace: Amazon.CDK.AWS.APIGateway
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Model : Resource, IResource, IModel
Syntax (vb)
Public Class Model
Inherits Resource
Implements IResource, IModel
Remarks
ExampleMetadata: infused
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 } }
}
}
});
Synopsis
Constructors
Model(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
Model(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Model(Construct, String, IModelProps) |
Properties
EMPTY_MODEL | Represents a reference to a REST API's Empty model, which is available as part of the model collection by default. |
ERROR_MODEL | Represents a reference to a REST API's Error model, which is available as part of the model collection by default. |
ModelId | Returns the model name, such as 'myModel'. |
Methods
FromModelName(Construct, String, String) |
Constructors
Model(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected Model(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
Model(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected Model(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Model(Construct, String, IModelProps)
public Model(Construct scope, string id, IModelProps props)
Parameters
- scope Constructs.Construct
- id System.String
- props IModelProps
Properties
EMPTY_MODEL
Represents a reference to a REST API's Empty model, which is available as part of the model collection by default.
public static IModel EMPTY_MODEL { get; }
Property Value
Remarks
This can be used for mapping JSON responses from an integration to what is returned to a client, where strong typing is not required. In the absence of any defined model, the Empty model will be used to return the response payload unmapped.
Definition { "$schema" : "http://json-schema.org/draft-04/schema#", "title" : "Empty Schema", "type" : "object" }
ERROR_MODEL
Represents a reference to a REST API's Error model, which is available as part of the model collection by default.
public static IModel ERROR_MODEL { get; }
Property Value
Remarks
This can be used for mapping error JSON responses from an integration to a client, where a simple generic message field is sufficient to map and return an error payload.
Definition { "$schema" : "http://json-schema.org/draft-04/schema#", "title" : "Error Schema", "type" : "object", "properties" : { "message" : { "type" : "string" } } }
ModelId
Returns the model name, such as 'myModel'.
public virtual string ModelId { get; }
Property Value
System.String
Remarks
Attribute: true
Methods
FromModelName(Construct, String, String)
public static IModel FromModelName(Construct scope, string id, string modelName)
Parameters
- scope Constructs.Construct
- id System.String
- modelName System.String
Returns