@@ -426,7 +426,9 @@ fn parse_object_type(name: &str, schema: &Yaml, output_file: &mut File) {
426426 if let Some ( type_label) = schema_map. get ( & Yaml :: String ( "x-oaiTypeLabel" . to_string ( ) ) ) {
427427 let type_label_str = type_label. as_str ( ) . unwrap ( ) ;
428428 match type_label_str {
429- "map" => writeln ! ( output_file, "pub struct {}(pub serde_json::Value);\n " , name) . unwrap ( ) ,
429+ "map" => {
430+ writeln ! ( output_file, "pub struct {}(pub serde_json::Value);\n " , name) . unwrap ( )
431+ }
430432 _ => unimplemented ! ( "{} with type label {:?}" , name, type_label) ,
431433 }
432434 } else {
@@ -520,6 +522,7 @@ fn parse_oneof_type(name: &str, schema: &Yaml, output_file: &mut File) {
520522 writeln ! ( output_file, "#[serde(untagged)]" ) . unwrap ( ) ;
521523 writeln ! ( output_file, "pub enum {} {{" , name) . unwrap ( ) ;
522524
525+ let mut string_enum_already_processed = false ;
523526 for ( index, one_of_variant) in one_of_list. iter ( ) . enumerate ( ) {
524527 let one_of_variant_hash = one_of_variant. as_hash ( ) . unwrap ( ) ;
525528 if let Some ( doc) = one_of_variant_hash
@@ -544,28 +547,9 @@ fn parse_oneof_type(name: &str, schema: &Yaml, output_file: &mut File) {
544547 {
545548 match variant_type. as_str ( ) {
546549 "string" => {
547- // Some variants have two String types to account for enumerations but for
548- // our type this is not necessary because all String representations are
549- // equal
550- if let Some ( Yaml :: Array ( enum_list) ) =
551- one_of_variant_hash. get ( & Yaml :: String ( "enum" . to_string ( ) ) )
552- {
553- for string_variant in enum_list {
554- writeln ! (
555- output_file,
556- "\t #[serde(rename=\" {}\" )]" ,
557- string_variant. as_str( ) . unwrap( )
558- )
559- . unwrap ( ) ;
560- writeln ! (
561- output_file,
562- "\t {}," ,
563- str_to_camel_case( string_variant. as_str( ) . unwrap( ) )
564- )
565- . unwrap ( ) ;
566- }
567- } else {
550+ if !string_enum_already_processed {
568551 writeln ! ( output_file, "\t String(String)," ) . unwrap ( ) ;
552+ string_enum_already_processed = true ;
569553 }
570554 }
571555 "integer" => {
@@ -1299,7 +1283,7 @@ fn parse_endpoint_path(path_schema: &Yaml, client_output_file: &mut File) {
12991283 if request_body_is_required {
13001284 writeln ! (
13011285 client_output_file,
1302- "\t \t request = request.body(serde_json::to_string( &request_body)? );" ,
1286+ "\t \t request = request.json( &request_body);" ,
13031287 )
13041288 . unwrap ( ) ;
13051289 } else {
0 commit comments