{"id":48275,"library":"json-schema-from-path","title":"json-schema-from-path","description":"A utility to extract a sub-schema from a JSON Schema by traversing a path (using / or . separators). Version 2.0.1 is current. Supports properties, additionalProperties, patternProperties, and items. Returns null if no schema exists at path. Simple, no external dependencies. Lightweight alternative to full JSON Schema processors for path-based lookups.","status":"active","version":"2.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/RangerMauve/json-schema-from-path","tags":["javascript","json","schema","path","get","prop","property"],"install":[{"cmd":"npm install json-schema-from-path","lang":"bash","label":"npm"},{"cmd":"yarn add json-schema-from-path","lang":"bash","label":"yarn"},{"cmd":"pnpm add json-schema-from-path","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package does not provide ESM exports; using dynamic import may work but require is safe and documented.","wrong":"import getSchemaFromPath from 'json-schema-from-path';","symbol":"getSchemaFromPath","correct":"const getSchemaFromPath = require('json-schema-from-path');"},{"note":"Using named import will fail as the module exports a single function directly.","wrong":"import { getSchemaFromPath } from 'json-schema-from-path';","symbol":"default","correct":"import getSchemaFromPath from 'json-schema-from-path';"},{"note":"If using ESM dynamic import, the default export is under .default.","wrong":"const getSchemaFromPath = await import('json-schema-from-path');","symbol":"getSchemaFromPath","correct":"const { default: getSchemaFromPath } = await import('json-schema-from-path');"}],"quickstart":{"code":"const getSchemaFromPath = require('json-schema-from-path');\n\nconst schema = {\n  properties: {\n    user: {\n      properties: {\n        name: { type: 'string' }\n      }\n    }\n  }\n};\n\nconst path = 'user/name';\nconst subSchema = getSchemaFromPath(schema, path);\nconsole.log(subSchema); // { type: 'string' }","lang":"javascript","description":"Demonstrates using require to import the function, defining a schema, and retrieving the sub-schema at path 'user/name'."},"warnings":[{"fix":"Ensure properties are ordered as expected or use array paths consistently.","message":"Path order: The function traverses schema properties in the order they appear in the schema object. If properties are out of order, results may differ.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use if (subSchema === null) to detect missing paths.","message":"Null return: Returns null if path doesn't exist, not undefined. Code must check for null explicitly.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use only one separator consistently, e.g., always '/' or always '.'.","message":"Separator confusion: Paths using '/' and '.' are both supported, but mixing them may cause unexpected traversal.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'2.0.1':26 'additionalproperti':31 'altern':48 'base':57 'current':28 'depend':46 'exist':40 'extern':45 'extract':9 'full':50 'get':63 'item':34 'javascript':59 'json':2,16,51,60 'json-schema-from-path':1 'lightweight':47 'lookup':58 'null':36 'path':5,21,42,56,62 'path-bas':55 'patternproperti':32 'processor':53 'prop':64 'properti':30,65 'return':35 'schema':3,13,17,39,52,61 'separ':24 'simpl':43 'sub':12 'sub-schema':11 'support':29 'travers':19 'use':22 'util':7 'version':25","created_at":"2026-06-07T16:55:47.478688+00:00","updated_at":"2026-06-07T16:55:47.478688+00:00","problems":[{"fix":"Use const getSchemaFromPath = require('json-schema-from-path'); or import getSchemaFromPath from 'json-schema-from-path';","cause":"Using ES6 import incorrectly or destructuring the default export.","error":"TypeError: getSchemaFromPath is not a function"},{"fix":"Check if getSchemaFromPath returns null before accessing properties.","cause":"Accessing sub-properties on null result when path not found.","error":"Uncaught TypeError: Cannot read properties of undefined (reading 'properties')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/RangerMauve/json-schema-from-path#readme","github":"https://github.com/RangerMauve/json-schema-from-path","docs":null,"changelog":null,"pypi":null,"npm":"json-schema-from-path","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}