From 3f8483534c1469923599da5f91f8f90800a29c75 Mon Sep 17 00:00:00 2001 From: Mariusz Zawadzki Date: Mon, 20 Jun 2022 17:45:22 +0200 Subject: [PATCH] Issue 1690: fix expected file to be in alphabetical order. Fix ObjectMapperProvider to sort all properties. --- .../org/springdoc/core/providers/ObjectMapperProvider.java | 3 +-- .../src/test/resources/results/3.0.1/app138.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/providers/ObjectMapperProvider.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/providers/ObjectMapperProvider.java index 2ebd73257..67dc68446 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/providers/ObjectMapperProvider.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/providers/ObjectMapperProvider.java @@ -25,7 +25,6 @@ import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.databind.json.JsonMapper; import io.swagger.v3.core.util.Json; import io.swagger.v3.core.util.Json31; import io.swagger.v3.core.util.ObjectMapperFactory; @@ -117,7 +116,7 @@ public static ObjectMapper createJson(SpringDocConfigProperties springDocConfigP */ public static void sortOutput(ObjectMapper objectMapper, SpringDocConfigProperties springDocConfigProperties) { objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true); - JsonMapper.builder().configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true); + objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true); if (OpenApiVersion.OPENAPI_3_1 == springDocConfigProperties.getApiDocs().getVersion()) { objectMapper.addMixIn(OpenAPI.class, SortedOpenAPIMixin31.class); objectMapper.addMixIn(Schema.class, SortedSchemaMixin31.class); diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app138.json b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app138.json index 5722d0a45..b5c657b22 100644 --- a/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app138.json +++ b/springdoc-openapi-webmvc-core/src/test/resources/results/3.0.1/app138.json @@ -1 +1 @@ -{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/testA":{"get":{"tags":["hello-controller"],"operationId":"testA","parameters":[{"name":"hello","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK"}}}},"/testB":{"get":{"tags":["hello-controller"],"operationId":"testB","parameters":[{"name":"hello","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK"}}}}},"components":{},"x-my-vendor-extensions":{"property1":"value1","property2":null}} \ No newline at end of file +{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/testA":{"get":{"operationId":"testA","parameters":[{"in":"query","name":"hello","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK"}},"tags":["hello-controller"]}},"/testB":{"get":{"operationId":"testB","parameters":[{"in":"query","name":"hello","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK"}},"tags":["hello-controller"]}}},"components":{},"x-my-vendor-extensions":{"property1":"value1","property2":null}} \ No newline at end of file