Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add --path Option to Target Specific Schema Parts in validate Command #220

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Karan-Palan
Copy link

What kind of change does this PR introduce?

  • Feature: Added support for the --path (or -p) option in the validate command to allow targeting specific parts of a JSON schema using JSON Pointers.

Issue Number:

Screenshots/videos:

Screencast.from.2025-02-02.12-53-07.webm

If relevant, did you update the documentation?

Not yet

Summary

This PR introduces the --path (-p) option to the validate command, enabling users to specify a JSON Pointer for validating a sub-schema within a larger JSON schema. This is especially useful for OpenAPI specs and complex JSON structures where validation may be needed for specific nested sections.

Key changes:

  • Added --path/-p option to CLI parser.
  • Integrated JSON Pointer resolution to extract the specified sub-schema.
  • Added error handling for invalid pointers or sub-schemas.

Does this PR introduce a breaking change?

  • No breaking changes. The new option is fully backward-compatible. Existing workflows without the --path option will continue to function as expected.

src/command_validate.cc Outdated Show resolved Hide resolved
@jviotti
Copy link
Member

jviotti commented Feb 3, 2025

Awesome! Great first step. Can you fix the formatting issues and add a couple of test cases (at least one where the pointer exists and one where it doesn't)?

@Karan-Palan Karan-Palan force-pushed the feat/add-path-to-validate branch 3 times, most recently from c14a91b to 7647e43 Compare February 3, 2025 09:42
@Karan-Palan Karan-Palan force-pushed the feat/add-path-to-validate branch from 7647e43 to c39d4c2 Compare February 3, 2025 09:48
@Karan-Palan
Copy link
Author

Awesome! Great first step. Can you fix the formatting issues and add a couple of test cases (at least one where the pointer exists and one where it doesn't)?

Thanks!
I fixed the linting errors - they were because my clang default was set to chromium's source. I also added some tests and docs (it's my first time writing tests in shell :p)
Please review when you get the time!

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.

Add a --path option to commands like validate
2 participants