Skip to content

Conversation

@Vaibhav701161
Copy link

Adds stdin support for instance input to enable real-time editor diagnostics.
Fixes(#537)

  • Centralized stdin parsing in src/input.h (JSON-first, YAML fallback).
  • validate accepts instances from stdin only; schemas must be file paths.
  • Stdin inputs resolve relative $ref against the current working directory.
  • Includes integration test test/validate/pass_stdin.sh.
  • Unblocks sourcemeta/studio#61; addresses sourcemeta/jsonschema#537.

Refs: sourcemeta/studio#61, #537

*Build and test:
Screenshot 2026-01-15 145159

@Vaibhav701161 Vaibhav701161 force-pushed the feat/stdin-validate branch 2 times, most recently from ddb8312 to 9a040d7 Compare January 15, 2026 10:07
@Vaibhav701161
Copy link
Author

Hi @jviotti , I’ve opened this PR and would appreciate a review when you have time. Thanks!

@jviotti
Copy link
Member

jviotti commented Jan 19, 2026

Hey @Vaibhav701161 , sorry for the delay. It has been a hectic week. I'll try to get into it today

@jviotti
Copy link
Member

jviotti commented Jan 19, 2026

I like the idea but I think there are some things to iron out:

  • If we accept standard input, we should do so in ALL commands, otherwise it gets weird
  • Some commands require a schema as input but for others, passing nothing means "the current directory", which introduces some ambiguity. For example, jsonschema fmt formats all schemas in the current directory, while jsonschema inspect <schema.json> requires a single schema argument
  • Furthermore, some commands require 2 schemas, like validate

I think for consistency, we can require the - to signify standard input in every command. However, for commands take potentially take directories as input, we should transparently implement this logic on src/input.h. So it happens out of the box.

The other problem here will be line numbers. We should make sure all relevant commands handle standard input while still reporting line/column information and potentially some "special" file path like <stdin>?

Signed-off-by: Vaibhav mittal <vaibhavmittal929@gmail.com>
Signed-off-by: Vaibhav mittal <vaibhavmittal929@gmail.com>
Signed-off-by: Vaibhav mittal <vaibhavmittal929@gmail.com>
Signed-off-by: Vaibhav mittal <vaibhavmittal929@gmail.com>
Signed-off-by: Vaibhav mittal <vaibhavmittal929@gmail.com>
Signed-off-by: Vaibhav mittal <vaibhavmittal929@gmail.com>
Signed-off-by: Vaibhav mittal <vaibhavmittal929@gmail.com>
@Vaibhav701161
Copy link
Author

Vaibhav701161 commented Jan 20, 2026

Hey @jviotti , thanks a lot for the feedback.

I’ve pushed an updated iteration that tries to address the concerns you mentioned:

  • - is now the explicit opt-in for stdin.
  • The stdin logic is centralized in src/input.h, so it’s not handled ad-hoc in individual commands.
  • Ambiguous cases (schema via stdin, multiple stdin inputs) are explicitly rejected.
  • Line/column information is preserved, and stdin is handled as a special input (covered via tests).

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