sdk-go
sdk-go copied to clipboard
allow empty auth definitions in parser
fixes https://github.com/serverlessworkflow/sdk-go/issues/110
Signed-off-by: spolti [email protected]
Many thanks for submitting your Pull Request :heart:!
What this PR does / why we need it:
Special notes for reviewers:
Additional information (if needed):
The problem is not cause by AuthDefinitions.Unmarshal implement, according to the specificaiton, auth field is an array of object, which like:

But in the source code, we place an Defs field under Auth Definition struct. So after we marshal object to json, it looks like:
{
"id": "applicantrequest",
"name": "Applicant Request Decision Workflow",
"description": "Determine if applicant request is valid",
"version": "1.0",
"start": {
"stateName": "CheckApplication"
},
"specVersion": "0.7",
"expressionLang": "jq",
"auth": {
"Defs": [{
"name": "testAuth",
"scheme": "bearer",
"properties": {
"token": "test_token"
}
}, {
"name": "testAuth2",
"scheme": "basic",
"properties": {
"username": "test_user",
"password": "test_pwd"
}
}]
},
"states": [{
"name": "CheckApplication",
"type": "switch",
"defaultCondition": {},
"dataConditions": [{
"condition": "${ .applicants | .age \u003e= 18 }",
"transition": {
"nextState": "StartApplication"
}
}, {
"condition": "${ .applicants | .age \u003c 18 }",
"transition": {
"nextState": "RejectApplication"
}
}],
"timeouts": {}
}, {
"name": "StartApplication",
"type": "operation",
"end": {
"terminate": true
},
"actions": [{
"subFlowRef": {
"workflowId": "startApplicationWorkflowId",
"invoke": "sync",
"onParentComplete": "terminate"
},
"sleep": {},
"actionDataFilter": {
"useResults": true
}
}]
}, {
"name": "RejectApplication",
"type": "operation",
"end": {
"terminate": true
},
"actionMode": "sequential",
"actions": [{
"functionRef": {
"refName": "sendRejectionEmailFunction",
"invoke": "sync"
},
"sleep": {},
"actionDataFilter": {
"useResults": true
}
}]
}],
"functions": [{
"name": "sendRejectionEmailFunction",
"operation": "http://myapis.org/applicationapi.json#emailRejection"
}],
"retries": [{
"name": "TimeoutRetryStrategy",
"delay": "PT1M",
"maxAttempts": "5",
"jitter": 0
}]
}
It's not equivalent. I think we should fix the struct field layout.
needed for v08 https://github.com/serverlessworkflow/sdk-go/issues/70
About the defs problem, there is another problem as well, see:
https://gist.github.com/spolti/ac43ce2cc5a51532987259db4f9fa5b7 Will address it on another issue: https://github.com/serverlessworkflow/sdk-go/issues/126
/lgtm