Define Schema as a newtype around serde_json::Value (#289)

This commit is contained in:
Graham Esau 2024-05-12 19:23:54 +01:00 committed by GitHub
parent 7f6a7b7e32
commit 342cd5fd09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
79 changed files with 1410 additions and 2394 deletions

View file

@ -1,4 +1,4 @@
use schemars::schema::{Schema, SchemaObject};
use schemars::Schema;
use schemars::{gen::SchemaGenerator, schema_for, JsonSchema};
use serde::{Deserialize, Serialize};
@ -21,9 +21,11 @@ pub struct MyStruct {
}
fn make_custom_schema(gen: &mut SchemaGenerator) -> Schema {
let mut schema: SchemaObject = <String>::json_schema(gen).into();
schema.format = Some("boolean".to_owned());
schema.into()
let mut schema = String::json_schema(gen);
schema
.ensure_object()
.insert("format".into(), "boolean".into());
schema
}
fn eight() -> i32 {