问题
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