[英]Load json data and create documentation without swagger-ui
I have seen the following link for my query, Python Flask automatically generated Swagger/OpenAPI 3.0 but i want to load json file inside apispec.我已经看到以下链接用于我的查询, Python Flask 自动生成 Swagger/OpenAPI 3.0 ,但我想在 apispec 中加载 json 文件。
Following is my tried code:以下是我尝试过的代码:
import json
with open("rest_api_swagger.json", 'r') as x:
a = json.loads(x.read())
final_data = []
def solve(x):
if type(x) == dict:
#print(x)
for k,v in x.items():
if type(v) == dict:
print("dict data entered: ","key name: ",k,"---->>",v)
solve(v)
elif type(v) == list:
for q in v:
print("array data entered: ","key name: ",k,"---->>",q)
elif type(v) == str:
if
print("This is string: ","key name: ",k,"---->>",v)
solve(a)
spec = APISpec(
"finaldata array here"
)
I know array data cannot be given into APISpec but just giving an example, is there a way to load json data into APISpec directly?我知道不能将数组数据提供给 APISpec 但只是举个例子,有没有办法将 json 数据直接加载到 APISpec 中?
I know APISpec generates json data but what i want is the api documetation, without using swagger-ui.我知道 APISpec 生成 json 数据,但我想要的是 api 文档,而不使用 swagger-ui。 Is there a way to create swagger documentation with json objects after loading swagger.json?
加载swagger.json后,有没有办法用json对象创建swagger文档?
can try to use flask-toolkits
this one link可以尝试使用
flask-toolkits
这个链接
upon implemented you can access both in your browser实施后,您可以在浏览器中访问两者
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.