Repository navigation
Add folder description to the generated postman.json #98
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| package com.adyen.codegen.postman; | ||
|
|
||
| import com.adyen.codegen.postman.model.PostmanRequestFolder; | ||
| import com.adyen.codegen.postman.model.PostmanRequestItem; | ||
| import com.adyen.codegen.postman.model.PostmanResponse; | ||
| import com.adyen.codegen.postman.model.PostmanVariable; | ||
|
|
@@ -54,7 +55,7 @@ public class PostmanV2Generator extends DefaultCodegen implements CodegenConfig | |
|
|
||
|
|
||
| // operations grouped by tag | ||
| protected Map<String, List<CodegenOperation>> codegenOperationsByTag = new HashMap<>(); | ||
| protected Map<PostmanRequestFolder, List<CodegenOperation>> codegenOperationsByTag = new HashMap<>(); | ||
| // list of operations | ||
| protected List<CodegenOperation> codegenOperationsList = new ArrayList<>(); | ||
|
|
||
|
|
@@ -270,24 +271,33 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<Mo | |
| return results; | ||
| } | ||
|
|
||
|
|
||
| void addToMap(CodegenOperation codegenOperation){ | ||
|
|
||
| String key; | ||
| PostmanRequestFolder folder = new PostmanRequestFolder(); | ||
| String tagName; | ||
| String tagDescription; | ||
| if(codegenOperation.tags == null || codegenOperation.tags.isEmpty()) { | ||
| key = "default"; | ||
| tagName = "Default"; | ||
| tagDescription = "Default tag"; | ||
| } else { | ||
| key = codegenOperation.tags.get(0).getName(); | ||
| // get from spec | ||
| tagName = codegenOperation.tags.get(0).getName(); | ||
| tagDescription = codegenOperation.tags.get(0).getDescription(); | ||
| if(tagDescription == null) { | ||
| tagDescription = tagName + " tag"; | ||
| } | ||
| } | ||
| folder.setName(tagName); | ||
| folder.setDescription(tagDescription); | ||
|
||
|
|
||
| List<CodegenOperation> list = codegenOperationsByTag.get(key); | ||
| List<CodegenOperation> list = codegenOperationsByTag.get(folder); | ||
|
|
||
| if(list == null) { | ||
| list = new ArrayList<>(); | ||
| } | ||
| list.add(codegenOperation); | ||
|
|
||
| codegenOperationsByTag.put(key, list); | ||
| codegenOperationsByTag.put(folder, list); | ||
|
|
||
| // sort requests by path | ||
| list.sort(Comparator.comparing(obj -> obj.path)); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package com.adyen.codegen.postman.model; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| public class PostmanRequestFolder { | ||
|
|
||
| String name; | ||
| String description; | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public void setName(String name) { | ||
| this.name = name; | ||
| } | ||
|
|
||
| public String getDescription() { | ||
| return description; | ||
| } | ||
|
|
||
| public void setDescription(String description) { | ||
| this.description = description; | ||
| } | ||
|
|
||
| public PostmanRequestFolder name(String name) { | ||
| this.name = name; | ||
| return this; | ||
| } | ||
|
|
||
| public PostmanRequestFolder description(String description) { | ||
| this.description = description; | ||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (o == null || getClass() != o.getClass()) return false; | ||
|
gcatanese marked this conversation as resolved.
Outdated
|
||
| PostmanRequestFolder folder = (PostmanRequestFolder) o; | ||
| return Objects.equals(name, folder.name) && Objects.equals(description, folder.description); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(name, description); | ||
| } | ||
|
gcatanese marked this conversation as resolved.
Outdated
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.