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

feat: add title flag to openapi:convert #1071

Merged
merged 2 commits into from
Nov 19, 2024
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
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
Loading