我尝试使用yaml在swagger 2.0中指定我的API数据类型,但我收到了引用错误(请参阅底部的错误详情)。
我使用嵌套结构,其中父对象(InvoiceConfigData)包含子对象数组(ProviderVariantsData)。这是yaml文件的层次结构:
.API /昂首阔步/ cfg中/ InvoiceConfigData.yaml:
required:
- providerName
- providerVariants
properties:
providerName:
type: string
providerVariants:
type: array
items:
$ref: "#/definitions/ProviderVariantsData"
.API /昂首阔步/ cfg中/ ProviderVariantsData.yaml:
properties:
displayName:
type: string
cif:
type: string
availableTemplates:
type: array
items:
type: string
.API /昂首阔步/ definitions.yaml:
ProviderVariantsData:
$ref: ./cfg/ProviderVariantsData.yaml
InvoiceConfigData:
$ref: ./cfg/InvoiceConfigData.yaml
但我收到以下错误:
API Errors:
#/definitions/InvoiceConfigData/$ref: Reference could not be resolved: ./cfg/InvoiceConfigData.yaml
#/definitions/ProviderVariantsData/$ref: Reference could not be resolved: ./cfg/ProviderVariantsData.yaml
API Warnings:
#/definitions/ProviderVariantsData: Definition is defined but is not used: #/definitions/ProviderVariantsData
我引用ProviderVariantsData的方式有问题,但我无法找到导致错误的原因。我试图在" definitions.yaml"中翻转订单。 (InvoiceConfigData在ProviderVariansData之上)没有成功。
答案 0 :(得分:-1)
swagger 2.0不支持多个YAML文件。