本页
Installation Distribution Channels NPM Registry
然后解释了它们之间的区别。因此,它们在功能上是等价的,但您选择的将取决于您的web服务器/网站如何提供
swagger用户界面页面
第一个例子
const ui = SwaggerUIBundle(...
适用于Swagger UI 3.x,这是Swagger UI的当前版本。第二个例子
window.swaggerUi = new SwaggerUi(...
信用卡
@Helen
获取此信息
this
回答)
大摇大摆解释说
SwaggerUI用于可以导入npm模块的应用程序中。
这包括React、Angular或其他单页应用程序(spa),这些应用程序包括类似于webpack的工具,用于将资源打包以交付给浏览器。
网页上写着:
import SwaggerUI from 'swagger-ui'
swaggerui是指JavaScript web项目使用的,这些项目包括Webpack、Browserify和Rollup等模块绑定器。
下面是一个使用npm内置模块的示例
swagger-ui
import SwaggerUI from 'swagger-ui'
// or use require, if you prefer
const SwaggerUI = require('swagger-ui')
SwaggerUI({
dom_id: '#myDomId'
})
大摇大摆地解释道
当你的应用不支持导入npm模块(例如java webapp)时,使用SwaggerUIBundle。
swagger用户界面可以通过使用
大摇大摆索引.html页码
如何使用SwaggerUIBundle的示例如下:
var SwaggerUIBundle = require('swagger-ui-dist').SwaggerUIBundle
const ui = SwaggerUIBundle({
url: "https://petstore.swagger.io/v2/swagger.json",
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIBundle.SwaggerUIStandalonePreset
],
layout: "StandaloneLayout"
})
如果您所在的JavaScript项目无法处理传统的npm模块,那么可以执行以下操作:
var SwaggerUIBundle = require('swagger-ui-dist').SwaggerUIBundle
它使用require()哪个
包含捆绑包的方式。
一种不那么令人困惑的解释方法是:
招摇过市用户界面
).
const ui = SwaggerUIBundle({
url: "https://petstore.swagger.io/v2/swagger.json",
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIBundle.SwaggerUIStandalonePreset
],
layout: "StandaloneLayout"
})
<script src="bundle.js"></script>.
看到了吗
https://github.com/swagger-api/swagger-ui/blob/master/dist/index.html
(位于swagger ui/dist中/索引.html).
var SwaggerUIBundle=require('swagger-ui-dist')。SwaggerUIBundle
如何将javscript打包到页面上取决于您自己。