Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable swagger and swagger-stats #4

Closed
bovandersteene opened this issue Oct 3, 2018 · 3 comments
Closed

Enable swagger and swagger-stats #4

bovandersteene opened this issue Oct 3, 2018 · 3 comments

Comments

@bovandersteene
Copy link

bovandersteene commented Oct 3, 2018

I'm submitting a...


[ ] Regression 
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When I add swagger and swagger-ui for documentation and statics. It doesn't load work. I get errors on the startup.

Following error was provided:


{ Error: ENOENT: no such file or directory, open '//indexTemplate.html'
    at Object.fs.openSync (fs.js:577:3)
    at Object.fs.readFileSync (fs.js:483:33)
    at Object.generateHTML (/Users/bovandersteene/projects/github/talks/angular-connect/collection/dist/server.js:168517:16)
    at Function.setup (/Users/bovandersteene/projects/github/talks/angular-connect/collection/dist/server.js:168461:39)
    at /Users/bovandersteene/projects/github/talks/angular-connect/collection/dist/server.js:168:83
    at step (/Users/bovandersteene/projects/github/talks/angular-connect/collection/dist/server.js:131:23)
    at Object.next (/Users/bovandersteene/projects/github/talks/angular-connect/collection/dist/server.js:112:53)
    at fulfilled (/Users/bovandersteene/projects/github/talks/angular-connect/collection/dist/server.js:103:58)
    at ZoneDelegate.invoke (/Users/bovandersteene/projects/github/talks/angular-connect/collection/dist/server.js:170788:26)
    at Zone.run (/Users/bovandersteene/projects/github/talks/angular-connect/collection/dist/server.js:170538:43)
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '//indexTemplate.html' }

Expected behavior

Access for swagger should be provided

Minimal reproduction of the problem with instructions

Add swagger to your main.ts file


import { NestFactory } from '@nestjs/core';
import { AppModule } from './src/app.module';
import * as swStats from 'swagger-stats';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';

import { enableProdMode } from '@angular/core';
enableProdMode();

async function bootstrap() {
  const app = await NestFactory.create(AppModule); 
  app.enableCors({
    methods: 'GET',
    maxAge: 3600,
  });

  const options = new DocumentBuilder()
    .setTitle('My-Collection backend')
    .setDescription('The collection api')
    .setVersion('1.0')
    .addTag('reibo')
    .build();

  const document = SwaggerModule.createDocument(app, options);
  SwaggerModule.setup('swagger', app, document);
  app.use(swStats.getMiddleware());

  await app.listen(4000);
}
bootstrap().catch(err => console.error(err));

What is the motivation / use case for changing the behavior?

Environment


Nest version:  5.3.10

 
For Tooling issues:
- Node version: XX  v10.2.1
- Platform:  Mac

Others:

@kamilmysliwiec
Copy link
Member

kamilmysliwiec commented Oct 4, 2018

Thanks for reporting, I'll check

@vildhjarta8
Copy link

vildhjarta8 commented Dec 24, 2018

+1, same error.

Using Universal & Swagger module.

Node v10.5.0
Windows 10

"@nestjs/common": "^5.5.0",
"@nestjs/core": "^5.5.0",
"@nestjs/ng-universal": "^0.1.1",
"@nestjs/swagger": "^2.5.1",

@kamilmysliwiec
Copy link
Member

kamilmysliwiec commented Feb 3, 2019

This is caused due to the way in how the underlying swagger UI library works. Unfortunately, we cannot do anything in this case. I'd suggest adding an issue to the swagger-ui-express repository though (lack of webpack compatibility).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants