Skip to main content

kynos_openapi/model/
external_docs.rs

1//! The External Documentation Object.
2
3use serde::{Deserialize, Serialize};
4
5use crate::model::extensions::Extensions;
6
7/// A pointer to extended documentation.
8#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
9pub struct ExternalDocumentation {
10    /// A description of the target documentation. [CommonMark] syntax may be
11    /// used.
12    ///
13    /// [CommonMark]: https://spec.commonmark.org/
14    #[serde(default, skip_serializing_if = "Option::is_none")]
15    pub description: Option<String>,
16
17    /// The URI for the target documentation.
18    pub url: String,
19
20    /// Specification extensions.
21    #[serde(flatten)]
22    pub extensions: Extensions,
23}
24
25impl ExternalDocumentation {
26    /// Points at the given URI.
27    pub fn new(url: impl Into<String>) -> Self {
28        Self {
29            url: url.into(),
30            ..Self::default()
31        }
32    }
33
34    /// Sets the description.
35    #[must_use]
36    pub fn with_description(mut self, description: impl Into<String>) -> Self {
37        self.description = Some(description.into());
38        self
39    }
40}