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

chore: bump @tstv/tsconfig-common from 2.0.0 to 3.3.1 #489

Merged
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"description": "Swagger API client generator based on axios and TypeScript.",
"devDependencies": {
"@tstv/tsconfig-common": "2.0.0",
"@tstv/tsconfig-common": "3.3.1",
"@types/ci-info": "3.1.0",
"@types/cli-interact": "0.1.2",
"@types/fs-extra": "11.0.2",
Expand Down
16 changes: 8 additions & 8 deletions src/Swaxios.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('writeClient', () => {
const actual = await fs.readFile(path.join(tempDir, 'rest/instance/ArchiveService.ts'), 'utf-8');
const expected = await fs.readFile(
path.resolve(__dirname, './test/snapshots/1-query-param-description.ts.fixture'),
'utf-8',
'utf-8'
);
expect(actual).toBe(expected);
});
Expand All @@ -40,7 +40,7 @@ describe('writeClient', () => {
const actual = await fs.readFile(path.join(tempDir, 'APIClient.ts'), 'utf-8');
const expected = await fs.readFile(
path.resolve(__dirname, './test/snapshots/2-deep-nested-endpoints.ts.fixture'),
'utf-8',
'utf-8'
);
expect(actual).toBe(expected);
});
Expand All @@ -51,7 +51,7 @@ describe('writeClient', () => {
const actual = await fs.readFile(path.join(tempDir, 'rest/api/v1/ExchangeService.ts'), 'utf-8');
const expected = await fs.readFile(
path.resolve(__dirname, './test/snapshots/3-delete-by-id-number.ts.fixture'),
'utf-8',
'utf-8'
);
expect(actual).toBe(expected);
});
Expand All @@ -62,7 +62,7 @@ describe('writeClient', () => {
const actual = await fs.readFile(path.join(tempDir, 'rest/api/v1/ExchangeService.ts'), 'utf-8');
const expected = await fs.readFile(
path.resolve(__dirname, './test/snapshots/4-delete-by-id-number-with-response.ts.fixture'),
'utf-8',
'utf-8'
);
expect(actual).toBe(expected);
});
Expand All @@ -74,7 +74,7 @@ describe('writeClient', () => {
const actual = await fs.readFile(path.join(tempDir, 'rest/api/UserService.ts'), 'utf-8');
const expected = await fs.readFile(
path.resolve(__dirname, './test/snapshots/5-query-param-required.ts.fixture'),
'utf-8',
'utf-8'
);

expect(actual).toBe(expected);
Expand Down Expand Up @@ -107,14 +107,14 @@ describe('writeClient', () => {
let actual = await fs.readFile(path.join(tempDir, 'interfaces/CreateAccountRequest.ts'), 'utf-8');
let expected = await fs.readFile(
path.resolve(__dirname, './test/snapshots/8-definitions-CreateAccountRequest.ts.fixture'),
'utf-8',
'utf-8'
);
expect(actual).toBe(expected);

actual = await fs.readFile(path.join(tempDir, 'interfaces/CreateAccountResponse.ts'), 'utf-8');
expected = await fs.readFile(
path.resolve(__dirname, './test/snapshots/8-definitions-CreateAccountResponse.ts.fixture'),
'utf-8',
'utf-8'
);
expect(actual).toBe(expected);
});
Expand All @@ -125,7 +125,7 @@ describe('writeClient', () => {
const actual = await fs.readFile(path.join(tempDir, 'APIClient.ts'), 'utf-8');
const expected = await fs.readFile(
path.resolve(__dirname, './test/snapshots/9-special-characters.ts.fixture'),
'utf-8',
'utf-8'
);
expect(actual).toBe(expected);
});
Expand Down
2 changes: 1 addition & 1 deletion src/generators/APIClientGenerator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('ResourceGenerator', () => {

const generator = new APIClientGenerator(fileIndex, '.', WireSSO);
const services = (await generator.generateAPI(fileIndex)) as Record<string, API>;
expect(services.login.authService).not.toBe(services.post.authService);
expect(services.login!.authService).not.toBe(services.post!.authService);
});
});
});
4 changes: 2 additions & 2 deletions src/generators/APIClientGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class APIClientGenerator extends TemplateGenerator {
const relativePath = path.dirname(path.relative(this.outputDirectory, file.fullPath)).replace(/\\/g, '/');

bundledImports[relativePath] = bundledImports[relativePath] || [];
bundledImports[relativePath].push(file);
bundledImports[relativePath]?.push(file);
}

for (const directory of Object.values(fileIndex.directories)) {
Expand All @@ -86,7 +86,7 @@ export class APIClientGenerator extends TemplateGenerator {
}

protected async getContext(): Promise<Context> {
const API = await this.generateAPI(this.fileIndex.directories.rest);
const API = await this.generateAPI(this.fileIndex.directories.rest!);
const apiString = inspect(API, {breakLength: Infinity, depth: Infinity}).replace(/'/gm, '');
const imports = this.generateImports(this.fileIndex);

Expand Down
5 changes: 3 additions & 2 deletions src/generators/InterfaceGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,12 @@ export class InterfaceGenerator extends TemplateGenerator {

let schemaType = schemaObject.type || SwaggerType.OBJECT;

if (Array.isArray(schemaType)) {
if (Array.isArray(schemaType) && schemaType[0]) {
schemaType = schemaType[0];
}

switch (schemaType.toLowerCase()) {
// TODO: Use proper assertion functions to identify "schemaType"
switch ((schemaType as string).toLowerCase()) {
case SwaggerType.BOOLEAN: {
return {basicType, type: TypeScriptType.BOOLEAN, imports};
}
Expand Down
2 changes: 1 addition & 1 deletion src/generators/MethodGenerator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('MethodGenerator', () => {
expect(methodDefinition.parameterMethod).toBe('postAll');
expect(methodDefinition.pathParameters).toEqual([]);
expect(methodDefinition.returnType).toBe(
'{ extraInfo: string; id: string, metadata: { certAuthnResponse: Array<string>; issuer: string, requestURI: string } }',
'{ extraInfo: string; id: string, metadata: { certAuthnResponse: Array<string>; issuer: string, requestURI: string } }'
);
});

Expand Down
4 changes: 2 additions & 2 deletions src/generators/MethodGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class MethodGenerator {
if (parameterMatch) {
if (!this.pathParameters.length) {
this.pathParameters.push({
name: parameterMatch[1],
name: parameterMatch[1]!,
type: TypeScriptType.ANY,
});
}
Expand Down Expand Up @@ -139,7 +139,7 @@ export class MethodGenerator {
}
const definitionString = ref.replace('#/definitions/', '');
const definition = this.spec.definitions[definitionString];
return definition.$ref ? this.getSchemaFromRef(definition.$ref) : definition;
return definition?.$ref ? this.getSchemaFromRef(definition?.$ref) : definition;
}

private buildParameters(parameters?: (OpenAPIV2.ParameterObject | OpenAPIV2.ReferenceObject)[]): void {
Expand Down
2 changes: 1 addition & 1 deletion src/util/StringUtil.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export function camelCase(words: string[], isPascalCase: boolean = false): string {
const casedWords = words.map(word => word.toLowerCase().charAt(0).toUpperCase() + word.slice(1));
if (!isPascalCase) {
casedWords[0] = casedWords[0].toLowerCase();
casedWords[0] = casedWords[0]!.toLowerCase();
}
return casedWords.join('');
}
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"outDir": "dist",
"rootDir": "src"
},
"exclude": ["coverage", "dist", "src/temp", "src/**/*.test.ts"],
"exclude": ["coverage", "dist", "src/temp"],
"extends": "@tstv/tsconfig-common/tsconfig.json"
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@
resolved "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.2.tgz#423c77877d0569db20e1fc80885ac4118314010e"
integrity sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==

"@tstv/tsconfig-common@2.0.0":
version "2.0.0"
resolved "https://registry.npmjs.org/@tstv/tsconfig-common/-/tsconfig-common-2.0.0.tgz#8be79ca4e2dfd8bed90790ec3a31ef9b5ad45ec4"
integrity sha512-WSCxPGHR1H5ZiOdBkA1ukQAPlnNT1wVXvhBgVxVyMfZ6lgMXhz/1OJn2xY21RkG+HLQwG1iIY7LwEFc5iz3xZQ==
"@tstv/tsconfig-common@3.3.1":
version "3.3.1"
resolved "https://registry.npmjs.org/@tstv/tsconfig-common/-/tsconfig-common-3.3.1.tgz#ab73b11a141d1ad289ff9f876969ea74ce147c09"
integrity sha512-OTf+DY0qd7AEBnm2Es1ytMxlIFzZejYJCsDk14JV1uEb2uCowaO1rZjOMaN/ak1RZY3bMz+9zmskPSDoUlL6yw==

"@types/[email protected]":
version "3.1.0"
Expand Down