Skip to content

Commit 4fe54a5

Browse files
committed
Add spotless code formatting and apply
1 parent 020602c commit 4fe54a5

File tree

1,099 files changed

+27312
-29157
lines changed

Some content is hidden

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

1,099 files changed

+27312
-29157
lines changed

README.md

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -62,39 +62,38 @@ https://github.com/swooby/openai-openapi-kotlin/pull/1/files
6262
## Updates
6363
When a new spec comes out:
6464
1. Make sure to start from a fresh/stashed checkout.
65-
2. `curl -o openapi-YYYYMMDD.yaml https://raw.githubusercontent.com/openai/openai-openapi/refs/heads/master/openapi.yaml`
66-
3. `openapi-generator generate -i openapi-YYYYMMDD.yaml -g kotlin -o ./lib --skip-validate-spec --additional-properties=artifactId=openai-kotlin-client,artifactVersion=0.0.1,groupId=com.openai,packageName=com.openai`
67-
4. `mv lib/build.gradle lib/build.gradle.kts`
68-
5. `rm -f ./gradle && mv lib/gradle* .`
69-
6. `mv lib/settings.gradle ./settings.gradle.kts`
70-
7. Review each changed file, especially ones that show as modified in:
65+
2. `rm -r ./lib/src`
66+
3. `curl -o openapi-YYYYMMDD.yaml https://raw.githubusercontent.com/openai/openai-openapi/refs/heads/master/openapi.yaml`
67+
4. `openapi-generator generate -i openapi-YYYYMMDD.yaml -g kotlin -o ./lib --skip-validate-spec --additional-properties=artifactId=openai-kotlin-client,artifactVersion=0.0.1,groupId=com.openai,packageName=com.openai`
68+
5. Fix generated gradle files:
69+
1. `mv lib/build.gradle lib/build.gradle.kts`
70+
2. `rm -f ./gradle && mv lib/gradle* .`
71+
3. `mv lib/settings.gradle ./settings.gradle.kts`
72+
4. Compare/Review with the settings.gradle and build.gradle files.
73+
1. `gradle*`: probably discard all changes
74+
2. `settings.gradle.kts`: probably discard all changes
75+
3. `lib/build.gradle.kts`: probably discard all changes
76+
5. While you are here, update any dependencies in `gradle/libs.versions.toml`
77+
6. Consistently format all generated code with `./gradlew spotlessApply`
78+
7. Fix generated code compiler errors:
79+
TODO: Open an OpenAPI or OpenAI bug on these...
80+
1. `apis/AudioApi`
81+
1. add/keep `AudioResponseFormat.json`
82+
2. add/keep `timestampGranularities?.value`
83+
2. `models/CreateAssistantRequestToolResourcesFileSearch`: keep non-data class
84+
(compiler error to have data class with no constructor parameters)
85+
3. `models/CreateThreadRequestToolResourcesFileSearch`: keep non-data class
86+
(compiler error to have data class with no constructor parameters)
87+
8. Review each changed file, especially ones that show as modified in:
7188
https://github.com/swooby/openai-openapi-kotlin/pull/1/files
72-
1. First review with the settings.gradle and build.gradle files.
73-
1. `gradle*`: probably discard all changes
74-
2. `settings.gradle.kts`: probably discard all changes
75-
3. `lib/build.gradle.kts`: probably discard all changes
76-
4. While you are here, update any dependencies in `gradle/libs.versions.toml`
77-
2. `docs`: probably keep all changes
78-
3. `test`: probably keep all changes except...
79-
1. probably delete `RealtimeResponseCreateParamsMaxResponseOutputTokensTest`
80-
2. probably delete `RealtimeResponseMaxOutputTokensTest`
81-
3. delete `RealtimeSessionModelTest`
82-
4. `infrastructure`:
83-
1. `AudioApi.kt`: probably discard all changes
84-
2. `ApiClient.kt`: probably discard all changes
85-
3. `BigDecimalAdapter.kt`: probably discard all changes
86-
4. `BigIntegerAdapter.kt`: probably discard all changes
87-
5. `Serializer.kt`: probably discard all changes
88-
5. `models`:
89-
1. Fix compiler errors:
90-
1. `CreateAssistantRequestToolResourcesFileSearch`: keep non-data class
91-
(compiler error to have data class with no constructor parameters)
92-
2. `CreateThreadRequestToolResourcesFileSearch`: keep non-data class
93-
(compiler error to have data class with no constructor parameters)
94-
2. optimize imports.
95-
NOTE: This will not complete successfully until all code compiles successfully.
96-
See the preceding `Create*RequestToolResourcesFileSearch` compiler errors.
97-
3. `Realtime*` files:
89+
1. `apis` & `docs`: probably keep all changes
90+
2. `infrastructure`:
91+
1. `ApiClient.kt`: probably discard all changes
92+
2. `BigDecimalAdapter.kt`: probably discard all changes
93+
3. `BigIntegerAdapter.kt`: probably discard all changes
94+
4. `Serializer.kt`: probably discard all changes
95+
3. `models`: probably keep all changes except...
96+
1. `Realtime*` files:
9897
(This can get a little complicated...)
9998
1. `RealtimeClientEvent*`: Keep all `type: RealtimeClientEvent*.Type = RealtimeClientEvent*.Type....` one-line assignments
10099
These help a lot to simplify sending client events.
@@ -137,5 +136,11 @@ When a new spec comes out:
137136
2. change/keep `type` to nested `Type`
138137
15. `RealtimeSessionCreateResponse`
139138
1. change/keep `maxResponseOutputTokens` to type `RealtimeSessionMaxResponseOutputTokens`
139+
16. restore/reset/keep `RealtimeSessionMaxResponseOutputTokens`
140140
16. delete `RealtimeSessionModel`
141141
This empty class would cause a runtime deserialization exception.
142+
4. `test`: probably keep all changes except...
143+
1. revert `RealtimeResponseCreateParamsMaxResponseOutputTokensTest`
144+
detected as a rename from `RealtimeSessionMaxResponseOutputTokensTest`
145+
2. delete `RealtimeResponseMaxOutputTokensTest`
146+
3. delete `RealtimeSessionModelTest`

lib/build.gradle.kts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
22

33
plugins {
44
alias(libs.plugins.kotlin.jvm)
5+
id("com.diffplug.spotless") version "7.0.2"
56
// id("maven-publish")
67
}
78

@@ -30,3 +31,16 @@ dependencies {
3031
implementation(libs.squareup.okhttp3)
3132
testImplementation(libs.kotlintest.runner.junit5)
3233
}
34+
35+
spotless {
36+
kotlin {
37+
ktfmt("0.54").googleStyle().configure {
38+
// https://github.com/diffplug/spotless/blob/main/lib/src/ktfmt/java/com/diffplug/spotless/glue/ktfmt/KtfmtFormattingOptions.java
39+
it.setMaxWidth(80)
40+
it.setBlockIndent(4)
41+
it.setContinuationIndent(4)
42+
it.setRemoveUnusedImports(true)
43+
it.setManageTrailingCommas(true)
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)