Skip to content

Commit

Permalink
set int to "integer" instead of "number"
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonToomey committed Jun 20, 2021
1 parent 60f172c commit f7ea843
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion marshmallow_jsonschema/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
set: {"type": "array"},
tuple: {"type": "array"},
float: {"type": "number", "format": "float"},
int: {"type": "number", "format": "integer"},
int: {"type": "integer"},
bool: {"type": "boolean"},
Enum: {"type": "string"},
}
Expand Down
9 changes: 4 additions & 5 deletions tests/test_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class TestSchema(Schema):
nested_def = dumped["definitions"]["TestNamedNestedSchema"]
nested_dmp = dumped["definitions"]["TestSchema"]["properties"]["nested"]
assert nested_dmp["type"] == "object"
assert nested_def["properties"]["foo"]["format"] == "integer"
assert nested_def["properties"]["foo"]["type"] == "integer"


def test_list():
Expand Down Expand Up @@ -198,7 +198,7 @@ class DictSchema(Schema):
assert "additionalProperties" in nested_json

item_schema = nested_json["additionalProperties"]
assert item_schema["type"] == "number"
assert item_schema["type"] == "integer"


def test_dict_with_nested_value_field():
Expand Down Expand Up @@ -531,9 +531,8 @@ class TestSchema(Schema):
assert dumped["definitions"]["TestSchema"]["properties"]["foo"] == {
"enum": [v for v in mapping.values()],
"enumNames": [k for k in mapping.keys()],
"format": "integer",
"title": "foo",
"type": "number",
"type": "integer",
}


Expand Down Expand Up @@ -695,7 +694,7 @@ class TestSchema(Schema):
"type": "object",
"properties": {
"field_1": {"type": "string", "title": "field_1"},
"field_2": {"type": "number", "title": "field_2", "format": "integer"},
"field_2": {"type": "integer", "title": "field_2"},
},
"additionalProperties": False,
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,4 @@ class TestSchema(Schema):

foo_property = dumped["definitions"]["TestSchema"]["properties"]["foo"]
assert {"title": "", "type": "string"} in foo_property["anyOf"]
assert {"title": "", "type": "number", "format": "integer"} in foo_property["anyOf"]
assert {"title": "", "type": "integer"} in foo_property["anyOf"]

0 comments on commit f7ea843

Please sign in to comment.