并创造了许多微服务 . 因此,只有在添加服务名称后,才能访问所有微服务 .
http://example.com/service_name/get_data
一切正常,然后我想为所有微服务添加招摇,所以尝试使用下面的代码我可以通过使用访问swagger ui
http://example.com/service_name/ui
但问题是我无法在该ui中加载swagger.json,因为它试图在下面的url上访问swagger.json
http://example.com/swagger.json
但是json文件已打开
http://example.com/service_name/swagger.json
如何更改swagger.json的默认路径?
微服务中的应用程序是在python-flask中创建的,我在下面的片段中尝试过
swagger: "2.0"
info:
description: "Add service"
version: "1.0.0"
title: "Add Service"
contact:
email: "abc@efg.com"
license:
name: "s1.0"
url: "http://sample.com"
host: "abc.efg.com"
tags:
- name: "add service"
description: "service"
- name: "delete service"
description: "data"
schemes:
- "http"
paths:
/service_name/get_data:
甚至我试图在swagger.yaml文件中添加basePath然后它甚至没有打开swaggerui
swagger: "2.0"
info:
description: "Add service"
version: "1.0.0"
title: "Add Service"
contact:
email: "abc@efg.com"
license:
name: "s1.0"
url: "http://sample.com"
host: "abc.efg.com"
basePath: "service_name"
tags:
- name: "add service"
description: "service"
- name: "delete service"
description: "data"
schemes:
- "http"
paths:
/get_data:
更新:
from flask import Flask
import connexion
app = Flask(__name__)
app = connexion.App(__name__)
app.add_api('swagger.yaml')
//apis
if __name__ == "__main__":
app.run(host='0.0.0.0', port=8090, debug=True)