Skip to content

pepperize/cdk-apigateway-swagger-ui

Repository files navigation

PRs Welcome GitHub npm (scoped) PyPI Nuget Sonatype Nexus (Releases) GitHub Workflow Status (branch) GitHub release (latest SemVer) Gitpod ready-to-code

CDK Apigateway SwaggerUI

Add SwaggerUI to your AWS Apigateway RestApi

SwaggerUI Example

Install

TypeScript

npm install @pepperize/cdk-apigateway-swagger-ui

or

yarn add @pepperize/cdk-apigateway-swagger-ui

Python

pip install pepperize.cdk-apigateway-swagger-ui

C# / .Net

dotnet add package Pepperize.CDK.ApigatewaySwaggerUi

Java

<dependency>
  <groupId>com.pepperize</groupId>
  <artifactId>cdk-apigateway-swagger-ui</artifactId>
  <version>${cdkApigatewaySwaggerUi.version}</version>
</dependency>

Usage

import { Stack } from "aws-cdk-lib";
import * as apigateway from "aws-cdk-lib/aws-apigateway";
import { SwaggerUi } from "@pepperize/cdk-apigateway-swagger-ui";

const stack = new Stack();
const restApi = new apigateway.RestApi();

new SwaggerUi(stack, "SwaggerUI", { resource: restApi.root });
  • Open your SwaggerUI: https://<rest api id>.execute-api.<aws region>.amazonaws.com/<stage>/api-docs/swagger-ui.html
  • View your API docs: https://<rest api id>.execute-api.<aws region>.amazonaws.com/<stage>/api-docs.json