openapi-spec-validator
openapi-spec-validator copied to clipboard
oneOf fails in post parameter
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
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).
Just wanted to follow up on this. I'm also experiencing this problem. Any fixes?