function finalize(swaggerObject, options) {
  let specification = swaggerObject;
  parser.parse(swaggerObject, (err, api) => {
    if (!err) {
      specification = api;
    }
  });

  if (specification.openapi) {
    specification = clean(specification);
  }

  return format(specification, options.format);
}
Parse the swagger object and remove useless properties if necessary.

@param {object} swaggerObject - Swagger object from parsing the api files.
@returns {object} The specification.