[typespec-metadata] Apply correct Java namespace prefix based on service type and flavor#4087
Draft
[typespec-metadata] Apply correct Java namespace prefix based on service type and flavor#4087
Conversation
…n typespec-metadata Co-authored-by: tjprescott <5723682+tjprescott@users.noreply.github.com> Agent-Logs-Url: https://github.com/Azure/typespec-azure/sessions/3831e54a-3bd9-495b-8dc7-3a43877e8ce6
Copilot
AI
changed the title
[WIP] Add prefix to Java package name for flavor support
[typespec-metadata] Apply correct Java namespace prefix based on service type and flavor
Mar 23, 2026
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.
The
typespec-metadataemitter's Java parser was returning namespaces as-is, ignoring both the TypeSpec service type (data vs. management) and theflavoremitter option. This caused incorrect Java package namespaces in the output metadata.Prefix rules
flavorcom.azure.com.azure.resourcemanager.azurev2com.azure.v2.azurev2com.azure.resourcemanager.v2.Changes
collector.tsapplyJavaNamespacePrefix— strips any existing known Azure prefix and applies the correct one based on service type and flavorparseJavato accepttypespecTypeand readflavorfrom emitter optionsLanguageParsertype,createLanguageMetadata,buildLanguageMetadata, andcollectLanguagePackagesto threadtypespecTypethrough the call chainemitter.tstypespecMetadata.typetocollectLanguagePackagesExample
Previously the metadata would emit
com.azure.resourcemanager.contoso. With this change it correctly emitscom.azure.resourcemanager.v2.contoso.Original prompt
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.