File tree Expand file tree Collapse file tree 3 files changed +8
-2
lines changed
springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service
springdoc-openapi-starter-webmvc-api/src/test
java/test/org/springdoc/api/v30/app173 Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 4242import java .util .stream .Collectors ;
4343import java .util .stream .Stream ;
4444
45+ import com .fasterxml .jackson .annotation .JsonInclude .Include ;
4546import com .fasterxml .jackson .core .JsonProcessingException ;
4647import com .fasterxml .jackson .databind .ObjectMapper ;
4748import io .swagger .v3 .core .jackson .TypeNameResolver ;
@@ -245,6 +246,9 @@ public OpenAPI build(Locale locale) {
245246 try {
246247 ObjectMapper objectMapper = ObjectMapperProvider .createJson (springDocConfigProperties );
247248 calculatedOpenAPI = objectMapper .readValue (objectMapper .writeValueAsString (openAPI ), OpenAPI .class );
249+ objectMapper .setSerializationInclusion (Include .NON_EMPTY );
250+ Map extensionsClone = objectMapper .readValue (objectMapper .writeValueAsString (openAPI .getExtensions ()), Map .class );
251+ calculatedOpenAPI .extensions (extensionsClone );
248252 }
249253 catch (JsonProcessingException e ) {
250254 LOGGER .warn ("Json Processing Exception occurred: {}" , e .getMessage ());
Original file line number Diff line number Diff line change 2525package test .org .springdoc .api .v30 .app173 ;
2626
2727import java .util .Locale ;
28+ import java .util .Map ;
2829
2930import io .swagger .v3 .oas .models .OpenAPI ;
3031import org .junit .jupiter .api .Test ;
@@ -67,7 +68,7 @@ private void testApp(Locale locale) throws Exception {
6768 static class SpringDocTestApp {
6869 @ Bean
6970 public OpenAPI openAPI () {
70- return new OpenAPI ();
71+ return new OpenAPI (). extensions ( Map . of ( "TEST" , "HELLO" )) ;
7172 }
7273 }
7374
Original file line number Diff line number Diff line change 2525 }
2626 }
2727 },
28- "components" : {}
28+ "components" : {},
29+ "TEST" : " HELLO"
2930}
You can’t perform that action at this time.
0 commit comments