@@ -255,6 +255,66 @@ describe('DEREF FUNCTION TESTS ', function() {
255
255
expect ( output . pattern ) . to . eql ( schema . pattern ) ;
256
256
done ( ) ;
257
257
} ) ;
258
+
259
+ it ( 'should not contain readOnly properties in resolved schema if they are not contained' +
260
+ ' in resolved schema' , function ( done ) {
261
+ var schema = {
262
+ type : 'object' ,
263
+ required : [ 'id' , 'name' ] ,
264
+ properties : {
265
+ id : {
266
+ type : 'integer' ,
267
+ format : 'int64' ,
268
+ readOnly : true
269
+ } ,
270
+ name : {
271
+ type : 'string'
272
+ } ,
273
+ tag : {
274
+ type : 'string' ,
275
+ writeOnly : true
276
+ }
277
+ }
278
+ } ,
279
+ parameterSource = 'REQUEST' ,
280
+ output ;
281
+
282
+ output = deref . resolveRefs ( schema , parameterSource , { concreteUtils : schemaUtils30X } ) ;
283
+ expect ( output . type ) . to . equal ( 'object' ) ;
284
+ expect ( output . properties ) . to . not . haveOwnProperty ( 'id' ) ;
285
+ expect ( output . required ) . to . not . include ( 'id' ) ;
286
+ done ( ) ;
287
+ } ) ;
288
+
289
+ it ( 'should not contain writeOnly properties in resolved schema if they are not contained' +
290
+ ' in resolved schema' , function ( done ) {
291
+ var schema = {
292
+ type : 'object' ,
293
+ required : [ 'id' , 'tag' ] ,
294
+ properties : {
295
+ id : {
296
+ type : 'integer' ,
297
+ format : 'int64' ,
298
+ readOnly : true
299
+ } ,
300
+ name : {
301
+ type : 'string'
302
+ } ,
303
+ tag : {
304
+ type : 'string' ,
305
+ writeOnly : true
306
+ }
307
+ }
308
+ } ,
309
+ parameterSource = 'RESPONSE' ,
310
+ output ;
311
+
312
+ output = deref . resolveRefs ( schema , parameterSource , { concreteUtils : schemaUtils30X } ) ;
313
+ expect ( output . type ) . to . equal ( 'object' ) ;
314
+ expect ( output . properties ) . to . not . haveOwnProperty ( 'tag' ) ;
315
+ expect ( output . required ) . to . not . include ( 'tag' ) ;
316
+ done ( ) ;
317
+ } ) ;
258
318
} ) ;
259
319
260
320
describe ( 'resolveAllOf Function' , function ( ) {
0 commit comments