- Automatically scans S3 bucket for
openapi.yml
files, and populates service/version dropdown menus - Displays documentation using ReDoc, based on the selected service/version
- Node.js 8.x
- npm 6.9.0
Should have a bucket on AWS S3 with the following structure:
[BUCKET]
|__[STAGE]
|__[SERVICE]
|__[TIMESTAMP-VERSION] || [VERSION-TIMESTAMP] || [TIMESTAMP] || [VERSION]
|__openapi.yml
BUCKET
- bucket for documentation;STAGE
- application development stage (example: dev, stage, prod);SERVICE
- service name;VERSION
- version;TIMESTAMP
- timestamp;openapi.yml
- .yml document;
For example:
bucket-api-documentation
|___dev
| |___mobileApp
| | |___1572347149-v1.0.0
| | | |___openapi.yml
| | |___1573159917
| | |___openapi.yml
| |
| |___backendApp
| |___v1.0.0-1572347149
| | |___openapi.yml
| |___v1.0.0
| |___openapi.yml
|
|___stage
|___mobileApp
| |___v1.0.0-1572347149
| |___openapi.yml
|
|___frontendApp
|___v1.0.1
| |___openapi.yml
|___v1.0.0
|___openapi.yml
There is a sample of the policy that can be used to provide the access to AWS S3
Don't forget to replace bucket-for-openapi-docs with your S3 bucket name.
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::bucket-for-openapi-docs",
"Effect": "Allow"
},
{
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::bucket-for-openapi-docs/*",
"Effect": "Allow"
}
]
}
- Required environment variables:
- S3_BUCKET = bucket-for-openapi-docs
- Optional environment variables (filled by default):
- PORT = 3000
- CACHE_TTL = 60000 //60s
- CACHE_MAX_SIZE = 50 * 1024 * 1024 //50mb
- S3_API_VERSION = '2006-03-01'
- S3_OBJECTS_PER_PAGE = 1000
- COOKIE_TTL = 2592000000 //1month
- AUTH_USER = ""
- AUTH_PASS = ""
- Optional AWS credentials
- AWS_ACCESS_KEY_ID = AKIAIOSFODNN7EXAMPLE
- AWS_SECRET_ACCESS_KEY = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
S3_AWS_ACCESS_KEY_ID (deprecated, preferred isAWS_ACCESS_KEY_ID
)S3_AWS_SECRET_ACCESS_KEY (deprecated, preferred isAWS_SECRET_ACCESS_KEY
)
If you have an error with region, please, use the AWS_REGION
environment variable
Error example:
The eu-south-2 location constraint is incompatible for the region specific endpoint this request was sent to.
Express-basic-auth - built-in middleware for authorization. You can specify environment variables:
- AUTH_USER
- AUTH_PASS
❗❗ If you don't specify environment variables the 'basic authentication' won't be enabled ❗❗
npm install
cp .env.sample .env
- (Modify .env)
npm run start-dev
docker pull velmie/openapi-renderer:latest
docker run -p 3000:80 -e AWS_ACCESS_KEY_ID="" -e AWS_SECRET_ACCESS_KEY="" -e S3_BUCKET="" velmie/openapi-renderer:latest
- Required environment variables:
- S3_BUCKET
- Optional environment variables for authentication:
- AUTH_USER
- AUTH_PASS
The health check is available by the following endpoint:
/health-check
Curl example:
curl -i --request GET 'http://localhost:3000/health-check'
# Response
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: text/html; charset=utf-8
Content-Length: 0
ETag: W/"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"
Date: Sat, 21 May 2022 14:33:15 GMT
Connection: keep-alive
Keep-Alive: timeout=5
❗ Please note that basic authentication
isn't applied to the health check
endpoint.