https://github.com/farist/liftr-docs
Documentation middleware for Liftr to document your routes in Swagger
https://github.com/farist/liftr-docs
documentation express liftr liftr-docs swagger typescript
Last synced: about 1 month ago
JSON representation
Documentation middleware for Liftr to document your routes in Swagger
- Host: GitHub
- URL: https://github.com/farist/liftr-docs
- Owner: farisT
- License: mit
- Created: 2019-03-05T08:53:32.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-02T16:20:55.000Z (about 7 years ago)
- Last Synced: 2025-01-22T19:13:08.963Z (over 1 year ago)
- Topics: documentation, express, liftr, liftr-docs, swagger, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/liftr-docs
- Size: 30.3 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# liftr-docs
[](https://github.com/farisT/liftr-docs)
A middleware for documenting your [Liftr](https://github.com/farisT/liftr) routes with [Swagger 3.0](https://swagger.io/) under the hood.
## Installation
```
npm install @liftr/docs --save
```
## Example usage
```
import * as express from 'express';
import { LiftrDocs } from '@liftr/docs';
import { routes } from '@routes/LiftrRoutingModule';
// swaggerDescriptions
// ---------------------------
// standard info and port config for the documentation
// the version of openapi used is 3.0.0. THIS SHOULD NOT CHANGE.
const swaggerDescriptions = {
info: {
title: 'Liftr REST API',
version: '1.0.0',
description: 'REST API for all the endpoints',
},
servers: [{
url: `http://localhost:${process.env.PORT || 4000}`,
}],
openapi: '3.0.0',
paths: {},
};
// swaggerResponses
// ---------------------------
// Define the responses for your API endpoints and what type of request body you will send.
const swaggerResponses = {
responses: {
200: {
description: 'OK',
},
400: {
description: 'Error: Bad Request',
},
401: {
description: 'Error: Unauthorized',
},
},
requestBody: {
required: true,
content: {
'application/json': { },
},
description: '',
},
};
// This will initiate the /docs route to contain the swagger documentation
// This will use the routes created in the LiftrRoutingModule
app.use('/docs', LiftrDocs(routes, swaggerDescriptions, swaggerResponses));
```