or run

npx @tessl/cli init
Log in

Version

Files

docs

index.md
tile.json

task.mdevals/scenario-6/

JSON Schema Path Extractor

Build a utility that extracts all JSON Pointer paths from a JSON Schema document using schema traversal.

Requirements

Create a function extractPaths that takes a JSON Schema object and returns an array of all JSON Pointer paths found in the schema.

The function should:

  • Accept a JSON Schema object as input
  • Traverse the entire schema structure
  • Collect all JSON Pointer paths encountered during traversal
  • Return an array of path strings sorted alphabetically
  • Handle schemas with nested structures (properties, items, allOf, etc.)

Implementation

@generates

API

/**
 * Extracts all JSON Pointer paths from a JSON Schema.
 *
 * @param {object} schema - A JSON Schema object
 * @returns {string[]} Array of JSON Pointer paths, sorted alphabetically
 */
function extractPaths(schema) {
  // IMPLEMENTATION HERE
}

module.exports = { extractPaths };

Test Cases

  • Given a schema with properties "foo" and "bar", returns paths: "", "/properties/bar", "/properties/foo" @test
  • Given a schema with nested properties (properties.user.properties.name), returns all nested paths including "/properties/user", "/properties/user/properties/name" @test
  • Given an empty schema object, returns only the root path "" @test

Dependencies { .dependencies }

json-schema-traverse { .dependency }

Provides schema traversal functionality.

@satisfied-by