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

@stoplight/json-ref-resolver

Package Overview
Dependencies
Maintainers
20
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stoplight/json-ref-resolver - npm Package Compare versions

Comparing version 3.0.3 to 3.0.4

2

crawler.js

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

const targetPath = json_1.pointerToPath(targetPointer);
let referencesParent = true;
let referencesParent = targetPath.length > 0;
for (const i in targetPath) {

@@ -71,0 +71,0 @@ if (parentPath[i] !== targetPath[i]) {

{
"name": "@stoplight/json-ref-resolver",
"version": "3.0.3",
"version": "3.0.4",
"description": "Recursively resolve JSON pointers and remote authorities.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -1,10 +0,11 @@

# JSON Ref Resolver
# JSON Ref Resolver
[![Maintainability](https://api.codeclimate.com/v1/badges/0b1d841cc2445e29ef50/maintainability)](https://codeclimate.com/github/stoplightio/json-ref-resolver/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/0b1d841cc2445e29ef50/test_coverage)](https://codeclimate.com/github/stoplightio/json-ref-resolver/test_coverage)
[![Buy us a tree](https://img.shields.io/badge/Buy%20us%20a%20tree-%F0%9F%8C%B3-lightgreen)](https://offset.earth/stoplightinc)
[![CircleCI](https://circleci.com/gh/stoplightio/json-ref-resolver.svg?style=svg)](https://circleci.com/gh/stoplightio/json-ref-resolver)
Dereference $ref values in JSON Schema, OpenAPI (Swagger), and any other objects with $ref values inside of them.
Follow `$ref` values in JSON Schema, OpenAPI (formerly known as Swagger), and any other objects with `$ref` values inside of them.
- View the changelog: [Releases](https://github.com/stoplightio/json-ref-resolver/releases)
### Features
## Features

@@ -15,7 +16,7 @@ - **Performant**: Hot paths are memoized, remote URIs are resolved concurrently, and the minimum surface area is crawled and resolved.

- **Reference equality:** $refs to the same location will resolve to the same object in memory. [example test](src/__tests__/resolver.spec.ts#L329)
- **Flexible:** Bring your own resolvers for `http://`, `file://`, `mongo://`, `custom://`... etc.
- **Flexible:** Bring your own readers for `http://`, `file://`, `mongo://`, `custom://`... etc, or use [one of ours][json-ref-readers].
- **Cross Platform:** Supports POSIX and Windows style file paths.
- **Reliable:** Well tested to handle all sorts of circular reference edge cases.
### Installation
## Installation

@@ -25,7 +26,6 @@ Supported in modern browsers and node.

```bash
# latest stable
yarn add @stoplight/json-ref-resolver
```
### Usage
## Usage

@@ -67,3 +67,3 @@ All relevant types and options can be found in [src/types.ts](./src/types.ts).

#### Example: Basic Inline Dereferencing
### Example: Basic Inline Dereferencing

@@ -100,3 +100,3 @@ By default, only inline references will be dereferenced.

#### Example: Dereference a Subset of the Source
### Example: Dereference a Subset of the Source

@@ -147,3 +147,3 @@ This will dereference the minimal number of references needed for the given target, and return the target.

#### Example: Dereferencing Remote References with Resolvers
### Example: Dereferencing Remote References with Resolvers

@@ -212,3 +212,3 @@ By default only inline references (those that point to values inside of the original object) are dereferenced.

#### Example: Dereferencing Relative Remote References with the baseUri Option
### Example: Dereferencing Relative Remote References with the baseUri Option

@@ -253,14 +253,10 @@ If there are relative remote references (for example, a relative file path `../model.json`), then the location of the source

In the above example, the user \$ref will resolve to `/models/user.json`, because `../models/user.json` is resolved against the baseUri of the current document (which was indicated at `/specs/api.json`). Relative references will not work if the source document has no baseUri set.
In the above example, the user `$ref` will resolve to `/models/user.json`, because `../models/user.json` is resolved against the `baseUri` of the current document (which was indicated at `/specs/api.json`). Relative references will not work if the source document has no baseUri set.
### Contributing
This is a simplistic example of a reader. You can create your own, but we have built some [readers][json-ref-readers] which you might find useful.
1. Clone repo.
2. Create / checkout `feature/{name}`, `chore/{name}`, or `fix/{name}` branch.
3. Install deps: `yarn`.
4. Make your changes.
5. Run tests: `yarn test.prod`.
6. Stage relevant files to git.
7. Commit: `yarn commit`. _NOTE: Commits that don't follow the [conventional](https://github.com/marionebl/commitlint/tree/master/%40commitlint/config-conventional) format will be rejected. `yarn commit` creates this format for you, or you can put it together manually and then do a regular `git commit`._
8. Push: `git push`.
9. Open PR targeting the `develop` branch.
## Contributing
If you are interested in contributing to Spectral itself, check out our [contributing docs](CONTRIBUTING.md) to get started.
[json-ref-readers]: https://github.com/stoplightio/json-ref-readers/

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

let ref = new URI(refStr);
if (ref.toString().charAt(0) !== '#') {
if (refStr[0] !== '#') {
const isFile = this.isFile(ref);

@@ -103,3 +103,3 @@ if (isFile) {

const { val, ref, resolvingPointer, parentPointer, pointerStack } = opts;
const parentPath = (opts.parentPath || []).slice();
const parentPath = opts.parentPath ? opts.parentPath.slice() : [];
const uriCacheKey = this.computeUriCacheKey(ref);

@@ -303,3 +303,3 @@ const lookupResult = {

const pointerPath = json_1.pointerToPath(pointer);
const val = lodash_1.get(draft, pointerPath);
const val = pointerPath.length === 0 ? immer_1.original(draft) : lodash_1.get(draft, pointerPath);
for (const dependant of dependants) {

@@ -306,0 +306,0 @@ let isCircular;

@@ -27,7 +27,7 @@ "use strict";

exports.uriToJSONPointer = (uri) => {
return uri && uri.fragment() ? `#${uri.fragment()}` : '';
return uri.fragment() ? `#${uri.fragment()}` : '#';
};
exports.uriIsJSONPointer = (ref) => {
return ref.toString().slice(0, 2) === '#/';
return ref.path() === '';
};
//# sourceMappingURL=utils.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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