ojoanalogo / nestjs-redoc Goto Github PK
View Code? Open in Web Editor NEW๐ ReDoc frontend for you NestJS swagger API documentation
License: MIT License
๐ ReDoc frontend for you NestJS swagger API documentation
License: MIT License
Hello,
Thank you for your plugin, this is really useful !
I was trying to use a redoc vendor extension, the x-tagGroups
,
but I don't know how to do it.
Is there a way ? Or do we have to write some code in your plugin to make this work ?
Thanks !
Since yesterday, the speed is very slow or stopped when expanding the response type or scrolling.
Looking at the page script, src="https://cdn.jsdelivr.net/npm/redoc@latest/bundles/redoc.standalone.js" is used as the script, which is presumed to be a side effect created by using the latest version.
Can you specify the version like this?
<script src="https://cdn.jsdelivr.net/npm/[email protected]/bundles/redoc.standalone.js"> </script>the sources:
Redocly/redoc#1883
The patch version bump from 1.3.0
to 1.3.1
contained some major dependency updates and probably should have been a 2.0.0
.
Specifically the Nest version here changes the INestApplication
type.
This broke my app with the following:
src/documentation/documentation.service.ts:44:39 - error TS2345: Argument of type 'import("/app/node_modules/@nestjs/common/interfaces/nest-application.interface").INestApplication' is not assignable to parameter of type 'import("/app/node_modules/nestjs-redoc/node_modules/@nestjs/common/interfaces/nest-application.interface").INestApplication'.
Property 'registerRequestByContextId' is missing in type 'import("/app/node_modules/@nestjs/common/interfaces/nest-application.interface").INestApplication' but required in type 'import("/app/node_modules/nestjs-redoc/node_modules/@nestjs/common/interfaces/nest-application.interface").INestApplication'.
Can we revert this and do it again as a major version change? For the moment I pinned to 1.3.0
.
Your docs outline how to modify the the theme and it all works as intended however I can't see any method to add custom fonts to the html template to then set in the theme config.
The official Redoc files reference settings a htmlTemplate but this key is outside the theme
key and so can't be configured with the nestjs-redoc options
This going to be picked up?
redoc is adding sortTagsAlphabetically
and some other options, but cannot bypass nestjs-redoc
validator
I want to restrict access to /docs
route from not logged in users. Maybe someone has an example for this? :)
It would be nice to add namespaces at the group level, like this:
tagGroups:
- name: 'User'
tags:
- 'Entity'
- 'Reports'
- name: 'Common'
tags:
- 'Reports'
And in decorators:
@ApiTags('User.Reports')
// ... some user reports controller
@ApiTags('Common.Reports')
// ... some common reports controller
But render without dots, like:
User
> Reports
Common
> Reports
We should load swagger from relative url because nest application could be proxied with some path prefix by some server like NGINX behind.
For example, we have Nest app with simple /docs/ route. And some SPA application on same domain. We will configure NGINX like
location /api {
// upstream to Nest app
}
location {
// route everything didnt match /api prefix to static files
}
In these cause a broken link swagger.json because it will be generated from the root
And these why all static files are loaded in original SwaggerModule
<script src="./swagger-ui-bundle.js"> </script>
<script src="./swagger-ui-standalone-preset.js"> </script>
<script src="./swagger-ui-init.js"> </script>
Creating an issue for better tracking, I'm working on adding tests to the package for 100% (or as close as I can get) coverage! ๐
nestjs-redoc
rewrites views directory base path and templates engine of the application, ruining Nest MVC techniques:
https://docs.nestjs.com/techniques/mvc#model-view-controller
Nest:
app.setBaseViewsDir(join(__dirname, '..', 'views'));
app.setViewEngine('hbs');
nestjs-redoc (https://github.com/mxarc/nestjs-redoc/blob/master/src/redoc-module.ts#L97):
// Set app to use handlebars as engine
app.engine('handlebars', hbs.engine);
app.set('view engine', 'handlebars');
// Set views folder
app.set('views', join(__dirname, '..', 'views'));
Because of this, it is not possible to use nestjs-redoc
and render project own pages at the same time.
NestJS server fails with error when redoc options doesn't have 'auth' optional parameter because of the line 135 of redoc-module.ts below.
if (options.auth.enabled) { const { user, password } = options.auth; expressAuth({ users: { [user]: password }, challenge: true })( req, res, () => { sendPage(); } ); } else { sendPage(); }
Also, I'm not sure if it makes sense to have auth optional option, but user & password required. What if enabled is false?
auth?: { enabled: boolean; user: string; password: string; };
Hi,
because this repository is not maintained for over 3 years and other alternatives are either part of a framework (that I don't need) or just slightly updated versions of this package, I decided to create a library myself:
Features:
I hope this library helps all devs who are looking for an alive and most updated solution for using Redoc in their NestJS projects ๐
Is this project still being maintained?
@ApiHeader({ name: 'Authorization', example: 'Bearer 2YotnFZFEjr1zCsicMWpAA', description: 'description' })
This gives the following result. The description field is also not clearly displayed at all
I would also like to know how to change the default api name of the route AccountConsentsController_createAccountConsents
In the image in the readme file I see tags like Introduction, Authentication and so on. How can those be added?
For example, I need an Introduction tag explaining high level the functionality. How can this be done?
Thank you ๐
When I'm protect my documentation with
auth: {
enabled: true,
user: config.get('openapi.user'),
password: config.get('openapi.password'),
},
this works for main page, but doesn't protect access to swagger.json!!!
See related
#19 (comment)
I'm using NestJS 7.5.1.
"dependencies": {
"@nestjs/common": "^7.5.1",
"@nestjs/core": "^7.5.1",
"@nestjs/platform-express": "^7.5.1",
"@nestjs/swagger": "^4.6.1",
"nestjs-redoc": "^1.3.2",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^6.6.3",
"swagger-ui-express": "^4.1.4"
},
And I got this error.
src/main.ts:39:36 - error TS2345: Argument of type 'import("/home/erickalmeida/dev/generic-adapter-nest/node_modules/@nestjs/common/interfaces/nest-application.interface").INestApplication' is not assignable to parameter of type 'import("/home/erickalmeida/dev/generic-adapter-nest/node_modules/nestjs-redoc/node_modules/@nestjs/common/interfaces/nest-application.interface").INestApplication'.
The types returned by 'getHttpAdapter().createMiddlewareFactory(...)' are incompatible between these types.
Type '((path: string, callback: Function) => any) | Promise<(path: string, callback: Function) => any>' is not assignable to type '(path: string, callback: Function) => any'.
Type 'Promise<(path: string, callback: Function) => any>' is not assignable to type '(path: string, callback: Function) => any'.
Type 'Promise<(path: string, callback: Function) => any>' provides no match for the signature '(path: string, callback: Function): any'.
39 await RedocModule.setup('/docs', app, document, redocOptions);
The URL used for serving swagger.json
should be constructed using url.resolve()
instead of path.join()
: https://github.com/mxarc/nestjs-redoc/blob/master/src/redoc-module.ts#L85
Because of path.join()
, the swagger URL is transformed from /docs/swagger.json
to \docs\swagger.json
which makes the route fail on Windows (ReDoc then yields a "Something went wrong" error).
The interface INestApplication changed the name 'listenAsync' method to 'listen'.
Hello Redoc, thank you for your awesome work. But i have a bit issue on how to install it.
So, I have already done all the installation and put some code inside my main.ts file exactly the same:
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);
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
await RedocModule.setup('/docs', app, document, redocOptions);
Focused on the line code : await RedocModule.setup('/docs', app, document, redocOptions);
I have an issue on 'app' such as:
Argument of type 'import("/Users/kcb/Documents/Projects/Sample/Deploy_zeit/deploy-zeit/node_modules/@nestjs/common/interfaces/nest-application.interface").INestApplication' is not assignable to parameter of type 'import("/Users/kcb/Documents/Projects/Sample/Deploy_zeit/deploy-zeit/node_modules/nestjs-redoc/node_modules/@nestjs/common/interfaces/nest-application.interface").INestApplication'.
The types returned by 'getHttpAdapter().createMiddlewareFactory(...)' are incompatible between these types.
Perhaps, you guys can help me on this issue. Thanks!
Hi , first of all thank you for a nice repo
I trying to implemnt in my project and I got page with lot of errors, i cant add data . the sandbox is empty ..etc
my code
controller :
@ApiOperation({ title: 'create a token' })
@ApiImplicitHeader({ name: 'Autherization' })
@UseGuards(AuthGuard)
@Get('token')
@ApiResponse({ status: 201, description: 'The record has been successfully created.'})
@ApiResponse({ status: 403, description: 'Forbidden.'})
public async getToken(@Request() request: TokenRequest) {
try {
return this.authService.createToken(request.credentials);
} catch (e) {
throw new UnauthorizedException();
}
}
main.ts
const options = new DocumentBuilder()
.setTitle('app title')
.setDescription('apii')
.setVersion('1.0')
.build();
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
};
const document = SwaggerModule.createDocument(app, options);
//SwaggerModule.setup('api', app, document);
await RedocModule.setup('/docs', app, document, redocOptions);
As the title
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.