Express Swagger openapi 3.0.x空体

Express Swagger openapi 3.0.x空体,express,swagger,openapi,swagger-jsdocs,Express,Swagger,Openapi,Swagger Jsdocs,我正在尝试将我的express api从swagger 2.0迁移到openapi 3.0.2。 swagger定义和路径是用swagger jsdoc编写的。这应该不会引起任何问题,因为他们的文档说明它可以与openapi 3.x以及swagger 2.0一起使用 将openapi:3.0.x添加到我的SwiggerDefinition时,视图看起来不错。 但是,当试图通过招摇视图执行post请求时,主体是空的 我对自大的定义如下: const swaggerOptions = { s

我正在尝试将我的express api从swagger 2.0迁移到openapi 3.0.2。 swagger定义和路径是用swagger jsdoc编写的。这应该不会引起任何问题,因为他们的文档说明它可以与openapi 3.x以及swagger 2.0一起使用

将openapi:3.0.x添加到我的SwiggerDefinition时,视图看起来不错。 但是,当试图通过招摇视图执行post请求时,主体是空的

我对自大的定义如下:

const swaggerOptions = {
    swaggerDefinition: {
        openapi: '3.0.2',
        info: {
            title: `Channels API`,
            description: "Channels API",
            version: "v1"
        },
        servers: [ {
            url: "http://127.0.0.1:3000",
            description: 'Local server'
        }],
    },
    apis: ['./routes/*.js'],
};
现在我有一个文件channels.js作为路由器: 其定义如下:

class Channel extends BaseRouter {
/**
* @swagger
*
* definitions:
*   channel:
*     type: object
*     tags:
*       - Channels
*     properties:
*       name:
*           type: string
*       global:
*           type: boolean
*     required:
*       - name
*/

constructor(app, version) {
    super(app, new ChannelCtrl(), version);
}

post() {
    /**
     * @swagger
     * /api/v1/channels:
     *  post:
     *      tags:
     *          - Channels
     *      name: Create
     *      produces:
     *          - application/json
     *      consumes:
     *          - application/json
     *      summary: Create new channel object
     *      parameters:
     *       - name: channel
     *         required: true
     *         in: body
     *         description: Fields of the channel object to be created
     *         type: object
     *         schema:
     *             $ref: '#/definitions/channel'
     *      responses:
     *          '200':
     *              description: Channel object has been created
     *              application/json:
     *                  schema:
     *                      $ref: '#/definitions/channel'
     */
    this.app.post(`/api/${this.version}/channels`, this.controller.create.bind(this.controller));
    return this;
}
使用swagger 2.0进行尝试似乎效果不错。。
我遗漏了什么?

在openapi 3.0.x中,他们已将参数替换为requestBody,如下所示,因此您的文件channels.js应如下所示:

    class Channel extends BaseRouter {
/**
* @swagger
*
* definitions:
*   channel:
*     type: object
*     tags:
*       - Channels
*     properties:
*       name:
*           type: string
*       global:
*           type: boolean
*     required:
*       - name
*/

constructor(app, version) {
    super(app, new ChannelCtrl(), version);
}

post() {
    /**
     * @swagger
     * /api/v1/channels:
     *  post:
     *      tags:
     *          - Channels
     *      name: Create
     *      produces:
     *          - application/json
     *      consumes:
     *          - application/json
     *      summary: Create new channel object
     *      requestBody:
     *         content:
     *            application/x-www-form-urlencoded:
     *               schema:
     *                  type: object
     *                  properties:
     *                     field1:          # <!--- form field name
     *                        type: string
     *                     field2:          # <!--- form field name
     *                        type: string
     *      responses:
     *          '200':
     *              description: Channel object has been created
     *              application/json:
     *                  schema:
     *                      $ref: '#/definitions/channel'
     */
    this.app.post(`/api/${this.version}/channels`, this.controller.create.bind(this.controller));
    return this;
}
类通道扩展BaseRouter{
/**
*大摇大摆
*
*定义:
*频道:
*类型:对象
*标签:
*-频道
*特性:
*姓名:
*类型:字符串
*全球:
*类型:布尔型
*所需:
*-姓名
*/
构造函数(应用程序,版本){
超级(应用程序,新ChannelCtrl(),版本);
}
post(){
/**
*大摇大摆
*/api/v1/频道:
*职位:
*标签:
*-频道
*名称:创建
*产生:
*-应用程序/json
*消耗:
*-应用程序/json
*摘要:创建新通道对象
*请求主体:
*内容:
*应用程序/x-www-form-urlencoded:
*模式:
*类型:对象
*特性:

*字段1:#您能找到解决方案吗@ARR@OrkunOzen,不,现在我切换回了swagger 2.0,但是我的其他项目没有这个问题。