Add a swagger endpoint to your EdgeAPI
Project description
@reapit-cdk/edge-api-swagger
Add a swagger endpoint to your EdgeAPI
Package Installation:
yarn add --dev @reapit-cdk/edge-api-swagger
# or
npm install @reapit-cdk/edge-api-swagger --save-dev
Usage
import { Stack, App } from 'aws-cdk-lib'
import { EdgeAPI, EdgeAPILambda, LambdaEndpoint, ProxyEndpoint } from '@reapit-cdk/edge-api'
import { Code, Runtime } from 'aws-cdk-lib/aws-lambda'
import { EdgeAPISwaggerEndpoint } from '@reapit-cdk/edge-api-swagger'
import { Certificate } from 'aws-cdk-lib/aws-certificatemanager'
import * as path from 'path'
const app = new App()
const stack = new Stack(app, 'stack-name')
const certificate = new Certificate(stack, 'certificate', {
domainName: 'example.org',
})
const api = new EdgeAPI(stack, 'api', {
certificate,
domains: ['example.org', 'example.com'],
devMode: false,
defaultEndpoint: new ProxyEndpoint({
destination: 'example.com',
pathPattern: '/*',
}),
})
const lambdaFunction = new EdgeAPILambda(stack, 'lambda', {
code: Code.fromAsset(path.resolve('../lambda/dist')),
codePath: path.resolve('../lambda/src/index.ts'), // gets added to the docs
handler: 'index.handler',
runtime: Runtime.NODEJS_18_X,
environment: {
aVariable: 'contents',
},
})
api.addEndpoint(
new LambdaEndpoint({
pathPattern: '/api/lambda',
lambdaFunction,
}),
)
api.addEndpoint(
new EdgeAPISwaggerEndpoint(stack, 'docs', {
api,
url: 'https://example.org',
pathPattern: '/swagger', // optional, defaults to /swagger
// optional
info: {
title: '', // defaults to Edge API
version: '', // defaults to 1.0.0
},
}),
)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for reapit-cdk.edge-api-swapper-0.1.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c56ae3fb214768bf25be3307f261c1c4bd9527119e8d27f92ee0554a50c4dae |
|
MD5 | cd5d1220bc2e9e1444a1acfcd86b2ea5 |
|
BLAKE2b-256 | d37ced5e7cbdaa0975f788efd0a36b41c9f194252dc44ef8e58535caf65ddaea |
Close
Hashes for reapit_cdk.edge_api_swapper-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e8dc976127467ed3ee39b9255fb2406898363261bcbb5158b9563e8bb7da547 |
|
MD5 | 52f72dbf6d066e025d292bff240c55e6 |
|
BLAKE2b-256 | dcf25151cbf0a04e8359ee762c73b56444e8dccdb3ff3b00ac922339ce69bd72 |