【问题标题】:API Documentation with ReDoc and Spring boot带有 ReDoc 和 Spring 引导的 API 文档
【发布时间】:2021-07-22 01:36:31
【问题描述】:

有人可以分享一些关于如何使用 ReDoc 和 SpringBoot 框架来实现 API 文档的示例。如果有人知道一些 ReDoc + Springboot 的好例子,那将是很大的帮助。

【问题讨论】:

标签: spring spring-boot spring-mvc redoc


【解决方案1】:

您可以创建一个启用 springdoc-openapi-ui [1] 的 Spring Boot 应用程序,然后添加一个静态 html [2] 如here 所示!通过将 spec-url 更改为 http://localhost:8080/v3/api-docs [3]

[1]:https://www.baeldung.com/spring-rest-openapi-documentation

[2]:https://stackoverflow.com/a/42393332/878710

[3]:

<!DOCTYPE html>
<html>
  <head>
    <title>Redoc</title>
    <!-- needed for adaptive design -->
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">

    <!--
    Redoc doesn't change outer page styles
    -->
    <style>
      body {
        margin: 0;
        padding: 0;
      }
    </style>
  </head>
  <body>
    <redoc spec-url='http://localhost:8080/v3/api-docs'></redoc>
    <script src="https://cdn.jsdelivr.net/npm/redoc@latest/bundles/redoc.standalone.js"> </script>
  </body>
</html>

【讨论】:

    猜你喜欢
    • 2016-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-12
    • 2016-03-22
    相关资源
    最近更新 更多