Skip to content

[typespec-metadata] Apply correct Java namespace prefix based on service type and flavor#4087

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/update-typspec-metadata-emitter
Draft

[typespec-metadata] Apply correct Java namespace prefix based on service type and flavor#4087
Copilot wants to merge 2 commits intomainfrom
copilot/update-typspec-metadata-emitter

Conversation

Copy link
Contributor

Copilot AI commented Mar 23, 2026

The typespec-metadata emitter's Java parser was returning namespaces as-is, ignoring both the TypeSpec service type (data vs. management) and the flavor emitter option. This caused incorrect Java package namespaces in the output metadata.

Prefix rules

Service type flavor Java namespace prefix
data (none) com.azure.
management (none) com.azure.resourcemanager.
data azurev2 com.azure.v2.
management azurev2 com.azure.resourcemanager.v2.

Changes

  • collector.ts

    • Added applyJavaNamespacePrefix — strips any existing known Azure prefix and applies the correct one based on service type and flavor
    • Updated parseJava to accept typespecType and read flavor from emitter options
    • Updated LanguageParser type, createLanguageMetadata, buildLanguageMetadata, and collectLanguagePackages to thread typespecType through the call chain
  • emitter.ts

    • Passes typespecMetadata.type to collectLanguagePackages

Example

# tsp-config.yaml for a next-gen ARM library
options:
  "@azure-tools/typespec-java":
    namespace: "com.azure.resourcemanager.contoso"
    flavor: azurev2

Previously the metadata would emit com.azure.resourcemanager.contoso. With this change it correctly emits com.azure.resourcemanager.v2.contoso.

Original prompt

This section details on the original issue you should resolve

<issue_title>[TypeSpec-Metadata] Java package name needs to account for "flavor"</issue_title>
<issue_description>Image</issue_description>

<agent_instructions>Update the typspec-metadata emitter to properly add the relevant prefix to java namespaces.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 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.

…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
Copilot AI requested a review from tjprescott March 23, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TypeSpec-Metadata] Java package name needs to account for "flavor"

2 participants