|
48 | 48 | import com.fasterxml.jackson.annotation.JsonView;
|
49 | 49 | import com.fasterxml.jackson.core.JsonProcessingException;
|
50 | 50 | import com.fasterxml.jackson.core.type.TypeReference;
|
51 |
| -import com.fasterxml.jackson.databind.MapperFeature; |
52 | 51 | import com.fasterxml.jackson.databind.ObjectMapper;
|
53 |
| -import com.fasterxml.jackson.databind.SerializationFeature; |
54 | 52 | import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
55 | 53 | import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature;
|
56 | 54 | import io.swagger.v3.core.filter.SpecFilter;
|
|
64 | 62 | import io.swagger.v3.oas.models.PathItem;
|
65 | 63 | import io.swagger.v3.oas.models.PathItem.HttpMethod;
|
66 | 64 | import io.swagger.v3.oas.models.Paths;
|
67 |
| -import io.swagger.v3.oas.models.media.Schema; |
68 | 65 | import io.swagger.v3.oas.models.media.StringSchema;
|
69 | 66 | import io.swagger.v3.oas.models.parameters.Parameter;
|
70 | 67 | import io.swagger.v3.oas.models.responses.ApiResponses;
|
|
73 | 70 | import org.apache.commons.lang3.StringUtils;
|
74 | 71 | import org.slf4j.Logger;
|
75 | 72 | import org.slf4j.LoggerFactory;
|
76 |
| -import org.springdoc.api.mixins.SortedOpenAPIMixin; |
77 |
| -import org.springdoc.api.mixins.SortedOpenAPIMixin31; |
78 |
| -import org.springdoc.api.mixins.SortedSchemaMixin; |
79 |
| -import org.springdoc.api.mixins.SortedSchemaMixin31; |
80 | 73 | import org.springdoc.core.AbstractRequestService;
|
81 | 74 | import org.springdoc.core.GenericParameterService;
|
82 | 75 | import org.springdoc.core.GenericResponseService;
|
|
98 | 91 | import org.springdoc.core.providers.ActuatorProvider;
|
99 | 92 | import org.springdoc.core.providers.CloudFunctionProvider;
|
100 | 93 | import org.springdoc.core.providers.JavadocProvider;
|
| 94 | +import org.springdoc.core.providers.ObjectMapperProvider; |
101 | 95 |
|
102 | 96 | import org.springframework.aop.support.AopUtils;
|
103 | 97 | import org.springframework.beans.factory.ObjectFactory;
|
@@ -1184,7 +1178,7 @@ protected String writeYamlValue(OpenAPI openAPI) throws JsonProcessingException
|
1184 | 1178 | String result;
|
1185 | 1179 | ObjectMapper objectMapper = springDocProviders.yamlMapper();
|
1186 | 1180 | if (springDocConfigProperties.isWriterWithOrderByKeys())
|
1187 |
| - sortOutput(objectMapper); |
| 1181 | + ObjectMapperProvider.sortOutput(objectMapper, springDocConfigProperties); |
1188 | 1182 | YAMLFactory factory = (YAMLFactory) objectMapper.getFactory();
|
1189 | 1183 | factory.configure(Feature.USE_NATIVE_TYPE_ID, false);
|
1190 | 1184 | if (!springDocConfigProperties.isWriterWithDefaultPrettyPrinter())
|
@@ -1255,7 +1249,7 @@ protected String writeJsonValue(OpenAPI openAPI) throws JsonProcessingException
|
1255 | 1249 | String result;
|
1256 | 1250 | ObjectMapper objectMapper = springDocProviders.jsonMapper();
|
1257 | 1251 | if (springDocConfigProperties.isWriterWithOrderByKeys())
|
1258 |
| - sortOutput(objectMapper); |
| 1252 | + ObjectMapperProvider.sortOutput(objectMapper, springDocConfigProperties); |
1259 | 1253 | if (!springDocConfigProperties.isWriterWithDefaultPrettyPrinter())
|
1260 | 1254 | result = objectMapper.writerFor(OpenAPI.class).writeValueAsString(openAPI);
|
1261 | 1255 | else
|
@@ -1324,23 +1318,6 @@ enum ConditionType {
|
1324 | 1318 | HEADERS
|
1325 | 1319 | }
|
1326 | 1320 |
|
1327 |
| - /** |
1328 |
| - * Sort output. |
1329 |
| - * |
1330 |
| - * @param objectMapper the object mapper |
1331 |
| - */ |
1332 |
| - private void sortOutput(ObjectMapper objectMapper) { |
1333 |
| - objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true); |
1334 |
| - objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true); |
1335 |
| - if (OpenApiVersion.OPENAPI_3_1 == springDocConfigProperties.getApiDocs().getVersion()){ |
1336 |
| - objectMapper.addMixIn(OpenAPI.class, SortedOpenAPIMixin31.class); |
1337 |
| - objectMapper.addMixIn(Schema.class, SortedSchemaMixin31.class); |
1338 |
| - } else { |
1339 |
| - objectMapper.addMixIn(OpenAPI.class, SortedOpenAPIMixin.class); |
1340 |
| - objectMapper.addMixIn(Schema.class, SortedSchemaMixin.class); |
1341 |
| - } |
1342 |
| - } |
1343 |
| - |
1344 | 1321 | /**
|
1345 | 1322 | * Sets model and view class.
|
1346 | 1323 | *
|
|
0 commit comments