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

Problem with loadServices and swagger #100

Closed
alfonsoal1983 opened this issue Jun 17, 2019 · 2 comments
Closed

Problem with loadServices and swagger #100

alfonsoal1983 opened this issue Jun 17, 2019 · 2 comments

Comments

@alfonsoal1983
Copy link

Doing tests with the import of the services, I just realized that the swaggerGen works well with the function buildServices (passing directly to the services) but when using the function loadServices (passing the route correctly) it does not create the routes in the swagger, the routes work well but the swagger does not generate it well. Do you know why it can be @thiagobustamante ?

The swagger only shows the text:

No operations defined in spec!

@thiagobustamante
Copy link
Owner

Hi @alfonsoal1983 ,

Swagger generator parses the typescript file and find all classes decorated with any typescript-rest decorator to generate the docs. This parser receives an entrypoint file and follow any imports it find to search into other files too.

When you are using buildServices you need to inform the Services directly to typescript-rest, so you need to import it into your main file. When using loadServices, you do not import it.

But is possible to inform to SwaggerGen the entrypoint for the parser. You can configure it in the swagger-config.json:

{
    "swagger": {
        "yaml": false,
        "outputDirectory": "./dist",
        "entryFile": "./src/services/myService.ts",
     }
}     

I changed the parser to accept also one array of entryFiles:

{
    "swagger": {
        "yaml": false,
        "outputDirectory": "./dist",
        "entryFile": ["./src/services/myService.ts","./src/services/myService2.ts"]
     }
}     

and also glob expressions:

{
    "swagger": {
        "yaml": false,
        "outputDirectory": "./dist",
        "entryFile": "./src/services/*.ts"
     }
}     

But is not published yet to npm. I am preparing a new major version that will include some other features, like support for open api 3.0

@thiagobustamante
Copy link
Owner

Done. Please update typescript-rest-swagger to version 1.0.3

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