在Swagger UI

时间:2017-07-07 11:27:32

标签: swagger swagger-ui

我使用Swagger编辑器Docker镜像来定义我的API规范,并生成一个nodejs服务器作为stub api运行,并提供我的API规范的文档。

我想知道是否可以将默认网址更改为我自己的网址,以便在我打开网页时显示我的规范,以及我将如何做到这一点。

enter image description here

例如,我想将默认地址更改为http://localhost:8080/spec

1 个答案:

答案 0 :(得分:1)

如果我理解正确,您使用Swagger Codegen生成Node.js服务器。现在当您#robot_test1 import urx from urx import urrobot try: rob = urx.Robot("192.168.120.30") print("Connection Opened") rob.is_running() print("Robot is running") rob.is_program_running() print("Program Running") x = rob.get_digital_in(0,'nb') print(x) print("digital Input is: "+str(x)) rob.set_digital_out(0,True) print() print("Current tool pose is: ", rob.getl) rob.movej((0.5,0,0,0,0,0),1,1, relative = True) print("Move tool pose is: ", rob.getl) rob.movej((-0.5,0,0,0,0,0),1,1,relative = True) rob.up(0.1,1,1) rob.down(0.1,1,1) except: print("Unexpected Error") finally: rob.close() print("Closing Connection") 并打开Swagger UI时,您希望输入框(规范网址)显示http://localhost:8080/ 规范,而不是http://localhost/ api文档

要更改.yaml规范的投放路径,请按以下步骤修改npm start

index.js

端口号由// 1 - add swaggerUi options var uiOptions = { apiDocs: '/spec' // <-- override the default /api-docs }; swaggerTools.initializeMiddleware(swaggerDoc, function (middleware) { ... // 2 - pass these options to swaggerUi app.use(middleware.swaggerUi(uiOptions)); 中的serverPort变量指定:

index.js