pub fn generate_request(request: &models::Request, context: &HashMap<String, Value>) -> models::Request {
    let generators = request.generators.clone();
    let mut request = request.clone();
    generators.apply_generator(&GeneratorCategory::PATH, |_, generator| {
        match generator.generate_value(&request.path, context) {
            Some(v) => request.path = v,
            None => ()
        }
    });
    generators.apply_generator(&GeneratorCategory::HEADER, |key, generator| {
        match request.headers {
            Some(ref mut headers) => if headers.contains_key(key) {
                match generator.generate_value(&headers.get(key).unwrap().clone(), context) {
                    Some(v) => headers.insert(key.clone(), v),
                    None => None
                };
            },
            None => ()
        }
    });
    generators.apply_generator(&GeneratorCategory::QUERY, |key, generator| {
      match request.query {
        Some(ref mut parameters) => match parameters.get_mut(key) {
          Some(parameter) => {
            let mut generated = parameter.clone();
            for (index, val) in parameter.iter().enumerate() {
              match generator.generate_value(val, context) {
                Some(v) => generated[index] = v,
                None => ()
              };
            }
            *parameter = generated;
          },
          None => ()
        },
        None => ()
      }
    });
    request.body = generators.apply_body_generators(&request.body, request.content_type_enum(),
        context);
    request
}
/// Generates the request by applying any defined generators
Generates the request by applying any defined generators
Generates the request by applying any defined generators
pub fn generate_request(request: &models::Request, context: &HashMap<String, Value>) -> models::Request {
    let generators = request.generators.clone();
    let mut request = request.clone();
    generators.apply_generator(&GeneratorCategory::PATH, |_, generator| {
        match generator.generate_value(&request.path, context) {
            Some(v) => request.path = v,
            None => ()
        }
    });
    generators.apply_generator(&GeneratorCategory::HEADER, |key, generator| {
        match request.headers {
            Some(ref mut headers) => if headers.contains_key(key) {
                match generator.generate_value(&headers.get(key).unwrap().clone(), context) {
                    Some(v) => headers.insert(key.clone(), v),
                    None => None
                };
            },
            None => ()
        }
    });
    generators.apply_generator(&GeneratorCategory::QUERY, |key, generator| {
      match request.query {
        Some(ref mut parameters) => match parameters.get_mut(key) {
          Some(parameter) => {
            let mut generated = parameter.clone();
            for (index, val) in parameter.iter().enumerate() {
              match generator.generate_value(val, context) {
                Some(v) => generated[index] = v,
                None => ()
              };
            }
            *parameter = generated;
          },
          None => ()
        },
        None => ()
      }
    });
    request.body = generators.apply_body_generators(&request.body, request.content_type_enum(),
        context);
    request
}
pub fn generate_request ( request : & models :: Request , context : & HashMap < String , Value > ) -> models :: Request { let generators = request . generators . clone ( ) ; let mut request = request . clone ( ) ; generators . apply_generator ( & GeneratorCategory :: PATH , | _ , generator | { match generator . generate_value ( & request . path , context ) { Some ( v ) => request . path = v , None => ( ) } } ) ; generators . apply_generator ( & GeneratorCategory :: HEADER , | key , generator | { match request . headers { Some ( ref mut headers ) => if headers . contains_key ( key ) { match generator . generate_value ( & headers . get ( key ) . unwrap ( ) . clone ( ) , context ) { Some ( v ) => headers . insert ( key . clone ( ) , v ) , None => None } ; } , None => ( ) } } ) ; generators . apply_generator ( & GeneratorCategory :: QUERY , | key , generator | { match request . query { Some ( ref mut parameters ) => match parameters . get_mut ( key ) { Some ( parameter ) => { let mut generated = parameter . clone ( ) ; for ( index , val ) in parameter . iter ( ) . enumerate ( ) { match generator . generate_value ( val , context ) { Some ( v ) => generated [ index ] = v , None => ( ) } ; } * parameter = generated ; } , None => ( ) } , None => ( ) } } ) ; request . body = generators . apply_body_generators ( & request . body , request . content_type_enum ( ) , context ) ; request }
Generates the request by applying any defined generators
Generates the request by applying any defined generators
request
&models::Request
context
&HashMap<String, Value>
request
&models::Request
context
&HashMap<String, Value>