Closed KasperJanssens closed 5 years ago
If you use the generator to create classes in the target folder, you need to declare dependencies in your project. It will not update your pom.
You can find required dependencies in build.gradle
file generated.
Is that your point?
I have admittedly not made myself very clear, logged that report too late in the evening. My point is that this is what is being generate (well, partially of course, the first 30 or so lines) :
import com.typesafe.config.ConfigFactory
import io.ktor.application.Application
import io.ktor.application.ApplicationStopping
import io.ktor.application.install
import io.ktor.application.log
import io.ktor.client.HttpClient
import io.ktor.client.engine.apache.Apache
import io.ktor.config.HoconApplicationConfig
import io.ktor.features.AutoHeadResponse
import io.ktor.features.Compression
import io.ktor.features.ContentNegotiation
import io.ktor.features.DefaultHeaders
import io.ktor.features.HSTS
import io.ktor.gson.GsonConverter
import io.ktor.http.ContentType
import io.ktor.locations.KtorExperimentalLocationsAPI
import io.ktor.locations.Locations
import io.ktor.metrics.Metrics
import io.ktor.routing.Routing
import java.util.concurrent.TimeUnit
import org.openapitools.server.apis.DefaultApi
@KtorExperimentalAPI
internal val settings = HoconApplicationConfig(ConfigFactory.defaultApplication(HTTP::class.java.classLoader))
which does not compile in and of itself, I get an error during the compilation process
AppMain.kt:[27,2] Unresolved reference: KtorExperimentalAPI
I need to add
import io.ktor.util.KtorExperimentalAPI
myself manually in the generated classes and then it compiles. So it feels like there is a missing import in the generated code. Or I am doing something wrong. Does that make more sense?
When using the 4.0.0 version of the maven plugin to generate kotlin server code like this :
The code being generated seems not to compile. The error seems to be Unresolved reference: KtorExperimentalAPI. I can open the generated code and explicitly add the import for this annotation, but because it's generated code that is of course not a good solution. The api.yaml is directly taken from the openapi specs : https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v3.0/api-with-examples.yaml.
The generation of the code happens through mvn clean install. I added these dependencies to the pom :
I target kotlin version 1.3.31 using the openjdk 11.0.3 on ubuntu linux.