OpenAPITools / OpenAPITools/openapi-generator

[BUG] [core] CodegenConfigurator not applying all GeneratorSettings

Open
#6,128 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: General Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist

I trying to apply custom GeneratorSettings, but get only default ones. For example with "scala-akka" template i got next:

          CodegenConfigurator configurator = new CodegenConfigurator()
          configurator.setGeneratorName("scala-akka")
          configurator.setPackageName("some.package")
          configurator.setApiPackage("some.package.api")
          configurator.setInvokerPackage("some.package.core")
          configurator.setModelPackage("some.package.model")

          ClientOptInput clientOptOutput = configurator.toClientOptInput

and the result is present with default values instead of defined explicitly

          clientOptOutput.getPackageName // this property not present at all
          clientOptOutput.getApiPackage = "org.openapitools.client.api"
          clientOptOutput.getInvokerPackage ="org.openapitools.client.core"
          clientOptOutput.getModelPackage = "org.openapitools.client.model"

Seems code can be improved here:
https://github.com/OpenAPITools/openapi-generator/blob/c08e80f49b806de169f133e177be08b3e2bafa46/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java#L532

Next step to generate files is (which is obviously generating un-expecting result):

    DefaultGenerator codeGenerator = new DefaultGenerator
    codeGenerator.opts(opts).generate()

Should we cover those properties in CodegenConfigurator or there is another way to solve it?

Upd:
Those properties converted to additionalProperties. Is it make sense to have those properties available for DefaultCodegen as a class properties or any specific reason to keep it in additionalProperties?

@jimschubert (2017/09) ❤️, @wing328 , @Helmsdown , @jmini

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java at the referenced line, then trace how CodegenConfigurator.toClientOptInput passes settings to DefaultGenerator. Reproduce the scala-akka example and determine the expected handling of package settings versus additionalProperties. Done means explicitly configured packages are preserved in the generated result rather than replaced by defaults.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.