Re-introduce field title & description in referenced schemas.
This commit is contained in:
parent
45a463786f
commit
ae981403c6
|
@ -57,7 +57,7 @@ pub enum Items<T> {
|
||||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct Constructor {
|
pub struct Constructor {
|
||||||
pub index: usize,
|
pub index: usize,
|
||||||
pub fields: Vec<Reference>,
|
pub fields: Vec<Annotated<Reference>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> From<T> for Annotated<T> {
|
impl<T> From<T> for Annotated<T> {
|
||||||
|
@ -191,7 +191,7 @@ impl Annotated<Schema> {
|
||||||
description: Some("An optional value.".to_string()),
|
description: Some("An optional value.".to_string()),
|
||||||
annotated: Constructor {
|
annotated: Constructor {
|
||||||
index: 0,
|
index: 0,
|
||||||
fields: vec![generic],
|
fields: vec![generic.into()],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Annotated {
|
Annotated {
|
||||||
|
@ -367,7 +367,11 @@ impl Data {
|
||||||
return Ok(schema.into_data(&field.tipo)?.annotated);
|
return Ok(schema.into_data(&field.tipo)?.annotated);
|
||||||
}
|
}
|
||||||
|
|
||||||
fields.push(reference);
|
fields.push(Annotated {
|
||||||
|
title: field.label.clone(),
|
||||||
|
description: field.doc.clone().map(|s| s.trim().to_string()),
|
||||||
|
annotated: reference,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let variant = Annotated {
|
let variant = Annotated {
|
||||||
|
@ -750,12 +754,12 @@ pub mod test {
|
||||||
let schema = Schema::Data(Data::AnyOf(vec![
|
let schema = Schema::Data(Data::AnyOf(vec![
|
||||||
Constructor {
|
Constructor {
|
||||||
index: 0,
|
index: 0,
|
||||||
fields: vec![Reference::new("Int")],
|
fields: vec![Reference::new("Int").into()],
|
||||||
}
|
}
|
||||||
.into(),
|
.into(),
|
||||||
Constructor {
|
Constructor {
|
||||||
index: 1,
|
index: 1,
|
||||||
fields: vec![Reference::new("Bytes")],
|
fields: vec![Reference::new("Bytes").into()],
|
||||||
}
|
}
|
||||||
.into(),
|
.into(),
|
||||||
]));
|
]));
|
||||||
|
|
|
@ -459,12 +459,17 @@ mod test {
|
||||||
"index": 0,
|
"index": 0,
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
"title": "contestationPeriod",
|
||||||
|
"description": "The contestation period as a number of seconds",
|
||||||
"$ref": "#/definitions/test_module~1ContestationPeriod"
|
"$ref": "#/definitions/test_module~1ContestationPeriod"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"title": "parties",
|
||||||
|
"description": "List of public key hashes of all participants",
|
||||||
"$ref": "#/definitions/List$ByteArray"
|
"$ref": "#/definitions/List$ByteArray"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"title": "utxoHash",
|
||||||
"$ref": "#/definitions/ByteArray"
|
"$ref": "#/definitions/ByteArray"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -680,6 +685,7 @@ mod test {
|
||||||
"index": 0,
|
"index": 0,
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
"title": "inner",
|
||||||
"$ref": "#/definitions/List$Tuple$ByteArray_Int"
|
"$ref": "#/definitions/List$Tuple$ByteArray_Int"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -786,6 +792,7 @@ mod test {
|
||||||
"index": 0,
|
"index": 0,
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
"title": "foo",
|
||||||
"$ref": "#/definitions/Data"
|
"$ref": "#/definitions/Data"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -965,6 +972,7 @@ mod test {
|
||||||
"index": 0,
|
"index": 0,
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
"title": "foo",
|
||||||
"$ref": "#/definitions/test_module~1LinkedList$Bool"
|
"$ref": "#/definitions/test_module~1LinkedList$Bool"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -975,9 +983,11 @@ mod test {
|
||||||
"index": 1,
|
"index": 1,
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
"title": "bar",
|
||||||
"$ref": "#/definitions/Int"
|
"$ref": "#/definitions/Int"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"title": "baz",
|
||||||
"$ref": "#/definitions/Tuple$ByteArray_List$test_module~1LinkedList$Int"
|
"$ref": "#/definitions/Tuple$ByteArray_List$test_module~1LinkedList$Int"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -74,9 +74,11 @@
|
||||||
"index": 0,
|
"index": 0,
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
"title": "transaction_id",
|
||||||
"$ref": "#/definitions/aiken~1transaction~1TransactionId"
|
"$ref": "#/definitions/aiken~1transaction~1TransactionId"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"title": "output_index",
|
||||||
"$ref": "#/definitions/Int"
|
"$ref": "#/definitions/Int"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -93,6 +95,7 @@
|
||||||
"index": 0,
|
"index": 0,
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
"title": "hash",
|
||||||
"$ref": "#/definitions/ByteArray"
|
"$ref": "#/definitions/ByteArray"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -39,9 +39,11 @@
|
||||||
"index": 0,
|
"index": 0,
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
"title": "policy_id",
|
||||||
"$ref": "#/definitions/ByteArray"
|
"$ref": "#/definitions/ByteArray"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"title": "asset_name",
|
||||||
"$ref": "#/definitions/ByteArray"
|
"$ref": "#/definitions/ByteArray"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -57,9 +59,11 @@
|
||||||
"index": 0,
|
"index": 0,
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
"title": "input_cs",
|
||||||
"$ref": "#/definitions/spend~1CurrencySymbol"
|
"$ref": "#/definitions/spend~1CurrencySymbol"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"title": "input_amount",
|
||||||
"$ref": "#/definitions/Int"
|
"$ref": "#/definitions/Int"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -75,12 +79,15 @@
|
||||||
"index": 0,
|
"index": 0,
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
"title": "currency_symbol",
|
||||||
"$ref": "#/definitions/spend~1CurrencySymbol"
|
"$ref": "#/definitions/spend~1CurrencySymbol"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"title": "balance",
|
||||||
"$ref": "#/definitions/Int"
|
"$ref": "#/definitions/Int"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"title": "lent_out",
|
||||||
"$ref": "#/definitions/Int"
|
"$ref": "#/definitions/Int"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -96,9 +103,11 @@
|
||||||
"index": 0,
|
"index": 0,
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
"title": "input_cs",
|
||||||
"$ref": "#/definitions/spend~1CurrencySymbol"
|
"$ref": "#/definitions/spend~1CurrencySymbol"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"title": "input_amount",
|
||||||
"$ref": "#/definitions/Int"
|
"$ref": "#/definitions/Int"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -114,6 +123,7 @@
|
||||||
"index": 0,
|
"index": 0,
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
"title": "action",
|
||||||
"$ref": "#/definitions/spend~1PoolRedeemerType"
|
"$ref": "#/definitions/spend~1PoolRedeemerType"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
"index": 0,
|
"index": 0,
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
"title": "owner",
|
||||||
"$ref": "#/definitions/ByteArray"
|
"$ref": "#/definitions/ByteArray"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -52,6 +53,7 @@
|
||||||
"index": 0,
|
"index": 0,
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
"title": "msg",
|
||||||
"$ref": "#/definitions/ByteArray"
|
"$ref": "#/definitions/ByteArray"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue