How to open local files in Swagger-UI

前端 未结 13 1682
粉色の甜心
粉色の甜心 2020-12-23 09:10

I\'m trying to open my self generated swagger specification file my.json with swagger-ui on my local computer.

So I downloaded the latest tag v2.1.8-M1

13条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-23 09:47

    I had that issue and here is much simpler solution:

    • Make a dir (eg: swagger-ui) in your public dir (static path: no route is required) and copy dist from swagger-ui into that directory and open localhost/swagger-ui
    • You will see swagger-ui with default petstore example
    • Replace default petstore url in dist/index.html with your localhost/api-docs or to make it more generalized, replace with this:

      location.protocol+'//' + location.hostname+(location.port ? ':' + location.port: '') + "/api-docs";

    • Hit again localhost/swagger-ui

    Voila! You local swagger implementation is ready

提交回复
热议问题