Skip to content

Commit 827bc48

Browse files
chore(internal): codegen related update (#228)
1 parent 795871e commit 827bc48

File tree

175 files changed

+11036
-8696
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

175 files changed

+11036
-8696
lines changed

README.md

Lines changed: 65 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
# Onebusaway SDK Kotlin API Library
22

3-
The Onebusaway SDK Kotlin SDK provides convenient access to the Onebusaway SDK REST API from applications written in Kotlin. It includes helper classes with helpful types and documentation for every request and response property.
4-
5-
The Onebusaway SDK Kotlin SDK is similar to the Onebusaway SDK Java SDK but with minor differences that make it more ergonomic for use in Kotlin, such as nullable values instead of `Optional`, `Sequence` instead of `Stream`, and suspend functions instead of `CompletableFuture`.
3+
<!-- x-release-please-start-version -->
64

7-
It is generated with [Stainless](https://www.stainlessapi.com/).
5+
[![Maven Central](https://img.shields.io/maven-central/v/org.onebusaway/onebusaway-sdk-kotlin)](https://central.sonatype.com/artifact/org.onebusaway/onebusaway-sdk-kotlin/0.1.0-alpha.57)
86

9-
## Documentation
7+
<!-- x-release-please-end -->
108

11-
The REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org).
9+
The Onebusaway SDK Kotlin SDK provides convenient access to the Onebusaway SDK REST API from applications written in Kotlin.
1210

13-
---
11+
The Onebusaway SDK Kotlin SDK is similar to the Onebusaway SDK Java SDK but with minor differences that make it more ergonomic for use in Kotlin, such as nullable values instead of `Optional`, `Sequence` instead of `Stream`, and suspend functions instead of `CompletableFuture`.
1412

15-
## Getting started
13+
It is generated with [Stainless](https://www.stainlessapi.com/).
1614

17-
### Install dependencies
15+
The REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org).
1816

19-
#### Gradle
17+
## Installation
2018

2119
<!-- x-release-please-start-version -->
2220

21+
### Gradle
22+
2323
```kotlin
2424
implementation("org.onebusaway:onebusaway-sdk-kotlin:0.1.0-alpha.57")
2525
```
2626

27-
#### Maven
27+
### Maven
2828

2929
```xml
3030
<dependency>
@@ -36,6 +36,12 @@ implementation("org.onebusaway:onebusaway-sdk-kotlin:0.1.0-alpha.57")
3636

3737
<!-- x-release-please-end -->
3838

39+
## Requirements
40+
41+
This library requires Java 8 or later.
42+
43+
## Usage
44+
3945
### Configure the client
4046

4147
Use `OnebusawaySdkOkHttpClient.builder()` to configure the client. At a minimum you need to set `.apiKey()`:
@@ -52,7 +58,6 @@ val client: OnebusawaySdkClient = OnebusawaySdkOkHttpClient.builder()
5258
Alternately, set the environment with `ONEBUSAWAY_API_KEY`, and use `OnebusawaySdkOkHttpClient.fromEnv()` to read from the environment.
5359

5460
```kotlin
55-
5661
import org.onebusaway.client.OnebusawaySdkClient
5762
import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient
5863

@@ -75,8 +80,7 @@ Read the documentation for more configuration options.
7580

7681
### Example: creating a resource
7782

78-
To create a new current time, first use the `CurrentTimeRetrieveParams` builder to specify attributes,
79-
then pass that to the `retrieve` method of the `currentTime` service.
83+
To create a new current time, first use the `CurrentTimeRetrieveParams` builder to specify attributes, then pass that to the `retrieve` method of the `currentTime` service.
8084

8185
```kotlin
8286
import org.onebusaway.models.CurrentTimeRetrieveParams
@@ -94,22 +98,7 @@ val currentTime: CurrentTimeRetrieveResponse = client.currentTime().retrieve(par
9498

9599
To make a request to the Onebusaway SDK API, you generally build an instance of the appropriate `Params` class.
96100

97-
In [Example: creating a resource](#example-creating-a-resource) above, we used the `CurrentTimeRetrieveParams.builder()` to pass to
98-
the `retrieve` method of the `currentTime` service.
99-
100-
Sometimes, the API may support other properties that are not yet supported in the Kotlin SDK types. In that case,
101-
you can attach them using the `putAdditionalProperty` method.
102-
103-
```kotlin
104-
105-
import org.onebusaway.core.JsonValue
106-
import org.onebusaway.models.CurrentTimeRetrieveParams
107-
108-
val params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.builder()
109-
// ... normal properties
110-
.putAdditionalProperty("secret_param", JsonValue.from("4242"))
111-
.build()
112-
```
101+
See [Undocumented request params](#undocumented-request-params) for how to send arbitrary parameters.
113102

114103
## Responses
115104

@@ -125,8 +114,7 @@ val currentTime: CurrentTimeRetrieveResponse = client.currentTime().retrieve().v
125114

126115
### Response properties as JSON
127116

128-
In rare cases, you may want to access the underlying JSON value for a response property rather than using the typed version provided by
129-
this SDK. Each model property has a corresponding JSON version, with an underscore before the method name, which returns a `JsonField` value.
117+
In rare cases, you may want to access the underlying JSON value for a response property rather than using the typed version provided by this SDK. Each model property has a corresponding JSON version, with an underscore before the method name, which returns a `JsonField` value.
130118

131119
```kotlin
132120
import java.util.Optional
@@ -166,31 +154,30 @@ val secret: JsonValue = references._additionalProperties().get("secret_field")
166154

167155
This library throws exceptions in a single hierarchy for easy handling:
168156

169-
- **`OnebusawaySdkException`** - Base exception for all exceptions
157+
- **`OnebusawaySdkException`** - Base exception for all exceptions
170158

171-
- **`OnebusawaySdkServiceException`** - HTTP errors with a well-formed response body we were able to parse. The exception message and the `.debuggingRequestId()` will be set by the server.
159+
- **`OnebusawaySdkServiceException`** - HTTP errors with a well-formed response body we were able to parse. The exception message and the `.debuggingRequestId()` will be set by the server.
172160

173-
| 400 | BadRequestException |
174-
| ------ | ----------------------------- |
175-
| 401 | AuthenticationException |
176-
| 403 | PermissionDeniedException |
177-
| 404 | NotFoundException |
178-
| 422 | UnprocessableEntityException |
179-
| 429 | RateLimitException |
180-
| 5xx | InternalServerException |
181-
| others | UnexpectedStatusCodeException |
161+
| 400 | BadRequestException |
162+
| ------ | ----------------------------- |
163+
| 401 | AuthenticationException |
164+
| 403 | PermissionDeniedException |
165+
| 404 | NotFoundException |
166+
| 422 | UnprocessableEntityException |
167+
| 429 | RateLimitException |
168+
| 5xx | InternalServerException |
169+
| others | UnexpectedStatusCodeException |
182170

183-
- **`OnebusawaySdkIoException`** - I/O networking errors
184-
- **`OnebusawaySdkInvalidDataException`** - any other exceptions on the client side, e.g.:
185-
- We failed to serialize the request body
186-
- We failed to parse the response body (has access to response code and body)
171+
- **`OnebusawaySdkIoException`** - I/O networking errors
172+
- **`OnebusawaySdkInvalidDataException`** - any other exceptions on the client side, e.g.:
173+
- We failed to serialize the request body
174+
- We failed to parse the response body (has access to response code and body)
187175

188176
## Network options
189177

190178
### Retries
191179

192-
Requests that experience certain errors are automatically retried 2 times by default, with a short exponential backoff. Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors will all be retried by default.
193-
You can provide a `maxRetries` on the client builder to configure this:
180+
Requests that experience certain errors are automatically retried 2 times by default, with a short exponential backoff. Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors will all be retried by default. You can provide a `maxRetries` on the client builder to configure this:
194181

195182
```kotlin
196183
import org.onebusaway.client.OnebusawaySdkClient
@@ -222,21 +209,44 @@ val client: OnebusawaySdkClient = OnebusawaySdkOkHttpClient.builder()
222209
Requests can be routed through a proxy. You can configure this on the client builder:
223210

224211
```kotlin
225-
val client = OnebusawaySdkOkHttpClient.builder()
226212
import java.net.InetSocketAddress
227213
import java.net.Proxy
228214
import org.onebusaway.client.OnebusawaySdkClient
229215
import org.onebusaway.client.okhttp.OnebusawaySdkOkHttpClient
230216

231217
val client: OnebusawaySdkClient = OnebusawaySdkOkHttpClient.builder()
232218
.fromEnv()
233-
.proxy(new Proxy(
234-
Type.HTTP,
235-
new InetSocketAddress("proxy.com", 8080)
236-
))
219+
.proxy(Proxy(Proxy.Type.HTTP, InetSocketAddress("example.com", 8080)))
220+
.build()
221+
```
222+
223+
## Making custom/undocumented requests
224+
225+
This library is typed for convenient access to the documented API. If you need to access undocumented params or response properties, the library can still be used.
226+
227+
### Undocumented request params
228+
229+
In [Example: creating a resource](#example-creating-a-resource) above, we used the `CurrentTimeRetrieveParams.builder()` to pass to the `retrieve` method of the `currentTime` service.
230+
231+
Sometimes, the API may support other properties that are not yet supported in the Kotlin SDK types. In that case, you can attach them using raw setters:
232+
233+
```kotlin
234+
import org.onebusaway.core.JsonValue
235+
import org.onebusaway.models.CurrentTimeRetrieveParams
236+
237+
val params: CurrentTimeRetrieveParams = CurrentTimeRetrieveParams.builder()
238+
.putAdditionalHeader("Secret-Header", "42")
239+
.putAdditionalQueryParam("secret_query_param", "42")
240+
.putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))
237241
.build()
238242
```
239243

244+
You can also use the `putAdditionalProperty` method on nested headers, query params, or body objects.
245+
246+
### Undocumented response properties
247+
248+
To access undocumented response properties, you can use `res._additionalProperties()` on a response object to get a map of untyped fields of type `Map<String, JsonValue>`. You can then access fields like `res._additionalProperties().get("secret_prop").asString()` or use other helpers defined on the `JsonValue` class to extract it to a desired type.
249+
240250
## Logging
241251

242252
We use the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).
@@ -257,13 +267,9 @@ $ export ONEBUSAWAY_SDK_LOG=debug
257267

258268
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
259269

260-
1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals)_.
270+
1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
261271
2. Changes that we do not expect to impact the vast majority of users in practice.
262272

263273
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
264274

265275
We are keen for your feedback; please open an [issue](https://www.github.com/OneBusAway/kotlin-sdk/issues) with questions, bugs, or suggestions.
266-
267-
## Requirements
268-
269-
This library requires Java 8 or later.

buildSrc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
`kotlin-dsl`
3-
kotlin("jvm") version "1.9.22"
3+
kotlin("jvm") version "2.1.0"
44
id("com.vanniktech.maven.publish") version "0.28.0"
55
}
66

buildSrc/src/main/kotlin/onebusaway-sdk.java.gradle.kts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import com.diffplug.gradle.spotless.SpotlessExtension
22
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
3-
import com.vanniktech.maven.publish.JavaLibrary
4-
import com.vanniktech.maven.publish.JavadocJar
5-
import com.vanniktech.maven.publish.MavenPublishBaseExtension
6-
import com.vanniktech.maven.publish.SonatypeHost
73

84
plugins {
95
`java-library`

buildSrc/src/main/kotlin/onebusaway-sdk.kotlin.gradle.kts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import com.diffplug.gradle.spotless.SpotlessExtension
22
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3-
import com.vanniktech.maven.publish.*
43

54
plugins {
65
id("onebusaway-sdk.java")
@@ -22,8 +21,12 @@ configure<SpotlessExtension> {
2221

2322
tasks.withType<KotlinCompile>().configureEach {
2423
kotlinOptions {
25-
allWarningsAsErrors = true
26-
freeCompilerArgs = listOf("-Xjvm-default=all", "-Xjdk-release=1.8")
24+
freeCompilerArgs = listOf(
25+
"-Xjvm-default=all",
26+
"-Xjdk-release=1.8",
27+
// Suppress deprecation warnings because we may still reference and test deprecated members.
28+
"-Xsuppress-warning=DEPRECATION"
29+
)
2730
jvmTarget = "1.8"
2831
}
2932
}

buildSrc/src/main/kotlin/onebusaway-sdk.publish.gradle.kts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
import org.gradle.api.publish.PublishingExtension
2-
import org.gradle.api.publish.maven.MavenPublication
3-
import org.gradle.kotlin.dsl.configure
4-
import org.gradle.kotlin.dsl.register
5-
import org.gradle.kotlin.dsl.get
6-
import com.vanniktech.maven.publish.JavaLibrary
7-
import com.vanniktech.maven.publish.JavadocJar
81
import com.vanniktech.maven.publish.MavenPublishBaseExtension
92
import com.vanniktech.maven.publish.SonatypeHost
103

@@ -25,7 +18,7 @@ configure<MavenPublishBaseExtension> {
2518
signAllPublications()
2619
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
2720

28-
this.coordinates(project.group.toString(), project.name, project.version.toString())
21+
coordinates(project.group.toString(), project.name, project.version.toString())
2922

3023
pom {
3124
name.set("OneBusAway")

gradle/wrapper/gradle-wrapper.jar

130 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,7 @@ done
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
8688
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87-
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
8890

8991
# Use the maximum available, or set MAX_FD != -1 to use that value.
9092
MAX_FD=maximum

gradlew.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
@rem See the License for the specific language governing permissions and
1414
@rem limitations under the License.
1515
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
1618

1719
@if "%DEBUG%"=="" @echo off
1820
@rem ##########################################################################

0 commit comments

Comments
 (0)