Skip to content

Commit e152fcc

Browse files
RobpMobXRobert Pospisil
authored andcommitted
#14906: add option to filter full paths
1 parent 0d2a016 commit e152fcc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,14 +605,20 @@ void generateApis(List<File> files, List<OperationsMap> allOperations, List<Mode
605605
LOGGER.info("Skipping generation of APIs.");
606606
return;
607607
}
608-
Map<String, List<CodegenOperation>> paths = processPaths(this.openAPI.getPaths());
609608
Set<String> apisToGenerate = null;
610609
String apiNames = GlobalSettings.getProperty(CodegenConstants.APIS);
611610
if (apiNames != null && !apiNames.isEmpty()) {
612611
apisToGenerate = new HashSet<>(Arrays.asList(apiNames.split(",")));
612+
//first filter full paths
613+
Set<String> fullPathsToGenerate = apisToGenerate.stream().filter(s->s.contains("/")).collect(Collectors.toSet());
614+
Set<String> filteredPathsKeysToRemove = this.openAPI.getPaths().keySet().stream().filter(k->!fullPathsToGenerate.contains(k)).collect(Collectors.toSet());
615+
filteredPathsKeysToRemove.forEach(p->this.openAPI.getPaths().remove(p));
616+
apisToGenerate = apisToGenerate.stream().filter(s->!s.contains("/")).collect(Collectors.toSet());
613617
}
618+
Map<String, List<CodegenOperation>> paths = processPaths(this.openAPI.getPaths());
614619
if (apisToGenerate != null && !apisToGenerate.isEmpty()) {
615620
Map<String, List<CodegenOperation>> updatedPaths = new TreeMap<>();
621+
//second we filter for basename
616622
for (String m : paths.keySet()) {
617623
if (apisToGenerate.contains(m)) {
618624
updatedPaths.put(m, paths.get(m));

0 commit comments

Comments
 (0)