@@ -10,7 +10,7 @@ use indexmap::{IndexMap, IndexSet};
1010use  openapiv3:: { Components ,  Parameter ,  ReferenceOr ,  Response ,  StatusCode } ; 
1111use  proc_macro2:: TokenStream ; 
1212use  quote:: { format_ident,  quote,  ToTokens } ; 
13- use  typify:: { TypeId ,  TypeSpace } ; 
13+ use  typify:: { TypeId ,  TypeSpace ,   TypeSpacePatch } ; 
1414
1515use  crate :: { 
1616    template:: PathTemplate , 
@@ -105,7 +105,7 @@ pub struct OperationParameter {
105105#[ derive( Debug ,  Eq ,  PartialEq ) ]  
106106pub  enum  OperationParameterType  { 
107107    Type ( TypeId ) , 
108-     Form ( IndexSet < String > ) , 
108+     Form ( TypeId ) , 
109109    RawBody , 
110110} 
111111
@@ -585,27 +585,15 @@ impl Generator {
585585            . map ( |param| { 
586586                let  name = format_ident ! ( "{}" ,  param. name) ; 
587587                match  & param. typ  { 
588-                     OperationParameterType :: Type ( type_id)  => { 
588+                     OperationParameterType :: Type ( type_id)  |
589+                     OperationParameterType :: Form ( type_id)  => { 
589590                        let  typ = self 
590591                            . type_space 
591592                            . get_type ( type_id) 
592593                            . expect ( "TypeIDs are _never_ deleted. qed" ) 
593594                            . parameter_ident_with_lifetime ( "a" ) ; 
594595                        quote !  {  #name:  #typ} 
595596                    } 
596-                     OperationParameterType :: Form ( keys)  => { 
597-                         let  ts = TokenStream :: from_iter ( 
598-                             itertools:: Itertools :: intersperse ( 
599-                                 keys. iter ( ) . map ( |form_prop_name| { 
600-                                     let  form_prop_name =
601-                                         format_ident ! ( "{}" ,  form_prop_name) ; 
602-                                     quote !  {  #form_prop_name:  Vec <u8 > } 
603-                                 } ) , 
604-                                 quote !  { ,  } , 
605-                             ) , 
606-                         ) ; 
607-                         ts
608-                     } 
609597                    OperationParameterType :: RawBody  => { 
610598                        quote !  {  #name:  B  } 
611599                    } 
@@ -935,15 +923,11 @@ impl Generator {
935923                    OperationParameterKind :: Body ( 
936924                        BodyContentType :: FormData 
937925                    ) , 
938-                     OperationParameterType :: Form ( map ) , 
926+                     OperationParameterType :: Form ( _ ) , 
939927                )  => { 
940-                     let  form_prop_names = map. iter ( ) . cloned ( ) . map ( |form_prop_name| { 
941-                         let  ident=  format_ident ! ( "{}" ,  form_prop_name) ; 
942-                         quote !  {  ( #form_prop_name,  #ident)  } 
943-                     } ) ; 
944928                    Some ( quote !  { 
945929                    // This uses progenitor_client::RequestBuilderExt which sets up a simple form data based on bytes 
946-                     . form_from_raw( vec! [  # ( #form_prop_names ) , *   ] ) ?
930+                     . form_from_raw( body . as_form ( ) ) ?
947931                } ) } , 
948932                ( OperationParameterKind :: Body ( _) ,  _)  => { 
949933                    unreachable ! ( "invalid body kind/type combination" ) 
@@ -1408,7 +1392,7 @@ impl Generator {
14081392            . params 
14091393            . iter ( ) 
14101394            . map ( |param| match  & param. typ  { 
1411-                 OperationParameterType :: Type ( type_id)  => { 
1395+                 OperationParameterType :: Type ( type_id)  |  OperationParameterType :: Form ( type_id )   => { 
14121396                    let  ty = self . type_space . get_type ( type_id) ?; 
14131397
14141398                    // For body parameters only, if there's a builder we'll 
@@ -1425,10 +1409,6 @@ impl Generator {
14251409                    } 
14261410                } 
14271411
1428-                 OperationParameterType :: Form ( _form)  => { 
1429-                     todo ! ( "Form is nit expected here" ) 
1430-                 } 
1431- 
14321412                OperationParameterType :: RawBody  => { 
14331413                    cloneable = false ; 
14341414                    Ok ( quote !  {  Result <reqwest:: Body ,  String > } ) 
@@ -1441,7 +1421,7 @@ impl Generator {
14411421            . params 
14421422            . iter ( ) 
14431423            . map ( |param| match  & param. typ  { 
1444-                 OperationParameterType :: Type ( type_id)  => { 
1424+                 OperationParameterType :: Type ( type_id)  |  OperationParameterType :: Form ( type_id )   => { 
14451425                    let  ty = self . type_space . get_type ( type_id) ?; 
14461426                    let  details = ty. details ( ) ; 
14471427                    let  optional =
@@ -1460,9 +1440,6 @@ impl Generator {
14601440                        Ok ( quote !  {  Err ( #err_msg. to_string( ) )  } ) 
14611441                    } 
14621442                } 
1463-                 OperationParameterType :: Form ( _form)  => { 
1464-                     todo ! ( "Form is nit expected here" ) 
1465-                 } 
14661443                OperationParameterType :: RawBody  => { 
14671444                    let  err_msg = format ! ( "{} was not initialized" ,  param. name) ; 
14681445                    Ok ( quote !  {  Err ( #err_msg. to_string( ) )  } ) 
@@ -1474,7 +1451,7 @@ impl Generator {
14741451            . params 
14751452            . iter ( ) 
14761453            . map ( |param| match  & param. typ  { 
1477-                 OperationParameterType :: Type ( type_id)  => { 
1454+                 OperationParameterType :: Type ( type_id)  |  OperationParameterType :: Form ( type_id )   => { 
14781455                    let  ty = self . type_space . get_type ( type_id) ?; 
14791456                    if  ty. builder ( ) . is_some ( )  { 
14801457                        let  type_name = ty. ident ( ) ; 
@@ -1488,14 +1465,6 @@ impl Generator {
14881465                    } 
14891466                } 
14901467
1491-                 OperationParameterType :: Form ( _form)  => { 
1492-                     todo ! ( "Form is nit expected here" ) 
1493-                 } 
1494- 
1495-                 OperationParameterType :: Form ( _form)  => { 
1496-                     todo ! ( "Form is nit expected here" ) 
1497-                 } 
1498- 
14991468                OperationParameterType :: RawBody  => Ok ( quote !  { } ) , 
15001469            } ) 
15011470            . collect :: < Result < Vec < _ > > > ( ) ?; 
@@ -1508,11 +1477,12 @@ impl Generator {
15081477            . map ( |param| { 
15091478                let  param_name = format_ident ! ( "{}" ,  param. name) ; 
15101479                match  & param. typ  { 
1511-                     OperationParameterType :: Type ( type_id)  => { 
1480+                     OperationParameterType :: Type ( type_id)  |
1481+                     OperationParameterType :: Form ( type_id)  => { 
15121482                        let  ty = self . type_space . get_type ( type_id) ?; 
15131483                        let  details = ty. details ( ) ; 
15141484                        match  ( & details,  ty. builder ( ) )  { 
1515-                             // TODO right now optional body paramters  are not 
1485+                             // TODO right now optional body parameters  are not 
15161486                            // addressed 
15171487                            ( typify:: TypeDetails :: Option ( _) ,  Some ( _) )  => { 
15181488                                unreachable ! ( ) 
@@ -1596,7 +1566,7 @@ impl Generator {
15961566                        } 
15971567                    } 
15981568
1599-                     OperationParameterType :: Form ( form_keys )  => { 
1569+                     OperationParameterType :: Form ( type_id )  => { 
16001570                        let  err_msg = format ! ( 
16011571                            "conversion to `reqwest::Body` for {} failed" , 
16021572                            param. name, 
@@ -2161,7 +2131,19 @@ impl Generator {
21612131                        schema
21622132                    ) ) ) , 
21632133                } ?; 
2164-                 OperationParameterType :: Form ( mapped) 
2134+ 
2135+                 let  form_name = sanitize ( 
2136+                     & format ! ( 
2137+                         "{}-form" , 
2138+                         operation. operation_id. as_ref( ) . unwrap( ) , 
2139+                     ) , 
2140+                     Case :: Pascal , 
2141+                 ) ; 
2142+                 let  type_id = self 
2143+                     . type_space 
2144+                     . add_type_with_name ( & schema. to_schema ( ) ,  Some ( form_name) ) ?; 
2145+                 self . forms . insert ( type_id. clone ( ) ) ; 
2146+                 OperationParameterType :: Form ( type_id) 
21652147            } 
21662148            BodyContentType :: Json  | BodyContentType :: FormUrlencoded  => { 
21672149                // TODO it would be legal to have the encoding field set for 
0 commit comments