Skip to content

Commit

Permalink
Fix endpoint handling (#4164)
Browse files Browse the repository at this point in the history
  • Loading branch information
live1206 authored Aug 13, 2024
1 parent 67adf07 commit 2c8d4e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { InputOperationParameterKind } from "../type/input-operation-parameter-k
import { InputParameter } from "../type/input-parameter.js";
import { InputEnumType, InputModelType, InputType } from "../type/input-type.js";
import { RequestLocation } from "../type/request-location.js";
import { fromSdkType } from "./converter.js";
import { Logger } from "./logger.js";
import { navigateModels } from "./model.js";
import { fromSdkServiceMethod, getParameterDefaultValue } from "./operation-converter.js";
Expand Down Expand Up @@ -153,11 +154,7 @@ export function createModel(sdkContext: SdkContext<NetEmitterOptions>): CodeMode
Name: "url",
CrossLanguageDefinitionId: "TypeSpec.url",
}
: {
Kind: "string",
Name: "string",
CrossLanguageDefinitionId: "TypeSpec.string",
};
: fromSdkType(parameter.type, sdkContext, modelMap, enumMap); // TODO: consolidate with converter.fromSdkEndpointType
parameters.push({
Name: parameter.name,
NameInRequest: parameter.serializedName,
Expand Down
10 changes: 9 additions & 1 deletion packages/http-client-csharp/emitter/src/lib/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export function fromSdkType(
} as InputNullableType;
}
if (sdkType.kind === "model") return fromSdkModelType(sdkType, context, models, enums);
if (sdkType.kind === "endpoint") return fromSdkEndpointType();
if (sdkType.kind === "enum") return fromSdkEnumType(sdkType, context, enums);
if (sdkType.kind === "enumvalue")
return fromSdkEnumValueTypeToConstantType(sdkType, context, enums, literalTypeContext);
Expand All @@ -68,7 +69,6 @@ export function fromSdkType(
// TODO -- endpoint and credential are handled separately in emitter, since we have specific locations for them in input model.
// 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.
if (sdkType.kind === "credential") throw new Error("Credential type is not supported yet.");
if (sdkType.kind === "endpoint") throw new Error("Endpoint type is not supported yet.");

return fromSdkBuiltInType(sdkType);
}
Expand Down Expand Up @@ -381,3 +381,11 @@ function fromSdkArrayType(
CrossLanguageDefinitionId: arrayType.crossLanguageDefinitionId,
};
}

function fromSdkEndpointType(): InputPrimitiveType {
return {
Kind: "string",
Name: "string",
CrossLanguageDefinitionId: "TypeSpec.string",
};
}

0 comments on commit 2c8d4e2

Please sign in to comment.