-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Jsondoc examples does not use settings from springs ObjectMapper #42
Comments
Hi @ST-DDT , once again thanks for your feedback, it's always very constructive and useful. There are basically 2 steps in template generation:
What I've changed so far resides in the Java objects creation. Jsondoc can only read Java fields to find properties, while Livedoc reads the properties returned by the configured This Java objects creation is done in the I didn't change the serialization of the doc AFAIR, and the only thing that comes to my mind so far is the fact that I changed the type of the I'll look into this issue ASAP. |
Hi @ST-DDT , I've got a couple questions to investigate this issue:
|
@Bean
public JsonLivedocController documentationController() {
String version = getCurrentVersion();
String contextPath = getContextPath();
List<String> packages = Arrays.asList("a", "b", "c");
return new JsonLivedocController(version, contextPath, packages);
} No other configuration for LiveDocs.
I don't understand the question, but I guess I don't.
No, I don't get the expected result with JsonDoc either. IIRC I get the following from JsonDoc: {
"currentTime": { },
"name": "",
"startupTime": { }
}
@Configration
public class MyWebMvcConfigurerAdapter extends WebMvcConfigurerAdapter {
@Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
for (HttpMessageConverter<?> converter : converters) {
if (converter instanceof AbstractJackson2HttpMessageConverter) {
((AbstractJackson2HttpMessageConverter) converter).getObjectMapper().disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
}
}
}
} |
Thanks a lot for your answers.
This was in fact answered by question 1. There is another
Thanks for the clarification, I was really wondering how on earth this behaviour could have changed. Regarding your |
Ok, I guess I have found the issue. In fact, Livedoc doesn't use the actual I had written it this way temporarily, but I thought I had changed it to access the actual The culprit is the SpringLivedocReaderFactory: public class SpringLivedocReaderFactory {
public static LivedocReader getReader(List<String> packages) {
Reflections reflections = LivedocUtils.newReflections(packages);
AnnotatedTypesFinder annotatedTypesFinder = LivedocUtils.createAnnotatedTypesFinder(reflections);
PropertyScanner propertyScanner = createJacksonPropertyScanner();
DocReader springDocReader = new SpringDocReader(annotatedTypesFinder);
DocReader baseDocReader = new LivedocAnnotationDocReader(annotatedTypesFinder);
return new LivedocReaderBuilder().scanningPackages(packages)
.withPropertyScanner(propertyScanner)
.addDocReader(springDocReader)
.addDocReader(baseDocReader)
.build();
}
private static PropertyScanner createJacksonPropertyScanner() {
// to match the spring config without accessing the actual bean containing it
ObjectMapper jacksonObjectMapper = Jackson2ObjectMapperBuilder.json().build();
return new JacksonPropertyScanner(jacksonObjectMapper);
}
} |
The issue
The example generated by jsondoc does match the settings that have been set on the
Jackson2HttpMessageConverter
.I don't know how the template is generated, so I cannot give you further hints how to fix this.
If you give me a pointer where/how they are generated I might be able to present a solution.
Livedoc output
Expected output
The text was updated successfully, but these errors were encountered: