Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -1482,14 +1482,28 @@ private File processTemplateToFile(Map<String, Object> templateData, String temp
}

public Map<String, List<CodegenOperation>> processPaths(Paths paths) {
return processPathItems(paths);
}

public Map<String, List<CodegenOperation>> processWebhooks(Map<String, PathItem> webhooks) {
return processPathItems(webhooks);
}

/**
* Collects the operations of the given path items (paths or webhooks), grouped by tag.
*
* @param pathItems The path items by path or webhook name, may be null
* @return The operations by tag
*/
private Map<String, List<CodegenOperation>> processPathItems(Map<String, PathItem> pathItems) {
Map<String, List<CodegenOperation>> ops = new TreeMap<>();
// when input file is not valid and doesn't contain any paths
if (paths == null) {
// no paths (the input file is not valid) or no webhooks
if (pathItems == null) {
return ops;
}
for (Map.Entry<String, PathItem> pathsEntry : paths.entrySet()) {
String resourcePath = pathsEntry.getKey();
PathItem path = pathsEntry.getValue();
for (Map.Entry<String, PathItem> pathItemEntry : pathItems.entrySet()) {
String resourcePath = pathItemEntry.getKey();
PathItem path = pathItemEntry.getValue();
processOperation(resourcePath, "get", path.getGet(), ops, path);
processOperation(resourcePath, "head", path.getHead(), ops, path);
processOperation(resourcePath, "put", path.getPut(), ops, path);
Expand All @@ -1502,27 +1516,6 @@ public Map<String, List<CodegenOperation>> processPaths(Paths paths) {
return ops;
}

public Map<String, List<CodegenOperation>> processWebhooks(Map<String, PathItem> webhooks) {
Map<String, List<CodegenOperation>> ops = new TreeMap<>();
// when input file is not valid and doesn't contain any paths
if (webhooks == null) {
return ops;
}
for (Map.Entry<String, PathItem> webhooksEntry : webhooks.entrySet()) {
String resourceKey = webhooksEntry.getKey();
PathItem path = webhooksEntry.getValue();
processOperation(resourceKey, "get", path.getGet(), ops, path);
processOperation(resourceKey, "head", path.getHead(), ops, path);
processOperation(resourceKey, "put", path.getPut(), ops, path);
processOperation(resourceKey, "post", path.getPost(), ops, path);
processOperation(resourceKey, "delete", path.getDelete(), ops, path);
processOperation(resourceKey, "patch", path.getPatch(), ops, path);
processOperation(resourceKey, "options", path.getOptions(), ops, path);
processOperation(resourceKey, "trace", path.getTrace(), ops, path);
}
return ops;
}

private void processOperation(String resourcePath, String httpMethod, Operation operation, Map<String, List<CodegenOperation>> operations, PathItem path) {
if (operation == null) {
return;
Expand Down
Loading