Swagger/Openapi-Annotations: How to produce allOf with $ref?

拜拜、爱过 提交于 2019-12-05 22:51:46

I haven't found a way to do it using annotations, i.e. by annotating the class.


I think it's possible to do, by:

  • Creating a model
  • Injecting the model using a ModelConverter

When I say "a model" I mean an instance of io.swagger.v3.oas.models.media.Schema.

In particular I think you'd want to create and inject a io.swagger.v3.oas.models.media.ComposedSchema instance, which supports allOf.

Doing this (i.e. creating model instances) isn't very different from hand-writing the YAML.


Another possibility -- which I haven't tried -- might be to write a slightly different ModelConverter, which you install into the chain of converters. Then, intercept calls to resolve which return a SchemaObject whose name is Betrag, and (sometimes?) replace that with a ComposedSchema instance which uses allOf.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!