Skip to content

Commit

Permalink
OpenAPI Extensions no longer work. Fixes #2104
Browse files Browse the repository at this point in the history
  • Loading branch information
bnasslahsen committed Mar 9, 2023
1 parent 53ca7f4 commit 82d46fd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.v3.core.jackson.TypeNameResolver;
Expand Down Expand Up @@ -249,6 +250,9 @@ public OpenAPI build(Locale locale) {
try {
ObjectMapper objectMapper = ObjectMapperProvider.createJson(springDocConfigProperties);
calculatedOpenAPI = objectMapper.readValue(objectMapper.writeValueAsString(openAPI), OpenAPI.class);
objectMapper.setSerializationInclusion(Include.ALWAYS);
Map extensionsClone = objectMapper.readValue(objectMapper.writeValueAsString(openAPI.getExtensions()), Map.class);
calculatedOpenAPI.extensions(extensionsClone);
}
catch (JsonProcessingException e) {
LOGGER.warn("Json Processing Exception occurred: {}", e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

package test.org.springdoc.api.v30.app173;

import java.util.Collections;
import java.util.Locale;

import io.swagger.v3.oas.models.OpenAPI;
Expand Down Expand Up @@ -65,7 +66,7 @@ private void testApp(Locale locale) throws Exception {
static class SpringDocTestApp {
@Bean
public OpenAPI openAPI() {
return new OpenAPI();
return new OpenAPI().extensions(Collections.singletonMap("TEST", "HELLO"));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@
}
}
},
"components": {}
"components": {},
"TEST": "HELLO"
}

0 comments on commit 82d46fd

Please sign in to comment.