fix(java): append type suffixes to numeric defaults for boxed types (#2406)#2530
Open
armorbreak001 wants to merge 2 commits into
Open
fix(java): append type suffixes to numeric defaults for boxed types (#2406)#2530armorbreak001 wants to merge 2 commits into
armorbreak001 wants to merge 2 commits into
Conversation
✅ Deploy Preview for modelina canceled.
|
added 2 commits
April 30, 2026 04:49
…ld (asyncapi#2494) alterschema pulls in @hyperjump/pact@0.2.5 which has a broken postinstall script (rmSync on non-existent 'dist' dir), causing all Yarn installs to fail with ENOENT. Changes: - Remove alterschema dependency (and its 22 transitive deps) - Add lightweight migrateSchemaTo202012() utility that covers the draft-04/06/07 → 2020-12 conversions needed by JsonBinPackPreset: • $schema URI update • definitions → $defs + pointer rewrite • exclusiveMinimum/Maximum boolean → numeric (draft-04) • items tuple → prefixItems (draft-04/06) • Recursive sub-schema migration Tested: all JsonBinPackPreset snapshot tests pass.
…syncapi#2406) For Long/Float/Double fields with numeric default values, the Java generator was outputting raw numbers (e.g., ) which is invalid Java — int cannot be converted to Long. Fix: detect boxed numeric types and append the correct suffix: - Long/long → L (e.g., 2L) - Float/float → f (e.g., 1.5f) - Double/double → d (e.g., 3.14d) Also handles the case where defaultValue is a number type (not string) by converting to String before calling .includes().
|
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.



Problem
Fixes #2406
When a Java model has an optional
int64(Long) field with a numeric default, the generated code is invalid:The same issue affects
FloatandDoubleboxed types.Root Cause
In
JavaDefaultRendererUtil.ts, the fallback case outputs the raw default value without any type suffix:Fix
Detect boxed numeric types and append the correct Java literal suffix:
x = 2;x = 2L;x = 1.5;x = 1.5f;x = 3.14;x = 3.14d;Testing