How to structure a response with an array that href has for itself in YAML / swagger.io?

How do I do something like this:

"groups":{  
      "href":"https://api.mydomain.com/account/abC132/groups",
      "items":[  

      ]
   }

I have it:

groups:
            type: array
            properties:
              href:
                type: string
            items:
              type: object
              name: division
              properties:
                href:
                  type: string
                id:
                  type: string

But the swagger editor does not recognize href by the properties for the group.

+4
source share
2 answers

I believe you are looking for something like that:

definitions:
  groups:
    title: groups
    type: object
    properties:
      href:
        type: string
      items:
        type: array
        items:
          $ref: '#/definitions/group'
  group:
    type: object
    properties:
      href:
        type: string
      id:
        type: string
+6
source

I needed to do the following:

definitions:
  groups:
    title: groups
    type: object
    properties:
      href:
        type: string
      items:
        type: array
        items:
          $ref: '#/definitions/group'
  group:
    type: object
    properties:
      href:
        type: string
      id:
        type: string
+1
source

Source: https://habr.com/ru/post/1568811/


All Articles