Commit d6b9003
fix(java): generate standalone files for orphaned inline types in endpoint responses (#16242)
* fix(java): generate standalone files for inline types only referenced from endpoint responses
When enable-inline-types is enabled, inline types that are only referenced
from endpoint response types (not from other type declarations) were skipped
during file generation. The generator assumed all inline types would be nested
inside parent types, but map value types in endpoint responses have no parent
type to nest into.
Added BFS reachability analysis from non-inline types to determine which inline
types will actually be nested. Only those are skipped; orphaned inline types are
now generated as standalone files.
Added test case to java-inline-types fixture with a map response endpoint.
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* chore: apply spotless formatting
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* chore: update ir-to-jsonschema snapshot for MapResponseValue
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* fix: prevent duplicate standalone files for inline types nested inside orphaned inline types
Addresses Devin Review finding: when an orphaned inline type (only referenced
from endpoints) itself references other inline types, those child types should
be nested inside the orphan, not generated as redundant standalone files.
Added second pass in computeNestedInlineTypeIds() to mark inline types
referenced from orphaned inline types as nested. Also added test case with
MapResponseValueNested inside MapResponseValue to validate.
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* chore: regenerate IR test definitions for java-inline-types
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* fix(java): remove unsafe second-pass suppression of orphan-referenced inline types
The second pass unconditionally marked all inline types referenced by orphans
as nested, which fails for:
1. Self-referencing orphans (e.g. Tree { children: list<Tree> }) — the type
appears in its own getReferencedTypes() (transitive closure) and gets
suppressed with no parent to nest into.
2. Inline types shared between an orphan parent and an endpoint — the type
gets suppressed but the endpoint client still emits a top-level import.
Fix: remove the second pass entirely. Orphan inline types that reference
other inline types will produce both a standalone file and a nested class
for the child — this duplication is harmless and always correct.
Also adds test fixtures for shared-inline-type (endpoint + orphan parent)
edge case.
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* test: add JSON schema snapshots for SharedChildType and OrphanParentWithSharedChild
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* test: regenerate IR and dynamic-snippets test definitions for java-inline-types
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
---------
Co-authored-by: cade <info@buildwithfern.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>1 parent 6e3c48c commit d6b9003
56 files changed
Lines changed: 14191 additions & 1315 deletions
File tree
- generators/java
- generator-utils/src/main/java/com/fern/java/generators
- sdk/changes/unreleased
- packages/cli
- fern-definition/ir-to-jsonschema/src/__test__/__snapshots__/java-inline-types
- generation/ir-generator-tests/src
- dynamic-snippets/__test__/test-definitions
- ir/__test__/test-definitions
- seed/java-sdk/java-inline-types
- enable-forward-compatible-enums
- .fern
- src/main/java/com
- seed/object
- types
- snippets
- inline
- .fern
- src/main/java/com
- seed/object
- types
- snippets
- no-inline
- .fern
- src/main/java/com
- seed/object
- types
- snippets
- no-wrapped-aliases
- .fern
- src/main/java/com
- seed/object
- types
- snippets
- test-definitions/fern/apis/java-inline-types
- definition
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 50 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| |||
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
47 | 54 | | |
48 | 55 | | |
49 | 56 | | |
50 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
51 | 60 | | |
52 | 61 | | |
53 | 62 | | |
| |||
71 | 80 | | |
72 | 81 | | |
73 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
74 | 123 | | |
75 | 124 | | |
76 | 125 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 44 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
Lines changed: 40 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
0 commit comments