Copilot commented on code in PR #26765:
URL: https://github.com/apache/camel/pull/26765#discussion_r4081190189
##########
components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java:
##########
@@ -627,9 +627,11 @@ String determineBasePath(final OpenAPI openapi) {
return restConfigurationBasePath;
}
- final String specificationBasePath =
RestOpenApiHelper.getBasePathFromOpenApi(openapi);
- if (isNotEmpty(specificationBasePath)) {
- return specificationBasePath;
+ if (openapi != null) {
+ final String specificationBasePath =
RestOpenApiHelper.getBasePathFromOpenApi(openapi);
+ if (isNotEmpty(specificationBasePath)) {
+ return specificationBasePath;
+ }
}
Review Comment:
This introduces additional nesting. For readability, consider inverting the
condition (e.g., early return when `openapi == null`), then keeping the
base-path extraction unindented. This keeps the happy-path linear and
consistent with other guard-style checks.
##########
components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java:
##########
@@ -627,9 +627,11 @@ String determineBasePath(final OpenAPI openapi) {
return restConfigurationBasePath;
}
- final String specificationBasePath =
RestOpenApiHelper.getBasePathFromOpenApi(openapi);
- if (isNotEmpty(specificationBasePath)) {
- return specificationBasePath;
+ if (openapi != null) {
+ final String specificationBasePath =
RestOpenApiHelper.getBasePathFromOpenApi(openapi);
+ if (isNotEmpty(specificationBasePath)) {
+ return specificationBasePath;
+ }
}
Review Comment:
Now that `determineBasePath` explicitly supports `openapi == null`, the
method contract should reflect that. Consider adding/adjusting Javadoc and/or a
`@Nullable` annotation on the `openapi` parameter (depending on project
conventions) so callers and static analysis tools understand null is acceptable.
--
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]