Skip to content

Commit 1a0bdfb

Browse files
committed
deal with defaults outside of ofProperty
1 parent 59c03ae commit 1a0bdfb

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/Convertor.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,28 @@ class Convertor {
121121
}
122122
}
123123

124+
const defaultValuesForOfProperties = () => {
125+
if (schema.type === undefined && this.ofProperties.some(element => Object.keys(schema).includes(element))) {
126+
if (Object.keys(schema).includes('default')) {
127+
for (const property of this.ofProperties) {
128+
if (Object.keys(schema).includes(property)) {
129+
for (const ofProperty of schema[property]) {
130+
if (ofProperty.type !== 'null' || ofProperty.nullable) {
131+
ofProperty.default = schema.default
132+
delete schema.default
133+
}
134+
}
135+
}
136+
}
137+
}
138+
}
139+
}
140+
124141
convertNull()
125142
convertTypeArrays()
126143
bannedWordsRemoval()
127144
convertDefaultValues()
145+
defaultValuesForOfProperties()
128146

129147
if (this.specialProperties.indexOf(parentKeyword) !== -1) {
130148
if (this.ofProperties.indexOf(parentKeyword) !== -1) {

0 commit comments

Comments
 (0)