Class ApiDefinition

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.apigateway.ApiDefinition
All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
Direct Known Subclasses:
AssetApiDefinition, InlineApiDefinition, S3ApiDefinition

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:44.689Z") @Stability(Stable) public abstract class ApiDefinition extends software.amazon.jsii.JsiiObject
Represents an OpenAPI definition asset.

Example:

 Integration integration;
 SpecRestApi api = SpecRestApi.Builder.create(this, "books-api")
         .apiDefinition(ApiDefinition.fromAsset("path-to-file.json"))
         .build();
 Resource booksResource = api.root.addResource("books");
 booksResource.addMethod("GET", integration);
 
  • Nested Class Summary

    Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject

    software.amazon.jsii.JsiiObject.InitializationMode
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
    protected
    ApiDefinition(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    ApiDefinition(software.amazon.jsii.JsiiObjectRef objRef)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    bind(Construct scope)
    Called when the specification is initialized to allow this object to bind to the stack, add resources and have fun.
    void
    bindAfterCreate(Construct _scope, IRestApi _restApi)
    Called after the CFN RestApi resource has been created to allow the Api Definition to bind to it.
    Loads the API specification from a local disk asset.
    fromAsset(String file, AssetOptions options)
    Loads the API specification from a local disk asset.
    fromBucket(IBucket bucket, String key)
    Creates an API definition from a specification file in an S3 bucket.
    fromBucket(IBucket bucket, String key, String objectVersion)
    Creates an API definition from a specification file in an S3 bucket.
    fromInline(Object definition)
    Create an API definition from an inline object.

    Methods inherited from class software.amazon.jsii.JsiiObject

    jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface software.amazon.jsii.JsiiSerializable

    $jsii$toJson
  • Constructor Details

    • ApiDefinition

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

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

      @Stability(Stable) protected ApiDefinition()
  • Method Details

    • fromAsset

      @Stability(Stable) @NotNull public static AssetApiDefinition fromAsset(@NotNull String file, @Nullable AssetOptions options)
      Loads the API specification from a local disk asset.

      Parameters:
      file - This parameter is required.
      options -
    • fromAsset

      @Stability(Stable) @NotNull public static AssetApiDefinition fromAsset(@NotNull String file)
      Loads the API specification from a local disk asset.

      Parameters:
      file - This parameter is required.
    • fromBucket

      @Stability(Stable) @NotNull public static S3ApiDefinition fromBucket(@NotNull IBucket bucket, @NotNull String key, @Nullable String objectVersion)
      Creates an API definition from a specification file in an S3 bucket.

      Parameters:
      bucket - This parameter is required.
      key - This parameter is required.
      objectVersion -
    • fromBucket

      @Stability(Stable) @NotNull public static S3ApiDefinition fromBucket(@NotNull IBucket bucket, @NotNull String key)
      Creates an API definition from a specification file in an S3 bucket.

      Parameters:
      bucket - This parameter is required.
      key - This parameter is required.
    • fromInline

      @Stability(Stable) @NotNull public static InlineApiDefinition fromInline(@NotNull Object definition)
      Create an API definition from an inline object.

      The inline object must follow the schema of OpenAPI 2.0 or OpenAPI 3.0

      Example:

       ApiDefinition.fromInline(Map.of(
               "openapi", "3.0.2",
               "paths", Map.of(
                       "/pets", Map.of(
                               "get", Map.of(
                                       "responses", Map.of(
                                               200, Map.of(
                                                       "content", Map.of(
                                                               "application/json", Map.of(
                                                                       "schema", Map.of(
                                                                               "$ref", "#/components/schemas/Empty"))))),
                                       "x-amazon-apigateway-integration", Map.of(
                                               "responses", Map.of(
                                                       "default", Map.of(
                                                               "statusCode", "200")),
                                               "requestTemplates", Map.of(
                                                       "application/json", "{\"statusCode\": 200}"),
                                               "passthroughBehavior", "when_no_match",
                                               "type", "mock")))),
               "components", Map.of(
                       "schemas", Map.of(
                               "Empty", Map.of(
                                       "title", "Empty Schema",
                                       "type", "object")))));
       

      Parameters:
      definition - This parameter is required.
    • bind

      @Stability(Stable) @NotNull public abstract ApiDefinitionConfig bind(@NotNull Construct scope)
      Called when the specification is initialized to allow this object to bind to the stack, add resources and have fun.

      Parameters:
      scope - The binding scope. This parameter is required.
    • bindAfterCreate

      @Stability(Stable) public void bindAfterCreate(@NotNull Construct _scope, @NotNull IRestApi _restApi)
      Called after the CFN RestApi resource has been created to allow the Api Definition to bind to it.

      Specifically it's required to allow assets to add metadata for tooling like SAM CLI to be able to find their origins.

      Parameters:
      _scope - This parameter is required.
      _restApi - This parameter is required.