Groovy metaClass not ignored when model is built for deserialization
See original GitHub issue @RequestMapping(value = "/myresource", method = RequestMethod.GET)
MyResource get() {
}
@RequestMapping(value = "/myresource", method = RequestMethod.POST)
MyResource save(@Valid @RequestBody MyResource myResource) {
}
When I have only “get”, in my controller - MyResource does not have metaClass. As soon as I add “save”, metaClass appears in both calls.
swagger-annotations:1.5.3-M1 swagger-model:1.5.3-M1 springfox-swagger2:2.0.0 jackson:2.4.5
Tracked to this code in BeanModelPropertyProvider:
private BeanDescription beanDescription(ResolvedType type, ModelContext context) {
if (context.isReturnType()) {
SerializationConfig serializationConfig = objectMapper.getSerializationConfig();
return serializationConfig.introspect(TypeFactory.defaultInstance()
.constructType(type.getErasedType()));
} else {
DeserializationConfig serializationConfig = objectMapper.getDeserializationConfig();
return serializationConfig.introspect(TypeFactory.defaultInstance()
.constructType(type.getErasedType()));
}
}
In both cases introspect returns metaClass description
Issue Analytics
- State:
- Created 8 years ago
- Comments:16 (7 by maintainers)
Top Results From Across the Web
Metaprogramming
The Groovy language supports two flavors of metaprogramming: runtime and compile-time. The first allows altering the class model and the ...
Read more >Jackson @JsonIgnoreProperties isn't working on referenced ...
And I was told that I cannot modify referenced model ( User ) in any way, so what I had tried was to...
Read more >Java Deserialization Tool Gadgetinspector First Glimpse
This tool will generate false positives and not false negatives (in fact, it will still be missed, which is determined by the strategy...
Read more >Metaprogramming in Groovy - Baeldung
Metaprogramming is a programming technique of writing a program to modify itself or another program using metadata. In Groovy, it's possible ...
Read more >4. User Guides - Groovy Language Documentation
All these packages and classes are imported by default, i.e. you do not have ... In Java, this is the opposite: methods are...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
exclude metaClass properties for groovy model classes in swagger: docket.ignoredParameterTypes(groovy.lang.MetaClass.class)
@aleksz have you used the guidance in the docs to configure the ObjectMapper? If you do it that way or create ObjectMapper using the Jackson2ObjectMapperBuilder you shouldn’t run into that issue.