Skip to content

feat: replace jsonschema with marshmallow for manifest validation - #71

Merged
amannocci merged 1 commit into
mainfrom
feat/marshmallow-validation
Sep 18, 2026
Merged

amannocci merged 1 commit into
mainfrom
feat/marshmallow-validation

Conversation

@amannocci

Copy link
Copy Markdown
Member

🧑‍💻What is the change being made?

Replaces the jsonschema dependency with marshmallow for manifest validation. Adds src/terranova/schemas/manifest.py with hand-written marshmallow.Schema classes (one per manifest version, 1.0-1.3, built via inheritance) and a MANIFEST_SCHEMAS registry, replaces the pkgutil/json/jsonschema.validate() call site in src/terranova/resources.py with a marshmallow schema.load() call, removes the four superseded manifest_schema_v*.json files, and swaps the jsonschema dependency for marshmallow in pyproject.toml.

❓ Why is the change being made?

jsonschema duplicated structure already expressed by the project's @serde dataclasses, and the project already leans on dataclasses throughout for serialization. This consolidates validation onto marshmallow for a more Pythonic API and better integration with existing patterns, closing #5.

✅ How has this been tested?

  • Existing tests/it/test_resources.py manifest-validation suite passes unmodified (missing/unreadable manifest, invalid YAML, the "missing version still fails" quirk, unsupported version, schema-validation failure, valid parse for versions 1.0-1.3).
  • Added two new cases to that suite: unknown/extra fields are still allowed, and an empty dependencies list is rejected.
  • Added tests/it/test_manifest_schemas.py with direct unit tests against each ManifestSchemaV1_x class.
  • Full suite (uv run poe test): 324 passed.
  • uv run poe lint (ruff + basedpyright): clean, 0 errors/0 warnings.
  • Manual end-to-end sanity check: terranova init against several tests/fixtures/*/manifest.yml fixtures (including a v1.2 manifest exercising the from/import/as renames) succeeds.

📚 How has this been documented?

Updated the four jsonschema references in .claude/CLAUDE.md to describe the new marshmallow-based validation and the src/terranova/schemas/manifest.py module.

🔗 Related Issues

Closes #5

Consolidates manifest validation onto marshmallow, reducing duplication
between the JSON Schema files and the existing @serde dataclasses while
preserving current validation behavior exactly (unknown fields allowed,
metadata fields not required, version still required despite its default).

Closes #5
@amannocci amannocci self-assigned this Sep 18, 2026
@amannocci
amannocci merged commit 3cf490e into main Sep 18, 2026
14 checks passed
@amannocci
amannocci deleted the feat/marshmallow-validation branch September 18, 2026 13:09
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.

[Feature]: Replace jsonschema with marshmallow for validation

1 participant