YAMLSyntaxError:所有集合项必须从同一列开始

YAMLSyntaxError: All collection items must start at the same column

提问人:alexthgreat _194 提问时间:11/16/2023 更新时间:11/17/2023 访问量:27

问:

我在Express.js路由中的一些招摇配置时遇到了问题。我正在使用“swagger-jsdoc”和“swagger-ui-express”在我的代码中制作文档,并使其可以通过“/docs路由访问

这段代码在我的路线的底部:


/**
 * @swagger
 * /table/join:
 *    post:
 *      summary: Join table
 *      requestBody:
 *        description: Table and user uuids
 *        required: true
 *        content:
 *          application/json:
 *            schema:
 *              type: object
 *              properties:
 *                user_id:
 *                  type: string
 *                table_uuid:
 *                  type: string
 *      tags:
 *        - Table
 *      responses:
 *        "200":
 *          description: Your table created successfully.
 *          content:
 *              application/json:
 *                  schema:
 *                      type: object
 *                      properties:
 *                          resultMessage:
 *                              $ref: '#/components/schemas/ResultMessage'
 *                          resultCode:
 *                              $ref: '#/components/schemas/ResultCode'
 *                          uuid:
 *                              type: string
 *       "400":
 *          description: Please provide all the required fields!
 *          content:
 *              application/json:
 *                  schema:
 *                      $ref: '#/components/schemas/Result'
 *       "500":
 *          description: An internal server error occurred, please try again.
 *          content:
 *              application/json:
 *                  schema:
 *                      $ref: '#/components/schemas/Result'
 */

无论我对间距有什么改变,什么都没有改变。我错过了什么吗?


 Error in src/api/controllers/user-table/join-table.js :
YAMLSyntaxError: All collection items must start at the same column at line 3, column 6:

     summary: Join table
     ^^^^^^^^^^^^^^^^^^^…
节点.js XML Express Swagger-UI

评论

1赞 Oluwafemi Sule 11/16/2023
更正缩进。前面应该有 3 个空格。即从上一级缩进 2 个空间。post

答:

0赞 Jeremy Fiel 11/17/2023 #1

看起来像你的,并且相差一个空格400500

@swagger:
/table/join:
  post:
    summary: Join table
    requestBody:
      description: Table and user uuids
      required: true
      content:
        application/json:
          schema:
            type: object
            properties:
              user_id:
                type: string
              table_uuid:
                type: string
    tags:
      - Table
    responses:
      "200":
        description: Your table created successfully.
        content:
          application/json:
            schema:
              type: object
              properties:
                resultMessage:
                  $ref: "#/components/schemas/ResultMessage"
                resultCode:
                  $ref: "#/components/schemas/ResultCode"
                uuid:
                  type: string
      "400":
        description: Please provide all the required fields!
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Result"
      "500":
        description: An internal server error occurred, please try again.
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Result"