springdoc / springdoc-openapi

Library for OpenAPI 3 with spring-boot
https://springdoc.org
Apache License 2.0
3.3k stars 500 forks source link

Operation id contains generated information when using Kotlin #2745

Closed ghilainm closed 1 month ago

ghilainm commented 1 month ago

Describe the bug

Operation id contains generated information when using Kotlin.

To Reproduce Steps to reproduce the behavior:

Output: operationId: hello-O5qlCLM

Expected behavior

Output: operationId: hello

divinenickname commented 1 month ago

@ghilainm Could you provide more details about the issue you're facing? I haven't reproduce this behaviour in my project with same setup.

ghilainm commented 1 month ago

Here is info about my java version:

java --version java 21.0.4 2024-07-16 LTS Java(TM) SE Runtime Environment Oracle GraalVM 21.0.4+8.1 (build 21.0.4+8-LTS-jvmci-23.1-b41) Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 21.0.4+8.1 (build 21.0.4+8-LTS-jvmci-23.1-b41, mixed mode, sharing)

Here is the list of plugin applied (via a custom plugin)

        project.pluginManager.apply("org.jetbrains.kotlin.jvm")
        project.pluginManager.apply("org.jetbrains.kotlin.plugin.spring")
        project.pluginManager.apply(SpringBootPlugin::class.java)
        project.pluginManager.apply(DependencyManagementPlugin::class.java)
        project.pluginManager.apply(NativeImagePlugin::class.java)
        project.pluginManager.apply(IdeaPlugin::class.java)

And the dependencies:

dependencies {
    annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
    implementation("org.springframework.boot:spring-boot-starter-actuator")
    implementation("org.springframework.boot:spring-boot-starter-data-jdbc")
    implementation("org.springframework.boot:spring-boot-starter-webflux")
    implementation("org.jetbrains.kotlin:kotlin-reflect")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")
    runtimeOnly("com.fasterxml.jackson.module:jackson-module-kotlin") {
        because("Required to have spring doc properly generating class value (https://github.com/springdoc/springdoc-openapi/issues/2623)")
    }
    runtimeOnly("org.springdoc:springdoc-openapi-starter-webflux-api:2.6.0")
    runtimeOnly("org.postgresql:postgresql")
    testImplementation("org.springframework.boot:spring-boot-starter-test")  {
        exclude(module = "mockito-core")
    }
    testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
    testImplementation("com.ninja-squad:springmockk:4.0.2")
    testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
bnasslahsen commented 1 month ago

@ghilainm,

This is duplicate of: https://github.com/springdoc/springdoc-openapi/issues/2623 that was already answered.

ghilainm commented 1 month ago

Hello @bnasslahsen , I had seen that ticket and I have already added the requested dependency to com.fasterxml.jackson.module:jackson-module-kotlin.

bnasslahsen commented 1 month ago

@ghilainm,

Well, check your dependencies to make sure it's correctly loaded. If it's not working, Feel free to provide a github repo with Minimal, Reproducible Example - with HelloController that reproduces the problem.