Aias00 opened a new issue, #6440:
URL: https://github.com/apache/shenyu/issues/6440
### Current Behavior
`SwaggerImportServiceImpl.buildMetaDataRegisterDTO()` assumes every imported
OpenAPI document has a top-level `servers` list and every operation has a
non-null `parameters` list.
Evidence:
-
`shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SwaggerImportServiceImpl.java:219`
-
`shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SwaggerImportServiceImpl.java:230`
```java
String urlString = openapi.getServers().get(0).getUrl();
...
String parameterTypes = operation.getParameters()
.stream()
.map(Parameter::getIn)
.collect(Collectors.joining(","));
```
OpenAPI 3 allows the top-level `servers` field to be omitted, and an
operation can omit `parameters`. Importing such a valid document through the
MCP import path can throw `NullPointerException` or `IndexOutOfBoundsException`
instead of importing what it can or returning a controlled validation error.
### Expected Behavior
MCP Swagger/OpenAPI import should handle valid documents without top-level
`servers` or operation `parameters` safely.
If ShenYu requires server URL metadata for MCP import, the endpoint should
return a clear validation error rather than a 500.
### Steps To Reproduce
Import an OpenAPI 3 document similar to:
```yaml
openapi: 3.0.3
info:
title: demo
version: 1.0.0
paths:
/ping:
get:
operationId: ping
responses:
'200':
description: ok
```
The document has no top-level `servers` and no operation `parameters`, both
of which are valid OpenAPI shapes.
### Suggested Fix
Guard `openapi.getServers()` and `operation.getParameters()` before
indexing/streaming. Use an empty parameter list when absent, and either infer a
default server URL or return a controlled validation error when server metadata
is required.
--
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]