feat: add ParseResult JSON schema output#14
feat: add ParseResult JSON schema output#14abhijeetnardele24-hash wants to merge 1 commit intovericontext:mainfrom
Conversation
Signed-off-by: abhijeet nardele <234410808+abhijeetnardele24-hash@users.noreply.github.com>
|
@abhijeetnardele24-hash is attempting to deploy a commit to the Kiyeon Jeon's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
Adds a CLI surface for exporting the Pydantic JSON Schema for ParseResult, enabling external tools to validate parsemux JSON output (per Issue #12).
Changes:
- Extend
parsemux schemawith--output-schemato printParseResult.model_json_schema()as JSON. - Add CLI tests covering schema output (and version output).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/parsemux/cli/main.py |
Adds --output-schema handling to print the ParseResult JSON Schema. |
tests/test_cli.py |
Adds Typer CLI tests for schema --output-schema (and version output assertions). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def test_version_flag_outputs_version() -> None: | ||
| result = runner.invoke(app, ["--version"]) | ||
|
|
||
| assert result.exit_code == 0 | ||
| assert result.stdout.strip() == f"parsemux {__version__}" | ||
|
|
||
|
|
There was a problem hiding this comment.
--version isn’t implemented in the Typer app (no callback/option defines it in src/parsemux/cli/main.py), so this test will fail with an “No such option: --version” error. Either add a global --version option on the app callback (printing parsemux {__version__}) or remove this test if only the version subcommand is supported.
| def test_version_flag_outputs_version() -> None: | |
| result = runner.invoke(app, ["--version"]) | |
| assert result.exit_code == 0 | |
| assert result.stdout.strip() == f"parsemux {__version__}" |
| def schema( | ||
| command: Optional[str] = typer.Argument(None, help="Command name (omit for all)"), | ||
| output_schema: bool = typer.Option(False, "--output-schema", help="Print the ParseResult JSON Schema"), | ||
| ) -> None: | ||
| """Show machine-readable schema for CLI commands (for AI agents).""" | ||
| if output_schema: | ||
| from parsemux.core.models import ParseResult | ||
|
|
||
| typer.echo(json.dumps(ParseResult.model_json_schema(), indent=2)) | ||
| return |
There was a problem hiding this comment.
The schema command docstring says it shows machine-readable schemas for CLI commands, but with --output-schema it outputs the Pydantic JSON Schema for ParseResult instead. Please update the docstring/help text (and the command-schemas payload below, if that’s meant to be complete for agents) to reflect this additional behavior/flag.
kiyeonjeon21
left a comment
There was a problem hiding this comment.
Nice work, this is a useful addition for AI agents!
One thing: this PR has a merge conflict with #13 on tests/test_cli.py (both create the same file). Once #13 is merged, please rebase this branch:
git fetch origin
git rebase origin/mainThe test file in #13 already has the version tests, so you'd just need to add your test_schema_output_schema_prints_parse_result_schema to it.
Code itself looks good — will approve after rebase.
Adds parsemux schema --output-schema to print the ParseResult Pydantic JSON Schema. Also adds a CLI test for the new output.
Closes #12