hello_world_infinity
hello_world_infinity

Reputation: 4830

Swagger ApiModelProperty access

I'm using the same Object both for my Request and Response on a REST endpoint. Is it possible to annotate a property with ApiModelProperty(access = "response") and then annotate the rest endpoint method with @ApiImplicitParam(access = "response") so that the property only shows up in the swagger doc for the response object and not the request one?

Upvotes: 26

Views: 5960

Answers (5)

lazarevsky
lazarevsky

Reputation: 83

You better write a new DTO for this purpose

Upvotes: 1

SSK
SSK

Reputation: 3766

You can achieve the same using @ApiModelProperty(readOnly = true). Allows a model property to be designated as read only. It will hide property from request and shows for a response only.

@ApiModelProperty(readOnly = true)

Upvotes: 3

Matt
Matt

Reputation: 31

You can also try:

@Schema(accessMode=AccessMode.READ_ONLY)

Upvotes: 0

acaruci
acaruci

Reputation: 909

You can use now

@ApiModelProperty(hidden=true)

Upvotes: -2

Man
Man

Reputation: 11

I think you can try with

@ApiParam(access = "hidden")

Reference:
Spring Rest API with Swagger – Fine-tuning exposed documentation

Upvotes: 0

Related Questions