Reputation: 11
I have a @RestController with such method
@RestController
public MyController {
@Operation(summary = "Some text", description = "Some text again"
@GetMapping("/route")
public MyClassResponse getSomething(
@Parameter(name = "My request", description = "My request") MyRequest request
) {
// to do smth
return response
}
where MyRequest is
public class MyRequest {
private int param1;
private String param2;
private MyClass param3;
}
and MyClass looks like
public class MyClass {
private int clazzParam1;
private int clazzParam2;
}
First of all, Swagger shows parameter MyRequest like body
{
"param1" : 0;
"param2" : "string",
"param3" : {
"clazzParam1" : 0,
"clazzParam2" : 0
}
}
but I would like to see every parameterlike this
Second when I try make request, I get this curl
http://localhost:8080/route?param1=0¶m2=string¶m3=clazzParam1,0,clazzParam2,0
instead
http://localhost:8080/route?param1=0¶m2=string¶m3.clazzParam1=0¶m3.clazzParam2=0
Therefore response contain next failure Failed to convert property value of type 'java.lang.String' to required type 'MyClass' for property 'param3'.
How should I use annotations to get what I want? For various reasons I can't use .yaml description. Thank you.
Upvotes: 1
Views: 1232
Reputation: 11
@ParameterObject is answer. It unpacking object to parameters in Swagger UI
Upvotes: 0