{
+
+ /**
+ * Returns a response owned by the caller for every HTTP status; transport failures complete
+ * exceptionally with the underlying transport error
+ *
+ * The response's optional request metadata describes the effective request associated with the
+ * final response, including redirects, when observable by the transport. An empty optional means
+ * it is unavailable; callers must not substitute the initial request as if it were the final one.
+ */
+ CompletableFuture> execute(WorkflowHttpRequestInfo request);
+}
diff --git a/common/http/src/test/java/cloud/openworkflow/sdk/http/HttpRequestInfoTest.java b/common/http/src/test/java/cloud/openworkflow/sdk/http/HttpRequestInfoTest.java
new file mode 100644
index 000000000..1c34db3bc
--- /dev/null
+++ b/common/http/src/test/java/cloud/openworkflow/sdk/http/HttpRequestInfoTest.java
@@ -0,0 +1,193 @@
+/*
+ * Copyright 2020-Present The Open Workflow Specification Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package cloud.openworkflow.sdk.http;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import org.junit.jupiter.api.Test;
+
+class HttpRequestInfoTest {
+
+ private static final URI URI_VALUE = URI.create("http://localhost/items");
+
+ private static WorkflowHttpRequestInfo request(byte[] body) {
+ return WorkflowHttpRequestInfo.builder("POST")
+ .headers(Map.of("X-Request", "value"))
+ .queryParams(Map.of("page", 1))
+ .body(body)
+ .build(URI_VALUE);
+ }
+
+ @Test
+ void methodNormalizationDoesNotDependOnTheDefaultLocale() {
+ var previous = java.util.Locale.getDefault();
+ try {
+ java.util.Locale.setDefault(java.util.Locale.forLanguageTag("tr"));
+ assertThat(
+ WorkflowHttpRequestInfo.builder("options")
+ .build(URI.create("https://example.test"))
+ .method())
+ .isEqualTo("OPTIONS");
+ } finally {
+ java.util.Locale.setDefault(previous);
+ }
+ }
+
+ @Test
+ void commonBuilderPreservesEncodedPathQueryAndFragmentDelimiters() {
+ var request =
+ WorkflowHttpRequestInfo.builder("GET")
+ .path(URI.create("items/a%2Fb?tag=a%26b#x%2Fy"))
+ .build(URI.create("https://example.test/v1"));
+ assertThat(request.uri().toString())
+ .isEqualTo("https://example.test/v1/items/a%2Fb?tag=a%26b#x%2Fy");
+ }
+
+ @Test
+ void sharedHeadersRetainSdkCaseInsensitiveLookupAndConsistentHashing() {
+ var first =
+ WorkflowHttpRequestInfo.builder("GET")
+ .headers(Map.of("Content-Type", "text/plain"))
+ .build(URI.create("https://example.test"));
+ var second =
+ WorkflowHttpRequestInfo.builder("GET")
+ .headers(Map.of("content-type", "text/plain"))
+ .build(first.uri());
+ assertThat(first.headers().get("CONTENT-TYPE")).isEqualTo("text/plain");
+ assertThat(first).isEqualTo(second);
+ assertThat(second).isEqualTo(first);
+ assertThat(first.hashCode()).isEqualTo(second.hashCode());
+ }
+
+ @Test
+ void equalsAndHashCode_shouldCompareBodyContents() {
+ var first = request(new byte[] {1, 2, 3});
+ var second = request(new byte[] {1, 2, 3});
+ var third = request(new byte[] {1, 2, 3});
+ assertThat(first).isEqualTo(first).isEqualTo(second).isEqualTo(third);
+ assertThat(second).isEqualTo(first).isEqualTo(third);
+ assertThat(first.hashCode()).isEqualTo(second.hashCode()).isEqualTo(third.hashCode());
+ assertThat(first).isNotEqualTo(null).isNotEqualTo("not a request");
+ }
+
+ @Test
+ void valueCopy_shouldRemainEqualAndUsableAsAHashKey() {
+ var original = request(new byte[] {1, 2, 3});
+ var copy =
+ WorkflowHttpRequestInfo.builder(original.method())
+ .headers(original.headers())
+ .queryParams(original.queryParams())
+ .body(original.body())
+ .redirect(original.redirect())
+ .timeout(original.timeout())
+ .build(original.uri());
+ assertThat(copy).isEqualTo(original);
+ assertThat(copy.hashCode()).isEqualTo(original.hashCode());
+ Map, String> indexed = new HashMap<>();
+ indexed.put(original, "stored");
+ assertThat(indexed.get(copy)).isEqualTo("stored");
+ }
+
+ @Test
+ void equals_shouldIncludeEveryComponent() {
+ var original = request(new byte[] {1, 2, 3});
+ assertThat(original)
+ .isNotEqualTo(
+ WorkflowHttpRequestInfo.builder(original.method())
+ .headers(original.headers())
+ .queryParams(original.queryParams())
+ .body(original.body())
+ .build(URI.create("http://localhost/other")));
+ assertThat(original)
+ .isNotEqualTo(
+ WorkflowHttpRequestInfo.builder("PUT")
+ .headers(original.headers())
+ .queryParams(original.queryParams())
+ .body(original.body())
+ .build(original.uri()));
+ assertThat(original)
+ .isNotEqualTo(
+ WorkflowHttpRequestInfo.builder(original.method())
+ .headers(Map.of("X-Request", "other"))
+ .queryParams(original.queryParams())
+ .body(original.body())
+ .build(original.uri()));
+ assertThat(original)
+ .isNotEqualTo(
+ WorkflowHttpRequestInfo.builder(original.method())
+ .headers(original.headers())
+ .queryParams(Map.of("page", 2))
+ .body(original.body())
+ .build(original.uri()));
+ assertThat(original).isNotEqualTo(request(new byte[] {1, 2, 4}));
+ }
+
+ @Test
+ void equalsAndHashCode_shouldDistinguishAbsentAndEmptyBodies() {
+ var absent = request(null);
+ var absentCopy = request(null);
+ var empty = request(new byte[0]);
+ var emptyCopy = request(new byte[0]);
+ assertThat(absent).isEqualTo(absentCopy).isNotEqualTo(empty);
+ assertThat(absent.hashCode()).isEqualTo(absentCopy.hashCode());
+ assertThat(empty).isEqualTo(emptyCopy);
+ assertThat(empty.hashCode()).isEqualTo(emptyCopy.hashCode());
+ assertThat(new HashSet<>(Set.of(absent, empty)).contains(emptyCopy)).isTrue();
+ }
+
+ @Test
+ void bodyCopies_shouldKeepHashKeysStable() {
+ byte[] source = {1, 2, 3};
+ var original = request(source);
+ var equivalent = request(new byte[] {1, 2, 3});
+ Set> keys = new HashSet<>(Set.of(original));
+ int hash = original.hashCode();
+ assertThat(original.body()).containsExactly((byte) 1, (byte) 2, (byte) 3);
+ assertThat(original).isEqualTo(equivalent);
+ assertThat(original.hashCode()).isEqualTo(hash).isEqualTo(equivalent.hashCode());
+ assertThat(keys.contains(equivalent)).isTrue();
+ }
+
+ @Test
+ void equalsAndHashCode_shouldIgnoreMapInsertionOrder() {
+ Map forward = new LinkedHashMap<>();
+ forward.put("first", 1);
+ forward.put("second", 2);
+ Map reverse = new LinkedHashMap<>();
+ reverse.put("second", 2);
+ reverse.put("first", 1);
+ var first =
+ WorkflowHttpRequestInfo.builder("POST")
+ .headers(forward)
+ .queryParams(reverse)
+ .body(new byte[] {1})
+ .build(URI_VALUE);
+ var second =
+ WorkflowHttpRequestInfo.builder("POST")
+ .headers(reverse)
+ .queryParams(forward)
+ .body(new byte[] {1})
+ .build(URI_VALUE);
+ assertThat(first).isEqualTo(second);
+ assertThat(first.hashCode()).isEqualTo(second.hashCode());
+ }
+}
diff --git a/common/http/src/test/java/cloud/openworkflow/sdk/http/JdkHttpTransportTest.java b/common/http/src/test/java/cloud/openworkflow/sdk/http/JdkHttpTransportTest.java
new file mode 100644
index 000000000..36f3e273b
--- /dev/null
+++ b/common/http/src/test/java/cloud/openworkflow/sdk/http/JdkHttpTransportTest.java
@@ -0,0 +1,235 @@
+/*
+ * Copyright 2020-Present The Open Workflow Specification Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package cloud.openworkflow.sdk.http;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.io.IOException;
+import java.net.http.HttpClient;
+import java.net.http.HttpClient.Redirect;
+import java.net.http.HttpTimeoutException;
+import java.nio.charset.StandardCharsets;
+import java.time.Duration;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import mockwebserver3.MockResponse;
+import mockwebserver3.MockWebServer;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+class JdkHttpTransportTest {
+
+ private HttpClient client;
+ private MockWebServer server;
+
+ record ConsumerJson(String json) {}
+
+ @BeforeEach
+ void setup() throws IOException {
+ server = new MockWebServer();
+ server.start();
+ client = HttpClient.newBuilder().followRedirects(Redirect.NORMAL).build();
+ }
+
+ @AfterEach
+ void close() {
+ server.close();
+ client.close();
+ }
+
+ @Test
+ void sendsConditionalDateFromTheSharedBuilderExactlyOnce() throws Exception {
+ WorkflowHttpTransport transport =
+ new JdkHttpTransport<>(client, JdkHttpTransport.BYTES);
+ server.enqueue(new MockResponse.Builder().build());
+ var request =
+ WorkflowHttpRequestInfo.builder("GET")
+ .ifModifiedSince(784111777000L)
+ .build(server.url("/").uri());
+ try (var response = transport.execute(request).get(5, java.util.concurrent.TimeUnit.SECONDS)) {
+ var headers =
+ server
+ .takeRequest(5, java.util.concurrent.TimeUnit.SECONDS)
+ .getHeaders()
+ .values("If-Modified-Since");
+ assertThat(headers).isEqualTo(java.util.List.of("Sun, 06 Nov 1994 08:49:37 GMT"));
+ }
+ }
+
+ @Test
+ void dedicatedConditionalDateOverridesTheHeaderMap() throws Exception {
+ WorkflowHttpTransport transport =
+ new JdkHttpTransport<>(client, JdkHttpTransport.BYTES);
+ server.enqueue(new MockResponse.Builder().build());
+ var request =
+ WorkflowHttpRequestInfo.builder("GET")
+ .headers(java.util.Map.of("if-modified-since", "discarded"))
+ .ifModifiedSince(784111777000L)
+ .build(server.url("/").uri());
+ try (var response = transport.execute(request).get(5, java.util.concurrent.TimeUnit.SECONDS)) {
+ var headers =
+ server
+ .takeRequest(5, java.util.concurrent.TimeUnit.SECONDS)
+ .getHeaders()
+ .values("If-Modified-Since");
+ assertThat(headers).isEqualTo(java.util.List.of("Sun, 06 Nov 1994 08:49:37 GMT"));
+ }
+ }
+
+ @Test
+ void execute_shouldExposeTheEffectiveGetAfterASeeOtherRedirect() throws Exception {
+ WorkflowHttpTransport transport =
+ new JdkHttpTransport<>(client, JdkHttpTransport.BYTES);
+ server.enqueue(
+ new MockResponse.Builder()
+ .code(303)
+ .addHeader("Location", "/final?source=redirect")
+ .build());
+ server.enqueue(new MockResponse.Builder().body("final response").build());
+ try (WorkflowHttpResponse response =
+ transport
+ .execute(
+ WorkflowHttpRequestInfo.builder("POST")
+ .headers(Map.of("X-Request", "redirected"))
+ .body("initial body".getBytes(StandardCharsets.UTF_8))
+ .build(server.url("/start?source=initial").uri()))
+ .join()) {
+
+ assertThat(response.status()).isEqualTo(200);
+ var effective = response.request().orElseThrow();
+ assertThat(effective.method()).isEqualTo("GET");
+ assertThat(effective.uri()).isEqualTo(server.url("/final?source=redirect").uri());
+ assertThat(effective.headers().get("x-request")).containsExactly("redirected");
+ var initial = server.takeRequest(5, TimeUnit.SECONDS);
+ assertThat(initial.getMethod()).isEqualTo("POST");
+ assertThat(initial.getBody().utf8()).isEqualTo("initial body");
+ var redirected = server.takeRequest(5, TimeUnit.SECONDS);
+ assertThat(redirected.getMethod()).isEqualTo("GET");
+ assertThat(redirected.getUrl().uri()).isEqualTo(effective.uri());
+ }
+ }
+
+ @Test
+ void execute_shouldDistinguishDirectRequestHeadersFromResponseHeaders() throws Exception {
+ server.start();
+ WorkflowHttpTransport transport =
+ new JdkHttpTransport<>(client, JdkHttpTransport.BYTES);
+ server.enqueue(new MockResponse.Builder().addHeader("X-Response", "received").build());
+ try (var response =
+ transport
+ .execute(
+ WorkflowHttpRequestInfo.builder("GET")
+ .headers(Map.of("X-Request", "sent"))
+ .queryParams(Map.of("search", "tea + coffee"))
+ .build(server.url("/direct?existing=a%2Bb").uri()))
+ .get(5, TimeUnit.SECONDS)) {
+ var effective = response.request().orElseThrow();
+ assertThat(effective.method()).isEqualTo("GET");
+ assertThat(effective.uri())
+ .isEqualTo(server.url("/direct?existing=a%2Bb&search=tea%20%2B%20coffee").uri());
+ assertThat(effective.headers().get("x-request")).containsExactly("sent");
+ assertThat(effective.headers()).doesNotContainKey("X-Response");
+ assertThat(response.getHeader("X-Response")).isEqualTo("received");
+ assertThat(response.headers()).doesNotContainKey("X-Request");
+ assertThat(server.takeRequest(5, TimeUnit.SECONDS).getUrl().uri()).isEqualTo(effective.uri());
+ }
+ }
+
+ // This example compiles and runs in a module with no engine on its classpath.
+ private static CompletableFuture thirdPartyCall(
+ WorkflowHttpTransport transport, java.net.URI uri) {
+ return transport.execute(
+ WorkflowHttpRequestInfo.builder("POST")
+ .headers(
+ Map.of(
+ "Content-Type", "application/json", "Authorization", "Bearer resolved-token"))
+ .queryParams(Map.of("search", "café + tea"))
+ .body("{\"name\":\"café\"}".getBytes(StandardCharsets.UTF_8))
+ .build(uri));
+ }
+
+ @Test
+ void thirdPartyCall_shouldSendResolvedDataAndExposeErrorResponses() throws Exception {
+ server.start();
+ WorkflowHttpTransport transport =
+ new JdkHttpTransport<>(client, JdkHttpTransport.BYTES);
+ server.enqueue(
+ new MockResponse.Builder()
+ .code(422)
+ .addHeader("X-Result", "invalid")
+ .addHeader("X-Result", "second")
+ .body("validation details")
+ .build());
+
+ try (cloud.openworkflow.sdk.http.WorkflowHttpResponse response =
+ thirdPartyCall(transport, server.url("/items?existing=a%2Bb").uri())
+ .get(5, TimeUnit.SECONDS)) {
+
+ assertThat(response.status()).isEqualTo(422);
+ assertThat(response.getHeader("x-result")).isEqualTo("invalid");
+ @SuppressWarnings("unchecked")
+ var resultHeaders = (java.util.List) response.headers().get("X-RESULT");
+ assertThat(resultHeaders).containsExactly("invalid", "second");
+ assertThat(new String(response.body(), StandardCharsets.UTF_8))
+ .isEqualTo("validation details");
+ var recorded = server.takeRequest(5, TimeUnit.SECONDS);
+ assertThat(recorded.getMethod()).isEqualTo("POST");
+ assertThat(recorded.getUrl().encodedQuery())
+ .isEqualTo("existing=a%2Bb&search=caf%C3%A9%20%2B%20tea");
+ assertThat(recorded.getHeaders().get("Authorization")).isEqualTo("Bearer resolved-token");
+ assertThat(recorded.getBody().utf8()).isEqualTo("{\"name\":\"café\"}");
+ }
+ }
+
+ @Test
+ void execute_shouldUseTheJdkRequestTimeout() throws Exception {
+ server.start();
+ WorkflowHttpTransport transport =
+ new JdkHttpTransport<>(client, JdkHttpTransport.BYTES);
+ server.enqueue(
+ new MockResponse.Builder().headersDelay(1, TimeUnit.SECONDS).body("late").build());
+ WorkflowHttpRequestInfo request =
+ WorkflowHttpRequestInfo.builder("GET")
+ .timeout(Duration.ofMillis(100))
+ .build(server.url("/").uri());
+ assertThatThrownBy(() -> transport.execute(request).get(5, TimeUnit.SECONDS))
+ .hasCauseInstanceOf(HttpTimeoutException.class);
+ }
+
+ @Test
+ void execute_shouldPreserveConfiguredRedirectBehavior() throws Exception {
+ server.start();
+ WorkflowHttpTransport normal = new JdkHttpTransport<>(client, JdkHttpTransport.BYTES);
+ HttpClient noRedirectClient =
+ HttpClient.newBuilder().followRedirects(HttpClient.Redirect.NEVER).build();
+ WorkflowHttpRequestInfo request =
+ WorkflowHttpRequestInfo.builder("GET").build(server.url("/start").uri());
+ server.enqueue(new MockResponse.Builder().code(302).addHeader("Location", "/end").build());
+ server.enqueue(new MockResponse.Builder().body("redirected").build());
+ try (var response = normal.execute(request).get(5, TimeUnit.SECONDS)) {
+ assertThat(new String(response.body(), StandardCharsets.UTF_8)).isEqualTo("redirected");
+ }
+ server.enqueue(new MockResponse.Builder().code(302).addHeader("Location", "/end").build());
+ WorkflowHttpTransport noRedirect =
+ new JdkHttpTransport<>(noRedirectClient, JdkHttpTransport.BYTES);
+ try (var response = noRedirect.execute(request).get(5, TimeUnit.SECONDS)) {
+ assertThat(response.status()).isEqualTo(302);
+ }
+ }
+}
diff --git a/impl/core/src/test/java/cloud/openworkflow/sdk/impl/http/DefaultURITemplateResolverTest.java b/common/http/src/test/java/cloud/openworkflow/sdk/http/JdkURITemplateResolverTest.java
similarity index 85%
rename from impl/core/src/test/java/cloud/openworkflow/sdk/impl/http/DefaultURITemplateResolverTest.java
rename to common/http/src/test/java/cloud/openworkflow/sdk/http/JdkURITemplateResolverTest.java
index 9ace2c3e9..75f569da1 100644
--- a/impl/core/src/test/java/cloud/openworkflow/sdk/impl/http/DefaultURITemplateResolverTest.java
+++ b/common/http/src/test/java/cloud/openworkflow/sdk/http/JdkURITemplateResolverTest.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package cloud.openworkflow.sdk.impl.http;
+package cloud.openworkflow.sdk.http;
import static org.assertj.core.api.Assertions.assertThat;
@@ -21,11 +21,11 @@
import java.util.Map;
import org.junit.jupiter.api.Test;
-public class DefaultURITemplateResolverTest {
+public class JdkURITemplateResolverTest {
@Test
public void testResolve() {
- URITemplateResolver resolver = new DefaultURITemplateResolver();
+ URITemplateResolver resolver = new JdkURITemplateResolver();
assertThat(
resolver.resolveTemplates(
"https://api.example.com/users/{userId}/posts/{post-Id}",
@@ -35,7 +35,7 @@ public void testResolve() {
@Test
public void testResolveOptional() {
- URITemplateResolver resolver = new DefaultURITemplateResolver();
+ URITemplateResolver resolver = new JdkURITemplateResolver();
assertThat(
resolver.resolveTemplates(
"https://api.example.com/pets{?limit,offset}", Map.of("limit", "10")))
diff --git a/impl/core/src/test/java/cloud/openworkflow/sdk/impl/WorkflowUtilsTest.java b/common/http/src/test/java/cloud/openworkflow/sdk/http/URIHelperTest.java
similarity index 83%
rename from impl/core/src/test/java/cloud/openworkflow/sdk/impl/WorkflowUtilsTest.java
rename to common/http/src/test/java/cloud/openworkflow/sdk/http/URIHelperTest.java
index 2704d6ba8..edaa4c204 100644
--- a/impl/core/src/test/java/cloud/openworkflow/sdk/impl/WorkflowUtilsTest.java
+++ b/common/http/src/test/java/cloud/openworkflow/sdk/http/URIHelperTest.java
@@ -13,20 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package cloud.openworkflow.sdk.impl;
+package cloud.openworkflow.sdk.http;
import static org.assertj.core.api.Assertions.assertThat;
import java.net.URI;
import org.junit.jupiter.api.Test;
-public class WorkflowUtilsTest {
+public class URIHelperTest {
@Test
void openApiServerWithTrailingSlashAndRootPath() {
URI base = URI.create("https://petstore3.swagger.io/api/v3/");
URI path = URI.create("/pet/findByStatus");
- URI result = WorkflowUtils.concatURI(base, path.toString());
+ URI result = URIHelper.concatURI(base, path.toString());
assertThat(result.toString()).isEqualTo("https://petstore3.swagger.io/api/v3/pet/findByStatus");
}
@@ -36,7 +36,7 @@ void openApiServerWithoutTrailingSlashAndRootPath() {
URI base = URI.create("https://petstore3.swagger.io/api/v3");
URI path = URI.create("/pet/findByStatus");
- URI result = WorkflowUtils.concatURI(base, path.toString());
+ URI result = URIHelper.concatURI(base, path.toString());
assertThat(result.toString()).isEqualTo("https://petstore3.swagger.io/api/v3/pet/findByStatus");
}
@@ -46,7 +46,7 @@ void baseWithSlashAndRelativePath() {
URI base = URI.create("https://example.com/api/v1/");
URI path = URI.create("pets");
- URI result = WorkflowUtils.concatURI(base, path.toString());
+ URI result = URIHelper.concatURI(base, path.toString());
assertThat(result.toString()).isEqualTo("https://example.com/api/v1/pets");
}
@@ -56,7 +56,7 @@ void baseWithoutPathAndRootPath() {
URI base = URI.create("https://example.com");
URI path = URI.create("/pets");
- URI result = WorkflowUtils.concatURI(base, path.toString());
+ URI result = URIHelper.concatURI(base, path.toString());
assertThat(result.toString()).isEqualTo("https://example.com/pets");
}
@@ -66,7 +66,7 @@ void absolutePathOverridesBase() {
URI base = URI.create("https://example.com/api");
URI path = URI.create("https://other.example.com/foo");
- URI result = WorkflowUtils.concatURI(base, path.toString());
+ URI result = URIHelper.concatURI(base, path.toString());
assertThat(result.toString()).isEqualTo("https://other.example.com/foo");
}
@@ -76,7 +76,7 @@ void queryAndFragmentAreTakenFromPath() {
URI base = URI.create("https://example.com/api/v1");
URI path = URI.create("/pets?status=available#top");
- URI result = WorkflowUtils.concatURI(base, path.toString());
+ URI result = URIHelper.concatURI(base, path.toString());
assertThat(result.toString()).isEqualTo("https://example.com/api/v1/pets?status=available#top");
}
diff --git a/common/openapi-jackson/README.md b/common/openapi-jackson/README.md
new file mode 100644
index 000000000..672129b12
--- /dev/null
+++ b/common/openapi-jackson/README.md
@@ -0,0 +1,35 @@
+# OpenAPI Jackson Reader
+
+## Introduction
+
+This module provides a Jackson-based implementation for reading OpenAPI specifications that other workflow engine implementations can reuse. It enables parsing of OpenAPI documents in JSON or YAML format using Jackson's serialization capabilities.
+
+## Dependency
+
+```xml
+
+ cloud.openworkflow.sdk
+ openworkflow-common-openapi-jackson
+ 8.0.0-SNAPSHOT
+
+```
+
+## Usage Example
+
+```java
+import cloud.openworkflow.sdk.openapi.UnifiedOpenAPI;
+import cloud.openworkflow.sdk.openapi.jackson.JacksonUnifiedOpenAPIReader;
+
+// Read OpenAPI document from bytes
+byte[] documentBytes = Files.readAllBytes(Path.of("api.yaml"));
+
+// Create reader and parse document
+JacksonUnifiedOpenAPIReader reader = new JacksonUnifiedOpenAPIReader();
+UnifiedOpenAPI document = reader.read("api.yaml", documentBytes);
+
+// Use the parsed document
+System.out.println("OpenAPI version: " + document.openapi());
+System.out.println("Servers: " + document.servers());
+```
+
+The reader automatically detects the format (JSON or YAML) based on the file extension and uses the appropriate Jackson mapper for parsing.
diff --git a/common/openapi-jackson/pom.xml b/common/openapi-jackson/pom.xml
new file mode 100644
index 000000000..5846d2fb1
--- /dev/null
+++ b/common/openapi-jackson/pom.xml
@@ -0,0 +1,19 @@
+
+ 4.0.0
+
+ cloud.openworkflow.sdk
+ openworkflow-common
+ 8.0.0-SNAPSHOT
+
+ openworkflow-common-openapi-jackson
+
+
+ cloud.openworkflow.sdk
+ openworkflow-common-openapi
+
+
+ cloud.openworkflow.sdk
+ openworkflow-api
+
+
+
\ No newline at end of file
diff --git a/impl/openapi-jackson/src/main/java/cloud/openworkflow/sdk/impl/executors/openapi/jackson/JacksonUnifiedOpenAPIMixIn.java b/common/openapi-jackson/src/main/java/cloud/openworkflow/sdk/openapi/jackson/JacksonUnifiedOpenAPIMixIn.java
similarity index 96%
rename from impl/openapi-jackson/src/main/java/cloud/openworkflow/sdk/impl/executors/openapi/jackson/JacksonUnifiedOpenAPIMixIn.java
rename to common/openapi-jackson/src/main/java/cloud/openworkflow/sdk/openapi/jackson/JacksonUnifiedOpenAPIMixIn.java
index f60745a27..6c956fa77 100644
--- a/impl/openapi-jackson/src/main/java/cloud/openworkflow/sdk/impl/executors/openapi/jackson/JacksonUnifiedOpenAPIMixIn.java
+++ b/common/openapi-jackson/src/main/java/cloud/openworkflow/sdk/openapi/jackson/JacksonUnifiedOpenAPIMixIn.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package cloud.openworkflow.sdk.impl.executors.openapi.jackson;
+package cloud.openworkflow.sdk.openapi.jackson;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/impl/openapi-jackson/src/main/java/cloud/openworkflow/sdk/impl/executors/openapi/jackson/JacksonUnifiedOpenAPIMixInModule.java b/common/openapi-jackson/src/main/java/cloud/openworkflow/sdk/openapi/jackson/JacksonUnifiedOpenAPIMixInModule.java
similarity index 93%
rename from impl/openapi-jackson/src/main/java/cloud/openworkflow/sdk/impl/executors/openapi/jackson/JacksonUnifiedOpenAPIMixInModule.java
rename to common/openapi-jackson/src/main/java/cloud/openworkflow/sdk/openapi/jackson/JacksonUnifiedOpenAPIMixInModule.java
index 84feae534..f7a14cbb0 100644
--- a/impl/openapi-jackson/src/main/java/cloud/openworkflow/sdk/impl/executors/openapi/jackson/JacksonUnifiedOpenAPIMixInModule.java
+++ b/common/openapi-jackson/src/main/java/cloud/openworkflow/sdk/openapi/jackson/JacksonUnifiedOpenAPIMixInModule.java
@@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package cloud.openworkflow.sdk.impl.executors.openapi.jackson;
+package cloud.openworkflow.sdk.openapi.jackson;
-import cloud.openworkflow.sdk.impl.executors.openapi.UnifiedOpenAPI;
+import cloud.openworkflow.sdk.openapi.UnifiedOpenAPI;
import tools.jackson.databind.module.SimpleModule;
public class JacksonUnifiedOpenAPIMixInModule extends SimpleModule {
diff --git a/impl/openapi-jackson/src/main/java/cloud/openworkflow/sdk/impl/executors/openapi/jackson/JacksonUnifiedOpenAPIReader.java b/common/openapi-jackson/src/main/java/cloud/openworkflow/sdk/openapi/jackson/JacksonUnifiedOpenAPIReader.java
similarity index 81%
rename from impl/openapi-jackson/src/main/java/cloud/openworkflow/sdk/impl/executors/openapi/jackson/JacksonUnifiedOpenAPIReader.java
rename to common/openapi-jackson/src/main/java/cloud/openworkflow/sdk/openapi/jackson/JacksonUnifiedOpenAPIReader.java
index 9cd0fa181..78c6b4709 100644
--- a/impl/openapi-jackson/src/main/java/cloud/openworkflow/sdk/impl/executors/openapi/jackson/JacksonUnifiedOpenAPIReader.java
+++ b/common/openapi-jackson/src/main/java/cloud/openworkflow/sdk/openapi/jackson/JacksonUnifiedOpenAPIReader.java
@@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package cloud.openworkflow.sdk.impl.executors.openapi.jackson;
+package cloud.openworkflow.sdk.openapi.jackson;
import cloud.openworkflow.sdk.api.WorkflowFormat;
-import cloud.openworkflow.sdk.impl.executors.openapi.UnifiedOpenAPI;
-import cloud.openworkflow.sdk.impl.executors.openapi.UnifiedOpenAPIReader;
+import cloud.openworkflow.sdk.openapi.UnifiedOpenAPI;
+import cloud.openworkflow.sdk.openapi.UnifiedOpenAPIReader;
public class JacksonUnifiedOpenAPIReader implements UnifiedOpenAPIReader {
@Override
diff --git a/common/openapi-jackson/src/main/resources/META-INF/services/tools.jackson.databind.JacksonModule b/common/openapi-jackson/src/main/resources/META-INF/services/tools.jackson.databind.JacksonModule
new file mode 100644
index 000000000..bdaa3d2ad
--- /dev/null
+++ b/common/openapi-jackson/src/main/resources/META-INF/services/tools.jackson.databind.JacksonModule
@@ -0,0 +1 @@
+cloud.openworkflow.sdk.openapi.jackson.JacksonUnifiedOpenAPIMixInModule
\ No newline at end of file
diff --git a/common/openapi/README.md b/common/openapi/README.md
new file mode 100644
index 000000000..e91ab3d1e
--- /dev/null
+++ b/common/openapi/README.md
@@ -0,0 +1,62 @@
+# OpenAPI Client
+
+## Introduction
+
+This module provides a reusable OpenAPI client library that other workflow engine implementations can leverage for making HTTP calls based on OpenAPI specifications, without requiring the full workflow engine.
+
+## Dependency
+
+```xml
+
+ cloud.openworkflow.sdk
+ openworkflow-common-openapi
+ 8.0.0-SNAPSHOT
+
+```
+
+For JSON/YAML parsing with Jackson:
+
+```xml
+
+ cloud.openworkflow.sdk
+ openworkflow-common-openapi-jackson
+ 8.0.0-SNAPSHOT
+
+```
+
+## Usage Example
+
+```java
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.util.Map;
+import cloud.openworkflow.sdk.api.WorkflowFormat;
+import cloud.openworkflow.sdk.http.*;
+import cloud.openworkflow.sdk.openapi.*;
+import cloud.openworkflow.sdk.openapi.jackson.JacksonUnifiedOpenAPIReader;
+
+// Read OpenAPI document
+UnifiedOpenAPI document = new JacksonUnifiedOpenAPIReader()
+ .read("api.yaml", documentBytes);
+
+// Create client for specific operation
+OpenAPIClient client = new OpenAPIClient(document, "operationId");
+
+// Create transport (reusable for multiple requests)
+JdkHttpTransport transport =
+ new JdkHttpTransport<>(HttpClient.newHttpClient(), JdkHttpTransport.BYTES);
+
+// Prepare and execute request
+Map parameters = Map.of("name", "John");
+WorkflowHttpRequestInfo request =
+ client.createRequest(parameters).build(URI.create("http://api.example.com"));
+
+CompletableFuture> responseFuture =
+ transport.execute(request);
+
+try (WorkflowHttpResponse response = responseFuture.get()) {
+ // Process response...
+}
+```
+
+**Important**: `WorkflowHttpTransport` does not implement `AutoCloseable` and can be reused. The underlying `HttpClient` should be managed by the application. `WorkflowHttpResponse` implements `AutoCloseable` and must be closed using try-with-resources.
\ No newline at end of file
diff --git a/common/openapi/pom.xml b/common/openapi/pom.xml
new file mode 100644
index 000000000..b3de20c32
--- /dev/null
+++ b/common/openapi/pom.xml
@@ -0,0 +1,31 @@
+
+ 4.0.0
+
+ cloud.openworkflow.sdk
+ openworkflow-common
+ 8.0.0-SNAPSHOT
+
+ openworkflow-common-openapi
+ Open Workflow :: Common:: OpenAPI
+
+
+ cloud.openworkflow.sdk
+ openworkflow-common-http
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.assertj
+ assertj-core
+ test
+
+
+ com.squareup.okhttp3
+ mockwebserver
+ test
+
+
+
diff --git a/common/openapi/src/main/java/cloud/openworkflow/sdk/openapi/OpenAPIClient.java b/common/openapi/src/main/java/cloud/openworkflow/sdk/openapi/OpenAPIClient.java
new file mode 100644
index 000000000..abe15761f
--- /dev/null
+++ b/common/openapi/src/main/java/cloud/openworkflow/sdk/openapi/OpenAPIClient.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright 2020-Present The Open Workflow Specification Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package cloud.openworkflow.sdk.openapi;
+
+import cloud.openworkflow.sdk.http.JdkURITemplateResolver;
+import cloud.openworkflow.sdk.http.URITemplateResolver;
+import cloud.openworkflow.sdk.http.WorkflowHttpRequestInfo;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.function.Function;
+
+/** OpenAPI request preparation and asynchronous execution using caller-owned HTTP resources. */
+public class OpenAPIClient {
+
+ private final OperationDefinition operation;
+
+ private final Function