From 7aa83b19d90e8486f3d2e0b87523fc7568ef416b Mon Sep 17 00:00:00 2001 From: Ian Allen Date: Mon, 29 Jan 2024 10:59:21 -0400 Subject: [PATCH] Fix springdoc so that enums names are used instead of toString This fixes bug where some apis will not execute correctly from the swagger pager due to the wrong enum value being supplied. i.e. visibility should be using enum values PUBLIC/PRIVATE instead of public/private in formatters/zip api, the format should be SIMPLE/PARTIAL/FULL instead of simple/partial/full --- .../main/java/org/fao/geonet/api/OpenApiController.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/services/src/main/java/org/fao/geonet/api/OpenApiController.java b/services/src/main/java/org/fao/geonet/api/OpenApiController.java index cc585db0b65..7a03f1ed844 100644 --- a/services/src/main/java/org/fao/geonet/api/OpenApiController.java +++ b/services/src/main/java/org/fao/geonet/api/OpenApiController.java @@ -21,7 +21,11 @@ package org.fao.geonet.api; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializationFeature; + +import io.swagger.v3.core.util.Json; import io.swagger.v3.core.util.PathUtils; +import io.swagger.v3.core.util.Yaml; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.models.OpenAPI; import org.springdoc.api.AbstractOpenApiResource; @@ -105,6 +109,10 @@ public OpenApiController(ObjectFactory openAPIBuilderObjectFacto this.servletContextProvider = servletContextProvider; this.springSecurityOAuth2Provider = springSecurityOAuth2Provider; this.routerFunctionProvider = routerFunctionProvider; + + // Ensure all enums are written based on the enum name. + Json.mapper().configure(SerializationFeature.WRITE_ENUMS_USING_TO_STRING, false); + Yaml.mapper().configure(SerializationFeature.WRITE_ENUMS_USING_TO_STRING, false); } @Operation(hidden = true)