home-cert-assistant/src/main/java/de/mlessmann/certassist/config/SpringdocConfiguration.java
Magnus Leßmann (@Mark.TwoFive) 8a843dc300
Some checks failed
Build / build (pull_request) Successful in 1m59s
Check formatting / check-formatting (pull_request) Failing after 19s
wip: Generate and configure OpenAPI spec
- 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
2025-06-19 23:07:27 +02:00

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);
}
}