diff --git a/api/src/main/resources/schema/workflow.yaml b/api/src/main/resources/schema/workflow.yaml index aecbeacb..daaedc41 100644 --- a/api/src/main/resources/schema/workflow.yaml +++ b/api/src/main/resources/schema/workflow.yaml @@ -241,33 +241,42 @@ $defs: properties: document: $ref: '#/$defs/externalResource' - title: WithAsyncAPIDocument + title: AsyncAPIDocument description: The document that defines the AsyncAPI operation to call. - operationRef: + channel: type: string - title: WithAsyncAPIOperation + title: With + description: The name of the channel on which to perform the operation. Used only in case the referenced document uses AsyncAPI v2.6.0. + operation: + type: string + title: AsyncAPIOperation description: A reference to the AsyncAPI operation to call. server: + $ref: '#/$defs/asyncApiServer' + title: AsyncAPIServer + description: An object used to configure to the server to call the specified AsyncAPI operation on. + protocol: type: string - title: WithAsyncAPIServer - description: A a reference to the server to call the specified AsyncAPI operation on. If not set, default to the first server matching the operation's channel. + title: AsyncApiProtocol + description: The protocol to use to select the target server. + enum: [ amqp, amqp1, anypointmq, googlepubsub, http, ibmmq, jms, kafka, mercure, mqtt, mqtt5, nats, pulsar, redis, sns, solace, sqs, stomp, ws ] message: - type: string - title: WithAsyncAPIMessage - description: The name of the message to use. If not set, defaults to the first message defined by the operation. - binding: - type: string - title: WithAsyncAPIBinding - description: The name of the binding to use. If not set, defaults to the first binding defined by the operation. - payload: - type: object - title: WithAsyncAPIPayload - description: The payload to call the AsyncAPI operation with, if any. + $ref: '#/$defs/asyncApiOutboundMessage' + title: AsyncApiMessage + description: An object used to configure the message to publish using the target operation. + subscription: + $ref: '#/$defs/asyncApiSubscription' + title: AsyncApiSubscription + description: An object used to configure the subscription to messages consumed using the target operation. authentication: $ref: '#/$defs/referenceableAuthenticationPolicy' - title: WithAsyncAPIAuthentication + title: AsyncAPIAuthentication description: The authentication policy, if any, to use when calling the AsyncAPI operation. - required: [ document, operationRef ] + oneOf: + - required: [ document, operation, message ] + - required: [ document, operation, subscription ] + - required: [ document, channel, message ] + - required: [ document, channel, subscription ] unevaluatedProperties: false - title: CallGRPC description: Defines the GRPC call to perform. @@ -341,29 +350,33 @@ $defs: properties: method: type: string - title: WithHTTPMethod + title: HTTPMethod description: The HTTP method of the HTTP request to perform. endpoint: - title: WithHTTPEndpoint + title: HTTPEndpoint description: The HTTP endpoint to send the request to. $ref: '#/$defs/endpoint' headers: type: object - title: WithHTTPHeaders + title: HTTPHeaders description: A name/value mapping of the headers, if any, of the HTTP request to perform. body: - title: WithHTTPBody + title: HTTPBody description: The body, if any, of the HTTP request to perform. query: type: object - title: WithHTTPQuery + title: HTTPQuery description: A name/value mapping of the query parameters, if any, of the HTTP request to perform. additionalProperties: true output: type: string - title: WithHTTPOutput + title: HTTPOutput description: The http call output format. Defaults to 'content'. enum: [ raw, content, response ] + redirect: + type: boolean + title: HttpRedirect + description: Specifies whether redirection status codes (`300–399`) should be treated as errors. required: [ method, endpoint ] unevaluatedProperties: false - title: CallOpenAPI @@ -403,6 +416,10 @@ $defs: enum: [ raw, content, response ] title: WithOpenAPIOutput description: The http call output format. Defaults to 'content'. + redirect: + type: boolean + title: HttpRedirect + description: Specifies whether redirection status codes (`300–399`) should be treated as errors. required: [ document, operationId ] unevaluatedProperties: false - title: CallFunction @@ -482,6 +499,10 @@ $defs: description: Defines the properties of event to emit. required: [ source, type ] additionalProperties: true + cc: + $ref: '#/$defs/endpoint' + title: EmitCarbonCopyDefinition + description: Defines an additional endpoint, if any, to publish an event's carbon copy to. required: [ event ] forTask: type: object @@ -581,6 +602,12 @@ $defs: default: true title: AwaitProcessCompletion description: Whether to await the process completion before continuing. + return: + type: string + title: ProcessReturnType + description: Configures the output of the process. + enum: [ stdout, stderr, code, all, none ] + default: stdout oneOf: - title: RunContainer description: Enables the execution of external processes encapsulated within a containerized environment. @@ -595,6 +622,10 @@ $defs: type: string title: ContainerImage description: The name of the container image to run. + name: + type: string + title: ContainerName + description: A runtime expression, if any, used to give specific name to the container. command: type: string title: ContainerCommand @@ -611,6 +642,10 @@ $defs: type: object title: ContainerEnvironment description: A key/value mapping of the environment variables, if any, to use when running the configured process. + lifetime: + $ref: '#/$defs/containerLifetime' + title: ContainerLifetime + description: An object, if any, used to configure the container's lifetime required: [ image ] required: [ container ] - title: RunScript @@ -1257,6 +1292,12 @@ $defs: - title: ExpressionDataSchema $ref: '#/$defs/runtimeExpression' description: An expression based event data schema. + data: + title: EventData + description: The event's payload data + anyOf: + - $ref: '#/$defs/runtimeExpression' + - {} additionalProperties: true eventConsumptionStrategy: type: object @@ -1274,14 +1315,47 @@ $defs: $ref: '#/$defs/eventFilter' required: [ all ] - title: AnyEventConsumptionStrategy - properties: - any: - type: array - title: AnyEventConsumptionStrategyConfiguration - description: A list containing any of the events to consume. - items: - $ref: '#/$defs/eventFilter' - required: [ any ] + oneOf: + - properties: + any: + type: array + title: AnyEventConsumptionStrategyConfiguration + description: A list containing any of the events to consume. + items: + $ref: '#/$defs/eventFilter' + minItems: 1 + until: + oneOf: + - type: string + title: AnyEventUntilCondition + description: A runtime expression condition evaluated after consuming an event and which determines whether or not to continue listening. + - allOf: + - $ref: '#/$defs/eventConsumptionStrategy' + title: AnyEventUntilConsumed + description: The strategy that defines the event(s) to consume to stop listening. + - properties: + until: false + required: [ any ] + - properties: + any: + type: array + title: AnyEventConsumptionStrategyConfiguration + description: A list containing any of the events to consume. + items: + $ref: '#/$defs/eventFilter' + maxItems: 0 + until: + oneOf: + - type: string + title: AnyEventUntilCondition + description: A runtime expression condition evaluated after consuming an event and which determines whether or not to continue listening. + - allOf: + - $ref: '#/$defs/eventConsumptionStrategy' + title: AnyEventUntilConsumed + description: The strategy that defines the event(s) to consume to stop listening. + - properties: + until: false + required: [ any, until ] - title: OneEventConsumptionStrategy properties: one: @@ -1522,16 +1596,147 @@ $defs: catalog: type: object title: Catalog - description: The definition of a resource catalog + description: The definition of a resource catalog. unevaluatedProperties: false properties: endpoint: $ref: '#/$defs/endpoint' title: CatalogEndpoint - description: The root URL where the catalog is hosted + description: The root URL where the catalog is hosted. required: [ endpoint ] runtimeExpression: type: string title: RuntimeExpression description: A runtime expression. pattern: "^\\s*\\$\\{.+\\}\\s*$" + containerLifetime: + type: object + title: ContainerLifetime + description: The configuration of a container's lifetime + unevaluatedProperties: false + properties: + cleanup: + type: string + title: ContainerCleanupPolicy + description: The container cleanup policy to use + enum: [ always, never, eventually ] + default: never + after: + $ref: '#/$defs/duration' + title: ContainerLifetimeDuration + description: The duration after which to cleanup the container, in case the cleanup policy has been set to 'eventually' + required: [ cleanup ] + if: + properties: + cleanup: + const: eventually + then: + required: [ after ] + else: + not: + required: [ after ] + processResult: + type: object + title: ProcessResult + description: The object returned by a run task when its return type has been set 'all'. + unevaluatedProperties: false + properties: + code: + type: integer + title: ProcessExitCode + description: The process's exit code. + stdout: + type: string + title: ProcessStandardOutput + description: The content of the process's STDOUT. + stderr: + type: string + title: ProcessStandardError + description: The content of the process's STDERR. + required: [ code, stdout, stderr ] + asyncApiServer: + type: object + title: AsyncApiServer + description: Configures the target server of an AsyncAPI operation. + unevaluatedProperties: false + properties: + name: + type: string + title: AsyncApiServerName + description: The target server's name. + variables: + type: object + title: AsyncApiServerVariables + description: The target server's variables, if any. + required: [ name ] + asyncApiOutboundMessage: + type: object + title: AsyncApiOutboundMessage + description: An object used to configure the message to publish using the target operation. + unevaluatedProperties: false + properties: + payload: + type: object + title: AsyncApiMessagePayload + description: The message's payload, if any. + additionalProperties: true + headers: + type: object + title: AsyncApiMessageHeaders + description: The message's headers, if any. + additionalProperties: true + asyncApiInboundMessage: + type: object + title: AsyncApiInboundMessage + description: Represents a message counsumed by an AsyncAPI subscription. + allOf: + - $ref: '#/$defs/asyncApiOutboundMessage' + properties: + correlationId: + type: string + title: AsyncApiMessageCorrelationId + description: The message's correlation id, if any. + asyncApiSubscription: + type: object + title: AsyncApiSubscription + description: An object used to configure the subscription to messages consumed using the target operation. + unevaluatedProperties: false + properties: + filter: + $ref: '#/$defs/runtimeExpression' + title: AsyncApiSubscriptionCorrelation + description: A runtime expression, if any, used to filter consumed messages. + consume: + $ref: '#/$defs/asyncApiMessageConsumptionPolicy' + title: AsyncApiMessageConsumptionPolicy + description: An object used to configure the subscription's message consumption policy. + required: [ consume ] + asyncApiMessageConsumptionPolicy: + type: object + title: AsyncApiMessageConsumptionPolicy + description: An object used to configure a subscription's message consumption policy. + unevaluatedProperties: false + properties: + for: + $ref: '#/$defs/duration' + title: AsyncApiMessageConsumptionPolicyFor + description: Specifies the time period over which messages will be consumed. + oneOf: + - properties: + amount: + type: integer + title: AsyncApiMessageConsumptionPolicyAmount + description: The amount of (filtered) messages to consume before disposing of the subscription. + required: [ amount ] + - properties: + while: + $ref: '#/$defs/runtimeExpression' + title: AsyncApiMessageConsumptionPolicyWhile + description: A runtime expression evaluated after each consumed (filtered) message to decide if message consumption should continue. + required: [ while ] + - properties: + until: + $ref: '#/$defs/runtimeExpression' + title: AsyncApiMessageConsumptionPolicyUntil + description: A runtime expression evaluated before each consumed (filtered) message to decide if message consumption should continue. + required: [ until ] diff --git a/custom-generator/src/main/java/io/serverlessworkflow/generator/AllAnyOneOfSchemaRule.java b/custom-generator/src/main/java/io/serverlessworkflow/generator/AllAnyOneOfSchemaRule.java index d14ba357..2fa343a0 100644 --- a/custom-generator/src/main/java/io/serverlessworkflow/generator/AllAnyOneOfSchemaRule.java +++ b/custom-generator/src/main/java/io/serverlessworkflow/generator/AllAnyOneOfSchemaRule.java @@ -468,25 +468,32 @@ private void unionType( Schema parentSchema, Collection types) { if (schemaNode.has(prefix)) { + ArrayNode array = (ArrayNode) schemaNode.get(prefix); int i = 0; - for (JsonNode oneOf : (ArrayNode) schemaNode.get(prefix)) { - String ref = parentSchema.getId().toString() + '/' + prefix + '/' + i++; - Schema schema = - ruleFactory - .getSchemaStore() - .create( - URI.create(ref), - ruleFactory.getGenerationConfig().getRefFragmentPathDelimiters()); - types.add( - new JTypeWrapper( - schema.isGenerated() - ? schema.getJavaType() - : apply(nodeName, oneOf, parent, generatableType.getPackage(), schema), - oneOf)); + for (JsonNode oneOf : array) { + if (!ignoreNode(oneOf)) { + String ref = parentSchema.getId().toString() + '/' + prefix + '/' + i++; + Schema schema = + ruleFactory + .getSchemaStore() + .create( + URI.create(ref), + ruleFactory.getGenerationConfig().getRefFragmentPathDelimiters()); + types.add( + new JTypeWrapper( + schema.isGenerated() + ? schema.getJavaType() + : apply(nodeName, oneOf, parent, generatableType.getPackage(), schema), + oneOf)); + } } } } + private static boolean ignoreNode(JsonNode node) { + return node.size() == 1 && node.has("required"); + } + private Optional refType( String nodeName, JsonNode schemaNode,