Swagger: [Help] ApiResponse, getAll, list of a type

Created on 7 Feb 2018  路  3Comments  路  Source: nestjs/swagger

Hello guys !

I'm nest with NestJS, and new with TS also. I'm trying to implement a basic API, and I have trouble to use the @ApiResponse while defining a list.

I was looking at this issue: https://github.com/nestjs/swagger/issues/41
But I clearly don't understand what's happening.

I'm trying something like this:

import { ApiModelProperty } from '@nestjs/swagger';

export class Location {
  @ApiModelProperty()
  id: string;

  @ApiModelProperty()
  name: string;
}
  @Get()
  @ApiResponse({
    type: Location[],
  })
  findAll() {}

And I don't know how to configure the type to understand that I want a list of Location.

Thank you !

Most helpful comment

You should use isArray property ;)

  @Get()
  @ApiResponse({
    type: Location,
    isArray: true
  })
  findAll() {}

All 3 comments

You should use isArray property ;)

  @Get()
  @ApiResponse({
    type: Location,
    isArray: true
  })
  findAll() {}

So simple ! Thank you very much !

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

djedlajn picture djedlajn  路  4Comments

kalaivanan-muthusamy picture kalaivanan-muthusamy  路  4Comments

cdiaz picture cdiaz  路  4Comments

yuval-hazaz picture yuval-hazaz  路  3Comments

patilrevansidh picture patilrevansidh  路  4Comments