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

fix: Add support for multiple paths #2122

Merged
Merged
Show file tree
Hide file tree
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 @@ -5,6 +5,7 @@
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import org.eclipse.microprofile.openapi.models.media.Content;
import org.eclipse.microprofile.openapi.models.media.Schema;
Expand Down Expand Up @@ -50,10 +51,10 @@ public static Comparator<Parameter> parameterComparator(List<Parameter> preferre

static final Pattern TEMPLATE_PARAM_PATTERN = Pattern.compile("\\{(\\w[\\w\\.-]*)\\}");

private String pathItemPath;
private List<String> pathItemPaths;
private List<Parameter> pathItemParameters;

private String operationPath;
private List<String> operationPaths;
private List<Parameter> operationParameters;

private Content formBodyContent;
Expand All @@ -62,12 +63,14 @@ public List<Parameter> getPathItemParameters() {
return pathItemParameters;
}

public String getOperationPath() {
return operationPath;
public List<String> getOperationPaths() {
return operationPaths;
}

public String getFullOperationPath() {
return pathItemPath + operationPath;
public List<String> getFullOperationPaths() {
return pathItemPaths.stream()
.flatMap(pathItemPath -> operationPaths.stream().map(operationPath -> pathItemPath + operationPath))
.collect(Collectors.toList());
}

public List<Parameter> getOperationParameters() {
Expand Down Expand Up @@ -107,16 +110,16 @@ public List<Parameter> getAllParameters() {
return all;
}

public void setPathItemPath(String pathItemPath) {
this.pathItemPath = pathItemPath;
public void setPathItemPaths(List<String> pathItemPaths) {
this.pathItemPaths = pathItemPaths;
}

public void setPathItemParameters(List<Parameter> pathItemParameters) {
this.pathItemParameters = pathItemParameters;
}

public void setOperationPath(String operationPath) {
this.operationPath = operationPath;
public void setOperationPaths(List<String> operationPaths) {
this.operationPaths = operationPaths;
}

public void setOperationParameters(List<Parameter> operationParameters) {
Expand All @@ -139,7 +142,11 @@ public void sort(List<Parameter> preferredOrder) {
}

public List<String> getPathParameterTemplateNames() {
return getPathParameterTemplateName(this.pathItemPath, this.operationPath);
return pathItemPaths.stream()
.flatMap(pathItemPath -> operationPaths.stream()
.flatMap(operationPath -> getPathParameterTemplateName(pathItemPath, operationPath).stream()))
.distinct()
.collect(Collectors.toList());
}

private static List<String> getPathParameterTemplateName(String... paths) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import java.math.BigInteger;
import java.nio.file.Path;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import org.eclipse.microprofile.openapi.models.Extensible;
import org.jboss.jandex.DotName;
Expand Down Expand Up @@ -63,6 +65,12 @@ public void setContextRoot(String path) {
this.contextRoot = path;
}

protected List<String> makePaths(List<String> operationPaths) {
return operationPaths.stream()
.map(operationPath -> createPathFromSegments(this.contextRoot, this.currentAppPath, operationPath))
.collect(Collectors.toList());
}

protected String makePath(String operationPath) {
return createPathFromSegments(this.contextRoot, this.currentAppPath, operationPath);
}
Expand Down
Loading
Loading