-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(MINOR) Updates needed for v2 JavaScript SDK (#521)
* Add missing `json_schema` traits, add serde traits * Provide access to a resource from the Reader * Generate schemas for ManifestStore and Settings * Add ManifestDefinition * Pass stream by reference * Fix schemars tag * Add mutable references * Undo mutable changes * Undo API changes * Update AsyncSigner for Wasm * Try to separate out AsyncSigner * Add temp function for debugging * Use `from_bytes` API * Add from_manifest_store function * Revert "Add from_manifest_store function" This reverts commit fcb1856. * Make async flow for adding an ingredient via the Builder * Add clippy, fix args * Don't expose buffer * Update serde-json * Update serde_json version in make_test_images * Make clippy fixes * Update image crate * Pin to image version * Update serde-json --------- Co-authored-by: Gavin Peacock <[email protected]>
- Loading branch information
Showing
10 changed files
with
169 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,28 @@ | ||
use std::{fs, path::Path}; | ||
|
||
use anyhow::Result; | ||
use c2pa::ManifestStore; | ||
use schemars::gen::SchemaSettings; | ||
use c2pa::{settings::Settings, ManifestDefinition, ManifestStore}; | ||
use schemars::{schema::RootSchema, schema_for}; | ||
|
||
fn main() -> Result<()> { | ||
println!("Exporting JSON schema"); | ||
let settings = SchemaSettings::draft07(); | ||
let gen = settings.into_generator(); | ||
let schema = gen.into_root_schema_for::<ManifestStore>(); | ||
let output = serde_json::to_string_pretty(&schema).expect("Failed to serialize schema"); | ||
fn write_schema(schema: &RootSchema, name: &str) { | ||
println!("Exporting JSON schema for {}", name); | ||
let output = serde_json::to_string_pretty(schema).expect("Failed to serialize schema"); | ||
let output_dir = Path::new("./target/schema"); | ||
fs::create_dir_all(output_dir).expect("Could not create schema directory"); | ||
let output_path = output_dir.join("ManifestStore.schema.json"); | ||
let output_path = output_dir.join(format!("{}.schema.json", name)); | ||
fs::write(&output_path, output).expect("Unable to write schema"); | ||
println!("Wrote schema to {}", output_path.display()); | ||
} | ||
|
||
fn main() -> Result<()> { | ||
let manifest_definition = schema_for!(ManifestDefinition); | ||
write_schema(&manifest_definition, "ManifestDefinition"); | ||
|
||
let manifest_store = schema_for!(ManifestStore); | ||
write_schema(&manifest_store, "ManifestStore"); | ||
|
||
let settings = schema_for!(Settings); | ||
write_schema(&settings, "Settings"); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.