Repository navigation
Fix parent schema discriminator validation - #951
Merged
Darrel (darrelmiller) merged 9 commits intoAug 17, 2022
Merged
Conversation
…the property name in the dicriminator
Member
|
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
|
Darrel (darrelmiller)
requested changes
Jul 30, 2022
Darrel (darrelmiller)
left a comment
Member
There was a problem hiding this comment.
The checking needs to be made recursive. See the example I included in the overview comments.
Contributor
Author
Thanks for the correction. Resolving.. |
Vincent Biret (baywet)
requested changes
Aug 4, 2022
Vincent Biret (baywet)
approved these changes
Aug 4, 2022
Vincent Biret (baywet)
requested review from
Darrel (darrelmiller) and
Irvine Sunday (irvinesunday)
August 4, 2022 13:52
Darrel (darrelmiller)
approved these changes
Aug 17, 2022
Darrel (darrelmiller)
deleted the
mk/fix-parent-schema-discriminator-issue
branch
August 17, 2022 01:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #402