OpenAPITools / OpenAPITools/openapi-generator
Custom Generator subclass not found
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
I'm trying to customize the kotlin-spring generator, using the "subclass" technique described in the customization doc. I tried to use the instructions to generate, applying generatorName = com.example.codegen.KotlinSpring in my gradle settings, but I get the following error:
Can't load config class with name 'com.example.codegen.KotlinSpring'
I overrode getName() and set a breakpoint in my subclass, but it doesn't seem to get called.
I noticed in the original PR to add kotlin-spring that this line was added to META-INF/services/org.openapitools.codegen.CodegenConfig, which looks like determines what generators the config finds.
I'm a bit new to Java, so not entirely sure, but any ideas here?
openapi-generator version
3.3.4
KotlinSpring.java
package com.example.codegen
import org.openapitools.codegen.languages.KotlinSpringServerCodegen
class KotlinSpring : KotlinSpringServerCodegen() {
override fun toModelName(name: String?): String {
return super.toModelName(name) + modelNameSuffix
}
override fun getName(): String {
return "haha"
}
}
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
Start with docs/customization.md and reproduce the Gradle configuration using generatorName = com.example.codegen.KotlinSpring. Then inspect the META-INF/services/org.openapitools.codegen.CodegenConfig registration and the KotlinSpring subclass to determine why the custom class is not loaded. Done means the subclass is discovered and its overridden behavior is used during generation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kotlin, openapi
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100