消除庞大的冗余

时间:2019-10-23 20:17:02

标签: yaml swagger

我写了一个swagger.yaml文件来定义类型。 我下面的招摇动着,但有冗余。为了删除它,我尝试了模式和$ ref,但似乎没有任何效果。

我正在工作的招摇文件:

definitions:
  RecallPerformanceDetailsResponse:
    type: object
    additionalProperties: false
    required:
      - parts_not_avail_vin_confirmed
      - parts_not_avail_disconnect
      - difficulty_obtaining_remedy
      - dealer_sell_through
    properties:
      parts_not_avail_vin_confirmed:
        type: object
        additionalProperties: false
        required:
         - no_mfr_disposition
         - remedied
         - remedy_in_progress
         - no_action
         - total
         - with_mfr_notes
         - other
        properties:
          no_mfr_disposition:
            type: object
            additionalProperties: false
            required:
              - freq
              - count
            properties:
              freq:
                type: string
              count:
                type: string
          remedied:
            type: object
            additionalProperties: false
            required:
              - freq
              - count
            properties:
              freq:
                type: string
              count:
                type: string
          remedy_in_progress:
            type: object
            additionalProperties: false
            required:
              - freq
              - count
            properties:
              freq:
                type: string
              count:
                type: string
          no_action:
            type: object
            additionalProperties: false
            required:
              - freq
              - count
            properties:
              freq:
                type: string
              count:
                type: string
          total:
            type: object
            additionalProperties: false
            required:
              - freq
              - count
            properties:
              freq:
               type: string
              count:
               type: string
          with_mfr_notes:
            type: object
            additionalProperties: false
            required:
              - percent
              - count
            properties:
              percent:
                type: string
              count:
                type: string
          other:
            type: object
            additionalProperties: false
            required:
              - freq
              - count
            properties:
              freq:
                type: string
              count:
                type: string
      parts_not_avail_disconnect:
        type: object
        additionalProperties: false
        required:
         - no_mfr_disposition
         - remedied
         - remedy_in_progress
         - no_action
         - total
         - with_mfr_notes
         - other
        properties:
          no_mfr_disposition:
            type: object
            additionalProperties: false
            required:
              - freq
              - count
            properties:
              freq:
                type: string
              count:
                type: string
          remedied:
            type: object
            additionalProperties: false
            required:
              - freq
              - count
            properties:
              freq:
                type: string
              count:
                type: string
          remedy_in_progress:
            type: object
            additionalProperties: false
            required:
              - freq
              - count
            properties:
              freq:
                type: string
              count:
                type: string
          no_action:
            type: object
            additionalProperties: false
            required:
              - freq
              - count
            properties:
              freq:
                type: string
              count:
                type: string
          total:
            type: object
            additionalProperties: false
            required:
              - freq
              - count
            properties:
              freq:
               type: string
              count:
               type: string
          with_mfr_notes:
            type: object
            additionalProperties: false
            required:
              - percent
              - count
            properties:
              percent:
                type: string
              count:
                type: string
          other:
            type: object
            additionalProperties: false
            required:
              - freq
              - count
            properties:
              freq:
                type: string
              count:
                type: string

我正在尝试什么:(获取架构不匹配错误,我认为它不能识别$ ref)

definitions:
  RecallPerformanceDetailsResponse:
    type: object
    required:
      - parts_not_avail_vin_confirmed
      - parts_not_avail_disconnect
    properties:
      parts_not_avail_vin_confirmed:
        $ref: "#/definitions/RecallPerformanceResponseObject"
      parts_not_avail_disconnect:
        $ref: "#/definitions/RecallPerformanceResponseObject"

  RecallPerformanceResponseObject:
    type: object
    required:
     - no_mfr_disposition
     - remedied
     - remedy_in_progress
     - no_action
     - total
     - with_mfr_notes
    properties:
     no_mfr_disposition:
        $ref: "#/definitions/CountAndFreq"
    remedied:
        $ref: "#/definitions/CountAndFreq"
    remedy_in_progress:
        $ref: "#/definitions/CountAndFreq"
    no_action:
        $ref: "#/definitions/CountAndFreq"
    total:
        $ref: "#/definitions/CountAndFreq"
    with_mfr_notes:
        $ref: "#/definitions/CountAndFreq"

  CountAndFreq: 
    type: object
    additionalProperties: false
    required:
     - freq
     - count
    properties:
      freq:
        type: string
      count:
        type: integer

0 个答案:

没有答案