如何在OpenAPI中拥有自定义数据类型?

发布于 2025-02-03 18:23:23 字数 1006 浏览 0 评论 0原文

我正在尝试创建一个REST API,并有不同的路由到每个端点以返回值,但是它不接受自定义数据类型,例如日期或坐标。我试图创建它,但仍未得到认可。

  Coordinate:
    type: object
    required:
      - longitude
      - latitude
    properties:
      longitude:
        type: number
        description: longitude for coordinate
      latitude:
        type: number
        description: latitude for coordinate

   facilities:
    properties:
     id:
       type: number
       description: facility Id
     name:
       type: string
       description: facility Name
     coordinates: #this gives an error says invalid data type
       type: Coordinate
       description: facility Coordinate
     address:
       type: string
       description: address of facility
     energyConsumption:
       allOf:
       - type: string
       - type: integer
       - type: boolean
       - type: number
       - type: array
       - type: object

我应该像这样进行坐标

{(123,123),{2144123,123444)}

I'm trying to create a REST API and have different routes to each endpoint to return a value, but it does not accept custom data types such as Date or Coordinate. I have tried to create it but it is still not recognized.

  Coordinate:
    type: object
    required:
      - longitude
      - latitude
    properties:
      longitude:
        type: number
        description: longitude for coordinate
      latitude:
        type: number
        description: latitude for coordinate

   facilities:
    properties:
     id:
       type: number
       description: facility Id
     name:
       type: string
       description: facility Name
     coordinates: #this gives an error says invalid data type
       type: Coordinate
       description: facility Coordinate
     address:
       type: string
       description: address of facility
     energyConsumption:
       allOf:
       - type: string
       - type: integer
       - type: boolean
       - type: number
       - type: array
       - type: object

I'm supposed to take coordinate like this

{(123,123),{2144123,123444)}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文