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 fails in post parameter #46

Open
lihan opened this issue Sep 7, 2018 · 2 comments
Open

oneOf fails in post parameter #46

lihan opened this issue Sep 7, 2018 · 2 comments

Comments

@lihan
Copy link

lihan commented Sep 7, 2018

Try validating against the schema from https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/

Got error of

Failed validating 'oneOf' in schema['properties']['paths']['patternProperties']['^/']['properties']['patch']['properties']['requestBody']:
    {'oneOf': [{'$ref': '#/definitions/requestBody'},
               {'$ref': '#/definitions/reference'}]}

Source spec file

paths:
  /pets:
    patch:
      requestBody:
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/Cat'
                - $ref: '#/components/schemas/Dog'
      responses:
        '200':
          description: Updated
components:
  schemas:
    Dog:
      type: object
      properties:
        bark:
          type: boolean
        breed:
          type: string
          enum: [Dingo, Husky, Retriever, Shepherd]
    Cat:
      type: object
      properties:
        hunts:
          type: boolean
        age:
          type: integer
@dtkav
Copy link
Contributor

dtkav commented Sep 7, 2018

The spec validator seems to be working fine with this spec on master once I added some required fields.

# added required fields to your spec
openapi: 3.0.0
info:
  version: 0.0.0
  title: pets
# added required fields to your spec

paths:
  /pets:
    patch:
      requestBody:
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/Cat'
                - $ref: '#/components/schemas/Dog'
      responses:
        '200':
          description: Updated
components:
  schemas:
    Dog:
      type: object
      properties:
        bark:
          type: boolean
        breed:
          type: string
          enum: [Dingo, Husky, Retriever, Shepherd]
    Cat:
      type: object
      properties:
        hunts:
          type: boolean
        age:
          type: integer
> openapi-spec-validator --schema 3.0.0 lihan.yaml
OK

I think this may have something to do with the Draft4Validator used in connexion, and not to do with the openapi-spec-validator (the spec itself validates fine).

@raini35
Copy link

raini35 commented Aug 30, 2019

Just wanted to follow up on this. I'm also experiencing this problem. Any fixes?

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