HY-love-sleep opened a new pull request, #7177: URL: https://github.com/apache/shenyu/pull/7177
### What this fixes Closes #6666. A bare `@ShenyuMcpTool` uses the default `@OpenAPIDefinition` / `@Operation`, whose `servers()` and `parameters` are unset. `McpOpenApiGenerator.generateOpenApiJson` assumed both were present: 1. `definition.servers()[0].url()` threw `ArrayIndexOutOfBoundsException` when `servers()` was empty (the default, and the same case `McpServiceEventListener.buildApiSuperPath` already guards). 2. `shenyuMcpTool.getOperation().getParameters()` returned `null` when the method declared no parameters, so `parameterList.isEmpty()` threw `NullPointerException`. This one is on the same path, so fixing only (1) still leaves the default form broken. Both are now guarded: the `server` block is only emitted when a server is configured (it is optional in OpenAPI 3.0), and the parameter list is only iterated when it is present. ### Tests `shenyu-client-mcp-common` had no tests; `McpOpenApiGeneratorTest` is added with three cases, building the tool through `OpenApiConvertorUtil.convertOperation` so the flow matches `McpServiceEventListener`: - default annotations (no servers, no parameters) — reproduces both failures on the current code, passes with the fix; - a configured `@Server(url = ...)` — the existing behaviour is unchanged; - a declared parameter — parameters are still emitted. ``` Tests run: 3, Failures: 0, Errors: 0, Skipped: 0 BUILD SUCCESS ``` `./mvnw -pl shenyu-client/shenyu-client-mcp/shenyu-client-mcp-common test -Dtest=McpOpenApiGeneratorTest` — checkstyle reports 0 violations, RAT passes. -- 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]
