Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/typespec-ts/src/modular/buildClassicalClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ export function buildClassicalClient(
});

constructor.addStatements([
`this._client = create${modularClientName}(${paramNames.join(",")})`
`this._client = create${modularClientName}(${paramNames.join(",")});`
]);
constructor.addStatements(`this.pipeline = this._client.pipeline`);
constructor.addStatements(`this.pipeline = this._client.pipeline;`);

buildClientOperationGroups(clientFile, _client, dpgContext, clientClass);
importAllApis(clientFile, srcPath, subfolder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export function buildGetClientOptionsParam(
expr += `credentials: ${credentials},`;
}

expr += `}`;
expr += `};`;

context.addStatements(expr);
return "updatedOptions";
Expand Down
34 changes: 32 additions & 2 deletions packages/typespec-ts/test/modularUnit/scenarios.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { assert } from "chai";
import { readdirSync, readFileSync, statSync, writeFileSync } from "fs";
import path from "path";
import {
emitModularClientContextFromTypeSpec,
emitModularClientFromTypeSpec,
emitModularModelsFromTypeSpec,
emitModularOperationsFromTypeSpec,
emitSamplesFromTypeSpec
Expand Down Expand Up @@ -32,7 +34,21 @@ const OUTPUT_CODE_BLOCK_TYPES: Record<string, EmitterFunction> = {
"(ts|typescript) models interface {name}": async (tsp, { name }, namedUnknownArgs) => {
const configs = namedUnknownArgs ? (namedUnknownArgs["configs"] as Record<string, string>) : {};
const result = await emitModularModelsFromTypeSpec(tsp, configs);
return result!.getInterfaceOrThrow(name ?? "No name specified!").getText();
return result!.getInterfaceOrThrow(name ?? "No name specified!").getFullText();
},

// Snapshot of a particular class named {name} in the models file
"(ts|typescript) models alias {name}": async (tsp, { name }, namedUnknownArgs) => {
const configs = namedUnknownArgs ? (namedUnknownArgs["configs"] as Record<string, string>) : {};
const result = await emitModularModelsFromTypeSpec(tsp, configs);
return result!.getTypeAlias(name ?? "No name specified!")!.getFullText();
},

// Snapshot of a particular enum named {name} in the models file
"(ts|typescript) models enum {name}": async (tsp, { name }, namedUnknownArgs) => {
const configs = namedUnknownArgs ? (namedUnknownArgs["configs"] as Record<string, string>) : {};
const result = await emitModularModelsFromTypeSpec(tsp, configs);
return result!.getEnum(name ?? "No name specified!")!.getFullText();
},

// Snapshot of a particular function named {name} in the models file
Expand Down Expand Up @@ -119,6 +135,20 @@ const OUTPUT_CODE_BLOCK_TYPES: Record<string, EmitterFunction> = {
)
.join("\n");
return text;
},

//Snapshot of the clientContext file for a given typespec
"(ts|typescript) clientContext": async (tsp, { }, namedUnknownArgs) => {
const configs = namedUnknownArgs ? (namedUnknownArgs["configs"] as Record<string, string>) : {};
const result = await emitModularClientContextFromTypeSpec(tsp, configs);
return result!.getFullText()!;
},

//Snapshot of the classicClient file for a given typespec
"(ts|typescript) classicClient": async (tsp, { }, namedUnknownArgs) => {
const configs = namedUnknownArgs ? (namedUnknownArgs["configs"] as Record<string, string>) : {};
const result = await emitModularClientFromTypeSpec(tsp, configs);
return result!.getFullText()!;
}
};

Expand Down Expand Up @@ -222,7 +252,7 @@ function describeScenarioFile(scenarioFile: string): void {
writeFileSync(scenarioFile, writeScenarios(scenarios));
}

await assertEqualContent(result, testCase.block.content, true);
await assertEqualContent(result, testCase.block.content, configs["ignoreWeirdLine"] as any === false ? false : true);
});
}
});
Expand Down
Loading