I'm using springfox for auto-generate swagger-api-document from my spring-mvc restful application.
To make the api clear, i'm using @ApiModelProperty
to add describe for response field. Recently there's an api which response a third-party model which i can't add @ApiModelProperty
to it's source.
So how to add @ApiModelProperty for third-party model which it's not controlled by you?
You have several options.
First, the response model does not need to be the concrete class that you're returning. So it might be UserDTO
but you can easily declare it as User
. That gives you the chance to create an interface or even extend your concrete class and add the @ApiModelProperty
annotations.
Next, most frameworks allow you to intercept the Swagger document before it's rendered. You can probably manually mutate the doc, and add the descriptions and metadata that you need.
I'd suggest going with the first approach as it's easier to implement and gives you all the control you need.