对于一个nodejs-project,我使用swagger-ui-express和swagger-jsdocs作为Swagger API。当我尝试使用Swagger调用应用程序的POST-Endpoint时,没有数据发送。会有什么问题呢?我的整个相关代码如下:
const swaggerOptionsJSDocs = {
swaggerDefinition: {
openapi: '3.0.1', //tried with 3.0.0 as well
info: {
title: "Testproject",
description: "Middleware for bla bla ",
contact: {
name: "John Doo"
}
}
},
apis: ["index.js"]
};
const swaggerDocs = swaggerJsDoc(swaggerOptionsJSDocs);
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocs));
**
* @swagger
* /user/upload:
* post:
* description: Receives a zipped and base64 encoded user
* consumes:
* - application/json
* parameters:
* - in: body
* name: fullRequest // name here doesn't matter
* description: ...
* schema:
* type: object
* required:
* - user
* properties:
* user:
* type: string
* jobId:
* type: string
* responseUrl:
* type: string
* inaugurationDate:
* type: string
* responses:
* '201':
* description: user received and uploaded successfully
* '400':
* description: user data is missing or invalid
* '500':
* description: Internal server error
*
*
*
*/
app.post('/user/upload', function(req, res) {
....
}
Swagger正在执行get请求,但当它发送数据时,d-flag为空。有人有主意吗?
最好的问候
2条答案
按热度按时间gwo2fgha1#
“:body”中的参数“”无效。在API 3中,你必须将requestBody作为一个单独的块传递。
此外,您必须使用@openapi才能使用Open API。
参考这里,查看requestBody对象的示例。
dbf7pr2w2#
我也遇到了同样的问题,请尝试更换
与