Skip to content

Commit b970f16

Browse files
committed
[Fix serverlessworkflow#359] Generating not referenced Pojos
Signed-off-by: Francisco Javier Tirado Sarti <ftirados@redhat.com>
1 parent 84943b5 commit b970f16

File tree

5 files changed

+214
-59
lines changed

5 files changed

+214
-59
lines changed

api/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,15 @@
9494
<targetVersion>${java.version}</targetVersion>
9595
<usePrimitives>true</usePrimitives>
9696
<useJakartaValidation>true</useJakartaValidation>
97+
<customRuleFactory>io.serverlessworkflow.generator.UnreferencedFactory</customRuleFactory>
9798
</configuration>
99+
<dependencies>
100+
<dependency>
101+
<groupId>io.serverlessworkflow</groupId>
102+
<artifactId>custom-generator</artifactId>
103+
<version>${project.version}</version>
104+
</dependency>
105+
</dependencies>
98106
<executions>
99107
<execution>
100108
<goals>

api/src/main/resources/schema/workflow.yaml

Lines changed: 102 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,13 @@ properties:
5151
$ref: '#/$defs/error'
5252
description: The workflow's reusable errors.
5353
extensions:
54-
type: object
55-
additionalProperties:
56-
$ref: '#/$defs/extension'
54+
type: array
55+
items:
56+
type: object
57+
minProperties: 1
58+
maxProperties: 1
59+
additionalProperties:
60+
$ref: '#/$defs/extension'
5761
description: The workflow's extensions.
5862
functions:
5963
type: object
@@ -72,11 +76,8 @@ properties:
7276
description: The workflow's secrets.
7377
description: Defines the workflow's reusable components.
7478
do:
75-
type: object
76-
minProperties: 1
77-
additionalProperties:
78-
$ref: '#/$defs/task'
79-
description: Defines the tasks the workflow must perform
79+
description: Defines the task the workflow must perform
80+
$ref: '#/$defs/task'
8081
timeout:
8182
$ref: '#/$defs/timeout'
8283
description: The workflow's timeout configuration, if any.
@@ -109,6 +110,9 @@ $defs:
109110
output:
110111
$ref: '#/$defs/output'
111112
description: Configure the task's output.
113+
export:
114+
$ref: '#/$defs/export'
115+
description: Export task output to context.
112116
timeout:
113117
$ref: '#/$defs/timeout'
114118
description: The task's timeout configuration, if any.
@@ -133,7 +137,7 @@ $defs:
133137
- properties:
134138
call:
135139
type: string
136-
constant: asyncapi
140+
const: asyncapi
137141
with:
138142
type: object
139143
properties:
@@ -156,15 +160,17 @@ $defs:
156160
type: object
157161
description: The payload to call the AsyncAPI operation with, if any.
158162
authentication:
159-
ref: '#/$defs/authenticationPolicy'
160163
description: The authentication policy, if any, to use when calling the AsyncAPI operation.
164+
oneOf:
165+
- $ref: '#/$defs/authenticationPolicy'
166+
- type: string
161167
required: [ document, operationRef ]
162168
description: Defines the AsyncAPI call to perform.
163169
required: [ call, with ]
164170
- properties:
165171
call:
166172
type: string
167-
constant: grpc
173+
const: grpc
168174
with:
169175
type: object
170176
properties:
@@ -187,8 +193,10 @@ $defs:
187193
max: 65535
188194
description: The port number of the GRPC service to call.
189195
authentication:
190-
$ref: '#/$defs/authenticationPolicy'
191196
description: The endpoint's authentication policy, if any.
197+
oneOf:
198+
- $ref: '#/$defs/authenticationPolicy'
199+
- type: string
192200
required: [ name, host ]
193201
method:
194202
type: string
@@ -203,16 +211,19 @@ $defs:
203211
- properties:
204212
call:
205213
type: string
206-
constant: http
214+
const: http
207215
with:
208216
type: object
209217
properties:
210218
method:
211219
type: string
212220
description: The HTTP method of the HTTP request to perform.
213221
endpoint:
214-
$ref: '#/$defs/endpoint'
215222
description: The HTTP endpoint to send the request to.
223+
oneOf:
224+
- $ref: '#/$defs/endpoint'
225+
- type: string
226+
format: uri-template
216227
headers:
217228
type: object
218229
description: A name/value mapping of the headers, if any, of the HTTP request to perform.
@@ -228,7 +239,7 @@ $defs:
228239
- properties:
229240
call:
230241
type: string
231-
constant: openapi
242+
const: openapi
232243
with:
233244
type: object
234245
properties:
@@ -243,8 +254,10 @@ $defs:
243254
additionalProperties: true
244255
description: A name/value mapping of the parameters of the OpenAPI operation to call.
245256
authentication:
246-
$ref: '#/$defs/authenticationPolicy'
247257
description: The authentication policy, if any, to use when calling the OpenAPI operation.
258+
oneOf:
259+
- $ref: '#/$defs/authenticationPolicy'
260+
- type: string
248261
output:
249262
type: string
250263
enum: [ raw, content, response ]
@@ -264,33 +277,44 @@ $defs:
264277
description: A name/value mapping of the parameters, if any, to call the function with.
265278
required: [ call ]
266279
compositeTask:
280+
type: object
281+
required: [ execute ]
282+
description: Serves as a pivotal orchestrator within workflow systems, enabling the seamless integration and execution of multiple subtasks to accomplish complex operations
267283
properties:
268284
execute:
269285
type: object
270-
oneOf:
271-
- properties:
272-
concurrently:
273-
type: object
274-
minProperties: 2
275-
additionalProperties:
276-
$ref: '#/$defs/task'
277-
description: A name/definition mapping of the tasks to perform concurrently.
278-
compete:
279-
type: boolean
280-
description: Indicates whether or not the concurrent tasks are racing against each other, with a single possible winner, which sets the composite task's output.
281-
required: [ concurrently ]
282-
- properties:
283-
sequentially:
284-
type: object
285-
minProperties: 2
286-
additionalProperties:
287-
$ref: '#/$defs/task'
288-
description: A name/definition mapping of the tasks to perform sequentially.
289-
required: [ sequentially ]
290286
description: Configures the task execution strategy to use
291-
required: [ execute ]
292-
description: Serves as a pivotal orchestrator within workflow systems, enabling the seamless integration and execution of multiple subtasks to accomplish complex operations
287+
oneOf:
288+
- required: [ concurrently ]
289+
properties:
290+
concurrently:
291+
description: A list of the tasks to perform concurrently.
292+
type: array
293+
minItems: 2
294+
items:
295+
type: object
296+
minProperties: 1
297+
maxProperties: 1
298+
additionalProperties:
299+
$ref: '#/$defs/task'
300+
compete:
301+
description: Indicates whether or not the concurrent tasks are racing against each other, with a single possible winner, which sets the composite task's output.
302+
type: boolean
303+
default: false
304+
- required: [ sequentially ]
305+
properties:
306+
sequentially:
307+
description: A list of the tasks to perform sequentially.
308+
type: array
309+
minItems: 2
310+
items:
311+
type: object
312+
minProperties: 1
313+
maxProperties: 1
314+
additionalProperties:
315+
$ref: '#/$defs/task'
293316
emitTask:
317+
type: object
294318
properties:
295319
emit:
296320
type: object
@@ -332,6 +356,7 @@ $defs:
332356
default: continue
333357
- type: string
334358
forTask:
359+
type: object
335360
properties:
336361
for:
337362
type: object
@@ -487,25 +512,32 @@ $defs:
487512
type: object
488513
properties:
489514
switch:
490-
type: object
491-
minProperties: 1
492-
additionalProperties:
515+
type: array
516+
minItems: 1
517+
items:
493518
type: object
494-
properties:
495-
when:
496-
type: string
497-
description: A runtime expression used to determine whether or not the case matches.
498-
then:
499-
$ref: '#/$defs/flowDirective'
500-
description: The flow directive to execute when the case matches.
519+
minProperties: 1
520+
maxProperties: 1
521+
additionalProperties:
522+
type: object
523+
properties:
524+
name:
525+
type: string
526+
description: The case's name.
527+
when:
528+
type: string
529+
description: A runtime expression used to determine whether or not the case matches.
530+
then:
531+
$ref: '#/$defs/flowDirective'
532+
description: The flow directive to execute when the case matches.
501533
required: [ switch ]
502534
description: Enables conditional branching within workflows, allowing them to dynamically select different paths based on specified conditions or criteria
503535
tryTask:
504536
type: object
505537
properties:
506538
try:
507-
$ref: '#/$defs/task'
508539
description: The task to perform.
540+
$ref: '#/$defs/task'
509541
catch:
510542
type: object
511543
properties:
@@ -524,8 +556,8 @@ $defs:
524556
$ref: '#/$defs/retryPolicy'
525557
description: The retry policy to use, if any, when catching errors.
526558
do:
527-
$ref: '#/$defs/task'
528559
description: The definition of the task to run when catching an error.
560+
$ref: '#/$defs/task'
529561
required: [ try, catch ]
530562
description: Serves as a mechanism within workflows to handle errors gracefully, potentially retrying failed tasks before proceeding with alternate ones.
531563
waitTask:
@@ -665,11 +697,13 @@ $defs:
665697
properties:
666698
uri:
667699
type: string
668-
format: uri
700+
format: uri-template
669701
description: The endpoint's URI.
670702
authentication:
671-
$ref: '#/$defs/authenticationPolicy'
672703
description: The authentication policy to use.
704+
oneOf:
705+
- $ref: '#/$defs/authenticationPolicy'
706+
- type: string
673707
required: [ uri ]
674708
eventConsumptionStrategy:
675709
type: object
@@ -746,11 +780,11 @@ $defs:
746780
type: string
747781
description: A runtime expression, if any, used to determine whether or not the extension should apply in the specified context.
748782
before:
749-
$ref: '#/$defs/task'
750783
description: The task to execute before the extended task, if any.
751-
after:
752784
$ref: '#/$defs/task'
785+
after:
753786
description: The task to execute after the extended task, if any.
787+
$ref: '#/$defs/task'
754788
required: [ extend ]
755789
description: The definition of a an extension.
756790
externalResource:
@@ -761,8 +795,10 @@ $defs:
761795
format: uri
762796
description: The endpoint's URI.
763797
authentication:
764-
$ref: '#/$defs/authenticationPolicy'
765798
description: The authentication policy to use.
799+
oneOf:
800+
- $ref: '#/$defs/authenticationPolicy'
801+
- type: string
766802
name:
767803
type: string
768804
description: The external resource's name, if any.
@@ -783,13 +819,20 @@ $defs:
783819
schema:
784820
$ref: '#/$defs/schema'
785821
description: The schema used to describe and validate the output of the workflow or task.
786-
from:
822+
as:
787823
type: string
788824
description: A runtime expression, if any, used to mutate and/or filter the output of the workflow or task.
789-
to:
790-
type: string
791-
description: A runtime expression, if any, used to output data to the current context.
792825
description: Configures the output of a workflow or task.
826+
export:
827+
type: object
828+
properties:
829+
schema:
830+
$ref: '#/$defs/schema'
831+
description: The schema used to describe and validate the workflow context.
832+
as:
833+
type: string
834+
description: A runtime expression, if any, used to export the output data to the context.
835+
description: Set the content of the context.
793836
retryPolicy:
794837
type: object
795838
properties:

custom-generator/pom.xml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<parent>
4+
<groupId>io.serverlessworkflow</groupId>
5+
<artifactId>serverlessworkflow-parent</artifactId>
6+
<version>7.0.0-SNAPSHOT</version>
7+
</parent>
8+
<artifactId>custom-generator</artifactId>
9+
<dependencies>
10+
<dependency>
11+
<groupId>org.jsonschema2pojo</groupId>
12+
<artifactId>jsonschema2pojo-core</artifactId>
13+
</dependency>
14+
</dependencies>
15+
<build>
16+
<plugins>
17+
<plugin>
18+
<groupId>com.spotify.fmt</groupId>
19+
<artifactId>fmt-maven-plugin</artifactId>
20+
<configuration>
21+
<sourceDirectory>src/main/java</sourceDirectory>
22+
<testSourceDirectory>src/test/java</testSourceDirectory>
23+
<verbose>false</verbose>
24+
<filesNamePattern>.*\.java</filesNamePattern>
25+
<skip>false</skip>
26+
<skipSortingImports>false</skipSortingImports>
27+
<style>google</style>
28+
</configuration>
29+
<executions>
30+
<execution>
31+
<goals>
32+
<goal>format</goal>
33+
</goals>
34+
</execution>
35+
</executions>
36+
</plugin>
37+
</plugins>
38+
</build>
39+
</project>

0 commit comments

Comments
 (0)