diff --git a/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Meta.java b/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Meta.java
index 8cee440fc3b..4ec67be8914 100644
--- a/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Meta.java
+++ b/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Meta.java
@@ -83,7 +83,7 @@ public class Meta implements Runnable {
ImmutableList.of(
new SupportingFile("pom.mustache", "", "pom.xml"),
new SupportingFile("generatorClass.mustache", on(File.separator).join("src/main/java", asPath(targetPackage)), mainClass.concat(".java")),
- new SupportingFile("debugGeneratorTest.mustache", on(File.separator).join("src/test/java", asPath("org.openapitools.codegen.debug")), "DebugCodegenLauncher.java"),
+ new SupportingFile("generatorClassTest.mustache", on(File.separator).join("src/test/java", asPath(targetPackage)), mainClass.concat("Test.java")),
new SupportingFile("README.mustache", "", "README.md"),
new SupportingFile("api.template", "src/main/resources" + File.separator + name,"api.mustache"),
new SupportingFile("model.template", "src/main/resources" + File.separator + name,"model.mustache"),
diff --git a/modules/openapi-generator/src/main/resources/codegen/debugGeneratorTest.mustache b/modules/openapi-generator/src/main/resources/codegen/debugGeneratorTest.mustache
deleted file mode 100644
index 9a9836c1143..00000000000
--- a/modules/openapi-generator/src/main/resources/codegen/debugGeneratorTest.mustache
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.openapitools.codegen.debug;
-
-import org.junit.Test;
-import org.openapitools.codegen.OpenAPIGenerator;
-
-/***
- * This test allows you to easily launch your code generation software under a debugger.
- * Then run this test under debug mode. You will be able to step through your java code
- * and then see the results in the out directory.
- *
- * To experiment with debugging your code generator:
- * 1) Set a break point in {{generatorClass}}.java in the postProcessOperationsWithModels() method.
- * 2) To launch this test in Eclipse: right-click | Debug As | JUnit Test
- *
- */
-public class DebugCodegenLauncher
-{
- @Test
- public void launchCodeGeneratorInDebugMode()
- {
- // use this test to launch you code generator in the debugger.
- // this allows you to easily set break points in {{generatorClass}}.
- String commandLineParams =
- "generate "+
- "-i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml "+ // sample swagger
- "-t ./src/main/resources/{{name}} "+ // template directory
- "-o out/{{name}} "+ // output directory
- "-g {{name}} "; // use this codegen library
-
- try{
- OpenAPIGenerator.main( commandLineParams.split(" ") );
- }
- catch(Exception ex) {
- System.err.println(ex.toString());
- }
- catch(Error er) {
- System.err.println(er.toString());
- }
- }
-}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/codegen/generatorClassTest.mustache b/modules/openapi-generator/src/main/resources/codegen/generatorClassTest.mustache
new file mode 100644
index 00000000000..4267a928fcf
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/codegen/generatorClassTest.mustache
@@ -0,0 +1,36 @@
+package {{generatorPackage}};
+
+import org.junit.Test;
+import org.openapitools.codegen.ClientOptInput;
+import org.openapitools.codegen.DefaultGenerator;
+import org.openapitools.codegen.config.CodegenConfigurator;
+
+/***
+ * This test allows you to easily launch your code generation software under a debugger.
+ * Then run this test under debug mode. You will be able to step through your java code
+ * and then see the results in the out directory.
+ *
+ * To experiment with debugging your code generator:
+ * 1) Set a break point in {{generatorClass}}.java in the postProcessOperationsWithModels() method.
+ * 2) To launch this test in Eclipse: right-click | Debug As | JUnit Test
+ *
+ */
+public class {{generatorClass}}Test {
+
+ // use this test to launch you code generator in the debugger.
+ // this allows you to easily set break points in MyclientcodegenGenerator.
+ @Test
+ public void launchCodeGenerator() {
+ // to understand how the 'openapi-generator-cli' module is using 'CodegenConfigurator', have a look at the 'Generate' class:
+ // https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Generate.java
+ final CodegenConfigurator configurator = new CodegenConfigurator()
+ .setGeneratorName("{{name}}") // use this codegen library
+ .setInputSpec("../../../modules/openapi-generator/src/test/resources/2_0/petstore.yaml") // sample OpenAPI file
+ // .setInputSpec("https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml") // or from the server
+ .setOutputDir("out/{{name}}"); // output directory
+
+ final ClientOptInput clientOptInput = configurator.toClientOptInput();
+ DefaultGenerator generator = new DefaultGenerator();
+ generator.opts(clientOptInput).generate();
+ }
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/codegen/pom.mustache b/modules/openapi-generator/src/main/resources/codegen/pom.mustache
index 8f9aa292252..628dd6552f7 100644
--- a/modules/openapi-generator/src/main/resources/codegen/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/codegen/pom.mustache
@@ -113,11 +113,6 @@
${openapi-generator-version}
provided
-
- org.openapitools
- openapi-generator-cli
- ${openapi-generator-version}
-
junit
junit
diff --git a/samples/meta-codegen/lib/pom.xml b/samples/meta-codegen/lib/pom.xml
index 0a904408cfe..f6782f61d1d 100644
--- a/samples/meta-codegen/lib/pom.xml
+++ b/samples/meta-codegen/lib/pom.xml
@@ -113,11 +113,6 @@
${openapi-generator-version}
provided
-
- org.openapitools
- openapi-generator-cli
- ${openapi-generator-version}
-
junit
junit
diff --git a/samples/meta-codegen/lib/src/test/java/com/my/company/codegen/MyclientcodegenGeneratorTest.java b/samples/meta-codegen/lib/src/test/java/com/my/company/codegen/MyclientcodegenGeneratorTest.java
new file mode 100644
index 00000000000..cc5c8103010
--- /dev/null
+++ b/samples/meta-codegen/lib/src/test/java/com/my/company/codegen/MyclientcodegenGeneratorTest.java
@@ -0,0 +1,36 @@
+package com.my.company.codegen;
+
+import org.junit.Test;
+import org.openapitools.codegen.ClientOptInput;
+import org.openapitools.codegen.DefaultGenerator;
+import org.openapitools.codegen.config.CodegenConfigurator;
+
+/***
+ * This test allows you to easily launch your code generation software under a debugger.
+ * Then run this test under debug mode. You will be able to step through your java code
+ * and then see the results in the out directory.
+ *
+ * To experiment with debugging your code generator:
+ * 1) Set a break point in MyclientcodegenGenerator.java in the postProcessOperationsWithModels() method.
+ * 2) To launch this test in Eclipse: right-click | Debug As | JUnit Test
+ *
+ */
+public class MyclientcodegenGeneratorTest {
+
+ // use this test to launch you code generator in the debugger.
+ // this allows you to easily set break points in MyclientcodegenGenerator.
+ @Test
+ public void launchCodeGenerator() {
+ // to understand how the 'openapi-generator-cli' module is using 'CodegenConfigurator', have a look at the 'Generate' class:
+ // https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Generate.java
+ final CodegenConfigurator configurator = new CodegenConfigurator()
+ .setGeneratorName("myClientCodegen") // use this codegen library
+ .setInputSpec("../../../modules/openapi-generator/src/test/resources/2_0/petstore.yaml") // sample OpenAPI file
+ // .setInputSpec("https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml") // or from the server
+ .setOutputDir("out/myClientCodegen"); // output directory
+
+ final ClientOptInput clientOptInput = configurator.toClientOptInput();
+ DefaultGenerator generator = new DefaultGenerator();
+ generator.opts(clientOptInput).generate();
+ }
+}
\ No newline at end of file
diff --git a/samples/meta-codegen/lib/src/test/java/org/openapitools/codegen/debug/DebugCodegenLauncher.java b/samples/meta-codegen/lib/src/test/java/org/openapitools/codegen/debug/DebugCodegenLauncher.java
deleted file mode 100644
index 46f2e3e314e..00000000000
--- a/samples/meta-codegen/lib/src/test/java/org/openapitools/codegen/debug/DebugCodegenLauncher.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.openapitools.codegen.debug;
-
-import org.junit.Test;
-import org.openapitools.codegen.OpenAPIGenerator;
-
-/***
- * This test allows you to easily launch your code generation software under a debugger.
- * Then run this test under debug mode. You will be able to step through your java code
- * and then see the results in the out directory.
- *
- * To experiment with debugging your code generator:
- * 1) Set a break point in MyclientcodegenGenerator.java in the postProcessOperationsWithModels() method.
- * 2) To launch this test in Eclipse: right-click | Debug As | JUnit Test
- *
- */
-public class DebugCodegenLauncher
-{
- @Test
- public void launchCodeGeneratorInDebugMode()
- {
- // use this test to launch you code generator in the debugger.
- // this allows you to easily set break points in MyclientcodegenGenerator.
- String commandLineParams =
- "generate "+
- "-i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml "+ // sample swagger
- "-t ./src/main/resources/myClientCodegen "+ // template directory
- "-o out/myClientCodegen "+ // output directory
- "-g myClientCodegen "; // use this codegen library
-
- try{
- OpenAPIGenerator.main( commandLineParams.split(" ") );
- }
- catch(Exception ex) {
- System.err.println(ex.toString());
- }
- catch(Error er) {
- System.err.println(er.toString());
- }
- }
-}
\ No newline at end of file
diff --git a/samples/meta-codegen/pom.xml b/samples/meta-codegen/pom.xml
index fc3ad25673e..530637969a7 100644
--- a/samples/meta-codegen/pom.xml
+++ b/samples/meta-codegen/pom.xml
@@ -8,5 +8,6 @@
lib/
../../modules/openapi-generator
+ ../../modules/openapi-generator-core