fix(scalars): correct jsonSchema definitions that misdescribe their values#3090
fix(scalars): correct jsonSchema definitions that misdescribe their values#3090ifeanyi-ugwu wants to merge 2 commits into
Conversation
Three scalars shipped a jsonSchema that rejects values the scalar itself accepts: - SESSN: the "patterns" were the format placeholders 'YYYYMMDDXXXX' / 'YYMMDDXXXX', used verbatim as regex patterns, so they matched only that literal text and no real personnummer. The `length` keyword beside them is not a JSON Schema keyword either. - PostalCode: oneOf over per-country patterns, but postal formats overlap — a 5-digit code matches US, DE, FR, IT, ES, ... at once — so every such code matches several patterns and fails oneOf's exactly-one requirement. - LocalDateTime: format 'date-time' requires an RFC 3339 timezone offset, which an offset-less LocalDateTime never has.
These jsonSchema definitions did not describe the value their scalar actually serializes: - Timestamp: declared type 'string', but serialize() returns a number of milliseconds (Date#getTime). 'unix-time' is also a non-standard, unenforceable format. - BigInt / Long: 'int64' implies a 64-bit bound a BigInt does not have, and type 'integer' alone omits the decimal-string form used for values beyond the safe-integer range. - USCurrency: the pattern forbade thousands separators and a leading minus, but serialize() emits locale-formatted strings like -$1,000.00, so the schema rejected the scalar's own output above $999 and for all negatives.
|
Those |
b23c016 to
5e7ce49
Compare
I dropped the Byte change.
|
Several scalars ship a
jsonSchemaextension that rejects values the scalar serializes or declares the wrong type. This corrects each to match the serialized output.Rejecting values the scalar accepts:
SESSN_PATTERNSheld the format placeholdersYYYYMMDDXXXX/YYMMDDXXXX, used verbatim as regex patterns, so they matched only that literal text and no real personnummer. Thelengthbeside them is not a JSON Schema keyword. Replaced with real patterns for the two accepted forms underanyOf.oneOfover the per-country patterns, but postal formats overlap (a 5-digit code matches US, DE, FR, IT, ES at once), so a valid code matches several patterns and failsoneOf's exactly-one requirement. Changed toanyOf.format:'date-time'mandates an RFC 3339 offset, which an offset-less LocalDateTime never has. Uses the scalar's own regex aspattern, like LocalDate and LocalTime.Mismatched serialized output:
type:'string', butserializereturns a number of milliseconds. Nowtype:'integer'.int64implies a 64-bit bound a BigInt does not have and omits the decimal-string form used beyond the safe-integer range. NowoneOf:[integer, numeric-string].toLocaleStringproduces, so it rejected the scalar's own output above$999and for negatives. Widened to match.