Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure openapi ObjectMapper using spring builder settings #1924

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
Expand Down Expand Up @@ -608,13 +609,14 @@ CloudFunctionProvider springCloudFunctionProvider(Optional<FunctionCatalog> func
* Object mapper provider object mapper provider.
*
* @param springDocConfigProperties the spring doc config properties
* @param objectMapperBuilder the object mapper builder
* @return the object mapper provider
*/
@Bean
@ConditionalOnMissingBean
@Lazy(false)
ObjectMapperProvider springDocObjectMapperProvider(SpringDocConfigProperties springDocConfigProperties){
return new ObjectMapperProvider(springDocConfigProperties);
ObjectMapperProvider springDocObjectMapperProvider(SpringDocConfigProperties springDocConfigProperties, Jackson2ObjectMapperBuilder objectMapperBuilder) {
return new ObjectMapperProvider(springDocConfigProperties, objectMapperBuilder);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.springdoc.api.mixins.SortedSchemaMixin31;
import org.springdoc.core.SpringDocConfigProperties;
import org.springdoc.core.SpringDocConfigProperties.ApiDocs.OpenApiVersion;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;

/**
* The type Spring doc object mapper provider.
Expand All @@ -58,8 +59,9 @@ public class ObjectMapperProvider extends ObjectMapperFactory {
* Instantiates a new Spring doc object mapper.
*
* @param springDocConfigProperties the spring doc config properties
* @param objectMapperBuilder the object mapper builder
*/
public ObjectMapperProvider(SpringDocConfigProperties springDocConfigProperties) {
public ObjectMapperProvider(SpringDocConfigProperties springDocConfigProperties, Jackson2ObjectMapperBuilder objectMapperBuilder) {
OpenApiVersion openApiVersion = springDocConfigProperties.getApiDocs().getVersion();
if (openApiVersion == OpenApiVersion.OPENAPI_3_1) {
jsonMapper = Json31.mapper();
Expand All @@ -69,6 +71,7 @@ public ObjectMapperProvider(SpringDocConfigProperties springDocConfigProperties)
jsonMapper = Json.mapper();
yamlMapper = Yaml.mapper();
}
objectMapperBuilder.configure(jsonMapper);
}

/**
Expand Down