openapi-merge-cli
Advanced tools
Comparing version 1.1.23 to 1.1.25
@@ -159,3 +159,3 @@ { | ||
"output": { | ||
"description": "The output file to put the results in.", | ||
"description": "The output file to put the results in. If you use the .yml or .yaml extension then the schema will be output\nin YAML format, otherwise, it will be output in JSON format.", | ||
"minLength": 1, | ||
@@ -162,0 +162,0 @@ "title": "output", |
@@ -84,3 +84,4 @@ export declare type OperationSelection = { | ||
/** | ||
* The output file to put the results in. | ||
* The output file to put the results in. If you use the .yml or .yaml extension then the schema will be output | ||
* in YAML format, otherwise, it will be output in JSON format. | ||
* | ||
@@ -87,0 +88,0 @@ * @minLength 1 |
@@ -130,2 +130,16 @@ "use strict"; | ||
} | ||
function isYamlExtension(filePath) { | ||
const extension = path_1.default.extname(filePath); | ||
return ['.yaml', '.yml'].includes(extension); | ||
} | ||
function dumpAsYaml(blob) { | ||
// Note: The JSON stringify and parse is required to strip the undefined values: https://github.com/nodeca/js-yaml/issues/571 | ||
return js_yaml_1.default.safeDump(JSON.parse(JSON.stringify(blob)), { indent: 2 }); | ||
} | ||
function writeOutput(outputFullPath, outputSchema) { | ||
const fileContents = isYamlExtension(outputFullPath) | ||
? dumpAsYaml(outputSchema) | ||
: JSON.stringify(outputSchema, null, 2); | ||
fs_1.default.writeFileSync(outputFullPath, fileContents); | ||
} | ||
function main() { | ||
@@ -159,3 +173,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
logger.log(`## Inputs merged, writing the results out to '${outputFullPath}'`); | ||
fs_1.default.writeFileSync(outputFullPath, JSON.stringify(mergeResult.output, null, 2)); | ||
writeOutput(outputFullPath, mergeResult.output); | ||
logger.log(`## Finished writing to '${outputFullPath}'`); | ||
@@ -162,0 +176,0 @@ }); |
{ | ||
"name": "openapi-merge-cli", | ||
"version": "1.1.23", | ||
"version": "1.1.25", | ||
"description": "A cli tool for the openapi-merge library.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28143
506