Skip to content

UnitVectorY-Labs/jsonschemaprofiles

Repository files navigation

GitHub release License Active Go Report Card

jsonschemaprofiles

A Go library and CLI tool for validating that JSON Schema documents conform to provider-specific structured-output restrictions (for example Gemini and OpenAI).

This project is about schema-profile validation—it validates schemas themselves, not JSON data instances.

Overview

LLM providers that support structured JSON output each accept only a subset of JSON Schema. A schema that works with one provider may be rejected by another. This library:

  • Validates schemas against provider profiles using a two-phase model
  • Coerces schemas toward compliance with minimal, traceable changes
  • Embeds all profile meta-schemas for zero-config usage
  • Provides both a Go library API and a CLI

Installation

Go Library

go get github.com/UnitVectorY-Labs/jsonschemaprofiles

CLI

go install github.com/UnitVectorY-Labs/jsonschemaprofiles/cmd/jsonschemaprofiles@latest

Or download a pre-built binary from Releases.

Quick Start

Library

import jsp "github.com/UnitVectorY-Labs/jsonschemaprofiles"

// Validate a schema against a profile
report, err := jsp.ValidateSchema(jsp.OPENAI_202602, schemaBytes, nil)
if !report.Valid {
    fmt.Println(report.Text())
}

// Coerce a schema for compliance
coerced, report, changed, err := jsp.CoerceSchema(jsp.OPENAI_202602, schemaBytes, &jsp.CoerceOptions{
    Mode: jsp.CoerceModeConservative,
})

CLI

# List profiles
jsonschemaprofiles profiles list

# Validate
jsonschemaprofiles validate schema --profile OPENAI_202602 --in schema.json

# Coerce
jsonschemaprofiles coerce schema --profile OPENAI_202602 --in schema.json --out fixed.json

Available Profiles

Profile ID Description
OPENAI_202602 OpenAI Structured Outputs subset
GEMINI_202602 Gemini baseline structured output
GEMINI_202503 Gemini 2.0 with required propertyOrdering
MINIMAL_202602 Lowest common denominator across providers

License

See LICENSE for details.

About

A Go library for validating and adapting JSON Schemas to constrained subsets used for predictable JSON output, such as LLM structured responses.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors