src/dt2js.js
function convertType (data) {
  switch (data.type) {
    case 'union':
      // If union of arrays
      if (Array.isArray(data.anyOf) && data.anyOf[0].type === 'array') {
        const items = data.anyOf.map(function (e) { return e.items })
        data.items = { anyOf: [] }
        data.items.anyOf = items
        data['type'] = 'array'
        delete data.anyOf
      } else {
        data['type'] = 'object'
      }
      break
    case 'nil':
      data['type'] = 'null'
      break
    case 'file':
      data = convertFileType(data)
      break
  }
  return data
}
function convertType (data) {
  switch (data.type) {
    case 'union':
      // If union of arrays
      if (Array.isArray(data.anyOf) && data.anyOf[0].type === 'array') {
        const items = data.anyOf.map(function (e) { return e.items })
        data.items = { anyOf: [] }
        data.items.anyOf = items
        data['type'] = 'array'
        delete data.anyOf
      } else {
        data['type'] = 'object'
      }
      break
    case 'nil':
      data['type'] = 'null'
      break
    case 'file':
      data = convertFileType(data)
      break
  }
  return data
}
function convertType ( data ) { switch ( data . type ) { case 'union' : // If union of arrays if ( Array . isArray ( data . anyOf ) && data . anyOf [ 0 ] . type === 'array' ) { const items = data . anyOf . map ( function ( e ) { return e . items } ) data . items = { anyOf : [ ] } data . items . anyOf = items data [ 'type' ] = 'array' delete data . anyOf } else { data [ 'type' ] = 'object' } break case 'nil' : data [ 'type' ] = 'null' break case 'file' : data = convertFileType ( data ) break } return data }
Change RAML type of data to valid JSON schema type.

@param  {Object} data
@returns  {Object}
Change RAML type of data to valid JSON schema type .