-
Notifications
You must be signed in to change notification settings - Fork 279
Fix parent schema discriminator validation #951
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
Conversation
…the property name in the dicriminator
|
The validation process needs to be recursive. The current check only validates direct children of the schema. The following example still fails. openapi: 3.0.0
info:
description: Service to test discriminator
version: 1.0.0
title: Test Service
servers:
- url: 'https://localhost'
paths:
/test:
post:
description: Sample post
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Parent'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Parent'
components:
schemas:
Parent:
type: object
oneOf:
- $ref: '#/components/schemas/ChildA'
- $ref: '#/components/schemas/ChildB'
discriminator:
propertyName: type
ChildA:
allOf:
- $ref: "#/components/schemas/BaseChild"
- properties:
AName:
type: string
type: object
ChildB:
allOf:
- $ref: "#/components/schemas/BaseChild"
- properties:
BName:
type: string
type: object
BaseChild:
properties:
type:
type: string
type: object
|
darrelmiller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The checking needs to be made recursive. See the example I included in the overview comments.
Thanks for the correction. Resolving.. |
Fixes #402