This is an automated email from the ASF dual-hosted git repository. marat pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-karavan.git
commit 7a40c58ff28de99af5c19e6da98027f91c8ff69a Author: Marat Gubaidullin <ma...@talismancloud.io> AuthorDate: Wed Apr 10 17:17:44 2024 -0400 Models for Camel 4.5.0 --- karavan-core/src/core/api/CamelDefinitionApi.ts | 34 +++++++++++-- .../src/core/api/CamelDefinitionYamlStep.ts | 56 ++++++++++++++++++++-- karavan-core/src/core/model/CamelDefinition.ts | 22 +++++++-- karavan-core/src/core/model/CamelMetadata.ts | 11 +++-- .../generator/CamelDefinitionApiGenerator.java | 18 ++++--- .../generator/CamelDefinitionGenerator.java | 1 + .../CamelDefinitionYamlStepGenerator.java | 24 ++++++---- 7 files changed, 136 insertions(+), 30 deletions(-) diff --git a/karavan-core/src/core/api/CamelDefinitionApi.ts b/karavan-core/src/core/api/CamelDefinitionApi.ts index fac45714..fa772f19 100644 --- a/karavan-core/src/core/api/CamelDefinitionApi.ts +++ b/karavan-core/src/core/api/CamelDefinitionApi.ts @@ -21,8 +21,9 @@ import {CamelElement} from "../model/IntegrationDefinition"; import { ProcessorDefinition, + ErrorHandlerFactory, BeansDeserializer, - ErrorHandlerBuilderDeserializer, + ErrorHandlerDeserializer, OutputAwareFromDefinition, AggregateDefinition, BeanDefinition, @@ -444,14 +445,38 @@ export class CamelDefinitionApi { return def; } + static createErrorHandlerFactory = (element: any): ErrorHandlerFactory => { + const def = element ? new ErrorHandlerFactory({...element}) : new ErrorHandlerFactory(); + def.uuid = element?.uuid ? element.uuid : def.uuid; + if (element?.deadLetterChannel !== undefined) { + def.deadLetterChannel = CamelDefinitionApi.createDeadLetterChannelDefinition(element.deadLetterChannel); + } + if (element?.defaultErrorHandler !== undefined) { + def.defaultErrorHandler = CamelDefinitionApi.createDefaultErrorHandlerDefinition(element.defaultErrorHandler); + } + if (element?.jtaTransactionErrorHandler !== undefined) { + def.jtaTransactionErrorHandler = CamelDefinitionApi.createJtaTransactionErrorHandlerDefinition(element.jtaTransactionErrorHandler); + } + if (element?.noErrorHandler !== undefined) { + def.noErrorHandler = CamelDefinitionApi.createNoErrorHandlerDefinition(element.noErrorHandler); + } + if (element?.refErrorHandler !== undefined) { + def.refErrorHandler = CamelDefinitionApi.createRefErrorHandlerDefinition(element.refErrorHandler); + } + if (element?.springTransactionErrorHandler !== undefined) { + def.springTransactionErrorHandler = CamelDefinitionApi.createSpringTransactionErrorHandlerDefinition(element.springTransactionErrorHandler); + } + return def; + } + static createBeansDeserializer = (element: any): BeansDeserializer => { const def = element ? new BeansDeserializer({...element}) : new BeansDeserializer(); def.uuid = element?.uuid ? element.uuid : def.uuid; return def; } - static createErrorHandlerBuilderDeserializer = (element: any): ErrorHandlerBuilderDeserializer => { - const def = element ? new ErrorHandlerBuilderDeserializer({...element}) : new ErrorHandlerBuilderDeserializer(); + static createErrorHandlerDeserializer = (element: any): ErrorHandlerDeserializer => { + const def = element ? new ErrorHandlerDeserializer({...element}) : new ErrorHandlerDeserializer(); def.uuid = element?.uuid ? element.uuid : def.uuid; if (element?.deadLetterChannel !== undefined) { def.deadLetterChannel = CamelDefinitionApi.createDeadLetterChannelDefinition(element.deadLetterChannel); @@ -2909,8 +2934,9 @@ export class CamelDefinitionApi { const newBody = CamelUtil.camelizeBody(name, body, clone); switch (name) { case 'ProcessorDefinition': return CamelDefinitionApi.createProcessorDefinition(newBody); + case 'ErrorHandlerFactory': return CamelDefinitionApi.createErrorHandlerFactory(newBody); case 'BeansDeserializer': return CamelDefinitionApi.createBeansDeserializer(newBody); - case 'ErrorHandlerBuilderDeserializer': return CamelDefinitionApi.createErrorHandlerBuilderDeserializer(newBody); + case 'ErrorHandlerDeserializer': return CamelDefinitionApi.createErrorHandlerDeserializer(newBody); case 'OutputAwareFromDefinition': return CamelDefinitionApi.createOutputAwareFromDefinition(newBody); case 'AggregateDefinition': return CamelDefinitionApi.createAggregateDefinition(newBody); case 'BeanDefinition': return CamelDefinitionApi.createBeanDefinition(newBody); diff --git a/karavan-core/src/core/api/CamelDefinitionYamlStep.ts b/karavan-core/src/core/api/CamelDefinitionYamlStep.ts index 4ad20158..61c57064 100644 --- a/karavan-core/src/core/api/CamelDefinitionYamlStep.ts +++ b/karavan-core/src/core/api/CamelDefinitionYamlStep.ts @@ -22,8 +22,9 @@ import {CamelElement} from "../model/IntegrationDefinition"; import { ProcessorDefinition, + ErrorHandlerFactory, BeansDeserializer, - ErrorHandlerBuilderDeserializer, + ErrorHandlerDeserializer, OutputAwareFromDefinition, AggregateDefinition, BeanDefinition, @@ -696,6 +697,55 @@ export class CamelDefinitionYamlStep { return def; } + static readErrorHandlerFactory = (element: any): ErrorHandlerFactory => { + + let def = element ? new ErrorHandlerFactory({...element}) : new ErrorHandlerFactory(); + if (element?.deadLetterChannel !== undefined) { + if (Array.isArray(element.deadLetterChannel)) { + def.deadLetterChannel = CamelDefinitionYamlStep.readDeadLetterChannelDefinition(element.deadLetterChannel[0]); + } else { + def.deadLetterChannel = CamelDefinitionYamlStep.readDeadLetterChannelDefinition(element.deadLetterChannel); + } + } + if (element?.noErrorHandler !== undefined) { + if (Array.isArray(element.noErrorHandler)) { + def.noErrorHandler = CamelDefinitionYamlStep.readNoErrorHandlerDefinition(element.noErrorHandler[0]); + } else { + def.noErrorHandler = CamelDefinitionYamlStep.readNoErrorHandlerDefinition(element.noErrorHandler); + } + } + if (element?.jtaTransactionErrorHandler !== undefined) { + if (Array.isArray(element.jtaTransactionErrorHandler)) { + def.jtaTransactionErrorHandler = CamelDefinitionYamlStep.readJtaTransactionErrorHandlerDefinition(element.jtaTransactionErrorHandler[0]); + } else { + def.jtaTransactionErrorHandler = CamelDefinitionYamlStep.readJtaTransactionErrorHandlerDefinition(element.jtaTransactionErrorHandler); + } + } + if (element?.defaultErrorHandler !== undefined) { + if (Array.isArray(element.defaultErrorHandler)) { + def.defaultErrorHandler = CamelDefinitionYamlStep.readDefaultErrorHandlerDefinition(element.defaultErrorHandler[0]); + } else { + def.defaultErrorHandler = CamelDefinitionYamlStep.readDefaultErrorHandlerDefinition(element.defaultErrorHandler); + } + } + if (element?.springTransactionErrorHandler !== undefined) { + if (Array.isArray(element.springTransactionErrorHandler)) { + def.springTransactionErrorHandler = CamelDefinitionYamlStep.readSpringTransactionErrorHandlerDefinition(element.springTransactionErrorHandler[0]); + } else { + def.springTransactionErrorHandler = CamelDefinitionYamlStep.readSpringTransactionErrorHandlerDefinition(element.springTransactionErrorHandler); + } + } + if (element?.refErrorHandler !== undefined) { + if (Array.isArray(element.refErrorHandler)) { + def.refErrorHandler = CamelDefinitionYamlStep.readRefErrorHandlerDefinition(element.refErrorHandler[0]); + } else { + def.refErrorHandler = CamelDefinitionYamlStep.readRefErrorHandlerDefinition(element.refErrorHandler); + } + } + + return def; + } + static readBeansDeserializer = (element: any): BeansDeserializer => { let def = element ? new BeansDeserializer({...element}) : new BeansDeserializer(); @@ -703,9 +753,9 @@ export class CamelDefinitionYamlStep { return def; } - static readErrorHandlerBuilderDeserializer = (element: any): ErrorHandlerBuilderDeserializer => { + static readErrorHandlerDeserializer = (element: any): ErrorHandlerDeserializer => { - let def = element ? new ErrorHandlerBuilderDeserializer({...element}) : new ErrorHandlerBuilderDeserializer(); + let def = element ? new ErrorHandlerDeserializer({...element}) : new ErrorHandlerDeserializer(); if (element?.deadLetterChannel !== undefined) { if (Array.isArray(element.deadLetterChannel)) { def.deadLetterChannel = CamelDefinitionYamlStep.readDeadLetterChannelDefinition(element.deadLetterChannel[0]); diff --git a/karavan-core/src/core/model/CamelDefinition.ts b/karavan-core/src/core/model/CamelDefinition.ts index c8b7df1d..093ecb92 100644 --- a/karavan-core/src/core/model/CamelDefinition.ts +++ b/karavan-core/src/core/model/CamelDefinition.ts @@ -92,6 +92,19 @@ export class ProcessorDefinition extends CamelElement { } } +export class ErrorHandlerFactory extends CamelElement { + deadLetterChannel?: DeadLetterChannelDefinition; + defaultErrorHandler?: DefaultErrorHandlerDefinition; + jtaTransactionErrorHandler?: JtaTransactionErrorHandlerDefinition; + noErrorHandler?: NoErrorHandlerDefinition; + refErrorHandler?: RefErrorHandlerDefinition | string; + springTransactionErrorHandler?: SpringTransactionErrorHandlerDefinition; + public constructor(init?: Partial<ErrorHandlerFactory>) { + super('ErrorHandlerFactory'); + Object.assign(this, init); + } +} + export class BeansDeserializer extends CamelElement { public constructor(init?: Partial<BeansDeserializer>) { @@ -100,15 +113,15 @@ export class BeansDeserializer extends CamelElement { } } -export class ErrorHandlerBuilderDeserializer extends CamelElement { +export class ErrorHandlerDeserializer extends CamelElement { deadLetterChannel?: DeadLetterChannelDefinition; defaultErrorHandler?: DefaultErrorHandlerDefinition; jtaTransactionErrorHandler?: JtaTransactionErrorHandlerDefinition; noErrorHandler?: NoErrorHandlerDefinition; refErrorHandler?: RefErrorHandlerDefinition | string; springTransactionErrorHandler?: SpringTransactionErrorHandlerDefinition; - public constructor(init?: Partial<ErrorHandlerBuilderDeserializer>) { - super('ErrorHandlerBuilderDeserializer'); + public constructor(init?: Partial<ErrorHandlerDeserializer>) { + super('ErrorHandlerDeserializer'); Object.assign(this, init); } } @@ -1064,6 +1077,8 @@ export class Resilience4jConfigurationDefinition extends CamelElement { timeoutExecutorService?: string; timeoutDuration?: number; timeoutCancelRunningFuture?: boolean; + recordException?: string[] = []; + ignoreException?: string[] = []; public constructor(init?: Partial<Resilience4jConfigurationDefinition>) { super('Resilience4jConfigurationDefinition'); Object.assign(this, init); @@ -1164,6 +1179,7 @@ export class RouteDefinition extends CamelElement { trace?: boolean; messageHistory?: boolean; logMask?: boolean; + errorHandlerRef?: string; shutdownRoute?: string; shutdownRunningTask?: string; precondition?: string; diff --git a/karavan-core/src/core/model/CamelMetadata.ts b/karavan-core/src/core/model/CamelMetadata.ts index b07e1b79..f36ad308 100644 --- a/karavan-core/src/core/model/CamelMetadata.ts +++ b/karavan-core/src/core/model/CamelMetadata.ts @@ -157,7 +157,7 @@ export const CamelDataFormatMetadata: ElementMeta[] = [ new ElementMeta('avro', 'AvroDataFormat', 'Avro', "Serialize and deserialize messages using Apache Avro binary data format.", 'dataformat,transformation', [ new PropertyMeta('id', 'Id', "The id of this node", 'string', '', '', false, false, false, false, '', ''), new PropertyMeta('instanceClassName', 'Instance Class Name', "Class name to use for marshal and unmarshalling", 'string', '', '', false, false, false, false, '', ''), - new PropertyMeta('library', 'Library', "Which Avro library to use.", 'string', 'ApacheAvro, Jackson', 'ApacheAvro', false, false, false, false, '', ''), + new PropertyMeta('library', 'Library', "Which Avro library to use.", 'string', 'ApacheAvro, Jackson', 'avroJackson', false, false, false, false, '', ''), new PropertyMeta('objectMapper', 'Object Mapper', "Lookup and use the existing ObjectMapper with the given id when using Jackson.", 'string', '', '', false, false, false, false, 'advanced', ''), new PropertyMeta('useDefaultObjectMapper', 'Use Default Object Mapper', "Whether to lookup and use default Jackson ObjectMapper from the registry.", 'boolean', '', 'true', false, false, false, false, '', ''), new PropertyMeta('unmarshalType', 'Unmarshal Type', "Class name of the java type to use when unmarshalling", 'string', '', '', false, false, false, false, '', ''), @@ -1646,11 +1646,13 @@ export const CamelModelMetadata: ElementMeta[] = [ new PropertyMeta('trace', 'Trace', "Whether tracing is enabled on this route.", 'boolean', '', '', false, false, false, false, '', ''), new PropertyMeta('messageHistory', 'Message History', "Whether message history is enabled on this route.", 'boolean', '', '', false, false, false, false, '', ''), new PropertyMeta('logMask', 'Log Mask', "Whether security mask for Logging is enabled on this route.", 'boolean', '', 'false', false, false, false, false, '', ''), + new PropertyMeta('errorHandlerRef', 'Error Handler', "Sets the bean ref name of the error handler builder to use on this route", 'string', '', '', false, false, false, false, 'error', ''), new PropertyMeta('shutdownRoute', 'Shutdown Route', "To control how to shutdown the route.", 'string', 'Default, Defer', '', false, false, false, false, 'advanced', ''), new PropertyMeta('shutdownRunningTask', 'Shutdown Running Task', "To control how to shut down the route.", 'string', 'CompleteCurrentTaskOnly, CompleteAllTasks', '', false, false, false, false, 'advanced', ''), new PropertyMeta('precondition', 'Precondition', "The predicate of the precondition in simple language to evaluate in order to determine if this route should be included or not.", 'string', '', '', false, false, false, false, 'advanced', ''), new PropertyMeta('inputType', 'Input Type', "Declare the expected data type of the input message. If the actual message type is different at runtime, camel look for a required org.apache.camel.spi.Transformer and apply if exists. The type name consists of two parts, 'scheme' and 'name' connected with ':'. For Java type 'name' is a fully qualified class name. For example {code java:java.lang.String} , {code json:ABCOrder} .", 'InputTypeDefinition', '', '', false, false, false, tru [...] new PropertyMeta('outputType', 'Output Type', "Declare the expected data type of the output message. If the actual message type is different at runtime, camel look for a required org.apache.camel.spi.Transformer and apply if exists. The type name consists of two parts, 'scheme' and 'name' connected with ':'. For Java type 'name' is a fully qualified class name. For example {code java:java.lang.String} , {code json:ABCOrder} .", 'OutputTypeDefinition', '', '', false, false, false, [...] + new PropertyMeta('errorHandler', 'errorHandler', "errorHandler", 'ErrorHandlerFactory', '', '', false, false, false, true, '', ''), new PropertyMeta('from', 'from', "from", 'FromDefinition', '', '', false, false, false, true, '', ''), new PropertyMeta('routePolicy', 'routePolicy', "routePolicy", 'string', '', '', false, false, false, false, '', ''), new PropertyMeta('streamCaching', 'streamCaching', "streamCaching", 'boolean', '', '', false, false, false, false, '', ''), @@ -1678,7 +1680,7 @@ export const CamelModelMetadata: ElementMeta[] = [ new PropertyMeta('host', 'Host', "The hostname to use for exposing the REST service.", 'string', '', '', false, false, false, false, '', ''), new PropertyMeta('port', 'Port', "The port number to use for exposing the REST service. Notice if you use servlet component then the port number configured here does not apply, as the port number in use is the actual port number the servlet component is using. eg if using Apache Tomcat its the tomcat http port, if using Apache Karaf its the HTTP service in Karaf that uses port 8181 by default etc. Though in those situations setting the port number here, allows tooling and JMX to [...] new PropertyMeta('apiHost', 'Api Host', "To use a specific hostname for the API documentation (such as swagger or openapi) This can be used to override the generated host with this configured hostname", 'string', '', '', false, false, false, false, 'consumer,advanced', ''), - new PropertyMeta('useXForwardHeaders', 'Use XForward Headers', "Whether to use X-Forward headers for Host and related setting. The default value is true.", 'boolean', '', 'true', false, false, false, false, 'consumer,advanced', ''), + new PropertyMeta('useXForwardHeaders', 'Use XForward Headers', "Whether to use X-Forward headers to set host etc. for OpenApi. This may be needed in special cases involving reverse-proxy and networking going from HTTP to HTTPS etc. Then the proxy can send X-Forward headers (X-Forwarded-Proto) that influences the host names in the OpenAPI schema that camel-openapi-java generates from Rest DSL routes.", 'boolean', '', 'false', false, false, false, false, 'consumer,advanced', ''), new PropertyMeta('producerApiDoc', 'Producer Api Doc', "Sets the location of the api document the REST producer will use to validate the REST uri and query parameters are valid accordingly to the api document. The location of the api document is loaded from classpath by default, but you can use file: or http: to refer to resources to load from file or http url.", 'string', '', '', false, false, false, false, 'producer,advanced', ''), new PropertyMeta('contextPath', 'Context Path', "Sets a leading context-path the REST services will be using. This can be used when using components such as camel-servlet where the deployed web application is deployed using a context-path. Or for components such as camel-jetty or camel-netty-http that includes a HTTP server.", 'string', '', '', false, false, false, false, 'consumer', ''), new PropertyMeta('apiContextPath', 'Api Context Path', "Sets a leading API context-path the REST API services will be using. This can be used when using components such as camel-servlet where the deployed web application is deployed using a context-path.", 'string', '', '', false, false, false, false, 'consumer', ''), @@ -1690,7 +1692,7 @@ export const CamelModelMetadata: ElementMeta[] = [ new PropertyMeta('clientRequestValidation', 'Client Request Validation', "Whether to enable validation of the client request to check: 1) Content-Type header matches what the Rest DSL consumes; returns HTTP Status 415 if validation error. 2) Accept header matches what the Rest DSL produces; returns HTTP Status 406 if validation error. 3) Missing required data (query parameters, HTTP headers, body); returns HTTP Status 400 if validation error. 4) Parsing error of the message body [...] new PropertyMeta('enableCORS', 'Enable CORS', "Whether to enable CORS headers in the HTTP response. The default value is false.", 'boolean', '', 'false', false, false, false, false, 'consumer,advanced', ''), new PropertyMeta('enableNoContentResponse', 'Enable No Content Response', "Whether to return HTTP 204 with an empty body when a response contains an empty JSON object or XML root object. The default value is false.", 'boolean', '', 'false', false, false, false, false, 'consumer,advanced', ''), - new PropertyMeta('inlineRoutes', 'Inline Routes', "Inline routes in rest-dsl which are linked using direct endpoints. By default, each service in Rest DSL is an individual route, meaning that you would have at least two routes per service (rest-dsl, and the route linked from rest-dsl). Enabling this allows Camel to optimize and inline this as a single route, however this requires to use direct endpoints, which must be unique per service. This option is default false.", 'boolean', [...] + new PropertyMeta('inlineRoutes', 'Inline Routes', "Inline routes in rest-dsl which are linked using direct endpoints. Each service in Rest DSL is an individual route, meaning that you would have at least two routes per service (rest-dsl, and the route linked from rest-dsl). By inlining (default) allows Camel to optimize and inline this as a single route, however this requires to use direct endpoints, which must be unique per service. If a route is not using direct endpoint then t [...] new PropertyMeta('jsonDataFormat', 'Json Data Format', "Name of specific json data format to use. By default jackson will be used. Important: This option is only for setting a custom name of the data format, not to refer to an existing data format instance.", 'string', '', '', false, false, false, false, 'advanced', ''), new PropertyMeta('xmlDataFormat', 'Xml Data Format', "Name of specific XML data format to use. By default jaxb will be used. Important: This option is only for setting a custom name of the data format, not to refer to an existing data format instance.", 'string', '', '', false, false, false, false, 'advanced', ''), new PropertyMeta('componentProperty', 'Component Property', "Allows to configure as many additional properties for the rest component in use.", 'RestPropertyDefinition', '', '', false, false, true, true, 'advanced', ''), @@ -1848,6 +1850,8 @@ export const CamelModelMetadata: ElementMeta[] = [ new PropertyMeta('timeoutExecutorService', 'Timeout Executor Service', "References to a custom thread pool to use when timeout is enabled (uses ForkJoinPool#commonPool() by default)", 'string', '', '', false, false, false, false, 'advanced', ''), new PropertyMeta('timeoutDuration', 'Timeout Duration', "Configures the thread execution timeout. Default value is 1 second.", 'number', '', '1000', false, false, false, false, '', ''), new PropertyMeta('timeoutCancelRunningFuture', 'Timeout Cancel Running Future', "Configures whether cancel is called on the running future. Defaults to true.", 'boolean', '', 'true', false, false, false, false, 'advanced', ''), + new PropertyMeta('recordException', 'Record Exception', "Configure a list of exceptions that are recorded as a failure and thus increase the failure rate. Any exception matching or inheriting from one of the list counts as a failure, unless explicitly ignored via ignoreExceptions.", 'string', '', '', false, false, true, true, 'advanced', ''), + new PropertyMeta('ignoreException', 'Ignore Exception', "Configure a list of exceptions that are ignored and neither count as a failure nor success. Any exception matching or inheriting from one of the list will not count as a failure nor success, even if the exceptions is part of recordExceptions.", 'string', '', '', false, false, true, true, 'advanced', ''), ]), new ElementMeta('restContextRef', 'RestContextRefDefinition', 'Rest Context Ref', "To refer to an XML file with rest services defined using the rest-dsl", 'configuration,rest', [ new PropertyMeta('ref', 'Ref', "Reference to the rest-dsl", 'string', '', '', true, false, false, false, '', ''), @@ -2355,6 +2359,7 @@ export const SensitiveKeys: string[] = [ "certresourcepassword", "clientsecretcredential", "oauthclientid", + "apikey", "clientsecret", "tokencredential", "blobstoragesharedkeycredential", diff --git a/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelDefinitionApiGenerator.java b/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelDefinitionApiGenerator.java index a1afa7db..67e68ef6 100644 --- a/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelDefinitionApiGenerator.java +++ b/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelDefinitionApiGenerator.java @@ -161,13 +161,17 @@ public final class CamelDefinitionApiGenerator extends AbstractGenerator { && !getDeprecatedClasses().contains(getAttributeClass(aValue)) // exception for deprecated classes ) { String attributeClass = getAttributeClass(aValue); - String template = attributeClass.equals("ExpressionDefinition") - ? " def.%1$s = CamelDefinitionApi.create%2$s(element.%1$s); \n" - : " if (element?.%1$s !== undefined) { \n" + - " def.%1$s = CamelDefinitionApi.create%2$s(element.%1$s); \n" + - " }"; - String code = String.format(template, name, getAttributeClass(aValue)); - attrs.add(code); + + var excludeProperty = excludeProperty(stepName, name, attributeClass); + if (!excludeProperty) { + String template = attributeClass.equals("ExpressionDefinition") + ? " def.%1$s = CamelDefinitionApi.create%2$s(element.%1$s); \n" + : " if (element?.%1$s !== undefined) { \n" + + " def.%1$s = CamelDefinitionApi.create%2$s(element.%1$s); \n" + + " }"; + String code = String.format(template, name, getAttributeClass(aValue)); + attrs.add(code); + } } }); String stringToRequired = getStringToRequired(obj, className); diff --git a/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelDefinitionGenerator.java b/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelDefinitionGenerator.java index 171e0703..aa7cada5 100644 --- a/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelDefinitionGenerator.java +++ b/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelDefinitionGenerator.java @@ -57,6 +57,7 @@ public final class CamelDefinitionGenerator extends AbstractGenerator { private String generateModel(String classFullName, JsonObject obj, JsonObject definitions, Map<String, JsonObject> dslMetadata) { + String className = classSimple(classFullName); String stepName = getStepNameForClass(className); Map<String, JsonObject> properties = getClassProperties(stepName, obj); diff --git a/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelDefinitionYamlStepGenerator.java b/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelDefinitionYamlStepGenerator.java index 0f967d6f..d3334a6a 100644 --- a/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelDefinitionYamlStepGenerator.java +++ b/karavan-generator/src/main/java/org/apache/camel/karavan/generator/CamelDefinitionYamlStepGenerator.java @@ -138,16 +138,20 @@ public final class CamelDefinitionYamlStepGenerator extends AbstractGenerator { && !getAttributeClass(aValue).equals("ToDynamicDefinition") // exception for ToDynamicDefinition (in REST Methods) && !getDeprecatedClasses().contains(getAttributeClass(aValue)) // exception for deprecated classes ) { - String code = String.format( - " if (element?.%1$s !== undefined) { \n" + - " if (Array.isArray(element.%1$s)) { \n" + - " def.%1$s = CamelDefinitionYamlStep.read%2$s(element.%1$s[0]); \n" + - " } else { \n" + - " def.%1$s = CamelDefinitionYamlStep.read%2$s(element.%1$s); \n" + - " } \n" + - " } \n" - , aName, getAttributeClass(aValue)); - attrs.put(aName, code); + String attributeClass = getAttributeClass(aValue); + var excludeProperty = excludeProperty(stepName, aName, attributeClass); + if (!excludeProperty) { + String code = String.format( + " if (element?.%1$s !== undefined) { \n" + + " if (Array.isArray(element.%1$s)) { \n" + + " def.%1$s = CamelDefinitionYamlStep.read%2$s(element.%1$s[0]); \n" + + " } else { \n" + + " def.%1$s = CamelDefinitionYamlStep.read%2$s(element.%1$s); \n" + + " } \n" + + " } \n" + , aName, getAttributeClass(aValue)); + attrs.put(aName, code); + } } else { }