From bc4df4b28191f91584660b100bde06143f495dcb Mon Sep 17 00:00:00 2001 From: Fabien BERNARD Date: Fri, 17 May 2019 17:57:03 +0200 Subject: [PATCH] Add a bit more explainations about the console.log override --- src/scripts/import-open-api.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/scripts/import-open-api.ts b/src/scripts/import-open-api.ts index c28abcc7..5871bfc9 100644 --- a/src/scripts/import-open-api.ts +++ b/src/scripts/import-open-api.ts @@ -480,14 +480,17 @@ const validate = async (schema: OpenAPIObject) => { const log = console.log; // Catch the internal console.log to add some information if needed - let haveOpenAPIValidatorOutput = false; + // because openApiValidator() calls console.log internally and + // we want to add more context if it's used + let wasConsoleLogCalledFromBlackBox = false; console.log = (...props: any) => { - haveOpenAPIValidatorOutput = true; + wasConsoleLogCalledFromBlackBox = true; log(...props); }; const { errors, warnings } = await openApiValidator(schema); - console.log = log; - if (haveOpenAPIValidatorOutput) { + console.log = log; // reset console.log because we're done with the black box + + if (wasConsoleLogCalledFromBlackBox) { log("More information: https://github.com/IBM/openapi-validator/#configuration"); } if (warnings.length) {