{"id":13547554,"url":"https://github.com/cvent/json-schema-deref","last_synced_at":"2026-01-27T06:51:32.849Z","repository":{"id":26495853,"uuid":"29948186","full_name":"cvent/json-schema-deref","owner":"cvent","description":"json-schema dereference utility","archived":false,"fork":false,"pushed_at":"2026-01-22T01:11:21.000Z","size":657,"stargazers_count":39,"open_issues_count":18,"forks_count":16,"subscribers_count":4,"default_branch":"master","last_synced_at":"2026-01-22T15:03:57.173Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://bojand.github.io/json-schema-deref","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cvent.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-01-28T03:16:01.000Z","updated_at":"2024-08-31T16:05:15.000Z","dependencies_parsed_at":"2025-04-02T20:31:50.776Z","dependency_job_id":"498f0780-37db-4355-b57c-b47aad1e27cc","html_url":"https://github.com/cvent/json-schema-deref","commit_stats":null,"previous_names":["bojand/json-schema-deref"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/cvent/json-schema-deref","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cvent%2Fjson-schema-deref","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cvent%2Fjson-schema-deref/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cvent%2Fjson-schema-deref/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cvent%2Fjson-schema-deref/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cvent","download_url":"https://codeload.github.com/cvent/json-schema-deref/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cvent%2Fjson-schema-deref/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28806722,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T06:25:51.065Z","status":"ssl_error","status_checked_at":"2026-01-27T06:25:50.640Z","response_time":168,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T12:00:57.954Z","updated_at":"2026-01-27T06:51:32.827Z","avatar_url":"https://github.com/cvent.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# json-schema-deref\n\n[![npm version](https://img.shields.io/npm/v/json-schema-deref.svg?style=flat-square)](https://www.npmjs.com/package/json-schema-deref)\n[![build status](https://img.shields.io/travis/bojand/json-schema-deref/master.svg?style=flat-square)](https://travis-ci.org/bojand/json-schema-deref)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](https://standardjs.com)\n[![License](https://img.shields.io/github/license/bojand/json-schema-deref.svg?style=flat-square)](https://raw.githubusercontent.com/bojand/json-schema-deref/master/LICENSE)\n\nDereference JSON pointers in a JSON schemas with their true resolved values.\nA lighter synchronous version of this module is available as [json-schema-deref-sync](https://github.com/bojand/json-schema-deref-sync),\nbut omits web references and custom loaders.\n\n## Installation\n\n`npm install json-schema-deref`\n\n## Overview\n\nLet's say you have the following JSON Schema:\n\n```json\n{\n  \"description\": \"Just some JSON schema.\",\n  \"title\": \"Basic Widget\",\n  \"type\": \"object\",\n  \"definitions\": {\n    \"id\": {\n      \"description\": \"unique identifier\",\n      \"type\": \"string\",\n      \"minLength\": 1,\n      \"readOnly\": true\n    }\n  },\n  \"properties\": {\n    \"id\": {\n      \"$ref\": \"#/definitions/id\"\n    },\n    \"foo\": {\n      \"$ref\": \"http://www.mysite.com/myschema.json#/definitions/foo\"\n    },\n    \"bar\": {\n      \"$ref\": \"bar.json\"\n    }\n  }\n}\n```\n\nSometimes you just want that schema to be fully expanded, with `$ref`'s being their (true) resolved values:\n\n```json\n{\n  \"description\": \"Just some JSON schema.\",\n  \"title\": \"Basic Widget\",\n  \"type\": \"object\",\n  \"definitions\": {\n    \"id\": {\n      \"description\": \"unique identifier\",\n      \"type\": \"string\",\n      \"minLength\": 1,\n      \"readOnly\": true\n    }\n  },\n  \"properties\": {\n    \"id\": {\n      \"description\": \"unique identifier\",\n      \"type\": \"string\",\n      \"minLength\": 1,\n      \"readOnly\": true\n    },\n    \"foo\": {\n      \"description\": \"foo property\",\n      \"readOnly\": true,\n      \"type\": \"number\"\n    },\n    \"bar\": {\n      \"description\": \"bar property\",\n      \"type\": \"boolean\"\n    }\n  }\n}\n```\n\nThis utility lets you do that:\n\n\n```js\nvar deref = require('json-schema-deref');\nvar myschema = require('schema.json');\n\nderef(myschema, function(err, fullSchema) {\n  console.dir(fullSchema); // has the full expanded $refs\n});\n```\n\n## API Reference\n\n\u003ca name=\"deref\"\u003e\u003c/a\u003e\n\n### deref(schema, options, fn)\nDerefs \u003ccode\u003e$ref\u003c/code\u003e's in JSON Schema to actual resolved values. Supports local, file and web refs.\n\n**Kind**: global function  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| schema | \u003ccode\u003eObject\u003c/code\u003e | The JSON schema |\n| options | \u003ccode\u003eObject\u003c/code\u003e | options |\n| options.baseFolder | \u003ccode\u003eString\u003c/code\u003e | the base folder to get relative path files from. Default is \u003ccode\u003eprocess.cwd()\u003c/code\u003e |\n| options.cache | \u003ccode\u003eString\u003c/code\u003e | whether to cache the result from the request. Default: \u003ccode\u003etrue\u003c/code\u003e. |\n| options.cacheTTL | \u003ccode\u003eNumber\u003c/code\u003e | the time to keep request result in cache. Default is \u003ccode\u003e5 minutes\u003c/code\u003e. |\n| options.failOnMissing | \u003ccode\u003eBoolean\u003c/code\u003e | By default missing / unresolved refs will be left as is with their ref value intact.                                        If set to \u003ccode\u003etrue\u003c/code\u003e we will error out on first missing ref that we cannot                                        resolve. Default: \u003ccode\u003efalse\u003c/code\u003e. |\n| options.loader | \u003ccode\u003efunction\u003c/code\u003e | a function for custom loader. Invoked if we could not resolve the ref type,                                  or if there was an error resolving a web or file ref types.                                  function with signature: \u003ccode\u003efunction(refValue, options, fn)\u003c/code\u003e                                  \u003ccode\u003erefValue\u003c/code\u003e - the string value of the ref being resolved. Ex: \u003ccode\u003edb://my_database_id\u003c/code\u003e                                  \u003ccode\u003eoptions\u003c/code\u003e - options parameter passed to \u003ccode\u003ederef\u003c/code\u003e                                  \u003ccode\u003efn\u003c/code\u003e - the final callback function, in form \u003ccode\u003efunction(err, newValue)\u003c/code\u003e                                  \u003ccode\u003eerr\u003c/code\u003e - error if ref is valid for the loader but there was an error resolving the ref.                                  If used in combination with \u003ccode\u003efailOnMissing\u003c/code\u003e option it will abort the whole deref process.                                  \u003ccode\u003enewValue\u003c/code\u003e - the resolved ref value, or \u003ccode\u003enull\u003c/code\u003e or \u003ccode\u003eundefined\u003c/code\u003e if the ref isn't for this custom                                  \u003ccode\u003eloader\u003c/code\u003e and we should just leave the \u003ccode\u003e$ref\u003c/code\u003e as is. |\n| options.mergeAdditionalProperties | \u003ccode\u003eBoolean\u003c/code\u003e | By default properties in a object with $ref will be removed in the output.                                                    If set to \u003ccode\u003etrue\u003c/code\u003e they will be added/overwrite the output.                                                    Default: \u003ccode\u003efalse\u003c/code\u003e. |\n| options.removeIds | \u003ccode\u003eBoolean\u003c/code\u003e | By default \u003ccode\u003e$id\u003c/code\u003e fields will get copied when dereferencing.                                    If set to \u003ccode\u003etrue\u003c/code\u003e they will be removed.                                    Default: \u003ccode\u003efalse\u003c/code\u003e. |\n| fn | \u003ccode\u003efunction\u003c/code\u003e | The final callback in form \u003ccode\u003e(error, newSchema)\u003c/code\u003e |\n\n## Custom Loader\n\nLet's say we want to get $ref's from a MongoDB database, and our `$ref` objects in the JSON Schema might be something like:\n\n```json\n\"foo\": {\n  \"$ref\":\"mongodb:507c35dd8fada716c89d0013\"\n}\n```\n\nOur custom loader function passed in the `options` `loader` parameter would look something like:\n\n```js\nfunction myMongoDBLoader(ref, option, fn) {\n  if(ref.indexOf('mongodb:') === 0) {\n    var id = ref.substring(8);\n    return collection.findOne({_id:id}, fn);\n  }\n\n  // not ours, pass back nothing to keep it the same\n  // or pass error and use failOnMissing to abort\n  return fn();\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcvent%2Fjson-schema-deref","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcvent%2Fjson-schema-deref","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcvent%2Fjson-schema-deref/lists"}