устранение избыточности чванства - PullRequest
1 голос
/ 23 октября 2019

Я написал файл 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
...