Yaml 在Swagger中创建复杂类型(定义)
我创建了一个名为Yaml 在Swagger中创建复杂类型(定义),yaml,swagger,swagger-2.0,swagger-editor,Yaml,Swagger,Swagger 2.0,Swagger Editor,我创建了一个名为Product的定义和另一个名为Text(参见代码)的定义 在路径的参数上我无法使用定义中创建的类型文本。在定义Product中,我有一个名为message的属性,我希望该属性也是Text类型 (...) paths: /products: get: summary: Product Types description: | Description text parameters: - name:
Product
的定义和另一个名为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
但出现这种错误:
招摇过市错误:
数据与“anyOf”中的任何架构不匹配
如何引用类型
产品上的类型文本?请改用$ref
。这里有一个例子
type: object
required:
- name
properties:
name:
type: string
address:
$ref: '#/definitions/Address'
age:
type: integer
format: int32
minimum: 0
参考:嗨,谢谢你的回答。。。它适用于本例,但现在我无法在路径参数中使用$ref。我把这个例子放在上面。您知道如何在路径的参数中引用此类型吗?注意。对于路径参数,不能使用模型
。路径参数应为基本类型,例如字符串、数字等。