Skip to content

Add standalone schema resolution and comparison tools#62

Open
smrgeoinfo wants to merge 1 commit intoopengeospatial:masterfrom
smrgeoinfo:add-schema-tools
Open

Add standalone schema resolution and comparison tools#62
smrgeoinfo wants to merge 1 commit intoopengeospatial:masterfrom
smrgeoinfo:add-schema-tools

Conversation

@smrgeoinfo
Copy link

@smrgeoinfo smrgeoinfo commented Feb 15, 2026

Summary

Adds two standalone Python tools under tools/ for building block authors to work with schemas locally, without running the full Docker postprocess pipeline.

  • tools/resolve_schema.py — Recursively resolves all $ref references into a single fully-inlined, self-contained JSON Schema
  • tools/compare_schemas.py — Compares schema.yaml source files against companion JSON schemas, reporting structural inconsistencies
  • tools/README.md — Usage documentation with examples and option reference

Motivation

The postprocess Docker tool generates annotated schemas in build/annotated/, but these still contain $ref references to remote URLs. Building block authors currently have no standard way to produce a fully-resolved, self-contained JSON Schema from their source files — useful for:

  • Local validation (e.g., jsonschema.validate(data, resolved_schema))
  • Tooling integration (e.g., JSON Forms, IDE schema support)
  • Inspection and debugging (single file, no external dependencies)

These tools complement the postprocess pipeline by providing a lightweight, standalone alternative that works directly on _sources/ without Docker.

$ref patterns handled by resolve_schema.py

  1. Relative path: $ref: ../detailEMPA/schema.yaml
  2. Fragment-only: $ref: '#/$defs/Identifier'
  3. Cross-file fragment: $ref: ../metaMetadata/schema.yaml#/$defs/conformsTo_item
  4. bblocks:// URI: $ref: bblocks://ogc.geo.features.feature — resolved locally via bblocks-config.yaml identifier-prefix
  5. Both YAML and JSON file extensions

Testing

Tested against:

  • opengeospatial/bblocks — 12 building blocks indexed, all local bblocks:// refs fully resolved (including $defs fragment refs like bblocks://ogc.ogc-utils.iri-or-curie#/$defs/MultipleOrObjectOrNull)
  • opengeospatial/bblock-template — resolves mySchema and myFeature example building blocks
  • A production repo with 101 building blocks — compare_schemas.py checks 100 YAML/JSON pairs, all consistent

Related PRs

🤖 Generated with Claude Code

Standalone Python tools for building block authors to produce
fully-resolved, self-contained JSON Schemas from source files
and to check YAML/JSON schema consistency.

- resolve_schema.py: recursively resolves all $ref (relative,
  fragment, cross-file, and bblocks:// URI) into a single inlined
  JSON Schema for validation and tooling integration
- compare_schemas.py: compares schema.yaml against companion JSON
  schemas, reporting structural inconsistencies
- tools/README.md: usage docs, option reference, examples

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant