Skip to content

Commit d0e0437

Browse files
authored
Merge pull request #77 from API-Flows/feat/missing-features
Implement missing Arazzo spec features
2 parents b4be1fe + 9671faa commit d0e0437

11 files changed

Lines changed: 494 additions & 144 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.apiflows.model;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
public abstract class Action {
7+
8+
private String name;
9+
private String type;
10+
private String workflowId;
11+
private String stepId;
12+
private List<Criterion> criteria;
13+
14+
public String getName() {
15+
return name;
16+
}
17+
18+
public void setName(String name) {
19+
this.name = name;
20+
}
21+
22+
public String getType() {
23+
return type;
24+
}
25+
26+
public void setType(String type) {
27+
this.type = type;
28+
}
29+
30+
public String getWorkflowId() {
31+
return workflowId;
32+
}
33+
34+
public void setWorkflowId(String workflowId) {
35+
this.workflowId = workflowId;
36+
}
37+
38+
public String getStepId() {
39+
return stepId;
40+
}
41+
42+
public void setStepId(String stepId) {
43+
this.stepId = stepId;
44+
}
45+
46+
public List<Criterion> getCriteria() {
47+
return criteria;
48+
}
49+
50+
public void setCriteria(List<Criterion> criteria) {
51+
this.criteria = criteria;
52+
}
53+
54+
public void addCriteria(Criterion criterion) {
55+
if (this.criteria == null) {
56+
this.criteria = new ArrayList<>();
57+
}
58+
this.criteria.add(criterion);
59+
}
60+
}

src/main/java/com/apiflows/model/Criterion.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package com.apiflows.model;
22

3+
import com.apiflows.parser.util.CriterionTypeDeserializer;
34
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
46

