YAML 中的多个引用重复了第 43 行的映射键错误

Multiple refs in YAML duplicated mapping key at line 43 error

我正在尝试将多个引用放入 YAML 文档以分解大小,但在第 43 行出现重复的映射键错误,有没有办法做到这一点?或者我只是想把它分解成很多,初始条目文件转到路径 '''

paths:
  $ref: "./paths/_index.yaml"

然后从那里分离到:

/Users:
  get:
    $ref: "./user/listUsers.yaml"
  post:
    $ref: "./user/createUsers.yaml"
/Users/{UserId}:
  get:
    $ref: "./user/showUserById.yaml"

列出用户然后进入用户架构:

    content:
      application/json:
        schema:
          ArrayOfUsers:
            type: array
            items:
          $ref: '../../schemas/User.yaml'
  '404':
    description: no users were found
  default:
    $ref: "../../responses/UnexpectedError.yaml"

然后我想分解用户模型中的部分,这样我就可以再次使用它们,而不是有一个巨大的块

type: object
description: random corp
properties:
  # contact_info:
  #   description: contact information
  #   type: object
  #   properties:
  #     firstName:
  #       type: string
  #     lastName:
  #       type: string
  #     companyName:
  #         type: string
  #     email:
  #       type: string
  #     phone:
  #       type: string
  # address_info:
  #   description: address information of the alitus customer
  #   type: object
  #   properties:
  #     firstName:
  #       type: string
  #     lastName:
  #       type: string
  #     companyName:
  #       type: string
  #     email:
  #       type: string
  #     phone:
  #       type: string
  # account_reference:
  #   description: Alitus customers number and id for referencing
  #   type: object
  #   properties:
  #     id:
  #       type: integer
  #       format: int64
  #     accountNumber:
  #       type: integer
  #       format: int64
  $ref: "/Login/LoginDetails.yaml"
  $ref: "/packageDetails/PackageDetails.yaml"
example:
  type: array
  items:
    anyOf:
      $ref: "../examples/UserExample.yaml"

xml:
  name: User

我是想把它分开很多还是可以在 3.0 中完成 这是错误 处理您的文件时出错。请修正错误并保存文件。

#/paths/~1Users/get/responses/200/content/application~1json/schema: duplicated mapping key at line 43, column 3:
      $ref: ../../schemas/User.yaml
#/paths/~1Users~1{UserId}/get/responses/200/content/application~1json/schema: duplicated mapping key at line 43, column 3:
      $ref: ../../schemas/User.yaml
#/components/schemas/User: duplicated mapping key at line 43, column 3:
      $ref: ./User.yaml

我想通了,我只需要有一个对包含多个元素的对象的引用

所以现在我只调用一个

$ref: "/test.yaml"

在测试文件中,我们只是像这样引用所有对象

Login:
   $ref: "/Login/LoginDetails.yaml"
Package:
   $ref: "/packageDetails/PackageDetails.yaml"