springfox: Groovy metaClass not ignored when model is built for deserialization
@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
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 16 (7 by maintainers)
Commits related to this issue
- Add tests to demonstrate using groovy models for services related to #752 — committed to springfox/springfox by dilipkrish 9 years ago
- Tests added for field property provider related to #752 — committed to springfox/springfox by dilipkrish 9 years ago
- Fixes field properties provider issue found while fixing the code coverage build issue Uncovered the fact that the field model properties provider was working incorrectly. This fixes that problem als... — committed to springfox/springfox by dilipkrish 9 years ago
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.