Openapi-specification: jsonapi included array

Created on 25 Jan 2018  Â·  5Comments  Â·  Source: OAI/OpenAPI-Specification

I apologize if this has been asked and answered but I cannot seem to get this to work

responses:
        '200':
          description: returns a jsonapi driver object
          content:
            'application/vnd.api+json':
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/driver'
                  included:
                    type: array
                    items:
                      enum:
                      - $ref: '#/components/schemas/account'
                      - $ref: '#/components/schemas/reservation-term'
                      - $ref: '#/components/schemas/term-agreement'
                      - $ref: '#/components/schemas/mobile-device'
                      - $ref: '#/components/schemas/driver-notification'
                  meta:
                    type: object
                    properties:
                      jwt:
                        type: string
                      subdomain:
                        type: string

In the example above it does not error, but it displays an array with a single empty {}

All 5 comments

@rossi-jeff enum values are literals, not schemas, so you cannot use Reference Objects ($ref) inside of enum.

If you want alternate schemas, use oneOf or anyOf

thank you for the very fast response

On Jan 25, 2018, at 4:41 PM, Henry Andrews notifications@github.com wrote:

If you want alternate schemas, use oneOf or anyOf

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/OAI/OpenAPI-Specification/issues/1465#issuecomment-360609640, or mute the thread https://github.com/notifications/unsubscribe-auth/AAo9WHIEdesDipEGxxQRZ9IUvHXVYAKtks5tOPT2gaJpZM4RthTL.

@MikeRalphson @webron @darrelmiller I think we can close this as answered? (and by "we" I mean "you" :-)

anyOf does not error, but renders as an array with a single null element on swagger

Was this page helpful?
0 / 5 - 0 ratings