Springfox -> Springdoc: How to expose additional models

末鹿安然 提交于 2020-05-17 07:38:26

问题


I need to expose some models which don't used directly in REST API methods.

With springfox I used Docket's additionalModels method to programmatically add models to specification:

docket.additionalModels(
  typeResolver.resolve(XModel1.class),
  typeResolver.resolve(XModel2.class)
)

How to do it with springdoc?

Ok, I've created fake operation with fake parameter which includes all required models. But it seems not a cool solution.


回答1:


With OpenApiCustomiser , you have access to the OpenAPI Object. You can add any object/operation you want without having to add annotations on your code.

You can have a look at the documentation for more details:

  • https://springdoc.github.io/springdoc-openapi-demos/faq.html#how-can-i-customise-the-openapi-object-


来源:https://stackoverflow.com/questions/60302708/springfox-springdoc-how-to-expose-additional-models

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