Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hyperjump/json-reference

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hyperjump/json-reference - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

29

dist/json-reference.js

@@ -49,3 +49,3 @@ "use strict";

var doc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : nil;
var resolvedUrl, response, result, resultValue;
var resolvedUrl, response, result, resultValue, id;
return regeneratorRuntime.wrap(function _callee$(_context) {

@@ -70,5 +70,25 @@ while (1) {

resultValue = value(result);
return _context.abrupt("return", isRef(resultValue) ? get(resultValue["$ref"], result) : result);
case 12:
if (!isRef(resultValue)) {
_context.next = 15;
break;
}
return _context.abrupt("return", get(resultValue["$ref"], result));
case 15:
if (!isId(resultValue)) {
_context.next = 21;
break;
}
id = resultValue["$id"];
delete resultValue["$id"];
return _context.abrupt("return", construct(id, resultValue));
case 21:
return _context.abrupt("return", result);
case 22:
case "end":

@@ -92,2 +112,5 @@ return _context.stop();

};
var isId = function isId(value) {
return isObject(value) && "$id" in value;
};

@@ -94,0 +117,0 @@ var append = function append(doc, key) {

2

package.json
{
"name": "@hyperjump/json-reference",
"version": "0.4.0",
"version": "0.5.0",
"description": "An implementation of JSON Reference",

@@ -5,0 +5,0 @@ "main": "./dist/json-reference.js",

@@ -30,6 +30,3 @@ JSON Reference

"foo": "bar",
"aaa": {
"bbb": 222,
"$ref": "#/foo"
},
"aaa": { "$ref": "#/foo" },
"ccc": { "$ref": "#/aaa" },

@@ -40,3 +37,7 @@ "ddd": {

},
"eee": ["a", { "$ref": "#/ddd/111" }]
"eee": ["a", { "$ref": "#/ddd/111" }],
"fff": {
"$id": "http://json-reference.hyperjump.io/example2",
"abc": 123
}
}

@@ -104,3 +105,4 @@ ```

authors as a starting point and evolve the concept from there. Therefore, this
implementation is not the same JSON Reference used by JSON Schema.
implementation IS NOT the same JSON Reference used in recent drafts of JSON
Schema.

@@ -125,3 +127,3 @@ Documentation

```http
GET /example#/foo HTTP/1.1
GET /example#/aaa HTTP/1.1
Accept: application/reference+json

@@ -141,5 +143,3 @@ ```

},
"ccc": {
"$ref": "#/aaa"
}
"ccc": { "$ref": "#/aaa" }
}

@@ -158,12 +158,19 @@ ```

When the "value" is an object with a `$ref` property, this should result in a
redirect to the URL defined by the `$ref`.
When the "value" is an object with a `$ref` property, it should be like following
a link to the URL defined by the `$ref`. It's a little like an iframe in HTML.
It's a document within a document.
Unlike JSON Reference draft-03, properties adjacent to a `$ref` property are not
ignored, but they are often shadowed. In the example above, when we request
`/example#/aaa/bbb` we get `222`, but if we're iterating over each of the
properties in the response, when we get to `/example#/aaa` we get redirected to
`/foo` and `/aaa/bbb` is never reached.
When the "value" is an object with an "$id" property, it should be interpreted
as a separate JSON Reference document embedded in the document. The `$id` is
equivalent to `$ref` if the `$ref` were followed and inlined into the document.
This is a little like the HTTP/2 server push feature. It's sending additional
documents with the request because we know the client is just going to request
those documents next.
Implementations are discouraged from inlining referenced documents. Inlining is
possible, but there are issues that we won't get into here.
The JSON Pointer fragment is not aware of the semantics of the `$ref` and `$id`
keywords. Therefore, it is possible to point to values that don't make sense
for a JSON Reference document. In the example above, we can request
`/example#/aaa/bbb` and get `222` even though `/example#/aaa` is a reference.
We allow this because we don't want JSON Pointer implementations to have to be
aware of JSON Reference, but doing things like this is highly discouraged and
will cause problems when inlining documents with `$id`.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc