2

I'm trying to write an OpenAPI custom generator as mentioned at openapi-generator on GitHub. Generated the codegen with below command.

java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar meta \
  -o out/generators/my-codegen -n my-codegen -p com.my.company.codegen

In the project, I extended the MyCodegenGenerator from JavaJAXRSCXFCDIServerCodegen and added the required mustache templates. When I tried to build the new codegen project, tests failed. So I skipped the tests and built the project. Then I proceeded with the next steps in the guide to use the custom codegen with the Maven plugin. As mentioned in the guide I used my-codegen as the generatorName:

<generatorName>my-codegen</generatorName>

I'm getting below error:

org.openapitools.codegen.GeneratorNotFoundException:
    Can't load config class with name 'my-codegen'

Tried com.my.company.codegen.MyCodegenGenerator as well as the generatorName and still get a similar error.

Please help me to resolve this issue.

2 Answers 2

3

I was able to find the cause of the issue. I had added the below dependency to the dependencies section of the build initially.

<dependency>
  <groupId>org.openapitools</groupId>
  <artifactId>my-codegen-openapi-generator</artifactId>
  <version>1.0.0</version>
</dependency>

After adding the dependency to the dependencies section of the plugin configuration, I was able to resolve the issue.

Sign up to request clarification or add additional context in comments.

Comments

1

You don't have to modify the pom.xml. Simply check that in your *Generator class, the overriden method getName() returns the same String as you use in .setGeneratorName(..) method call in your test class.

Also you have to check that the path at .setInputSpec(..) points to a valid yaml file which is out of the box not the case.

1 Comment

That is the correct answer, wasted hours till figured this out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.