Skip to content

Commit

Permalink
fix(core): serialize default inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
loicmathieu committed Dec 13, 2024
1 parent bdef596 commit 20f4a51
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 0 additions & 2 deletions core/src/main/java/io/kestra/core/models/flows/Input.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.kestra.core.models.flows;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
Expand Down Expand Up @@ -39,7 +38,6 @@
@JsonSubTypes.Type(value = URIInput.class, name = "URI"),
@JsonSubTypes.Type(value = MultiselectInput.class, name = "MULTISELECT")
})
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
public abstract class Input<T> implements Data {
@NotNull
@NotBlank
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ void inputsFailed() {
void inputs() {
Flow flow = this.parse("flows/valids/inputs.yaml");

assertThat(flow.getInputs().size(), is(27));
assertThat(flow.getInputs().stream().filter(Input::getRequired).count(), is(9L));
assertThat(flow.getInputs().size(), is(28));
assertThat(flow.getInputs().stream().filter(Input::getRequired).count(), is(10L));
assertThat(flow.getInputs().stream().filter(r -> !r.getRequired()).count(), is(18L));
assertThat(flow.getInputs().stream().filter(r -> r.getDefaults() != null).count(), is(1L));
assertThat(flow.getInputs().stream().filter(r -> r.getDefaults() != null).count(), is(2L));
assertThat(flow.getInputs().stream().filter(r -> r instanceof StringInput && ((StringInput)r).getValidator() != null).count(), is(1L));
}

Expand Down
5 changes: 5 additions & 0 deletions core/src/test/resources/flows/valids/inputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ inputs:
- name: array
type: ARRAY
itemType: INT
# required true and an empty default value will only work if we correctly serialize default values which is what this input is about to test.
- name: empty
type: STRING
defaults: ''
required: true

tasks:
- id: string
Expand Down

0 comments on commit 20f4a51

Please sign in to comment.