use serde::{Deserialize, Serialize};
use super::{PropMap, Server};
#[derive(Serialize, Deserialize, Clone, PartialEq, Default, Debug)]
#[non_exhaustive]
pub struct Link {
#[serde(skip_serializing_if = "String::is_empty", default)]
pub operation_ref: String,
#[serde(skip_serializing_if = "String::is_empty", default)]
pub operation_id: String,
#[serde(skip_serializing_if = "PropMap::is_empty")]
pub parameters: PropMap<String, serde_json::Value>,
#[serde(skip_serializing_if = "Option::is_none")]
pub request_body: Option<serde_json::Value>,
#[serde(skip_serializing_if = "String::is_empty", default)]
pub description: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub server: Option<Server>,
}
impl Link {
pub fn operation_ref<S: Into<String>>(mut self, operation_ref: S) -> Self {
self.operation_ref = operation_ref.into();
self
}
pub fn operation_id<S: Into<String>>(mut self, operation_id: S) -> Self {
self.operation_id = operation_id.into();
self
}
pub fn parameter<N: Into<String>, V: Into<serde_json::Value>>(
mut self,
name: N,
value: V,
) -> Self {
self.parameters.insert(name.into(), value.into());
self
}
pub fn request_body<B: Into<serde_json::Value>>(mut self, request_body: Option<B>) -> Self {
self.request_body = request_body.map(|request_body| request_body.into());
self
}
pub fn description<S: Into<String>>(mut self, description: S) -> Self {
self.description = description.into();
self
}
pub fn server<S: Into<Server>>(mut self, server: Option<S>) -> Self {
self.server = server.map(|server| server.into());
self
}
}