Skip to content

Commit

Permalink
Fix springdoc so that enums names are used instead of toString
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ianwallen committed Feb 2, 2024
1 parent 440714c commit 7aa83b1
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -105,6 +109,10 @@ public OpenApiController(ObjectFactory<OpenAPIService> 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)
Expand Down

0 comments on commit 7aa83b1

Please sign in to comment.