如何以昂首阔步的方式发布文件?

时间:2021-09-24 17:40:00

I am using Swagger for documenting my REST Services. 1 of my service required CSV file to be upload. After specifying following properties for parameter section in JSON file I am able to get file upload option on my swagger page.

我使用Swagger来记录我的REST服务。我的一项服务需要上传CSV文件。在JSON文件中为参数部分指定以下属性后,我可以在我的招摇页面上获取文件上载选项。

{
       "name": "File",
       "description": "The file in zip format.",
       "paramType": "body",
       "required": true,
       "allowMultiple": false,
       "dataType": "file"
}

But when I select a file and click on I am getting error NS_ERROR_XPC_BAD_OP_ON_WN_PROTO: Illegal operation on WrappedNative prototype object in jquery-1.8.0.min.js (line 2), its continuously processing and I am not getting any response.

但是,当我选择一个文件并单击时,我收到错误NS_ERROR_XPC_BAD_OP_ON_WN_PROTO:在jquery-1.8.0.min.js(第2行)中对WrappedNative原型对象进行了非法操作,其持续处理并且我没有得到任何响应。

3 个解决方案

#1


31  

Note, for Swagger 2.0 (OpenAPI Specification 2.0), the Parameter object allows type to be set to file:

注意,对于Swagger 2.0(OpenAPI规范2.0),Parameter对象允许将类型设置为file:

  consumes:
    - multipart/form-data  # and/or application/x-www-form-urlencoded
  parameters:
    - name: file
      in: formData
      description: The uploaded file data
      required: true
      type: file

Described by the type field name in the OpenAPI Specification 2.0:

由OpenAPI规范2.0中的类型字段名称描述:

... "integer", "boolean", "array" or "file". If type is "file", the consumes MUST be either "multipart/form-data", " application/x-www-form-urlencoded" or both and the parameter MUST be in "formData".

...“整数”,“布尔”,“数组”或“文件”。如果type是“file”,则消耗必须是“multipart / form-data”,“application / x-www-form-urlencoded”或两者,参数必须在“formData”中。

#2


17  

finally i found answer for this, actually previously there is no support for file upload, now they updated swagger-ui.js file. You need to replace your old one with new and also you have to define these properties under Parameters for particular parameter:

最后我找到了答案,实际上以前没有文件上传支持,现在他们更新了swagger-ui.js文件。您需要用new替换旧的,并且还必须在Parameters下为特定参数定义这些属性:

 "paramType": "body",
 "dataType": "file",

#3


3  

Mine seems to work with

我似乎合作

 "paramType": "formData",
 "dataType": "file",

#1


31  

Note, for Swagger 2.0 (OpenAPI Specification 2.0), the Parameter object allows type to be set to file:

注意,对于Swagger 2.0(OpenAPI规范2.0),Parameter对象允许将类型设置为file:

  consumes:
    - multipart/form-data  # and/or application/x-www-form-urlencoded
  parameters:
    - name: file
      in: formData
      description: The uploaded file data
      required: true
      type: file

Described by the type field name in the OpenAPI Specification 2.0:

由OpenAPI规范2.0中的类型字段名称描述:

... "integer", "boolean", "array" or "file". If type is "file", the consumes MUST be either "multipart/form-data", " application/x-www-form-urlencoded" or both and the parameter MUST be in "formData".

...“整数”,“布尔”,“数组”或“文件”。如果type是“file”,则消耗必须是“multipart / form-data”,“application / x-www-form-urlencoded”或两者,参数必须在“formData”中。

#2


17  

finally i found answer for this, actually previously there is no support for file upload, now they updated swagger-ui.js file. You need to replace your old one with new and also you have to define these properties under Parameters for particular parameter:

最后我找到了答案,实际上以前没有文件上传支持,现在他们更新了swagger-ui.js文件。您需要用new替换旧的,并且还必须在Parameters下为特定参数定义这些属性:

 "paramType": "body",
 "dataType": "file",

#3


3  

Mine seems to work with

我似乎合作

 "paramType": "formData",
 "dataType": "file",