swagger 编辑器不会生成正确的文件上传请求
swagger editor does not generate correct request for file upload
我正在使用 Swagger 编辑器构建一个 post 上传文件的请求。我的swaggerjson文件定义如下
swagger: '2.0'
info:
version: 0.0.0
title: '<enter your title>'
host: 'localhost:11235'
paths:
/form/upload:
post:
description: |
Post files.
consumes:
- multipart/form-data
produces:
- application/octet-stream
parameters:
- name: file
in: formData
description: upload file
required: true
type: file
- name: text
description: additional info
in: formData
type: string
responses:
'200':
description: Successful response
schema:
type: file
然后在小编右边。我单击尝试此操作。我select一个文件。构造的请求看起来像这样。
POST http://localhost:11235/form/upload HTTP/1.1
....
Content-Length: 40
Content-Type: multipart/form-data
file: C:\fakepath\swagger.json
text: 123
请求中没有传输文件内容。只有文件名被写入请求。这是因为swagger editor不支持文件上传还是我的swagger json错了?谁能帮我解决这个问题?谢谢
swagger-editor 仍然存在未解决的问题:
https://github.com/swagger-api/swagger-editor/issues/599
据报道,它已在 swagger-api 中修复:
https://github.com/swagger-api/swagger-ui/issues/838
使用swagger-ui上传文件,有效:
- in: formData
name: document
description: Documento Fiscal
required: true
type: file
我正在使用 Swagger 编辑器构建一个 post 上传文件的请求。我的swaggerjson文件定义如下
swagger: '2.0'
info:
version: 0.0.0
title: '<enter your title>'
host: 'localhost:11235'
paths:
/form/upload:
post:
description: |
Post files.
consumes:
- multipart/form-data
produces:
- application/octet-stream
parameters:
- name: file
in: formData
description: upload file
required: true
type: file
- name: text
description: additional info
in: formData
type: string
responses:
'200':
description: Successful response
schema:
type: file
然后在小编右边。我单击尝试此操作。我select一个文件。构造的请求看起来像这样。
POST http://localhost:11235/form/upload HTTP/1.1
....
Content-Length: 40
Content-Type: multipart/form-data
file: C:\fakepath\swagger.json
text: 123
请求中没有传输文件内容。只有文件名被写入请求。这是因为swagger editor不支持文件上传还是我的swagger json错了?谁能帮我解决这个问题?谢谢
swagger-editor 仍然存在未解决的问题: https://github.com/swagger-api/swagger-editor/issues/599
据报道,它已在 swagger-api 中修复: https://github.com/swagger-api/swagger-ui/issues/838
使用swagger-ui上传文件,有效:
- in: formData
name: document
description: Documento Fiscal
required: true
type: file