招摇过市错误JSON模式对象的确定版本
这是模式定义招摇过市错误JSON模式对象的确定版本,json,swagger,Json,Swagger,这是模式定义 serviceArea: [{ states: [{ type: String }], districts: [{ type: String }], cities: [{ type: String }] }] serviceArea: - states: - type: String districts: - type: Str
serviceArea: [{
states: [{
type: String
}],
districts: [{
type: String
}],
cities: [{
type: String
}]
}]
serviceArea:
- states:
- type: String
districts:
- type: String
cities:
- type: String
这就是自大的定义
serviceArea: [{
states: [{
type: String
}],
districts: [{
type: String
}],
cities: [{
type: String
}]
}]
serviceArea:
- states:
- type: String
districts:
- type: String
cities:
- type: String
我得到了上面提到的错误。请帮忙。提前谢谢。
这是浏览器中的招摇过市编辑器。假设
服务区
应该是一个具有属性状态
、地区
和城市
的对象,定义应该如下所示:
serviceArea:
type: object
properties:
states:
type: string
districts:
type: string
cities:
type: string
更新关于OP的评论:
这是一个数组的数组
数组的数组描述为:
serviceArea:
type: array
items:
type: array
items:
type: string
另一个错误是:
type:
- number
- "null"
类型
必须是单个类型,例如类型:编号
,而不是类型数组。此外,OpenAPI规范2.0不支持null
类型。一些工具使用扩展属性x-nullable:true
指示可为空的类型,因此您可以尝试以下操作:
type: number
x-nullable: true
nullable
将在下一版本OpenAPI 3.0中本机支持。这不是一个有效的招摇过市规范。您的serviceArea对象在请求/响应中应该是什么样子的?我上面已经提到过。我认为数据类型是小写的,例如字符串而不是字符串,请检查一个示例并重新格式化是的,我做到了。相同错误。请不要将代码作为图像发布。您可以将代码直接粘贴到问题中,然后使用{}
按钮将其格式化为代码。不,它不是对象。这是一个数组和你说的属性,它们也是数组。那你怎么格式化呢?对不起,我不明白。通过“试用”发送/接收时,该数组应该如何格式化?它是否只是一个数组数组,如(JSON)[[“a”、“b”、“c”]、[“d”、“e”]]
?是的,它是一个数组数组。感谢您的帮助。我做了一些修改。它起作用了。