我创建了一个名为 Product
的定义,另一个名为 Text
(参见代码) .
在 parameters
paths
我无法使用定义中创建的 Text
类型 . 在定义 Product
我有一个名为 message
的属性,我希望该属性也是 Text
类型 .
(...)
paths:
/products:
get:
summary: Product Types
description: |
Description text
parameters:
- name: latitude
in: query
description: Latitude component of location.
required: true
### The type Text was not found here
type: Text ### The type Text was not found here
(...)
definitions:
Product:
properties:
message:
### The type Text was not found here
type: Text ### Compilation Error in this line ####
name:
type: string
description: Data description.
Text:
properties:
code:
type: string
但是会发生以下错误:
Swagger错误:数据与'anyOf'中的任何模式都不匹配 .
如何在 Product
类型上引用类型 Text
?
1 回答
请改用
$ref
. 这是一个例子参考:https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#simple-model