gnodet-bot commented on code in PR #26766:
URL: https://github.com/apache/camel/pull/26766#discussion_r4081625320


##########
components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpointV3Test.java:
##########
@@ -400,6 +401,27 @@ public void shouldDetermineHostFromSpecification() {
         assertThat(endpoint.determineHost(openapi, 
dummyOp)).isEqualTo("https://petstore.openapi.io";);
     }
 
+    @Test
+    public void shouldFailDescriptivelyWhenServersSectionIsMissing() throws 
Exception {

Review Comment:
   ⚠️ **Misleading test name.**
   
   The method is named `shouldFailDescriptivelyWhenServersSectionIsMissing` but 
the `servers` section is not missing — `swagger-parser` automatically defaults 
it to `[{url: "/"}]` per the OpenAPI 3.0 spec (§4.7.5). What the test actually 
validates is: *when all server URLs are relative (no absolute http/https URL) 
and no host is configured via endpoint/component/RestConfiguration, the 
component throws with a clear message.*
   
   Rename to something accurate:
   ```suggestion
       public void shouldThrowWhenNoAbsoluteServerUrlAndNoHostConfigured() 
throws Exception {
   ```



##########
components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpointV3Test.java:
##########
@@ -400,6 +401,27 @@ public void shouldDetermineHostFromSpecification() {
         assertThat(endpoint.determineHost(openapi, 
dummyOp)).isEqualTo("https://petstore.openapi.io";);
     }
 
+    @Test
+    public void shouldFailDescriptivelyWhenServersSectionIsMissing() throws 
Exception {
+        final RestOpenApiComponent component = new RestOpenApiComponent();
+        final CamelContext camelContext = new DefaultCamelContext();
+        component.setCamelContext(camelContext);
+
+        final RestOpenApiEndpoint endpoint = new RestOpenApiEndpoint(
+                "rest-openapi:missing-servers.yaml#testOperation",
+                "missing-servers.yaml#testOperation",

Review Comment:
   ⚠️ **`operationId` mismatch between endpoint URI and fixture.**
   
   The endpoint URI says `#testOperation`, but `missing-servers.yaml` declares 
`operationId: test`. The test bypasses `operationId` lookup (it calls 
`createProducerFor` directly), so this doesn't affect execution — but it will 
confuse anyone reading the test who checks the fixture.
   
   Either rename the fixture's `operationId` to `testOperation`, or update the 
URI to `#test`:
   ```suggestion
                   "rest-openapi:missing-servers.yaml#testOperation",
                   "missing-servers.yaml#testOperation",
   ```
   *(Also update `missing-servers.yaml` line 27: `operationId: testOperation`)*



##########
components/camel-rest-openapi/src/test/resources/missing-servers.yaml:
##########
@@ -0,0 +1,30 @@
+#
+# 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.
+#
+
+openapi: 3.0.0
+
+info:
+  title: Missing Servers Test
+  version: 1.0.0
+
+paths:
+  /test:
+    get:
+      operationId: test

Review Comment:
   Align `operationId` with the endpoint URI used in the test 
(`#testOperation`):
   ```suggestion
         operationId: testOperation
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to