java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.core.Construct
software.amazon.awscdk.core.Resource
software.amazon.awscdk.services.apigateway.Model
All Implemented Interfaces:
IConstruct, IDependable, IResource, IModel, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:45.018Z") @Stability(Stable) public class Model extends Resource implements IModel
Example:

 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());
 
  • Field Details

    • EMPTY_MODEL

      @Stability(Stable) public static final IModel EMPTY_MODEL
      Represents a reference to a REST API's Empty model, which is available as part of the model collection by default.

      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" }

      See Also:
    • ERROR_MODEL

      @Stability(Stable) public static final IModel ERROR_MODEL
      Represents a reference to a REST API's Error model, which is available as part of the model collection by default.

      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" } } }

  • Constructor Details

    • Model

      protected Model(software.amazon.jsii.JsiiObjectRef objRef)
    • Model

      protected Model(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • Model

      @Stability(Stable) public Model(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull ModelProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • fromModelName

      @Stability(Stable) @NotNull public static IModel fromModelName(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String modelName)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      modelName - This parameter is required.
    • getModelId

      @Stability(Stable) @NotNull public String getModelId()
      Returns the model name, such as 'myModel'.
      Specified by:
      getModelId in interface IModel