cancel
Showing results for 
Search instead for 
Did you mean: 

Question about schemas

Bernadete
New Member

Question about schemas

Does anyone know how to create a schema where one object is inside another object?

Example:

Bernadete_0-1613175824491.png

I read a doc, but I couldn't find a solution.

1 REPLY 1
HKosova
Moderator

Re: Question about schemas

Hi @Bernadete, check out the examples here:

Nested Objects

How to have a property reference a model (i.e. nest the models)? 

 

Basically, you define a separate schema for the nested object and then have a property $ref that schema, like so:

properties:
  user:
    # OAS 3
    $ref: '#/components/schemas/User'
    # OAS 2
    # $ref: '#/definitions/User'

 


Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements