昂首阔步的交互式HTML [英] Swagger single interactive html
问题描述
我正在尝试使用尝试按钮创建一个html。
swagger-code gen或swagger-ui都给我这个结果。您有任何建议吗?
I'm trying to make a single html with the try out button. The swagger-code gen nor the swagger-ui gives me that result. Do you have any suggestion?
推荐答案
您可以尝试更改将Swagger UI 转换为一个大的HTML杂乱文件,如下所示:
You can try changing Swagger UI into "one big messy HTML file" as follows:
-
下载Swagger用户界面(链接到最新的母版)。
转到 dist
文件夹。
编辑 index.html
如下:
-
删除
< link rel = stylesheet type = text / css href = ./ swagger-ui.css>
并粘贴的内容swagger-ui.css
文件放入< style>
元素。
Delete
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
and paste the contents of theswagger-ui.css
file into the<style>
element.
替换
<script src="./swagger-ui-bundle.js"> </script>
<script src="./swagger-ui-standalone-preset.js"> </script>
带有< script> ...< / script>
元素,其中包含 swagger-ui-bundle.js
和 swagger-ui-standalone-preset.js
。
with a <script>...</script>
element containing the code from swagger-ui-bundle.js
and swagger-ui-standalone-preset.js
.
替换
url: "http://petstore.swagger.io/v2/swagger.json",
, spec
参数包含JSON格式的API规范,例如:
with the spec
parameter containing your API spec in the JSON format, like so:
spec: {
"swagger": "2.0",
"info": ...,
"paths": ...
},
如果您的规范是YAML,请先将其转换为JSON,例如使用 https://www.json2yaml.com 。
If your spec is YAML, convert it to JSON first, e.g. using https://www.json2yaml.com.
删除图标:< link rel = icon type = image / png href = ./ favicon -...
现在 index.html
可以用作独立文件。
Now index.html
can be used as a standalone file.
这篇关于昂首阔步的交互式HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!