diff --git a/src/main/java/it/cnr/isti/workflow/manager/blocks/configurations/JsonSchemaProducer.java b/src/main/java/it/cnr/isti/workflow/manager/blocks/configurations/JsonSchemaProducer.java index b4b4825..b39b203 100644 --- a/src/main/java/it/cnr/isti/workflow/manager/blocks/configurations/JsonSchemaProducer.java +++ b/src/main/java/it/cnr/isti/workflow/manager/blocks/configurations/JsonSchemaProducer.java @@ -1203,6 +1203,10 @@ public class JsonSchemaProducer { for (String value : entry.getValue().value()) { enumValues.add(value); } + String defaultValue = entry.getValue().defaultValue(); + if (defaultValue != null && !defaultValue.isBlank()) { + propertySchema.put("default", defaultValue); + } } } diff --git a/src/main/java/it/cnr/isti/workflow/manager/blocks/configurations/MCPAgentBlockConfiguration.java b/src/main/java/it/cnr/isti/workflow/manager/blocks/configurations/MCPAgentBlockConfiguration.java index dab66b7..ddb14a9 100644 --- a/src/main/java/it/cnr/isti/workflow/manager/blocks/configurations/MCPAgentBlockConfiguration.java +++ b/src/main/java/it/cnr/isti/workflow/manager/blocks/configurations/MCPAgentBlockConfiguration.java @@ -124,7 +124,9 @@ public class MCPAgentBlockConfiguration extends BlockConfigurationHere rather than in an annotation of its own because it is the same statement: these are + * the values, and this is the one that holds when nobody chose. The editor needs it to say what + * an empty field is actually doing - without it, it can only say "using the default" and leave + * the reader to guess which. + */ + String defaultValue() default ""; } diff --git a/src/test/java/it/cnr/isti/workflow/manager/controllers/BlocksControllerTest.java b/src/test/java/it/cnr/isti/workflow/manager/controllers/BlocksControllerTest.java index f5eaecf..659f337 100644 --- a/src/test/java/it/cnr/isti/workflow/manager/controllers/BlocksControllerTest.java +++ b/src/test/java/it/cnr/isti/workflow/manager/controllers/BlocksControllerTest.java @@ -573,6 +573,18 @@ public class BlocksControllerTest { sharedSessionRef.path("x-retriever-url").asText()); assertEquals(UiContextKeys.FLOW_ID, sharedSessionRef.path("x-retriever-depends-on").get(0).asText()); + + // The binding's sourceType has a default in Java (effectiveSourceType(): blank means + // CATALOG) and now declares it, so the editor can say which default an empty field is + // using instead of only that it is using one. + // The binding is a nested record, so it lives in the definitions and mcpServers.items is a + // $ref to it - the same shape the other nested-record assertions in this class walk. + JsonNode definitions = schema.has("definitions") ? schema.path("definitions") : schema.path("$defs"); + JsonNode binding = definitions.path("MCPServerBinding"); + JsonNode sourceType = binding.path("properties").path("sourceType"); + assertEquals("CATALOG", sourceType.path("default").asText()); + assertEquals("CATALOG", sourceType.path("enum").get(0).asText()); + assertEquals("CUSTOM", sourceType.path("enum").get(1).asText()); assertTrue(sharedSessionRef.path("x-retriever-requires-auth").asBoolean()); }