Skip to content

Commit 98bfe31

Browse files
author
bnasslahsen
committed
code review
1 parent 13e3bfe commit 98bfe31

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

springdoc-openapi-data-rest/src/main/java/org/springdoc/data/rest/core/DataRestRouterOperationBuilder.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,8 @@ private void buildRouterOperationList(List<RouterOperation> routerOperationList,
179179
PatternsRequestCondition patternsRequestCondition = requestMappingInfo.getPatternsCondition();
180180
Set<String> patterns = patternsRequestCondition.getPatterns();
181181
Map<String, String> regexMap = new LinkedHashMap<>();
182-
String operationPath = calculateOperationPath(path, subPath, patterns, regexMap, controllerType);
183-
if (ControllerType.PROPERTY.equals(controllerType))
184-
operationPath = operationPath.replace("{property}", dataRestRepository.getRelationName());
182+
String relationName = (dataRestRepository!=null) ? dataRestRepository.getRelationName(): null;
183+
String operationPath = calculateOperationPath(path, subPath, patterns, regexMap, controllerType, relationName);
185184
buildRouterOperation(routerOperationList, dataRestRepository, openAPI, methodResourceMapping,
186185
handlerMethod, requestMethod, resourceMetadata, operationPath, controllerType);
187186
}
@@ -199,13 +198,15 @@ private void buildRouterOperationList(List<RouterOperation> routerOperationList,
199198
* @return the string
200199
*/
201200
private String calculateOperationPath(String path, String subPath, Set<String> patterns,
202-
Map<String, String> regexMap, ControllerType controllerType) {
201+
Map<String, String> regexMap, ControllerType controllerType, String relationName) {
203202
String operationPath = null;
204203
for (String pattern : patterns) {
205204
operationPath = PathUtils.parsePath(pattern, regexMap);
206205
operationPath = operationPath.replace(REPOSITORY_PATH, path);
207206
if (ControllerType.SEARCH.equals(controllerType))
208207
operationPath = operationPath.replace(SEARCH_PATH, subPath);
208+
else if (ControllerType.PROPERTY.equals(controllerType))
209+
operationPath = operationPath.replace("{property}", relationName);
209210
}
210211
return operationPath;
211212
}

0 commit comments

Comments
 (0)