@@ -160,6 +160,62 @@ test('keeping additionalProperties with object type', function(assert) {
160
160
assert . deepEqual ( result , expected , 'additionalProperties kept unchanged' ) ;
161
161
} ) ;
162
162
163
+ test ( 'keeping additionalProperties with array type' , function ( assert ) {
164
+ var schema
165
+ , result
166
+ , expected
167
+ ;
168
+
169
+ assert . plan ( 1 ) ;
170
+
171
+ schema = {
172
+ type : 'object' ,
173
+ additionalProperties : {
174
+ type : 'array' ,
175
+ items : {
176
+ type : 'string'
177
+ }
178
+ } ,
179
+ 'x-patternProperties' : {
180
+ '^[a-z]*$' : {
181
+ type : 'string'
182
+ } ,
183
+ '^[A-Z]*$' : {
184
+ type : 'array' ,
185
+ items : {
186
+ type : 'string'
187
+ }
188
+ }
189
+ }
190
+ } ;
191
+
192
+ result = convert ( schema , { supportPatternProperties : true } ) ;
193
+
194
+ expected = {
195
+ $schema : 'http://json-schema.org/draft-04/schema#' ,
196
+ type : 'object' ,
197
+ additionalProperties : {
198
+ type : 'array' ,
199
+ items : {
200
+ type : 'string'
201
+ }
202
+ } ,
203
+ patternProperties : {
204
+ '^[a-z]*$' : {
205
+ type : 'string'
206
+ } ,
207
+ '^[A-Z]*$' : {
208
+ type : 'array' ,
209
+ items : {
210
+ type : 'string'
211
+ }
212
+ }
213
+ }
214
+ } ;
215
+
216
+ assert . deepEqual ( result , expected , 'additionalProperties kept unchanged' ) ;
217
+ } ) ;
218
+
163
219
test ( 'not supporting patternProperties' , function ( assert ) {
164
220
var schema
165
221
, result
@@ -278,3 +334,38 @@ test('setting custom patternProperties handler', function(assert) {
278
334
279
335
assert . deepEqual ( result , expected , 'handler with custom handler' ) ;
280
336
} ) ;
337
+
338
+ test ( 'additionalProperties not modified if set to true' , function ( assert ) {
339
+ var schema
340
+ , result
341
+ , expected
342
+ , options
343
+ ;
344
+
345
+ assert . plan ( 1 ) ;
346
+
347
+ schema = {
348
+ type : 'object' ,
349
+ additionalProperties : true ,
350
+ 'x-patternProperties' : {
351
+ '^[a-z]*$' : {
352
+ type : 'string'
353
+ }
354
+ }
355
+ } ;
356
+
357
+ result = convert ( schema , { supportPatternProperties : true } ) ;
358
+
359
+ expected = {
360
+ $schema : 'http://json-schema.org/draft-04/schema#' ,
361
+ type : 'object' ,
362
+ additionalProperties : true ,
363
+ patternProperties : {
364
+ '^[a-z]*$' : {
365
+ type : 'string'
366
+ }
367
+ }
368
+ } ;
369
+
370
+ assert . deepEqual ( result , expected , 'additionalProperties not removed' ) ;
371
+ } ) ;
0 commit comments