Skip to content

Commit df242b3

Browse files
authored
Merge pull request #1713 from mariusz-zawadzki/fix/issue_1690/ensure_alphabetical_order_of_properties_when_configured
Issue 1690: fix expected file to be in alphabetical order. Fix ObjectMapperProvider to sort all properties.
2 parents f5208eb + 3f84835 commit df242b3

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

springdoc-openapi-common/src/main/java/org/springdoc/core/providers/ObjectMapperProvider.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import com.fasterxml.jackson.databind.MapperFeature;
2626
import com.fasterxml.jackson.databind.ObjectMapper;
2727
import com.fasterxml.jackson.databind.SerializationFeature;
28-
import com.fasterxml.jackson.databind.json.JsonMapper;
2928
import io.swagger.v3.core.util.Json;
3029
import io.swagger.v3.core.util.Json31;
3130
import io.swagger.v3.core.util.ObjectMapperFactory;
@@ -117,7 +116,7 @@ public static ObjectMapper createJson(SpringDocConfigProperties springDocConfigP
117116
*/
118117
public static void sortOutput(ObjectMapper objectMapper, SpringDocConfigProperties springDocConfigProperties) {
119118
objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
120-
JsonMapper.builder().configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
119+
objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
121120
if (OpenApiVersion.OPENAPI_3_1 == springDocConfigProperties.getApiDocs().getVersion()) {
122121
objectMapper.addMixIn(OpenAPI.class, SortedOpenAPIMixin31.class);
123122
objectMapper.addMixIn(Schema.class, SortedSchemaMixin31.class);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +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}}
1+
{"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}}

0 commit comments

Comments
 (0)