0

I am using springfox-swagger2 and springfox-swagger-ui version 2.8.0 which was not exists in previous version 2.5.0. I am seeing in this version there is an Example Value added in the request however, the example shows default as application/xml as default .

@RequestMapping(value = "/", 
        produces = {"application/xml","application/json"},
        consumes = {"application/xml", "application/json"}, method = RequestMethod.POST)
public ResponseEntity<?> addEmp(
            @ApiParam(name = "request", value = "Payment Adding a new Employee Payload", required = true)
            @Valid @RequestBody Employee request)

This Example Value is getting derived from the the Object Employee and converting to either xml, json etc. My question is, is there any way the default value for Example Value can be defined in the drop down of from the multiple consuming object types defined in @RequestMapping'sconsumes` array.

Screenshot

enter image description here

Sujit
  • 468
  • 1
  • 8
  • 22
  • Sorry, it's not quite clear what you are asking for. Do you want the default example to be JSON instead of XML? If you mean something else, please clarify your question (e.g. maybe add a screenshot of Swagger UI and show what you'd like to change there). – Helen Jul 19 '18 at 06:56
  • That's right. In the Example Value of new Swagger UI I would the default is JSON instead of XML. I have attached the screenshot as well. – Sujit Jul 19 '18 at 16:54

1 Answers1

0

To fix this issue set the validatorUrl(String str) as empty string in the UiConfiguration configuration bean, passing null wouldn't work. Hope this help whomever referring this thread in future.

@Bean
public UiConfiguration uiConfig() {
  return UiConfigurationBuilder.builder()
      .
      .
      .validatorUrl(StringUtils.EMPTY)
      .build();
}
Sujit
  • 468
  • 1
  • 8
  • 22