Copilot commented on code in PR #6379:
URL: https://github.com/apache/shenyu/pull/6379#discussion_r3384857971
##########
shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/OpenApiUtils.java:
##########
@@ -296,6 +747,228 @@ private static ResponseType parseGenericArrayType(final
ResponseType responseTyp
return responseType;
}
+ private static Schema parseSchema(final Type type, final int depth, final
Map<TypeVariable<?>, Type> typeVariableMap) {
+ if (depth > 5) {
+ return new Schema("object", null);
+ }
+ if (type instanceof Class) {
+ return parseClassSchema((Class<?>) type, depth, typeVariableMap);
+ } else if (type instanceof ParameterizedType) {
+ return parseParameterizedTypeSchema((ParameterizedType) type,
depth, typeVariableMap);
+ } else if (type instanceof GenericArrayType) {
+ Schema elementSchema = parseSchema(((GenericArrayType)
type).getGenericComponentType(), depth + 1, typeVariableMap);
+ Schema schema = new Schema("array", null);
+ schema.setRefs(Collections.singletonList(elementSchema));
+ return schema;
Review Comment:
For `GenericArrayType` schemas, the element schema is added to `refs`
without a `name`. This later becomes a `Parameter` with `name = null`,
producing unstable/invalid JSON (e.g., `"name":null`) for array request
parameters.
##########
shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/OpenApiUtils.java:
##########
@@ -89,34 +149,182 @@ public static List<Parameter>
generateDocumentParameters(final String path, fina
parameter.setIn("query");
parameter.setRequired(required);
parameter.setName(name);
- parameter.setSchema(new Schema("string", null));
+ parameter.setType("string");
list.add(parameter);
}
Review Comment:
`generateRequestDocParameters` currently adds a query parameter entry for
*every* annotation on the method parameter once the first annotation is
`@RequestParam`/`@RequestPart`. If there are additional annotations (e.g.,
`@Valid`, `@NotNull`), this will add extra query parameters with an empty name.
##########
shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/OpenApiUtils.java:
##########
@@ -296,6 +747,228 @@ private static ResponseType parseGenericArrayType(final
ResponseType responseTyp
return responseType;
}
+ private static Schema parseSchema(final Type type, final int depth, final
Map<TypeVariable<?>, Type> typeVariableMap) {
+ if (depth > 5) {
+ return new Schema("object", null);
+ }
+ if (type instanceof Class) {
+ return parseClassSchema((Class<?>) type, depth, typeVariableMap);
+ } else if (type instanceof ParameterizedType) {
+ return parseParameterizedTypeSchema((ParameterizedType) type,
depth, typeVariableMap);
+ } else if (type instanceof GenericArrayType) {
+ Schema elementSchema = parseSchema(((GenericArrayType)
type).getGenericComponentType(), depth + 1, typeVariableMap);
+ Schema schema = new Schema("array", null);
+ schema.setRefs(Collections.singletonList(elementSchema));
+ return schema;
+ } else if (type instanceof TypeVariable) {
+ Type actualType = typeVariableMap.get(type);
+ if (Objects.nonNull(actualType)) {
+ return parseSchema(actualType, depth, typeVariableMap);
+ } else if (((TypeVariable<?>) type).getBounds().length > 0) {
+ return parseSchema(((TypeVariable<?>) type).getBounds()[0],
depth, typeVariableMap);
+ } else {
+ return new Schema("object", null);
+ }
+ } else {
+ return new Schema("object", null);
+ }
+ }
+
+ private static Schema parseClassSchema(final Class<?> clazz, final int
depth, final Map<TypeVariable<?>, Type> typeVariableMap) {
+ if (clazz.isArray()) {
+ Schema elementSchema = parseSchema(clazz.getComponentType(), depth
+ 1, typeVariableMap);
+ Schema schema = new Schema("array", null);
+ schema.setRefs(Collections.singletonList(elementSchema));
+ return schema;
Review Comment:
For Java array types (`clazz.isArray()`), the element schema is added to
`refs` without a `name`. This later becomes a `Parameter` with `name = null` in
generated docs for array parameters.
##########
shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-logging-rocketmq/compose/script/e2e-logging-rocketmq-compose.sh:
##########
@@ -31,16 +31,18 @@ SYNC_ARRAY=("websocket" "http" "zookeeper")
docker network create -d bridge shenyu
for sync in "${SYNC_ARRAY[@]}"; do
+
sync_compose_file="$SHENYU_TESTCASE_DIR"/compose/sync/shenyu-sync-"${sync}".yml
echo -e "------------------\n"
echo "[Start ${sync} synchronous] create shenyu-admin-${sync}.yml
shenyu-bootstrap-${sync}.yml "
- docker compose -f
"$SHENYU_TESTCASE_DIR"/compose/sync/shenyu-sync-"${sync}".yml up -d --quiet-pull
+ docker compose -f "${sync_compose_file}" up -d --quiet-pull || true
Review Comment:
The PR title/description focuses on RocketMQ logging e2e compose startup
recovery, but this PR also includes substantial unrelated changes (OpenAPI doc
generation logic, protobuf/grpc tests and build plugins, SOFA listener
refactor, Dubbo example annotations). Please update the PR description to
reflect the full scope or split these concerns into separate PRs to keep
reviews and rollbacks manageable.
##########
shenyu-e2e/shenyu-e2e-case/shenyu-e2e-case-logging-rocketmq/compose/script/e2e-logging-rocketmq-compose.sh:
##########
@@ -31,16 +31,18 @@ SYNC_ARRAY=("websocket" "http" "zookeeper")
docker network create -d bridge shenyu
for sync in "${SYNC_ARRAY[@]}"; do
+
sync_compose_file="$SHENYU_TESTCASE_DIR"/compose/sync/shenyu-sync-"${sync}".yml
echo -e "------------------\n"
echo "[Start ${sync} synchronous] create shenyu-admin-${sync}.yml
shenyu-bootstrap-${sync}.yml "
- docker compose -f
"$SHENYU_TESTCASE_DIR"/compose/sync/shenyu-sync-"${sync}".yml up -d --quiet-pull
+ docker compose -f "${sync_compose_file}" up -d --quiet-pull || true
sleep 30s
- sh "$SHENYU_TESTCASE_DIR"/k8s/script/healthcheck.sh
http://localhost:31095/actuator/health
- sh "$SHENYU_TESTCASE_DIR"/k8s/script/healthcheck.sh
http://localhost:31195/actuator/health
+ sh "$SHENYU_TESTCASE_DIR"/k8s/script/healthcheck.sh
http://localhost:31095/actuator/health || exit 1
+ docker compose -f "${sync_compose_file}" up -d shenyu-bootstrap
+ sh "$SHENYU_TESTCASE_DIR"/k8s/script/healthcheck.sh
http://localhost:31195/actuator/health || exit 1
Review Comment:
This `docker compose up -d shenyu-bootstrap` command is not checked for
failure (the script does not use `set -e`). If it fails, the script will
continue until the later healthcheck, which can make failures harder to
diagnose and can hide immediate compose errors.
--
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]