简介,基于Swagger UI其实是纯static的web程序,仅仅在页面加载的时候,调用http连接,获取yaml字符串或者json字符串,这里我将yaml文件和放到静态项目中,并使用tomcat启动,下面来看看怎么做的
<script type="text/javascript"> $(function () { var url = window.location.search.match(/url=([^&]+)/); if (url && url.length > 1) { url = decodeURIComponent(url[1]); } else { url = "http://petstore.swagger.io/v2/swagger.json"; } |
为
<script type="text/javascript"> var resourceName=window.location.href.split('?')[1]; $(function () { var url = window.location.search.match(/url=([^&]+)/); if (url && url.length > 1) { url = decodeURIComponent(url[1]); } else { //url = "http://petstore.swagger.io/v2/swagger.json"; url="/yaml/"+resourceName+".yaml"; } |