From 816d4073ddad8dd68550d07877780b3c013aa618 Mon Sep 17 00:00:00 2001 From: Fio Date: Mon, 13 Nov 2023 23:05:08 +0800 Subject: [PATCH] feature: Add license --- .../com/ly/doc/helper/DocBuildHelper.java | 20 +++++ .../java/com/ly/doc/helper/GitHelper.java | 20 +++++ .../java/com/ly/doc/util/ParamUtilTest.java | 87 +++++++++++++++++++ 3 files changed, 127 insertions(+) diff --git a/src/main/java/com/ly/doc/helper/DocBuildHelper.java b/src/main/java/com/ly/doc/helper/DocBuildHelper.java index 5e5f7dbb1..c9d989db9 100644 --- a/src/main/java/com/ly/doc/helper/DocBuildHelper.java +++ b/src/main/java/com/ly/doc/helper/DocBuildHelper.java @@ -1,3 +1,23 @@ +/* + * Copyright (C) 2018-2023 smart-doc + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package com.ly.doc.helper; import com.ly.doc.builder.ProjectDocConfigBuilder; diff --git a/src/main/java/com/ly/doc/helper/GitHelper.java b/src/main/java/com/ly/doc/helper/GitHelper.java index 590308c87..5f5b1ff98 100644 --- a/src/main/java/com/ly/doc/helper/GitHelper.java +++ b/src/main/java/com/ly/doc/helper/GitHelper.java @@ -1,3 +1,23 @@ +/* + * Copyright (C) 2018-2023 smart-doc + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package com.ly.doc.helper; import com.power.common.util.StringUtil; diff --git a/src/test/java/com/ly/doc/util/ParamUtilTest.java b/src/test/java/com/ly/doc/util/ParamUtilTest.java index 4ce791814..519f9661c 100644 --- a/src/test/java/com/ly/doc/util/ParamUtilTest.java +++ b/src/test/java/com/ly/doc/util/ParamUtilTest.java @@ -1,12 +1,99 @@ package com.ly.doc.util; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.reflect.TypeToken; +import com.ly.doc.model.ApiParam; +import com.ly.doc.utils.JsonUtil; import com.ly.doc.utils.ParamUtil; import org.junit.jupiter.api.Test; +import java.util.ArrayList; +import java.util.List; + public class ParamUtilTest { @Test public void testFormatMockValue() { System.out.printf(ParamUtil.formatMockValue("*\\/5 * * *")); } + + @Test + public void testExtractQualifiedName() { + String paramJson = "[\n" + + " {\n" + + " \"className\": \"org.example.springboot.dto.PetDTO\",\n" + + " \"id\": 1,\n" + + " \"field\": \"name\",\n" + + " \"type\": \"string\",\n" + + " \"desc\": \"name\",\n" + + " \"required\": false,\n" + + " \"version\": \"-\",\n" + + " \"pid\": 0,\n" + + " \"pathParam\": false,\n" + + " \"queryParam\": false,\n" + + " \"value\": \"\",\n" + + " \"hasItems\": false,\n" + + " \"maxLength\": \"\",\n" + + " \"configParam\": false,\n" + + " \"selfReferenceLoop\": false\n" + + " },\n" + + " {\n" + + " \"className\": \"org.example.springboot.dto.PetDTO\",\n" + + " \"id\": 2,\n" + + " \"field\": \"age\",\n" + + " \"type\": \"int32\",\n" + + " \"desc\": \"age\",\n" + + " \"required\": false,\n" + + " \"version\": \"-\",\n" + + " \"pid\": 0,\n" + + " \"pathParam\": false,\n" + + " \"queryParam\": false,\n" + + " \"value\": \"0\",\n" + + " \"hasItems\": false,\n" + + " \"maxLength\": \"\",\n" + + " \"configParam\": false,\n" + + " \"selfReferenceLoop\": false\n" + + " },\n" + + " {\n" + + " \"className\": \"org.example.springboot.dto.PetDTO\",\n" + + " \"id\": 3,\n" + + " \"field\": \"master\",\n" + + " \"type\": \"object\",\n" + + " \"desc\": \"master\",\n" + + " \"required\": false,\n" + + " \"version\": \"-\",\n" + + " \"pid\": 0,\n" + + " \"pathParam\": false,\n" + + " \"queryParam\": false,\n" + + " \"value\": \"\",\n" + + " \"hasItems\": false,\n" + + " \"maxLength\": \"\",\n" + + " \"configParam\": false,\n" + + " \"selfReferenceLoop\": false\n" + + " },\n" + + " {\n" + + " \"className\": \"org.example.springboot.dto.UserDTO\",\n" + + " \"id\": 4,\n" + + " \"field\": \"└─username\",\n" + + " \"type\": \"string\",\n" + + " \"desc\": \"No comments found.\",\n" + + " \"required\": false,\n" + + " \"version\": \"-\",\n" + + " \"pid\": 3,\n" + + " \"pathParam\": false,\n" + + " \"queryParam\": false,\n" + + " \"value\": \"\",\n" + + " \"hasItems\": false,\n" + + " \"maxLength\": \"\",\n" + + " \"configParam\": false,\n" + + " \"selfReferenceLoop\": false\n" + + " }\n" + + "]"; + List paramList = new Gson().fromJson(paramJson, new TypeToken>() { + }); + List qualifiedList = ParamUtil.extractQualifiedName(paramList); + qualifiedList.forEach(System.out::println); + } + }