Skip to content

Commit

Permalink
Use postProcessOperationsWithModels(Map, List) (OpenAPITools#431)
Browse files Browse the repository at this point in the history
Instead of postProcessOperations(Map)
  • Loading branch information
jmini authored and wing328 committed Jul 5, 2018
1 parent 0f60098 commit 1af4615
Show file tree
Hide file tree
Showing 54 changed files with 86 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ public interface CodegenConfig {

Map<String, Object> postProcessModels(Map<String, Object> objs);

/**
* @deprecated use {@link #postProcessOperationsWithModels(Map, List)} instead. This method will be removed
* @param objs the objects map that will be passed to the templating engine
* @return the the objects map instance.
*/
@Deprecated
Map<String, Object> postProcessOperations(Map<String, Object> objs);

Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation

@SuppressWarnings("unchecked")
@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,8 @@ public void updateCodegenPropertyEnum(CodegenProperty var) {
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
super.postProcessOperations(objs);
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
super.postProcessOperationsWithModels(objs, allModels);
if (objs != null) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
if (operations != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public String toOperationId(String operationId) {
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
@SuppressWarnings("unchecked")
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public String toOperationId(String operationId) {
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
@SuppressWarnings("unchecked")
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
// Remove imports of List, ArrayList, Map and HashMap as they are
// imported in the template already.
List<Map<String, String>> imports = (List<Map<String, String>>) objs.get("imports");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void preprocessOpenAPI(OpenAPI openAPI) {
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
return jaxrsPostProcessOperations(objs);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation op : operationList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public String escapeUnsafeCharacters(String input) {

@SuppressWarnings("unchecked")
@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
List<CodegenOperation> newOpList = new ArrayList<CodegenOperation>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@ public String getModelPropertyNaming() {
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
super.postProcessOperations(objs);
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
super.postProcessOperationsWithModels(objs, allModels);
if (objs != null) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
if (operations != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public String escapeText(String input) {
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> operations) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public String getTypeDeclaration(Schema p) {
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation op : operationList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation

@SuppressWarnings("unchecked")
@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
String classname = (String) operations.get("classname");
operations.put("classnameSnakeUpperCase", DefaultCodegen.underscore(classname).toUpperCase());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public String toApiFilename(String name) {

@SuppressWarnings("unchecked")
@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
List<CodegenOperation> newOpList = new ArrayList<CodegenOperation>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ public void preprocessOpenAPI(OpenAPI openAPI) {
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
Map<String, Object> operations = (Map<String, Object>) super.postProcessOperations(objs).get("operations");
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> operations = (Map<String, Object>) super.postProcessOperationsWithModels(objs, allModels).get("operations");
List<CodegenOperation> os = (List<CodegenOperation>) operations.get("operation");
List<ExtendedCodegenOperation> newOs = new ArrayList<ExtendedCodegenOperation>();
Pattern pattern = Pattern.compile("\\{([^\\}]+)\\}([^\\{]*)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {

@Override
@SuppressWarnings({"static-method", "unchecked"})
public Map<String, Object> postProcessOperations(Map<String, Object> operations) {
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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public String toOperationId(String operationId) {
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> os = (List<CodegenOperation>) operations.get("operation");
List<ExtendedCodegenOperation> newOs = new ArrayList<ExtendedCodegenOperation>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public String toApiFilename(String name) {
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation op : operationList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public String modelFileFolder() {

@SuppressWarnings("unchecked")
@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation op : operationList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,20 +682,6 @@ public List<CodegenSecurity> fromSecurity(Map<String, SecurityScheme> schemes) {
return secs;
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
Map<String, Object> ret = super.postProcessOperations(objs);

HashMap<String, Object> pathOps = (HashMap<String, Object>) ret.get("operations");
ArrayList<CodegenOperation> ops = (ArrayList<CodegenOperation>) pathOps.get("operation");
if (ops.size() > 0) {
ops.get(0).vendorExtensions.put(X_HAS_NEW_TAG, true);
}

updateGlobalAdditionalProps();
return ret;
}

@Override
public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
updateGlobalAdditionalProps();
Expand Down Expand Up @@ -728,6 +714,16 @@ public int compare(Map<String, Object> o1, Map<String, Object> o2) {

@Override
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> ret = super.postProcessOperationsWithModels(objs, allModels);

HashMap<String, Object> pathOps = (HashMap<String, Object>) ret.get("operations");
ArrayList<CodegenOperation> ops = (ArrayList<CodegenOperation>) pathOps.get("operation");
if (ops.size() > 0) {
ops.get(0).vendorExtensions.put(X_HAS_NEW_TAG, true);
}

updateGlobalAdditionalProps();

for (Object o : allModels) {
HashMap<String, Object> h = (HashMap<String, Object>) o;
CodegenModel m = (CodegenModel) h.get("model");
Expand All @@ -746,9 +742,8 @@ public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> o
}
}
}

}
return objs;
return ret;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
objs = super.postProcessOperations(objs);
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
objs = super.postProcessOperationsWithModels(objs, allModels);
return AbstractJavaJAXRSServerCodegen.jaxrsPostProcessOperations(objs);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,8 @@ private boolean usesRetrofit2Library() {

@SuppressWarnings("unchecked")
@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
super.postProcessOperations(objs);
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
super.postProcessOperationsWithModels(objs, allModels);
if (usesAnyRetrofitLibrary()) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
if (operations != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
if (operations != null) {
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public void processOpts() {

@SuppressWarnings("unchecked")
@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
if (operations != null) {
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public void setUseSwaggerUI(boolean useSwaggerUI) {
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
if (operations != null) {
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
return super.postProcessOperations(objs);
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
return super.postProcessOperationsWithModels(objs, allModels);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
return super.postProcessOperations(objs);
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
return super.postProcessOperationsWithModels(objs, allModels);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void processOpts() {
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
if (operations != null) {
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
Map<String, Object> newObjs = super.postProcessOperations(objs);
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> newObjs = super.postProcessOperationsWithModels(objs, allModels);
Map<String, Object> operations = (Map<String, Object>) newObjs.get("operations");
if (operations != null) {
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ private boolean isPrimitiveType(String type) {

@SuppressWarnings("unchecked")
@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
// Generate and store argument list string of each operation into
// vendor-extension: x-codegen-argList.
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.TreeSet;
import java.util.*;
import java.io.File;

Expand Down Expand Up @@ -285,7 +284,7 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
if (objs.get("imports") instanceof List) {
List<Map<String, String>> imports = (ArrayList<Map<String, String>>)objs.get("imports");
Collections.sort(imports, new Comparator<Map<String, String>>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ public String toOperationId(String operationId) {
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
@SuppressWarnings("unchecked")
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public void setExportedName(String name) {
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
@SuppressWarnings("unchecked")
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ public void setLicense(String license) {
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
if (operations != null) {
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
}

@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation op : operationList) {
Expand Down
Loading

0 comments on commit 1af4615

Please sign in to comment.