diff --git a/lib/config.js b/lib/config.js index 41ff4bf5..1f86ae9e 100644 --- a/lib/config.js +++ b/lib/config.js @@ -20,6 +20,7 @@ class Config { }, resolve: { output: args.output, + internalRefs: args.internalRefs }, serve: { port: args.port, diff --git a/resolve.js b/resolve.js index 7b54051a..bc3259be 100755 --- a/resolve.js +++ b/resolve.js @@ -13,6 +13,7 @@ const command = async (file, cmd) => { const jsonSchema = config.get('jsonSchema'); const output = config.get('resolve:output'); const verbose = config.get('quiet') ? 0 : config.get('verbose', 1); + const internalRefs = config.get('resolve:internalRefs'); const spec = await loader.readOrError( file, @@ -40,7 +41,7 @@ const command = async (file, cmd) => { }); }; -const buildLoaderOptions = (jsonSchema, verbose) => { +const buildLoaderOptions = (jsonSchema, verbose, internalRefs) => { const options = { resolve: true, cache: [], @@ -52,6 +53,7 @@ const buildLoaderOptions = (jsonSchema, verbose) => { verbose, }; if (jsonSchema) options.filters.push(fromJsonSchema); + if (internalRefs) options.resolveInternal = true; return options; } diff --git a/speccy.js b/speccy.js index dc05eeb6..35b98b2d 100755 --- a/speccy.js +++ b/speccy.js @@ -19,7 +19,6 @@ function increaseVerbosity(v, total) { return total + 1; } - program .version(version) .usage('') @@ -50,7 +49,8 @@ program .option('-o, --output ', 'file to output to') .option('-q, --quiet', 'reduce verbosity') .option('-j, --json-schema', 'treat $ref like JSON Schema and convert to OpenAPI Schema Objects (default: false)') - .option('-v, --verbose', 'increase verbosity', increaseVerbosity,1) + .option('-i, --internal-refs', 'resolve internal references (default: false)') + .option('-v, --verbose', 'increase verbosity', increaseVerbosity, 1) .action((specFile, cmd) => { resolve.command(specFile, cmd) .then(() => { process.exit(0) }) @@ -68,7 +68,7 @@ program .option('-p, --port [value]', 'port on which the server will listen (default: 5000)') .option('-q, --quiet', 'reduce verbosity') .option('-j, --json-schema', 'treat $ref like JSON Schema and convert to OpenAPI Schema Objects (default: false)') - .option('-v, --verbose', 'increase verbosity', increaseVerbosity,1) + .option('-v, --verbose', 'increase verbosity', increaseVerbosity, 1) // TODO .option('-w, --watch', 'reloading browser on spec file changes') .action((specFile, cmd) => { serve.command(specFile, cmd)