How to document implicitly dto usage, when we use entity class as api param?

穿精又带淫゛_ 提交于 2019-12-25 08:49:24

问题


There are a problem, when we use Jersey2 resource with implicitly dto usage.

Example:

@POST
@ApiOperation(value = "Create pet", response = PetDTO.class)
public Pet create(Pet pet) throws IOException {
    return this.petService.save(pet);
}

In this example we implicitly get petDto as param, and than map it to entity.

The question is, is the way to how to configure swagger to document PetDTO as api param, not Pet?


回答1:


It can be done next way:

@POST
@ApiOperation(value = "Create pet", response = PetDTO.class)
@ApiImplicitParams({
        @ApiImplicitParam(name = "Pet dto",
        value = "pet", required = true,
        dataType = "com.example.PetDTO", paramType = "body")
})

public Pet create(@ApiParam(hidden = true) Pet pet) throws IOException {
}


来源:https://stackoverflow.com/questions/41481588/how-to-document-implicitly-dto-usage-when-we-use-entity-class-as-api-param

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!