【问题标题】:Springfox swagger inheritance support workaroundSpringfox swagger 继承支持解决方法
【发布时间】:2018-02-12 11:14:38
【问题描述】:

自 2.7.0 起,SpringFox Swagger 不支持继承:

https://github.com/springfox/springfox/issues/1983

我有一个应用程序依赖于 swagger 支持继承这一事实,但仍需要将库更新到 2.8.0 版本。

真的有可能以某种方式(甚至是肮脏的方式)为继承提供向后兼容性吗?

非常感谢任何帮助,谢谢

【问题讨论】:

  • 您找到解决方法了吗?我有同样的问题。如果您找到任何解决方法,请分享详细信息。谢谢
  • 是的,请分享您的解决方法

标签: java spring spring-boot swagger-2.0 springfox


【解决方案1】:

SpringFox Swagger 2.9.0(本文发布时的最新版本)引入了一部分继承功能。 所以你可以使用像@Apimodel(parent = MyParent.class)这样的smth将allof $ref添加到孩子, 但是这个version 不支持父类的oneof $ref

我的解决方法是迁移到springdoc open-api

父类

@Schema(oneOf = {Child1.class, Child2.class})

子类

@Schema(allOf = Parent.class)

【讨论】:

  • 我们需要@Schema(allOf = Parent.class) 部分吗?相反,我们不能只在父类上使用注解来达到预期的结果吗?
  • @TharinduSathischandra 这也可能对您有用.. 但 swagger 规范定义了使用 2 路连接...
猜你喜欢
  • 2018-03-08
  • 1970-01-01
  • 2019-04-15
  • 1970-01-01
  • 2023-04-08
  • 1970-01-01
  • 1970-01-01
  • 2012-08-14
  • 1970-01-01
相关资源
最近更新 更多