【发布时间】:2020-06-23 21:31:47
【问题描述】:
我正在尝试将多个 refs 放入 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
【问题讨论】:
-
不确定它是否重复,另一个问题是关于使用数组或对象的标准嵌套,这是关于使用引用以及如何绕过它说它们是重复的,它没有什么可做的处理它是数组还是对象,从我的回答中可以看出