#Get User type instead of Loaded<User, never> to make it work with the Swagger plugin

1 messages · Page 1 of 1 (latest)

eternal kernel
#

When using this nest-cli.json configuration

      {
        "name": "@nestjs/swagger",
        "options": {
          "introspectComments": true
        }
      }

I can get the swagger documentation generated like this

This only works when the controllers return the type of an entity. The POST method works because the repository.create method returns an entity. But the find* methods return the Loaded<User, never> type.

#

I can define the correct type like this

  @Get(':id')
  async findOne(@Param('id') id: string): Promise<User> {
    const user = await this.usersService.findOne(+id);
    return user;
  }

and it works even though the returned type from this.usersService.findOne is Loaded<User, never> , but is there a way to get only the entity type without having to add the return type in each method?

floral fox
#

Is maybe the userService.findAll method generic?