mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-11 18:32:43 +00:00
[cli][gradle] filter deprecated generators by default when listing available generators (#3612)
* Filter deprecated generators from CLI list by default. * [gradle] Exclude deprecated generators from list by default, add "include" option to allow for customization of list task. * Update scripts to support the --include option of the list command * Update gradle/cli docs for generators listing with "include" option.
This commit is contained in:
@@ -5,15 +5,14 @@ import com.google.common.base.Objects;
|
||||
import io.airlift.airline.Command;
|
||||
import io.airlift.airline.Option;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConfigLoader;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
// NOTE: List can later have subcommands such as list languages, list types, list frameworks, etc.
|
||||
@@ -26,9 +25,31 @@ public class ListGenerators implements Runnable {
|
||||
@Option(name = {"-d", "--docsite" }, description = "format for docusaurus site output", hidden = true)
|
||||
private Boolean docusaurus = false;
|
||||
|
||||
@Option(name = {"-i", "--include" },
|
||||
description = "comma-separated list of stability indexes to include (value: all,beta,stable,experimental,deprecated). Excludes deprecated by default.",
|
||||
allowedValues = { "all", "beta", "stable", "experimental", "deprecated" })
|
||||
private String include = "stable,beta,experimental";
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
List<CodegenConfig> generators = CodegenConfigLoader.getAll();
|
||||
List<CodegenConfig> generators = new ArrayList<>();
|
||||
List<Stability> stabilities = Arrays.asList(Stability.values());
|
||||
|
||||
if (!StringUtils.isEmpty(include)) {
|
||||
List<String> includes = Arrays.asList(include.split(","));
|
||||
if (includes.size() != 0 && !includes.contains("all")) {
|
||||
stabilities = includes.stream()
|
||||
.map(Stability::forDescription)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
for (CodegenConfig codegenConfig : CodegenConfigLoader.getAll()) {
|
||||
GeneratorMetadata meta = codegenConfig.getGeneratorMetadata();
|
||||
if (meta != null && stabilities.contains(meta.getStability())) {
|
||||
generators.add(codegenConfig);
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user