@Generated(value="jsii-pacmak/1.74.0 (build 6d08790)",
date="2023-03-28T21:34:26.637Z")
public abstract class ApiDefinition
extends software.amazon.jsii.JsiiObject
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);
Modifier | Constructor and Description |
---|---|
protected |
ApiDefinition() |
protected |
ApiDefinition(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
ApiDefinition(software.amazon.jsii.JsiiObjectRef objRef) |
Modifier and Type | Method and Description |
---|---|
abstract ApiDefinitionConfig |
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.
|
static AssetApiDefinition |
fromAsset(java.lang.String file)
Loads the API specification from a local disk asset.
|
static AssetApiDefinition |
fromAsset(java.lang.String file,
AssetOptions options)
Loads the API specification from a local disk asset.
|
static S3ApiDefinition |
fromBucket(IBucket bucket,
java.lang.String key)
Creates an API definition from a specification file in an S3 bucket.
|
static S3ApiDefinition |
fromBucket(IBucket bucket,
java.lang.String key,
java.lang.String objectVersion)
Creates an API definition from a specification file in an S3 bucket.
|
static InlineApiDefinition |
fromInline(java.lang.Object definition)
Create an API definition from an inline object.
|
protected ApiDefinition(software.amazon.jsii.JsiiObjectRef objRef)
protected ApiDefinition(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
protected ApiDefinition()
public static AssetApiDefinition fromAsset(java.lang.String file, AssetOptions options)
file
- This parameter is required.options
- public static AssetApiDefinition fromAsset(java.lang.String file)
file
- This parameter is required.public static S3ApiDefinition fromBucket(IBucket bucket, java.lang.String key, java.lang.String objectVersion)
bucket
- This parameter is required.key
- This parameter is required.objectVersion
- public static S3ApiDefinition fromBucket(IBucket bucket, java.lang.String key)
bucket
- This parameter is required.key
- This parameter is required.public static InlineApiDefinition fromInline(java.lang.Object definition)
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")))));
definition
- This parameter is required.public abstract ApiDefinitionConfig bind(Construct scope)
scope
- The binding scope. This parameter is required.public void bindAfterCreate(Construct _scope, IRestApi _restApi)
Specifically it's required to allow assets to add metadata for tooling like SAM CLI to be able to find their origins.
_scope
- This parameter is required._restApi
- This parameter is required.