I have created rest webservice using springboot and added springdoc-open-api for ducumentation of webservice, Now i have 2 question
1-how to add custom test value into request which displying on swagger-ui document page?
2-how to execute the request on click of TRY IT OUT button on swagger-ui document page?
Please refer below code snippet for rest webservice:
@PostMapping(value="/result", consumes={ "application/json"},produces={ "application/json" } )
@Parameter(description = "Student object need to calculate the score" ,name="InputObject", required = true )
public ResponseEntity<Result> displayResult(@Valid @RequestBody Student request);
Public class Student{
String name;
String birthDate;
String motherName;
int rollNo;
int seatNo;
}
Public class Result{
int marks;
String grade;
double percentage;
}
I have tried to add value of request using @Schema(name = "name", example= "Rubeena", description = "Name of student"), is it right way to add the value in example request ?
Even after adding this schema when i click on TRY IT OUT button i dont get the outcome.
Is there any way to solve this problem?
use @ApiModelProperty annotation in your dto class.
Example -