From 8f26ee53d24819972943490215990c79d929b2fd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 22 Jul 2025 03:55:17 +0000 Subject: [PATCH 1/3] feat(client): allow configuring env via system properties --- README.md | 27 ++++++++++++------- .../org/onebusaway/core/ClientOptions.kt | 8 ++++-- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 7dd6a3a..d685d21 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,8 @@ import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams; import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse; -// Configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables +// Configures using the `onebusawaysdk.onebusawayApiKey` and `onebusawaysdk.baseUrl` system properties +// Or configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.fromEnv(); CurrentTimeRetrieveResponse currentTime = client.currentTime().retrieve(); @@ -61,13 +62,14 @@ CurrentTimeRetrieveResponse currentTime = client.currentTime().retrieve(); ## Client configuration -Configure the client using environment variables: +Configure the client using system properties or environment variables: ```java import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; -// Configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables +// Configures using the `onebusawaysdk.onebusawayApiKey` and `onebusawaysdk.baseUrl` system properties +// Or configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.fromEnv(); ``` @@ -89,7 +91,8 @@ import org.onebusaway.client.OnebusawaySdkClient; import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() - // Configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables + // Configures using the `onebusawaysdk.onebusawayApiKey` and `onebusawaysdk.baseUrl` system properties + Or configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables .fromEnv() .apiKey("My API Key") .build(); @@ -97,10 +100,12 @@ OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.builder() See this table for the available options: -| Setter | Environment variable | Required | Default value | -| --------- | ------------------------- | -------- | ----------------------------------------- | -| `apiKey` | `ONEBUSAWAY_API_KEY` | true | - | -| `baseUrl` | `ONEBUSAWAY_SDK_BASE_URL` | true | `"https://api.pugetsound.onebusaway.org"` | +| Setter | System property | Environment variable | Required | Default value | +| --------- | -------------------------------- | ------------------------- | -------- | ----------------------------------------- | +| `apiKey` | `onebusawaysdk.onebusawayApiKey` | `ONEBUSAWAY_API_KEY` | true | - | +| `baseUrl` | `onebusawaysdk.baseUrl` | `ONEBUSAWAY_SDK_BASE_URL` | true | `"https://api.pugetsound.onebusaway.org"` | + +System properties take precedence over environment variables. > [!TIP] > Don't create more than one client in the same application. Each client has a connection pool and @@ -146,7 +151,8 @@ import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient; import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams; import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse; -// Configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables +// Configures using the `onebusawaysdk.onebusawayApiKey` and `onebusawaysdk.baseUrl` system properties +// Or configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables OnebusawaySdkClient client = OnebusawaySdkOkHttpClient.fromEnv(); CompletableFuture currentTime = client.async().currentTime().retrieve(); @@ -161,7 +167,8 @@ import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClientAsync; import org.onebusaway.models.currenttime.CurrentTimeRetrieveParams; import org.onebusaway.models.currenttime.CurrentTimeRetrieveResponse; -// Configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables +// Configures using the `onebusawaysdk.onebusawayApiKey` and `onebusawaysdk.baseUrl` system properties +// Or configures using the `ONEBUSAWAY_API_KEY` and `ONEBUSAWAY_SDK_BASE_URL` environment variables OnebusawaySdkClientAsync client = OnebusawaySdkOkHttpClientAsync.fromEnv(); CompletableFuture currentTime = client.currentTime().retrieve(); diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt index 2396b90..27a9167 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/ClientOptions.kt @@ -220,8 +220,12 @@ private constructor( fun timeout(): Timeout = timeout fun fromEnv() = apply { - System.getenv("ONEBUSAWAY_SDK_BASE_URL")?.let { baseUrl(it) } - System.getenv("ONEBUSAWAY_API_KEY")?.let { apiKey(it) } + (System.getProperty("onebusawaysdk.baseUrl") + ?: System.getenv("ONEBUSAWAY_SDK_BASE_URL")) + ?.let { baseUrl(it) } + (System.getProperty("onebusawaysdk.onebusawayApiKey") + ?: System.getenv("ONEBUSAWAY_API_KEY")) + ?.let { apiKey(it) } } /** From 6994f026a6c7abb90a0bfec9ebb213f51dcf9347 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 22 Jul 2025 06:29:16 +0000 Subject: [PATCH 2/3] feat(client): add `{QueryParams,Headers}#put(String, JsonValue)` methods --- .../org/onebusaway/core/http/Headers.kt | 41 +++++++++++++++---- .../org/onebusaway/core/http/QueryParams.kt | 21 ++++++++++ 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/Headers.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/Headers.kt index c3820c3..13da56f 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/Headers.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/Headers.kt @@ -1,6 +1,16 @@ +// File generated from our OpenAPI spec by Stainless. + package org.onebusaway.core.http import java.util.TreeMap +import org.onebusaway.core.JsonArray +import org.onebusaway.core.JsonBoolean +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonNull +import org.onebusaway.core.JsonNumber +import org.onebusaway.core.JsonObject +import org.onebusaway.core.JsonString +import org.onebusaway.core.JsonValue import org.onebusaway.core.toImmutable class Headers @@ -28,6 +38,19 @@ private constructor( TreeMap(String.CASE_INSENSITIVE_ORDER) private var size: Int = 0 + fun put(name: String, value: JsonValue): Builder = apply { + when (value) { + is JsonMissing, + is JsonNull -> {} + is JsonBoolean -> put(name, value.value.toString()) + is JsonNumber -> put(name, value.value.toString()) + is JsonString -> put(name, value.value) + is JsonArray -> value.values.forEach { put(name, it) } + is JsonObject -> + value.values.forEach { (nestedName, value) -> put("$name.$nestedName", value) } + } + } + fun put(name: String, value: String) = apply { map.getOrPut(name) { mutableListOf() }.add(value) size++ @@ -41,15 +64,6 @@ private constructor( headers.names().forEach { put(it, headers.values(it)) } } - fun remove(name: String) = apply { size -= map.remove(name).orEmpty().size } - - fun removeAll(names: Set) = apply { names.forEach(::remove) } - - fun clear() = apply { - map.clear() - size = 0 - } - fun replace(name: String, value: String) = apply { remove(name) put(name, value) @@ -68,6 +82,15 @@ private constructor( headers.names().forEach { replace(it, headers.values(it)) } } + fun remove(name: String) = apply { size -= map.remove(name).orEmpty().size } + + fun removeAll(names: Set) = apply { names.forEach(::remove) } + + fun clear() = apply { + map.clear() + size = 0 + } + fun build() = Headers( map.mapValuesTo(TreeMap(String.CASE_INSENSITIVE_ORDER)) { (_, values) -> diff --git a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/QueryParams.kt b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/QueryParams.kt index e88dc5d..d10f923 100644 --- a/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/QueryParams.kt +++ b/onebusaway-sdk-java-core/src/main/kotlin/org/onebusaway/core/http/QueryParams.kt @@ -2,6 +2,14 @@ package org.onebusaway.core.http +import org.onebusaway.core.JsonArray +import org.onebusaway.core.JsonBoolean +import org.onebusaway.core.JsonMissing +import org.onebusaway.core.JsonNull +import org.onebusaway.core.JsonNumber +import org.onebusaway.core.JsonObject +import org.onebusaway.core.JsonString +import org.onebusaway.core.JsonValue import org.onebusaway.core.toImmutable class QueryParams @@ -28,6 +36,19 @@ private constructor( private val map: MutableMap> = mutableMapOf() private var size: Int = 0 + fun put(key: String, value: JsonValue): Builder = apply { + when (value) { + is JsonMissing, + is JsonNull -> {} + is JsonBoolean -> put(key, value.value.toString()) + is JsonNumber -> put(key, value.value.toString()) + is JsonString -> put(key, value.value) + is JsonArray -> value.values.forEach { put(key, it) } + is JsonObject -> + value.values.forEach { (nestedKey, value) -> put("$key[$nestedKey]", value) } + } + } + fun put(key: String, value: String) = apply { map.getOrPut(key) { mutableListOf() }.add(value) size++ From a9d3e770f4a0f5718a78bb865c495d08d2685492 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 22 Jul 2025 06:29:37 +0000 Subject: [PATCH 3/3] release: 0.1.0-alpha.29 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 9 +++++++++ README.md | 10 +++++----- build.gradle.kts | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index f471069..c412e97 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.28" + ".": "0.1.0-alpha.29" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index dca1cf0..75745bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 0.1.0-alpha.29 (2025-07-22) + +Full Changelog: [v0.1.0-alpha.28...v0.1.0-alpha.29](https://github.com/OneBusAway/java-sdk/compare/v0.1.0-alpha.28...v0.1.0-alpha.29) + +### Features + +* **client:** add `{QueryParams,Headers}#put(String, JsonValue)` methods ([6994f02](https://github.com/OneBusAway/java-sdk/commit/6994f026a6c7abb90a0bfec9ebb213f51dcf9347)) +* **client:** allow configuring env via system properties ([8f26ee5](https://github.com/OneBusAway/java-sdk/commit/8f26ee53d24819972943490215990c79d929b2fd)) + ## 0.1.0-alpha.28 (2025-07-19) Full Changelog: [v0.1.0-alpha.27...v0.1.0-alpha.28](https://github.com/OneBusAway/java-sdk/compare/v0.1.0-alpha.27...v0.1.0-alpha.28) diff --git a/README.md b/README.md index d685d21..9ed5e20 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/org.onebusaway/onebusaway-sdk-java)](https://central.sonatype.com/artifact/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.28) -[![javadoc](https://javadoc.io/badge2/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.28/javadoc.svg)](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.28) +[![Maven Central](https://img.shields.io/maven-central/v/org.onebusaway/onebusaway-sdk-java)](https://central.sonatype.com/artifact/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.29) +[![javadoc](https://javadoc.io/badge2/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.29/javadoc.svg)](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.29) @@ -15,7 +15,7 @@ It is generated with [Stainless](https://www.stainless.com/). -The REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org). Javadocs are available on [javadoc.io](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.28). +The REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org). Javadocs are available on [javadoc.io](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-java/0.1.0-alpha.29). @@ -26,7 +26,7 @@ The REST API documentation can be found on [developer.onebusaway.org](https://de ### Gradle ```kotlin -implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.28") +implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.29") ``` ### Maven @@ -35,7 +35,7 @@ implementation("org.onebusaway:onebusaway-sdk-java:0.1.0-alpha.28") org.onebusaway onebusaway-sdk-java - 0.1.0-alpha.28 + 0.1.0-alpha.29 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 8dd6454..d27d975 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "org.onebusaway" - version = "0.1.0-alpha.28" // x-release-please-version + version = "0.1.0-alpha.29" // x-release-please-version } subprojects {