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

basePath swaggerConfig json ignored. #134

Open
sabarishnarain opened this issue Dec 7, 2020 · 1 comment
Open

basePath swaggerConfig json ignored. #134

sabarishnarain opened this issue Dec 7, 2020 · 1 comment

Comments

@sabarishnarain
Copy link

I'm noticing the generated json and yml does have basePath in it, but the server is not accessible with the base path.

The generated swagger.json

{
	"basePath": "/swagger-demo",
	"definitions": {},
..
..
..

My swaggerConfig.json is

  "swagger": {
    "basePath": "/swagger-demo",
      "outputDirectory": "./dist",
      "entryFile": "./src/routes/catService.ts",
  }
}```


My server.ts is 

```import express from 'express';
const app = express();
import bodyParser from 'body-parser';
import {Server} from "typescript-rest";
import {CatService} from "./routes/catService";

const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('./swagger.json');

app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
app.get('/ping', (req: any, res: any) => { res.send('PONG')});

Server.buildServices(app, CatService);

app.listen(3000);
console.log(`Server @: 3000`);

Expected result: the api end points should be accessible at
http://localhost:3000/swagger-demo/cat
http://localhost:3000/swagger-demo/ping

If this problem relates to the typescript-rest module, I'm happy to move it.

@jpmoraez
Copy link

Were you able to access swagger ui ?

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

No branches or pull requests

2 participants