use serde::{Deserialize, Serialize};
use strum::{Display, EnumString};
#[cfg(feature = "openapi")]
use utoipa::ToSchema;
pub type KeyReference = String;
#[derive(EnumString, Display, Clone, PartialEq, Debug, Deserialize, Serialize)]
#[serde(tag = "type", content = "value")]
#[cfg_attr(feature = "openapi", derive(ToSchema))]
pub enum Key {
AnnotatedRelationshipElement(KeyReference),
AssetAdministrationShell(KeyReference),
BasicEventElement(KeyReference),
Blob(KeyReference),
Capability(KeyReference),
ConceptDescription(KeyReference),
DataElement(KeyReference),
Entity(KeyReference),
EventElement(KeyReference),
File(KeyReference),
FragmentReference(KeyReference),
GlobalReference(KeyReference),
Identifiable(KeyReference),
MultiLanguageProperty(KeyReference),
Operation(KeyReference),
Property(KeyReference),
Range(KeyReference),
Referable(KeyReference),
ReferenceElement(KeyReference),
RelationshipElement(KeyReference),
Submodel(KeyReference),
SubmodelElement(KeyReference),
SubmodelElementCollection(KeyReference),
SubmodelElementList(KeyReference),
}
pub mod xml {
#[cfg(test)]
mod tests {}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn serialize() {
let json = r#"
{
"type": "Submodel",
"value": "https://example.com/idta/Submodel/Test"
}
"#;
let expected = Key::Submodel("https://example.com/idta/Submodel/Test".to_string());
let actual: Key = serde_json::from_str(json).expect("Not serializing");
assert_eq!(actual, expected);
}
}