@@ -932,6 +932,7 @@ pub enum Message {
932
932
Hello ( Box < models:: Hello > ) ,
933
933
Greeting ( Box < models:: Greeting > ) ,
934
934
Goodbye ( Box < models:: Goodbye > ) ,
935
+ SomethingCompletelyDifferent ( Box < models:: SomethingCompletelyDifferent > ) ,
935
936
}
936
937
937
938
impl validator:: Validate for Message {
@@ -940,6 +941,7 @@ impl validator::Validate for Message {
940
941
Self :: Hello ( x) => x. validate ( ) ,
941
942
Self :: Greeting ( x) => x. validate ( ) ,
942
943
Self :: Goodbye ( x) => x. validate ( ) ,
944
+ Self :: SomethingCompletelyDifferent ( x) => x. validate ( ) ,
943
945
}
944
946
}
945
947
}
@@ -953,6 +955,7 @@ impl serde::Serialize for Message {
953
955
Self :: Hello ( x) => x. serialize ( serializer) ,
954
956
Self :: Greeting ( x) => x. serialize ( serializer) ,
955
957
Self :: Goodbye ( x) => x. serialize ( serializer) ,
958
+ Self :: SomethingCompletelyDifferent ( x) => x. serialize ( serializer) ,
956
959
}
957
960
}
958
961
}
@@ -972,6 +975,11 @@ impl From<models::Goodbye> for Message {
972
975
Self :: Goodbye ( Box :: new ( value) )
973
976
}
974
977
}
978
+ impl From < models:: SomethingCompletelyDifferent > for Message {
979
+ fn from ( value : models:: SomethingCompletelyDifferent ) -> Self {
980
+ Self :: SomethingCompletelyDifferent ( Box :: new ( value) )
981
+ }
982
+ }
975
983
976
984
/// Converts Query Parameters representation (style=form, explode=false) to a Message value
977
985
/// as specified in https://swagger.io/docs/specification/serialization/
@@ -983,3 +991,42 @@ impl std::str::FromStr for Message {
983
991
serde_json:: from_str ( s)
984
992
}
985
993
}
994
+
995
+ #[ derive( Debug , Clone , PartialEq , serde:: Serialize , serde:: Deserialize ) ]
996
+ #[ serde( untagged) ]
997
+ #[ allow( non_camel_case_types) ]
998
+ pub enum SomethingCompletelyDifferent {
999
+ VecOfObject ( Box < Vec < crate :: types:: Object > > ) ,
1000
+ Object ( Box < crate :: types:: Object > ) ,
1001
+ }
1002
+
1003
+ impl validator:: Validate for SomethingCompletelyDifferent {
1004
+ fn validate ( & self ) -> std:: result:: Result < ( ) , validator:: ValidationErrors > {
1005
+ match self {
1006
+ Self :: VecOfObject ( _) => std:: result:: Result :: Ok ( ( ) ) ,
1007
+ Self :: Object ( x) => x. validate ( ) ,
1008
+ }
1009
+ }
1010
+ }
1011
+
1012
+ impl From < Vec < crate :: types:: Object > > for SomethingCompletelyDifferent {
1013
+ fn from ( value : Vec < crate :: types:: Object > ) -> Self {
1014
+ Self :: VecOfObject ( Box :: new ( value) )
1015
+ }
1016
+ }
1017
+ impl From < crate :: types:: Object > for SomethingCompletelyDifferent {
1018
+ fn from ( value : crate :: types:: Object ) -> Self {
1019
+ Self :: Object ( Box :: new ( value) )
1020
+ }
1021
+ }
1022
+
1023
+ /// Converts Query Parameters representation (style=form, explode=false) to a SomethingCompletelyDifferent value
1024
+ /// as specified in https://swagger.io/docs/specification/serialization/
1025
+ /// Should be implemented in a serde deserializer
1026
+ impl std:: str:: FromStr for SomethingCompletelyDifferent {
1027
+ type Err = serde_json:: Error ;
1028
+
1029
+ fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
1030
+ serde_json:: from_str ( s)
1031
+ }
1032
+ }
0 commit comments