fixed deserialisation of 'AuxiliaryDetails' api response
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
// Copyright 2023-2024 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use crate::helpers::de_maybe_stringified;
|
||||
use celes::Country;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -171,7 +170,6 @@ pub struct NodeDescription {
|
||||
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
|
||||
pub struct AuxiliaryDetails {
|
||||
/// Optional ISO 3166 alpha-2 two-letter country code of the node's **physical** location
|
||||
#[serde(deserialize_with = "de_maybe_stringified")]
|
||||
#[cfg_attr(feature = "openapi", schema(example = "PL", value_type = Option<String>))]
|
||||
#[schemars(with = "Option<String>")]
|
||||
#[schemars(length(equal = 2))]
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
// Copyright 2024 - Nym Technologies SA <contact@nymtech.net>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
use serde::{Deserialize, Deserializer};
|
||||
use std::fmt::Display;
|
||||
use std::str::FromStr;
|
||||
|
||||
pub fn de_maybe_stringified<'de, D, T, E>(deserializer: D) -> Result<Option<T>, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
T: FromStr<Err = E>,
|
||||
E: Display,
|
||||
{
|
||||
let raw = String::deserialize(deserializer)?;
|
||||
if raw.is_empty() {
|
||||
Ok(None)
|
||||
} else {
|
||||
Ok(Some(raw.parse().map_err(serde::de::Error::custom)?))
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,6 @@
|
||||
|
||||
pub mod api;
|
||||
pub mod error;
|
||||
pub(crate) mod helpers;
|
||||
|
||||
macro_rules! absolute_route {
|
||||
( $name:ident, $parent:expr, $suffix:expr ) => {
|
||||
pub fn $name() -> String {
|
||||
|
||||
Reference in New Issue
Block a user