function handleOptions(options) {
  // We default to the `all` type if no explicit datatype
  // was provided
  let datatype = options.datatype || 'all';
  // Normalize the legacy `integer` type to `int`.
  if (datatype === 'integer') { datatype = 'int'; }

  // By default ports are not required for graph execution
  const required = options.required || false;

  // Ensure datatype defined for the port is valid
  if (validTypes.indexOf(datatype) === -1) {
    throw new Error(`Invalid port datatype '${datatype}' specified, valid are ${validTypes.join(', ')}`);
  }

  // Ensure schema defined for the port is valid
  const schema = options.schema || options.type;

  if (schema && (schema.indexOf('/') === -1)) {
    throw new Error(`Invalid port schema '${schema}' specified. Should be URL or MIME type`);
  }

  // Scoping
  const scoped = (typeof options.scoped === 'boolean') ? options.scoped : true;

  // Description
  const description = options.description || '';

  /* eslint-disable prefer-object-spread */
  return Object.assign({}, options, {
    description,
    datatype,
    required,
    schema,
    scoped,
  });
}
@template {BaseOptions} BaseportOptions
@param {BaseportOptions} options
@return {BaseportOptions}