Skip to content

Take into account (x-)nullable when validating defaults #1463

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

Merged
merged 1 commit into from
Feb 17, 2022

Conversation

RobbeSneyders
Copy link
Member

@RobbeSneyders RobbeSneyders commented Feb 16, 2022

Fixes #1462.

CC: @nielsbox

@RobbeSneyders RobbeSneyders requested a review from Ruwann February 16, 2022 15:41
@RobbeSneyders RobbeSneyders force-pushed the bugfix/nullable-defaults branch from c3c8e8c to 842bb4d Compare February 16, 2022 16:00
@coveralls
Copy link

Pull Request Test Coverage Report for Build 1853825683

  • 9 of 9 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.002%) to 97.063%

Totals Coverage Status
Change from base Build 1819970533: 0.002%
Covered Lines: 2842
Relevant Lines: 2928

💛 - Coveralls

Copy link
Member

@Ruwann Ruwann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM!

@Ruwann Ruwann merged commit 089176f into main Feb 17, 2022
@Ruwann Ruwann deleted the bugfix/nullable-defaults branch February 17, 2022 18:51
Copy link
Member

@Ruwann Ruwann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, overlooked something!

'type': allow_nullable(Draft4Validator.VALIDATORS['type']),
'enum': allow_nullable(Draft4Validator.VALIDATORS['enum']),
'type': NullableTypeValidator,
'enum': NullableTypeValidator,
Copy link
Member

@Ruwann Ruwann Feb 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should actually be NullableEnumValidator:

Suggested change
'enum': NullableTypeValidator,
'enum': NullableEnumValidator,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

@Ruwann Ruwann restored the bugfix/nullable-defaults branch February 17, 2022 18:56
@@ -67,3 +67,16 @@ paths:
description: User object
schema:
$ref: '#/definitions/User'

/nullable_default:
Copy link
Member

@Ruwann Ruwann Feb 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this endpoint actually tested? The added test doesn't seem to call it? Or is it purely the loading of the spec itself that caused issues?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the loading of the spec, since the validation of the spec itself failed.

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

Successfully merging this pull request may close these issues.

x-nullable is not taken into account when validating defaults in during validation of the OpenAPI specification.
3 participants