Fix parent schema discriminator validation#951
Merged
darrelmiller merged 9 commits intovnextmicrosoft/OpenAPI.NET:vnextfrom Aug 17, 2022
mk/fix-parent-schema-discriminator-issuemicrosoft/OpenAPI.NET:mk/fix-parent-schema-discriminator-issueCopy head branch name to clipboard
Merged
Fix parent schema discriminator validation#951darrelmiller merged 9 commits intovnextmicrosoft/OpenAPI.NET:vnextfrom mk/fix-parent-schema-discriminator-issuemicrosoft/OpenAPI.NET:mk/fix-parent-schema-discriminator-issueCopy head branch name to clipboard
darrelmiller merged 9 commits intovnextmicrosoft/OpenAPI.NET:vnextfrom
mk/fix-parent-schema-discriminator-issuemicrosoft/OpenAPI.NET:mk/fix-parent-schema-discriminator-issueCopy head branch name to clipboard
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
|
darrelmiller
requested changes
Jul 30, 2022
Member
darrelmiller
left a comment
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.. |
irvinesunday
reviewed
Aug 2, 2022
irvinesunday
reviewed
Aug 2, 2022
irvinesunday
reviewed
Aug 2, 2022
irvinesunday
reviewed
Aug 2, 2022
irvinesunday
reviewed
Aug 2, 2022
baywet
requested changes
Aug 4, 2022
baywet
approved these changes
Aug 4, 2022
darrelmiller
approved these changes
Aug 17, 2022
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