From 8d6190bf2ecfb6b2092a7be103023d10d0240a54 Mon Sep 17 00:00:00 2001 From: Shivam Gupta Date: Wed, 9 Oct 2024 16:25:43 +0530 Subject: [PATCH] Fix(catalog): Expressions does not show input expression field as required --- .../camelcatalog/generator/CamelCatalogProcessor.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CamelCatalogProcessor.java b/packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CamelCatalogProcessor.java index d0efb4421..794b187ab 100644 --- a/packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CamelCatalogProcessor.java +++ b/packages/catalog-generator/src/main/java/io/kaoto/camelcatalog/generator/CamelCatalogProcessor.java @@ -250,6 +250,7 @@ public String getLanguageCatalog() throws Exception { catalogMap.put(modelCatalog.getName(), camelCatalog.eipModel(name)); } for (var entry : languageSchemaMap.entrySet()) { + List required = new ArrayList<>(); var languageName = entry.getKey(); var languageSchema = entry.getValue(); EipModel eipModel = catalogMap.get(languageName); @@ -267,6 +268,16 @@ public String getLanguageCatalog() throws Exception { var json = JsonMapper.asJsonObject(languageCatalog).toJson(); var catalogTree = (ObjectNode) jsonMapper.readTree(json); catalogTree.set("propertiesSchema", languageSchema); + // setting required property to the language schema + var camelYamlDslProperties = languageSchema.withObject("/properties").properties().stream() + .map(Map.Entry::getKey).toList(); + for (var propertyName : camelYamlDslProperties) { + var catalogPropertySchema = catalogTree.withObject("/properties").withObject("/" + propertyName); + if (catalogPropertySchema.has("required") && catalogPropertySchema.get("required").asBoolean()) { + required.add(propertyName); + } + } + catalogTree.withObject("/propertiesSchema").set("required", jsonMapper.valueToTree(required)); answer.set(languageName, catalogTree); } StringWriter writer = new StringWriter();