Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Multiple refs in schema definition

940 views
Skip to first unread message

Kanchan Pimplapure

unread,
Apr 5, 2016, 5:27:21 AM4/5/16
to Swagger
Hi All,

My response object is in json format as follows:

{{"data": [{"name":"abc","id":"1"}, {"name":"pqr","id":"2"}],"anotherData":[{"age":"40","company":"company 1"}, {"age":"35","company":"company 2"}]}

I am using Swagger Import Utility to create a doc.http://editor.swagger.io/#/
Here is what I have defined in responses:

responses:
        '200':
          description: 200 response
          schema:
            type: array
            items:
              $ref: '#/definitions/data'
              $ref: '#/definitions/anotherData'
and in definitions: I have defined:
definitions:
 data:
    type: array
    description: this is data description
    items:
      type: object
      properties:
        name:
          type: string
          description: name 
        Id:
          type: string
          description: ID
  anotherData:
    type: array
    description: this is anotherData description
    items:
      type: object
      properties:
        age:
          type: string
          description: age
        company:
          type: string
          description: company
  Empty:
    type: object
I am getting swagger error "Definition is not used: #/definitions/data"

Could you please help me how can I add/set two $refs in swagger


 

Ron Ratovsky

unread,
Apr 5, 2016, 10:39:13 AM4/5/16
to swagger-sw...@googlegroups.com
Swagger doesn’t support multi-typed arrays, unless they are derived from a common object.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages