Skip to content

Namespace revisit#4033

Open
tadelesh wants to merge 3 commits intomainfrom
namespace_revisit
Open

Namespace revisit#4033
tadelesh wants to merge 3 commits intomainfrom
namespace_revisit

Conversation

@tadelesh
Copy link
Member

When Go and Rust deal with the namespace in the emitter, they are asking how to determine a root namespace that could let language know where a package should start from. Current TCGC's namespace concept is just to represent TypeSpec namespace or user specific namespace. We do not have root namespace concept. So, we want to know if all languages have such requirement and does TCGC need a rootNamespace config for emitter, and provide getRootNamespaces with calculating longest common prefix for all root clients' namespaces?

@microsoft-github-policy-service microsoft-github-policy-service bot added the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label Mar 11, 2026
@azure-sdk
Copy link
Collaborator

No changes needing a change description found.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 11, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@azure-tools/typespec-client-generator-core@4033

commit: 831c44a

@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website

Copy link
Contributor

@iscai-msft iscai-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love the doc

@weidongxu-microsoft
Copy link
Member

weidongxu-microsoft commented Mar 19, 2026

When no namespace in tspconfig, Java would generate client and model to their namespace specified by TCGC (we may do some hack for models from TypeSpec or Azure namespace -- here is the only place a rootNamespace may matter -- we need to put them somewhere, if not to typespec.rest package). This part would be fine without a rootNamespace.

The remaining problem I see, is the artifactId in the generated pom.xml.


E.g. for source

@service(#{ title: "Pet Store" })
namespace PetStore {
  model Dog { ... }
}

@service(#{ title: "Toy Store" })
namespace ToyStore {
  model Car { ... }
}

The 2 client would be generated under petstore and toystore package. No surprise.
But we are not able to decide whether the artifactId (you can think it as package name) should be petstore or toystore.

In addition, if the project uses TypeSpec.Rest.ResourceCreateModel<>, we either generate it under typespec.rest package, or use the guessed root namespace.


Hence for Java, there is not as much a problem of rootNamespace, but packageName. E.g. if we had a package-name tspconfig, the problem thus be solved without knowing a rootNamespace.

CC @srnagar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants