Example for map at swagger

Viewed 70

I'm trying to create a valid example for a request using swagger ui. I have a data class that is the body of a request.

data class LoadTestRequest (
  @ApiModelProperty(example = "https://...", required = true, value = "Url to send request")
  val url: String,
  @ApiModelProperty(example = "POST", required = true, value = "HttpMethod for a request")
  val method: HttpMethod,
  @ApiModelProperty(example = "{\"key\": \"value\"}", required = true, value = "Parameters for a request", dataType = "java.util.Map")
  val data: Map<String, String>
)

Everything is fine with examples for first 2 fields, but the Map field example generates as String

{
  "method": "POST",
  "url": "https://...",
  "data": "{\"key\": \"value\"}"
}

How can I change this value of an example to a valid serialization of Map?

"data": {"key": "value"}
0 Answers
Related