or run

npx @tessl/cli init
Log in

Version

Files

docs

index.md
tile.json

task.mdevals/scenario-9/

JSON Schema Analyzer

A utility that analyzes JSON Schema documents and collects information about all schema objects within them.

Capabilities

Schema Collection

Build a tool that traverses a JSON Schema document and collects all schema objects into an array. The tool should visit every schema object in the document, including nested schemas within properties, items, definitions, and other schema-containing keywords.

  • Given a schema with properties {properties: {name: {type: 'string'}, age: {type: 'number'}}}, the tool returns an array containing 3 schema objects: the root schema, the name schema, and the age schema @test
  • Given an empty schema {}, the tool returns an array with only the root schema object @test

Schema Type Filtering

Extend the tool to filter and collect only schemas of a specific type. The tool should traverse the entire schema document and return only those schema objects that match a given type.

  • Given a schema with multiple types and filtering for 'string' types, the tool returns only schema objects where type === 'string' @test
  • Given a schema with no schemas matching the filter type, the tool returns an empty array @test

Implementation

@generates

API

/**
 * Collects all schema objects from a JSON Schema document.
 *
 * @param {object} schema - The JSON Schema document to analyze.
 * @returns {Array<object>} An array of all schema objects found in the document.
 */
function collectSchemas(schema) {
  // IMPLEMENTATION HERE
}

/**
 * Collects schema objects of a specific type from a JSON Schema document.
 *
 * @param {object} schema - The JSON Schema document to analyze.
 * @param {string} typeFilter - The type to filter for (e.g., 'string', 'number', 'object').
 * @returns {Array<object>} An array of schema objects matching the specified type.
 */
function collectSchemasByType(schema, typeFilter) {
  // IMPLEMENTATION HERE
}

module.exports = {
  collectSchemas,
  collectSchemasByType
};

Dependencies { .dependencies }

json-schema-traverse { .dependency }

Provides schema traversal functionality for visiting all schema objects in a JSON Schema document.

@satisfied-by