1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! Implements [OpenAPI Tag Object][tag] types.
//!
//! [tag]: https://spec.openapis.org/oas/latest.html#tag-object
use serde_derive::{Deserialize, Serialize};
use super::extensions::Extensions;
use super::external_docs::ExternalDocs;
/// Implements [OpenAPI Tag Object][tag].
///
/// Tag can be used to provide additional metadata for tags used by path operations.
///
/// [tag]: https://spec.openapis.org/oas/latest.html#tag-object
#[non_exhaustive]
#[derive(Serialize, Deserialize, Default, Clone, PartialEq, Eq, bon::Builder)]
#[cfg_attr(feature = "debug", derive(Debug))]
#[serde(rename_all = "camelCase")]
#[builder(on(_, into))]
pub struct Tag {
/// Name of the tag. Should match to tag of **operation**.
pub name: String,
/// Additional description for the tag shown in the document.
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
/// Additional external documentation for the tag.
#[serde(skip_serializing_if = "Option::is_none")]
pub external_docs: Option<ExternalDocs>,
/// Optional extensions "x-something".
#[serde(skip_serializing_if = "Option::is_none", flatten)]
pub extensions: Option<Extensions>,
}
impl Tag {
/// Construct a new [`Tag`] with given name.
pub fn new<S: AsRef<str>>(name: S) -> Self {
Self {
name: name.as_ref().to_string(),
..Default::default()
}
}
}