Open jgallagher opened 4 months ago
In the following JSON schema, all three ByteCountN variants have the same type and format, and only differ by maximum:
ByteCountN
type
format
maximum
ByteCount1
ByteCount2
i64::MAX
ByteCount3
i64::MAX + 1
{ "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { "ByteCount1": { "description": "Byte count to express memory or storage capacity.", "type": "integer", "format": "uint64", "minimum": 0 }, "ByteCount2": { "description": "Byte count to express memory or storage capacity.", "type": "integer", "format": "uint64", "minimum": 0, "maximum": 9223372036854775807 }, "ByteCount3": { "description": "Byte count to express memory or storage capacity.", "type": "integer", "format": "uint64", "minimum": 0, "maximum": 9223372036854775808 } } }
I expected all of these to produce a struct wrapping a u64, but ByteCount{2,3} use i64 instead:
u64
ByteCount{2,3}
i64
% cargo typify bytecount.json && rg 'struct ByteCount' bytecount.rs 48:pub struct ByteCount1(pub u64); 114:pub struct ByteCount2(pub i64); 180:pub struct ByteCount3(pub i64);
Oof.. ByteCount3 seems particularly stupid.
In the following JSON schema, all three
ByteCountN
variants have the sametype
andformat
, and only differ bymaximum
:ByteCount1
omitsmaximum
ByteCount2
sets itsmaximum
toi64::MAX
ByteCount3
sets itsmaximum
toi64::MAX + 1
I expected all of these to produce a struct wrapping a
u64
, butByteCount{2,3}
usei64
instead: