Skip to content

Commit

Permalink
http-client-java, map typespec.rest.resource model to sdk base namesp…
Browse files Browse the repository at this point in the history
  • Loading branch information
weidongxu-microsoft authored Dec 12, 2024
1 parent b2c14cc commit 093e986
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
46 changes: 27 additions & 19 deletions packages/http-client-java/emitter/src/code-model-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2537,25 +2537,33 @@ export class CodeModelBuilder {
// clientNamespace from TCGC
const clientNamespace: string | undefined = type?.clientNamespace;

if (this.isBranded() && type) {
// special handling for namespace of model that cannot be mapped to azure-core
if (type.crossLanguageDefinitionId === "TypeSpec.Http.File") {
// TypeSpec.Http.File
return this.baseJavaNamespace;
} else if (type.crossLanguageDefinitionId === "Azure.Core.Foundations.OperationState") {
// Azure.Core.OperationState
return this.baseJavaNamespace;
} else if (
type.crossLanguageDefinitionId === "Azure.Core.ResourceOperationStatus" ||
type.crossLanguageDefinitionId === "Azure.Core.Foundations.OperationStatus"
) {
// Azure.Core.ResourceOperationStatus<>
// Azure.Core.Foundations.OperationStatus<>
// usually this model will not be generated, but javadoc of protocol method requires it be in SDK namespace
return this.baseJavaNamespace;
} else if (type.crossLanguageDefinitionId.startsWith("Azure.ResourceManager.")) {
// models in Azure.ResourceManager
return this.baseJavaNamespace;
if (type) {
if (this.isBranded()) {
// special handling for namespace of model that cannot be mapped to azure-core
if (type.crossLanguageDefinitionId === "TypeSpec.Http.File") {
// TypeSpec.Http.File
return this.baseJavaNamespace;
} else if (type.crossLanguageDefinitionId === "Azure.Core.Foundations.OperationState") {
// Azure.Core.OperationState
return this.baseJavaNamespace;
} else if (
type.crossLanguageDefinitionId === "Azure.Core.ResourceOperationStatus" ||
type.crossLanguageDefinitionId === "Azure.Core.Foundations.OperationStatus"
) {
// Azure.Core.ResourceOperationStatus<>
// Azure.Core.Foundations.OperationStatus<>
// usually this model will not be generated, but javadoc of protocol method requires it be in SDK namespace
return this.baseJavaNamespace;
} else if (type.crossLanguageDefinitionId.startsWith("Azure.ResourceManager.")) {
// models in Azure.ResourceManager
return this.baseJavaNamespace;
}
} else {
// special handling for namespace of model in TypeSpec.Rest.Resource
if (type.crossLanguageDefinitionId.startsWith("TypeSpec.Rest.Resource.")) {
// models in TypeSpec.Rest.Resource
return this.baseJavaNamespace;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public class ExternalPackage {

public static final String CLIENTCORE_PACKAGE_NAME = "io.clientcore.core";
public static final String CLIENTCORE_JSON_PACKAGE_NAME = "io.clientcore.core.json";
public static final String CLIENTCORE_JSON_PACKAGE_NAME = "io.clientcore.core.serialization.json";

public static final String AZURE_CORE_PACKAGE_NAME = "com.azure.core";
public static final String AZURE_JSON_PACKAGE_NAME = "com.azure.json";
Expand Down

0 comments on commit 093e986

Please sign in to comment.