Skip to content

Commit

Permalink
Add defaults for added object
Browse files Browse the repository at this point in the history
  • Loading branch information
Yevhen Zavhorodnii committed Nov 21, 2024
1 parent b25efa3 commit 938e1be
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions server/static/js/property-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ class EditorGenerator {

if (property.additionalProperties?.type === 'object') {
subObject[newKey] = {};

const nestedProperties = property.additionalProperties.properties || {};
for (const [nestedKey, nestedProperty] of Object.entries(nestedProperties)) {
if (nestedProperty.enum) {
subObject[newKey][nestedKey] = nestedProperty.enum[0]; // Initialize with first enum value
}
}
} else {
subObject[newKey] = '';
}
Expand Down Expand Up @@ -370,6 +377,14 @@ class EditorGenerator {
return;
}
subObject[newKey] = {};
const nestedProperties = property.additionalProperties.properties || {};
for (const [nestedKey, nestedProperty] of Object.entries(nestedProperties)) {
if (nestedProperty.enum) {
subObject[newKey][nestedKey] = nestedProperty.enum[0]; // Initialize with first enum value
}
}


renderExtendableEntries();
callback(key, newKey);
});
Expand Down Expand Up @@ -441,6 +456,13 @@ class EditorGenerator {

if (property.additionalProperties?.type === 'object') {
subObject[newKey] = {};

const nestedProperties = property.additionalProperties.properties || {};
for (const [nestedKey, nestedProperty] of Object.entries(nestedProperties)) {
if (nestedProperty.enum) {
subObject[newKey][nestedKey] = nestedProperty.enum[0]; // Initialize with first enum value
}
}
} else {
subObject[newKey] = '';
}
Expand Down

0 comments on commit 938e1be

Please sign in to comment.