Analyze cyclic (recursive) dependencies in JSON Schema definitions. Version 3.0.0 is a pure ESM package requiring Node.js >=14.13.1 or >=16.0.0. Unlike alternatives, it offers both a full analysis (analyzeTypes) that returns detailed cycle information including entrypoints and a fast analysis (analyzeTypesFast) for large schemas where memory or performance is a concern. Only handles local definitions; external $ref must be resolved beforehand.
npm install json-schema-cyclesNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to use both analyzeTypes and analyzeTypesFast with a simple cyclic schema, printing cycles and graph.
Switch to import statements or use dynamic import() if in CommonJS environment.
Prefer analyzeTypesFast for large or deeply recursive schemas.
Use a JSON Schema ref parser like @apidevtools/json-schema-ref-parser to bundle references into a single schema before passing to json-schema-cycles.
Change to import { analyzeTypes } from 'json-schema-cycles' or use dynamic import() in a CommonJS file.Use import { analyzeTypes } from 'json-schema-cycles'.Switch to analyzeTypesFast which uses iterative approach and is safer.