Détail du package

@json-schema-tools/reference-resolver

json-schema-tools146.7kApache-2.01.2.6

Turns a $ref into a JSONSchema

readme

JSON Schema Reference Resolver

CircleCI branch npm GitHub release GitHub commits since latest release

Takes a $ref string and a root object, and returns the referenced value.

Works in browser & in node (file system refs ignored in browser).

Easily add support for your own protocols.

Getting Started

npm install @json-schema-tools/reference-resolver

import refRes from "@json-schema-tools/reference-resolver";

refRes.resolve("#/properties/foo", { properties: { foo: true } }); // returns true
refRes.resolve("https://foo.com/"); // returns what ever json foo.com returns
refRef.resolve("../my-object.json"); // you get teh idea

Adding custom protocol handlers

import referenceResolver from "@json-schema-tools/reference-resolver";
import JSONSchema from "@json-schema-tools/meta-schema";

referenceResolver.protocolHandlerMap.ipfs = (uri) => {
   const pretendItsFetchedFromIpfs = {
     title: "foo",
     type: "string",
   } as JSONSchema;
   return Promise.resolve(fetchedFromIpfs);
};

referenceResolver.protocolHandlerMap["customprotocol"] = (uri) => {
   return Promise.resolve({
     type: "string",
     title: uri.replace("customprotocol://", ""),
   });
};

referenceResolver.resolve("ipfs://80088008800880088008");
referenceResolver.resolve("customprotocol://foobar");

Contributing

How to contribute, build and release are outlined in CONTRIBUTING.md, BUILDING.md and RELEASING.md respectively. Commits in this repository follow the CONVENTIONAL_COMMITS.md specification.

changelog

1.2.6 (2024-05-07)

Bug Fixes

1.2.5 (2022-10-05)

Bug Fixes

  • bump node version in circle and update container (f1d596a)
  • remove dead readme badge (1733530)
  • typedoc building again (5b2a179)
  • update linting and bump all versions (4e81683)

1.2.4 (2022-03-18)

Bug Fixes

  • node version for CirceCI (e111a7c)
  • This corrects the behavior for nested resolution for json schemas. (497c56f)

1.2.3 (2021-06-24)

Bug Fixes

1.2.2 (2021-06-08)

Bug Fixes

1.2.1 (2021-05-10)

Bug Fixes

1.2.0 (2021-05-10)

Features

1.1.1 (2020-11-03)

Bug Fixes

  • refactor code into shared method (794a8ce)
  • return a promise once again (772302d)
  • use hashless ref for urls (f278761)

1.1.0 (2020-10-28)

Bug Fixes

  • make test coverage 100 and fix test case (84da5c8)

Features

  • handle hash fragment of json pointers (dd85381)

1.0.7 (2020-10-27)

Bug Fixes

  • browser build mock fs not working still (ffadb24)

1.0.6 (2020-10-27)

Bug Fixes

1.0.5 (2020-10-27)

Bug Fixes

  • restore browser support (61e766c)

1.0.4 (2020-10-23)

Bug Fixes

1.0.3 (2020-10-23)

Bug Fixes

1.0.2 (2020-10-17)

Bug Fixes

  • add more tests to clarify file reference relativity (485fcbb)
  • handle filepath error checks differently (8e7e69f)
  • update node version (1779adb)
  • update remaining deps (d4e2b62)
  • update typing deps (b7c0678)

1.0.1 (2020-10-17)

Bug Fixes

1.0.0 (2020-07-23)

Bug Fixes

Features

1.1.0 (2020-07-21)

Bug Fixes

  • remove hold (df2f3bb)
  • update package json meta a little bit (cb257fe)

Features

  • update to new meta schema and traverse (b42fb4a)

1.0.15 (2020-07-20)

Bug Fixes

1.0.14 (2020-07-15)

Bug Fixes

1.0.13 (2020-07-07)

Bug Fixes

  • remove definitions key after dereffing (ed43c3f)

1.0.12 (2020-07-07)

Bug Fixes

1.0.11 (2020-07-07)

Bug Fixes

  • update traverse with cycle fix (2371305)

1.0.10 (2020-07-06)

Bug Fixes

1.0.9 (2020-07-06)

Bug Fixes

  • add test that infinite loops. bed time fuck this shit (d269fe5)
  • pre-refactoring (cf25929)
  • remove commented out garbage (b2ede0a)
  • tests passing but logs after tests finish still somehow (06f2a07)

1.0.8 (2020-07-03)

Bug Fixes

1.0.7 (2020-07-01)

Bug Fixes

1.0.6 (2020-07-01)

Bug Fixes

1.0.5 (2020-06-30)

Bug Fixes

1.0.4 (2020-06-30)

Bug Fixes

1.0.3 (2020-06-27)

Bug Fixes

1.0.2 (2020-06-27)

Bug Fixes

1.0.1 (2020-06-26)

Bug Fixes

  • add funding (ffda6d9)
  • put hold in parallel with test and build (479ed2f)

1.0.0 (2020-06-26)

Bug Fixes

Features