OpenAPITools / OpenAPITools/openapi-generator
[BUG] Error generating code with kotlin-server
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I am developing an API using Ktor and Kotlin. And I want to generate the models and interfaces from the swagger, but I am getting an error when generating the files. It seems that the "interfaceOnly" config is not working. The file "/build/generated/src/main/kotlin/org/openapitools/server/AppMain.kt" is being generated missing a "}" at the end of the file. In the Paths file it is asking to use a serializer but I did not see a parameter in the openapi-generator settings to do this.
openapi-generator version
7.4.0
OpenAPI declaration file content or url
Generation Details
gradle.properties.
build.gradle.kts.
openApiGenerate {
generatorName.set("kotlin-server")
inputSpec.set("$rootDir/src/main/resources/swagger.json")
outputDir.set(generatedSourcesPath)
generateApiTests.set(false)
generateModelTests.set(false)
configOptions.set(
mapOf(
"interfaceOnly" to "true",
"serializationLibrary" to "kotlinx.serialization.json.JsonObject",
"additionalModelTypeAnnotations" to "@Contextual"
)
)
}
kotlin.sourceSets["main"].kotlin.srcDir("$generatedSourcesPath/src/main/kotlin")
tasks.withType<KotlinCompile>().configureEach {
dependsOn("openApiGenerate")
}
Steps to reproduce
To reproduce the problem, create a project in intellij, it is not necessary to add any plugins.
Then replace the contents of the "build.gradle.kts" and "gradle.properties" files and add swagger to the "resources" folder. Once this is done, just build the project to generate the code.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the generation using the linked swagger.json, gradle.properties, and build.gradle.kts with the kotlin-server generator and interfaceOnly enabled. Inspect the generated AppMain.kt and Paths-related output for the missing closing brace and serializer handling; done means the generated Kotlin project builds successfully with the reported configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100