Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/main/java/com/apiflows/model/Criterion.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,20 @@ public String getType() {
public void setType(String type) {
this.type = type;
}

public Criterion condition(String condition) {
this.condition = condition;
return this;
}

public Criterion context(String context) {
this.context = context;
return this;
}

public Criterion type(String type) {
this.type = type;
return this;
}
}

44 changes: 44 additions & 0 deletions src/main/java/com/apiflows/model/FailureAction.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
package com.apiflows.model;

import io.swagger.v3.oas.models.media.IntegerSchema;

import java.util.ArrayList;
import java.util.List;

public class FailureAction {

private String type;
private String workflowId;
private String stepId;
private Long retryAfter;
private Integer retryLimit;
private List<Criterion> criteria;

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getWorkflowId() {
return workflowId;
}
Expand Down Expand Up @@ -49,4 +61,36 @@ public List<Criterion> getCriteria() {
public void setCriteria(List<Criterion> criteria) {
this.criteria = criteria;
}

public FailureAction type(String type) {
this.type = type;
return this;
}

public FailureAction stepId(String stepId) {
this.stepId = stepId;
return this;
}

public FailureAction workflowId(String workflowId) {
this.workflowId = workflowId;
return this;
}

public FailureAction retryAfter(Long retryAfter) {
this.retryAfter = retryAfter;
return this;
}

public FailureAction retryLimit(Integer retryLimit) {
this.retryLimit = retryLimit;
return this;
}

public void addCriteria(Criterion criterion) {
if(this.criteria == null) {
this.criteria = new ArrayList<>();
}
this.criteria.add(criterion);
}
}
16 changes: 16 additions & 0 deletions src/main/java/com/apiflows/model/Info.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,20 @@ public String getDescription() {
public void setDescription(String description) {
this.description = description;
}

public Info title(String title) {
this.title = title;
return this;
}

public Info version(String version) {
this.version = version;
return this;
}

public Info description(String description) {
this.description = description;
return this;
}

}
31 changes: 31 additions & 0 deletions src/main/java/com/apiflows/model/Parameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,35 @@ public void setStyle(String style) {
public void set$ref(String $ref) {
this.$ref = $ref;
}

public Parameter name(String name) {
this.name = name;
return this;
}

public Parameter in(String in) {
this.in = in;
return this;
}

public Parameter value(String value) {
this.value = value;
return this;
}

public Parameter target(String target) {
this.target = target;
return this;
}

public Parameter style(String style) {
this.style = style;
return this;
}

public Parameter $ref(String $ref) {
this.$ref = $ref;
return this;
}

}
16 changes: 16 additions & 0 deletions src/main/java/com/apiflows/model/SourceDescription.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,20 @@ public boolean isOpenApi() {
public boolean IsWorkflowsSpec() {
return "workflowsSpec".equals(this.type);
}

public SourceDescription name(String name) {
this.name = name;
return this;
}

public SourceDescription url(String url) {
this.url = url;
return this;
}

public SourceDescription type(String type) {
this.type = type;
return this;
}

}
65 changes: 65 additions & 0 deletions src/main/java/com/apiflows/model/Step.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,69 @@ public List<FailureAction> getOnFailure() {
public void setOnFailure(List<FailureAction> onFailure) {
this.onFailure = onFailure;
}

public Step stepId(String stepId) {
this.setStepId(stepId);
return this;
}

public Step operationId(String operationId) {
this.setOperationId(operationId);
return this;
}

public Step operationRef(String operationRef) {
this.setOperationRef(operationRef);
return this;
}

public Step operation(Operation operation) {
this.setOperation(operation);
return this;
}

public Step workflowId(String workflowId) {
this.setWorkflowId(workflowId);
return this;
}

public Step workflow(Workflow workflow) {
this.setWorkflow(workflow);
return this;
}

public Step description(String description) {
this.setDescription(description);
return this;
}

public Step dependsOn(String dependsOn) {
this.setDependsOn(dependsOn);
return this;
}

public Step parameters(List<Parameter> parameters) {
this.setParameters(parameters);
return this;
}

public Step successCriteria(List<Criterion> successCriteria) {
this.setSuccessCriteria(successCriteria);
return this;
}

public Step outputs(Map<String, String> outputs) {
this.setOutputs(outputs);
return this;
}

public Step onSuccess(List<SuccessAction> onSuccess) {
this.setOnSuccess(onSuccess);
return this;
}

public Step onFailure(List<FailureAction> onFailure) {
this.setOnFailure(onFailure);
return this;
}
}
23 changes: 23 additions & 0 deletions src/main/java/com/apiflows/model/SuccessAction.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.apiflows.model;

import java.util.ArrayList;
import java.util.List;

public class SuccessAction {
Expand Down Expand Up @@ -40,4 +41,26 @@ public List<Criterion> getCriteria() {
public void setCriteria(List<Criterion> criteria) {
this.criteria = criteria;
}

public void addCriteria(Criterion criterion) {
if(this.criteria == null) {
this.criteria = new ArrayList<>();
}
this.criteria.add(criterion);
}

public SuccessAction type(String type) {
this.type = type;
return this;
}

public SuccessAction workflowId(String workflowId) {
this.workflowId = workflowId;
return this;
}

public SuccessAction stepId(String stepId) {
this.stepId = stepId;
return this;
}
}
25 changes: 25 additions & 0 deletions src/main/java/com/apiflows/model/Workflow.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public void setSteps(List<Step> steps) {
this.steps = steps;
}

public Workflow addStep(Step step) {
this.steps.add(step);
return this;
}

@JsonProperty("outputs")
public Map<String, String> getOutputs() {
return outputs;
Expand All @@ -70,4 +75,24 @@ public Map<String, String> getOutputs() {
public void setOutputs(Map<String, String> outputs) {
this.outputs = outputs;
}

public Workflow workflowId(String workflowId) {
this.workflowId = workflowId;
return this;
}

public Workflow summary(String summary) {
this.summary = summary;
return this;
}
public Workflow description(String description) {
this.description = description;
return this;
}

public Workflow inputs(Schema inputs) {
this.inputs = inputs;
return this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public OpenAPIWorkflowParserResult parse(String input, ParseOptions options) {
result.setOpenAPIWorkflow(openAPIWorkflow);

if(options != null && options.isApplyValidation()) {
OpenAPIWorkflowValidatorResult validatorResult = new OpenAPIWorkflowValidator().validate(openAPIWorkflow);
OpenAPIWorkflowValidatorResult validatorResult = new OpenAPIWorkflowValidator(openAPIWorkflow).validate();
result.setValid(validatorResult.isValid());
result.setErrors(validatorResult.getErrors());
}
Expand Down
Loading