From a9428b5754250d105b20a6c283c53eba57c63000 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 12:55:43 +0000 Subject: [PATCH 01/11] fix: use const for call tasks Signed-off-by: Matthias Pichler --- schema/workflow.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/schema/workflow.yaml b/schema/workflow.yaml index d98321f3..b678f76f 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -133,7 +133,7 @@ $defs: - properties: call: type: string - constant: asyncapi + const: asyncapi with: type: object properties: @@ -164,7 +164,7 @@ $defs: - properties: call: type: string - constant: grpc + const: grpc with: type: object properties: @@ -203,7 +203,7 @@ $defs: - properties: call: type: string - constant: http + const: http with: type: object properties: @@ -228,7 +228,7 @@ $defs: - properties: call: type: string - constant: openapi + const: openapi with: type: object properties: From 58fb86c09ab6a2b0dfbba656b31cf60db1677e04 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 13:02:56 +0000 Subject: [PATCH 02/11] fix: replace ref with $ref Signed-off-by: Matthias Pichler --- schema/workflow.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/workflow.yaml b/schema/workflow.yaml index b678f76f..7ca8bdf7 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -156,7 +156,7 @@ $defs: type: object description: The payload to call the AsyncAPI operation with, if any. authentication: - ref: '#/$defs/authenticationPolicy' + $ref: '#/$defs/authenticationPolicy' description: The authentication policy, if any, to use when calling the AsyncAPI operation. required: [ document, operationRef ] description: Defines the AsyncAPI call to perform. From 672794a45a34cb5e2b1b9d13fd051ca63c9cf040 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 13:07:03 +0000 Subject: [PATCH 03/11] fix: allow references to authentications in use Signed-off-by: Matthias Pichler --- schema/workflow.yaml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/schema/workflow.yaml b/schema/workflow.yaml index 7ca8bdf7..a65d6589 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -156,8 +156,10 @@ $defs: type: object description: The payload to call the AsyncAPI operation with, if any. authentication: - $ref: '#/$defs/authenticationPolicy' description: The authentication policy, if any, to use when calling the AsyncAPI operation. + oneOf: + - $ref: '#/$defs/authenticationPolicy' + - type: string required: [ document, operationRef ] description: Defines the AsyncAPI call to perform. required: [ call, with ] @@ -187,8 +189,10 @@ $defs: max: 65535 description: The port number of the GRPC service to call. authentication: - $ref: '#/$defs/authenticationPolicy' description: The endpoint's authentication policy, if any. + oneOf: + - $ref: '#/$defs/authenticationPolicy' + - type: string required: [ name, host ] method: type: string @@ -243,8 +247,10 @@ $defs: additionalProperties: true description: A name/value mapping of the parameters of the OpenAPI operation to call. authentication: - $ref: '#/$defs/authenticationPolicy' description: The authentication policy, if any, to use when calling the OpenAPI operation. + oneOf: + - $ref: '#/$defs/authenticationPolicy' + - type: string output: type: string enum: [ raw, content, response ] @@ -668,8 +674,10 @@ $defs: format: uri description: The endpoint's URI. authentication: - $ref: '#/$defs/authenticationPolicy' description: The authentication policy to use. + oneOf: + - $ref: '#/$defs/authenticationPolicy' + - type: string required: [ uri ] eventConsumptionStrategy: type: object @@ -761,8 +769,10 @@ $defs: format: uri description: The endpoint's URI. authentication: - $ref: '#/$defs/authenticationPolicy' description: The authentication policy to use. + oneOf: + - $ref: '#/$defs/authenticationPolicy' + - type: string name: type: string description: The external resource's name, if any. From b178a8f871879728ec4ad399d17efee868b0c5e6 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 13:08:30 +0000 Subject: [PATCH 04/11] fix: add missing type directives to tasks Signed-off-by: Matthias Pichler --- schema/workflow.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/schema/workflow.yaml b/schema/workflow.yaml index a65d6589..6c8f2903 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -270,6 +270,7 @@ $defs: description: A name/value mapping of the parameters, if any, to call the function with. required: [ call ] compositeTask: + type: object properties: execute: type: object @@ -297,6 +298,7 @@ $defs: required: [ execute ] description: Serves as a pivotal orchestrator within workflow systems, enabling the seamless integration and execution of multiple subtasks to accomplish complex operations emitTask: + type: object properties: emit: type: object @@ -338,6 +340,7 @@ $defs: default: continue - type: string forTask: + type: object properties: for: type: object From e7cd73fa0286e43ff1fb79dd5cdc3e871f2a324c Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 13:24:10 +0000 Subject: [PATCH 05/11] fix: update use endpoint in examples Signed-off-by: Matthias Pichler --- dsl-reference.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/dsl-reference.md b/dsl-reference.md index f4fd9ad0..036fd872 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -149,14 +149,14 @@ use: call: http with: method: post - uri: https://fake.log.collector.com + endpoint: https://fake.log.collector.com body: message: "${ \"Executing task '\($task.reference)'...\" }" after: call: http with: method: post - uri: https://fake.log.collector.com + endpoint: https://fake.log.collector.com body: message: "${ \"Executed task '\($task.reference)'...\" }" functions: @@ -259,7 +259,7 @@ do: call: http with: method: get - uri: https://petstore.swagger.io/v2/pet/{petId} + endpoint: https://petstore.swagger.io/v2/pet/{petId} ``` Serverless Workflow defines several default functions that **MUST** be supported by all implementations and runtimes: @@ -371,7 +371,7 @@ do: call: http with: method: get - uri: https://petstore.swagger.io/v2/pet/{petId} + endpoint: https://petstore.swagger.io/v2/pet/{petId} ``` ##### OpenAPI Call @@ -481,7 +481,7 @@ do: call: http with: method: put - uri: https://fake-hospital.com/api/v3/alert/nurses + endpoint: https://fake-hospital.com/api/v3/alert/nurses body: patientId: ${ .patient.fullName } room: ${ .room.number } @@ -489,7 +489,7 @@ do: call: http with: method: put - uri: https://fake-hospital.com/api/v3/alert/doctor + endpoint: https://fake-hospital.com/api/v3/alert/doctor body: patientId: ${ .patient.fullName } room: ${ .room.number } @@ -917,7 +917,7 @@ do: call: http with: method: get - uri: https:// + endpoint: https:// catch: errors: with: @@ -1203,14 +1203,14 @@ use: call: http with: method: post - uri: https://fake.log.collector.com + endpoint: https://fake.log.collector.com body: message: "${ \"Executing task '\($task.reference)'...\" }" after: call: http with: method: post - uri: https://fake.log.collector.com + endpoint: https://fake.log.collector.com body: message: "${ \"Executed task '\($task.reference)'...\" }" do: @@ -1218,7 +1218,7 @@ do: call: http with: method: get - uri: https://fake.com/sample + endpoint: https://fake.com/sample ``` *Intercept HTTP calls to 'https://mocked.service.com' and mock its response:* @@ -1247,7 +1247,7 @@ do: call: http with: method: get - uri: https://fake.com/sample + endpoint: https://fake.com/sample ``` ### Error From a07afc02d52257c8bcc8c0af88424b7053428948 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 13:28:33 +0000 Subject: [PATCH 06/11] fix: allow to specify endpoint as string as described in dsl Signed-off-by: Matthias Pichler --- schema/workflow.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/schema/workflow.yaml b/schema/workflow.yaml index d98321f3..5088fe4c 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -211,8 +211,11 @@ $defs: type: string description: The HTTP method of the HTTP request to perform. endpoint: - $ref: '#/$defs/endpoint' description: The HTTP endpoint to send the request to. + oneOf: + - $ref: '#/$defs/endpoint' + - type: string + format: uri headers: type: object description: A name/value mapping of the headers, if any, of the HTTP request to perform. From 4425b0f80933cc5fc6a2e119db859a613be8a6e3 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 17:51:12 +0000 Subject: [PATCH 07/11] docs: add shorthand endpoint example Signed-off-by: Matthias Pichler --- examples/call-http-shorthand-endpoint.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 examples/call-http-shorthand-endpoint.yaml diff --git a/examples/call-http-shorthand-endpoint.yaml b/examples/call-http-shorthand-endpoint.yaml new file mode 100644 index 00000000..35a8c81d --- /dev/null +++ b/examples/call-http-shorthand-endpoint.yaml @@ -0,0 +1,11 @@ +document: + dsl: 1.0.0-alpha1 + namespace: examples + name: call-http-shorthand-endpoint + version: 1.0.0-alpha1 +do: + getPetById: + call: http + with: + method: get + endpoint: https://petstore.swagger.io/v2/pet/1 \ No newline at end of file From 62e012ddf7c97dbd99d8ad70d08cc834fd56951e Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 18:33:08 +0000 Subject: [PATCH 08/11] docs: add example of reusable auth Signed-off-by: Matthias Pichler --- examples/use-authentication.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 examples/use-authentication.yaml diff --git a/examples/use-authentication.yaml b/examples/use-authentication.yaml new file mode 100644 index 00000000..c8cd34fe --- /dev/null +++ b/examples/use-authentication.yaml @@ -0,0 +1,18 @@ +document: + dsl: 1.0.0-alpha1 + namespace: examples + name: bearer-auth + version: 1.0.0-alpha1 +use: + authentications: + petStoreAuth: + bearer: + token: ${ .token } +do: + getPetById: + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/{petId} + authentication: petStoreAuth From bd2aff41052cf47432444a1248f43bd2a24aa962 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 18:36:15 +0000 Subject: [PATCH 09/11] docs: add async api example Signed-off-by: Matthias Pichler --- examples/asyncapi.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 examples/asyncapi.yaml diff --git a/examples/asyncapi.yaml b/examples/asyncapi.yaml new file mode 100644 index 00000000..8c02d90d --- /dev/null +++ b/examples/asyncapi.yaml @@ -0,0 +1,20 @@ +document: + dsl: 1.0.0-alpha1 + namespace: examples + name: bearer-auth + version: 1.0.0-alpha1 +do: + greetUser: + call: asyncapi + with: + document: + uri: https://fake.com/docs/asyncapi.json + operation: findPetsByStatus + server: staging + message: getPetByStatusQuery + binding: http + payload: + petId: ${ .pet.id } + authentication: + bearer: + token: ${ .token } From aeba879bd76a95de65d5a1877f713e42afc1d505 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 18:39:54 +0000 Subject: [PATCH 10/11] fix: use operationRef Signed-off-by: Matthias Pichler --- examples/asyncapi.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/asyncapi.yaml b/examples/asyncapi.yaml index 8c02d90d..9d442d08 100644 --- a/examples/asyncapi.yaml +++ b/examples/asyncapi.yaml @@ -9,7 +9,7 @@ do: with: document: uri: https://fake.com/docs/asyncapi.json - operation: findPetsByStatus + operationRef: findPetsByStatus server: staging message: getPetByStatusQuery binding: http From fe884219a28f6fbe199ccf991cda0a65f30f7bb3 Mon Sep 17 00:00:00 2001 From: Matthias Pichler Date: Mon, 3 Jun 2024 19:13:45 +0000 Subject: [PATCH 11/11] fix: use uri-template Signed-off-by: Matthias Pichler --- examples/call-http-shorthand-endpoint.yaml | 2 +- schema/workflow.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/call-http-shorthand-endpoint.yaml b/examples/call-http-shorthand-endpoint.yaml index 35a8c81d..f682ed30 100644 --- a/examples/call-http-shorthand-endpoint.yaml +++ b/examples/call-http-shorthand-endpoint.yaml @@ -8,4 +8,4 @@ do: call: http with: method: get - endpoint: https://petstore.swagger.io/v2/pet/1 \ No newline at end of file + endpoint: https://petstore.swagger.io/v2/pet/{petId} diff --git a/schema/workflow.yaml b/schema/workflow.yaml index e39171d5..75c2093e 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -219,7 +219,7 @@ $defs: oneOf: - $ref: '#/$defs/endpoint' - type: string - format: uri + format: uri-template headers: type: object description: A name/value mapping of the headers, if any, of the HTTP request to perform.