Class SpecRestApi
- Namespace
- Amazon.CDK.AWS.APIGateway
- Assembly
- Amazon.CDK.AWS.APIGateway.dll
Represents a REST API in Amazon API Gateway, created with an OpenAPI specification.
public class SpecRestApi : RestApiBase, IRestApi, IResource, IConstruct, IConstruct, IDependable
- Inheritance
-
SpecRestApi
- Implements
-
IResourceIConstructIConstructIDependable
- Inherited Members
Examples
Integration integration;
var api = new SpecRestApi(this, "books-api", new SpecRestApiProps {
ApiDefinition = ApiDefinition.FromAsset("path-to-file.json")
});
var booksResource = api.Root.AddResource("books");
booksResource.AddMethod("GET", integration);
Remarks
Some properties normally accessible on @see {@link RestApi} - such as the description - must be declared in the specification. All Resources and Methods need to be defined as part of the OpenAPI specification file, and cannot be added via the CDK.
By default, the API will automatically be deployed and accessible from a public endpoint.
Resource: AWS::ApiGateway::RestApi
ExampleMetadata: infused
Constructors
SpecRestApi(Construct, string, ISpecRestApiProps)
public SpecRestApi(Construct scope, string id, ISpecRestApiProps props)
Parameters
scope
Constructid
stringprops
ISpecRestApiProps
Properties
RestApiId
The ID of this API Gateway RestApi.
public override string RestApiId { get; }
Property Value
RestApiRootResourceId
The resource ID of the root resource.
public override string RestApiRootResourceId { get; }
Property Value
Remarks
Attribute: true
Root
Represents the root resource of this API endpoint ('/').
public override IResource Root { get; }
Property Value
Remarks
Resources and Methods are added to this resource.