question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I require object list of a class in ApiModelProperty

See original GitHub issue

I’m submitting a…


[ ] Regression 
[ ] Bug report
[ x ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Right now `@ApiResponseModelProperty({ … }) I require object list of a class.

Expected behavior

@ApiResponseModelProperty I want to be able to get a list of my class

Minimal reproduction of the problem with instructions

i have 2 class: Articulo and UnidadMedida export class UnidadMedida extends BaseModel { @prop() descripcion: string; @prop() abrev: string; }

Class: Articulo export class Articulo extends BaseModel { @prop() nombre: string; @prop({ ref: UnidadMedida, required: true }) unidadmedida_id: Ref<UnidadMedida>; }

I have created a record class to show in the swagger, but I want to list the _id of my class unit measure

export class RegisterArticuloVm { @ApiModelProperty() nombre: string; @ApiModelProperty() unidadmedida_id: UnidadMedida (is my class UnidadMedida); }

image

What is the motivation / use case for changing the behavior?

I’m new using swagger, i don’t understand as obtain list of my class with ApiResponse Model Property

PD: I Love NESTJS ❤️

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
MumblesNZcommented, Mar 4, 2019

Hey @Russ3ll-Franz, you need to setup UnidadMedia with ApiModelProperties as well to display in the model. Something like below might help, the @IsString(), @Type() & @ValidateNested() decorators is for validation so might not be needed for your use case, but validation is always handy to have.

import { Type } from 'class-transformer';

export class UnidadMedidaDto {
  @ApiModelProperty({
    required: true,
    type: String,
  })
  @IsString()
  _id: string;

@ApiModelProperty({
    required: true,
    type: String,
  })
  @IsString()
  nombre: string;
}

export class RegisterArticuloVm { 
@ApiModelProperty() nombre: string; 

@ApiModelProperty({
    description: 'My descriptionr',
    required: true,
    type: UnidadMedidaDto ,
  })
  @ValidateNested()
  @Type(() => UnidadMedidaDto)

 unidadMedida: UnidadMedidaDto; 
}

`

0reactions
lock[bot]commented, Apr 25, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

swagger @ApiModelProperty example value for List<String ...
I managed to get this to work, generating a List of Strings. Within the ApiModelProperty with springfox 2, write your example as follows:...
Read more >
ApiModelProperty (swagger-annotations 1.5.0 API)
Specifies if the parameter is required or not. ... The value will override the data type as read from the class property. Default:...
Read more >
Swagger @ApiParam vs @ApiModelProperty | Baeldung
The @ApiParam annotation is for the parameters of an API resource request, whereas @ApiModelProperty is for properties of the model.
Read more >
Swaggerui doesn't show pojo class in models area
This is my swagger configuration class: ... String", required = true) public String accoutNumber; ... Use a model for a list of objects....
Read more >
Springfox Reference Documentation - GitHub Pages
Springfox works by examining an application, once, at runtime to infer API semantics based on spring configurations, class structure and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found