Skip to content
This repository has been archived by the owner on Nov 15, 2024. It is now read-only.

Commit

Permalink
make generator generate defaults when there are collection types in t…
Browse files Browse the repository at this point in the history
…he action signature

upgrade versions
  • Loading branch information
daviddenton committed Oct 26, 2023
1 parent da3eed9 commit 66ff4c5
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
This list is not intended to be all-encompassing - it will document major and breaking API
changes with their rationale when appropriate. Given version `A.B.C.D`, breaking changes are to be expected in version number increments where changes in the `A` or `B` sections:

### v5.2.5.0
- **http4k-connect-*** - Upgrade dependencies.
- **http4k-connect-*** - Generated extension functions create defaults for collections types when they are defaulted in the core Action.

### v5.2.4.0
- **http4k-connect-*** - Upgrade dependencies.
- **http4k-connect-*** - Prevent extra dependencies being published in maven artefacts.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,16 @@ private fun generateExtensionFunction(

ctr.parameters.forEach {
val base = ParameterSpec.builder(it.name!!.asString(), it.type.toTypeName())
if (it.type.resolve().isMarkedNullable) base.defaultValue(CodeBlock.of("null"))
with(it.type.resolve()) {
if (isMarkedNullable) base.defaultValue(CodeBlock.of("null"))
else if (it.hasDefault) {
if (starProjection().toString() == "Map<*, *>") base.defaultValue(CodeBlock.of("emptyMap()"))
else if (starProjection().toString() == "List<*>") base.defaultValue(CodeBlock.of("emptyList()"))
else if (starProjection().toString() == "Set<*>") base.defaultValue(CodeBlock.of("emptySet()"))
else {
}
} else { }
}
baseFunction.addParameter(base.build())
}
return baseFunction.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import org.http4k.core.Request
import org.http4k.core.Response

@Http4kConnectAction
data class TestBarAction(val input: String, val input2: String) : BarAction<String> {
data class TestBarAction(val input: String,
val input2: String? = "default",
val input3: Map<String, String> = emptyMap(),
val input4: List<String> = emptyList(),
val input5: Set<String> = emptySet()
) : BarAction<String> {
constructor(input: String) : this(input, input)

override fun toRequest() = Request(Method.GET, "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ import dev.forkhandles.result4k.Success
import org.http4k.connect.Http4kConnectAction
import org.http4k.connect.RemoteFailure
import org.http4k.connect.plugin.foo.TestEnum.one
import org.http4k.connect.plugin.foo.TestEnum.two
import org.http4k.core.Method.GET
import org.http4k.core.Request
import org.http4k.core.Response

@Http4kConnectAction
data class TestFooAction(val input: String, val input2: TestEnum) : FooAction<String> {
data class TestFooAction(
val input: String,
val input2: TestEnum = two
) : FooAction<String> {
constructor(input: String) : this(input, one)

override fun toRequest() = Request(GET, "")
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pluginManagement {

plugins {
id("de.fayard.refreshVersions").version("0.60.2")
//// # available:"0.60.3")
}

refreshVersions {
Expand Down
18 changes: 10 additions & 8 deletions versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ plugin.com.github.kt3k.coveralls=2.12.2

plugin.com.google.devtools.ksp=1.9.10-1.0.13

plugin.de.fayard.buildSrcLibs=0.60.2
plugin.de.fayard.buildSrcLibs=0.60.3

plugin.com.github.davidmc24.gradle.plugin.avro=1.8.0
plugin.com.github.davidmc24.gradle.plugin.avro=1.9.1

version.com.google.devtools.ksp..symbol-processing-api=1.9.10-1.0.13

Expand All @@ -27,9 +27,9 @@ version.com.h2database..h2=2.2.224

version.com.zaxxer..HikariCP=5.0.1

version.dev.forkhandles..forkhandles-bom=2.7.1.0
version.dev.forkhandles..forkhandles-bom=2.8.0.0

version.http4k=5.8.1.0
version.http4k=5.8.6.0

version.io.lettuce..lettuce-core=6.2.6.RELEASE

Expand All @@ -38,6 +38,8 @@ version.jetbrains.exposed=0.41.1
## # available=0.42.0
## # available=0.42.1
## # available=0.43.0
## # available=0.44.0
## # available=0.44.1

version.org.apache.avro..avro=1.11.3

Expand All @@ -59,14 +61,14 @@ version.kotlinpoet=1.14.2
version.mockk=1.13.7
### available=1.13.8

version.org.testcontainers..testcontainers-bom=1.19.0
version.org.testcontainers..testcontainers-bom=1.19.1

version.org.webjars..swagger-ui=5.7.2
version.org.webjars..swagger-ui=5.9.0

version.se.ansman.kotshi..api=2.13.1

version.se.ansman.kotshi..compiler=2.13.1

version.software.amazon.awssdk..bom=2.20.153
version.software.amazon.awssdk..bom=2.21.8

version.com.nimbusds..nimbus-jose-jwt=9.35
version.com.nimbusds..nimbus-jose-jwt=9.37

0 comments on commit 66ff4c5

Please sign in to comment.