cancel
Showing results for 
Search instead for 
Did you mean: 

allOf to include main object and more array of schemas within it

Highlighted
New Member

allOf to include main object and more array of schemas within it

I am trying to return a Posts object with Images and Videos with it.
Posts, Images and Videos are all separate objects.
Posts may or may not have Images and Videos associated to it.
I am trying to create a new response in the following way:

    PostsResponse:
      allOf:
      - $ref: '#/components/schemas/Post'
      - Images:
        type: array
        items:
          $ref: '#/components/schemas/Image'
      - Videos:
        type: array
        items:
          $ref: '#/components/schemas/Video'

While trying to do the above thing following error is thrown
should NOT have additional properties
additionalProperty: Images
same error for Videos.

Please help

2 REPLIES 2
Highlighted
Moderator

Re: allOf to include main object and more array of schemas within it

Try this:

    PostsResponse:
      allOf:
      - $ref: '#/components/schemas/Post'
      - properties:
          Images:
            type: array
            items:
              $ref: '#/components/schemas/Image'
          Videos:
            type: array
            items:
              $ref: '#/components/schemas/Video'

Helen Kosova
SmartBear Technical Writer
________________________

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
Community Manager

Re: allOf to include main object and more array of schemas within it

Thank you Helen!

 

@sanghvi_yash did the solution work for you? Please let us know!


Sonya Mihaljova
Community and Education Specialist

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:
Read the Latest News
JuneSCNJ
Top Kudoed Authors
Top Kudoed Posts