繁体   English   中英

Swagger 无法创建对象数组

[英]Swagger cannot create array of objects

您好我正在尝试在 swagger 集线器中创建对象数组

但是我似乎无缘无故地出错了

LocationGetAllResponse:
  properties:
    type: array
    items: 
      $ref: '#/components/schemas/LocationObject'


LocationObject:
  type: object
  properties:
    longitude:
      type: number
      example: 1
    latitude:
      type: number
      example: 2
    altitude:
      type: number
      example: 

我按照官方文档https://swagger.io/docs/specification/data-models/data-types/#array 建模

但是我得到的错误是

Structural error at components.schemas.LocationGetAllResponse.properties.type

应该是 object

基本上在 type:array 它说它应该是 object

任何帮助,将不胜感激

只需删除“属性:”:

LocationGetAllResponse:
  type: array
  items: 
    $ref: '#/components/schemas/LocationObject'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM