Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,13 @@ SYNOPSIS
[--instantiation-types <instantiation types>...]
[--invoker-package <invoker package>]
[--language-specific-primitives <language specific primitives>...]
[--library <library>] [--log-to-stderr]
[--library <library>] [--log-to-stderr] [--minimal-update]
[--model-name-prefix <model name prefix>]
[--model-name-suffix <model name suffix>]
[--model-package <model package>]
[(-o <output directory> | --output <output directory>)]
[--release-note <release note>] [--remove-operation-id-prefix]
[--package-name <package name>] [--release-note <release note>]
[--remove-operation-id-prefix]
[--reserved-words-mappings <reserved word mappings>...]
[(-s | --skip-overwrite)] [--skip-validate-spec]
[(-t <template directory> | --template-dir <template directory>)]
Expand Down
10 changes: 6 additions & 4 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,20 +241,22 @@ SYNOPSIS
[(-c <configuration file> | --config <configuration file>)]
[-D <system properties>...] [--enable-post-process-file]
[(-g <generator name> | --generator-name <generator name>)]
[--git-repo-id <git repo id>] [--git-user-id <git user id>]
[--group-id <group id>] [--http-user-agent <http user agent>]
[--generate-alias-as-model] [--git-repo-id <git repo id>]
[--git-user-id <git user id>] [--group-id <group id>]
[--http-user-agent <http user agent>]
(-i <spec file> | --input-spec <spec file>)
[--ignore-file-override <ignore file override location>]
[--import-mappings <import mappings>...]
[--instantiation-types <instantiation types>...]
[--invoker-package <invoker package>]
[--language-specific-primitives <language specific primitives>...]
[--library <library>] [--log-to-stderr]
[--library <library>] [--log-to-stderr] [--minimal-update]
[--model-name-prefix <model name prefix>]
[--model-name-suffix <model name suffix>]
[--model-package <model package>]
[(-o <output directory> | --output <output directory>)]
[--release-note <release note>] [--remove-operation-id-prefix]
[--package-name <package name>] [--release-note <release note>]
[--remove-operation-id-prefix]
[--reserved-words-mappings <reserved word mappings>...]
[(-s | --skip-overwrite)] [--skip-validate-spec]
[(-t <template directory> | --template-dir <template directory>)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ public class Generate implements Runnable {
+ "overwritten during the generation.")
private Boolean skipOverwrite;


@Option(name = {"--package-name"}, title = "package name",
description = CodegenConstants.PACKAGE_NAME_DESC)
private String packageName;

@Option(name = {"--api-package"}, title = "api package",
description = CodegenConstants.API_PACKAGE_DESC)
private String apiPackage;
Expand Down Expand Up @@ -288,6 +293,10 @@ public void run() {
configurator.setTemplateDir(templateDir);
}

if (isNotEmpty(packageName)) {
configurator.setPackageName(packageName);
}

if (isNotEmpty(templatingEngine)) {
configurator.setTemplatingEngineName(templatingEngine);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,19 @@ public void testSkipOverwrite() throws Exception {
};
}

@Test
public void testPackageName() throws Exception {
final String value = "io.foo.bar.baz";
setupAndRunGenericTest("--package-name", value);

new FullVerifications() {
{
configurator.setPackageName(value);
times = 1;
}
};
}

@Test
public void testApiPackage() throws Exception {
final String value = "io.foo.bar.api";
Expand Down
5 changes: 5 additions & 0 deletions modules/openapi-generator-gradle-plugin/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ The gradle plugin is not currently published to https://plugins.gradle.org/m2/.
|false
|Specifies if the existing files should be overwritten during the generation.

|packageName
|String
|(generator specific)
|Package for generated classes (where supported).

|apiPackage
|String
|(generator specific)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class OpenApiGeneratorPlugin : Plugin<Project> {
systemProperties.set(generate.systemProperties)
configFile.set(generate.configFile)
skipOverwrite.set(generate.skipOverwrite)
packageName.set(generate.packageName)
apiPackage.set(generate.apiPackage)
modelPackage.set(generate.modelPackage)
modelNamePrefix.set(generate.modelNamePrefix)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
*/
val skipOverwrite = project.objects.property<Boolean?>()

/**
* Package for generated classes (where supported)
*/
val packageName = project.objects.property<String>()

/**
* Package for generated api classes
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ open class GenerateTask : DefaultTask() {
@get:Internal
val skipOverwrite = project.objects.property<Boolean?>()

/**
* Package for generated classes (where supported)
*/
@get:Internal
val packageName = project.objects.property<String>()

/**
* Package for generated api classes
*/
Expand Down Expand Up @@ -456,6 +462,10 @@ open class GenerateTask : DefaultTask() {
configurator.templateDir = value
}

packageName.ifNotEmpty { value ->
configurator.packageName = value
}

apiPackage.ifNotEmpty { value ->
configurator.apiPackage = value
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ public class CodegenConstants {

public static final String PROJECT_NAME = "projectName";
public static final String PACKAGE_NAME = "packageName";
public static final String PACKAGE_NAME_DESC = "package for generated classes (where supported)";

public static final String PACKAGE_VERSION = "packageVersion";

public static final String PACKAGE_TITLE = "packageTitle";
Expand Down