Further reduce memory footprint of SchemaObject.
More fields are now wrapped in Option<Box<_>>, reducing size of JsonSchema (depending on system) from 424 to 240 bytes.
This commit is contained in:
parent
72629a3c37
commit
c78d721fc5
6 changed files with 87 additions and 59 deletions
|
@ -1,5 +1,5 @@
|
|||
use pretty_assertions::assert_eq;
|
||||
use schemars::{gen::SchemaSettings, schema::Schema, schema_for, JsonSchema};
|
||||
use schemars::{gen::SchemaSettings, schema::SchemaObject, schema_for, JsonSchema};
|
||||
use std::error::Error;
|
||||
use std::fs;
|
||||
use std::panic;
|
||||
|
@ -18,7 +18,7 @@ pub fn test_default_generated_schema<T: JsonSchema>(file: &str) -> TestResult {
|
|||
test_schema(&actual, file)
|
||||
}
|
||||
|
||||
fn test_schema(actual: &Schema, file: &str) -> TestResult {
|
||||
fn test_schema(actual: &SchemaObject, file: &str) -> TestResult {
|
||||
let expected_json = match fs::read_to_string(format!("tests/expected/{}.json", file)) {
|
||||
Ok(j) => j,
|
||||
Err(e) => {
|
||||
|
@ -36,7 +36,7 @@ fn test_schema(actual: &Schema, file: &str) -> TestResult {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn write_actual_to_file(schema: &Schema, file: &str) -> TestResult {
|
||||
fn write_actual_to_file(schema: &SchemaObject, file: &str) -> TestResult {
|
||||
let actual_json = serde_json::to_string_pretty(&schema)?;
|
||||
fs::write(format!("tests/actual/{}.json", file), actual_json)?;
|
||||
Ok(())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue