我正在使用flask-restx构建一个带有swagger的应用程序,并且我试图上传这个swagger文件作为AWS API Gateway文档的一部分。通过这个傲慢的UI,我使用户能够上传一个CSV文件进行进一步的数据处理。
我有以下swagger json:
{
"swagger": "2.0",
"basePath": "/",
"paths": {
"/upload_profile/csv": {
"post": {
"responses": {
"200": {
"description": "Profile uploaded"
},
"400": {
"description": "Validation Error"
},
"401": {
"description": "Not authorized"
}
},
"operationId": "Get uploaded profiles from user",
"parameters": [
{
"name": "csv_file",
"in": "formData",
"type": "file",
"required": true,
"description": "CSV file"
}
],
"consumes": [
"multipart/form-data"
],
"tags": [
"upload_profile"
]
}
}
},
"info": {
"title": "Upload Profile",
"version": "0.0.1"
},
"produces": [
"application/json"
],
"consumes": [
"application/json"
],
"tags": [
{
"name": "upload_profile",
"description": "Uploading User Profiles"
}
],
"responses": {
"ParseError": {
"description": "When a mask can't be parsed"
},
"MaskError": {
"description": "When any error occurs on mask"
}
}
}当我转到API网关-->文档--> Import并粘贴json时,我得到以下错误:

如何解决以下问题?如果formData不受API Gateway的支持,那么是否有其他的方法来托管这个swagger?
发布于 2020-10-21 09:10:50
问题是API需要swagger/OpenAPI版本3,而您的文件是版本2。如果您只想要一种用于文档/协作目的的托管swagger的方法,请看一下SwaggerHub https://swagger.io/tools/swaggerhub/。
但是,如果您真的必须使用,那么您需要获得OpenAPI-3格式的规范。由于API相当小,我建议自己准备OpenAPI-3规范(而不是生成它),并通过swagger在本地测试它。
https://stackoverflow.com/questions/64422925
复制相似问题