Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array items with oneOf schemas are rendered as null in examples #3859

Closed
hkosova opened this issue Nov 2, 2017 · 1 comment · Fixed by #4136
Closed

Array items with oneOf schemas are rendered as null in examples #3859

hkosova opened this issue Nov 2, 2017 · 1 comment · Fixed by #4136

Comments

@hkosova
Copy link
Contributor

hkosova commented Nov 2, 2017

Q A
Bug or feature request? Bug
Which Swagger/OpenAPI version? 3.0
Which Swagger-UI version? 3.4.2
How did you install Swagger-UI? http://editor.swagger.io
Which browser & version? Chrome 62
Which operating system? Windows 7

Demonstration API definition

openapi: 3.0.0
info:
  version: 0.0.0
  title: test

paths:
  /:
    get:
      responses:
        '200':
          description: An array containing strings and/or integers
          content:
            application/json:
              schema:
                type: array
                items:
                  oneOf:
                    - type: string
                    - type: integer

Expected Behavior

The rendered array example should use the appropriate item type - in this example, string and/or integer, that is, something like

[
  "string"
]

or

[
  0
]

or maybe even

[
  "string",
  0
]

Current Behavior

The response example is displayed as

[
  null
]

which is wrong - because the array item schema is not nullable.

Context

This might be related to #3803.

Workaround

Add an example to the schema:

              schema:
                type: array
                items:
                  oneOf:
                    - type: string
                    - type: integer
                  example: apples
                # OR
                example:
                  - oranges
                  - 15
@lock
Copy link

lock bot commented Jul 2, 2019

Locking due to inactivity.

This is done to avoid resurrecting old issues and bumping long threads with new, possibly unrelated content.

If you think you're experiencing something similar to what you've found here: please open a new issue, follow the template, and reference this issue in your report.

Thanks!

@lock lock bot locked and limited conversation to collaborators Jul 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants