api: Ignore unknown fields (Rust JSON decode).

The JSON encoding should only be used for debugging purposes! However
this change avoids showing errors in case there are unknown fields in the
JSON payload. This would happen when for example the MQTT Forwarder
and ChirpStack uses a different API version (which in case of Protobuf
would be fine, as long as the major version remains the same).
This commit is contained in:
Orne Brocaar 2023-10-16 10:51:29 +01:00
parent d9a2eeba3c
commit c82bfa5a72

5
api/rust/build.rs vendored
View File

@ -41,6 +41,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let descriptor_set = std::fs::read(out_dir.join("common").join("proto_descriptor.bin"))?;
pbjson_build::Builder::new()
.register_descriptors(&descriptor_set)?
.ignore_unknown_fields()
.out_dir(out_dir.join("common"))
.build(&[".common"])?;
}
@ -65,6 +66,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let descriptor_set = std::fs::read(out_dir.join("gw").join("proto_descriptor.bin"))?;
pbjson_build::Builder::new()
.register_descriptors(&descriptor_set)?
.ignore_unknown_fields()
.out_dir(out_dir.join("gw"))
.extern_path(".common", "crate::common")
.build(&[".gw"])?;
@ -94,6 +96,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let descriptor_set = std::fs::read(out_dir.join("internal").join("proto_descriptor.bin"))?;
pbjson_build::Builder::new()
.register_descriptors(&descriptor_set)?
.ignore_unknown_fields()
.out_dir(out_dir.join("internal"))
.extern_path(".common", "crate::common")
.build(&[".internal"])?;
@ -126,6 +129,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
pbjson_build::Builder::new()
.emit_fields()
.register_descriptors(&descriptor_set)?
.ignore_unknown_fields()
.out_dir(out_dir.join("integration"))
.extern_path(".common", "crate::common")
.extern_path(".gw", "crate::gw")
@ -149,6 +153,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let descriptor_set = std::fs::read(out_dir.join("meta").join("proto_descriptor.bin"))?;
pbjson_build::Builder::new()
.register_descriptors(&descriptor_set)?
.ignore_unknown_fields()
.out_dir(out_dir.join("meta"))
.extern_path(".common", "crate::common")
.extern_path(".gw", "crate::gw")