Ссылка на несколько схем в одной схеме - PullRequest
0 голосов
/ 10 января 2019

В swaggerhub я пытаюсь создать спокойный API. Для которого я создал n POJO для запроса. Я хотел бы представить их как ссылки в другом примере POJO:

 ClientInformation:
   type: object
   schema:
     $ref: '#/definitions/EditClient'
     $ref: '#/definitions/OtherDetails' #Duplicate mapping key error I see at this line
    properties:
      notes:
      type: string
      example: This is a test
      description: A description

Я пытался ,, но не сработало. Пожалуйста, предложите.

1 Ответ

0 голосов
/ 12 января 2019

Если ClientInformation является объединением схем EditClient и OtherDetails, вам необходимо allOf:

ClientInformation:
  allOf:
    - $ref: '#/definitions/EditClient'
    - $ref: '#/definitions/OtherDetails'
    - type: object
      properties:
        notes:
          type: string
          example: This is a test
          description: A description

Если ClientInformation имеет свойства, которые являются экземплярами других схем, вы можете $ref схемы свойств следующим образом:

ClientInformation:
  type: object
  properties:
    notes:
      type: string
      example: This is a test
      description: A description
    foo:
      $ref: '#/definitions/EditClient'
    bar:
      $ref: '#/definitions/OtherDetails'
...