Skip to content

Commit

Permalink
fix(doc-gen): now also displaying properties with @PluginProperty ins…
Browse files Browse the repository at this point in the history
…ide bases in json schema (including conditions)

closes #1704
  • Loading branch information
brian-mulier-p committed Jul 31, 2023
1 parent e66ed6c commit 96551f4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,10 @@ protected <T> Map<String, Object> generate(Class<? extends T> cls, @Nullable Cla

this.build(builder,false);

// base is passed, we don't return base properties
// we don't return base properties unless specified with @PluginProperty
builder
.forFields()
.withIgnoreCheck(fieldScope -> base != null && fieldScope.getDeclaringType().getTypeName().equals(base.getName()));
.withIgnoreCheck(fieldScope -> base != null && fieldScope.getAnnotation(PluginProperty.class) == null && fieldScope.getDeclaringType().getTypeName().equals(base.getName()));

SchemaGeneratorConfig schemaGeneratorConfig = builder.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import io.kestra.core.models.annotations.PluginProperty;
import io.kestra.core.models.conditions.Condition;
import io.kestra.core.models.tasks.WorkerGroup;
import io.micronaut.core.annotation.Introspected;
Expand Down Expand Up @@ -39,6 +40,7 @@ abstract public class AbstractTrigger {
private String description;

@Valid
@PluginProperty
@Schema(
title = "List of Conditions in order to limit the flow trigger."
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;

import java.net.URISyntaxException;
Expand Down Expand Up @@ -121,6 +122,13 @@ void trigger() throws URISyntaxException {
var allOf = (List<Object>) task.get("allOf");

assertThat(allOf.size(), is(1));

Map<String, Object> jsonSchema = jsonSchemaGenerator.generate(AbstractTrigger.class, AbstractTrigger.class);

assertThat((Map<String, Object>) jsonSchema.get("properties"), allOf(
Matchers.aMapWithSize(1),
hasKey("conditions")
));
});
}

Expand Down

0 comments on commit 96551f4

Please sign in to comment.