diff --git a/documentation/commands/openapi.md b/documentation/commands/openapi.md index e05bff469..e1e77161a 100644 --- a/documentation/commands/openapi.md +++ b/documentation/commands/openapi.md @@ -7,6 +7,7 @@ Manage your API definition (e.g., syncing, validation, analysis, conversion, etc * [`rdme openapi convert [SPEC]`](#rdme-openapi-convert-spec) * [`rdme openapi inspect [SPEC]`](#rdme-openapi-inspect-spec) * [`rdme openapi reduce [SPEC]`](#rdme-openapi-reduce-spec) +* [`rdme openapi refs [SPEC]`](#rdme-openapi-refs-spec) * [`rdme openapi validate [SPEC]`](#rdme-openapi-validate-spec) ## `rdme openapi [SPEC]` @@ -226,13 +227,13 @@ EXAMPLES $ rdme openapi reduce petstore.json --path /pet/{id} --method get --method put --out petstore.reduced.json ``` -## `rdme openapi:refs [SPEC]` +## `rdme openapi refs [SPEC]` Resolves circular and recursive references in OpenAPI by replacing them with object schemas. ``` USAGE - $ rdme openapi:refs [SPEC] [--out <value>] [--workingDirectory <value>] + $ rdme openapi refs [SPEC] [--out <value>] [--workingDirectory <value>] ARGUMENTS SPEC A file/URL to your API definition @@ -254,16 +255,16 @@ DESCRIPTION EXAMPLES This will resolve circular and recursive references in the OpenAPI definition at the given file or URL: - $ rdme openapi:refs [url-or-local-path-to-file] + $ rdme openapi refs [url-or-local-path-to-file] You can omit the file name and `rdme` will scan your working directory (and any subdirectories) for OpenAPI files. This approach will provide you with CLI prompts, so we do not recommend this technique in CI environments. - $ rdme openapi:refs + $ rdme openapi refs If you wish to automate this command, you can pass in CLI arguments to bypass the prompts: - $ rdme openapi:refs petstore.json --out petstore.openapi.json + $ rdme openapi refs petstore.json --out petstore.openapi.json ``` ## `rdme openapi validate [SPEC]` diff --git a/src/commands/openapi/refs.ts b/src/commands/openapi/refs.ts index c4d5411e1..a0cc0e873 100644 --- a/src/commands/openapi/refs.ts +++ b/src/commands/openapi/refs.ts @@ -312,7 +312,7 @@ export default class OpenAPIRefsCommand extends BaseCommand<typeof OpenAPIRefsCo this.debug(`Switching working directory from ${previousWorkingDirectory} to ${process.cwd()}`); } - const { preparedSpec, specPath, specType } = await prepareOas(spec, 'openapi:refs', { convertToLatest: true }); + const { preparedSpec, specPath, specType } = await prepareOas(spec, 'openapi refs', { convertToLatest: true }); if (specType !== 'OpenAPI') { throw new Error('Sorry, this ref resolver feature in rdme only supports OpenAPI 3.0+ definitions.'); } diff --git a/src/lib/prepareOas.ts b/src/lib/prepareOas.ts index 1ff08a2dd..77a7971fb 100644 --- a/src/lib/prepareOas.ts +++ b/src/lib/prepareOas.ts @@ -49,7 +49,7 @@ const capitalizeSpecType = (type: string) => */ export default async function prepareOas( path: string | undefined, - command: 'openapi convert' | 'openapi inspect' | 'openapi reduce' | 'openapi validate' | 'openapi', + command: 'openapi convert' | 'openapi inspect' | 'openapi reduce' | 'openapi refs' |'openapi validate' | 'openapi', opts: { /** * Optionally convert the supplied or discovered API definition to the latest OpenAPI release.