forked from ojoanalogo/nestjs-redoc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ RedocModule now accepts custom options and theme
Bumped a few dependencies versions, added interfaces and joi for parameter validation, pretty much all of the options ReDoc offers are now implemented
- Loading branch information
Alfonso Reyes
committed
Jul 11, 2019
1 parent
75a3328
commit cea94c7
Showing
10 changed files
with
434 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{yml,json,lock}] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,72 @@ | ||
# nestjs-redoc | ||
📘 ReDoc frontend for you NestJS swagger API documentation | ||
<h1 align="center"> | ||
NestJS-Redoc | ||
<h4 align="center">ReDoc powered frontend for your NestJS API spec</h4> | ||
</h1> | ||
<br /> | ||
|
||
<div align="center"> | ||
<a href="http://makeapullrequest.com"> | ||
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square" alt="PRs welcome" /> | ||
</a> | ||
<a href="https://github.com/nestjs/nest"> | ||
<img src="https://raw.githubusercontent.com/nestjsx/crud/master/img/nest-powered.svg?sanitize=true" alt="Nest Powered" /> | ||
</a> | ||
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-blue.svg"></a> | ||
</div> | ||
|
||
<p align="center"> | ||
<a href="#-features">Features</a> • | ||
<a href="#-how-to-use">How to use</a> • | ||
<a href="#-changelog">Changelog</a> • | ||
</p> | ||
|
||
<p align="center"> | ||
⚡ This is a ReDoc powered frontend for your NestJS API spec. By using ReDoc you improve your documentation presentation using a better UI/UX design | ||
</p> | ||
|
||
## ⚡ Features | ||
|
||
TBD | ||
|
||
## Installation | ||
|
||
Using npm: ```npm i nestjs-redoc``` | ||
|
||
Using yarn: ```yarn add nestjs-redoc``` | ||
|
||
## ❓ How to use | ||
|
||
You need to install the Swagger module first if you want to get definitions, otherwise you may use a URL parameter for an OpenAPI definition instead of document object. | ||
|
||
```typescript | ||
const options = new DocumentBuilder() | ||
.setTitle('Look, i have a title') | ||
.setDescription('A very nice description') | ||
.setBasePath('/api/v1') | ||
.build(); | ||
const document = SwaggerModule.createDocument(app, options); | ||
``` | ||
|
||
Then add the followring example code. | ||
|
||
**Note**: All properties are optional, if you don't specify a title we will fallback to the one you used above. | ||
|
||
```typescript | ||
const redocOptions: RedocOptions = { | ||
title: 'Hello Nest', | ||
logo: { | ||
url: 'https://redocly.github.io/redoc/petstore-logo.png', | ||
backgroundColor: '#F0F0F0', | ||
altText: 'PetStore logo' | ||
}, | ||
sortPropsAlphabetically: true, | ||
hideDownloadButton: false, | ||
hideHostname: false | ||
}; | ||
// Instead of using SwaggerModule.setup() you call this module | ||
RedocModule.setup('/docs', app, document, redocOptions); | ||
``` | ||
|
||
|
||
## 📋 ToDo | ||
bla bla |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './redoc-module'; | ||
export * from './interfaces'; | ||
export * from './interfaces'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './redoc_options.interface'; | ||
export * from './redoc_document.interface'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { SwaggerDocument } from '@nestjs/swagger'; | ||
import { LogoOptions } from './redoc_options.interface'; | ||
|
||
export interface RedocDocument extends Partial<SwaggerDocument> { | ||
info: SwaggerDocument['info'] & { | ||
'x-logo'?: LogoOptions | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,54 @@ | ||
export interface RedocOptions { | ||
/** Web site title (e.g: ReDoc documentation) */ | ||
title?: string; | ||
theme?: RedocTheme; | ||
imgUrl?: string; | ||
/** Logo Options */ | ||
logo?: LogoOptions; | ||
/** Theme options */ | ||
theme?: any; | ||
/** If set, the spec is considered untrusted and all HTML/markdown is sanitized to prevent XSS, by default is false */ | ||
untrustedSpec?: boolean; | ||
/** If set, warnings are not rendered at the top of documentation (they are still logged to the console) */ | ||
supressWarnings?: boolean; | ||
/** If set, the protocol and hostname won't be shown in the operation definition */ | ||
hideHostname?: boolean; | ||
/** Specify which responses to expand by default by response codes, | ||
* values should be passed as comma-separated list without spaces | ||
* (e.g: 200, 201, "all") | ||
*/ | ||
expandResponses?: string; | ||
/** If set, show required properties first ordered in the same order as in required array */ | ||
requiredPropsFirst?: boolean; | ||
/** If set, propeties will be sorted alphabetically */ | ||
sortPropsAlphabetically?: boolean; | ||
/** If set the fields starting with "x-" will be showed, can be a boolean or a string with names of extensions to display */ | ||
showExtensions?: boolean | string; | ||
/** If set, redoc won't inject authentication section automatically */ | ||
noAutoAuth?: boolean; | ||
/** If set, path link and HTTP verb will be shown in the middle panel instead of the right one */ | ||
pathInMiddlePanel?: boolean; | ||
/** If set, loading spinner animation won't be shown */ | ||
hideLoading?: boolean; | ||
/** If set, a native scrollbar will be used instead of perfect-scroll, this can improve performance of the frontend for big specs */ | ||
nativeScrollbars?: boolean; | ||
/** This will hide the "Download spec" button, it only hides the button */ | ||
hideDownloadButton?: boolean; | ||
/** If set, the search bar will be disable */ | ||
disableSearch?: boolean; | ||
/** SHows only required fileds in request samples */ | ||
onlyRequiredInSamples?: boolean; | ||
} | ||
|
||
export interface RedocTheme { | ||
color: ''; | ||
} | ||
|
||
export interface LogoOptions { | ||
/** The URL pointing to the spec logo, must be in the format of a URL and an absolute URL */ | ||
url?: string; | ||
/** Background color to be used, must be RGB color in hexadecimal format (e.g: #008080) */ | ||
backgroundColor?: string; | ||
/** Alt tag for logo */ | ||
altText?: string; | ||
/** href tag for logo, it defaults to the one used in your API spec */ | ||
href?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.