OXY-149: separate Integer JsonType (json + schema) - #294
Merged
Conversation
Kalin-Rudnicki
commented
Aug 15, 2026
Split Json.Type.Number into distinct Integer vs Number discriminants so
oxygen-json and oxygen-schema can tell 123 (integer) from 1.5 (number) at
the type level, matching JSON Schema 2020-12 / OpenAPI.
- Json.scala: add Json.Type.Integer; Json.tpe classifies Json.Number via
BigDecimal.isWhole. No new AST node -- existing case _: Json.Number /
Json.Number(v) matches keep working (fully backwards compatible).
- JsonSchemaEmitter.astSchema: emit {"type":"integer"} for Type.Integer.
- Compared.diffJsonAST: integer->number widening (FromIsMoreSpecific),
number->integer breaking (ToIsMoreSpecific); typed-number vs AST-integer
made consistent.
- Parser / decoders / encoders: unchanged.
Classification is by numeric value: 1.0, 1e+3, 0.000 -> Integer; 1.5,
1e-3 -> Number. Schema uses bare integer (no int32).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Kalin-Rudnicki
force-pushed
the
OXY-149
branch
from
August 15, 2026 01:03
5afce6a to
c6a2e82
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Splits the monolithic
Json.Type.Numberinto distinctIntegervsNumberdiscriminants sooxygen-jsonandoxygen-schemacan tell123(integer) from1.5(number) at the type level, matching JSON Schema 2020-12 / OpenAPI.Changes
Json.scala: addJson.Type.Integer;Json.tpeclassifiesJson.NumberviaBigDecimal.isWhole. No new AST node — kept the singleJson.Number(BigDecimal), so all existingcase _: Json.Number/Json.Number(v)pattern matches keep working (fully backwards compatible).JsonSchemaEmitter.astSchema: emit{"type":"integer"}forJson.Type.Integer.Compared.diffJsonAST: integer→number = widening (FromIsMoreSpecific), number→integer = breaking (ToIsMoreSpecific); typed-number vs AST-integer made consistent.Json.Number;JsonDecoder[Int]already rejects fractional via round-trip narrowing).Key decisions
Classification is by numeric value (
isWhole):1.0,1e+3,0.000→Integer;1.5,1e-3→Number. Schema uses bareinteger(noint32). Full rationale + all resolved open questions inreport/OXY-149.md.Tests
utJVM/testOnly oxygen.json.* oxygen.schema.*→ 107 passed, 0 failed, including new:parse("123").tpe == Integer,parse("1.5").tpe == Number,JsonDecoder[Int]rejects1.5,JsonSchema[Int]emitsinteger,JsonSchema[Double]emitsnumber.Confidence: 8.5/10
json + schema compile clean and their full test suites pass; changes are additive/non-breaking. Residual risk: full monorepo not built (additive change, low risk); Compared widening/breaking semantics verified by reading (CompatSpec is a print-only placeholder, not an assertive test).
🤖 Generated with Claude Code