function prepare(definition) {
  const swaggerObject = JSON.parse(JSON.stringify(definition));
  const specificationTemplate = {
    v2: [
      'paths',
      'definitions',
      'responses',
      'parameters',
      'securityDefinitions',
    ],
    v3: [
      'paths',
      'definitions',
      'responses',
      'parameters',
      'securityDefinitions',
      'components',
    ],
    v4: ['components', 'channels'],
  };

  const getVersion = () => {
    if (swaggerObject.asyncapi) {
      return 'v4';
    }

    if (swaggerObject.openapi) {
      return 'v3';
    }

    if (swaggerObject.swagger) {
      return 'v2';
    }

    swaggerObject.swagger = '2.0';
    return 'v2';
  };

  const version = getVersion();

  specificationTemplate[version].forEach((property) => {
    swaggerObject[property] = swaggerObject[property] || {};
  });

  swaggerObject.tags = swaggerObject.tags || [];

  return swaggerObject;
}
Prepare the swagger/openapi specification object.
@see https://github.com/OAI/OpenAPI-Specification/tree/master/versions
@param {object} definition - The `definition` or `swaggerDefinition` from options.
@returns {object} swaggerObject