Open Kolobok12309 opened 3 years ago
same here, @Kolobok12309 did you handle this?
@pashkash At the moment I don't remember why, but this my code now
@Crud({
model: {
type: BreedDto,
},
dto: {
create: CreateBreedDto,
update: UpdateBreedDto,
},
routes: {
only: ['getManyBase', 'createOneBase', 'updateOneBase', 'deleteOneBase'],
},
...
})
// TODO Remove it after crud decorator fix `getOneBase` bug
@ApiExtraModels(BreedDto)
@ApiTags('Breed')
@Controller('breed')
export class BreedController implements CrudController<BreedDto> {
constructor(public service: BreedService) {}
}
@Kolobok12309 thank you for reply; this decorator @ApiExtraModels(...) added schemas for entities for me; which is good, but all they are empty in openapi json file, e.g.
"BreedDto": { "type": "object", "properties": {} },
ok, i just need to add @ApiProperty()
, ApiModelProperty
, etc to properties of entities; which you dont need to add if you are not using crud; solved;
dont forget to use type: (type) => Contact
in yours
@ApiModelProperty({ type: (type) => Contact, isArray: false })
for entities relations to let swagger to render relations schemas
I have 2 entities with specific routes, they haven't
getOneBase
routes, only'getManyBase', 'createOneBase', 'updateOneBase', 'deleteOneBase'
For one of this entities i have this crud optionsAnd i get error in swagger
But if i add
getOneBase
to routes array, all worked fine. I think it's not normal.@ApiExtraModels(BreedDto)
fix it too And if i replaceCreateBreedDto
orUpdateBreedDto
or mb addBreedDto
to some dto properties, all normally. Try addserialize.get
andserialize.getMany
, but it uselessVersion