Class AssetApiDefinition
OpenAPI specification from a local file.
Inherited Members
Namespace: Amazon.CDK.AWS.APIGateway
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class AssetApiDefinition : ApiDefinition
Syntax (vb)
Public Class AssetApiDefinition Inherits ApiDefinition
Remarks
ExampleMetadata: infused
Examples
var myApiDefinition = ApiDefinition.FromAsset("path-to-file.json");
var specRestApi = new SpecRestApi(this, "my-specrest-api", new SpecRestApiProps {
Deploy = false,
ApiDefinition = myApiDefinition
});
// Use `stageName` to deploy to an existing stage
var deployment = new Deployment(this, "my-deployment", new DeploymentProps {
Api = specRestApi,
StageName = "dev",
RetainDeployments = true
});
// Trigger a new deployment on OpenAPI definition updates
deployment.AddToLogicalId(myApiDefinition);
Synopsis
Constructors
AssetApiDefinition(string, IAssetOptions?) | OpenAPI specification from a local file. |
Methods
Bind(Construct) | Called when the specification is initialized to allow this object to bind to the stack, add resources and have fun. |
BindAfterCreate(Construct, IRestApi) | Called after the CFN RestApi resource has been created to allow the Api Definition to bind to it. |
Constructors
AssetApiDefinition(string, IAssetOptions?)
OpenAPI specification from a local file.
public AssetApiDefinition(string path, IAssetOptions? options = null)
Parameters
- path string
- options IAssetOptions
Remarks
ExampleMetadata: infused
Examples
var myApiDefinition = ApiDefinition.FromAsset("path-to-file.json");
var specRestApi = new SpecRestApi(this, "my-specrest-api", new SpecRestApiProps {
Deploy = false,
ApiDefinition = myApiDefinition
});
// Use `stageName` to deploy to an existing stage
var deployment = new Deployment(this, "my-deployment", new DeploymentProps {
Api = specRestApi,
StageName = "dev",
RetainDeployments = true
});
// Trigger a new deployment on OpenAPI definition updates
deployment.AddToLogicalId(myApiDefinition);
Methods
Bind(Construct)
Called when the specification is initialized to allow this object to bind to the stack, add resources and have fun.
public override IApiDefinitionConfig Bind(Construct scope)
Parameters
- scope Construct
Returns
Overrides
Remarks
ExampleMetadata: infused
BindAfterCreate(Construct, IRestApi)
Called after the CFN RestApi resource has been created to allow the Api Definition to bind to it.
public override void BindAfterCreate(Construct scope, IRestApi restApi)
Parameters
- scope Construct
- restApi IRestApi
Overrides
Remarks
Specifically it's required to allow assets to add metadata for tooling like SAM CLI to be able to find their origins.