Skip to content

Commit

Permalink
Merge pull request #108 from nprzy/generate-plaid-client
Browse files Browse the repository at this point in the history
Automatically generate plaid client
  • Loading branch information
dvankley authored Jul 20, 2024
2 parents cfe4d2f + f4e5ad2 commit af11139
Show file tree
Hide file tree
Showing 922 changed files with 53,358 additions and 58,627 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ hs_err_pid*

application-*.yml
test_cursor_map*

# Temporary files generated by OpenAPI Generator
.openapi-generator
34 changes: 34 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.nio.file.Paths

val kotlinVersion: String by project
val kotlinCoroutinesVersion: String by project
Expand All @@ -7,6 +8,7 @@ val ktorVersion: String by project
val jacksonVersion: String by project

plugins {
id("org.openapi.generator") version "7.7.0"
id("org.springframework.boot") version "3.3.1"
id("io.spring.dependency-management") version "1.1.5"
alias(libs.plugins.kotlin.jvm)
Expand Down Expand Up @@ -35,11 +37,43 @@ dependencies {
testImplementation("org.assertj:assertj-core:3.26.0")
}

var generatePlaidClient = tasks.register<org.openapitools.generator.gradle.plugin.tasks.GenerateTask>("generatePlaidClient") {
generatorName.set("kotlin")
inputSpec.set(layout.projectDirectory.dir("specs").file("plaid-2020-09-14.yml").toString())
cleanupOutput.set(true)
outputDir.set(layout.buildDirectory.dir("generated-plaid").get().toString())
apiPackage.set("net.djvk.fireflyPlaidConnector2.api.plaid.apis")
invokerPackage.set("net.djvk.fireflyPlaidConnector2.api.plaid.invoker")
modelPackage.set("net.djvk.fireflyPlaidConnector2.api.plaid.models")
globalProperties.put("modelDocs", "false")
globalProperties.put("apiDocs", "false")
globalProperties.put("modelTests", "false")
globalProperties.put("apiTests", "false")
configOptions.put("groupId", "net.djvk")
configOptions.put("packageName", "net.djvk.fireflyPlaidConnector2.api.plaid")
configOptions.put("library", "jvm-ktor")
configOptions.put("dateLibrary", "java8")
configOptions.put("serializationLibrary", "jackson")
configOptions.put("additionalModelTypeAnnotations", "@com.fasterxml.jackson.annotation.JsonIgnoreProperties(ignoreUnknown = true)")
configOptions.put("requestDateConverter", "toString")
configOptions.put("typeMappings", "BigDecimal=Double")
configOptions.put("omitGradleWrapper", "true")
}

kotlin {
sourceSets {
main {
kotlin.srcDir(Paths.get(generatePlaidClient.get().outputDir.get(), "src", "main", "kotlin"))
}
}
}

tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "17"
}
dependsOn(generatePlaidClient)
}

tasks.withType<Test> {
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kotlin.daemon.jvmargs=-Xmx3g
50,797 changes: 50,797 additions & 0 deletions specs/plaid-2020-09-14.yml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package net.djvk.fireflyPlaidConnector2.api.plaid

import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.SerializationFeature
import io.ktor.client.HttpClientConfig
import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.plugins.*
import io.ktor.http.*
import kotlinx.coroutines.delay
import net.djvk.fireflyPlaidConnector2.api.plaid.apis.PlaidApi
import net.djvk.fireflyPlaidConnector2.api.plaid.infrastructure.ApiClient
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Component
Expand Down Expand Up @@ -35,7 +38,11 @@ class PlaidApiWrapper(
httpClientEngine: HttpClientEngine? = null,
httpClientConfig: ((HttpClientConfig<*>) -> Unit)? = null,
) {
private val plaidApi = PlaidApi(baseUrl, httpClientEngine, httpClientConfig)
private val plaidApi = PlaidApi(baseUrl, httpClientEngine, httpClientConfig) {
ApiClient.JSON_DEFAULT.invoke(this)
configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true)
}
private val logger = LoggerFactory.getLogger(this::class.java)

init {
Expand Down
5,341 changes: 0 additions & 5,341 deletions src/main/kotlin/net/djvk/fireflyPlaidConnector2/api/plaid/apis/PlaidApi.kt

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit af11139

Please sign in to comment.