generateExamples = (context, responseExamples, requestBodyExamples, responseBodySchema, isXMLExample) => {
    const pmExamples = [],
      responseExampleKeys = _.map(responseExamples, 'key'),
      requestBodyExampleKeys = _.map(requestBodyExamples, 'key'),
      usedRequestExamples = _.fill(Array(requestBodyExamples.length), false),
      exampleKeyComparator = (example, key) => {
        return _.toLower(example.key) === _.toLower(key);
      };

    let matchedKeys = _.intersectionBy(responseExampleKeys, requestBodyExampleKeys, _.toLower),
      isResponseCodeMatching = false;

    // Only match in case of default response example matching with any request body example
    if (!matchedKeys.length && responseExamples.length === 1 && responseExamples[0].key === '_default') {
      const responseCodes = _.map(responseExamples, 'responseCode');

      matchedKeys = _.intersectionBy(responseCodes, requestBodyExampleKeys, _.toLower);
      isResponseCodeMatching = matchedKeys.length > 0;
    }

    // Do keys matching first and ignore any leftover req/res body for which matching is not found
    if (matchedKeys.length) {
      _.forEach(matchedKeys, (key) => {
        const matchedRequestExamples = _.filter(requestBodyExamples, (example) => {
            return exampleKeyComparator(example, key);
          }),
          responseExample = _.find(responseExamples, (example) => {
            // If there is a response code key-matching, then only match with keys based on response code
            if (isResponseCodeMatching) {
              return example.responseCode === key;
            }

            return exampleKeyComparator(example, key);
          });

        let requestExample = _.find(matchedRequestExamples, ['contentType', _.get(responseExample, 'contentType')]),
          responseExampleData;

        if (!requestExample) {
          requestExample = _.head(matchedRequestExamples);
        }

        responseExampleData = getExampleData(context, { [responseExample.key]: responseExample.value });

        if (isXMLExample) {
          responseExampleData = getXMLExampleData(context, responseExampleData, responseBodySchema);
        }

        pmExamples.push({
          request: getExampleData(context, { [requestExample.key]: requestExample.value }),
          response: responseExampleData,
          name: _.get(responseExample, 'value.summary') ||
            (responseExample.key !== '_default' && responseExample.key) ||
            _.get(requestExample, 'value.summary') || requestExample.key || 'Example'
        });
      });

      return pmExamples;
    }

    // No key matching between req and res were found, so perform positional matching now
    _.forEach(responseExamples, (responseExample, index) => {

      if (!_.isObject(responseExample)) {
        return;
      }

      let responseExampleData = getExampleData(context, { [responseExample.key]: responseExample.value }),
        requestExample;

      if (isXMLExample) {
        responseExampleData = getXMLExampleData(context, responseExampleData, responseBodySchema);
      }

      if (_.isEmpty(requestBodyExamples)) {
        pmExamples.push({
          response: responseExampleData,
          name: _.get(responseExample, 'value.summary') || responseExample.key
        });
        return;
      }

      if (requestBodyExamples[index] && !usedRequestExamples[index]) {
        requestExample = requestBodyExamples[index];
        usedRequestExamples[index] = true;
      }
      else {
        requestExample = requestBodyExamples[0];
      }

      pmExamples.push({
        request: getExampleData(context, { [requestExample.key]: requestExample.value }),
        response: responseExampleData,
        name: _.get(responseExample, 'value.summary') || (responseExample.key !== '_default' && responseExample.key) ||
          _.get(requestExample, 'value.summary') || requestExample.key || 'Example'
      });
    });

    // eslint-disable-next-line one-var
    let responseExample,
      responseExampleData;

    // Add any left over request body examples with first response body as matching
    for (let i = 0; i < requestBodyExamples.length; i++) {

      if (!usedRequestExamples[i] || pmExamples.length === 0) {
        if (!responseExample) {
          responseExample = _.head(responseExamples);

          if (responseExample) {
            responseExampleData = getExampleData(context, { [responseExample.key]: responseExample.value });
          }

          if (isXMLExample) {
            responseExampleData = getXMLExampleData(context, responseExampleData, responseBodySchema);
          }
        }
        pmExamples.push({
          request: getExampleData(context, { [requestBodyExamples[i].key]: requestBodyExamples[i].value }),
          response: responseExampleData,
          name: _.get(requestBodyExamples[i], 'value.summary') ||
            (requestBodyExamples[i].key !== '_default' && requestBodyExamples[i].key) ||
            _.get(responseExample, 'value.summary') || 'Example'
        });
      }
    }

    return pmExamples;
  }
Generates postman equivalent examples which contains request and response mappings of
each example based on examples mentioned in definition

This matching between request bodies and response bodies are done in following order.
1. Try matching keys from request and response examples

   (We'll also be considering any request body example with response code as key
   that's matching default response body example if present
   See fro example - test/data/valid_openapi/multiExampleResponseCodeMatching.json)

2. If any key matching is found, we'll generate example from it and ignore non-matching keys

3. If no matching key is found, we'll generate examples based on positional matching.

Positional matching means first example in request body will be matched with first example
in response body and so on. Any left over request or response body for which
positional matching is not found, we'll use first req/res example.

@param {Object} context - Global context object
@param {Object} responseExamples - Examples defined in the response
@param {Object} requestBodyExamples - Examples defined in the request body
@param {Object} responseBodySchema - Schema of the response body
@param {Boolean} isXMLExample - Whether the example is XML example
@returns {Array} Examples for corresponding operation