How to document implicitly dto usage, when we use

2019-09-16 14:57发布

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条回答
做个烂人
2楼-- · 2019-09-16 15:19

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 {
}
查看更多
登录 后发表回答