Skip to content

Commit

Permalink
fix(core): can now override the way to retrieve registered plugins in…
Browse files Browse the repository at this point in the history
… JsonSchemaGenerator

used in #1807
  • Loading branch information
brian-mulier-p committed Jul 31, 2023
1 parent 9ce70f7 commit e66ed6c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions core/src/main/java/io/kestra/core/docs/JsonSchemaGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.kestra.core.models.tasks.Output;
import io.kestra.core.models.tasks.Task;
import io.kestra.core.models.triggers.AbstractTrigger;
import io.kestra.core.plugins.RegisteredPlugin;
import io.kestra.core.serializers.JacksonMapper;
import io.kestra.core.services.PluginService;
import io.micronaut.core.annotation.Nullable;
Expand Down Expand Up @@ -304,29 +305,25 @@ public CustomDefinition provideCustomSchemaDefinition(ResolvedType javaType, Sch
TypeContext typeContext = context.getTypeContext();

if (declaredType.getErasedType() == Task.class) {
return pluginService
.allPlugins()
return getRegisteredPlugins()
.stream()
.flatMap(registeredPlugin -> registeredPlugin.getTasks().stream())
.map(clz -> typeContext.resolveSubtype(declaredType, clz))
.collect(Collectors.toList());
} else if (declaredType.getErasedType() == AbstractTrigger.class) {
return pluginService
.allPlugins()
return getRegisteredPlugins()
.stream()
.flatMap(registeredPlugin -> registeredPlugin.getTriggers().stream())
.map(clz -> typeContext.resolveSubtype(declaredType, clz))
.collect(Collectors.toList());
} else if (declaredType.getErasedType() == Condition.class) {
return pluginService
.allPlugins()
return getRegisteredPlugins()
.stream()
.flatMap(registeredPlugin -> registeredPlugin.getConditions().stream())
.map(clz -> typeContext.resolveSubtype(declaredType, clz))
.collect(Collectors.toList());
} else if (declaredType.getErasedType() == ScheduleCondition.class) {
return pluginService
.allPlugins()
return getRegisteredPlugins()
.stream()
.flatMap(registeredPlugin -> registeredPlugin.getConditions().stream())
.filter(ScheduleCondition.class::isAssignableFrom)
Expand Down Expand Up @@ -404,6 +401,11 @@ public CustomDefinition provideCustomSchemaDefinition(ResolvedType javaType, Sch
}
}

protected List<RegisteredPlugin> getRegisteredPlugins() {
return pluginService
.allPlugins();
}

private boolean defaultInAllOf(JsonNode property) {
if (property.has("allOf")) {
for (Iterator<JsonNode> it = property.get("allOf").elements(); it.hasNext(); ) {
Expand Down

0 comments on commit e66ed6c

Please sign in to comment.