Skip to content

feat(python): add output schema validation and JSON Schema to Picoschema reverse conversion#540

Merged
yesudeep merged 1 commit intomainfrom
feat/python-schema-validation-and-parity
Feb 19, 2026
Merged

feat(python): add output schema validation and JSON Schema to Picoschema reverse conversion#540
yesudeep merged 1 commit intomainfrom
feat/python-schema-validation-and-parity

Conversation

@yesudeep
Copy link
Collaborator

Summary

Closes Python parity gaps in dotprompt by adding two new modules and updating the parity documentation.

Changes

New: Output Schema Validation (validate.py)

  • validate_output(data, schema) validates rendered output against JSON Schema using jsonschema (Draft 2020-12)
  • SchemaValidationError with structured error details (path + message for each violation)
  • 22 tests covering objects, arrays, enums, nested objects, missing required fields, additional properties, multiple errors

New: JSON Schema to Picoschema Reverse Conversion (picoschema_reverse.py)

  • json_schema_to_picoschema(schema) converts JSON Schema back to compact Picoschema notation
  • Supports objects, arrays, enums, wildcards ((*)), nullable types, descriptions, optional fields
  • 14 unit tests + 3 round-trip tests (Picoschema -> JSON Schema -> Picoschema)
  • Python is now the first runtime with this feature at full parity

Updated: DOTPROMPT_PARITY.md

Fixed stale Python entries where features were already implemented but marked as partial:

Feature Before After Evidence
Recursive partials partial full Code has cycle detection, spec tests pass
Schema validation partial full jsonschema validation added
Schema validation errors partial full SchemaValidationError with structured errors
JSON Schema to Picoschema partial full picoschema_reverse.py added
spec/helpers/ partial full All 81 spec tests pass
spec/partials.yaml partial full All spec tests pass
Spec Tests partial full 343+ tests total

Also marked Q1 2026 "Python specification test coverage" as done.

Dependency

  • Added jsonschema>=4.23.0 to pyproject.toml

Test Results

343 passed, 2 warnings in 1.11s

All existing tests continue to pass. 39 new tests added (22 validation + 17 reverse conversion).

@yesudeep yesudeep force-pushed the feat/python-schema-validation-and-parity branch 5 times, most recently from 2713a52 to a31a8df Compare February 19, 2026 18:21
…ema reverse conversion

- Add `validate.py`: output schema validation using jsonschema (Draft 2020-12)
  with SchemaValidationError providing structured error details
- Add `picoschema_reverse.py`: JSON Schema to Picoschema reverse conversion
  supporting objects, arrays, enums, wildcards, nullable types, and descriptions
- Add `jsonschema>=4.23.0` dependency to pyproject.toml
- Add 22 tests for schema validation (validate_test.py)
- Add 17 tests for reverse conversion including round-trip tests (picoschema_reverse_test.py)
- Update DOTPROMPT_PARITY.md: fix stale Python entries
  - Recursive partials: 🔶 → ✅ (cycle detection already implemented)
  - Schema validation: 🔶 → ✅ (jsonschema added)
  - Schema validation errors: 🔶 → ✅
  - JSON Schema → Picoschema: 🔶 → ✅ (reverse conversion added)
  - spec/helpers/: 🔶 → ✅ (all spec tests pass)
  - spec/partials.yaml: 🔶 → ✅ (all spec tests pass)
  - Spec Tests: 🔶 → ✅ (343+ tests)
  - Mark Q1 2026 Python spec test coverage as done
  - Update last-updated date to 2026-02-19

All 343 tests pass.
@yesudeep yesudeep force-pushed the feat/python-schema-validation-and-parity branch from a31a8df to 5371411 Compare February 19, 2026 18:25
@yesudeep yesudeep merged commit 5c0ea0a into main Feb 19, 2026
75 checks passed
@yesudeep yesudeep deleted the feat/python-schema-validation-and-parity branch February 19, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants