or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-10/

JSON Schema Path Analyzer

Build a tool that analyzes JSON Schema documents and generates a detailed report about schema structure using path information.

Requirements

Your tool should traverse a JSON Schema and collect information about each schema object, then generate a structured report showing:

  1. Schema paths: List all schema objects with their JSON Pointer paths
  2. Schema types: For each schema object, include its type if defined
  3. Parent information: Show parent-child relationships including which keyword contains each schema
  4. Nesting depth: Calculate and report the depth of each schema in the tree

The tool should export a function analyzeSchema(schema) that:

  • Takes a JSON Schema object as input
  • Returns an object containing:
    • paths: An array of objects with path, type, parent, parentKeyword, and depth properties
    • maxDepth: The maximum nesting depth found in the schema
    • totalSchemas: The total count of schema objects found

Implementation

@generates

API

/**
 * Analyzes a JSON Schema document and returns structural information
 * @param {Object} schema - The JSON Schema to analyze
 * @returns {Object} Analysis results with paths, maxDepth, and totalSchemas
 */
function analyzeSchema(schema) {
  // Implementation here
}

module.exports = { analyzeSchema };

Test Cases

  • Analyzing a schema with nested properties returns correct paths with parent information @test
  • Analyzing a schema with array keywords (allOf, anyOf) includes array index information @test
  • The analyzer correctly calculates nesting depth for deeply nested schemas @test
  • Root schema is included with empty string path and depth 0 @test

Dependencies { .dependencies }

json-schema-traverse { .dependency }

Provides JSON Schema traversal functionality with rich contextual information about each schema object's location and relationships.

@satisfied-by