如何自定义swagger-ui?

Fra*_*ank 5 swagger webjars

我正在学习招摇,试图做一些改变,看看它是否可以反映在索引页面上。所以起点是index.html页面,我从jar文件中复制了它:

C:\swagger-ui\target\swagger-ui-2.1.0-M1\WEB-INF\lib\swagger-ui-2.1.8-M1.jar

并将新页面保存为index2.html,在里面的html内容中添加一行,并添加到上面的jar文件中。

但我注意到它有一个.gz文件作为原始的index.html文件,不知道它的用途,所以我还制作了一个名为index2.html.gz的文件并将其添加到上面的jar文件中,然后运行jetty服务器,并加载index.html: http://localhost:8080/swagger-ui/webjars/swagger-ui/2.1.8-M1/index.html

它显示正常,然后我尝试加载:index2.html,但找不到该页面,为什么?我应该在哪里包含它,以便它显示在:http://localhost:8080/swagger-ui/webjars/swagger-ui/2.1.8-M1/index2.html

错误消息是:

HTTP 错误 404

访问 /swagger-ui/webjars/swagger-ui/2.1.8-M1/index2.html 时出现问题。原因:

Not Found
Run Code Online (Sandbox Code Playgroud)

Fra*_*ank 1

I got it done with the following steps :

[1] Create : C:\swagger-ui\petstore
[2] Copy swagger.json into it [ This is where you can customize ]
[3] Copy the index.html and save it as : Swagger_Test.html into C:\swagger-ui\src\main\webapp [ This is where you can customize ]
[4] Unpack swagger-ui-2.1.8-M1.jar into : C:\swagger-ui\src\main\webapp
[5] Create C:\swagger-ui\src\main\webapp\css and move the *.css and  *.css.gz files mentioned in the original index.html file from C:\swagger-ui\src\main\webapp to C:\swagger-ui\src\main\webapp\css
[6] Create C:\swagger-ui\src\main\webapp\lib and move the *.js and *.js.gz files mentioned in the original index.html file from C:\swagger-ui\src\main\webapp to C:\swagger-ui\src\main\webapp\lib
[7] Maybe move another few files in the original index.html file from C:\swagger-ui\src\main\webapp to C:\swagger-ui\src\main\webapp\css or C:\swagger-ui\src\main\webapp\lib
[8] Comment out the following from the pom file

<dependency>
  <groupId>org.webjars</groupId>
  <artifactId>swagger-ui</artifactId>
  <version>2.1.8-M1</version>
</dependency>

[9] In the Swagger_Test.html file
    replace : url = "http://petstore.swagger.io/v2/swagger.json";
       with : url = "/swagger-ui/petstore/swagger.json";

[10] Recompile and start the server
[11] Load page : http://localhost:8080/swagger-ui/Swagger_Test.html
            or : http://localhost:8080/swagger-ui/Swagger_Test.html?url=http://localhost:8080/swagger-ui/petstore/swagger.json
Run Code Online (Sandbox Code Playgroud)