-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #601 from netdied/master
feat:fix #564
- Loading branch information
Showing
9 changed files
with
137 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/com/power/doc/constants/ComponentTypeEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.power.doc.constants; | ||
|
||
import com.power.doc.model.ApiMethodDoc; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
/** | ||
* @author xingzi | ||
* Date 2023/9/10 14:47 | ||
*/ | ||
public enum ComponentTypeEnum { | ||
/** | ||
* support @Validated | ||
*/ | ||
RANDOM("RANDOM"), | ||
/** | ||
* don't support @Validated, | ||
* for openapi generator | ||
*/ | ||
NORMAL("NORMAL"); | ||
|
||
ComponentTypeEnum(String componentType) { | ||
this.componentType = componentType; | ||
} | ||
|
||
/** | ||
* openapi component generator Key type | ||
*/ | ||
private final String componentType; | ||
|
||
public static String getRandomName(ComponentTypeEnum componentTypeEnum, ApiMethodDoc apiMethodDoc) { | ||
if (componentTypeEnum.equals(RANDOM)) { | ||
return apiMethodDoc.getUrl(); | ||
} | ||
return StringUtils.EMPTY; | ||
} | ||
|
||
public String getComponentType() { | ||
return componentType; | ||
} | ||
|
||
public static ComponentTypeEnum getComponentEnumByCode(String code) { | ||
for (ComponentTypeEnum typeEnum : ComponentTypeEnum.values()) { | ||
if (typeEnum.getComponentType().equals(code)) { | ||
return typeEnum; | ||
} | ||
} | ||
return RANDOM; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters