Skip to content
Merged
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: 1 addition & 1 deletion openapitools.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "6.6.0"
"version": "7.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { ExecutorContext } from '@nx/devkit';
import { execSync } from 'child_process';
import { existsSync } from 'node:fs';
import generateClients, { ClientGeneratorSchemaType, validateSpec } from './client-generator';

// Mock child_process
jest.mock('child_process');
const mockExecSync = execSync as jest.MockedFunction<typeof execSync>;

// Mock node:fs
jest.mock('node:fs');
const mockExistsSync = existsSync as jest.MockedFunction<typeof existsSync>;

// Mock console.error
const mockConsoleError = jest.spyOn(console, 'error').mockImplementation(() => {
return undefined;
Expand Down Expand Up @@ -63,6 +68,8 @@ describe('generateClients', () => {
// By default, validation succeeds (returns clean output)
// execSync with { encoding: 'utf-8' } returns a string
mockExecSync.mockReturnValue('No validation issues detected.' as any);
// By default, openapitools.json exists
mockExistsSync.mockReturnValue(true);
});

afterAll(() => {
Expand Down Expand Up @@ -433,14 +440,24 @@ describe('generateClients', () => {
expect(mockExecSync).toHaveBeenCalledWith(expect.stringContaining("TS_POST_PROCESS_FILE='./postProcess.sh'"), { stdio: 'inherit' });
});

it('should include openapitools.json path', async () => {
it('should include openapitools.json path when file exists', async () => {
mockExistsSync.mockReturnValue(true);
await generateClients(mockOptions, mockContext);

expect(mockExecSync).toHaveBeenCalledWith(expect.stringContaining('--openapitools /workspace/test-project/openapitools.json'), {
stdio: 'inherit',
});
});

it('should omit openapitools.json path when file does not exist', async () => {
mockExistsSync.mockReturnValue(false);
await generateClients(mockOptions, mockContext);

expect(mockExecSync).toHaveBeenCalledWith(expect.not.stringContaining('--openapitools'), {
stdio: 'inherit',
});
});

it('should include skip-validate-spec and enable-post-process-file flags', async () => {
await generateClients(mockOptions, mockContext);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ExecutorContext } from '@nx/devkit';
import { execSync } from 'child_process';
import { existsSync } from 'node:fs';
import { join } from 'node:path';
import { z } from 'zod';

Expand Down Expand Up @@ -50,8 +51,11 @@ function generateClient(packagePath: string, spec: string, outputDir: string, cl
'--custom-generator=target/typescript-axios-webpack-module-federation-openapi-generator-1.0.0.jar -g typescript-axios-webpack-module-federation';
}

const packageOpenapitools = join(packagePath, 'openapitools.json');
const openapiToolsArg = existsSync(packageOpenapitools) ? `--openapitools ${packageOpenapitools}` : '';

execSync(
`TS_POST_PROCESS_FILE='./postProcess.sh' openapi-generator-cli generate -i ${spec} -o ${outputDir} --openapitools ${packagePath}/openapitools.json --skip-validate-spec --enable-post-process-file ${additionalArgs} --additional-properties clientName=${clientName}`,
`TS_POST_PROCESS_FILE='./postProcess.sh' openapi-generator-cli generate -i ${spec} -o ${outputDir} ${openapiToolsArg} --skip-validate-spec --enable-post-process-file ${additionalArgs} --additional-properties clientName=${clientName}`,
{ stdio: 'inherit' },
);
}
Expand Down
7 changes: 0 additions & 7 deletions packages/compliance/openapitools.json

This file was deleted.

7 changes: 0 additions & 7 deletions packages/config-manager/openapitools.json

This file was deleted.

7 changes: 0 additions & 7 deletions packages/entitlements/openapitools.json

This file was deleted.

7 changes: 0 additions & 7 deletions packages/host-inventory/openapitools.json

This file was deleted.

7 changes: 0 additions & 7 deletions packages/insights/openapitools.json

This file was deleted.

7 changes: 0 additions & 7 deletions packages/integrations/openapitools.json

This file was deleted.

7 changes: 0 additions & 7 deletions packages/notifications/openapitools.json

This file was deleted.

7 changes: 0 additions & 7 deletions packages/patch/openapitools.json

This file was deleted.

7 changes: 0 additions & 7 deletions packages/quickstarts/openapitools.json

This file was deleted.

7 changes: 0 additions & 7 deletions packages/rbac/openapitools.json

This file was deleted.

7 changes: 0 additions & 7 deletions packages/remediations/openapitools.json

This file was deleted.

8 changes: 0 additions & 8 deletions packages/shared/openapitools.json

This file was deleted.

7 changes: 0 additions & 7 deletions packages/sources/openapitools.json

This file was deleted.

7 changes: 0 additions & 7 deletions packages/topological-inventory/openapitools.json

This file was deleted.

1 change: 1 addition & 0 deletions packages/vulnerabilities/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"options": {
"postProcess": "./postProcess.sh",
"legacyGenerator": true,
"skipValidation": true,
"specs": {
"default": "apiSpec.json",
"git-api": "apiSpec.json"
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<openapi-generator-version>6.6.0</openapi-generator-version>
<openapi-generator-version>7.0.0</openapi-generator-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<junit-version>4.13.2</junit-version>
<apache-commons-version>1.10.0</apache-commons-version>
Expand Down
Loading