Forum Discussion

KinnarChowdhury's avatar
KinnarChowdhury
New Contributor
5 years ago

How do i define a nested class json body in a swagger file version 3.0.1

Sample of a response body Response body { "admn_user_id": 55, "admindetails": { "userdetail_id": 02, "firstname": "example1", "lastname": "example2", "contact_phon...
  • HKosova's avatar
    5 years ago

    KinnarChowdhury wrote:

    Can I pass a schema model inside another using $ref?


    Yes! Here's how:

    components:
      schemas:
    ParentSchema: type: object properties: admn_user_id: type: object example: 55 admindetails: $ref: '#/components/schemas/AdminDetails' # <------- ...
    AdminDetails: type: object properties: userdetail_id: type: integer example: 2 firstname: type: string ...