Crud: Default id parameter present in the Swagger documentation of every route of a @Crud() controller

Created on 9 Apr 2019  路  2Comments  路  Source: nestjsx/crud

Hey,

I recently tried the demo project of nestjsx/crud (nestjsx/crud/integration/typeorm).
I recognized that the swagger documentation contains an additional id parameter for every route - even for "get all" or "create one", where it's not necessary to provide such an id at all.

Here is what I mean:
Bildschirmfoto 2019-04-09 um 12 08 52

In the code, the params attribute is explicitly set to {} (empty).
Is this a bug?

// ...
@Crud(Company, {
  params: {},
  routes: {},
  options: {
    join: {
      users: {
        exclude: ['password'],
      },
    },
    sort: [{ field: 'id', order: 'DESC' }],
    maxLimit: 5,
    cache: 10000,
  },
})
@ApiUseTags('companies')
@Controller('companies')
export class CompaniesController {
// ...

[EDIT]

In helpers.js in function setDefaultCrudOptions() the parameter id: number is used by default:

function setDefaultCrudOptions(crudOptions, target) {
    const check = (obj) => shared_utils_1.isNil(obj) || !shared_utils_1.isObject(obj) || !Object.keys(obj).length;
    if (check(crudOptions.params)) {
        crudOptions.params = { id: 'number' };
    }
    // ...
}

Is this really necessary? Since not every route has an id parameter.

Most helpful comment

Sorry for not closing thing issue on time. Yep it was fixed with v4.0.0

All 2 comments

Sorry for not closing thing issue on time. Yep it was fixed with v4.0.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leo-jnesis picture leo-jnesis  路  5Comments

btd1337 picture btd1337  路  4Comments

dulkith picture dulkith  路  3Comments

terapepo picture terapepo  路  3Comments

lalalalaluk picture lalalalaluk  路  4Comments