Skip to content

basePath swaggerConfig json ignored. #134

@sabarishnarain

Description

@sabarishnarain

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions