在SwaggerUI中包括客户端SDK使用示例 [英] Include client SDK usage sample in SwaggerUI
问题描述
我一直在寻找一种工具,该工具可以帮助我解析JSON swagger文件(甚至YAML文件)并基于
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上动态获取它)
- 石板,但我想继续大张旗鼓
- 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 ?
推荐答案
最后得到了它.我们不能轻易地将SwaggerUI的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屋!