public static List generateDocumentParameters()

in shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/utils/OpenApiUtils.java [69:120]


    public static List<Parameter> generateDocumentParameters(final String path, final Method method) {
        ArrayList<Parameter> list = new ArrayList<>();
        Pair<Boolean, Annotation[][]> query = isQuery(method);
        if (query.getLeft()) {
            for (Annotation[] annotations : query.getRight()) {
                if (annotations.length > 0 && isQueryName(annotations[0].annotationType().getName(), QUERY_CLASSES)) {
                    for (Annotation annotation : annotations) {
                        String name = "";
                        boolean required = false;
                        if (StringUtils.equals(QUERY_CLASSES[0], annotation.annotationType().getName())) {
                            RequestParam requestParam = (RequestParam) annotation;
                            name = requestParam.value();
                            required = requestParam.required();
                        }
                        if (StringUtils.equals(QUERY_CLASSES[1], annotation.annotationType().getName())) {
                            RequestPart requestPart = (RequestPart) annotation;
                            name = requestPart.value();
                            required = requestPart.required();
                        }
                        Parameter parameter = new Parameter();
                        parameter.setIn("query");
                        parameter.setRequired(required);
                        parameter.setName(name);
                        parameter.setSchema(new Schema("string", null));
                        list.add(parameter);
                    }
                }
            }
        } else {
            List<String> segments = UrlPathUtils.getSegments(path);
            for (String segment : segments) {
                if (EVERY_PATH.equals(segment)) {
                    Parameter parameter = new Parameter();
                    parameter.setIn("path");
                    parameter.setName(segment);
                    parameter.setRequired(true);
                    parameter.setSchema(new Schema("string", null));
                    list.add(parameter);
                }
                if (segment.startsWith(LEFT_ANGLE_BRACKETS) && segment.endsWith(RIGHT_ANGLE_BRACKETS)) {
                    String name = segment.substring(1, segment.length() - 1);
                    Parameter parameter = new Parameter();
                    parameter.setIn("path");
                    parameter.setName(name);
                    parameter.setRequired(true);
                    parameter.setSchema(new Schema("string", null));
                    list.add(parameter);
                }
            }
        }
        return list;
    }