feat: add JSON Schema for ScenarioSpec, robots.txt pointer, and example templates#762
Open
mvanhorn wants to merge 1 commit intoauthorjapps:masterfrom
Open
feat: add JSON Schema for ScenarioSpec, robots.txt pointer, and example templates#762mvanhorn wants to merge 1 commit intoauthorjapps:masterfrom
mvanhorn wants to merge 1 commit intoauthorjapps:masterfrom
Conversation
…le templates Closes authorjapps#761. Adds a JSON Schema (Draft-07) describing the structure of a Zerocode scenario JSON file so: - IDEs (VS Code, IntelliJ) can validate and auto-complete scenario files - CLI users can validate scenarios with `ajv-cli` (or any Draft-07 tool) before runtime - AI tools generating scenarios have a contract to target The schema mirrors the Java POJOs in `core/src/main/java/.../domain/`: ScenarioSpec, Step, Retry, Validator, and Parameterized. All required fields (scenarioName, steps, validator.field, validator.value) are marked `required`; optional fields are listed but not required; free-form Jackson `JsonNode` properties (request, sort, assertions, verify, validator.value) accept any JSON type via union types. `additionalProperties: false` is set throughout to make typos catchable. The standard `$schema` pointer is whitelisted at the root so scenario files can self-describe their schema for IDE pickup. ## Files - `schema/zerocode-scenario-schema.json` — the schema - `robots.txt` — root-level pointer to the schema (per the issue) - `core/src/test/resources/templates/example_scenario_1.json` — typical REST flow with two steps, headers, retry, verify, and inter-step value resolution - `core/src/test/resources/templates/example_scenario_2.json` — parameterized scenario demonstrating both `valueSource` and `csvSource` (with `withHeaders`) - `README.md` — new "Configuration" section pointing to the schema with CLI / IDE / AI usage examples ## Verification Both examples and two existing real-world scenarios (`reports_e2e/two_step_scenario_1.json`, `reports_e2e/two_step_scenario_2.json`) validate successfully against the schema (verified with `jsonschema` Draft-07 validator).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #761.
Adds a JSON Schema (Draft-07) describing the structure of a Zerocode scenario JSON file so:
The schema mirrors the Java POJOs in `core/src/main/java/.../domain/`: `ScenarioSpec`, `Step`, `Retry`, `Validator`, and `Parameterized`. All required fields (`scenarioName`, `steps`, `validator.field`, `validator.value`) are marked `required`; optional fields are listed but not required; free-form Jackson `JsonNode` properties (`request`, `sort`, `assertions`, `verify`, `validator.value`) accept any JSON type via union types.
`additionalProperties: false` is set throughout to make typos catchable. The standard `$schema` pointer is whitelisted at the root so scenario files can self-describe their schema for IDE pickup.
Files
Verification
Both examples and two existing real-world scenarios (`reports_e2e/two_step_scenario_1.json`, `reports_e2e/two_step_scenario_2.json`) validate successfully against the schema (verified with the `jsonschema` Draft-07 validator).
Notes
The schema is intentionally permissive on free-form fields like `request`, `assertions`, and `verify` because the Java POJOs hold those as `JsonNode` (any JSON shape). Tightening these to specific shapes (e.g. `status` as integer, `headers` as object of strings) is a natural follow-up but would constrain valid scenarios that already exist in the repo, so I kept Draft-07 unions for parity with the current runtime behavior.
🤖 Authored with Claude Code