You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Codegen classes can be used directly (no maven plugin, no cli tool) like this:
JavaClientCodegen config = new io.swagger.codegen.languages.JavaClientCodegen();
config.setJava8Mode(true);
config.setOutputDir(outputDir);
final SwaggerParser swaggerParser = new SwaggerParser();
Swagger swagger = swaggerParser.read(folder + "/" + inputSpecName + ".json", null, true);
final ClientOptInput opts = new ClientOptInput();
opts.setConfig(config);
opts.setSwagger(swagger);
opts.setOpts(new ClientOpts());
new DefaultGenerator().opts(opts).generate();
For some values, it is possible to use a setter, for some values the only way is to use the additionalProperties map.
Currently hideGenerationTimestamp is can only be modified like this:
JavaClientCodegen config = new JavaClientCodegen();
codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false);
This issue is about providing a setter setHideGenerationTimestamp(boolean) in order to be able to do something like this:
JavaClientCodegen config = new JavaClientCodegen();
codegen.setHideGenerationTimestamp(false);
There are already setters in the DefaultCodegen class:
setSkipOverwrite(..)
setRemoveOperationIdPrefix(..)
…
The new setter should work in a similar manner.
The value need to be available in the templates (using {{hideGenerationTimestamp}})
The Codegen classes need to conciliate both way (value set with the new setter, value set in the additionalProperties map) and ensure that everything is consistent. This is done in processOpts().
hideGenerationTimestamp is defined multiple times. In the DefaultCodegen class and in some child classes.
This is bad design. “fields declaration hiding another field or variable” is a bad practice in java. Name shadowing can cause subtle errors and should be avoided.
With this pull request, the code should be clean up for hideGenerationTimestamp (otherwise the setters need to be defined at each level where hideGenerationTimestamp is declared).
When this change is made, the code that deals with hideGenerationTimestamp in the child processOpts() methods can be removed. It is handled at DefaultCodegen level.
The default value set in each subclass needs to be kept (initial value and custom initial value).
A getter isHideGenerationTimestamp() should be added in DefaultCodegen.
The text was updated successfully, but these errors were encountered:
This is inspired by swagger-api/swagger-codegen-generators#55 for swagger v3.
Codegen classes can be used directly (no maven plugin, no cli tool) like this:
For some values, it is possible to use a setter, for some values the only way is to use the
additionalProperties
map.Currently
hideGenerationTimestamp
is can only be modified like this:This issue is about providing a setter
setHideGenerationTimestamp(boolean)
in order to be able to do something like this:There are already setters in the
DefaultCodegen
class:setSkipOverwrite(..)
setRemoveOperationIdPrefix(..)
The new setter should work in a similar manner.
The value need to be available in the templates (using
{{hideGenerationTimestamp}}
)The
Codegen
classes need to conciliate both way (value set with the new setter, value set in theadditionalProperties
map) and ensure that everything is consistent. This is done inprocessOpts()
.hideGenerationTimestamp
is defined multiple times. In theDefaultCodegen
class and in some child classes.This is bad design. “fields declaration hiding another field or variable” is a bad practice in java. Name shadowing can cause subtle errors and should be avoided.
With this pull request, the code should be clean up for
hideGenerationTimestamp
(otherwise the setters need to be defined at each level wherehideGenerationTimestamp
is declared).When this change is made, the code that deals with
hideGenerationTimestamp
in the childprocessOpts()
methods can be removed. It is handled atDefaultCodegen
level.The default value set in each subclass needs to be kept (initial value and custom initial value).
A getter
isHideGenerationTimestamp()
should be added inDefaultCodegen
.The text was updated successfully, but these errors were encountered: