我正在使用POST动词创建一个API端点,它需要一个文件。我将我的端点声明如下:
consumes:
- application/json
- multipart/form-data
# format of the responses to the client (Accepts)
produces:
- application/json
...
/importfile:
x-swagger-router-controller: import_file
post:
description: Sends the uploaded file to deliveries microservice to be processed.
consumes:
- multipart/form-data
produces:
- application/json
operationId: importcsv
parameters:
- name: file
in: formData
description: file to upload
required: true
type: file
我在import_file.js
中有以下内容const util = require('util');
function importcsv(req, res) {
console.log(req);
const message = util.format('hi there!');
// this sends back a JSON response which is a single string
return res.json(message);
}
module.exports = {
importcsv,
};
几个问题:
即使成功回复,我也会看到:
HTTP / 1.1
content-type:text / html;字符集= utf-8的 cache-control:no-cache
Multipart:未找到边界
为什么?
我是Swagger的新手。提前谢谢。