Skip to content

Allow undefined required properties #312

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 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion openapi_spec_validator/validation/keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def __call__(
set(required) - set(properties) - set(nested_properties)
)
else:
extra_properties = list(set(required) - set(properties))
extra_properties = []

if extra_properties and require_properties:
yield ExtraParametersError(
Expand Down
7 changes: 2 additions & 5 deletions tests/integration/validation/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def test_allow_allof_when_required_is_linked_to_the_parent_object(self):
errors_list = list(errors)
assert errors_list == []

def test_extra_parameters_in_required(self):
def test_allow_extra_parameters_in_required(self):
spec = {
"openapi": "3.0.0",
"info": {
Expand All @@ -225,10 +225,7 @@ def test_extra_parameters_in_required(self):
errors = OpenAPIV30SpecValidator(spec).iter_errors()

errors_list = list(errors)
assert errors_list[0].__class__ == ExtraParametersError
assert errors_list[0].message == (
"Required list has not defined properties: ['testparam1']"
)
assert len(errors_list) == 0

def test_undocumented_parameter(self):
spec = {
Expand Down