json-schema-loader
Advanced tools
Comparing version
@@ -0,1 +1,2 @@ | ||
var loaderUtils = require('loader-utils'); | ||
var _ = require('lodash'); | ||
@@ -5,2 +6,4 @@ var RefParser = require('json-schema-ref-parser'); | ||
module.exports = function(source) { | ||
var query = loaderUtils.parseQuery(this.query); | ||
var callback = this.async(); | ||
@@ -10,3 +13,3 @@ var parser = new RefParser(); | ||
parser.dereference(this.resourcePath) | ||
parser.dereference(query.useSource ? JSON.parse(source) : this.resourcePath) | ||
.then(handleResolveSuccess.bind(this)) | ||
@@ -19,4 +22,4 @@ .catch(callback); | ||
_.map(parser.$refs.paths(), this.addDependency); | ||
callback(null, 'module.exports = ' + json + ';'); | ||
callback(null, 'module.exports = ' + json + ';', schema); | ||
} | ||
} |
{ | ||
"name": "json-schema-loader", | ||
"version": "0.0.3", | ||
"version": "1.0.0", | ||
"description": "Webpack loader that resolves Json Schema references.", | ||
@@ -14,5 +14,6 @@ "license": "BSD-3-Clause", | ||
"dependencies": { | ||
"lodash": "^4.10.0", | ||
"json-schema-ref-parser": "^3.0.2" | ||
"json-schema-ref-parser": "^3.0.2", | ||
"loader-utils": "^0.2.16", | ||
"lodash": "^4.10.0" | ||
} | ||
} |
# Json Schema Loader | ||
This package is part of the [doca](https://github.com/cloudflare/doca) suite. Please file any issues at the [doca repository](https://github.com/cloudflare/doca/issues) | ||
## Installation | ||
@@ -33,1 +35,7 @@ | ||
``` | ||
### Options | ||
#### `useSource: boolean` | ||
This loader normally passes the RefParser the `resourcePath`, not the source. If you want to chain loaders, make sure to set `useSource=true`. |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
7973
134.98%6
20%18
12.5%0
-100%41
24.24%3
50%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added