Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data object classes for templating context #837

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ packages/

/target
/generated-files
test-output/
nbactions.xml

# scalatra
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
package org.openapitools.codegen.templating;

import java.util.*;

import org.openapitools.codegen.CodegenSecurity;

public class ApiBundle extends BaseBundle {

private OperationsBundle operations;
private String _package;
private List<Map<String, String>> imports = new ArrayList<>();
private String basePath;
private String basePathWithoutHost;
private String contextPath;
private String baseName;
private String apiPackage;
private String modelPackage;
private String classname;
private String classVarName;
private String importPath;
private String classFilename;
private Map<String, Object> vendorExtensions = new HashMap<>();
private boolean sortParamsByRequiredFlag;
private Collection<CodegenSecurity> authMethods = new ArrayList<>();
private boolean hasMore;
private boolean hasImport;


// getters and setters. Each setter puts the value in the underlying Map

public String getPackage() {
return _package;
}

public void setPackage(String _package) {
this._package = _package;
put("package", _package);
}


public List<Map<String, String>> getImports() {
return imports;
}

public void setImports(List<Map<String, String>> imports) {
this.imports = imports;
put("imports", imports);
}


public String getBasePath() {
return basePath;
}

public void setBasePath(String basePath) {
this.basePath = basePath;
put("basePath", basePath);
}


public String getBasePathWithoutHost() {
return basePathWithoutHost;
}

public void setBasePathWithoutHost(String basePathWithoutHost) {
this.basePathWithoutHost = basePathWithoutHost;
put("basePathWithoutHost", basePathWithoutHost);
}


public String getContextPath() {
return contextPath;
}

public void setContextPath(String contextPath) {
this.contextPath = contextPath;
put("contextPath", contextPath);
}


public String getBaseName() {
return baseName;
}

public void setBaseName(String baseName) {
this.baseName = baseName;
put("baseName", baseName);
}


public String getApiPackage() {
return apiPackage;
}

public void setApiPackage(String apiPackage) {
this.apiPackage = apiPackage;
put("apiPackage", apiPackage);
}


public String getModelPackage() {
return modelPackage;
}

public void setModelPackage(String modelPackage) {
this.modelPackage = modelPackage;
put("modelPackage", modelPackage);
}


public String getClassname() {
return classname;
}

public void setClassname(String classname) {
this.classname = classname;
put("classname", classname);
}


public String getClassVarName() {
return classVarName;
}

public void setClassVarName(String classVarName) {
this.classVarName = classVarName;
put("classVarName", classVarName);
}


public String getImportPath() {
return importPath;
}

public void setImportPath(String importPath) {
this.importPath = importPath;
put("importPath", importPath);
}


public String getClassFilename() {
return classFilename;
}

public void setClassFilename(String classFilename) {
this.classFilename = classFilename;
put("classFilename", classFilename);
}


public Map<String, Object> getVendorExtensions() {
return vendorExtensions;
}

public void setVendorExtensions(Map<String, Object> vendorExtensions) {
this.vendorExtensions = vendorExtensions;
put("vendorExtensions", vendorExtensions);
}


public boolean isSortParamsByRequiredFlag() {
return sortParamsByRequiredFlag;
}

public void setSortParamsByRequiredFlag(boolean sortParamsByRequiredFlag) {
this.sortParamsByRequiredFlag = sortParamsByRequiredFlag;
put("sortParamsByRequiredFlag", sortParamsByRequiredFlag);
}


public OperationsBundle getOperations() {
return this.operations;
}

public void setOperations(OperationsBundle operations) {
this.operations = operations;
put("operations", operations);
}


public boolean getHasMore() {
return hasMore;
}

public void setHasMore(boolean hasMore) {
this.hasMore = hasMore;
put("hasMore", hasMore);
}

public void setHasImport(boolean hasImport) {
this.hasImport = hasImport;
put("hasImport", hasImport);
}

public boolean getHasImport() {
return hasImport;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.openapitools.codegen.templating;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class ApiInfoBundle extends BaseBundle {

private List<ApiBundle> apis = new ArrayList<>();

// getters and setters. Each setter puts the value in the underlying Map

public List<ApiBundle> getApis() {
return this.apis;
}

public void setApis(List<ApiBundle> apis) {
this.apis = apis;
put("apis", apis);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.openapitools.codegen.templating;

import java.util.HashMap;
import java.util.Map;

/**
* simply extend HashMap
*/
class BaseBundle extends HashMap<String, Object> implements Bundle {

BaseBundle() {
}

public BaseBundle(Map<String, Object> value) {
super(value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.openapitools.codegen.templating;

import java.util.Map;

/**
* a Bundle is a simple {@literal Map<String, Object>}
* but we add strongly typed fields to avoid
* - get("name") | put("name", value) pseudo-properties
* - the back and forth casting
*/
public interface Bundle extends Map<String, Object>{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.openapitools.codegen.templating;

import org.openapitools.codegen.CodegenOperation;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;

public class CodegenOperationBundle extends BaseBundle{
private String path;
private Collection<CodegenOperation> operation = new ArrayList<>();
private boolean hasMore;

// getters and setters. Each setter puts the value in the underlying Map

public String getPath() {
return path;
}

public void setPath(String path) {
this.path = path;
put("path", path);
}


public Collection<CodegenOperation> getOperation() {
return operation;
}

public void setOperation(Collection<CodegenOperation> operation) {
this.operation = operation;
put("operation", operation);
}


public boolean getHasMore() {
return hasMore;
}

public void setHasMore(boolean hasMore) {
this.hasMore = hasMore;
put("hasMore", hasMore);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.openapitools.codegen.templating;

import org.openapitools.codegen.CodegenModel;

import java.util.Map;

public class ModelBundle extends BaseBundle{
CodegenModel model;
String importPath;

public ModelBundle(Map<String, Object> model) {
super(model);
if (model.containsKey("model")) {
setModel((CodegenModel) model.get("model"));
}
if (model.containsKey("importPath")) {
setImportPath((String) model.get("importPath"));
}
}

public ModelBundle() {
super();
}

// getters and setters. Each setter puts the value in the underlying Map

public CodegenModel getModel() {
return model;
}

public void setModel(CodegenModel model) {
this.model = model;
put("model", model);
}


public String getImportPath() {
return importPath;
}

public void setImportPath(String importPath) {
this.importPath = importPath;
put("importPath", importPath);
}
}
Loading