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

Fix 3859 Added support for oneOf and anyOf in array sample #4136

Merged
merged 14 commits into from
Mar 3, 2018

Conversation

PavelStefanov
Copy link
Contributor

@PavelStefanov PavelStefanov commented Jan 18, 2018

Motivation and Context

Fixes #3859

Description

Added support for oneOf and anyOf properties in array sample.

schema:
  type: array
  items:
    oneOf:
      - type: string
      - type: integer
schema:
  type: array
  items:
    anyOf:
      - type: string
      - type: integer

it will look like this

[
  "string",
  0
]

Also fixed examples for array items.

schema:
  type: array
  items:
      oneOf:
        - type: string
        - type: integer
      example:
        - oranges
        - 15

before

[
  [
    "oranges",
    15
  ]
]

now

[
  "oranges",
  15
]

Types of changes

  • No code changes (changes to documentation, CI, metadata, etc)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@PavelStefanov PavelStefanov changed the title Bug/3859 array one of any of Bug/3859 Added support for oneOf and anyOf in array sample Jan 18, 2018
@PavelStefanov PavelStefanov changed the title Bug/3859 Added support for oneOf and anyOf in array sample Fix 3859 Added support for oneOf and anyOf in array sample Jan 18, 2018
@hkosova
Copy link
Contributor

hkosova commented Jan 20, 2018

Just FYI, this example is not really valid

schema:
  type: array
  items:
      oneOf:
        - type: string
        - type: integer
      example:
        - oranges
        - 15

It means an array item can have the literal value ["oranges", 15]. So the rendering of this as a nested array is correct.

Multi-item examples (aka whole array examples) should be on the array level, not under items

schema:
  type: array
  items:
      oneOf:
        - type: string
        - type: integer
  example:
    - oranges
    - 15

Atomic item examples can be defined like so:

  items:
      oneOf:
        - type: string
          example: oranges
        - type: integer
          example: 15
      example: oranges

@PavelStefanov
Copy link
Contributor Author

@hkosova thank you for the clarification. I removed changes for examples and fixed tests

@shockey shockey merged commit b13b05e into swagger-api:master Mar 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Array items with oneOf schemas are rendered as null in examples
3 participants