-
Notifications
You must be signed in to change notification settings - Fork 6
Graphical Editing of Request Body
Indra Basak edited this page May 5, 2017
·
3 revisions
If a REST operation consumes a request body as JSON, the Swagger requires the input to be a JSON string. In the case of Lion API
, the POST
operation expecting a JSON request body would like:
{
"name": "Simba",
"gender": "MALE"
}
The corresponding Swagger UI will look like:
This becomes relatively painful if the JSON request body is complex. Springfox provides UiConfiguration
class to
manipulate the look and feel of the UI in a limited way. Setting the jsonEditor
input parameter to true
turns the request body into a graphical view.
Here is an example of UiConfiguration
bean declared in the SwaggerConfiguration
class.
@Configuration
@EnableSwagger2
public class SwaggerConfiguration {
@Bean
public UiConfiguration uiConfig() {
return new UiConfiguration(
null,
"none",
"alpha",
"schema",
UiConfiguration.Constants.DEFAULT_SUBMIT_METHODS,
true,
true,
60000L);
}
}
Give this configuration, the Swagger UI for POST
operation of the Lion API
will look like: