fantonangeli commented on code in PR #3367:
URL: 
https://github.com/apache/incubator-kie-tools/pull/3367#discussion_r2593425517


##########
packages/runtime-tools-components/src/utils/ModelConversionTool.ts:
##########
@@ -84,6 +104,7 @@ function convertModel(model: any, schema: Record<string, 
any>, ctx: ConversionCo
 
   Object.keys(model).forEach((propertyName) => {
     const property = schema.properties[propertyName];
+    const propSchema = 
lookupSchemaPropertyProps(schema.properties[propertyName], ctx);

Review Comment:
   This seems not to be used



##########
packages/runtime-tools-components/src/utils/ModelConversionTool.ts:
##########
@@ -25,6 +25,26 @@ export class ModelConversionTool {
   public static convertStringToDate = (model: any, schema: Record<string, 
any>): any => {
     return doConvert(model, schema, (value) => new Date(value));
   };
+
+  public static applySchemaDefaults(model: any, schema: Record<string, any>): 
any {
+    const newModel = { ...model };
+    if (schema.properties) {
+      Object.keys(schema.properties).forEach((key) => {
+        const prop = schema.properties[key];
+        if (newModel[key] !== undefined) {
+          return;
+        }
+        if (prop.default !== undefined) {
+          newModel[key] = prop.default;
+          return;
+        }
+        if (prop.type === "boolean") {
+          newModel[key] = false;
+        }

Review Comment:
   ```suggestion
           if (prop.type === "boolean" && newModel[key] === undefined) {
             newModel[key] = prop.default ?? false;
           }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to