openapiv3/discriminator.rs
1use indexmap::IndexMap;
2use serde::{Deserialize, Serialize};
3
4/// When request bodies or response payloads may be one of a number of different schemas,
5/// a discriminator object can be used to aid in serialization, deserialization,
6/// and validation. The discriminator is a specific object in a schema which is
7/// used to inform the consumer of the specification of an alternative schema based
8/// on the value associated with it.
9///
10/// When using the discriminator, inline schemas will not be considered.
11#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq)]
12#[serde(rename_all = "camelCase")]
13pub struct Discriminator {
14 /// REQUIRED. The name of the property in the payload that
15 /// will hold the discriminator value.
16 pub property_name: String,
17 /// An object to hold mappings between payload values and schema names or references.
18 #[serde(default, skip_serializing_if = "IndexMap::is_empty")]
19 pub mapping: IndexMap<String, String>,
20 /// Inline extensions to this object.
21 #[serde(flatten, deserialize_with = "crate::util::deserialize_extensions")]
22 pub extensions: IndexMap<String, serde_json::Value>,
23}