Skip to content

Commit 37e2faf

Browse files
committed
Fix set site settings in swagger_ui so it function correctly.
Prior to this fix, the swagger ui for applying site settings was not working.
1 parent 490e6b9 commit 37e2faf

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

services/src/main/java/org/fao/geonet/api/site/SiteApi.java

+28-7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import co.elastic.clients.elasticsearch.core.CountResponse;
2828
import io.swagger.v3.oas.annotations.Parameter;
2929
import io.swagger.v3.oas.annotations.media.Content;
30+
import io.swagger.v3.oas.annotations.media.ExampleObject;
3031
import io.swagger.v3.oas.annotations.media.Schema;
3132
import io.swagger.v3.oas.annotations.responses.ApiResponse;
3233
import io.swagger.v3.oas.annotations.responses.ApiResponses;
@@ -387,11 +388,29 @@ public List<Setting> getSettingsDetails(
387388

388389
@io.swagger.v3.oas.annotations.Operation(
389390
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(
392412
path = "/settings",
393-
produces = MediaType.APPLICATION_JSON_VALUE,
394-
method = RequestMethod.POST
413+
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE
395414
)
396415
@PreAuthorize("hasAuthority('Administrator')")
397416
@ResponseStatus(HttpStatus.NO_CONTENT)
@@ -400,9 +419,11 @@ public List<Setting> getSettingsDetails(
400419
@ApiResponse(responseCode = "403", description = ApiParams.API_RESPONSE_NOT_ALLOWED_ONLY_ADMIN)
401420
})
402421
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,
406427
HttpServletRequest request
407428
) throws Exception {
408429
ApplicationContext applicationContext = ApplicationContextHolder.get();

0 commit comments

Comments
 (0)