aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/warden-core/Cargo.toml5
-rw-r--r--lib/warden-core/build.rs19
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/warden-core/Cargo.toml b/lib/warden-core/Cargo.toml
index dbe61fd..9cd4617 100644
--- a/lib/warden-core/Cargo.toml
+++ b/lib/warden-core/Cargo.toml
@@ -13,12 +13,17 @@ rustdoc-args = ["--cfg", "docsrs"]
[dependencies]
prost = { workspace = true, optional = true }
+serde = { workspace = true, optional = true }
+serde_json = { workspace = true, optional = true }
tonic = { workspace = true, optional = true }
tonic-types = { version = "0.14.0", optional = true }
+utoipa = { workspace = true, optional = true }
[features]
default = []
iso20022 = ["dep:prost", "dep:tonic", "dep:tonic-types"]
+serde = ["dep:serde", "serde/derive", "dep:serde_json"]
+openapi = ["dep:utoipa", "serde"]
[build-dependencies]
tonic-prost-build = { version = "0.14.0", features = ["cleanup-markdown"] }
diff --git a/lib/warden-core/build.rs b/lib/warden-core/build.rs
index be4f8f2..7ae6b6a 100644
--- a/lib/warden-core/build.rs
+++ b/lib/warden-core/build.rs
@@ -50,6 +50,12 @@ fn build_proto(package: &str, entity: Entity) -> Result<(), Box<dyn std::error::
format!("#[cfg(feature = \"rpc-client-{package}\")] #[cfg_attr(docsrs, doc(cfg(feature = \"rpc-client-{package}\")))]"),
);
+ #[cfg(feature = "serde")]
+ let config = add_serde(config);
+
+ #[cfg(feature = "openapi")]
+ let config = add_openapi(config);
+
config
.file_descriptor_set_path(out_dir.join(format!("{package}_descriptor.bin")))
.server_mod_attribute(
@@ -69,3 +75,16 @@ fn build_proto(package: &str, entity: Entity) -> Result<(), Box<dyn std::error::
Ok(())
}
+
+#[cfg(all(feature = "serde", feature = "iso20022"))]
+fn add_serde(config: tonic_prost_build::Builder) -> tonic_prost_build::Builder {
+ config.type_attribute(
+ ".",
+ "#[derive(serde::Serialize, serde::Deserialize)] #[serde(rename_all = \"snake_case\")]",
+ )
+}
+
+#[cfg(all(feature = "openapi", feature = "iso20022"))]
+fn add_openapi(config: tonic_prost_build::Builder) -> tonic_prost_build::Builder {
+ config.type_attribute(".", "#[derive(utoipa::ToSchema)]")
+}