Skip to content

Commit 9a5e4a0

Browse files
committed
chore(prettier): reformat files
1 parent edcb80a commit 9a5e4a0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+264
-321
lines changed

.github/workflows/CI-CD.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ jobs:
6161
fail-fast: true
6262
matrix:
6363
os:
64-
- ubuntu-latest # Chrome, Firefox
65-
- windows-latest # Internet Explorer
64+
- ubuntu-latest # Chrome, Firefox
65+
- windows-latest # Internet Explorer
6666

6767
steps:
6868
- name: Checkout source

.vscode/launch.json

+3-10
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
"cwd": "${workspaceRoot}",
1212
"preLaunchTask": null,
1313
"runtimeExecutable": null,
14-
"runtimeArgs": [
15-
"--nolazy"
16-
],
14+
"runtimeArgs": ["--nolazy"],
1715
"env": {
1816
"NODE_ENV": "development"
1917
},
@@ -26,16 +24,11 @@
2624
"request": "launch",
2725
"program": "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js",
2826
"stopOnEntry": false,
29-
"args": [
30-
"run",
31-
"test:typescript"
32-
],
27+
"args": ["run", "test:typescript"],
3328
"cwd": "${workspaceRoot}",
3429
"preLaunchTask": null,
3530
"runtimeExecutable": null,
36-
"runtimeArgs": [
37-
"--nolazy"
38-
],
31+
"runtimeArgs": ["--nolazy"],
3932
"env": {
4033
"NODE_ENV": "development"
4134
},

.vscode/tasks.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
"kind": "build",
2121
"isDefault": true
2222
},
23-
"problemMatcher": "$tsc",
23+
"problemMatcher": "$tsc"
2424
},
2525
{
2626
"type": "npm",
2727
"script": "test:node",
2828
"group": {
2929
"kind": "test",
3030
"isDefault": true
31-
},
32-
},
31+
}
32+
}
3333
]
3434
}

README.md

