Skip to content

Commit

Permalink
Update libs.
Browse files Browse the repository at this point in the history
Fix kotlin warnings
  • Loading branch information
altro3 committed Dec 16, 2023
1 parent 0492c91 commit f08142a
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 63 deletions.
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ managed-freemarker = "2.3.32"
managed-pegdown = "1.6.0"

kotlin = "1.9.21"
ksp = "1.9.21-1.0.15"
ksp = "1.9.21-1.0.16"
jspecify = "0.3.0"
jdt-annotation = "2.2.800"
android-annotation = "1.7.0"
spotbugs-annotations = "4.8.2"
android-annotation = "1.7.1"
spotbugs-annotations = "4.8.3"
openapi-generator = "7.1.0"
swagger-parser = "1.0.68"
swagger-parser-v3 = "2.1.19"
javaparser = "3.25.7"
commons-codec = "1.16.0"

micronaut = "4.2.1"
micronaut = "4.2.2"
micronaut-platform = "4.2.2"
micronaut-security = "4.4.0"
micronaut-serde = "2.5.1"
micronaut-rxjava2 = "2.2.0"
Expand All @@ -28,11 +29,10 @@ micronaut-reactor = "3.2.0"
micronaut-gradle-plugin = "4.2.1"
micronaut-groovy = "4.1.0"
micronaut-validation = "4.2.0"
micronaut-data = "4.4.0"
micronaut-data = "4.4.1"
micronaut-test = "4.1.1"
micronaut-kotlin = "4.1.0"
micronaut-logging = "1.2.0"
micronaut-platform = "4.2.1"

[libraries]
# Core
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import io.swagger.v3.oas.models.OpenAPI
import io.swagger.v3.oas.models.Operation
import io.swagger.v3.oas.models.media.Schema
import io.swagger.v3.oas.models.responses.ApiResponse
import spock.lang.Ignore

class OpenApiPojoControllerKotlinSpec extends AbstractKotlinCompilerSpec {

Expand Down Expand Up @@ -77,4 +78,55 @@ class MyBean {}
schema.enum[0] == 'mysys'
schema.enum[1] == 'SYSTEM2'
}

@Ignore
void "test kotlin2"() {

when:
buildBeanDefinition('test.MyBean', '''
package test
import io.micronaut.core.annotation.Nullable
import io.micronaut.data.model.Pageable
import io.micronaut.http.MediaType
import io.micronaut.http.annotation.Body
import io.micronaut.http.annotation.Controller
import io.micronaut.http.annotation.Post
import io.micronaut.http.annotation.Produces
import io.swagger.v3.oas.annotations.OpenAPIDefinition
import io.swagger.v3.oas.annotations.info.Info
@OpenAPIDefinition(
info = Info(
title = "micronaut-swaggerui-demo",
version = "1.0.0"
)
)
object Api
@Controller("/hello")
class HelloController {
@Post
@Produces(MediaType.TEXT_PLAIN)
fun index(@Nullable @Body body: Pageable) = ""
}
class Foo {
private val bar = object {}
}
@jakarta.inject.Singleton
class MyBean {}
''')
then: "the state is correct"
Utils.testReference != null

when: "The OpenAPI is retrieved"
OpenAPI openAPI = Utils.testReference
Operation operation = openAPI.paths.'/hello'.get

then: "the state is correct"
operation != null
}
}
9 changes: 4 additions & 5 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ include 'test-suite-java-client-generator'
include 'test-suite-java-server-generator'
include 'test-suite-kotlin-kapt-client-generator'
include 'test-suite-kotlin-kapt-server-generator'
include 'test-suite-kotlin-ksp-client-generator'
// Skip it. Need to fix issues:
// https://github.com/micronaut-projects/micronaut-core/issues/10228
// https://github.com/micronaut-projects/micronaut-core/issues/10227
//include 'test-suite-kotlin-ksp-server-generator'
// Skip it. Need to fix issue:
// https://github.com/micronaut-projects/micronaut-core/issues/10277
//include 'test-suite-kotlin-ksp-client-generator'
include 'test-suite-kotlin-ksp-server-generator'
include 'test-suite-generator-util'

dependencyResolutionManagement {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,52 +24,52 @@ open class RequestBodyController : RequestBodyApi {
return Mono.empty()
}

override fun sendListOfSimpleModels(simpleModels: List<SimpleModel>?): Mono<List<SimpleModel>> {
return Mono.just(simpleModels!!)
override fun sendListOfSimpleModels(simpleModel: List<SimpleModel>?): Mono<List<SimpleModel>> {
return Mono.just(simpleModel!!)
}

override fun sendModelWithRequiredProperties(model: ModelWithRequiredProperties?): Mono<ModelWithRequiredProperties> {
return Mono.just(model!!)
override fun sendModelWithRequiredProperties(modelWithRequiredProperties: ModelWithRequiredProperties?): Mono<ModelWithRequiredProperties> {
return Mono.just(modelWithRequiredProperties!!)
}

override fun sendDateModel(model: DateModel?): Mono<DateModel> {
return Mono.just(model!!)
override fun sendDateModel(dateModel: DateModel?): Mono<DateModel> {
return Mono.just(dateModel!!)
}

override fun sendEnum(color: String): Mono<ColorEnum> {
return Mono.just(fromValue(color.replace("\"", "")))
override fun sendEnum(body: String): Mono<ColorEnum> {
return Mono.just(fromValue(body.replace("\"", "")))
}

override fun sendEnumList(availableColors: List<ColorEnum>): Mono<List<ColorEnum>> {
return Mono.just(availableColors)
override fun sendEnumList(colorEnum: List<ColorEnum>): Mono<List<ColorEnum>> {
return Mono.just(colorEnum)
}

override fun sendModelWithMapProperty(model: ModelWithMapProperty): Mono<ModelWithMapProperty> {
return Mono.just(model)
override fun sendModelWithMapProperty(modelWithMapProperty: ModelWithMapProperty): Mono<ModelWithMapProperty> {
return Mono.just(modelWithMapProperty)
}

override fun sendModelWithValidatedListProperty(modelWithValidatedListProperty: ModelWithValidatedListProperty): Mono<Void> {
return Mono.empty()
}

override fun sendNestedModel(model: NestedModel): Mono<NestedModel> {
return Mono.just(model)
override fun sendNestedModel(nestedModel: NestedModel): Mono<NestedModel> {
return Mono.just(nestedModel)
}

override fun sendModelWithInnerEnum(model: ModelWithInnerEnum): Mono<ModelWithInnerEnum> {
return Mono.just(model)
override fun sendModelWithInnerEnum(modelWithInnerEnum: ModelWithInnerEnum): Mono<ModelWithInnerEnum> {
return Mono.just(modelWithInnerEnum)
}

override fun sendModelWithDiscriminator(model: Animal): Mono<Animal> {
return Mono.just(model)
override fun sendModelWithDiscriminator(animal: Animal): Mono<Animal> {
return Mono.just(animal)
}

override fun sendBytes(bytes: ByteArray?): Mono<ByteArray> {
return Mono.just(bytes!!)
override fun sendBytes(body: ByteArray?): Mono<ByteArray> {
return Mono.just(body!!)
}

override fun sendModelWithEnumList(model: ModelWithEnumList): Mono<ModelWithEnumList> {
return Mono.just(model)
override fun sendModelWithEnumList(modelWithEnumList: ModelWithEnumList): Mono<ModelWithEnumList> {
return Mono.just(modelWithEnumList)
}

override fun sendFile(file: CompletedFileUpload?): Mono<ByteArray> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.time.ZonedDateTime
* A response that contains information about last modification.
*
* @param <T> The response body type.
</T> */
*/
data class DatedResponse<T>(
@NonNull
var body: T,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import java.io.OutputStream
* A class for writing [DatedResponse] to the HTTP response with JSON body.
*
* @param <T> the type of the response body
</T> */
*/
@Singleton
@Produces(MediaType.APPLICATION_JSON)
@Order(-1)
Expand All @@ -34,7 +34,7 @@ internal class DatedResponseBodyWriter<T> private constructor(
override fun createSpecific(
type: Argument<DatedResponse<T>>
): MessageBodyWriter<DatedResponse<T>> {
val bt: Argument<T> = type.getTypeParameters()[0] as Argument<T>
val bt: Argument<T> = type.typeParameters[0] as Argument<T>
val writer = registry.findWriter(bt, listOf(MediaType.APPLICATION_JSON_TYPE))
.orElseThrow { ConfigurationException("No JSON message writer present") }
return DatedResponseBodyWriter(registry, writer, bt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal class PageBodyWriter<T>(
constructor(registry: MessageBodyHandlerRegistry) : this(registry, null, null)

override fun createSpecific(type: Argument<Page<T>>): MessageBodyWriter<Page<T>> {
val bt: Argument<List<T>> = Argument.listOf(type.getTypeParameters()[0]) as Argument<List<T>>
val bt: Argument<List<T>> = Argument.listOf(type.typeParameters[0]) as Argument<List<T>>
val writer = registry.findWriter(bt, listOf(MediaType.APPLICATION_JSON_TYPE))
.orElseThrow { ConfigurationException("No JSON message writer present") }
return PageBodyWriter(registry, writer, bt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,52 +24,52 @@ open class RequestBodyController : RequestBodyApi {
return Mono.empty()
}

override fun sendListOfSimpleModels(simpleModels: List<SimpleModel>?): Mono<List<SimpleModel>> {
return Mono.just(simpleModels!!)
override fun sendListOfSimpleModels(simpleModel: List<SimpleModel>?): Mono<List<SimpleModel>> {
return Mono.just(simpleModel!!)
}

override fun sendModelWithRequiredProperties(model: ModelWithRequiredProperties?): Mono<ModelWithRequiredProperties> {
return Mono.just(model!!)
override fun sendModelWithRequiredProperties(modelWithRequiredProperties: ModelWithRequiredProperties?): Mono<ModelWithRequiredProperties> {
return Mono.just(modelWithRequiredProperties!!)
}

override fun sendDateModel(model: DateModel?): Mono<DateModel> {
return Mono.just(model!!)
override fun sendDateModel(dateModel: DateModel?): Mono<DateModel> {
return Mono.just(dateModel!!)
}

override fun sendEnum(color: String): Mono<ColorEnum> {
return Mono.just(fromValue(color.replace("\"", "")))
override fun sendEnum(body: String): Mono<ColorEnum> {
return Mono.just(fromValue(body.replace("\"", "")))
}

override fun sendEnumList(availableColors: List<ColorEnum>): Mono<List<ColorEnum>> {
return Mono.just(availableColors)
override fun sendEnumList(colorEnum: List<ColorEnum>): Mono<List<ColorEnum>> {
return Mono.just(colorEnum)
}

override fun sendModelWithMapProperty(model: ModelWithMapProperty): Mono<ModelWithMapProperty> {
return Mono.just(model)
override fun sendModelWithMapProperty(modelWithMapProperty: ModelWithMapProperty): Mono<ModelWithMapProperty> {
return Mono.just(modelWithMapProperty)
}

override fun sendModelWithValidatedListProperty(modelWithValidatedListProperty: ModelWithValidatedListProperty): Mono<Void> {
return Mono.empty()
}

override fun sendNestedModel(model: NestedModel): Mono<NestedModel> {
return Mono.just(model)
override fun sendNestedModel(nestedModel: NestedModel): Mono<NestedModel> {
return Mono.just(nestedModel)
}

override fun sendModelWithInnerEnum(model: ModelWithInnerEnum): Mono<ModelWithInnerEnum> {
return Mono.just(model)
override fun sendModelWithInnerEnum(modelWithInnerEnum: ModelWithInnerEnum): Mono<ModelWithInnerEnum> {
return Mono.just(modelWithInnerEnum)
}

override fun sendModelWithDiscriminator(model: Animal): Mono<Animal> {
return Mono.just(model)
override fun sendModelWithDiscriminator(animal: Animal): Mono<Animal> {
return Mono.just(animal)
}

override fun sendBytes(bytes: ByteArray?): Mono<ByteArray> {
return Mono.just(bytes!!)
override fun sendBytes(body: ByteArray?): Mono<ByteArray> {
return Mono.just(body!!)
}

override fun sendModelWithEnumList(model: ModelWithEnumList): Mono<ModelWithEnumList> {
return Mono.just(model)
override fun sendModelWithEnumList(modelWithEnumList: ModelWithEnumList): Mono<ModelWithEnumList> {
return Mono.just(modelWithEnumList)
}

override fun sendFile(file: CompletedFileUpload?): Mono<ByteArray> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.time.ZonedDateTime
* A response that contains information about last modification.
*
* @param <T> The response body type.
</T> */
*/
data class DatedResponse<T>(
@NonNull
var body: T,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import java.io.OutputStream
* A class for writing [DatedResponse] to the HTTP response with JSON body.
*
* @param <T> the type of the response body
</T> */
*/
@Singleton
@Produces(MediaType.APPLICATION_JSON)
@Order(-1)
Expand All @@ -34,7 +34,7 @@ internal class DatedResponseBodyWriter<T> private constructor(
override fun createSpecific(
type: Argument<DatedResponse<T>>
): MessageBodyWriter<DatedResponse<T>> {
val bt: Argument<T> = type.getTypeParameters()[0] as Argument<T>
val bt: Argument<T> = type.typeParameters[0] as Argument<T>
val writer = registry.findWriter(bt, listOf(MediaType.APPLICATION_JSON_TYPE))
.orElseThrow { ConfigurationException("No JSON message writer present") }
return DatedResponseBodyWriter(registry, writer, bt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal class PageBodyWriter<T>(
constructor(registry: MessageBodyHandlerRegistry) : this(registry, null, null)

override fun createSpecific(type: Argument<Page<T>>): MessageBodyWriter<Page<T>> {
val bt: Argument<List<T>> = Argument.listOf(type.getTypeParameters()[0]) as Argument<List<T>>
val bt: Argument<List<T>> = Argument.listOf(type.typeParameters[0]) as Argument<List<T>>
val writer = registry.findWriter(bt, listOf(MediaType.APPLICATION_JSON_TYPE))
.orElseThrow { ConfigurationException("No JSON message writer present") }
return PageBodyWriter(registry, writer, bt)
Expand Down

0 comments on commit f08142a

Please sign in to comment.