为什么swagger-ui没有主题?

Why there are no themes for swagger-ui?

我非常喜欢 swagger 来记录 Restful API,尤其是 "Try it out!" 按钮,但是 swagger-ui 界面看起来不太酷。

而且我不敢相信没有这种出色的开源工具的模板(或者我找不到)?

我不想要免费的..就像http://getbootstrap.com/ has many sites to buy themes (like https://wrapbootstrap.com/),为什么我找不到任何 swagger 主题的网站?

Swagger-UI 虽然不是新工具,但它的任务非常具体。我不知道有任何网站为其提供主题(免费或付费)。它的许多用户都自定义了 UI 以适合他们的本地主题。一些进行了细微的更改,一些进行了彻底的修改。

我建议您查看可用的实现,看看是否有满足您需求的东西。然后也许请求允许根据您自己的需要重用他们的 theme/template。

一个迟到的答案,尽管是一个很好的答案。这太棒了!一个巧妙的实现,他已经定制了许多易于调整的东西来满足您的需求:https://github.com/jensoleg/swagger-ui

感谢此 google 组:https://groups.google.com/forum/#!topic/swagger-swaggersocket/oeMyayrvKRI。奇怪,这还没有张贴在这里。

有关动作演示,请查看此 link:http://senodio.com/site/swagger/#!/pet/addPet

--

编辑: 最近发现 DEMO 挂了,所以我 fork 了 Repo (https://github.com/MartinSahlen/swagger-ui) 并创建了一个在 heroku 上运行的简单 node/express 服务器。请注意,这是一个免费的 heroku dyno,因此如果一段时间内 activity 电量不足,可能需要一段时间才能加载(~20 秒)。

You're welcome: http://sleepy-harbor-80783.herokuapp.com/#!/pet/addPet

编辑 2: 刚刚遇到另一个看起来很有希望的: https://github.com/legendecas/material-swagger-ui .看来我现在主持的招摇 ui 在 http://swaggerui.herokuapp.com/ 复活了。把我的也留着,以防它再次被取下来。

这是一组可应用于 Swagger 的样式表主题 UI。 Link 下面到我的 repo 了解如何使用。

希望对您有所帮助。

https://github.com/ostranme/swagger-ui-themes

我最近使用 bootstrap v4 为任何感兴趣的人分叉重构了上面共享的 swagger-ui 主题。在这里查看 https://github.com/afgarcia86/bootstrap-swagger-ui

另一个选项是ReDoc

您只需要携带 swagger.json 文件和 index.html。设置简单。

<head>
    <title>ReDoc</title>
    <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">
    <style>
      body {
        margin: 0;
        padding: 0;
      }
    </style>
  </head>
  <body>
    <redoc spec-url='your.swagger.json'></redoc>
    <script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script>
  </body>

我也在寻找更好看的主题并找到 https://github.com/mrin9/RapiDoc

它基于 Web 组件,并表示它适用于任何框架。