Hi <@U0653A2V2QK> Regarding the new OpenAPI spec g...
# ktor
s
Hi @Bruce Hamilton Regarding the new OpenAPI spec generation, I’m encountering a few issues:
1. Still experiencing StackOverflowError on Ktor
3.3.2
- According to https://youtrack.jetbrains.com/issue/KTOR-8878, this appears to be fixed, but I’m still facing the issue. 2. Does the plugin support type-safe routes? 3. The plugin silently skips generation when the GraalVM plugin is applied with custom source sets.
For graalvm the following configuration is used
Copy code
"org.graalvm.buildtools.native" - 0.11.2
Here is the custom sourceset (as per the native image documentation)
Copy code
val graal by
    sourceSets.registering {
      compileClasspath += sourceSets.main.get().output
      runtimeClasspath += sourceSets.main.get().output
    }

configurations {
  val graalImplementation by existing
  val graalRuntimeOnly by existing

  graalImplementation.extendsFrom(implementation)
  graalRuntimeOnly.extendsFrom(runtimeOnly)
  nativeImageClasspath.extendsFrom(graalImplementation)
}
b
Hey, thanks for the feedback! 1. Sorry about the stack overflow issue, the the schema generation is pretty simplistic atm and it's probably dying on a self-reference somewhere. I'll reopen the issue and take a look. 2. Yes, it does! 3. The command just uses the JVM source set, so if you're extending it with another then it ought to work if you keep your Ktor code under
src/main/kotlin
. We'll have support for other targets in the full release in 3.4, and it'll avoid problems like the stack overflow because it will just delegate to the serialization plugin or whatever is configured.
thank you color 1
s
Sorry i forgot to share the stack-trace for stack overflow error. Here it is,
Copy code
exception: caused by: java.lang.StackOverflowError
exception:      at org.jetbrains.kotlin.fir.types.ConeTypeUtilsKt.withArguments(ConeTypeUtils.kt:148)
exception:      at io.ktor.compiler.utils.FirScopedEvaluator.resolveType(ScopedExpressionEvaluator.kt:234)
exception:      at io.ktor.compiler.utils.FirScopedEvaluator.resolveType(ScopedExpressionEvaluator.kt:239)
exception:      at io.ktor.compiler.utils.FirScopedEvaluator.resolveTypeProjection(ScopedExpressionEvaluator.kt:182)
exception:      at io.ktor.openapi.routing.RouteStackKt.resolveType(RouteStack.kt:41)
exception:      at io.ktor.openapi.model.JsonSchema$Companion.asJsonSchema(JsonSchema.kt:58)
exception:      at io.ktor.openapi.model.JsonSchema$Companion.asJsonSchema(JsonSchema.kt:58)
Any idea what could cause this issue or any interim workaround ?
b
If I were to guess, it could be caused by a generic that looks something like
class Enum<E extends Enum<E>>
or maybe there's some more mundane condition that causes the inference to go funky. You can probably find the problematic code by commenting out routes that use functions with generic types, since the failure occurs when trying to infer the values of type parameters based on the stack.