Skip to content

Commit ccda74f

Browse files
committed
#708 Fixes issue where if string is defined for required field, conversion was failing
1 parent afe9a58 commit ccda74f

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

assets/json-schema-faker.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24352,10 +24352,6 @@ function extend() {
2435224352
const skipped = [];
2435324353
const missing = [];
2435424354

24355-
if (typeof _props !== 'object') {
24356-
console.log('here');
24357-
}
24358-
2435924355
_props.forEach(key => {
2436024356
for (let i = 0; i < ignoreProperties.length; i += 1) {
2436124357
if ((ignoreProperties[i] instanceof RegExp && ignoreProperties[i].test(key))

test/unit/faker.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,22 @@ describe('JSON SCHEMA FAKER TESTS', function () {
136136
expect(fakedData.length >= 2).to.be.true;
137137
expect(fakedData.length <= 63).to.be.true;
138138
});
139+
140+
it('Should successsfully generate data iff required is defined as string', function () {
141+
const schema = {
142+
type: 'object',
143+
required: 'timebase',
144+
properties: {
145+
timebase: { type: 'string' },
146+
linkid: { type: 'string' },
147+
chartRef: { type: 'string' }
148+
}
149+
};
150+
151+
var fakedData = schemaFaker(schema);
152+
expect(fakedData).to.be.an('object');
153+
expect(fakedData.timebase).to.be.a('string');
154+
expect(fakedData.linkid).to.be.a('string');
155+
expect(fakedData.chartRef).to.be.a('string');
156+
});
139157
});

0 commit comments

Comments
 (0)