57
public class Criterion {
68

79
private String condition;
810
private String context;
9-
private String type;
11+
12+
@JsonDeserialize(using = CriterionTypeDeserializer.class)
13+
private Object type;
1014

1115
public String getCondition() {
1216
return condition;
@@ -24,14 +28,25 @@ public void setContext(String context) {
2428
this.context = context;
2529
}
2630

31+
/** Returns the simple string type (e.g. "simple", "regex") or null if an expression type object is used. */
32+
@JsonProperty("type")
2733
public String getType() {
28-
return type;
34+
return type instanceof String ? (String) type : null;
2935
}
3036

3137
public void setType(String type) {
3238
this.type = type;
3339
}
3440

41+
/** Returns the expression type object when type is "jsonpath" or "xpath" with a version, or null otherwise. */
42+
public CriterionExpressionType getExpressionType() {
43+
return type instanceof CriterionExpressionType ? (CriterionExpressionType) type : null;
44+
}
45+
46+
public void setExpressionType(CriterionExpressionType expressionType) {
47+
this.type = expressionType;
48+
}
49+
3550
public Criterion condition(String condition) {
3651
this.condition = condition;
3752
return this;
@@ -46,5 +61,10 @@ public Criterion type(String type) {
4661
this.type = type;
4762
return this;
4863
}
64+
65+
public Criterion expressionType(CriterionExpressionType expressionType) {
66+
this.type = expressionType;
67+
return this;
68+
}
4969
}
5070

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.apiflows.model;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
public class CriterionExpressionType {
6+
7+
private String type;
8+
private String version;
9+
10+
@JsonProperty("type")
11+
public String getType() {
12+
return type;
13+
}
14+
15+
public void setType(String type) {
16+
this.type = type;
17+
}
18+
19+
@JsonProperty("version")
20+
public String getVersion() {
21+
return version;
22+
}
23+
24+
public void setVersion(String version) {
25+
this.version = version;
26+
}
27+
28+
public CriterionExpressionType type(String type) {
29+
this.type = type;
30+
return this;
31+
}
32+
33+
public CriterionExpressionType version(String version) {
34+
this.version = version;
35+
return this;
36+
}
37+
}
Lines changed: 7 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,9 @@
11
package com.apiflows.model;
22

3-
import java.util.ArrayList;
4-
import java.util.List;
3+
public class FailureAction extends Action {
54

6-
public class FailureAction {
7-
8-
private String type;
9-
private String workflowId;
10-
private String stepId;
115
private Double retryAfter;
126
private Integer retryLimit;
13-
private List<Criterion> criteria;
14-
15-
public String getType() {
16-
return type;
17-
}
18-
19-
public void setType(String type) {
20-
this.type = type;
21-
}
22-
23-
public String getWorkflowId() {
24-
return workflowId;
25-
}
26-
27-
public void setWorkflowId(String workflowId) {
28-
this.workflowId = workflowId;
29-
}
30-
31-
public String getStepId() {
32-
return stepId;
33-
}
34-
35-
public void setStepId(String stepId) {
36-
this.stepId = stepId;
37-
}
387

398
public Double getRetryAfter() {
409
return retryAfter;
@@ -52,26 +21,23 @@ public void setRetryLimit(Integer retryLimit) {
5221
this.retryLimit = retryLimit;
5322
}
5423

55-
public List<Criterion> getCriteria() {
56-
return criteria;
57-
}
58-
59-
public void setCriteria(List<Criterion> criteria) {
60-
this.criteria = criteria;
24+
public FailureAction name(String name) {
25+
setName(name);
26+
return this;
6127
}
6228

6329
public FailureAction type(String type) {
64-
this.type = type;
30+
setType(type);
6531
return this;
6632
}
6733

6834
public FailureAction stepId(String stepId) {
69-
this.stepId = stepId;
35+
setStepId(stepId);
7036
return this;
7137
}
7238

7339
public FailureAction workflowId(String workflowId) {
74-
this.workflowId = workflowId;
40+
setWorkflowId(workflowId);
7541
return this;
7642
}
7743

@@ -84,11 +50,4 @@ public FailureAction retryLimit(Integer retryLimit) {
8450
this.retryLimit = retryLimit;
8551
return this;
8652
}
87-
88-
public void addCriteria(Criterion criterion) {
89-
if(this.criteria == null) {
90-
this.criteria = new ArrayList<>();
91-
}
92-
this.criteria.add(criterion);
93-
}
9453
}

src/main/java/com/apiflows/model/Info.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
public class Info {
66

77
private String title;
8+
private String summary;
89
private String version;
910
private String description;
1011

@@ -17,6 +18,15 @@ public void setTitle(String title) {
1718
this.title = title;
1819
}
1920

21+
@JsonProperty("summary")
22+
public String getSummary() {
23+
return summary;
24+
}
25+
26+
public void setSummary(String summary) {
27+
this.summary = summary;
28+
}
29+
2030
@JsonProperty("version")
2131
public String getVersion() {
2232
return version;
@@ -40,6 +50,11 @@ public Info title(String title) {
4050
return this;
4151
}
4252

53+
public Info summary(String summary) {
54+
this.summary = summary;
55+
return this;
56+
}
57+
4358
public Info version(String version) {
4459
this.version = version;
4560
return this;

src/main/java/com/apiflows/model/Parameter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class Parameter {
66

77
private String name;
88
private String in;
9-
private String value;
9+
private Object value;
1010
private String reference;
1111

1212
@JsonProperty("name")
@@ -28,11 +28,11 @@ public void setIn(String in) {
2828
}
2929

3030
@JsonProperty("value")
31-
public String getValue() {
31+
public Object getValue() {
3232
return value;
3333
}
3434

35-
public void setValue(String value) {
35+
public void setValue(Object value) {
3636
this.value = value;
3737
}
3838

@@ -55,7 +55,7 @@ public Parameter in(String in) {
5555
return this;
5656
}
5757

58-
public Parameter value(String value) {
58+
public Parameter value(Object value) {
5959
this.value = value;
6060
return this;
6161
}
Lines changed: 7 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,24 @@
11
package com.apiflows.model;
22

3-
import java.util.ArrayList;
4-
import java.util.List;
3+
public class SuccessAction extends Action {
54

6-
public class SuccessAction {
7-
8-
private String type;
9-
private String workflowId;
10-
private String stepId;
11-
private List<Criterion> criteria;
12-
13-
public String getType() {
14-
return type;
15-
}
16-
17-
public void setType(String type) {
18-
this.type = type;
19-
}
20-
21-
public String getWorkflowId() {
22-
return workflowId;
23-
}
24-
25-
public void setWorkflowId(String workflowId) {
26-
this.workflowId = workflowId;
27-
}
28-
29-
public String getStepId() {
30-
return stepId;
31-
}
32-
33-
public void setStepId(String stepId) {
34-
this.stepId = stepId;
35-
}
36-
37-
public List<Criterion> getCriteria() {
38-
return criteria;
39-
}
40-
41-
public void setCriteria(List<Criterion> criteria) {
42-
this.criteria = criteria;
43-
}
44-
45-
public void addCriteria(Criterion criterion) {
46-
if(this.criteria == null) {
47-
this.criteria = new ArrayList<>();
48-
}
49-
this.criteria.add(criterion);
5+
public SuccessAction name(String name) {
6+
setName(name);
7+
return this;
508
}
519

5210
public SuccessAction type(String type) {
53-
this.type = type;
11+
setType(type);
5412
return this;
5513
}
5614

5715
public SuccessAction workflowId(String workflowId) {
58-
this.workflowId = workflowId;
16+
setWorkflowId(workflowId);
5917
return this;
6018
}
6119

6220
public SuccessAction stepId(String stepId) {
63-
this.stepId = stepId;
21+
setStepId(stepId);
6422
return this;
6523
}
6624
}

0 commit comments

Comments
 (0)