27
27
import co .elastic .clients .elasticsearch .core .CountResponse ;
28
28
import io .swagger .v3 .oas .annotations .Parameter ;
29
29
import io .swagger .v3 .oas .annotations .media .Content ;
30
+ import io .swagger .v3 .oas .annotations .media .ExampleObject ;
30
31
import io .swagger .v3 .oas .annotations .media .Schema ;
31
32
import io .swagger .v3 .oas .annotations .responses .ApiResponse ;
32
33
import io .swagger .v3 .oas .annotations .responses .ApiResponses ;
@@ -387,11 +388,29 @@ public List<Setting> getSettingsDetails(
387
388
388
389
@ io .swagger .v3 .oas .annotations .Operation (
389
390
summary = "Save settings" ,
390
- description = "" )
391
- @ RequestMapping (
391
+ description = "Save the provided settings." ,
392
+ requestBody = @ io .swagger .v3 .oas .annotations .parameters .RequestBody (
393
+ description = "Map of settings to be saved" ,
394
+ required = true ,
395
+ content = @ Content (
396
+ mediaType = MediaType .APPLICATION_FORM_URLENCODED_VALUE ,
397
+ schema = @ Schema (implementation = Map .class ),
398
+ examples = {
399
+ @ ExampleObject (
400
+ name = "Example setting" ,
401
+ value = "{\n \" additionalProp1\" : \" string\" ,\n \" additionalProp2\" : \" string\" ,\n \" additionalProp3\" : \" string\" \n }"
402
+ ),
403
+ @ ExampleObject (
404
+ name = "Example setting selection manager max records to 1000" ,
405
+ value = "{\n \" system/selectionmanager/maxrecords\" : \" 1000\" \n }"
406
+ )
407
+ }
408
+ )
409
+ )
410
+ )
411
+ @ PostMapping (
392
412
path = "/settings" ,
393
- produces = MediaType .APPLICATION_JSON_VALUE ,
394
- method = RequestMethod .POST
413
+ consumes = MediaType .APPLICATION_FORM_URLENCODED_VALUE
395
414
)
396
415
@ PreAuthorize ("hasAuthority('Administrator')" )
397
416
@ ResponseStatus (HttpStatus .NO_CONTENT )
@@ -400,9 +419,11 @@ public List<Setting> getSettingsDetails(
400
419
@ ApiResponse (responseCode = "403" , description = ApiParams .API_RESPONSE_NOT_ALLOWED_ONLY_ADMIN )
401
420
})
402
421
public void saveSettings (
403
- @ Parameter (hidden = false )
404
- @ RequestParam
405
- Map <String , String > allRequestParams ,
422
+ // Mark parameter as hidden in open api specificatin as the Operation requestBody will describe the format to be supplied
423
+ // Without this fix, the swagger ui will fail to work correctly.
424
+ @ Parameter (description = "Map of settings to be saved" , required = true , hidden = true )
425
+ @ RequestParam
426
+ Map <String ,String > allRequestParams ,
406
427
HttpServletRequest request
407
428
) throws Exception {
408
429
ApplicationContext applicationContext = ApplicationContextHolder .get ();
0 commit comments