Skip to content

Add JSON Schemas for features - #62

Open
ppkarwasz wants to merge 1 commit into
apache:mainfrom
ppkarwasz:feat/json-schema
Open

Add JSON Schemas for features#62
ppkarwasz wants to merge 1 commit into
apache:mainfrom
ppkarwasz:feat/json-schema

Conversation

@ppkarwasz

@ppkarwasz ppkarwasz commented Apr 10, 2025

Copy link
Copy Markdown
Member

This change documents the available .asf.yaml options as composable draft-07 JSON Schemas.

Since features live in separate Python modules, the schemas are composable too: each feature's schema sits next to the module that validates it (e.g. asfyaml/feature/notifications.schema.json, asfyaml/feature/github/rulesets.schema.json), and the root asfyaml/asfyaml.schema.json wires them together through relative $refs. The $id of every file is its raw.githubusercontent.com URL and mirrors its path in the repository, so refs resolve both on disk and over HTTP. Editors can therefore validate a repository's .asf.yaml with a single comment:

# yaml-language-server: $schema=https://raw.githubusercontent.com/apache/infrastructure-asfyaml/refs/heads/main/asfyaml/asfyaml.schema.json

Coverage matches the current validators on main: all root keys (meta, notifications, project, github, pelican, jekyll, publish, staging), the full github feature set (branch protection, rulesets in both raw and convenience styles, deployment environments, merge buttons, custom subjects, pull requests, Copilot code review, etc.), and constraints that are only enforced at runtime today (enums, label limits, wait_timer range, ASF mailing list pattern).

A new test module (tests/json_schema.py) checks every schema against the draft-07 metaschema, enforces the $id/path mirroring, and validates known-good and known-bad .asf.yaml samples with all refs resolved offline. jsonschema is added as a test-only dependency.

@ppkarwasz

Copy link
Copy Markdown
Member Author

@netomi,

Personally I would like to validate the .asf.yaml schemas against JSON schemas published to infra.apache.org, but I would settle on apache.github.io. Where should I put the schema files in this repo's folder hierarchy?

@potiuk

potiuk commented May 3, 2026

Copy link
Copy Markdown
Member

Nice. I think this schema could also be used to validate asf.yaml when it is parsed. And I think - keeping the schema in here in github with "raw" URL is probably not a bad idea?

Documents the .asf.yaml configuration format as draft-07 JSON Schemas.
Each feature's schema lives next to the Python module that validates it,
and the root schema composes them through relative $ref, so a feature
and its schema can evolve in the same place. The $id of each file is its
raw.githubusercontent.com URL and mirrors its path in the repository,
which makes the refs resolve both on disk and over HTTP.

A new test module checks every schema against the draft-07 metaschema,
enforces the $id/path mirroring, and validates known-good and known-bad
.asf.yaml samples against the root schema with all refs resolved
offline.

Assisted-By: Claude Fable 5 <noreply@anthropic.com>
@ppkarwasz
ppkarwasz marked this pull request as ready for review August 13, 2026 16:02
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.

2 participants