Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Fix missng works item from openapi.json #330

Merged
merged 3 commits into from
May 10, 2023
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
17 changes: 15 additions & 2 deletions workflow-service-sdk/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -877,10 +877,16 @@ components:
example:
workFlowName: workFlowName
works:
- name: name
- works:
- null
- null
name: name
type: TASK
status: FAILED
- name: name
- works:
- null
- null
name: name
type: TASK
status: FAILED
workFlowExecutionId: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
Expand Down Expand Up @@ -954,6 +960,9 @@ components:
type: object
WorkStatusResponseDTO:
example:
works:
- null
- null
name: name
type: TASK
status: FAILED
Expand All @@ -973,6 +982,10 @@ components:
- TASK
- WORKFLOW
type: string
works:
items:
$ref: '#/components/schemas/WorkStatusResponseDTO'
type: array
type: object
updateParameter_200_response:
allOf:
Expand Down
1 change: 1 addition & 0 deletions workflow-service-sdk/docs/WorkStatusResponseDTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
|**name** | **String** | | [optional] |
|**status** | [**StatusEnum**](#StatusEnum) | | [optional] |
|**type** | [**TypeEnum**](#TypeEnum) | | [optional] |
|**works** | [**List<WorkStatusResponseDTO>**](WorkStatusResponseDTO.md) | | [optional] |



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
package com.redhat.parodos.sdk.model;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.TypeAdapter;
Expand Down Expand Up @@ -159,6 +162,11 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException {
@SerializedName(SERIALIZED_NAME_TYPE)
private TypeEnum type;

public static final String SERIALIZED_NAME_WORKS = "works";

@SerializedName(SERIALIZED_NAME_WORKS)
private List<WorkStatusResponseDTO> works = new ArrayList<>();

public WorkStatusResponseDTO() {
}

Expand Down Expand Up @@ -222,6 +230,34 @@ public void setType(TypeEnum type) {
this.type = type;
}

public WorkStatusResponseDTO works(List<WorkStatusResponseDTO> works) {

this.works = works;
return this;
}

public WorkStatusResponseDTO addWorksItem(WorkStatusResponseDTO worksItem) {
if (this.works == null) {
this.works = new ArrayList<>();
}
this.works.add(worksItem);
return this;
}

/**
* Get works
* @return works
**/
@javax.annotation.Nullable

public List<WorkStatusResponseDTO> getWorks() {
return works;
}

public void setWorks(List<WorkStatusResponseDTO> works) {
this.works = works;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand All @@ -233,12 +269,13 @@ public boolean equals(Object o) {
WorkStatusResponseDTO workStatusResponseDTO = (WorkStatusResponseDTO) o;
return Objects.equals(this.name, workStatusResponseDTO.name)
&& Objects.equals(this.status, workStatusResponseDTO.status)
&& Objects.equals(this.type, workStatusResponseDTO.type);
&& Objects.equals(this.type, workStatusResponseDTO.type)
&& Objects.equals(this.works, workStatusResponseDTO.works);
}

@Override
public int hashCode() {
return Objects.hash(name, status, type);
return Objects.hash(name, status, type, works);
}

@Override
Expand All @@ -248,6 +285,7 @@ public String toString() {
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" status: ").append(toIndentedString(status)).append("\n");
sb.append(" type: ").append(toIndentedString(type)).append("\n");
sb.append(" works: ").append(toIndentedString(works)).append("\n");
sb.append("}");
return sb.toString();
}
Expand All @@ -273,6 +311,7 @@ private String toIndentedString(Object o) {
openapiFields.add("name");
openapiFields.add("status");
openapiFields.add("type");
openapiFields.add("works");

// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet<String>();
Expand Down Expand Up @@ -323,6 +362,23 @@ public static void validateJsonObject(JsonObject jsonObj) throws IOException {
String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`",
jsonObj.get("type").toString()));
}
if (jsonObj.get("works") != null && !jsonObj.get("works").isJsonNull()) {
JsonArray jsonArrayworks = jsonObj.getAsJsonArray("works");
if (jsonArrayworks != null) {
// ensure the json data is an array
if (!jsonObj.get("works").isJsonArray()) {
throw new IllegalArgumentException(
String.format("Expected the field `works` to be an array in the JSON string but got `%s`",
jsonObj.get("works").toString()));
}

// validate the optional field `works` (array)
for (int i = 0; i < jsonArrayworks.size(); i++) {
WorkStatusResponseDTO.validateJsonObject(jsonArrayworks.get(i).getAsJsonObject());
}
;
}
}
}

public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
Expand Down
6 changes: 6 additions & 0 deletions workflow-service/generated/openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,12 @@
"type" : {
"type" : "string",
"enum" : [ "TASK", "WORKFLOW" ]
},
"works" : {
"type" : "array",
"items" : {
"$ref" : "#/components/schemas/WorkStatusResponseDTO"
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
@JsonIgnoreProperties(ignoreUnknown = true)
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class WorkDefinitionResponseDTO {

private UUID id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ public class WorkFlowDefinitionResponseDTO {

private Date modifyDate;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Map<String, Map<String, Object>> parameters;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private WorkFlowPropertiesDefinitionDTO properties;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<WorkDefinitionResponseDTO> works;

public static class WorkFlowDefinitionResponseDTOBuilder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class WorkFlowContextResponseDTO {

private UUID workFlowExecutionId;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private WorkFlowOptionsResponseDTO workFlowOptions;

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@Data
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class WorkFlowOptionsResponseDTO {

private WorkFlowOption currentVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
@Data
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class WorkFlowResponseDTO {

private UUID workFlowExecutionId;
Expand All @@ -44,7 +44,6 @@ public class WorkFlowResponseDTO {

private String workFlowName;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
private WorkStatus workStatus;

private String startDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class WorkFlowStatusResponseDTO {

private WorkStatus status;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<WorkStatusResponseDTO> works;

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.redhat.parodos.workflow.enums.WorkType;
import com.redhat.parodos.workflow.execution.entity.WorkFlowExecution;
import com.redhat.parodos.workflows.work.WorkStatus;
Expand Down Expand Up @@ -46,7 +47,8 @@ public class WorkStatusResponseDTO {

private WorkStatus status;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty("works")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<WorkStatusResponseDTO> works;

@JsonIgnore
Expand Down