1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
/// Transaction to monitor
#[cfg_attr(feature = "utoipa", schema(example = json!({
"type": "custom.schema",
"version": "1.0.0",
"json_schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "FinancialTransaction",
"type": "object",
"required": ["transaction_id", "amount", "currency", "timestamp"],
"properties": {
"transaction_id": {
"type": "string",
"format": "uuid"
},
"amount": {
"type": "number",
"exclusiveMinimum": 0
},
"currency": {
"type": "string",
"pattern": "^[A-Z]{3}$",
"description": "ISO 4217 Alpha-3 code (e.g., USD, EUR)"
},
"timestamp": {
"type": "string",
"format": "date-time"
},
}
}
})))]
pub struct CreateSchema {
#[serde(rename = "type")]
/// Transaction schema type
pub kind: String,
/// The schema's version
pub version: String,
/// The json schema to validate for each transaction of this type and version
#[serde(rename = "json_schema")]
pub schema: serde_json::Value,
}
|