Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and update swagger client generation #384

Merged
merged 5 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ $ ./gradlew build
## Update client

* Run `./gradlew generateSwaggerCode`
* Discard changes to `client/build.gradle` (newer versions of dependencies)
* Fix compile error in `client/src/main/java/com/github/gotify/client/auth/OAuthOkHttpClient.java` (caused by an updated dependency)
* Delete `client/settings.gradle` (client is a gradle sub project and must not have a settings.gradle)
* Delete `repositories` block from `client/build.gradle`
* Delete `implementation "com.sun.xml.ws:jaxws-rt:x.x.x“` from `client/build.gradle`
* Insert missing bracket in `retryingIntercept` method of class `src/main/java/com/github/gotify/client/auth/OAuth`
* Commit changes

## Versioning
Expand Down
5 changes: 4 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,14 @@ dependencies {

implementation "org.tinylog:tinylog-api-kotlin:$tinylog_version"
implementation "org.tinylog:tinylog-impl:$tinylog_version"

implementation 'com.google.code.gson:gson:2.11.0'
implementation 'com.squareup.retrofit2:retrofit:2.11.0'
implementation 'org.threeten:threetenbp:1.7.0'
}

configurations {
configureEach {
exclude group: 'org.json', module: 'json'
exclude group: 'androidx.lifecycle', module: 'lifecycle-viewmodel-ktx'
}
}
3 changes: 2 additions & 1 deletion app/src/main/kotlin/com/github/gotify/login/LoginActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.github.gotify.client.ApiClient
import com.github.gotify.client.api.ClientApi
import com.github.gotify.client.api.UserApi
import com.github.gotify.client.model.Client
import com.github.gotify.client.model.ClientParams
import com.github.gotify.client.model.VersionInfo
import com.github.gotify.databinding.ActivityLoginBinding
import com.github.gotify.databinding.ClientNameDialogBinding
Expand Down Expand Up @@ -291,7 +292,7 @@ internal class LoginActivity : AppCompatActivity() {
nameProvider: TextInputEditText
): DialogInterface.OnClickListener {
return DialogInterface.OnClickListener { _, _ ->
val newClient = Client().name(nameProvider.text.toString())
val newClient = ClientParams().name(nameProvider.text.toString())
client.createService(ClientApi::class.java)
.createClient(newClient)
.enqueue(
Expand Down
24 changes: 11 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
plugins {
id 'com.android.application' version '8.5.0' apply false
id 'org.jetbrains.kotlin.android' version '2.0.0' apply false
id 'org.hidetake.swagger.generator' version '2.14.0'
}

ext {
gotifyVersion = 'master'
specLocation = "$layout.buildDirectory/gotify.spec.json"
id 'org.hidetake.swagger.generator' version '2.19.2'
}

tasks.register('clean', Delete) {
delete rootProject.layout.buildDirectory
}

static def download(String url, String filename ) {
new URL( url ).openConnection().with { conn ->
new File( filename ).withOutputStream { out ->
new URI(url).toURL().openConnection().with { conn ->
new File(filename).withOutputStream { out ->
conn.inputStream.with { inp ->
out << inp
inp.close()
Expand All @@ -25,16 +20,19 @@ static def download(String url, String filename ) {
}

tasks.register('downloadSpec') {
inputs.property 'version', gotifyVersion
def gotifyVersion = 'master'
def url = "https://raw.githubusercontent.com/gotify/server/$gotifyVersion/docs/spec.json"
def buildDir = project.layout.buildDirectory.get()
def specLocation = buildDir.file('gotify.spec.json').asFile.absolutePath
doFirst {
layout.buildDirectory.mkdirs()
download("https://raw.githubusercontent.com/gotify/server/${gotifyVersion}/docs/spec.json", specLocation)
buildDir.asFile.mkdirs()
download(url, specLocation)
}
}

swaggerSources {
gotify {
inputFile = specLocation as File
inputFile = "$projectDir/build/gotify.spec.json" as File
code {
configFile = "$projectDir/swagger.config.json" as File
language = 'java'
Expand All @@ -44,7 +42,7 @@ swaggerSources {
}

dependencies {
swaggerCodegen 'io.swagger:swagger-codegen-cli:2.3.1'
swaggerCodegen 'io.swagger.codegen.v3:swagger-codegen-cli:3.0.63'
}

generateSwaggerCode.dependsOn downloadSpec
2 changes: 1 addition & 1 deletion client/.swagger-codegen/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.1
3.0.63
1 change: 0 additions & 1 deletion client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,3 @@ After the client library is installed/deployed, you can use it in your Maven pro




71 changes: 49 additions & 22 deletions client/build.gradle
Original file line number Diff line number Diff line change
@@ -1,32 +1,59 @@
apply plugin: 'idea'
apply plugin: 'eclipse'

group = 'io.swagger'
version = '1.0.0'

apply plugin: 'java-library'

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
plugins {
id 'java'
id 'maven-publish'
}

ext {
oltu_version = "1.0.2"
retrofit_version = "2.5.0"
swagger_annotations_version = "1.5.15"
junit_version = "4.13"
threetenbp_version = "1.4.4"
json_fire_version = "1.8.4"
retrofit_version = "2.7.1"
swagger_annotations_version = "2.0.0"
junit_version = "4.12"
threetenbp_version = "1.4.1"
json_fire_version = "1.8.3"
}

dependencies {
api "com.squareup.retrofit2:retrofit:$retrofit_version"
api "com.squareup.retrofit2:converter-scalars:$retrofit_version"
api "com.squareup.retrofit2:converter-gson:$retrofit_version"
api "io.swagger:swagger-annotations:$swagger_annotations_version"
implementation ("org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version") {
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-scalars:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
implementation "io.swagger.core.v3:swagger-annotations:$swagger_annotations_version"
implementation ("org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"){
exclude group:'org.apache.oltu.oauth2' , module: 'org.apache.oltu.oauth2.common'
exclude group: 'org.json', module: 'json'
}
api "io.gsonfire:gson-fire:$json_fire_version"
api "org.threeten:threetenbp:$threetenbp_version"
implementation "org.json:json:20180130"
implementation "io.gsonfire:gson-fire:$json_fire_version"
implementation "org.threeten:threetenbp:$threetenbp_version"

testImplementation "junit:junit:$junit_version"
}

group = 'io.swagger'
version = '1.0.0'
description = 'Swagger Java'

java.sourceCompatibility = 11
java.targetCompatibility = 11

tasks.register('testsJar', Jar) {
archiveClassifier = 'tests'
from(sourceSets.test.output)
}

java {
withSourcesJar()
withJavadocJar()
}

publishing {
publications {
maven(MavenPublication) {
from(components.java)
artifact(testsJar)
}
}
}

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
4 changes: 2 additions & 2 deletions client/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ lazy val root = (project in file(".")).
"com.squareup.retrofit2" % "retrofit" % "2.3.0" % "compile",
"com.squareup.retrofit2" % "converter-scalars" % "2.3.0" % "compile",
"com.squareup.retrofit2" % "converter-gson" % "2.3.0" % "compile",
"io.swagger" % "swagger-annotations" % "1.5.15" % "compile",
"org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1" % "compile",
"io.swagger.core.v3" % "swagger-annotations" % "2.0.0" % "compile",
"org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.2" % "compile",
"org.threeten" % "threetenbp" % "1.3.5" % "compile",
"io.gsonfire" % "gson-fire" % "1.8.0" % "compile",
"junit" % "junit" % "4.12" % "test",
Expand Down
6 changes: 2 additions & 4 deletions client/docs/Application.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@

# Application

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**defaultPriority** | **Long** | The default priority of messages sent by this application. Defaults to 0. | [optional]
**description** | **String** | The description of the application. |
**id** | **Long** | The application id. |
**image** | **String** | The image of the application. |
**internal** | **Boolean** | Whether the application is an internal application. Internal applications should not be deleted. |
**lastUsed** | [**OffsetDateTime**](OffsetDateTime.md) | The last time the application token was used. | [optional]
**name** | **String** | The application name. This is how the application should be displayed to the user. |
**token** | **String** | The application token. Can be used as &#x60;appToken&#x60;. See Authentication. |



Loading
Loading