Skip to content

Handle value set with setters the same way than with the additionalProperties map #55

Closed
@jmini

Description

@jmini

This feature was implemented with #43 and removed with #54.


The framework is providing two ways to set values:

  • with the additionalProperties map.
  • with the setter.

From a usage point of view, setting a value in one way or an other one should create no difference:

Setter:

JavaClientCodegen config = new io.swagger.codegen.languages.java.JavaClientCodegen();
config.setArtifactId("my-artifact-id");
config.setModelPackage("xyz.company.example.model");

Map:

JavaClientCodegen config = new io.swagger.codegen.languages.java.JavaClientCodegen();
config.additionalProperties().put(CodegenConstants.ARTIFACT_ID, "my-artifact-id")
config.additionalProperties().put(CodegenConstants.MODEL_PACKAGE, "xyz.company.example.model");

In my opinion, using setters is more natural, but both way are offered and needs to be supported.


Because of this dual way to set value, the Codegen classes need to conciliate both way and ensure that everything is consistent. This is done in processOpts(). The values need to be available in the templates (using {{artifactId}} or {{modelPacakge}} from the previous example), no matter if they were set the map or the setter way.


To solve this issue, the commit aa9e90b pushed with PR #54 needs to be reverted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions