mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2026-03-17 00:49:15 +00:00
[GROOVY] update client generator to a stable version (#2847)
* [GROOVY] update client generator to a stable version * fix tab * fix remove using invokerPackage * fix test
This commit is contained in:
committed by
William Cheng
parent
48314905da
commit
98afbe062b
@@ -978,10 +978,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessParameter(CodegenParameter parameter) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
|
||||
// recursively add import for mapping one type to multiple imports
|
||||
|
||||
@@ -17,20 +17,16 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
|
||||
public class GroovyClientCodegen extends AbstractJavaCodegen {
|
||||
public static final String CONFIG_PACKAGE = "configPackage";
|
||||
protected String title = "Petstore Server";
|
||||
protected String configPackage = "org.openapitools.configuration";
|
||||
|
||||
public GroovyClientCodegen() {
|
||||
super();
|
||||
@@ -60,18 +56,14 @@ public class GroovyClientCodegen extends AbstractJavaCodegen {
|
||||
artifactId = "openapi-groovy";
|
||||
dateLibrary = "legacy"; //TODO: add joda support to groovy
|
||||
|
||||
// clioOptions default redifinition need to be updated
|
||||
// clioOptions default redefinition need to be updated
|
||||
updateOption(CodegenConstants.SOURCE_FOLDER, this.getSourceFolder());
|
||||
updateOption(CodegenConstants.INVOKER_PACKAGE, this.getInvokerPackage());
|
||||
updateOption(CodegenConstants.ARTIFACT_ID, this.getArtifactId());
|
||||
updateOption(CodegenConstants.API_PACKAGE, apiPackage);
|
||||
updateOption(CodegenConstants.MODEL_PACKAGE, modelPackage);
|
||||
updateOption(this.DATE_LIBRARY, this.getDateLibrary());
|
||||
updateOption(DATE_LIBRARY, this.getDateLibrary());
|
||||
|
||||
additionalProperties.put("title", title);
|
||||
additionalProperties.put(CONFIG_PACKAGE, configPackage);
|
||||
|
||||
cliOptions.add(new CliOption(CONFIG_PACKAGE, "configuration package for generated code").defaultValue(this.configPackage));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,25 +78,32 @@ public class GroovyClientCodegen extends AbstractJavaCodegen {
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a Groovy API client (beta).";
|
||||
return "Generates a Groovy API client.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
if (additionalProperties.containsKey(CONFIG_PACKAGE)) {
|
||||
this.setConfigPackage((String) additionalProperties.get(CONFIG_PACKAGE));
|
||||
}
|
||||
|
||||
supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle"));
|
||||
// TODO readme to be added later
|
||||
//supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("ApiUtils.mustache",
|
||||
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "ApiUtils.groovy"));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<Object> allModels) {
|
||||
Map<String, Object> objs = (Map<String, Object>) operations.get("operations");
|
||||
|
||||
List<CodegenOperation> ops = (List<CodegenOperation>) objs.get("operation");
|
||||
for (CodegenOperation op : ops) {
|
||||
// Overwrite path to map variable with path parameters
|
||||
op.path = op.path.replace("{", "${");
|
||||
}
|
||||
return operations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
if (name.length() == 0) {
|
||||
@@ -114,10 +113,6 @@ public class GroovyClientCodegen extends AbstractJavaCodegen {
|
||||
return camelize(name) + "Api";
|
||||
}
|
||||
|
||||
public void setConfigPackage(String configPackage) {
|
||||
this.configPackage = configPackage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
// remove ' to avoid code injection
|
||||
|
||||
Reference in New Issue
Block a user