Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent tcgc versioning projection #745

Merged
merged 13 commits into from
May 6, 2024
1 change: 0 additions & 1 deletion packages/typespec-autorest/src/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ const defaultOptions = {
export async function $onEmit(context: EmitContext<AutorestEmitterOptions>) {
const resolvedOptions = { ...defaultOptions, ...context.options };
// set api-version to all to prevent tcgc versioning projection
(context.options as any)["api-version"] = "all";
const tcgcSdkContext = createSdkContext(context, "@azure-tools/typespec-autorest");
const armTypesDir = interpolatePath(
resolvedOptions["arm-types-dir"] ?? "{project-root}/../../common-types/resource-management",
Expand Down
13 changes: 12 additions & 1 deletion packages/typespec-client-generator-core/src/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,16 +571,27 @@ export function listOperationsInOperationGroup(
return operations;
}

interface CreateSdkContextOptions {
ignoreVersioning?: boolean;
tadelesh marked this conversation as resolved.
Show resolved Hide resolved
}

export function createSdkContext<
TOptions extends Record<string, any> = SdkEmitterOptions,
TServiceOperation extends SdkServiceOperation = SdkHttpOperation,
>(context: EmitContext<TOptions>, emitterName?: string): SdkContext<TOptions, TServiceOperation> {
>(
context: EmitContext<TOptions>,
emitterName?: string,
options?: CreateSdkContextOptions
): SdkContext<TOptions, TServiceOperation> {
const diagnostics = createDiagnosticCollector();
const protocolOptions = true; // context.program.getLibraryOptions("generate-protocol-methods");
const convenienceOptions = true; // context.program.getLibraryOptions("generate-convenience-methods");
const generateProtocolMethods = context.options["generate-protocol-methods"] ?? protocolOptions;
const generateConvenienceMethods =
context.options["generate-convenience-methods"] ?? convenienceOptions;
if (options?.ignoreVersioning === false) {
context.options["api-version"] ?? "all";
tadelesh marked this conversation as resolved.
Show resolved Hide resolved
}
const sdkContext: SdkContext<TOptions, TServiceOperation> = {
program: context.program,
emitContext: context,
Expand Down
Loading