Skip to content

Commit c46b4ea

Browse files
authored
Fix json creation bugs (#1643)
* fix logic for warning * remove tests that check for type rule conflicts * ran black * delete accidentally commited file
1 parent 1ba98e8 commit c46b4ea

File tree

2 files changed

+2
-31
lines changed

2 files changed

+2
-31
lines changed

schematic/schemas/create_json_schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,8 @@ def _get_validation_rule_based_fields(
293293
f"that conflicts with the implicit type: '{implicit_js_type}' "
294294
f"derived from its validation rules: {validation_rules}"
295295
)
296-
raise ValueError(msg)
297-
if implicit_js_type:
296+
warnings.warn(msg)
297+
if not explicit_js_type and implicit_js_type:
298298
js_type = implicit_js_type
299299
msg = (
300300
f"No explicit type set for property: '{name}', "

tests/unit/test_create_json_schema.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -366,35 +366,6 @@ def test_get_validation_rule_based_fields_with_explicit_type(
366366
assert pattern == expected_pattern
367367

368368

369-
@pytest.mark.parametrize(
370-
"validation_rules, explicit_type",
371-
[
372-
(["str"], JSONSchemaType.INTEGER),
373-
(["inRange 50 100"], JSONSchemaType.STRING),
374-
(["regex search [a-f]"], JSONSchemaType.INTEGER),
375-
(["date"], JSONSchemaType.INTEGER),
376-
(["url"], JSONSchemaType.INTEGER),
377-
],
378-
ids=[
379-
"String rule, integer type",
380-
"InRange rule, string type",
381-
"Regex rule, integer type",
382-
"Date rule, integer type",
383-
"Url rule, integer type",
384-
],
385-
)
386-
def test_get_validation_rule_based_fields_with_exception(
387-
validation_rules: list[str],
388-
explicit_type: JSONSchemaType,
389-
) -> None:
390-
"""
391-
Test for _get_validation_rule_based_fields
392-
Tests that output is expected based on the input validation rules, and explicit type
393-
"""
394-
with pytest.raises(ValueError):
395-
_get_validation_rule_based_fields(validation_rules, explicit_type, "name")
396-
397-
398369
class TestGraphTraversalState:
399370
"""Tests for GraphTraversalState class"""
400371

0 commit comments

Comments
 (0)