Skip to content

Commit 5a8a889

Browse files
committed
Added support for file type filed for form-data body
1 parent c753ff0 commit 5a8a889

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

libV2/schemaUtils.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const schemaFaker = require('../assets/json-schema-faker'),
4545
'ipv4', 'ipv6',
4646
'regex',
4747
'uuid',
48+
'binary',
4849
'json-pointer',
4950
'int64',
5051
'float',
@@ -576,15 +577,9 @@ let QUERYPARAM = 'query',
576577
return;
577578
}
578579

579-
// Set type to binary
580-
if (property.format === 'binary') {
581-
property.type = 'binary';
582-
}
583-
584580
if (
585581
property.format === 'decimal' ||
586582
property.format === 'byte' ||
587-
property.format === 'binary' ||
588583
property.format === 'password' ||
589584
property.format === 'unix-time'
590585
) {
@@ -848,7 +843,6 @@ let QUERYPARAM = 'query',
848843
for (const prop in resolvedSchema.properties) {
849844
if (resolvedSchema.properties.hasOwnProperty(prop)) {
850845
if (
851-
resolvedSchema.properties[prop].format === 'binary' ||
852846
resolvedSchema.properties[prop].format === 'byte' ||
853847
resolvedSchema.properties[prop].format === 'decimal'
854848
) {
@@ -1363,7 +1357,6 @@ let QUERYPARAM = 'query',
13631357
}
13641358

13651359
if (
1366-
requestBodySchema.properties[prop].format === 'binary' ||
13671360
requestBodySchema.properties[prop].format === 'byte' ||
13681361
requestBodySchema.properties[prop].format === 'decimal'
13691362
) {
@@ -1523,7 +1516,7 @@ let QUERYPARAM = 'query',
15231516

15241517
// TODO: Add handling for headers from encoding
15251518

1526-
if (paramSchema && paramSchema.type === 'binary') {
1519+
if (paramSchema && paramSchema.type === 'string' && paramSchema.format === 'binary') {
15271520
param = {
15281521
key,
15291522
value: '',

libV2/validationUtils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ schemaFaker.option({
8585
maxItems: 20, // limit on maximum number of items faked for (type: array)
8686
useDefaultValue: true,
8787
ignoreMissingRefs: true,
88-
avoidExampleItemsLength: true // option to avoid validating type array schema example's minItems and maxItems props.
88+
avoidExampleItemsLength: true, // option to avoid validating type array schema example's minItems and maxItems props.
89+
failOnInvalidFormat: false
8990
});
9091

9192
/**

test/unit/faker.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ describe('JSON SCHEMA FAKER TESTS', function () {
1313
useDefaultValue: true,
1414
useExamplesValue: true,
1515
ignoreMissingRefs: true,
16-
avoidExampleItemsLength: false
16+
avoidExampleItemsLength: false,
17+
failOnInvalidFormat: false
1718
});
1819
});
1920

@@ -27,7 +28,8 @@ describe('JSON SCHEMA FAKER TESTS', function () {
2728
maxItems: 20,
2829
useDefaultValue: true,
2930
ignoreMissingRefs: true,
30-
avoidExampleItemsLength: true
31+
avoidExampleItemsLength: true,
32+
failOnInvalidFormat: false
3133
});
3234
});
3335

0 commit comments

Comments
 (0)