Skip to content

Commit f035439

Browse files
committed
feat: ability to skip license header in generated files
1 parent 3c664d1 commit f035439

8 files changed

Lines changed: 19 additions & 0 deletions

File tree

docs/generators/elixir.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
2727
|licenseHeader|The license header to prepend to the top of all source files.| |null|
2828
|packageName|Elixir package name (convention: lowercase).| |null|
2929
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
30+
|skipLicenseHeader|Skip the license header in the generated files.| |false|
3031
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
3132
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
3233

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElixirClientCodegen.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ public ElixirClientCodegen() {
235235
"The main namespace to use for all classes. e.g. Yay.Pets"));
236236
cliOptions.add(new CliOption("licenseHeader", "The license header to prepend to the top of all source files."));
237237
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Elixir package name (convention: lowercase)."));
238+
cliOptions.add(new CliOption("skipLicenseHeader", "Skip the license header in the generated files.").defaultValue(Boolean.FALSE.toString()));
238239
}
239240

240241
/**
@@ -277,6 +278,7 @@ public void processOpts() {
277278
additionalProperties.put("supportedElixirVersion", supportedElixirVersion);
278279
additionalProperties.put("extraApplications", join(",", extraApplications));
279280
additionalProperties.put("deps", deps);
281+
additionalProperties.put("skipLicenseHeader", Boolean.FALSE);
280282
additionalProperties.put("underscored", new Mustache.Lambda() {
281283
@Override
282284
public void execute(Template.Fragment fragment, Writer writer) throws IOException {
@@ -309,6 +311,10 @@ public void execute(Template.Fragment fragment, Writer writer) throws IOExceptio
309311
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
310312
setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
311313
}
314+
if (additionalProperties.containsKey("skipLicenseHeader")) {
315+
boolean skipLicenseHeader = Boolean.parseBoolean(additionalProperties.get("skipLicenseHeader").toString());
316+
additionalProperties.put("skipLicenseHeader", skipLicenseHeader);
317+
}
312318
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
313319
}
314320

modules/openapi-generator/src/main/resources/elixir/api.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
{{^skipLicenseHeader}}
12
{{>licenseInfo}}
3+
{{/skipLicenseHeader}}
24
defmodule {{moduleName}}.Api.{{classname}} do
35
@moduledoc """
46
API calls for all endpoints tagged `{{baseName}}`.

modules/openapi-generator/src/main/resources/elixir/connection.ex.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
{{^skipLicenseHeader}}
12
{{>licenseInfo}}
3+
{{/skipLicenseHeader}}
24
defmodule {{moduleName}}.Connection do
35
@moduledoc """
46
Handle Tesla connections for {{moduleName}}.

modules/openapi-generator/src/main/resources/elixir/deserializer.ex.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
{{^skipLicenseHeader}}
12
{{>licenseInfo}}
3+
{{/skipLicenseHeader}}
24
defmodule {{moduleName}}.Deserializer do
35
@moduledoc """
46
Helper functions for deserializing responses into models

modules/openapi-generator/src/main/resources/elixir/model.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
{{^skipLicenseHeader}}
12
{{>licenseInfo}}
3+
{{/skipLicenseHeader}}
24
{{#models}}{{#model}}defmodule {{moduleName}}.Model.{{classname}} do
35
@moduledoc """
46
{{&description}}

modules/openapi-generator/src/main/resources/elixir/request_builder.ex.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
{{^skipLicenseHeader}}
12
{{>licenseInfo}}
3+
{{/skipLicenseHeader}}
24
defmodule {{moduleName}}.RequestBuilder do
35
@moduledoc """
46
Helper functions for building Tesla requests

modules/openapi-generator/src/test/java/org/openapitools/codegen/options/ElixirClientOptionsProvider.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class ElixirClientOptionsProvider implements OptionsProvider {
2626
public static final String INVOKER_PACKAGE_VALUE = "Yay.Pets";
2727
public static final String PREPEND_FORM_OR_BODY_PARAMETERS_VALUE = "true";
2828
public static final String ENUM_UNKNOWN_DEFAULT_CASE_VALUE = "false";
29+
public static final String SKIP_LICENSE_HEADER_VALUE = "false";
2930

3031
@Override
3132
public String getLanguage() {
@@ -47,6 +48,7 @@ public Map<String, String> createOptions() {
4748
.put(CodegenConstants.LEGACY_DISCRIMINATOR_BEHAVIOR, "true")
4849
.put(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT, "true")
4950
.put(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE, ENUM_UNKNOWN_DEFAULT_CASE_VALUE)
51+
.put("skipLicenseHeader", SKIP_LICENSE_HEADER_VALUE)
5052
.build();
5153
}
5254

0 commit comments

Comments
 (0)