gnodet-bot commented on code in PR #26755:
URL: https://github.com/apache/camel/pull/26755#discussion_r4078364447
##########
components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpointV3Test.java:
##########
@@ -213,6 +213,32 @@ public void shouldDetermineBasePath() {
.isEqualTo("/endpoint");
}
+ @Test
+ public void shouldDetermineEmptyBasePathFromOpenApiServer() {
+ final RestConfiguration restConfiguration = new RestConfiguration();
+
+ final CamelContext camelContext = mock(CamelContext.class);
+
when(camelContext.getRestConfiguration()).thenReturn(restConfiguration);
+
+ final OpenAPI openapi = new OpenAPI();
+ openapi.addServersItem(new Server().url("http://localhost:8080"));
+
+ final RestOpenApiComponent component = new RestOpenApiComponent();
+ component.setCamelContext(camelContext);
+
+ final RestOpenApiEndpoint endpoint = new RestOpenApiEndpoint(
+ "rest-openapi:getPetById", "getPetById", component,
+ Collections.emptyMap());
+
+ assertThat(RestOpenApiHelper.getBasePathFromOpenApi(openapi))
+ .as("OpenAPI server without a path should produce an empty
base path")
+ .isEmpty();
+
+ assertThat(endpoint.determineBasePath(openapi))
+ .as("When the OpenAPI server URL has no path, the base path
should be empty")
+ .isEmpty();
+ }
+
@Test
public void shouldDetermineEndpointParameters() {
final CamelContext camelContext = mock(CamelContext.class);
Review Comment:
⚠️ **Missing coverage for `RestOpenApiHelper.determineBasePath` (static
method)**
The PR fixes the same `isNotEmpty` → `!= null` bug in two places: the
instance method `RestOpenApiEndpoint.determineBasePath` and the static
`RestOpenApiHelper.determineBasePath`. The new test only covers the instance
method. The static method is the one called by `camel-openapi-validator`
(`OpenApiRestClientRequestValidator` and `OpenApiRestClientResponseValidator`)
— so the validator path has the same fix but zero test coverage.
Add a second assertion in this test (or a dedicated test in
`RestOpenApiHelperTest`) that exercises
`RestOpenApiHelper.determineBasePath(camelContext, component, endpoint,
openapi)` with the pathless server URL and verifies it returns `""` instead of
`"/"`.
##########
components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java:
##########
@@ -745,7 +747,7 @@ String determineHost(final OpenAPI openApi, Operation
operation) {
if (isNotEmpty(componentHost)) {
return componentHost;
}
-
+
Review Comment:
🔧 **Trailing whitespace** — this blank line was converted to a
whitespace-only line (` `) by the editor. Revert to a true empty line.
```suggestion
```
##########
components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java:
##########
@@ -791,7 +793,7 @@ String determineHost(final OpenAPI openApi, Operation
operation) {
if (globalConfigurationHost != null) {
return globalConfigurationHost;
}
-
+
Review Comment:
🔧 **Trailing whitespace** — same as above; ` ` (7 spaces) instead of
an empty line.
```suggestion
```
--
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]