【问题标题】:how to define multiple object times in map object in Open api yml如何在 Openapi yaml 的地图对象中定义多个对象时间
【发布时间】:2021-03-02 21:07:04
【问题描述】:

我是 openapi 的新手。我需要一些帮助来编写 open api yml 3.0

以下回复格式

{
    “Details”: {
        “detail1”: [
            {
                "id": “idvalue”1,
                “Info”: {
                    “Testinfo1”: "1.0.0",
                    “Testinfo2”: "2.0.0"
                }
            }
        ],
        “Detail2”: [
            {
                "id": “idvalue2”,
                “Info”: {
                    “Testinfo3”: "1.0.0",
                    “Testinfo4”: "2.0.0"                }
            }
        ],
        "Detail3”: [
            {
                “First name”: “firstName,
                “Lastname: “last”Name,
                “Address”: “address”,
                “Dependents”: []
            }
        ]
    },
    "links": {
        "self": {
            "href": “some url”
        }
    }
}

detail1、detail2、detail3 可以是不同的对象类型或相同的对象类型 并且可以没有任何细节。 我对以下几点感到震惊

  1. 我如何表示地图打开 api
  2. 如何在地图中表示多种对象类型。

【问题讨论】:

    标签: swagger swagger-ui openapi swagger-2.0 swagger-editor


    【解决方案1】:

    在 YAML 快照下方检查此内容

    DetailsSchemaElement:
      type: object
      properties:
        Details:
          type: object
          properties:
            detail1:
              type: array
              items:
                properties:
                  id:
                    type: string
                  Info:
                    type: object
                    properties:
                      Testinfo1:
                        type: string
                      Testinfo2:
                        type: string
            Detail2:
              type: array
              items:
                properties:
                  id:
                    type: string
                  Info:
                    type: object
                    properties:
                      Testinfo4:
                        type: string
                      Testinfo3:
                        type: string
            Detail3:
              type: array
              items:
                properties:
                  First-name:
                    type: string
                  Address:
                    type: string
                  Dependents:
                    type: array
                    items:
                      type: string
                  Lastname:
                    type: string
        links:
          type: object
          properties:
            self:
              type: object
              properties:
                href:
                  type: string
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多