Skip to content

Commit 2c8d4e2

Browse files
authored
Fix endpoint handling (#4164)
1 parent 67adf07 commit 2c8d4e2

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

packages/http-client-csharp/emitter/src/lib/client-model-builder.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { InputOperationParameterKind } from "../type/input-operation-parameter-k
1919
import { InputParameter } from "../type/input-parameter.js";
2020
import { InputEnumType, InputModelType, InputType } from "../type/input-type.js";
2121
import { RequestLocation } from "../type/request-location.js";
22+
import { fromSdkType } from "./converter.js";
2223
import { Logger } from "./logger.js";
2324
import { navigateModels } from "./model.js";
2425
import { fromSdkServiceMethod, getParameterDefaultValue } from "./operation-converter.js";
@@ -153,11 +154,7 @@ export function createModel(sdkContext: SdkContext<NetEmitterOptions>): CodeMode
153154
Name: "url",
154155
CrossLanguageDefinitionId: "TypeSpec.url",
155156
}
156-
: {
157-
Kind: "string",
158-
Name: "string",
159-
CrossLanguageDefinitionId: "TypeSpec.string",
160-
};
157+
: fromSdkType(parameter.type, sdkContext, modelMap, enumMap); // TODO: consolidate with converter.fromSdkEndpointType
161158
parameters.push({
162159
Name: parameter.name,
163160
NameInRequest: parameter.serializedName,

packages/http-client-csharp/emitter/src/lib/converter.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export function fromSdkType(
5353
} as InputNullableType;
5454
}
5555
if (sdkType.kind === "model") return fromSdkModelType(sdkType, context, models, enums);
56+
if (sdkType.kind === "endpoint") return fromSdkEndpointType();
5657
if (sdkType.kind === "enum") return fromSdkEnumType(sdkType, context, enums);
5758
if (sdkType.kind === "enumvalue")
5859
return fromSdkEnumValueTypeToConstantType(sdkType, context, enums, literalTypeContext);
@@ -68,7 +69,6 @@ export function fromSdkType(
6869
// TODO -- endpoint and credential are handled separately in emitter, since we have specific locations for them in input model.
6970
// We can handle unify the way we handle them in the future, probably by chaning the input model schema and do the conversion in generator.
7071
if (sdkType.kind === "credential") throw new Error("Credential type is not supported yet.");
71-
if (sdkType.kind === "endpoint") throw new Error("Endpoint type is not supported yet.");
7272

7373
return fromSdkBuiltInType(sdkType);
7474
}
@@ -381,3 +381,11 @@ function fromSdkArrayType(
381381
CrossLanguageDefinitionId: arrayType.crossLanguageDefinitionId,
382382
};
383383
}
384+
385+
function fromSdkEndpointType(): InputPrimitiveType {
386+
return {
387+
Kind: "string",
388+
Name: "string",
389+
CrossLanguageDefinitionId: "TypeSpec.string",
390+
};
391+
}

0 commit comments

Comments
 (0)