Socket
Socket
Sign inDemoInstall

@json-schema-tools/traverse

Package Overview
Dependencies
0
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @json-schema-tools/traverse

This package exports a method that will traverse a JSON-Schema, calling a mutation function for each sub schema found. It is useful for building tools to work with JSON Schemas.


Version published
Weekly downloads
12K
increased by19.26%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

1.10.3 (2024-03-12)

Bug Fixes

  • add self-review suggestions (f1f95e5)
  • all tests passing (0c180b0)
  • bug fixed and tests fixed (6f9b06e)
  • parent fixups and testing (77a77f6)
  • simplify code a bit where possible (b3eae12)
  • undo debugging stuff (516cea9)

Readme

Source

JSON Schema Traverse

CircleCI branch npm GitHub release GitHub commits since latest release

This package exports a method that will traverse a JSON-Schema, calling a "mutation" function for each sub schema found. It is useful for building tools to work with JSON Schemas.

Features

  • circular reference detection & handling
  • synchronous - doesn't touch the filesystem or make network requests.
  • easily perform schema mutations while traversing
  • optional mutability (toggle updating original schema object)
  • returns JSONPaths as it traverses

Getting Started

npm install @json-schema-tools/traverse
const traverse = require("@json-schema-tools/traverse").default;
//import traverse from "@json-schema-tools/traverse"

const mySchema = {
  title: "baz",
  type: "object",
  properties: {
    foo: {
      title: "foo",
      type: "array",
      items: { type: "string" }
    },
    bar: {
      title: "bar",
      anyOf: [
        { title: "stringerific", type: "string" },
        { title: "numberoo", type: "number" }
      ]
    }
  }
};

traverse(mySchema, (schemaOrSubschema) => {
  console.log(schemaOrSubschema.title);
});

API Docs

https://json-schema-tools.github.io/traverse/

Features Todo

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.

FAQs

Last updated on 12 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc