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

'oneOf' support #25

Open
tomfitzhenry opened this issue Nov 10, 2014 · 3 comments
Open

'oneOf' support #25

tomfitzhenry opened this issue Nov 10, 2014 · 3 comments

Comments

@tomfitzhenry
Copy link

See: http://json-schema.org/latest/json-schema-validation.html#anchor88

Example

---
swagger: "2.0"
info:
  title: oneOf
  version: 0.0.1
paths:
  /:
    get:
      summary: oneOf
      responses:
        200:
          description: word or number
          schema:
            type: object
            properties:
              aWordOrNumber:
                type: object
                oneOf:
                  - type: object
                    properties:
                      myWord:
                        title: My Word
                        type: string
                  - type: object
                    properties:
                      myNumber:
                        title: My Number
                        type: number

Expected

Either:
{"aWordOrNumber":{"myWord": "foobar"}} or
{"aWordOrNumber":{"myNumber": 1}}

Actual

{"aWordOrNumber":{}}

@tomfitzhenry tomfitzhenry changed the title 'anyOf' support 'oneOf' support Nov 11, 2014
@mohsen1
Copy link

mohsen1 commented Nov 11, 2014

The schema should not have anyOf and oneOf according to Swagger specs. Swagger is designed to have predictable response objects. This helps tools like SDK generators work accurately.

@tomfitzhenry
Copy link
Author

@mohsen1 In response definitions, is it valid to have JSON Schema (which includes oneOf and anyOf)?

@webron
Copy link

webron commented Nov 11, 2014

@tomfitzhenry - no. Swagger does not support JSON Schema as a whole but uses a subset of it with specific extensions. You can see what's actually supported here - https://github.com/wordnik/swagger-spec/blob/master/versions/2.0.md#schemaObject

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

No branches or pull requests

3 participants