Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

rest

yaml

swagger

How do I do something like this:

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

      ]
   }

I have this:

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

But the swagger editor isn't recognizing the href under properties for the group.

like image 858
richard Avatar asked Mar 17 '23 13:03

richard


2 Answers

I believe you're looking for something along the lines of this:

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
like image 90
Ron Avatar answered Apr 07 '23 06:04

Ron


I had 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
like image 38
Ryan Wild Avatar answered Apr 07 '23 04:04

Ryan Wild