Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[missing feature] custom generators on classpath are not visible #237

Closed
SardarNL opened this issue Jan 26, 2021 · 3 comments · Fixed by #335
Closed

[missing feature] custom generators on classpath are not visible #237

SardarNL opened this issue Jan 26, 2021 · 3 comments · Fixed by #335
Assignees
Labels
bug Something isn't working released

Comments

@SardarNL
Copy link

Custom generators are not visible to openapi-generator

Custom generators can be shipped as .jar file with codegen config and templates. This works fine with maven/gradle plugins, just add the .jar with a custom generator to dependencies. However, this will not work with openapi-generator-cli because generator .jar is called using -jar option. When java is started with -jar option, then -cp (classpath) option is ignored.

A solution to this could be use of class path and main class explicitly

  java -cp "${userProvidedClasspath}:${this.versionManager.filePath()}" org.openapitools.codegen.OpenAPIGenerator ...

This will work the same as with -jar option, but provides the user with an option to declare custom generator.

Steps to Reproduce

  1. Make a new custom generator
  2. Add script to package.json with JAVA_OPTS='-cp custom-generator.jar' openapi-generator-cli list
  3. You will not see the generator because -cp option is ignored

Expected behavior

A mechanism to add custom .jar files to classpath. This will make it possible to ship custom generator as a .jar file.

I can make a pull request with this fix if you approve this idea. PassThroughService can simply check if class path extensions are provided. If not, then run generator with -jar option. Otherwise, assemble class path and run main class directly.

@mcaden
Copy link
Contributor

mcaden commented Apr 27, 2021

I implemented the feature but I missed how it was originally requested to accept the -cp argument. Rather than intercept a provided -cp I implemented it as a custom parameter that changes the behavior. Not sure if this is preferable or not.

Usage:
--custom-generator=my-generator.jar

@SardarNL
Copy link
Author

Tested PR above, it works. This allows us to --custom-generator our extensions/generators while benefitting from standardly built main generator.

kay-schecker added a commit that referenced this issue May 19, 2021
feat(custom generators): added '--custom-generator' parameter fixes #237
@github-actions
Copy link

🎉 This issue has been resolved in version 2.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants