https://github.com/rangermauve/json-schema-from-path
A utility to get the sub-schema from a JSON-schema from the path in an object
https://github.com/rangermauve/json-schema-from-path
Last synced: 14 days ago
JSON representation
A utility to get the sub-schema from a JSON-schema from the path in an object
- Host: GitHub
- URL: https://github.com/rangermauve/json-schema-from-path
- Owner: RangerMauve
- License: mit
- Created: 2018-09-06T18:11:34.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-01-22T06:24:01.000Z (over 1 year ago)
- Last Synced: 2025-04-29T12:08:24.855Z (22 days ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 14
- Watchers: 3
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# json-schema-from-path
A utility to get the sub-schema from a JSON-schema from the path in an objectSupports schemas that use:
- `properties` (type object)
- `additionalProperties` (type object)
- `patternProperties` (type object)
- `items` (type array)
- paths that use either `/` or `.` as separators```javascript
var getSchemaFromPath = require("json-schema-from-path");var someSchema = {
properties: {
foo: {
properties: {
bar: {
type: "string"
}
}
}
}
};var mypath = "foo/bar";
var theSchema = getSchemaFromPath(someSchema, path);
theSchema === someSchema.properties.foo.properties.bar
```
If a schema object doesn't exist for the given path, `null` is returned.