From 23b8e6634dca5ee8d048909858d852493fe26720 Mon Sep 17 00:00:00 2001 From: Rachael Sewell Date: Tue, 13 Dec 2022 14:34:28 -0800 Subject: [PATCH] update validation for openapi script (#33521) --- script/rest/update-files.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/script/rest/update-files.js b/script/rest/update-files.js index 6728d39ef0..550acb5905 100755 --- a/script/rest/update-files.js +++ b/script/rest/update-files.js @@ -28,7 +28,7 @@ program ) .option( '-v --versions ', - 'A list of undeprecated, published versions to build, separated by a space. Example "ghes-3.1" or "api.github.com github.ae"' + 'A list of undeprecated, published versions to build, separated by a space. Example `-v ghes-3.1` or `-v api.github.com github.ae`' ) .option('-d --include-deprecated', 'Includes schemas that are marked as `deprecated: true`') .option('-u --include-unpublished', 'Includes schemas that are marked as `published: false`') @@ -131,9 +131,8 @@ async function getBundlerOptions() { async function validateInputParameters() { // The `--versions` and `--decorate-only` options cannot be used // with the `--include-deprecated` or `--include-unpublished` options - const numberOfOptions = Object.keys(program.opts()).length - if (numberOfOptions > 1 && (decorateOnly || versions)) { - const errorMsg = `🛑 You cannot use the versions and decorate-only options with any other options.\nThe decorate-only switch will decorate all dereferenced schemas files in the docs-internal repo.\nThis script doesn't support generating individual deprecated or unpublished schemas.\nPlease reach out to #docs-engineering if this is a use case that you need.` + if ((includeDeprecated || includeUnpublished) && (decorateOnly || versions)) { + const errorMsg = `🛑 You cannot use the versions option with the include-unpublished or include-deprecated options. This is not currently supported in the bundler.\nYou cannot use the decorate-only option with include-unpublished or include-deprecated because the include-unpublished and include-deprecated options are only available when running the bundler. The decorate-only option skips running the bundler.\nPlease reach out to #docs-engineering if a new use case should be supported.` throw new Error(errorMsg) }