nestjsx / crud

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

OpenApiTools error on swagger JSON emitted from @Crud controllers #409

Open colorado-nate opened 4 years ago

colorado-nate commented 4 years ago

We have a nestjs controller decorated with @Crud. The model is pretty simple, just 5 fields, 4 strings and a boolean. We generate swagger.json from our service, and generate SDK's from swagger.json using openApiTools. Recently, we started getting errors from openApiTools when generating the SDK. For each of the routes that are auto-generated from @Crud, we get an error of the form -attribute paths.'/api/someroute/{id}'(put).responses.200.description is missing.

If I look at the swagger.json, sure enough, the "responses.200" key has no description for the auto-generated routes. If I manually add a description, the errors go away (but this isn't a solution, it was just an experiment). For the routes we create explicitly (i.e., not using @Crud), we use the "@ApiOkResponse({ description: 'Describe the response here' })" decorator, which adds the description to the response key, and everything is happy.

Request: Have @Crud add a description for each response

Tools versions: nestjs: 6.11.4 nestjs/swagger: 4.2.3 nestjsx/crud: 4.4.1 class-validator: 0.10.0 openapitools/openapi-generator-cli: 1.0.8-4.2.2

iingsoc commented 4 years ago

Please refer to https://github.com/nestjsx/crud/issues/355. The fix seems to be on its way :)