Closed 6293 closed 1 year ago
This is intentional and probably should be documented better.
We explode number
type into [number, integer]
. This is done so that when the type is changed from integer
to number
, no breaking change is recorded, because integer
is a subtype of number
.
We explode number type into [number, integer]. This is done so that when the type is changed from integer to number, no breaking change is recorded, because integer is a subtype of number.
We can detect integer
-> number
transition without exploding exploding trick, by postprocessing the result from diff
.
e.g. if diff
is going to return
vec![
Change {
path: "some_path".to_string(),
change: ChangeKind::TypeAdd {
added: JsonSchemaType::Number,
},
},
Change {
path: "some_path".to_string(),
change: ChangeKind::TypeRemove {
removed: JsonSchemaType::Integer,
},
},
]
we can find pair of changes that is (removal_of_integer, addition_of_number) which shares the same path
. This pair are then squashed into some kind of
vec![
Change {
path: "some_path".to_string(),
change: ChangeKind::TypeLoose {
kind: Loosen::IntegerToNumber,
},
},
]
But I am not obsessed with this idea because the current behavior is not harmful at all
i'm inclined to not add more processing stages for now. i also want to keep the ChangeKind enum as small as possible because this output is post-processed by a script and it needs to implement support for every variant
https://github.com/getsentry/json-schema-diff/blob/1c6b1cbb91356b9bca3b7a8c65c2644364a16d7a/src/lib.rs#L91
I noticed that in this test
diff
reports false-positiveinteger
addition