0xPlaygrounds / 0xPlaygrounds/rig

feat: Better typing for JSON Schema

Aperta
#647 6 commenti 2 reazioni 0 assegnatari Vedi su GitHub
feat
Lingua principale
Rust
Stelle
8.6k
Fork
959
Merge medio
4h 32m
PR unite (30g)
117

Descrizione

- [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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
rust
Ambito
backend-api-design
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.