This is an automated email from the ASF dual-hosted git repository.

fmariani pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 83376c75e228 CAMEL-23243: Convert OpenAI operation property from 
String to enum
83376c75e228 is described below

commit 83376c75e22812edf580f980ed248589369347c1
Author: Croway <[email protected]>
AuthorDate: Thu Apr 9 17:19:15 2026 +0200

    CAMEL-23243: Convert OpenAI operation property from String to enum
---
 .../apache/camel/catalog/components/openai.json    |  2 +-
 .../org/apache/camel/component/openai/openai.json  |  2 +-
 .../camel/component/openai/OpenAIComponent.java    |  2 +-
 .../camel/component/openai/OpenAIEndpoint.java     | 17 ++++----
 .../camel/component/openai/OpenAIOperations.java   | 49 ++++++++++++++++++++++
 .../builder/endpoint/StaticEndpointBuilders.java   |  4 ++
 .../endpoint/dsl/OpenAIEndpointBuilderFactory.java |  4 ++
 7 files changed, 67 insertions(+), 13 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/openai.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/openai.json
index feb4bfac903d..a3b430392764 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/openai.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/openai.json
@@ -63,7 +63,7 @@
     "CamelOpenAIOriginalText": { "index": 27, "kind": "header", "displayName": 
"", "group": "producer", "label": "", "required": false, "javaType": "String or 
List<String>", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "Original text content when embeddings 
operation is used", "constantName": 
"org.apache.camel.component.openai.OpenAIConstants#ORIGINAL_TEXT" }
   },
   "properties": {
-    "operation": { "index": 0, "kind": "path", "displayName": "Operation", 
"group": "producer", "label": "", "required": true, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "The operation to perform: 
'chat-completion', 'embeddings', or 'tool-execution'" },
+    "operation": { "index": 0, "kind": "path", "displayName": "Operation", 
"group": "producer", "label": "", "required": true, "type": "enum", "javaType": 
"org.apache.camel.component.openai.OpenAIOperations", "enum": [ 
"chat-completion", "embeddings", "tool-execution" ], "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": "The 
operation to perform: 'chat-completion', 'embeddings', or 'tool-execution'" },
     "additionalBodyProperty": { "index": 1, "kind": "parameter", 
"displayName": "Additional Body Property", "group": "producer", "label": "", 
"required": false, "type": "object", "javaType": 
"java.util.Map<java.lang.String, java.lang.Object>", "prefix": 
"additionalBodyProperty.", "multiValue": true, "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, 
"configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", 
"configurationField": "configur [...]
     "apiKey": { "index": 2, "kind": "parameter", "displayName": "Api Key", 
"group": "producer", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": true, "configurationClass": 
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": 
"configuration", "description": "OpenAI API key. Can also be set via 
OPENAI_API_KEY environment variable." },
     "autoToolExecution": { "index": 3, "kind": "parameter", "displayName": 
"Auto Tool Execution", "group": "producer", "label": "", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 
true, "configurationClass": 
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": 
"configuration", "description": "When true and MCP servers are configured, 
automatically execut [...]
diff --git 
a/components/camel-ai/camel-openai/src/generated/resources/META-INF/org/apache/camel/component/openai/openai.json
 
b/components/camel-ai/camel-openai/src/generated/resources/META-INF/org/apache/camel/component/openai/openai.json
index feb4bfac903d..a3b430392764 100644
--- 
a/components/camel-ai/camel-openai/src/generated/resources/META-INF/org/apache/camel/component/openai/openai.json
+++ 
b/components/camel-ai/camel-openai/src/generated/resources/META-INF/org/apache/camel/component/openai/openai.json
@@ -63,7 +63,7 @@
     "CamelOpenAIOriginalText": { "index": 27, "kind": "header", "displayName": 
"", "group": "producer", "label": "", "required": false, "javaType": "String or 
List<String>", "deprecated": false, "deprecationNote": "", "autowired": false, 
"secret": false, "description": "Original text content when embeddings 
operation is used", "constantName": 
"org.apache.camel.component.openai.OpenAIConstants#ORIGINAL_TEXT" }
   },
   "properties": {
-    "operation": { "index": 0, "kind": "path", "displayName": "Operation", 
"group": "producer", "label": "", "required": true, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": false, "description": "The operation to perform: 
'chat-completion', 'embeddings', or 'tool-execution'" },
+    "operation": { "index": 0, "kind": "path", "displayName": "Operation", 
"group": "producer", "label": "", "required": true, "type": "enum", "javaType": 
"org.apache.camel.component.openai.OpenAIOperations", "enum": [ 
"chat-completion", "embeddings", "tool-execution" ], "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "description": "The 
operation to perform: 'chat-completion', 'embeddings', or 'tool-execution'" },
     "additionalBodyProperty": { "index": 1, "kind": "parameter", 
"displayName": "Additional Body Property", "group": "producer", "label": "", 
"required": false, "type": "object", "javaType": 
"java.util.Map<java.lang.String, java.lang.Object>", "prefix": 
"additionalBodyProperty.", "multiValue": true, "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, 
"configurationClass": "org.apache.camel.component.openai.OpenAIConfiguration", 
"configurationField": "configur [...]
     "apiKey": { "index": 2, "kind": "parameter", "displayName": "Api Key", 
"group": "producer", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", 
"autowired": false, "secret": true, "configurationClass": 
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": 
"configuration", "description": "OpenAI API key. Can also be set via 
OPENAI_API_KEY environment variable." },
     "autoToolExecution": { "index": 3, "kind": "parameter", "displayName": 
"Auto Tool Execution", "group": "producer", "label": "", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, 
"deprecationNote": "", "autowired": false, "secret": false, "defaultValue": 
true, "configurationClass": 
"org.apache.camel.component.openai.OpenAIConfiguration", "configurationField": 
"configuration", "description": "When true and MCP servers are configured, 
automatically execut [...]
diff --git 
a/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIComponent.java
 
b/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIComponent.java
index 566f05e00c41..6c5a93336391 100644
--- 
a/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIComponent.java
+++ 
b/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIComponent.java
@@ -66,7 +66,7 @@ public class OpenAIComponent extends DefaultComponent 
implements SSLContextParam
 
         OpenAIEndpoint endpoint = new OpenAIEndpoint(uri, this, configuration);
         // set the operation from the URI path (e.g., chat-completion)
-        endpoint.setOperation(remaining);
+        endpoint.setOperation(OpenAIOperations.fromValue(remaining));
         setProperties(endpoint, parameters);
 
         if (configuration.getSslContextParameters() == null) {
diff --git 
a/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIEndpoint.java
 
b/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIEndpoint.java
index b2be34ceda7c..e9fc9e0d53c9 100644
--- 
a/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIEndpoint.java
+++ 
b/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIEndpoint.java
@@ -76,9 +76,8 @@ public class OpenAIEndpoint extends DefaultEndpoint {
     private static final Logger LOG = 
LoggerFactory.getLogger(OpenAIEndpoint.class);
 
     @UriPath
-    @Metadata(required = true, description = "The operation to perform: 
'chat-completion', 'embeddings', or 'tool-execution'",
-              enums = "chat-completion,embeddings,tool-execution")
-    private String operation;
+    @Metadata(required = true, description = "The operation to perform: 
'chat-completion', 'embeddings', or 'tool-execution'")
+    private OpenAIOperations operation;
 
     @UriParam
     private OpenAIConfiguration configuration;
@@ -99,11 +98,9 @@ public class OpenAIEndpoint extends DefaultEndpoint {
     @Override
     public Producer createProducer() throws Exception {
         return switch (operation) {
-            case "chat-completion" -> new OpenAIProducer(this);
-            case "embeddings" -> new OpenAIEmbeddingsProducer(this);
-            case "tool-execution" -> new OpenAIToolExecutionProducer(this);
-            default -> throw new IllegalArgumentException(
-                    "Unknown operation: " + operation + ". Supported: 
chat-completion, embeddings, tool-execution");
+            case chatCompletion -> new OpenAIProducer(this);
+            case embeddings -> new OpenAIEmbeddingsProducer(this);
+            case toolExecution -> new OpenAIToolExecutionProducer(this);
         };
     }
 
@@ -500,11 +497,11 @@ public class OpenAIEndpoint extends DefaultEndpoint {
         return OAuthHelper.resolveOAuthToken(getCamelContext(), 
configuration.getOauthProfile());
     }
 
-    public String getOperation() {
+    public OpenAIOperations getOperation() {
         return operation;
     }
 
-    public void setOperation(String operation) {
+    public void setOperation(OpenAIOperations operation) {
         this.operation = operation;
     }
 
diff --git 
a/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIOperations.java
 
b/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIOperations.java
new file mode 100644
index 000000000000..7f1ac265733e
--- /dev/null
+++ 
b/components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIOperations.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.openai;
+
+public enum OpenAIOperations {
+
+    chatCompletion("chat-completion"),
+    embeddings("embeddings"),
+    toolExecution("tool-execution");
+
+    private final String value;
+
+    OpenAIOperations(String value) {
+        this.value = value;
+    }
+
+    public static OpenAIOperations fromValue(String value) {
+        for (OpenAIOperations op : values()) {
+            if (op.value.equalsIgnoreCase(value) || 
op.name().equalsIgnoreCase(value)) {
+                return op;
+            }
+        }
+        throw new IllegalArgumentException(
+                "Unknown operation: " + value + ". Supported: chat-completion, 
embeddings, tool-execution");
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    @Override
+    public String toString() {
+        return value;
+    }
+}
diff --git 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
index 94fc5482e3c8..16749098ece9 100644
--- 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
+++ 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
@@ -12557,6 +12557,8 @@ public class StaticEndpointBuilders {
      * Path parameter: operation (required)
      * The operation to perform: 'chat-completion', 'embeddings', or
      * 'tool-execution'
+     * There are 3 enums and the value can be one of: chat-completion,
+     * embeddings, tool-execution
      * 
      * @param path operation
      * @return the dsl builder
@@ -12577,6 +12579,8 @@ public class StaticEndpointBuilders {
      * Path parameter: operation (required)
      * The operation to perform: 'chat-completion', 'embeddings', or
      * 'tool-execution'
+     * There are 3 enums and the value can be one of: chat-completion,
+     * embeddings, tool-execution
      * 
      * @param componentName to use a custom component name for the endpoint
      * instead of the default name
diff --git 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/OpenAIEndpointBuilderFactory.java
 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/OpenAIEndpointBuilderFactory.java
index d719573604a7..21a722c59c84 100644
--- 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/OpenAIEndpointBuilderFactory.java
+++ 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/OpenAIEndpointBuilderFactory.java
@@ -962,6 +962,8 @@ public interface OpenAIEndpointBuilderFactory {
          * Path parameter: operation (required)
          * The operation to perform: 'chat-completion', 'embeddings', or
          * 'tool-execution'
+         * There are 3 enums and the value can be one of: chat-completion,
+         * embeddings, tool-execution
          * 
          * @param path operation
          * @return the dsl builder
@@ -982,6 +984,8 @@ public interface OpenAIEndpointBuilderFactory {
          * Path parameter: operation (required)
          * The operation to perform: 'chat-completion', 'embeddings', or
          * 'tool-execution'
+         * There are 3 enums and the value can be one of: chat-completion,
+         * embeddings, tool-execution
          * 
          * @param componentName to use a custom component name for the endpoint
          * instead of the default name

Reply via email to