function prepareBody(endpointSchema, globalMimeTypes) {
  const mimeTypes = endpointSchema.consumes || globalMimeTypes || [];
  const isAvailable = m => mimeTypes.includes(m);
  const supportedMimeType = SUPPORTED_MIME_TYPES.find(isAvailable);

  if (supportedMimeType === MIMETYPE_JSON) {
    const isSendInBody = p => p.in === 'body';
    const parameters = endpointSchema.parameters || [];
    const bodyParameter = parameters.find(isSendInBody);
    if (!bodyParameter) {
      return {
        mimeType: supportedMimeType,
      };
    }

    const example = bodyParameter ? generateParameterExample(bodyParameter.schema) : undefined;
    const text = JSON.stringify(example, null, 2);
    return {
      mimeType: supportedMimeType,
      text,
    };
  }

  if (mimeTypes && mimeTypes.length) {
    return {
      mimeType: mimeTypes[0] || undefined,
    };
  } else {
    return {};
  }
}
function prepareBody(endpointSchema, globalMimeTypes) {
  const mimeTypes = endpointSchema.consumes || globalMimeTypes || [];
  const isAvailable = m => mimeTypes.includes(m);
  const supportedMimeType = SUPPORTED_MIME_TYPES.find(isAvailable);

  if (supportedMimeType === MIMETYPE_JSON) {
    const isSendInBody = p => p.in === 'body';
    const parameters = endpointSchema.parameters || [];
    const bodyParameter = parameters.find(isSendInBody);
    if (!bodyParameter) {
      return {
        mimeType: supportedMimeType,
      };
    }

    const example = bodyParameter ? generateParameterExample(bodyParameter.schema) : undefined;
    const text = JSON.stringify(example, null, 2);
    return {
      mimeType: supportedMimeType,
      text,
    };
  }

  if (mimeTypes && mimeTypes.length) {
    return {
      mimeType: mimeTypes[0] || undefined,
    };
  } else {
    return {};
  }
}
function prepareBody ( endpointSchema , globalMimeTypes ) { const mimeTypes = endpointSchema . consumes || globalMimeTypes || [ ] ; const isAvailable = m => mimeTypes . includes ( m ) ; const supportedMimeType = SUPPORTED_MIME_TYPES . find ( isAvailable ) ; if ( supportedMimeType === MIMETYPE_JSON ) { const isSendInBody = p => p . in === 'body' ; const parameters = endpointSchema . parameters || [ ] ; const bodyParameter = parameters . find ( isSendInBody ) ; if ( ! bodyParameter ) { return { mimeType : supportedMimeType , } ; } const example = bodyParameter ? generateParameterExample ( bodyParameter . schema ) : undefined ; const text = JSON . stringify ( example , null , 2 ) ; return { mimeType : supportedMimeType , text , } ; } if ( mimeTypes && mimeTypes . length ) { return { mimeType : mimeTypes [ 0 ] || undefined , } ; } else { return { } ; } }
Imports insomnia request body definitions, including data mock (if available)

If multiple types are available, the one for which an example can be generated will be selected first (i.e. application/json)

@param {Object} endpointSchema - swagger 2.0 endpoint schema
@param {string[]} globalMimeTypes - list of mimeTypes available in document globally (i.e. document.consumes)

@return {Object} insomnia request's body definition
Imports insomnia request body definitions including data mock ( if available )
Prepare the body for the request