Skip to content

Commit c3aea90

Browse files
Merge pull request #331 from coveord/fix/type-null
fix: [JSON Schema] Type "null" should be string
2 parents 8f132c4 + acbb13f commit c3aea90

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

schema/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ def _to_schema(s: Any, ignore_extra_keys: bool) -> Schema:
701701
if len(or_values) == 1:
702702
or_value = or_values[0]
703703
if or_value is None:
704-
return_schema["type"] = None
704+
return_schema["type"] = "null"
705705
else:
706706
return_schema["const"] = _to_json_type(or_value)
707707
return return_schema
@@ -736,7 +736,7 @@ def _to_schema(s: Any, ignore_extra_keys: bool) -> Schema:
736736
return_schema["allOf"] = all_of_values
737737
elif flavor == COMPARABLE:
738738
if s is None:
739-
return_schema["type"] = None
739+
return_schema["type"] = "null"
740740
else:
741741
return_schema["const"] = _to_json_type(s)
742742
elif flavor == VALIDATOR and type(s) == Regex:

test_schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ def test_json_schema_const_is_none():
11461146
assert s.json_schema("my-id") == {
11471147
"$schema": "http://json-schema.org/draft-07/schema#",
11481148
"$id": "my-id",
1149-
"properties": {"test": {"type": None}},
1149+
"properties": {"test": {"type": "null"}},
11501150
"required": ["test"],
11511151
"additionalProperties": False,
11521152
"type": "object",
@@ -1413,7 +1413,7 @@ def test_json_schema_dict_type():
14131413
}
14141414

14151415

1416-
def test_regex_json_schema():
1416+
def test_json_schema_title_and_description():
14171417
s = Schema(
14181418
{
14191419
Literal(

0 commit comments

Comments
 (0)