@@ -2,6 +2,13 @@ var deepEqual = require('deep-equal');
22
33module . exports = convert ;
44
5+ function InvalidTypeError ( message ) {
6+ this . name = 'InvalidTypeError' ;
7+ this . message = message ;
8+ }
9+
10+ InvalidTypeError . prototype = new Error ( ) ;
11+
512function convert ( schema , options ) {
613 var notSupported = [
714 'nullable' , 'discriminator' , 'readOnly' ,
@@ -78,6 +85,7 @@ function convertSchema(schema, options) {
7885
7986 }
8087
88+ validateType ( schema . type ) ;
8189 schema = convertTypes ( schema , options ) ;
8290
8391 if ( typeof schema [ 'x-patternProperties' ] === 'object'
@@ -119,6 +127,14 @@ function convertProperties(properties, options) {
119127 return props ;
120128}
121129
130+ function validateType ( type ) {
131+ var validTypes = [ 'integer' , 'number' , 'string' , 'boolean' , 'object' , 'array' ] ;
132+
133+ if ( validTypes . indexOf ( type ) < 0 && type !== undefined ) {
134+ throw new InvalidTypeError ( 'Type "' + type + '" is not a valid type' ) ;
135+ }
136+ }
137+
122138function convertTypes ( schema , options ) {
123139 var toDateTime = options . dateToDateTime ;
124140
0 commit comments