diff --git a/packages/http-client-java/emitter/src/code-model-builder.ts b/packages/http-client-java/emitter/src/code-model-builder.ts index f94904a16c..b561aaa263 100644 --- a/packages/http-client-java/emitter/src/code-model-builder.ts +++ b/packages/http-client-java/emitter/src/code-model-builder.ts @@ -281,7 +281,7 @@ export class CodeModelBuilder { } else { const schema = this.processSchema(arg.type, arg.name); this.trackSchemaUsage(schema, { - usage: [SchemaContext.Input, SchemaContext.Output /*SchemaContext.Public*/], + usage: [SchemaContext.Input, SchemaContext.Output, SchemaContext.Public], }); parameter = new Parameter(arg.name, arg.doc ?? "", schema, { implementation: ImplementationLocation.Client, diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/util/SchemaUtil.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/util/SchemaUtil.java index 0056348fb8..f862385bdf 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/util/SchemaUtil.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/util/SchemaUtil.java @@ -25,6 +25,8 @@ import com.microsoft.typespec.http.client.generator.core.model.clientmodel.IterableType; import com.microsoft.typespec.http.client.generator.core.model.clientmodel.ListType; import com.microsoft.typespec.http.client.generator.core.model.clientmodel.PrimitiveType; +import org.apache.tools.ant.taskdefs.Java; + import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; @@ -223,7 +225,12 @@ public static IType removeModelFromParameter(RequestParameterLocation parameterR returnType = ClassType.BINARY_DATA; } else if (!(returnType instanceof PrimitiveType)) { if (type instanceof EnumType) { - returnType = ClassType.STRING; + boolean isPathOrURIParameter = RequestParameterLocation.PATH == parameterRequestLocation + || RequestParameterLocation.URI == parameterRequestLocation; + boolean isEnumAsString = !(JavaSettings.getInstance().isDataPlaneClient() && isPathOrURIParameter); + if (isEnumAsString) { // do not change enum to string type for data-plane path/url parameter + returnType = ClassType.STRING; + } } if (type instanceof IterableType && ((IterableType) type).getElementType() instanceof EnumType) { returnType = new IterableType(ClassType.STRING);