/// Analysises the shapes of interactions that have request or response bodies with previously
/// unseen content types. From the result, observed types per json trail, commands can be generated
/// applyable to the spec that would make the interaction compliant. Results can also be merged with
/// each other, creating a union. In effect, this allows a spec to be learned from interactions.
///
/// A diff is performed to find a matching Request / Response, but with missing content types
/// respectively. When found, a normalized description of the shape of the interaction is traversed.
Analysises the shapes of interactions that have request or response bodies with previously
unseen content types. From the result, observed types per json trail, commands can be generated
applyable to the spec that would make the interaction compliant. Results can also be merged with
each other, creating a union. In effect, this allows a spec to be learned from interactions.

A diff is performed to find a matching Request / Response, but with missing content types
respectively. When found, a normalized description of the shape of the interaction is traversed.
Analysises the shapes of interactions that have request or response bodies with previously unseen content types . From the result observed types per json trail commands can be generated applyable to the spec that would make the interaction compliant . Results can also be merged with each other creating a union . In effect this allows a spec to be learned from interactions . A diff is performed to find a matching Request / Response but with missing content types respectively . When found a normalized description of the shape of the interaction is traversed .
pub fn analyze_undocumented_bodies<'a>(
  spec_projection: &SpecProjection,
  interaction: HttpInteraction,
  config: &AnalyzeUndocumentedBodiesConfig,
) -> impl Iterator<Item = BodyAnalysisResult> {
  let endpoint_projection = spec_projection.endpoint();
  let endpoint_queries = EndpointQueries::new(endpoint_projection);
  let interaction_traverser = traverser::Traverser::new(&endpoint_queries);
  let mut diff_visitors = visitors::diff::DiffVisitors::new();
  interaction_traverser.traverse(&interaction, &mut diff_visitors);
  let results = diff_visitors.take_results().unwrap();
  results.into_iter().flat_map(move |result| match result {
    InteractionDiffResult::UnmatchedQueryParameters(diff) => {
      if let UnmatchedQueryParameters::Observed(_) = &diff {
        let maybe_query_params: Option<BodyDescriptor> = (&interaction.request.query).into();
        let query_params = maybe_query_params.or_else(|| Some(BodyDescriptor::empty_object()));
        let query_trail_observations = observe_body_trails(query_params);
        vec![BodyAnalysisResult {
          body_location: BodyAnalysisLocation::from(diff),
          trail_observations: query_trail_observations,
        }]
      } else {
        vec![]
      }
    }
    InteractionDiffResult::UnmatchedRequestBodyContentType(diff) => {
      let body = &interaction.request.body;
      let body_trail_observations = observe_body_trails(&body.value);
      vec![BodyAnalysisResult {
        body_location: BodyAnalysisLocation::from(diff.clone()),
        trail_observations: body_trail_observations,
      }]
    }
    InteractionDiffResult::UnmatchedResponseBodyContentType(diff) => {
      let body = &interaction.response.body;
      let trail_observations = observe_body_trails(&body.value);
      vec![BodyAnalysisResult {
        body_location: BodyAnalysisLocation::from(diff),
        trail_observations,
      }]
    }
    _ => vec![],
  })
}
pub fn analyze_undocumented_bodies < ' a > ( spec_projection : & SpecProjection , interaction : HttpInteraction , config : & AnalyzeUndocumentedBodiesConfig , ) -> impl Iterator < Item = BodyAnalysisResult > { let endpoint_projection = spec_projection . endpoint ( ) ; let endpoint_queries = EndpointQueries :: new ( endpoint_projection ) ; let interaction_traverser = traverser :: Traverser :: new ( & endpoint_queries ) ; let mut diff_visitors = visitors :: diff :: DiffVisitors :: new ( ) ; interaction_traverser . traverse ( & interaction , & mut diff_visitors ) ; let results = diff_visitors . take_results ( ) . unwrap ( ) ; results . into_iter ( ) . flat_map ( move | result | match result { InteractionDiffResult :: UnmatchedQueryParameters ( diff ) => { if let UnmatchedQueryParameters :: Observed ( _ ) = & diff { let maybe_query_params : Option < BodyDescriptor > = ( & interaction . request . query ) . into ( ) ; let query_params = maybe_query_params . or_else ( | | Some ( BodyDescriptor :: empty_object ( ) ) ) ; let query_trail_observations = observe_body_trails ( query_params ) ; vec ! [ BodyAnalysisResult { body_location BodyAnalysisLocation from ( diff ) trail_observations query_trail_observations } ] } else { vec ! [ ] } } InteractionDiffResult :: UnmatchedRequestBodyContentType ( diff ) => { let body = & interaction . request . body ; let body_trail_observations = observe_body_trails ( & body . value ) ; vec ! [ BodyAnalysisResult { body_location BodyAnalysisLocation from ( diff clone ( ) ) trail_observations body_trail_observations } ] } InteractionDiffResult :: UnmatchedResponseBodyContentType ( diff ) => { let body = & interaction . response . body ; let trail_observations = observe_body_trails ( & body . value ) ; vec ! [ BodyAnalysisResult { body_location BodyAnalysisLocation from ( diff ) trail_observations } ] } _ => vec ! [ ] , } ) }
Analysises the shapes of interactions that have request or response bodies with previously
unseen content types.
Analysises the shapes of interactions that have request or response bodies with previously unseen content types .
spec_projection
&SpecProjection
interaction
HttpInteraction
config
&AnalyzeUndocumentedBodiesConfig