Skip to content

Commit 3e10147

Browse files
New options!
1 parent 2048bdb commit 3e10147

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

docs/options.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,7 @@ $RefParser.dereference("my-schema.yaml", {
3333
|`cache.fs` |number |60 |<a name="caching"></a>The length of time (in seconds) to cache local files. The default is one minute. Setting to zero will cache forever.
3434
|`cache.http` |number |300 |The length of time (in seconds) to cache HTTP URLs. The default is five minutes. Setting to zero will cache forever.
3535
|`cache.https` |number |300 |The length of time (in seconds) to cache HTTPS URLs. The default is five minutes. Setting to zero will cache forever.
36+
|`http.headers` |object |`{}` |HTTP to send when downloading files<br> (note: [some headers are protected](https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name) and cannot be set)
37+
|`http.timeout` |number |5000 |The HTTP request timeout (in milliseconds)
38+
|`http.redirects` |number |5 |The maximum number of HTTP redirects to follow. To disable automatic following of redirects, set this to zero.
3639
|`http.withCredentials`|bool |false |When used in browser specifies [`withCredentials`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials) option of [`XMLHttpRequest`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) object. Set this to `true` if you're downloading files from a CORS-enabled server that requries authentication

lib/options.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,28 @@ function $RefParserOptions(options) {
9696
* HTTP request options
9797
*/
9898
this.http = {
99+
/**
100+
* HTTP headers to send when downloading files.
101+
*/
102+
headers: {},
103+
104+
/**
105+
* HTTP request timeout (in milliseconds).
106+
*/
107+
timeout: 5000,
108+
109+
/**
110+
* The maximum number of HTTP redirects to follow.
111+
* To disable automatic following of redirects, set this to zero.
112+
*/
113+
redirects: 5,
114+
99115
/**
100116
* The `withCredentials` option of XMLHttpRequest.
101117
* Set this to `true` if you're downloading files from a CORS-enabled server that requires authentication
102118
*/
103-
withCredentials: false
119+
withCredentials: false,
120+
104121
};
105122

106123
merge(options, this);

0 commit comments

Comments
 (0)