@@ -206,7 +206,7 @@ describe('SCHEMA UTILITY FUNCTION TESTS ', function () {
206
206
schemaCache = {
207
207
schemaFakerCache : { }
208
208
} ,
209
- key = hash ( 'resolveToSchema ' + JSON . stringify ( resolvedSchema ) ) ,
209
+ key = hash ( 'resolveToSchema ' + JSON . stringify ( resolvedSchema ) + ' schemaFormatDEFAULT' ) ,
210
210
options = {
211
211
indentCharacter : ' ' ,
212
212
stackLimit : 10 ,
@@ -251,7 +251,7 @@ describe('SCHEMA UTILITY FUNCTION TESTS ', function () {
251
251
{ components, concreteUtils } ,
252
252
{ resolveFor, resolveTo }
253
253
) ,
254
- key = hash ( 'resolveToExample ' + JSON . stringify ( resolvedSchema ) ) ,
254
+ key = hash ( 'resolveToExample ' + JSON . stringify ( resolvedSchema ) + ' schemaFormatDEFAULT' ) ,
255
255
options = {
256
256
indentCharacter : ' ' ,
257
257
stackLimit : 10 ,
@@ -268,6 +268,60 @@ describe('SCHEMA UTILITY FUNCTION TESTS ', function () {
268
268
done ( ) ;
269
269
270
270
} ) ;
271
+
272
+ it ( 'should populate schemaFakerCache with distinct value when only the schemaFormat is different' , function ( done ) {
273
+ var schema = {
274
+ $ref : '#/components/schema/request'
275
+ } ,
276
+ components = {
277
+ schema : {
278
+ request : {
279
+ properties : {
280
+ name : {
281
+ type : 'string'
282
+ }
283
+ }
284
+ }
285
+ }
286
+ } ,
287
+ parameterSource = 'REQUEST' ,
288
+ resolveTo = 'schema' ,
289
+ resolveFor = 'CONVERSION' ,
290
+ resolvedSchema = deref . resolveRefs ( schema ,
291
+ parameterSource ,
292
+ { components, concreteUtils } ,
293
+ { resolveFor, resolveTo }
294
+ ) ,
295
+ schemaCache = {
296
+ schemaFakerCache : { }
297
+ } ,
298
+ xml_key = hash ( 'resolveToSchema ' + JSON . stringify ( resolvedSchema ) + ' schemaFormatXML' ) ,
299
+ default_key = hash ( 'resolveToSchema ' + JSON . stringify ( resolvedSchema ) + ' schemaFormatDEFAULT' ) ,
300
+ options = {
301
+ indentCharacter : ' ' ,
302
+ stackLimit : 10 ,
303
+ includeDeprecated : true
304
+ } ,
305
+ fakedSchema_default = SchemaUtils . safeSchemaFaker ( schema , resolveTo , resolveFor , parameterSource ,
306
+ { components, concreteUtils } , 'default' , schemaCache , options ) ,
307
+ fakedSchema_xml = SchemaUtils . safeSchemaFaker ( schema , resolveTo , resolveFor , parameterSource ,
308
+ { components, concreteUtils } , 'xml' , schemaCache , options ) ;
309
+
310
+ expect ( schemaCache . schemaFakerCache ) . to . have . property ( default_key ) ;
311
+ expect ( schemaCache . schemaFakerCache [ default_key ] ) . to . equal ( fakedSchema_default ) ;
312
+ expect ( fakedSchema_default ) . to . eql ( {
313
+ name : '<string>'
314
+ } ) ;
315
+
316
+ expect ( schemaCache . schemaFakerCache ) . to . have . property ( xml_key ) ;
317
+ expect ( schemaCache . schemaFakerCache [ xml_key ] ) . to . equal ( fakedSchema_xml ) ;
318
+ expect ( fakedSchema_xml ) . to . eql (
319
+ '<element>\n <name>(string)</name>\n</element>'
320
+ ) ;
321
+
322
+ done ( ) ;
323
+ } ) ;
324
+
271
325
} ) ;
272
326
273
327
describe ( 'convertToPmCollectionVariables function' , function ( ) {
0 commit comments