- Create two (non-functioning) demo endpoints to check the swagger UI with - Configure Jackson to only serialize specific attributes - Configure SpringDoc so that only attributes known to Jackson are shown - Add some shortcut annotations for Json formatting
27 lines
No EOL
1,001 B
Java
27 lines
No EOL
1,001 B
Java
package de.mlessmann.certassist.config;
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import io.swagger.v3.core.jackson.ModelResolver;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
/**
|
|
* Configuration for Springdoc OpenAPI to respect Jackson annotations.
|
|
* This ensures that only properties that are visible to Jackson (annotated with @JsonProperty)
|
|
* are included in the OpenAPI schema.
|
|
*/
|
|
@Configuration
|
|
public class SpringdocConfiguration {
|
|
|
|
/**
|
|
* Creates a ModelResolver that uses the same ObjectMapper as the application.
|
|
* This ensures that Springdoc respects the same visibility settings as Jackson.
|
|
*
|
|
* @param objectMapper the configured ObjectMapper from JacksonConfiguration
|
|
* @return a ModelResolver that uses the application's ObjectMapper
|
|
*/
|
|
@Bean
|
|
public ModelResolver modelResolver(ObjectMapper objectMapper) {
|
|
return new ModelResolver(objectMapper);
|
|
}
|
|
} |