Add extra front-end types and make MainPodBuilder emit these (#166)
* All test pass on middleware->frontend type refactor * Convert frontend CustomPredicateRef to a named field struct * Minor serialization improvements * Set appropriate titles in JSON schemas * Add names for custom predicates * Remove PodClass from front-end Origin type * Simplify value conversion --------- Co-authored-by: Ahmad <root@ahmadafuni.com>
This commit is contained in:
parent
6528914366
commit
a6cd02ec2f
9 changed files with 538 additions and 113 deletions
|
|
@ -12,6 +12,7 @@ use crate::middleware::PodId;
|
|||
use super::{MainPod, SignedPod, Value};
|
||||
|
||||
#[derive(Serialize, Deserialize, JsonSchema)]
|
||||
#[schemars(title = "SignedPod")]
|
||||
pub struct SignedPodHelper {
|
||||
entries: HashMap<String, Value>,
|
||||
proof: String,
|
||||
|
|
@ -54,6 +55,7 @@ impl From<SignedPod> for SignedPodHelper {
|
|||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, JsonSchema)]
|
||||
#[schemars(title = "MainPod")]
|
||||
pub struct MainPodHelper {
|
||||
public_statements: Vec<Statement>,
|
||||
proof: String,
|
||||
|
|
@ -152,6 +154,7 @@ pub fn transform_value_schema(schema: &mut Schema) {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use anyhow::Result;
|
||||
use schemars::generate::SchemaSettings;
|
||||
|
||||
use crate::{
|
||||
backends::plonky2::mock::{mainpod::MockProver, signedpod::MockSigner},
|
||||
|
|
@ -297,4 +300,17 @@ mod tests {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_schema() {
|
||||
let generator = SchemaSettings::draft07().into_generator();
|
||||
let mainpod_schema = generator.clone().into_root_schema_for::<MainPodHelper>();
|
||||
let signedpod_schema = generator.into_root_schema_for::<SignedPodHelper>();
|
||||
|
||||
println!("{}", serde_json::to_string_pretty(&mainpod_schema).unwrap());
|
||||
println!(
|
||||
"{}",
|
||||
serde_json::to_string_pretty(&signedpod_schema).unwrap()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue