Fix endpoint handling (#4164)
This commit is contained in:
Родитель
67adf07c3f
Коммит
2c8d4e2185
|
@ -19,6 +19,7 @@ import { InputOperationParameterKind } from "../type/input-operation-parameter-k
|
||||||
import { InputParameter } from "../type/input-parameter.js";
|
import { InputParameter } from "../type/input-parameter.js";
|
||||||
import { InputEnumType, InputModelType, InputType } from "../type/input-type.js";
|
import { InputEnumType, InputModelType, InputType } from "../type/input-type.js";
|
||||||
import { RequestLocation } from "../type/request-location.js";
|
import { RequestLocation } from "../type/request-location.js";
|
||||||
|
import { fromSdkType } from "./converter.js";
|
||||||
import { Logger } from "./logger.js";
|
import { Logger } from "./logger.js";
|
||||||
import { navigateModels } from "./model.js";
|
import { navigateModels } from "./model.js";
|
||||||
import { fromSdkServiceMethod, getParameterDefaultValue } from "./operation-converter.js";
|
import { fromSdkServiceMethod, getParameterDefaultValue } from "./operation-converter.js";
|
||||||
|
@ -153,11 +154,7 @@ export function createModel(sdkContext: SdkContext<NetEmitterOptions>): CodeMode
|
||||||
Name: "url",
|
Name: "url",
|
||||||
CrossLanguageDefinitionId: "TypeSpec.url",
|
CrossLanguageDefinitionId: "TypeSpec.url",
|
||||||
}
|
}
|
||||||
: {
|
: fromSdkType(parameter.type, sdkContext, modelMap, enumMap); // TODO: consolidate with converter.fromSdkEndpointType
|
||||||
Kind: "string",
|
|
||||||
Name: "string",
|
|
||||||
CrossLanguageDefinitionId: "TypeSpec.string",
|
|
||||||
};
|
|
||||||
parameters.push({
|
parameters.push({
|
||||||
Name: parameter.name,
|
Name: parameter.name,
|
||||||
NameInRequest: parameter.serializedName,
|
NameInRequest: parameter.serializedName,
|
||||||
|
|
|
@ -53,6 +53,7 @@ export function fromSdkType(
|
||||||
} as InputNullableType;
|
} as InputNullableType;
|
||||||
}
|
}
|
||||||
if (sdkType.kind === "model") return fromSdkModelType(sdkType, context, models, enums);
|
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 === "enum") return fromSdkEnumType(sdkType, context, enums);
|
||||||
if (sdkType.kind === "enumvalue")
|
if (sdkType.kind === "enumvalue")
|
||||||
return fromSdkEnumValueTypeToConstantType(sdkType, context, enums, literalTypeContext);
|
return fromSdkEnumValueTypeToConstantType(sdkType, context, enums, literalTypeContext);
|
||||||
|
@ -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.
|
// 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.
|
// 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 === "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);
|
return fromSdkBuiltInType(sdkType);
|
||||||
}
|
}
|
||||||
|
@ -381,3 +381,11 @@ function fromSdkArrayType(
|
||||||
CrossLanguageDefinitionId: arrayType.crossLanguageDefinitionId,
|
CrossLanguageDefinitionId: arrayType.crossLanguageDefinitionId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fromSdkEndpointType(): InputPrimitiveType {
|
||||||
|
return {
|
||||||
|
Kind: "string",
|
||||||
|
Name: "string",
|
||||||
|
CrossLanguageDefinitionId: "TypeSpec.string",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче