Skip to content

Commit

Permalink
Fix handling for -b option in typegen
Browse files Browse the repository at this point in the history
  • Loading branch information
anttiviljami committed Sep 10, 2024
1 parent dcdb9e1 commit 704a48e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/commands/typegen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ describe('typegen', () => {
expect(ctx.stdout).to.match(/export type Pet = Components.Schemas.Pet/);
});

test
.stdout()
.command(['typegen', resourcePath('openapi.json'), '-b', '/* Generated by openapicmd */'])
.it('adds file banner', (ctx) => {
expect(ctx.stdout).to.match(/Generated by openapicmd/);
});

test
.stdout()
.command(['typegen', resourcePath('openapi.json')])
Expand Down
6 changes: 3 additions & 3 deletions src/commands/typegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ export class Typegen extends Command {
this.error(err, { exit: 1 });
}

const [imports, schemaTypes, operationTypings, banner, aliases] = await generateTypesForDocument(document, { transformOperationName: (name) => name });
const [imports, schemaTypes, operationTypings, _banner, aliases] = await generateTypesForDocument(document, { transformOperationName: (name) => name });

Check warning on line 64 in src/commands/typegen.ts

View workflow job for this annotation

GitHub Actions / Test

'_banner' is assigned a value but never used

if (flags.banner && banner) {
this.log(banner + '\n');
if (flags.banner) {
this.log(flags.banner + '\n');
}

this.log([
Expand Down

0 comments on commit 704a48e

Please sign in to comment.