+26-34
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
[![License](https://img.shields.io/npm/l/@apidevtools/json-schema-ref-parser.svg)](LICENSE)
1010
[![Buy us a tree](https://img.shields.io/badge/Treeware-%F0%9F%8C%B3-lightgreen)](https://plant.treeware.earth/APIDevTools/json-schema-ref-parser)
1111

12-
Installation
13-
--------------------------
12+
## Installation
13+
1414
Install using [npm](https://docs.npmjs.com/about-npm/):
1515

1616
```bash
@@ -19,8 +19,8 @@ yarn add @apidevtools/json-schema-ref-parser
1919
bun add @apidevtools/json-schema-ref-parser
2020
```
2121

22-
The Problem:
23-
--------------------------
22+
## The Problem:
23+
2424
You've got a JSON Schema with `$ref` pointers to other files and/or URLs. Maybe you know all the referenced files ahead
2525
of time. Maybe you don't. Maybe some are local files, and others are remote URLs. Maybe they are a mix of JSON and YAML
2626
format. Maybe some of the files contain cross-references to each other.
@@ -48,8 +48,8 @@ format. Maybe some of the files contain cross-references to each other.
4848
}
4949
```
5050

51-
The Solution:
52-
--------------------------
51+
## The Solution:
52+
5353
JSON Schema $Ref Parser is a full [JSON Reference](https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03)
5454
and [JSON Pointer](https://tools.ietf.org/html/rfc6901) implementation that crawls even the most
5555
complex [JSON Schemas](http://json-schema.org/latest/json-schema-core.html) and gives you simple, straightforward
@@ -68,8 +68,7 @@ JavaScript objects.
6868
instance
6969
- Compatible with Node LTS and beyond, and all major web browsers on Windows, Mac, and Linux
7070

71-
Example
72-
--------------------------
71+
## Example
7372

7473
```javascript
7574
import $RefParser from "@apidevtools/json-schema-ref-parser";
@@ -89,10 +88,7 @@ try {
8988

9089
For more detailed examples, please see the [API Documentation](https://apitools.dev/json-schema-ref-parser/docs/)
9190

92-
93-
Polyfills
94-
--------------------------
95-
91+
## Polyfills
9692

9793
If you are using Node.js < 18, you'll need a polyfill for `fetch`,
9894
like [node-fetch](https://github.com/node-fetch/node-fetch):
@@ -103,8 +99,8 @@ import fetch from "node-fetch";
10399
globalThis.fetch = fetch;
104100
```
105101

106-
Browser support
107-
--------------------------
102+
## Browser support
103+
108104
JSON Schema $Ref Parser supports recent versions of every major web browser. Older browsers may
109105
require [Babel](https://babeljs.io/) and/or [polyfills](https://babeljs.io/docs/en/next/babel-polyfill).
110106

@@ -121,54 +117,50 @@ Edit your `webpack.config.js` :
121117

122118
```js
123119
config.resolve.fallback = {
124-
"path": require.resolve("path-browserify"),
125-
'fs': require.resolve('browserify-fs')
126-
}
120+
path: require.resolve("path-browserify"),
121+
fs: require.resolve("browserify-fs"),
122+
};
127123

128124
config.plugins.push(
129125
new webpack.ProvidePlugin({
130-
Buffer: ['buffer', 'Buffer']
131-
})
132-
)
133-
126+
Buffer: ["buffer", "Buffer"],
127+
}),
128+
);
134129
```
135130

136-
API Documentation
137-
--------------------------
131+
## API Documentation
132+
138133
Full API documentation is available [right here](https://apitools.dev/json-schema-ref-parser/docs/)
139134

135+
## Contributing
140136

141-
Contributing
142-
--------------------------
143137
I welcome any contributions, enhancements, and
144-
bug-fixes. [Open an issue](https://github.com/APIDevTools/json-schema-ref-parser/issues) on GitHub
138+
bug-fixes. [Open an issue](https://github.com/APIDevTools/json-schema-ref-parser/issues) on GitHub
145139
and [submit a pull request](https://github.com/APIDevTools/json-schema-ref-parser/pulls).
146140

147141
#### Building/Testing
148142

149143
To build/test the project locally on your computer:
150144

151-
1. __Clone this repo__<br>
145+
1. **Clone this repo**<br>
152146
`git clone https://github.com/APIDevTools/json-schema-ref-parser.git`
153147

154-
2. __Install dependencies__<br>
148+
2. **Install dependencies**<br>
155149
`yarn install`
156150

157-
3. __Run the tests__<br>
151+
3. **Run the tests**<br>
158152
`yarn test`
159153

160-
License
161-
--------------------------
154+
## License
155+
162156
JSON Schema $Ref Parser is 100% free and open-source, under the [MIT license](LICENSE). Use it however you want.
163157

164158
This package is [Treeware](http://treeware.earth). If you use it in production, then we ask that you [**buy the world a
165159
tree**](https://plant.treeware.earth/APIDevTools/json-schema-ref-parser) to thank us for our work. By contributing to
166160
the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.
167161

162+
## Big Thanks To
168163

169-
170-
Big Thanks To
171-
--------------------------
172164
Thanks to these awesome companies for their support of Open Source developers ❤
173165

174166
[![Stoplight](https://svgshare.com/i/TK5.svg)](https://stoplight.io/?utm_source=github&utm_medium=readme&utm_campaign=json_schema_ref_parser)

docs/README.md

+25-28
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
JSON Schema $Ref Parser API
2-
==========================
1+
# JSON Schema $Ref Parser API
2+
3+
## Things to Know
34

4-
Things to Know
5-
---------------------
65
- [Class methods vs. Instance methods](#class-methods-vs-instance-methods)
76
- [Callbacks vs. Promises](#callbacks-vs-promises)
87
- [Circular references](#circular-refs)
98

10-
11-
Classes & Methods
12-
---------------------
9+
## Classes & Methods
1310

1411
#### [The `$RefParser` class](ref-parser.md)
12+
1513
- [`schema` property](ref-parser.md#schema)
1614
- [`$refs` property](ref-parser.md#refs)
1715
- [`dereference()` method](ref-parser.md#dereferenceschema-options-callback)
@@ -20,6 +18,7 @@ Classes & Methods
2018
- [`resolve()` method](ref-parser.md#resolveschema-options-callback)
2119

2220
#### [The `$Refs` class](refs.md)
21+
2322
- [`circular` property](refs.md#circular)
2423
- [`paths()` method](refs.md#pathstypes)
2524
- [`values()` method](refs.md#valuestypes)
@@ -29,9 +28,9 @@ Classes & Methods
2928

3029
#### [The `Options` object](options.md)
3130

32-
3331
### Class methods vs. Instance methods
34-
All of JSON Schema $Ref Parser's methods are available as static (class) methods, and as instance methods. The static methods simply create a new [`$RefParser`](ref-parser.md) instance and then call the corresponding instance method. Thus, the following line...
32+
33+
All of JSON Schema $Ref Parser's methods are available as static (class) methods, and as instance methods. The static methods simply create a new [`$RefParser`](ref-parser.md) instance and then call the corresponding instance method. Thus, the following line...
3534

3635
```javascript
3736
$RefParser.bundle("my-schema.json");
@@ -46,47 +45,45 @@ parser.bundle("my-schema.json");
4645

4746
The difference is that in the second example you now have a reference to `parser`, which means you can access the results ([`parser.schema`](ref-parser.md#schema) and [`parser.$refs`](ref-parser.md#refs)) anytime you want, rather than just in the callback function.
4847

49-
5048
### Callbacks vs. Promises
51-
Many people prefer [Promise syntax](http://javascriptplayground.com/blog/2015/02/promises/) or `async`/`await` instead of callbacks. JSON Schema $Ref Parser allows you to use whichever one you prefer.
5249

53-
If you pass a callback function to any method, then the method will call the callback using the Node.js error-first convention. If you do _not_ pass a callback function, then the method will return a Promise.
50+
Many people prefer [Promise syntax](http://javascriptplayground.com/blog/2015/02/promises/) or `async`/`await` instead of callbacks. JSON Schema $Ref Parser allows you to use whichever one you prefer.
51+
52+
If you pass a callback function to any method, then the method will call the callback using the Node.js error-first convention. If you do _not_ pass a callback function, then the method will return a Promise.
5453

5554
The following two examples are equivalent:
5655

5756
```javascript
5857
// Callback syntax
5958
$RefParser.dereference(mySchema, (err, api) => {
60-
if (err) {
61-
// Error
62-
}
63-
else {
64-
// Success
65-
}
59+
if (err) {
60+
// Error
61+
} else {
62+
// Success
63+
}
6664
});
6765
```
6866

6967
```javascript
7068
try {
71-
// async/await syntax
72-
let api = await $RefParser.dereference(mySchema);
69+
// async/await syntax
70+
let api = await $RefParser.dereference(mySchema);
7371

74-
// Success
75-
}
76-
catch (err) {
77-
// Error
72+
// Success
73+
} catch (err) {
74+
// Error
7875
}
7976
```
8077

81-
8278
### Circular $Refs
83-
JSON Schema files can contain [circular $ref pointers](https://gist.github.com/JamesMessinger/d18278935fc73e3a0ee1), and JSON Schema $Ref Parser fully supports them. Circular references can be resolved and dereferenced just like any other reference. However, if you intend to serialize the dereferenced schema as JSON, then you should be aware that [`JSON.stringify`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) does not support circular references by default, so you will need to [use a custom replacer function](https://stackoverflow.com/questions/11616630/json-stringify-avoid-typeerror-converting-circular-structure-to-json).
79+
80+
JSON Schema files can contain [circular $ref pointers](https://gist.github.com/JamesMessinger/d18278935fc73e3a0ee1), and JSON Schema $Ref Parser fully supports them. Circular references can be resolved and dereferenced just like any other reference. However, if you intend to serialize the dereferenced schema as JSON, then you should be aware that [`JSON.stringify`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) does not support circular references by default, so you will need to [use a custom replacer function](https://stackoverflow.com/questions/11616630/json-stringify-avoid-typeerror-converting-circular-structure-to-json).
8481

8582
You can disable circular references by setting the [`dereference.circular`](options.md) option to `false`. Then, if a circular reference is found, a `ReferenceError` will be thrown.
8683

87-
Or you can choose to just ignore circular references altogether by setting the [`dereference.circular`](options.md) option to `"ignore"`. In this case, all non-circular references will still be dereferenced as normal, but any circular references will remain in the schema.
84+
Or you can choose to just ignore circular references altogether by setting the [`dereference.circular`](options.md) option to `"ignore"`. In this case, all non-circular references will still be dereferenced as normal, but any circular references will remain in the schema.
8885

89-
Another option is to use the [`bundle`](ref-parser.md#bundleschema-options-callback) method rather than the [`dereference`](ref-parser.md#dereferenceschema-options-callback) method. Bundling does _not_ result in circular references, because it simply converts _external_ `$ref` pointers to _internal_ ones.
86+
Another option is to use the [`bundle`](ref-parser.md#bundleschema-options-callback) method rather than the [`dereference`](ref-parser.md#dereferenceschema-options-callback) method. Bundling does _not_ result in circular references, because it simply converts _external_ `$ref` pointers to _internal_ ones.
9087

9188
```javascript
9289
"person": {

0 commit comments

Comments
 (0)