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 fa95c3be1..0e33268be 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 @@ -22,6 +22,7 @@ import org.apache.camel.catalog.CamelCatalog; import org.apache.camel.tooling.model.ComponentModel; import org.apache.camel.tooling.model.EipModel; +import org.apache.camel.tooling.model.EipModel.EipOptionModel; import org.apache.camel.tooling.model.JsonMapper; import org.apache.camel.tooling.model.Kind; @@ -200,11 +201,24 @@ private void generatePropertiesSchema(ObjectNode parent) { * @throws Exception */ public String getDataFormatCatalog() throws Exception { + var catalogMap = new LinkedHashMap(); + for (var name : camelCatalog.findDataFormatNames()) { + var modelCatalog = camelCatalog.dataFormatModel(name); + catalogMap.put(modelCatalog.getName(), camelCatalog.eipModel(name)); + } var answer = jsonMapper.createObjectNode(); var dataFormatSchemaMap = schemaProcessor.getDataFormats(); for (var entry : dataFormatSchemaMap.entrySet()) { var dataFormatName = entry.getKey(); var dataFormatSchema = entry.getValue(); + EipModel eipModel = catalogMap.get(dataFormatName); + List eipModelOptions = Arrays.asList(); + if (eipModel != null) { + eipModelOptions = eipModel.getOptions(); + } + + sortPropertiesAccordingToCamelCatalog(dataFormatSchema, eipModelOptions); + var dataFormatCatalog = (EipModel) camelCatalog.model(Kind.eip, dataFormatName); if (dataFormatCatalog == null) { throw new Exception("DataFormat " + dataFormatName + " is not found in Camel model catalog."); @@ -230,9 +244,22 @@ public String getDataFormatCatalog() throws Exception { public String getLanguageCatalog() throws Exception { var answer = jsonMapper.createObjectNode(); var languageSchemaMap = schemaProcessor.getLanguages(); + var catalogMap = new LinkedHashMap(); + for (var name : camelCatalog.findLanguageNames()) { + var modelCatalog = camelCatalog.languageModel(name); + catalogMap.put(modelCatalog.getName(), camelCatalog.eipModel(name)); + } for (var entry : languageSchemaMap.entrySet()) { var languageName = entry.getKey(); var languageSchema = entry.getValue(); + EipModel eipModel = catalogMap.get(languageName); + List eipModelOptions = Arrays.asList(); + if (eipModel != null) { + eipModelOptions = eipModel.getOptions(); + } + + sortPropertiesAccordingToCamelCatalog(languageSchema, eipModelOptions); + var languageCatalog = (EipModel) camelCatalog.model(Kind.eip, languageName); if (languageCatalog == null) { throw new Exception("Language " + languageName + " is not found in Camel model catalog."); @@ -426,7 +453,7 @@ public String getEntityCatalog() throws Exception { processEntityParameters(entityName, entitySchema, entityCatalog); } - sortPropertiesAccordingToCamelCatalog(entitySchema, entityCatalog); + sortPropertiesAccordingToCamelCatalog(entitySchema, entityCatalog.getOptions()); var json = JsonMapper.asJsonObject(entityCatalog).toJson(); var catalogTree = (ObjectNode) jsonMapper.readTree(json); @@ -624,11 +651,11 @@ private void processEntityParameters(String entityName, ObjectNode entitySchema, } } - private void sortPropertiesAccordingToCamelCatalog(ObjectNode entitySchema, EipModel entityCatalog) { + private void sortPropertiesAccordingToCamelCatalog(ObjectNode entitySchema, List entityCatalogOptions) { var sortedSchemaProperties = jsonMapper.createObjectNode(); var camelYamlDslProperties = entitySchema.withObject("/properties").properties().stream().map(Map.Entry::getKey) .sorted( - new CamelYamlDSLKeysComparator(entityCatalog.getOptions())) + new CamelYamlDSLKeysComparator(entityCatalogOptions)) .toList(); for (var propertyName : camelYamlDslProperties) {