我只需将https://github.com/swagger-api/swagger-core添加到我的项目中,并生成一个魔术般的模式。
但是该框架不会处理mixin批注@jsonignore,并且大摇大摆的架构会显示它。
swagger支持mixin吗?
我的配置:
@ApplicationPath("/")
public class MyApplication extends ResourceConfig {
public MyApplication() {
register(JacksonFeature.class);
register(JacksonObjectMapperProvider.class);
register(PreFilter.class);
register(PosFilter.class);
OpenApiResource openApiResource = new OpenApiResource();
register(openApiResource);
}
对象映射器定义(JacksonObjectMapperProvider)
public class JacksonObjectMapperProvider implements ContextResolver {
final ObjectMapper defaultObjectMapper;
public JacksonObjectMapperProvider() {
defaultObjectMapper = createDefaultMapper();
}
@Override
public ObjectMapper getContext(Class<?> type) {
return defaultObjectMapper;
}
public static ObjectMapper createDefaultMapper() {
final ObjectMapper jackson = new ObjectMapper();
jackson.addMixIn(Model.class, ModelMixin.class);
return jackson;
}
}