Skip to content

Commit

Permalink
Fix py27 issue, small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ngaya-ll committed Jun 8, 2020
1 parent 1c6e176 commit f88e150
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion swagger_spec_validator/validator20.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def validate_definition(definition, deref, def_name=None, visited_definitions_id

if not isinstance(definition, dict):
raise SwaggerValidationError('Definition of {} must be a dict; got {}'.format(
def_name or '(no name)', type(definition)))
def_name or '(no name)', definition.__class__.__name__))

swagger_type = definition.get('type')
if isinstance(swagger_type, list):
Expand Down
9 changes: 4 additions & 5 deletions tests/validator20/validate_definitions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,8 @@ def test_type_array_without_items_succeed_fails():


def test_type_object_additional_properties_dict_succeeds():
# See https://github.com/OAI/OpenAPI-Specification/issues/668
definitions = {
'example': {
'Example': {
'type': 'object',
'additionalProperties': {
'type': 'string',
Expand All @@ -151,7 +150,7 @@ def test_type_object_additional_properties_dict_succeeds():
def test_type_object_additional_properties_boolean_fails():
# See https://github.com/OAI/OpenAPI-Specification/issues/668
definitions = {
'example': {
'Example': {
'type': 'object',
'additionalProperties': False,
},
Expand All @@ -160,8 +159,8 @@ def test_type_object_additional_properties_boolean_fails():
with pytest.raises(SwaggerValidationError) as exc_info:
validate_definitions(definitions, lambda x: x)

assert str(exc_info.value) == "Definition of #/definitions/example/additionalProperties " \
"must be a dict; got <class 'bool'>"
assert str(exc_info.value) == "Definition of #/definitions/Example/additionalProperties " \
"must be a dict; got bool"


def test_inline_model_is_not_valid_validation_fails():
Expand Down

0 comments on commit f88e150

Please sign in to comment.