Skip to content

Commit

Permalink
feat: add title flag to openapi:convert (#1071)
Browse files Browse the repository at this point in the history
## 🧰 Changes

I accidentally added the `titleFlag` (allows you to overwrite the
`info.title` field) to `openapi:inspect` in #1068 which doesn't make a
ton of sense so I'm removing it in this PR. In doing this, I also
decided to add the `title` flag to `openapi:convert` b/c why not.
  • Loading branch information
kanadgupta authored Nov 19, 2024
1 parent 0d0a855 commit 1d71f3f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/commands/openapi/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import chalk from 'chalk';
import prompts from 'prompts';

import BaseCommand from '../../lib/baseCommand.js';
import { workingDirectoryFlag } from '../../lib/flags.js';
import { titleFlag, workingDirectoryFlag } from '../../lib/flags.js';
import { warn } from '../../lib/logger.js';
import prepareOas from '../../lib/prepareOas.js';
import promptTerminal from '../../lib/promptWrapper.js';
Expand All @@ -23,20 +23,24 @@ export default class OpenAPIConvertCommand extends BaseCommand<typeof OpenAPICon

static flags = {
out: Flags.string({ description: 'Output file path to write converted file to' }),
title: titleFlag,
workingDirectory: workingDirectoryFlag,
};

async run() {
const { spec } = this.args;
const { out, workingDirectory } = this.flags;
const { out, title, workingDirectory } = this.flags;

if (workingDirectory) {
const previousWorkingDirectory = process.cwd();
process.chdir(workingDirectory);
this.debug(`switching working directory from ${previousWorkingDirectory} to ${process.cwd()}`);
}

const { preparedSpec, specPath, specType } = await prepareOas(spec, 'openapi:convert', { convertToLatest: true });
const { preparedSpec, specPath, specType } = await prepareOas(spec, 'openapi:convert', {
convertToLatest: true,
title,
});
const parsedPreparedSpec: OASDocument = JSON.parse(preparedSpec);

if (specType === 'OpenAPI') {
Expand Down
3 changes: 1 addition & 2 deletions src/commands/openapi/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getBorderCharacters, table } from 'table';

import analyzeOas, { getSupportedFeatures } from '../../lib/analyzeOas.js';
import BaseCommand from '../../lib/baseCommand.js';
import { titleFlag, workingDirectoryFlag } from '../../lib/flags.js';
import { workingDirectoryFlag } from '../../lib/flags.js';
import { oraOptions } from '../../lib/logger.js';
import prepareOas from '../../lib/prepareOas.js';
import SoftError from '../../lib/softError.js';
Expand Down Expand Up @@ -185,7 +185,6 @@ export default class OpenAPIInspectCommand extends BaseCommand<typeof OpenAPIIns
multiple: true,
options: getSupportedFeatures(),
}),
title: titleFlag,
workingDirectory: workingDirectoryFlag,
};

Expand Down

0 comments on commit 1d71f3f

Please sign in to comment.