fix(java): generate named Java type for unknown type aliases#13445
Merged
fix(java): generate named Java type for unknown type aliases#13445
Conversation
Co-Authored-By: judah <jsklan.development@gmail.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
🌱 Seed Test SelectorSelect languages to run seed tests for:
How to use: Click the ⋯ menu above → "Edit" → check the boxes you want → click "Update comment". Tests will run automatically and snapshots will be committed to this PR. |
…-unknown-type-alias
…-unknown-type-alias
fern-support
approved these changes
Mar 17, 2026
|
Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit in Settings → Usage. Once credits are available, reopen this pull request to trigger a review. |
Co-Authored-By: judah <jsklan.development@gmail.com>
Co-Authored-By: judah <jsklan.development@gmail.com>
Co-Authored-By: judah <jsklan.development@gmail.com>
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.
Description
Linear ticket: Closes FER-8937
When an OpenAPI schema has no
typeand noproperties(representing an "any" type), the Java SDK generator was dropping the named type definition entirely and inliningObjectwherever it was referenced. This PR fixes the generator to emit a named wrapper class for unknown type aliases, consistent with how other alias types are handled.Link to Devin Session
Requested by: @jsklan
Changes Made
Java generator (3 files)
SingleTypeGenerator.java—visitAlias()now also generates a wrapper class when the alias's underlying type is unknown (value.getAliasOf().isUnknown()), not only whenwrappedAliasesconfig is enabled or the alias comes from an error declaration.PoetTypeNameMapper.java—visitNamed()no longer resolves unknown aliases to their underlyingObjecttype. Previously all aliases were transparently resolved whenwrappedAliaseswas false, causing the named type reference to be lost.Cli.java(SDK) — TheWrappedAliasinterface is now also generated when any type declaration is an alias with an unknownaliasOf, since the generated wrapper class implements this interface.Dynamic snippet generator (1 file)
DynamicTypeLiteralMapper.ts—convertNamed()now wraps the converted value inType.of()when the alias's inner type reference isunknown, producing e.g.DocumentedUnknownType.of(new HashMap<>() {{ ... }})instead of passing the rawHashMapdirectly.generators/java/sdk/versions.ymlwith changelog entryTesting
java-sdk/exhaustivefixture — all 14 configs passDocumentedUnknownType.javagenerated correctly across all configsObjectWithDocumentedUnknownType.javareferencesDocumentedUnknownType(notObject)snippet.jsonwraps unknown alias values withDocumentedUnknownType.of(...)java-modelandjava-springseed testsKey review points
WrappedAlias.javais now generated for any API that has unknown type aliases, even withoutwrappedAliases: trueconfig. This is a net-new file in SDK output for affected APIs. Verify this is acceptable.Cli.javachange only covers the SDK generator. Verify whetherjava-modelandjava-springgenerators (which shareSingleTypeGeneratorandPoetTypeNameMapperviagenerator-utils) need a similarWrappedAliasinterface generation change in their own Cli classes.DocumentedUnknownType.equals()does not null-guardthis.value— consistent with existingAliasGeneratoroutput but worth noting.