这是indexloc提供的服务,不要输入任何密码
Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions packages/openapi-ts-tests/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"@hey-api/custom-client": "workspace:*",
"@hey-api/openapi-ts": "workspace:*",
"@pinia/colada": "0.17.7",
"@nestjs/common": "11.1.6",
"@nestjs/core": "11.1.6",
"@tanstack/angular-query-experimental": "5.73.3",
"@tanstack/react-query": "5.73.3",
"@tanstack/solid-query": "5.73.3",
Expand Down
158 changes: 158 additions & 0 deletions packages/openapi-ts-tests/main/test/clients.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,3 +510,161 @@ describe('my-client', () => {
);
});
});

describe.only('client-nestjs', () => {
const namespace = 'clients';

const outputDir = path.join(
__dirname,
'generated',
'3.1.x',
namespace,
'client-nestjs',
);

const createConfig = (
userConfig: Omit<UserConfig, 'input'> & Pick<Partial<UserConfig>, 'input'>,
): UserConfig => ({
...userConfig,
input: path.join(getSpecsPath(), '3.1.x', 'full.yaml'),
logs: {
level: 'silent',
},
output:
typeof userConfig.output === 'string'
? path.join(outputDir, userConfig.output)
: {
...userConfig.output,
path: path.join(outputDir, userConfig.output.path),
},
});

const scenarios = [
{
config: createConfig({
output: 'custom-client-name',
plugins: [
{
clientName: 'MyApi',
name: '@hey-api/client-nestjs',
},
],
}),
description: 'custom client name',
},
{
config: createConfig({
output: 'custom-module-name',
plugins: [
{
clientName: 'CustomClient',
moduleName: 'MyCustomModule',
name: '@hey-api/client-nestjs',
},
],
}),
description: 'custom module name',
},
{
config: createConfig({
output: 'custom-client-class-name',
plugins: [
{
clientClassName: 'MyHttpClient',
clientName: 'TestApi',
name: '@hey-api/client-nestjs',
},
],
}),
description: 'custom client class name',
},
{
config: createConfig({
output: 'throw-on-error-true',
plugins: [
{
name: '@hey-api/client-nestjs',
throwOnError: true,
},
],
}),
description: 'throw on error enabled',
},
{
config: createConfig({
output: 'throw-on-error-false',
plugins: [
{
name: '@hey-api/client-nestjs',
throwOnError: false,
},
],
}),
description: 'throw on error disabled',
},
{
config: createConfig({
output: 'bundled',
plugins: [
{
bundle: true,
name: '@hey-api/client-nestjs',
},
],
}),
description: 'bundled client',
},
{
config: createConfig({
output: 'no-bundle',
plugins: [
{
bundle: false,
name: '@hey-api/client-nestjs',
},
],
}),
description: 'client without bundle',
},
{
config: createConfig({
output: 'custom-config-combined',
plugins: [
{
clientClassName: 'SuperClient',
clientName: 'AdvancedApi',
moduleName: 'AdvancedApiModule',
name: '@hey-api/client-nestjs',
throwOnError: true,
},
],
}),
description: 'combined custom configuration',
},
];

it.each(scenarios)('$description', async ({ config }) => {
await createClient(config);

const outputPath =
typeof config.output === 'string' ? config.output : config.output.path;
const filePaths = getFilePaths(outputPath);

await Promise.all(
filePaths.map(async (filePath) => {
const fileContent = fs.readFileSync(filePath, 'utf-8');

await expect(fileContent).toMatchFileSnapshot(
path.join(
__dirname,
'__snapshots__',
'3.1.x',
namespace,
'client-nestjs',
filePath.slice(outputDir.length + 1),
),
);
}),
);
});
});
1 change: 1 addition & 0 deletions packages/openapi-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
"@angular/platform-browser-dynamic": "19.2.15",
"@angular/router": "19.2.15",
"@config/vite-base": "workspace:*",
"@nestjs/common": "11.1.6",
"@types/bun": "1.3.1",
"@types/cross-spawn": "6.0.6",
"@types/semver": "7.7.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { Plugin } from '~/plugins';

Check failure on line 1 in packages/openapi-ts/src/plugins/@hey-api/client-core/types.d.ts

View workflow job for this annotation

GitHub Actions / Build, Lint, Test (macos-latest, 20.19.0)

Run autofix to sort these imports!

Check failure on line 1 in packages/openapi-ts/src/plugins/@hey-api/client-core/types.d.ts

View workflow job for this annotation

GitHub Actions / Build, Lint, Test (ubuntu-latest, 22.12.0)

Run autofix to sort these imports!

Check failure on line 1 in packages/openapi-ts/src/plugins/@hey-api/client-core/types.d.ts

View workflow job for this annotation

GitHub Actions / Build, Lint, Test (ubuntu-latest, 20.19.0)

Run autofix to sort these imports!
import type { HeyApiClientAngularPlugin } from '~/plugins/@hey-api/client-angular';
import type { HeyApiClientAxiosPlugin } from '~/plugins/@hey-api/client-axios';
import type { HeyApiClientFetchPlugin } from '~/plugins/@hey-api/client-fetch';
import type { HeyApiClientNextPlugin } from '~/plugins/@hey-api/client-next';
import type { HeyApiClientNuxtPlugin } from '~/plugins/@hey-api/client-nuxt';
import type { HeyApiClientOfetchPlugin } from '~/plugins/@hey-api/client-ofetch';
import type { HeyApiClientNestjsPlugin } from '~/plugins/@hey-api/client-nestjs';

export interface PluginHandler {
(...args: Parameters<HeyApiClientAngularPlugin['Handler']>): void;
Expand All @@ -13,6 +14,7 @@
(...args: Parameters<HeyApiClientNextPlugin['Handler']>): void;
(...args: Parameters<HeyApiClientNuxtPlugin['Handler']>): void;
(...args: Parameters<HeyApiClientOfetchPlugin['Handler']>): void;
(...args: Parameters<HeyApiClientNestjsPlugin['Handler']>): void;
}

/**
Expand Down
Loading
Loading