Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
bf7bb33
Resolved might be null
P0lip Apr 24, 2020
ed377cb
Tweak Error types
P0lip Apr 26, 2020
d270782
Throw errors with more meaningful paths
P0lip Apr 22, 2020
0346204
Release under Stoplight
P0lip Apr 26, 2020
26d9608
fix: do not re-crawl unless necessary
marbemac Jun 5, 2020
b95ed0a
v9.0.2
marbemac Jun 6, 2020
2c75399
Do not use js-yaml
P0lip Jun 14, 2020
baff5d4
fix: continueOnError behaves correctly with empty parsing result
karol-maciaszek Jun 16, 2020
b001d1e
fix: do not depend on continueOnError
karol-maciaszek Jun 17, 2020
d75be5e
Merge pull request #3 from karol-maciaszek/master
karol-maciaszek Jun 17, 2020
b05f58a
release 9.0.4
P0lip Jun 17, 2020
38b717b
skip typed arrays and DataViews while crawling the schema
ntamas Jun 24, 2020
a1e1f27
Handle direct external circular references
P0lip Apr 27, 2020
f3f2ed9
Temporarily disabling redirect tests because HTTPBin is down
JamesMessinger Jul 8, 2020
5a18f59
moved top-level property to the top of the object
JamesMessinger Jul 10, 2020
3e32475
fix: do not mutate objects when values do not change
haggholm Jul 23, 2020
5c3eece
add processedObject list to avoid recursion in already processed tree…
Oct 20, 2020
2e7e1e0
Updated dependencies
JamesMessinger Jul 10, 2020
04ea301
Updated dependencies
JamesMessinger Jul 19, 2020
ad45e79
Updated ESLint rules
JamesMessinger Jul 19, 2020
d0e19d6
ESLint fixes
JamesMessinger Jul 19, 2020
8e3766f
Linter fixes
JamesMessinger Jul 19, 2020
5bc1e25
Unixify paths in tests
P0lip Jun 1, 2020
067c60a
Release 9.0.5
P0lip Nov 13, 2020
8ab03cb
Downgrade @jsdevtools/karma-config
P0lip Nov 13, 2020
df72735
Custom bundling roots (#4)
P0lip Nov 18, 2020
33fb610
Publish 9.1.0-beta.1
P0lip Nov 18, 2020
42ee896
Improve custom bundling key generation (#5)
P0lip Nov 30, 2020
5895bcf
Publish 9.1.0-beta.2
P0lip Nov 30, 2020
8ba5cdf
Include mid only in case of collision (#6)
P0lip Jan 5, 2021
3837ab1
Publish 9.1.0-beta.3
P0lip Jan 6, 2021
018de17
StoplightKeyGenerator should defer access of gen opts (#8)
P0lip Jan 7, 2021
411b8eb
Publish 9.1.0-beta.4
P0lip Jan 7, 2021
0a16ff0
Setup CircleCI (#9)
P0lip Jan 7, 2021
2b65001
Arbitrary urls (#10)
P0lip Jan 8, 2021
f093843
Support v2 Stoplight platform (#11)
P0lip Jan 11, 2021
3ee2ac5
Publish 9.1.0-beta.5
P0lip Jan 11, 2021
a54461a
Do not create additional root for already rooted $refs (#7)
P0lip Jan 13, 2021
dcdb5ea
Publish 9.1.0-beta.6
P0lip Jan 14, 2021
0007c72
Handle scoped only imports (#12)
P0lip Jan 22, 2021
c9161de
Publish 9.1.0-beta.7
P0lip Jan 22, 2021
26917e9
Cover subsequently missed custom root
P0lip Jan 26, 2021
8092880
Publish 9.1.0
P0lip Jan 26, 2021
92a7f9a
Inline certain references rather than hoisting them (#13)
P0lip Jan 28, 2021
d364d51
Publish 9.1.1
P0lip Feb 1, 2021
517e613
Re-export JSONParserErrorGroup from the main entrypoint
P0lip Feb 4, 2021
fc7ae09
Capitalize may potentially throw an exception
P0lip Feb 4, 2021
2be4217
Pregenerate filepath if needed
P0lip Feb 4, 2021
3abeae4
An extra test showing arbitary URLs are handled
P0lip Feb 5, 2021
5e27512
Support any Stoplight service
P0lip Feb 5, 2021
d302594
Use isomorphic-fetch for http requests (#14)
P0lip Feb 5, 2021
411c482
Publish 9.1.2
P0lip Feb 5, 2021
24601c3
Bundling support for other shared components (#16)
Feb 10, 2021
172f172
Release 9.1.3-beta.1
P0lip Feb 15, 2021
2b01005
Support nested custom roots (#19)
P0lip Feb 18, 2021
b927a11
Release 9.1.3-beta.2
P0lip Feb 18, 2021
b572efa
Ignore query in Stoplight endpoint URLs (#20)
P0lip Mar 3, 2021
8abb4c5
Release 9.1.3
P0lip Mar 3, 2021
40b4bdd
Perf of dereference is unstable (#17)
P0lip Mar 5, 2021
e354e4f
Release 9.1.4
P0lip Mar 5, 2021
36c1cca
Track usage (#21)
P0lip Mar 19, 2021
15bc775
Release 9.2.0
P0lip Mar 19, 2021
558135b
Bundle generates incorrect propertyMap (#23)
P0lip Mar 26, 2021
13ace0f
Release 9.2.1
P0lip Mar 26, 2021
e252a2e
Test fields override (#24)
P0lip Apr 2, 2021
1693308
Let defaultRoot be null (#26)
P0lip Jul 27, 2021
9edb650
fix: remove abort-controller polyfill
marbemac Feb 7, 2022
f4c4ae9
try this out
marbemac Feb 7, 2022
008226a
still need node polyfill for < 16
marbemac Feb 7, 2022
a1628de
chrome bin
marbemac Feb 7, 2022
22c69b1
circle file
marbemac Feb 8, 2022
94f0376
browser tools
marbemac Feb 8, 2022
64e22bb
fix: switch to node only abort controller polyfill
marbemac Feb 8, 2022
06d298a
fix(bundle): handle external URLs better (#30)
P0lip May 3, 2022
0a15f2d
Release 9.2.2
marbemac May 3, 2022
51665de
fix(http): replace url based basic auth with header
May 3, 2023
dd778ae
Merge pull request #37 from stoplightio/fix/fetch-auth
mmarti21 May 4, 2023
9c852d0
fix(http): allow for undefined headers
May 4, 2023
5c9b100
Merge pull request #42 from stoplightio/fix/fetch-auth-headers
mmarti21 May 4, 2023
c888ec6
improve MissingPointerError message
EdVinyard May 30, 2023
00f024a
fix a couple tests; try to get more info about remaining failing tests
EdVinyard May 31, 2023
aa05447
fix constructor param order (thanks Daniel!); revert experimental cha…
EdVinyard May 31, 2023
70e087e
release v9.2.5
EdVinyard May 31, 2023
fc3f606
Merge pull request #43 from stoplightio/improve-MissingPointerError-m…
ksoviero-stoplight May 31, 2023
0e46146
chore: increase suggest key attempts
Aug 29, 2023
fc79d97
Updated config.yml
mmarti21 Aug 29, 2023
6e6ba8c
Merge pull request #46 from stoplightio/fix/increase-key-attempts
mmarti21 Aug 29, 2023
ae6977f
convert relative refs when resolving an external schema
brendarearden Sep 26, 2023
ec34b4c
add npm version
brendarearden Sep 26, 2023
4f5c085
clone object in test helper, fix linting errors
brendarearden Sep 26, 2023
446ca7a
skip failing test
brendarearden Sep 28, 2023
6377871
updating images and version in workflows
brendarearden Sep 28, 2023
cdcfd4f
Merge pull request #47 from stoplightio/fix/2385-external-ref-resolution
mmarti21 Sep 29, 2023
9f9465e
undo toFileSystemPath changes
brendarearden Oct 2, 2023
9f37789
Merge pull request #50 from stoplightio/fix/2385-external-ref-resolution
mmarti21 Oct 2, 2023
86ad38e
fix bug in test helper
brendarearden Oct 3, 2023
f6c013d
Merge pull request #51 from stoplightio/fix/2385-external-ref-resolution
mmarti21 Oct 3, 2023
15d4514
process refs through fileSystemPath to account for os & browser
brendarearden Oct 4, 2023
8d19b3b
Merge pull request #52 from stoplightio/fix/2385-external-ref-resolution
mmarti21 Oct 5, 2023
b72c855
add check to not convert actual urls
brendarearden Oct 5, 2023
79a8cda
Merge pull request #53 from stoplightio/fix/2385-external-ref-resolution
mmarti21 Oct 9, 2023
8fb793b
Add url as explicit dependency (#58)
dnascimento Mar 13, 2024
067afb3
chore: drop binary parser (#60)
P0lip Mar 14, 2024
ab6ad5a
Drop redundant dependencies (#59)
P0lip Mar 14, 2024
fcee80d
chore: drop process (#61)
P0lip Mar 18, 2024
1eff26d
chore: release 10.0
P0lip Mar 18, 2024
3fb54b4
build: no need to test against Edge anymore
P0lip Mar 18, 2024
2299bcc
test: use path.unixify to normalize paths
P0lip Mar 18, 2024
c1af82b
code optimisation for circular ref issue
SB-rohitdesai Jun 3, 2024
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
version: 2.1

orbs:
node: circleci/node@4.7.0
browser-tools: circleci/browser-tools@1.4.8

executors:
linux:
docker:
- image: cimg/base:2022.02

commands:
install:
steps:
- run:
name: Install dependencies
command: npm ci

test-node:
steps:
- run:
name: Lint the code
command: npm run lint
- run:
name: Run node tests
command: npm run test:node
- run:
name: Verify typings
command: npm run test:typescript

jobs:
test:
parameters:
os:
type: executor
node-version:
type: string
executor: << parameters.os >>
steps:
- checkout
- node/install:
node-version: << parameters.node-version >>
install-yarn: false
install-npm: true
npm-version: "9.7.1"
- install
- test-node

test-browser:
docker:
- image: cimg/node:16.20-browsers
steps:
- checkout
- browser-tools/install-browser-tools
- install
- run:
name: Run browser tests
command: npm run test:browser

workflows:
commit:
jobs:
- test:
matrix:
parameters:
os:
- linux
node-version:
- "18.19.1"
- test-browser
17 changes: 5 additions & 12 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
# ESLint config
# http://eslint.org/docs/user-guide/configuring
# https://jstools.dev/eslint-config-modular/
# https://jstools.dev/eslint-config/

root: true

extends:
- "@jsdevtools/modular/best-practices"
- "@jsdevtools/modular/style"
- "@jsdevtools/modular/browser"
- "@jsdevtools/modular/node"
- "@jsdevtools/modular/es6"

rules:
# This rule erroneously flags functions that use the `arguments` object
no-unused-vars: off
extends: "@jsdevtools"
env:
node: true
browser: true
31 changes: 15 additions & 16 deletions .github/workflows/CI-CD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ jobs:
- macos-latest
- windows-latest
node:
- 10
- 12
- 18
- 20

steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install Node ${{ matrix.node }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

Expand All @@ -53,30 +53,29 @@ jobs:
run: npm run coverage:node

- name: Send code coverage results to Coveralls
uses: coverallsapp/github-action@v1.0.1
uses: coverallsapp/github-action@v1.1.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel: true

browser_tests:
name: Browser Tests
runs-on: ${{ matrix.os }}
timeout-minutes: 10
timeout-minutes: 15
strategy:
fail-fast: true
matrix:
os:
- ubuntu-latest # Chrome, Firefox, Safari (via SauceLabs), Edge (via SauceLabs)
- windows-latest # Internet Explorer
- ubuntu-latest # Chrome, Firefox

steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install Node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 12
node-version: 16

- name: Install dependencies
run: npm ci
Expand All @@ -94,21 +93,21 @@ jobs:
cat coverage/*/lcov.info > ./coverage/lcov.info

- name: Send code coverage results to Coveralls
uses: coverallsapp/github-action@v1.0.1
uses: coverallsapp/github-action@v1.1.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel: true

coverage:
name: Code Coverage
runs-on: ubuntu-latest
timeout-minutes: 10
timeout-minutes: 5
needs:
- node_tests
- browser_tests
steps:
- name: Let Coveralls know that all tests have finished
uses: coverallsapp/github-action@v1.0.1
uses: coverallsapp/github-action@v1.1.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
Expand All @@ -124,10 +123,10 @@ jobs:

steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install Node
uses: actions/setup-node@v1
uses: actions/setup-node@v3

- name: Install dependencies
run: npm ci
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
33 changes: 22 additions & 11 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,34 @@
// ${cwd}: the current working directory of the spawned process

{
"version": "0.1.0",
"version": "2.0.0",
"command": "npm",
"isShellCommand": true,
"suppressTaskName": true,
"tasks": [
{
"taskName": "lint",
"args": ["run", "lint"],
"showOutput": "always",
"label": "lint",
"type": "shell",
"args": [
"run",
"lint"
],
"problemMatcher": "$eslint-stylish",
"isBuildCommand": true
"group": {
"_id": "build",
"isDefault": false
}
},
{
"taskName": "test",
"args": ["run", "mocha"],
"showOutput": "always",
"isTestCommand": true
"label": "test",
"type": "shell",
"args": [
"run",
"mocha"
],
"problemMatcher": [],
"group": {
"_id": "test",
"isDefault": false
}
}
]
}
32 changes: 22 additions & 10 deletions docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Example

```javascript
$RefParser.dereference("my-schema.yaml", {
continueOnError: true, // Don't throw on the first error
parse: {
json: false, // Disable the JSON parser
yaml: {
Expand All @@ -27,10 +28,10 @@ $RefParser.dereference("my-schema.yaml", {
withCredentials: true, // Include auth credentials when resolving HTTP references
}
},
continueOnError: true, // Don't throw on the first error
dereference: {
circular: false // Don't allow circular $refs
}
},
bundle: {} // bundling specific options
});
```

Expand All @@ -39,15 +40,15 @@ $RefParser.dereference("my-schema.yaml", {
-------------------
The `parse` options determine how different types of files will be parsed.

JSON Schema $Ref Parser comes with built-in JSON, YAML, plain-text, and binary parsers, any of which you can configure or disable. You can also add [your own custom parsers](plugins/parsers.md) if you want.
JSON Schema $Ref Parser comes with built-in JSON, YAML, and plain-text parsers, any of which you can configure or disable. You can also add [your own custom parsers](plugins/parsers.md) if you want.

|Option(s) |Type |Description
|:----------------------------|:----------|:------------
|`json`<br>`yaml`<br>`text`<br>`binary`|`object` `boolean`|These are the built-in parsers. In addition, you can add [your own custom parsers](plugins/parsers.md)<br><br>To disable a parser, just set it to `false`.
|`json.order` `yaml.order` `text.order` `binary.order`|`number`|Parsers run in a specific order, relative to other parsers. For example, a parser with `order: 5` will run _before_ a parser with `order: 10`. If a parser is unable to successfully parse a file, then the next parser is tried, until one succeeds or they all fail.<br><br>You can change the order in which parsers run, which is useful if you know that most of your referenced files will be a certain type, or if you add [your own custom parser](plugins/parsers.md) that you want to run _first_.
|`json.allowEmpty` `yaml.allowEmpty` `text.allowEmpty` `binary.allowEmpty`|`boolean`|All of the built-in parsers allow empty files by default. The JSON and YAML parsers will parse empty files as `undefined`. The text parser will parse empty files as an empty string. The binary parser will parse empty files as an empty byte array.<br><br>You can set `allowEmpty: false` on any parser, which will cause an error to be thrown if a file empty.
|`json.canParse` `yaml.canParse` `text.canParse` `binary.canParse`|`boolean`, `RegExp`, `string`, `array`, `function`|Determines which parsers will be used for which files.<br><br>A regular expression can be used to match files by their full path. A string (or array of strings) can be used to match files by their file extension. Or a function can be used to perform more complex matching logic. See the [custom parser](plugins/parsers.md) docs for details.
|`text.encoding`|`string` |The encoding to use when parsing text-based files. The default is "utf8".
| Option(s) |Type |Description
|:-----------------------------------------------------------------------|:----------|:------------
| `json`<br>`yaml`<br>`text` |`object` `boolean`|These are the built-in parsers. In addition, you can add [your own custom parsers](plugins/parsers.md)<br><br>To disable a parser, just set it to `false`.
| `json.order` `yaml.order` `text.order` |`number`|Parsers run in a specific order, relative to other parsers. For example, a parser with `order: 5` will run _before_ a parser with `order: 10`. If a parser is unable to successfully parse a file, then the next parser is tried, until one succeeds or they all fail.<br><br>You can change the order in which parsers run, which is useful if you know that most of your referenced files will be a certain type, or if you add [your own custom parser](plugins/parsers.md) that you want to run _first_.
| `json.allowEmpty` `yaml.allowEmpty` `text.allowEmpty` |`boolean`|All of the built-in parsers allow empty files by default. The JSON and YAML parsers will parse empty files as `undefined`. The text parser will parse empty files as an empty string.
| `json.canParse` `yaml.canParse` `text.canParse` |`boolean`, `RegExp`, `string`, `array`, `function`|Determines which parsers will be used for which files.<br><br>A regular expression can be used to match files by their full path. A string (or array of strings) can be used to match files by their file extension. Or a function can be used to perform more complex matching logic. See the [custom parser](plugins/parsers.md) docs for details.
| `text.encoding` |`string` |The encoding to use when parsing text-based files. The default is "utf8".


`resolve` Options
Expand Down Expand Up @@ -75,3 +76,14 @@ The `dereference` options control how JSON Schema $Ref Parser will dereference `
|Option(s) |Type |Description
|:---------------------|:-------------------|:------------
|`circular`|`boolean` or `"ignore"`|Determines whether [circular `$ref` pointers](README.md#circular-refs) are handled.<br><br>If set to `false`, then a `ReferenceError` will be thrown if the schema contains any circular references.<br><br> If set to `"ignore"`, then circular references will simply be ignored. No error will be thrown, but the [`$Refs.circular`](refs.md#circular) property will still be set to `true`.

`bundle` Options

The `bundle` options control how JSON Schema $Ref Parser will bundle `$ref` pointers within the JSON schema.


|Option(s) |Type |Description
|:---------------------|:-------------------|:------------
|`generateKey`|`(value: any, file: string, hash: string or null) => string or null`|Used to generate $ref.
|`defaultRoot`|`string`|The default root to optimize for.

4 changes: 2 additions & 2 deletions docs/plugins/parsers.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Custom Parsers
==========================

JSON Schema $Ref Parser comes with built-in JSON, YAML, plain-text, and binary parsers, but you can add your own parsers to support additional file types, or even replace any of the built-in parsers with your own custom implementation.
JSON Schema $Ref Parser comes with built-in JSON, YAML, and plain-text parsers, but you can add your own parsers to support additional file types, or even replace any of the built-in parsers with your own custom implementation.

You can see the source code for any of the built-in parsers [right here](../../lib/parsers).

Expand All @@ -26,7 +26,7 @@ $RefParser.dereference(mySchema, { parse: { csv: myParser }});
```

#### The `order` property
All parsers have an `order` property, even the built-in parsers. If you don't specify an `order` property, then your parser will run last. Specifying `order: 1`, like we did in this example, will make your parser run first. Or you can squeeze your parser in-between some of the built-in parsers. For example, `order: 201` would make it run _after_ the JSON and YAML parsers, but _before_ the plain-text and binary parsers. You can see the order of all the built-in parsers by looking at [their source code](../../lib/parsers).
All parsers have an `order` property, even the built-in parsers. If you don't specify an `order` property, then your parser will run last. Specifying `order: 1`, like we did in this example, will make your parser run first. Or you can squeeze your parser in-between some of the built-in parsers. For example, `order: 201` would make it run _after_ the JSON and YAML parsers, but _before_ the plain-text parser. You can see the order of all the built-in parsers by looking at [their source code](../../lib/parsers).

The `order` property and `canParse` property are related to each other. For each file that JSON Schema $Ref Parser needs to parse, it first determines which parsers _can_ parse that file by checking their `canParse` property. If only one parser matches a file, then _only_ that one parser is called, regardless of its `order`. If multiple parsers match a file, then those parsers are tried _in order_ until one of them successfully parses the file. Once a parser successfully parses the file, the rest of the parsers are skipped.

Expand Down
3 changes: 0 additions & 3 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,5 @@ module.exports = karmaConfig({
browsers: {
chrome: host.ci ? host.os.linux : true,
firefox: host.ci ? host.os.linux : true,
safari: host.ci ? host.os.linux : host.os.mac,
edge: host.ci ? host.os.linux : host.os.windows,
ie: host.os.windows,
},
});
Loading