Skip to content

Commit dbcd718

Browse files
committed
fix an issue with default values being undefined and not being on the correct types
1 parent fdb1e80 commit dbcd718

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Convertor.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ class Convertor {
6969
obj.nullable = true
7070
} else {
7171
obj.type = type
72+
if (schema?.default) {
73+
obj.default = schema.default
74+
delete schema.default
75+
}
76+
7277
for (const property of Object.keys(schema)) {
7378
if (type === 'array' && property === 'items') {
7479
obj.items = schema[property]
@@ -110,7 +115,7 @@ class Convertor {
110115
}
111116

112117
if (schema.type === 'string') {
113-
if (Object.keys(schema).indexOf('default')) {
118+
if (Object.keys(schema).indexOf('default') !== -1) {
114119
schema.default = `${schema.default}`
115120
}
116121
}

0 commit comments

Comments
 (0)