Repository: kestra-io/kestra (java)

Issue:
JSON Schema - failed validation checks
### Describe the issue

I'm working on updating the json schema for Kestra flows over at https://json.schemastore.org/. I've followed the same process I usually do but this time the checks fail, it seems to relate to the below section of code.

Looking at `format` it would seem to be related to matching a pebble string? The json schema spec seems to imply that `pattern` could be used. I updated the schema with `"pattern": ".*\\{\\{.*\\}\\}.*"` and this then passes the checks in the json schema git repo. What I'm not sure is how it's used with Kestra and would making this change lead to any issues?

https://github.com/kestra-io/kestra/blob/78f5ff2b7b085a9ad117e701ae0c59e1c9e7b27e/core/src/main/java/io/kestra/core/docs/JsonSchemaGenerator.java#L278

### Environment

- Kestra Version: 0.19.0 and above


Pull request description:
Fix/dynamic property
Fixes #6037

Patch:
diff --git a/core/src/main/java/io/kestra/core/docs/JsonSchemaGenerator.java b/core/src/main/java/io/kestra/core/docs/JsonSchemaGenerator.java
index a3cb6d7df..58801a563 100644
--- a/core/src/main/java/io/kestra/core/docs/JsonSchemaGenerator.java
+++ b/core/src/main/java/io/kestra/core/docs/JsonSchemaGenerator.java
@@ -16,6 +16,7 @@ import com.github.victools.jsonschema.module.jakarta.validation.JakartaValidatio
 import com.github.victools.jsonschema.module.jakarta.validation.JakartaValidationOption;
 import com.github.victools.jsonschema.module.swagger2.Swagger2Module;
 import com.google.common.collect.ImmutableMap;
+import io.kestra.core.models.property.Data;
 import io.kestra.core.models.property.Property;
 import io.kestra.core.models.annotations.Plugin;
 import io.kestra.core.models.annotations.PluginProperty;
@@ -272,11 +273,13 @@ public class JsonSchemaGenerator {
 
             if (member.getDeclaredType().isInstanceOf(Property.class)) {
                 memberAttributes.put("$dynamic", true);
-                // if we are in the String definition of a Property but the target type is not String: we configure the format
+                // if we are in the String definition of a Property but the target type is not String: we configure the pattern
                 Class<?> targetType = member.getDeclaredType().getTypeParameters().getFirst().getErasedType();
                 if (!String.class.isAssignableFrom(targetType) && String.class.isAssignableFrom(member.getType().getErasedType())) {
-                    memberAttributes.put("format", ".*{{.*}}.*");
+                    memberAttributes.put("pattern", ".*{{.*}}.*");
                 }
+            } else if (member.getDeclaredType().isInstanceOf(Data.class)) {
+                memberAttributes.put("$dynamic", false);
             }
         });
 


Test patch:
diff --git a/core/src/test/java/io/kestra/core/docs/ClassPluginDocumentationTest.java b/core/src/test/java/io/kestra/core/docs/ClassPluginDocumentationTest.java
index b80bff867..78823e11e 100644
--- a/core/src/test/java/io/kestra/core/docs/ClassPluginDocumentationTest.java
+++ b/core/src/test/java/io/kestra/core/docs/ClassPluginDocumentationTest.java
@@ -149,7 +149,7 @@ class ClassPluginDocumentationTest {
             assertThat(oneOf.getFirst().get("type"), is("integer"));
             assertThat(oneOf.getFirst().get("$dynamic"), is(true));
             assertThat(oneOf.get(1).get("type"), is("string"));
-            assertThat(oneOf.get(1).get("format"), is(".*{{.*}}.*"));
+            assertThat(oneOf.get(1).get("pattern"), is(".*{{.*}}.*"));
 
             Map<String, Object> withDefault = (Map<String, Object>) properties.get("withDefault");
             assertThat(withDefault.get("type"), is("string"));