nestjsx / crud

NestJs CRUD for RESTful APIs
https://github.com/nestjsx/crud/wiki
MIT License
4.09k stars 539 forks source link

Improving generated swagger documentation #618

Closed yann510 closed 3 years ago

yann510 commented 4 years ago

It would be great if the generated documentation would have proper responses being returned in the examples.

image

Also, for the requests, it's very hard to know what is actually possible. You need to go look at the defined schemas at the bottom of the page and even then, they do not seem to be properly generated.

image

Any idea as to how we can improve this? I'd be happy to help.

tbrannam commented 3 years ago

My application has these things - I suspect you are missing something either in your controllers or the swagger setup in your app?

yann510 commented 3 years ago

Is your application open-source? If so a link to it would be amazing so I can learn what I'm doing wrong!

tbrannam commented 3 years ago

It is not, but I'd look at yours if you had it in github or something like that.

On Fri, Nov 13, 2020, 4:11 PM Yann Thibodeau notifications@github.com wrote:

Is your application open-source? If so a link to it would be amazing so I can learn what I'm doing wrong!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nestjsx/crud/issues/618#issuecomment-727037472, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAATHXJ7C7TH43EDZWUPZ6DSPWOHFANCNFSM4SVNRAXA .

yann510 commented 3 years ago

It is in fact an open-source project, I really appreciate you giving me a hand :)

https://github.com/chocolat-chaud-io/stator you can find the nest application under apps/api

tbrannam commented 3 years ago

I don't see anything super obviously wrong in your code - my only thought is perhaps the Swagger DocumentBuilder can't resolve the path for Todo while Typescript can... I'd suggest doing a test by copying your model and referencing it as a local module.

yann510 commented 3 years ago

Ok, thank you for taking a look. I will try doing that.

yann510 commented 3 years ago

For anyone interested, here is how I managed to solve the issue: https://github.com/chocolat-chaud-io/stator/pull/135 The problem was caused by the fact the schemas were not loaded automatically.

yleflour commented 3 years ago

For those facing the same issue, you actually need to setup the CLI https://docs.nestjs.com/openapi/cli-plugin#using-the-cli-plugin