0xPlaygrounds / 0xPlaygrounds/rig

feat: Better typing for JSON Schema

Open
#647 6 comments 2 reactions 0 assignees View on GitHub
feat
Dominant language
Rust
Stars
8.6k
Forks
959
Avg merge
4h 32m
Merged PRs (30d)
117

Description

- [x] I have looked for existing issues (including closed) about this

## Feature Request
Right now the schemas are just serde_json::Value. I am wondering if it would be worth either building primitives to better type that or at least verify that this is a valid JSON Schema.

### Motivation
The JSON value is very barebone and doesn't offer a lot of security/guard rails for the user. It is even worse if you have to accept user provided data for tools.
That would also allow us to transform the schema if need be for each provider, though most of them seem to support part of the JSON Schema (at whatever draft version it is at right now).

### Proposal
1. We could start with a custom wrapper around the Value that would check with [jsonschema](https://docs.rs/jsonschema/latest/jsonschema/) that it is a valid JSON Schema
2. We could build/contribute to an existing crate a macro/builder for JSON Schema and a parser for it (similar to what [valico](https://github.com/s-panferov/valico) offers

### Alternatives
- The user needs to do it's own parsing

Contributor guide

Open the contributing guide

Research direction

Look at how JSON schemas are currently used in the codebase, likely as serde_json::Value. Examine the jsonschema crate for validation. Start by exploring the existing schema handling in the code, then design a wrapper type that validates schemas. Check if there are existing tests for schema-related functionality to understand the expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.