@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-19T20:26:36.196Z") @Stability(value=Stable) public class Model extends Resource implements IModel
RestApi api;
// We define the JSON Schema for the transformed valid response
Model responseModel = api.addModel("ResponseModel", ModelOptions.builder()
.contentType("application/json")
.modelName("ResponseModel")
.schema(JsonSchema.builder()
.schema(JsonSchemaVersion.DRAFT4)
.title("pollResponse")
.type(JsonSchemaType.OBJECT)
.properties(Map.of(
"state", JsonSchema.builder().type(JsonSchemaType.STRING).build(),
"greeting", JsonSchema.builder().type(JsonSchemaType.STRING).build()))
.build())
.build());
// We define the JSON Schema for the transformed error response
Model errorResponseModel = api.addModel("ErrorResponseModel", ModelOptions.builder()
.contentType("application/json")
.modelName("ErrorResponseModel")
.schema(JsonSchema.builder()
.schema(JsonSchemaVersion.DRAFT4)
.title("errorResponse")
.type(JsonSchemaType.OBJECT)
.properties(Map.of(
"state", JsonSchema.builder().type(JsonSchemaType.STRING).build(),
"message", JsonSchema.builder().type(JsonSchemaType.STRING).build()))
.build())
.build());
| Modifier and Type | Class and Description |
|---|---|
static class |
Model.Builder
A fluent builder for
Model. |
software.amazon.jsii.JsiiObject.InitializationModeIModel.Jsii$Default, IModel.Jsii$ProxyIResource.Jsii$Default| Modifier and Type | Field and Description |
|---|---|
static IModel |
EMPTY_MODEL
Represents a reference to a REST API's Empty model, which is available as part of the model collection by default.
|
static IModel |
ERROR_MODEL
Represents a reference to a REST API's Error model, which is available as part of the model collection by default.
|
| Modifier | Constructor and Description |
|---|---|
|
Model(software.constructs.Construct scope,
String id,
ModelProps props) |
protected |
Model(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
Model(software.amazon.jsii.JsiiObjectRef objRef) |
| Modifier and Type | Method and Description |
|---|---|
static IModel |
fromModelName(software.constructs.Construct scope,
String id,
String modelName) |
String |
getModelId()
Returns the model name, such as 'myModel'.
|
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResourcejsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet@Stability(value=Stable) public static final IModel EMPTY_MODEL
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" }
@Stability(value=Stable) public static final IModel ERROR_MODEL
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" } } }
protected Model(software.amazon.jsii.JsiiObjectRef objRef)
protected Model(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable)
public Model(@NotNull
software.constructs.Construct scope,
@NotNull
String id,
@NotNull
ModelProps props)
scope - This parameter is required.id - This parameter is required.props - This parameter is required.@Stability(value=Stable) @NotNull public static IModel fromModelName(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String modelName)
scope - This parameter is required.id - This parameter is required.modelName - This parameter is required.@Stability(value=Stable) @NotNull public String getModelId()
getModelId in interface IModelCopyright © 2022. All rights reserved.