Skip to content

Commit 30b85fd

Browse files
committed
Bundle local and remote file references
1 parent fcafeb7 commit 30b85fd

File tree

8 files changed

+144
-52
lines changed

8 files changed

+144
-52
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## unreleased
22

3+
- CLI - Bundle local and remote file references
4+
35
## [1.23.2] - 2024-09-16
46

57
- Filter - handle inverseFlagValues removal of nested array values

bin/__snapshots__/cli.test.js.snap

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`openapi-format CLI command should load the default .openapiformatrc if configFile is not provided 1`] = `
4-
"================================================================================
5-
OpenAPI-Format CLI settings:
6-
- Sort file: (defaultSort.json)
7-
- Input file: test/yaml-default/input.yaml
8-
================================================================================
9-
✅ OpenAPI formatted successfully
10-
================================================================================
11-
"
12-
`;
13-
143
exports[`openapi-format CLI command should keep the comments for YAML 1`] = `
154
"================================================================================
165
OpenAPI-Format CLI settings:
@@ -33,6 +22,17 @@ OpenAPI-Format CLI options:
3322
"
3423
`;
3524

25+
exports[`openapi-format CLI command should load the default .openapiformatrc if configFile is not provided 1`] = `
26+
"================================================================================
27+
OpenAPI-Format CLI settings:
28+
- Sort file: (defaultSort.json)
29+
- Input file: test/yaml-default/input.yaml
30+
================================================================================
31+
✅ OpenAPI formatted successfully
32+
================================================================================
33+
"
34+
`;
35+
3636
exports[`openapi-format CLI command should not convert large numbers in JSON 1`] = `
3737
"================================================================================
3838
OpenAPI-Format CLI settings:
@@ -132,7 +132,7 @@ exports[`openapi-format CLI command should stop and show error about remote file
132132
OpenAPI-Format CLI settings:
133133
- Sort file: (defaultSort.json)
134134
- Input file: https://raw.githubusercontent.com/thim81/openapi-format/main/test/yaml-default/foo.yaml
135-
[31m Input file error - Failed to download file: 404 Not Found
135+
[31m Input file error - Failed to read file: 404 Not Found
136136
"
137137
`;
138138

bin/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ async function run(oaFile, options) {
204204
input = resObj;
205205
} catch (err) {
206206
if (err.code !== 'ENOENT') {
207-
console.error('\x1b[31m', `Input file error - Failed to download file: ${err.message}`);
207+
console.error('\x1b[31m', `Input file error - Failed to read file: ${err.message}`);
208208
process.exit(1);
209209
}
210210
console.error('\x1b[31m', `Input file error - Failed to read file: ${oaFile}`);

openapi-format.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const {
2828
convertExclusiveMaximum,
2929
setInObject
3030
} = require('./utils/convert');
31-
const {parseFile, writeFile, stringify, detectFormat, parseString, analyzeOpenApi} = require('./utils/file');
31+
const {parseFile, writeFile, stringify, detectFormat, parseString, analyzeOpenApi, readFile} = require('./utils/file');
3232
const {parseTpl, getOperation} = require('./utils/parseTpl');
3333

3434
/**
@@ -1120,6 +1120,7 @@ module.exports = {
11201120
openapiChangeCase: openapiChangeCase,
11211121
openapiConvertVersion: openapiConvertVersion,
11221122
openapiRename: openapiRename,
1123+
readFile: readFile,
11231124
parseFile: parseFile,
11241125
parseString: parseString,
11251126
stringify: stringify,

package-lock.json

Lines changed: 39 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
},
3434
"dependencies": {
3535
"@stoplight/yaml": "^4.3.0",
36+
"api-ref-bundler": "^0.4.3",
3637
"case-anything": "2.1.10",
3738
"commander": "^7.2.0",
3839
"neotraverse": "^0.6.18"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
components:
2+
schemas:
3+
Extern:
4+
type: object
5+
properties:
6+
id:
7+
type: string

0 commit comments

Comments
 (0)