class AssetApiDefinition
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.APIGateway.AssetApiDefinition |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsapigateway#AssetApiDefinition |
Java | software.amazon.awscdk.services.apigateway.AssetApiDefinition |
Python | aws_cdk.aws_apigateway.AssetApiDefinition |
TypeScript (source) | aws-cdk-lib » aws_apigateway » AssetApiDefinition |
Extends
Api
OpenAPI specification from a local file.
Example
const myApiDefinition = apigateway.ApiDefinition.fromAsset('path-to-file.json');
const specRestApi = new apigateway.SpecRestApi(this, 'my-specrest-api', {
deploy: false,
apiDefinition: myApiDefinition
});
// Use `stageName` to deploy to an existing stage
const deployment = new apigateway.Deployment(this, 'my-deployment', {
api: specRestApi,
stageName: 'dev',
retainDeployments: true, // keep old deployments
});
// Trigger a new deployment on OpenAPI definition updates
deployment.addToLogicalId(myApiDefinition);
Initializer
new AssetApiDefinition(path: string, options?: AssetOptions)
Parameters
- path
string
- options
Asset
Options
Methods
Name | Description |
---|---|
bind(scope) | Called when the specification is initialized to allow this object to bind to the stack, add resources and have fun. |
bind | Called after the CFN RestApi resource has been created to allow the Api Definition to bind to it. |
bind(scope)
public bind(scope: Construct): ApiDefinitionConfig
Parameters
- scope
Construct
Returns
Called when the specification is initialized to allow this object to bind to the stack, add resources and have fun.
AfterCreate(scope, restApi)
bindpublic bindAfterCreate(scope: Construct, restApi: IRestApi): void
Parameters
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.