为 REST API 生成 Swagger UI 文档文档、API、REST、UI

2023-09-07 14:17:09 作者:心心相印

我使用 Java 中的 JAX-RS/Jersey 开发了我的 REST API.我想为其转换/生成基于 Swagger 的 UI 文档.谁能以简单的方式告诉我如何做到这一点的精确/步骤?很抱歉,他们网站上给出的步骤对我来说有点模糊.

I have my REST API developed using JAX-RS/Jersey in Java. I want to convert to/generate Swagger based UI documentation for it. Can anyone please tell me precise/steps in simple way on how to do so? I m sorry but, steps given on their site are little vague for me.

推荐答案

有几种方法可以将 swagger-core 与您的应用程序集成,但根据您的描述,我将按照 https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-1.X-Project-Setup-1.5 或 https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-2.X-Project-Setup-1.5 取决于您使用的 Jersey 版本.

There are several ways to integrate swagger-core with your application, but based on your description, I'd just follow the wiki page as described either by https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-1.X-Project-Setup-1.5 or https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-2.X-Project-Setup-1.5 depending on the Jersey version you use.

这些页面还链接到一组示例,供您参考并了解它们的工作原理.他们还将 swagger-ui 直接拉入其中,因此您可以看到全套交互.

Those pages also link to a set of samples you can use for reference and see how they work. They also pull in swagger-ui directly into them so you can see a full set of interaction.