Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions test/__utils__/test-utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs');
const sy = require('@stoplight/yaml');
const os = require('os');
const {exec} = require('child_process');
const path = require('path');
const {parseFile, stringify} = require('../../utils/file');
Expand All @@ -13,6 +13,7 @@ async function loadTest(folder, inputType = 'yaml', outType = 'yaml') {
const inputPath = `./test/${folder}/${inputFile}`;
const outputFile = `output.${outType}`;
const outputPath = `./test/${folder}/${outputFile}`;
const tmpOutput = path.join(os.tmpdir(), `openapi-format-${folder}-output.${outType}`);

try {
input = await parseFile(inputPath);
Expand All @@ -26,10 +27,10 @@ async function loadTest(folder, inputType = 'yaml', outType = 'yaml') {
// File not found = {} will be used
}

let result = await cli([`${inputFile}`, `--configFile options.yaml`], testPath);
let result = await cli([`${inputFile}`, `--configFile options.yaml`, `--output ${tmpOutput}`], testPath);

try {
outputAfter = await parseFile(outputPath);
outputAfter = await parseFile(tmpOutput);
} catch (err) {
//
}
Expand Down
2 changes: 1 addition & 1 deletion test/json-default-bug-big-numbers/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion test/json-delete-method/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion test/json-filter-inverse-operationids-126/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion test/json-filter-unused/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,4 @@
}
}
}
}
}
1 change: 0 additions & 1 deletion test/overlay-extends-local/output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ info:
title: Base Local
version: 1.0.0
paths: {}

1 change: 0 additions & 1 deletion test/overlay-extends-remote/output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ info:
servers:
- url: 'https://api.example.com'
description: Default server

11 changes: 5 additions & 6 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ describe('openapi-format tests', () => {
if (fs.existsSync(configFilename)) {
// Load options file
configFileOptions = await parseFile(configFilename);
configFileOptions.sort = !configFileOptions['no-sort'];
if (configFileOptions['no-sort'] && configFileOptions['no-sort'] === true) {
configFileOptions.sort = configFileOptions.sort ?? true;
configFileOptions.bundle = configFileOptions.bundle ?? true;
if (configFileOptions['no-sort']) {
configFileOptions.sort = !configFileOptions['no-sort'];
delete configFileOptions['no-sort'];
}
configFileOptions.bundle = !configFileOptions['no-bundle'];
if (configFileOptions['no-sort'] && configFileOptions['no-bundle'] === true) {
if (configFileOptions['no-bundle']) {
configFileOptions.bundle = !configFileOptions['no-bundle'];
delete configFileOptions['no-bundle'];
}
Expand Down Expand Up @@ -128,8 +128,7 @@ describe('openapi-format tests', () => {

try {
if (!readOutput) {
// Write OpenAPI string to file
await writeFile(outputFilename, result, options);
fs.writeFileSync(outputFilename, result, 'utf8');
}
} catch (error) {
console.error('error', error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ openapi: 3.0.1
servers:
- url: 'https://server-e'
x-stage:
- e
- e
Loading