Skip to content

Commit

Permalink
feat:add english comment,change config type
Browse files Browse the repository at this point in the history
  • Loading branch information
lixingzhi committed Sep 12, 2023
1 parent b459b75 commit 089a7ba
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
/*
*smart-doc https://github.com/smart-doc-group/smart-doc
*
*Copyright(C)2018-2023smart-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,Version2.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.power.doc.builder.openapi;
*smart-doc https://github.com/smart-doc-group/smart-doc
*
*Copyright(C)2018-2023smart-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,Version2.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.power.doc.builder.openapi;

import com.power.common.util.CollectionUtil;
import com.power.common.util.StringUtil;
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/power/doc/constants/ComponentTypeEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ public enum ComponentTypeEnum {
/**
* support @Validated
*/
RANDOM(1),
RANDOM("RANDOM"),
/**
* don't support @Validated,
* for openapi generator
*/
NORMAL(2);
NORMAL("NORMAL");

ComponentTypeEnum(Integer componentType) {
ComponentTypeEnum(String componentType) {
this.componentType = componentType;
}

/**
* openapi 类型
* openapi component generator Key type
*/
private final Integer componentType;
private final String componentType;

public static String getRandomName(ComponentTypeEnum componentTypeEnum, ApiMethodDoc apiMethodDoc) {
if (componentTypeEnum.equals(RANDOM)) {
Expand All @@ -34,11 +34,11 @@ public static String getRandomName(ComponentTypeEnum componentTypeEnum, ApiMetho
return StringUtils.EMPTY;
}

public Integer getComponentType() {
public String getComponentType() {
return componentType;
}

public static ComponentTypeEnum getComponentEnumByCode(Integer code) {
public static ComponentTypeEnum getComponentEnumByCode(String code) {
for (ComponentTypeEnum typeEnum : ComponentTypeEnum.values()) {
if (typeEnum.getComponentType().equals(code)) {
return typeEnum;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/power/doc/model/ApiConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,13 @@ public static ApiConfig getInstance() {
* build random component for openApi
* @see com.power.doc.constants.ComponentTypeEnum
*/
private Integer componentType;
private String componentType;

public Integer getComponentType() {
public String getComponentType() {
return componentType;
}

public ApiConfig setComponentType(Integer componentType) {
public ApiConfig setComponentType(String componentType) {
this.componentType = componentType;
return this;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/power/doc/utils/OpenApiSchemaUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ public static String getClassNameFromParams(List<ApiParam> apiParams) {
&& CollectionUtil.isEmpty(apiParams.get(0).getChildren())) {
return DocGlobalConstants.DEFAULT_PRIMITIVE;
}
//随机值
//random name
if (componentTypeEnum.equals(ComponentTypeEnum.RANDOM)) {
return DigestUtils.md5Hex(GSON.toJson(apiParams));
}
//参数值
//className
for (ApiParam a : apiParams) {
if (StringUtil.isNotEmpty(a.getClassName())) {
return OpenApiSchemaUtil.delClassName(a.getClassName());
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/com/power/doc/ApiDocTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ public class ApiDocTest {
/**
* 包括设置请求头,缺失注释的字段批量在文档生成期使用定义好的注释
*/
@Deprecated
@Test
public void testBuilderControllersApi() {
@Deprecated
ApiConfig config = ApiConfig.getInstance();
config.setServerUrl("http://127.0.0.1:8899");
// config.setStrict(true);
Expand Down

0 comments on commit 089a7ba

Please sign in to comment.