mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-17 20:50:44 +00:00
Fixed process responses in openapi.yaml -- they were a layer too low, w/ a wrapped "typedResponse" above them (and since they were being serialized directly by jackson, were missing the 'values' now that they were marked to be ignored by it... so going through our conversion method in here - this suggests some refactoring that should apply a change like this to all specs, in case they have overrides of handleOutput as well...
This commit is contained in:
@ -28,6 +28,7 @@ import java.time.LocalDate;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.kingsrook.qqq.backend.core.actions.tables.InsertAction;
|
import com.kingsrook.qqq.backend.core.actions.tables.InsertAction;
|
||||||
import com.kingsrook.qqq.backend.core.actions.values.QValueFormatter;
|
import com.kingsrook.qqq.backend.core.actions.values.QValueFormatter;
|
||||||
@ -141,12 +142,14 @@ public class ProcessSpecUtilsV1
|
|||||||
errorResponse.setError("Illegal Argument Exception: NaN");
|
errorResponse.setError("Illegal Argument Exception: NaN");
|
||||||
errorResponse.setUserFacingError("The process could not be completed due to invalid input.");
|
errorResponse.setUserFacingError("The process could not be completed due to invalid input.");
|
||||||
|
|
||||||
|
Function<ProcessInitOrStepOrStatusResponseV1, Example> responseToExample = response -> new Example().withValue(convertResponseToJSONObject(response).toMap());
|
||||||
|
|
||||||
return MapBuilder.of(() -> new LinkedHashMap<String, Example>())
|
return MapBuilder.of(() -> new LinkedHashMap<String, Example>())
|
||||||
.with("COMPLETE", new Example().withValue(completeResponse))
|
.with("COMPLETE", responseToExample.apply(completeResponse))
|
||||||
.with("COMPLETE with metaDataAdjustment", new Example().withValue(completeResponseWithMetaDataAdjustment))
|
.with("COMPLETE with metaDataAdjustment", responseToExample.apply(completeResponseWithMetaDataAdjustment))
|
||||||
.with("JOB_STARTED", new Example().withValue(jobStartedResponse))
|
.with("JOB_STARTED", responseToExample.apply(jobStartedResponse))
|
||||||
.with("RUNNING", new Example().withValue(runningResponse))
|
.with("RUNNING", responseToExample.apply(runningResponse))
|
||||||
.with("ERROR", new Example().withValue(errorResponse))
|
.with("ERROR", responseToExample.apply(errorResponse))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +158,21 @@ public class ProcessSpecUtilsV1
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
**
|
**
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
public static void handleOutput(Context context, ProcessInitOrStepOrStatusResponseV1 output)
|
public static void handleOutput(Context context, ProcessInitOrStepOrStatusResponseV1 response)
|
||||||
|
{
|
||||||
|
JSONObject outputJsonObject = convertResponseToJSONObject(response);
|
||||||
|
|
||||||
|
String json = outputJsonObject.toString(3);
|
||||||
|
System.out.println(json);
|
||||||
|
context.result(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
**
|
||||||
|
***************************************************************************/
|
||||||
|
private static JSONObject convertResponseToJSONObject(ProcessInitOrStepOrStatusResponseV1 response)
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// normally, we like the JsonUtils behavior of excluding null/empty elements. //
|
// normally, we like the JsonUtils behavior of excluding null/empty elements. //
|
||||||
@ -163,7 +180,7 @@ public class ProcessSpecUtilsV1
|
|||||||
// so, go through a loop of object → JSON String → JSONObject → String... //
|
// so, go through a loop of object → JSON String → JSONObject → String... //
|
||||||
// also - work with the TypedResponse sub-object within this response class //
|
// also - work with the TypedResponse sub-object within this response class //
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ProcessInitOrStepOrStatusResponseV1.TypedResponse typedOutput = output.getTypedResponse();
|
ProcessInitOrStepOrStatusResponseV1.TypedResponse typedOutput = response.getTypedResponse();
|
||||||
|
|
||||||
String outputJson = JsonUtils.toJson(typedOutput);
|
String outputJson = JsonUtils.toJson(typedOutput);
|
||||||
JSONObject outputJsonObject = new JSONObject(outputJson);
|
JSONObject outputJsonObject = new JSONObject(outputJson);
|
||||||
@ -280,10 +297,7 @@ public class ProcessSpecUtilsV1
|
|||||||
outputJsonObject.put("values", valuesAsJsonObject);
|
outputJsonObject.put("values", valuesAsJsonObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return outputJsonObject;
|
||||||
String json = outputJsonObject.toString(3);
|
|
||||||
System.out.println(json);
|
|
||||||
context.result(json);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1652,66 +1652,61 @@ paths:
|
|||||||
examples:
|
examples:
|
||||||
COMPLETE:
|
COMPLETE:
|
||||||
value:
|
value:
|
||||||
typedResponse:
|
values:
|
||||||
nextStep: "reviewScreen"
|
firstLastName: "Aabramson"
|
||||||
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
totalAge: 32768
|
||||||
type: "COMPLETE"
|
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
||||||
values:
|
nextStep: "reviewScreen"
|
||||||
totalAge: 32768
|
type: "COMPLETE"
|
||||||
firstLastName: "Aabramson"
|
|
||||||
COMPLETE with metaDataAdjustment:
|
COMPLETE with metaDataAdjustment:
|
||||||
value:
|
value:
|
||||||
typedResponse:
|
values:
|
||||||
nextStep: "inputScreen"
|
firstLastName: "Aabramson"
|
||||||
processMetaDataAdjustment:
|
totalAge: 32768
|
||||||
updatedFields:
|
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
||||||
someField:
|
nextStep: "inputScreen"
|
||||||
displayFormat: "%s"
|
processMetaDataAdjustment:
|
||||||
isEditable: true
|
updatedFields:
|
||||||
isHeavy: false
|
someField:
|
||||||
isHidden: false
|
isRequired: true
|
||||||
isRequired: true
|
isEditable: true
|
||||||
name: "someField"
|
name: "someField"
|
||||||
type: "STRING"
|
displayFormat: "%s"
|
||||||
updatedFrontendStepList:
|
type: "STRING"
|
||||||
- components:
|
isHeavy: false
|
||||||
- type: "EDIT_FORM"
|
isHidden: false
|
||||||
formFields:
|
updatedFrontendStepList:
|
||||||
- displayFormat: "%s"
|
- components:
|
||||||
isEditable: true
|
- type: "EDIT_FORM"
|
||||||
isHeavy: false
|
name: "inputScreen"
|
||||||
isHidden: false
|
formFields:
|
||||||
isRequired: false
|
- isRequired: false
|
||||||
name: "someField"
|
isEditable: true
|
||||||
type: "STRING"
|
name: "someField"
|
||||||
name: "inputScreen"
|
displayFormat: "%s"
|
||||||
- components:
|
type: "STRING"
|
||||||
- type: "PROCESS_SUMMARY_RESULTS"
|
isHeavy: false
|
||||||
name: "resultScreen"
|
isHidden: false
|
||||||
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
- components:
|
||||||
type: "COMPLETE"
|
- type: "PROCESS_SUMMARY_RESULTS"
|
||||||
values:
|
name: "resultScreen"
|
||||||
totalAge: 32768
|
type: "COMPLETE"
|
||||||
firstLastName: "Aabramson"
|
|
||||||
JOB_STARTED:
|
JOB_STARTED:
|
||||||
value:
|
value:
|
||||||
typedResponse:
|
jobUUID: "98765432-10FE-DCBA-9876-543210FEDCBA"
|
||||||
jobUUID: "98765432-10FE-DCBA-9876-543210FEDCBA"
|
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
||||||
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
type: "JOB_STARTED"
|
||||||
type: "JOB_STARTED"
|
|
||||||
RUNNING:
|
RUNNING:
|
||||||
value:
|
value:
|
||||||
typedResponse:
|
current: 47
|
||||||
current: 47
|
total: 1701
|
||||||
message: "Processing person records"
|
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
||||||
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
type: "RUNNING"
|
||||||
total: 1701
|
message: "Processing person records"
|
||||||
type: "RUNNING"
|
|
||||||
ERROR:
|
ERROR:
|
||||||
value:
|
value:
|
||||||
typedResponse:
|
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
||||||
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
type: "RUNNING"
|
||||||
type: "RUNNING"
|
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/ProcessStepResponseV1"
|
$ref: "#/components/schemas/ProcessStepResponseV1"
|
||||||
description: "State of the initialization of the job, with different fields\
|
description: "State of the initialization of the job, with different fields\
|
||||||
@ -1788,66 +1783,61 @@ paths:
|
|||||||
examples:
|
examples:
|
||||||
COMPLETE:
|
COMPLETE:
|
||||||
value:
|
value:
|
||||||
typedResponse:
|
values:
|
||||||
nextStep: "reviewScreen"
|
firstLastName: "Aabramson"
|
||||||
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
totalAge: 32768
|
||||||
type: "COMPLETE"
|
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
||||||
values:
|
nextStep: "reviewScreen"
|
||||||
totalAge: 32768
|
type: "COMPLETE"
|
||||||
firstLastName: "Aabramson"
|
|
||||||
COMPLETE with metaDataAdjustment:
|
COMPLETE with metaDataAdjustment:
|
||||||
value:
|
value:
|
||||||
typedResponse:
|
values:
|
||||||
nextStep: "inputScreen"
|
firstLastName: "Aabramson"
|
||||||
processMetaDataAdjustment:
|
totalAge: 32768
|
||||||
updatedFields:
|
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
||||||
someField:
|
nextStep: "inputScreen"
|
||||||
displayFormat: "%s"
|
processMetaDataAdjustment:
|
||||||
isEditable: true
|
updatedFields:
|
||||||
isHeavy: false
|
someField:
|
||||||
isHidden: false
|
isRequired: true
|
||||||
isRequired: true
|
isEditable: true
|
||||||
name: "someField"
|
name: "someField"
|
||||||
type: "STRING"
|
displayFormat: "%s"
|
||||||
updatedFrontendStepList:
|
type: "STRING"
|
||||||
- components:
|
isHeavy: false
|
||||||
- type: "EDIT_FORM"
|
isHidden: false
|
||||||
formFields:
|
updatedFrontendStepList:
|
||||||
- displayFormat: "%s"
|
- components:
|
||||||
isEditable: true
|
- type: "EDIT_FORM"
|
||||||
isHeavy: false
|
name: "inputScreen"
|
||||||
isHidden: false
|
formFields:
|
||||||
isRequired: false
|
- isRequired: false
|
||||||
name: "someField"
|
isEditable: true
|
||||||
type: "STRING"
|
name: "someField"
|
||||||
name: "inputScreen"
|
displayFormat: "%s"
|
||||||
- components:
|
type: "STRING"
|
||||||
- type: "PROCESS_SUMMARY_RESULTS"
|
isHeavy: false
|
||||||
name: "resultScreen"
|
isHidden: false
|
||||||
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
- components:
|
||||||
type: "COMPLETE"
|
- type: "PROCESS_SUMMARY_RESULTS"
|
||||||
values:
|
name: "resultScreen"
|
||||||
totalAge: 32768
|
type: "COMPLETE"
|
||||||
firstLastName: "Aabramson"
|
|
||||||
JOB_STARTED:
|
JOB_STARTED:
|
||||||
value:
|
value:
|
||||||
typedResponse:
|
jobUUID: "98765432-10FE-DCBA-9876-543210FEDCBA"
|
||||||
jobUUID: "98765432-10FE-DCBA-9876-543210FEDCBA"
|
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
||||||
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
type: "JOB_STARTED"
|
||||||
type: "JOB_STARTED"
|
|
||||||
RUNNING:
|
RUNNING:
|
||||||
value:
|
value:
|
||||||
typedResponse:
|
current: 47
|
||||||
current: 47
|
total: 1701
|
||||||
message: "Processing person records"
|
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
||||||
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
type: "RUNNING"
|
||||||
total: 1701
|
message: "Processing person records"
|
||||||
type: "RUNNING"
|
|
||||||
ERROR:
|
ERROR:
|
||||||
value:
|
value:
|
||||||
typedResponse:
|
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
||||||
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
type: "RUNNING"
|
||||||
type: "RUNNING"
|
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/ProcessStepResponseV1"
|
$ref: "#/components/schemas/ProcessStepResponseV1"
|
||||||
description: "State of the backend's running of the next step(s) of the\
|
description: "State of the backend's running of the next step(s) of the\
|
||||||
@ -1895,66 +1885,61 @@ paths:
|
|||||||
examples:
|
examples:
|
||||||
COMPLETE:
|
COMPLETE:
|
||||||
value:
|
value:
|
||||||
typedResponse:
|
values:
|
||||||
nextStep: "reviewScreen"
|
firstLastName: "Aabramson"
|
||||||
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
totalAge: 32768
|
||||||
type: "COMPLETE"
|
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
||||||
values:
|
nextStep: "reviewScreen"
|
||||||
totalAge: 32768
|
type: "COMPLETE"
|
||||||
firstLastName: "Aabramson"
|
|
||||||
COMPLETE with metaDataAdjustment:
|
COMPLETE with metaDataAdjustment:
|
||||||
value:
|
value:
|
||||||
typedResponse:
|
values:
|
||||||
nextStep: "inputScreen"
|
firstLastName: "Aabramson"
|
||||||
processMetaDataAdjustment:
|
totalAge: 32768
|
||||||
updatedFields:
|
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
||||||
someField:
|
nextStep: "inputScreen"
|
||||||
displayFormat: "%s"
|
processMetaDataAdjustment:
|
||||||
isEditable: true
|
updatedFields:
|
||||||
isHeavy: false
|
someField:
|
||||||
isHidden: false
|
isRequired: true
|
||||||
isRequired: true
|
isEditable: true
|
||||||
name: "someField"
|
name: "someField"
|
||||||
type: "STRING"
|
displayFormat: "%s"
|
||||||
updatedFrontendStepList:
|
type: "STRING"
|
||||||
- components:
|
isHeavy: false
|
||||||
- type: "EDIT_FORM"
|
isHidden: false
|
||||||
formFields:
|
updatedFrontendStepList:
|
||||||
- displayFormat: "%s"
|
- components:
|
||||||
isEditable: true
|
- type: "EDIT_FORM"
|
||||||
isHeavy: false
|
name: "inputScreen"
|
||||||
isHidden: false
|
formFields:
|
||||||
isRequired: false
|
- isRequired: false
|
||||||
name: "someField"
|
isEditable: true
|
||||||
type: "STRING"
|
name: "someField"
|
||||||
name: "inputScreen"
|
displayFormat: "%s"
|
||||||
- components:
|
type: "STRING"
|
||||||
- type: "PROCESS_SUMMARY_RESULTS"
|
isHeavy: false
|
||||||
name: "resultScreen"
|
isHidden: false
|
||||||
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
- components:
|
||||||
type: "COMPLETE"
|
- type: "PROCESS_SUMMARY_RESULTS"
|
||||||
values:
|
name: "resultScreen"
|
||||||
totalAge: 32768
|
type: "COMPLETE"
|
||||||
firstLastName: "Aabramson"
|
|
||||||
JOB_STARTED:
|
JOB_STARTED:
|
||||||
value:
|
value:
|
||||||
typedResponse:
|
jobUUID: "98765432-10FE-DCBA-9876-543210FEDCBA"
|
||||||
jobUUID: "98765432-10FE-DCBA-9876-543210FEDCBA"
|
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
||||||
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
type: "JOB_STARTED"
|
||||||
type: "JOB_STARTED"
|
|
||||||
RUNNING:
|
RUNNING:
|
||||||
value:
|
value:
|
||||||
typedResponse:
|
current: 47
|
||||||
current: 47
|
total: 1701
|
||||||
message: "Processing person records"
|
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
||||||
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
type: "RUNNING"
|
||||||
total: 1701
|
message: "Processing person records"
|
||||||
type: "RUNNING"
|
|
||||||
ERROR:
|
ERROR:
|
||||||
value:
|
value:
|
||||||
typedResponse:
|
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
||||||
processUUID: "01234567-89AB-CDEF-0123-456789ABCDEF"
|
type: "RUNNING"
|
||||||
type: "RUNNING"
|
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/ProcessStepResponseV1"
|
$ref: "#/components/schemas/ProcessStepResponseV1"
|
||||||
description: "State of the backend's running of the specified job, with\
|
description: "State of the backend's running of the specified job, with\
|
||||||
|
Reference in New Issue
Block a user