sw4rm_rs/shared/
xml.rs

1use std::collections::HashMap;
2use serde::{Deserialize, Serialize};
3use serde_json::Value;
4
5/// XML Object
6///
7/// A metadata object that allows for more fine-tuned XML model definitions.
8///
9/// When using arrays, XML element names are not inferred (for singular/plural forms) and
10/// the name property should be used to add that information. See examples for expected behavior.
11#[derive(Debug, Serialize, Deserialize, Default, Clone, PartialEq)]
12#[serde(default, rename_all = "camelCase")]
13pub struct XML {
14    /// Replaces the name of the element/attribute used for the described schema property. When
15    /// defined within the Items Object (items), it will affect the name of the individual XML
16    /// elements within the list. When defined alongside type being array (outside the items), it
17    /// will affect the wrapping element and only if wrapped is true. If wrapped is false, it
18    /// will be ignored.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub name: Option<String>,
21    /// The URL of the namespace definition. Value SHOULD be in the form of a URL.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub namespace: Option<String>,
24    /// The prefix to be used for the name.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub prefix: Option<String>,
27    /// Declares whether the property definition translates to an attribute instead of an element.
28    /// Default value is false.
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub attribute: Option<bool>,
31    /// MAY be used only for an array definition. Signifies whether the array is wrapped (for
32    /// example, <books><book/><book/></books>) or unwrapped (<book/><book/>). Default value is
33    /// false. The definition takes effect only when defined alongside type being array (outside
34    /// the items).
35    #[serde(skip_serializing_if = "Option::is_none")]
36    pub wrapped: Option<bool>,
37
38    /// Allows extensions to the Swagger Schema. The field name MUST begin with x-, for example,
39    /// x-internal-id. The value can be null, a primitive, an array or an object. See Vendor
40    /// Extensions for further details.
41    #[serde(flatten, skip_serializing_if = "HashMap::is_empty")]
42    pub x_fields: HashMap<String, Value>,
43}