restify_openapi/models/
info.rs

1use indexmap::IndexMap;
2use serde::Serialize;
3use serde_json::Value;
4
5/// The object provides metadata about the API. The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience.
6#[derive(Serialize, Clone, Debug, Default)]
7#[cfg_attr(any(test, feature = "deserialize"), derive(serde::Deserialize, PartialEq))]
8#[serde(rename_all = "camelCase")]
9pub struct Info {
10  /// The title of the API
11  pub title: String,
12  /// A short description of the API. [CommonMark](https://spec.commonmark.org/) syntax MAY be used for rich text representation.
13  #[serde(skip_serializing_if = "Option::is_none")]
14  pub description: Option<String>,
15  /// A URL to the Terms of Service for the API. MUST be in the format of a URL.
16  #[serde(skip_serializing_if = "Option::is_none")]
17  pub terms_of_service: Option<String>,
18  /// The contact information for the exposed API.
19  #[serde(skip_serializing_if = "Option::is_none")]
20  pub contact: Option<Contact>,
21  /// The license information for the exposed API.
22  #[serde(skip_serializing_if = "Option::is_none")]
23  pub license: Option<License>,
24  /// The version of the OpenAPI document (which is distinct from the [OpenAPI Specification version](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#oasVersion) or the API implementation version).
25  pub version: String,
26  /// This object MAY be extended with [Specification Extensions](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#specification-extensions).
27  #[serde(flatten, skip_serializing_if = "IndexMap::is_empty", skip_deserializing)]
28  pub extensions: IndexMap<String, Value>,
29}
30
31/// Contact information for the exposed API.
32#[derive(Serialize, Clone, Debug, Default)]
33#[cfg_attr(any(test, feature = "deserialize"), derive(serde::Deserialize, PartialEq))]
34#[serde(rename_all = "camelCase")]
35pub struct Contact {
36  /// The identifying name of the contact person/organization.
37  #[serde(skip_serializing_if = "Option::is_none")]
38  pub name: Option<String>,
39  /// The URL pointing to the contact information. MUST be in the format of a URL.
40  #[serde(skip_serializing_if = "Option::is_none")]
41  pub url: Option<String>,
42  /// The email address of the contact person/organization. MUST be in the format of an email address.
43  #[serde(skip_serializing_if = "Option::is_none")]
44  pub email: Option<String>,
45  /// This object MAY be extended with [Specification Extensions](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#specification-extensions).
46  #[serde(flatten, skip_serializing_if = "IndexMap::is_empty", skip_deserializing)]
47  pub extensions: IndexMap<String, Value>,
48}
49
50/// License information for the exposed API.
51#[derive(Serialize, Clone, Debug, Default)]
52#[cfg_attr(any(test, feature = "deserialize"), derive(serde::Deserialize, PartialEq))]
53#[serde(rename_all = "camelCase")]
54pub struct License {
55  /// The license name used for the API.
56  pub name: String,
57  /// A URL to the license used for the API. MUST be in the format of a URL.
58  #[serde(skip_serializing_if = "Option::is_none")]
59  pub url: Option<String>,
60  /// This object MAY be extended with [Specification Extensions](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#specification-extensions).
61  #[serde(flatten, skip_serializing_if = "IndexMap::is_empty", skip_deserializing)]
62  pub extensions: IndexMap<String, Value>,
63}