在 SwaggerUI 中包含客户端 SDK 使用示例 [英] Include client SDK usage sample in SwaggerUI

查看:30
本文介绍了在 SwaggerUI 中包含客户端 SDK 使用示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一种工具,它可以帮助我解析我的 JSON swagger 文件(甚至 YAML 文件)并基于 此示例 API 文档.

I've been searching for a tool which could help me parse my JSON swagger file (or even YAML file) and generate code sample resources in my UI based on this example of API doc.

我已经试过了:

  • codegen(所以我确实在 github 存储库中有代码示例,但我不知道如何在我的 UI 上动态获取它)
  • slate,但我正在尝试继续大摇大摆
  • Widdershins
  • codegen (So I do have the code samples in a github repo, but I don't know how to get it on my UI dynamically)
  • slate, but i'm trying to go on with swagger
  • Widdershins

有人知道第三方工具能够产生这样的功能,还是我错过了 codegen 或 swagger-UI 中的某些东西?
或者我应该在我的页面中粗略地编写所有代码示例?

Does someone knows about a third-party-tool able to produce such a feature or did I miss something from codegen or swagger-UI ?
Or should I just write all my code samples roughly in my page ?

推荐答案

终于搞定了.严格地说,我们不能将 SDK 使用示例动态包含"到 SwaggerUI 中.不过,您可以使用多种语言 SDK 生成 ui!它看起来不一样,但无论如何我都会覆盖 css.

Finally got it. We can't strickly speaking "include" dynamically SDK usage samples into SwaggerUI. Nevertheless, you can generate the ui with multiple languages SDK ! It won't look the same but I'll override css anyway.

直到我发现这个Github问题 !您所要做的就是使用编辑器或代码生成器生成 html2 客户端...

Wasn't clear for me until I found this Github issue ! All you have to do is generate html2 client with the editor or codegen...

所有内容都在 index.html 中实现(有点脏,但仍然可以正常工作!).

Everything is implemented in the index.html (which is kinda dirty but still, it works fine !).

这篇关于在 SwaggerUI 中包含客户端 SDK 使用示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