如何使用swagger来描述具有文件和文件名的表单
我想创建一个http表单,它包含两个输入字段:file,fname,其中文件类型为file,fname为text(上传文件的名称)。表单将把结果发送到节点应用程序。像这样大摇大摆地:如何使用swagger来描述具有文件和文件名的表单,swagger,Swagger,我想创建一个http表单,它包含两个输入字段:file,fname,其中文件类型为file,fname为text(上传文件的名称)。表单将把结果发送到节点应用程序。像这样大摇大摆地: swagger: '2.0' info: title: Test description: Tdesc version: "1.0.0" host: localhost:8080 schemes: - http basePath: /v1 produces: - application/json
swagger: '2.0'
info:
title: Test
description: Tdesc
version: "1.0.0"
host: localhost:8080
schemes:
- http
basePath: /v1
produces:
- application/json
paths:
/fileup:
x-swagger-router-controller: Default
put:
operationId: fileupPut
consumes:
- multipart/form-data
parameters:
- name: fname
in: formData
required: false
type: string
- name: file
in: formData
required: false
type: file
responses:
200:
description: D
schema:
type: string
我将其复制到,然后将其导出为nodejs程序并运行该程序。访问以使用swagger生成的UI“放置”文件fname。我在生成的Default.js控制器中放置了一个断点,并注意到文件和fname未定义
module.exports.fileupPut = function fileupPut (req, res, next) {
var file = req.swagger.params['file'].value;
var fname = req.swagger.params['fname'].value;
...
我知道文件处理代码(比如busboy)可以用来流式传输到文件。我不明白如何使用swagger解析来获取file和fname的字符串