0
我正在使用POST動詞創建一個API端點,並且需要一個文件。我宣佈我的終點如下:用swaggerize-hapi和node.js上傳文件?
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
內容類型:text/html的;字符集= UTF-8 緩存控制:無緩存
多部分:邊界沒有找到
這是爲什麼?
我是新來的Swagger。提前致謝。
res.json看起來不正確,你怎麼聲明配置關聯的處理器的路線? –