Skip to content

Commit 657c37d

Browse files
author
bnasslahsen
committed
code review
1 parent eae78b2 commit 657c37d

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

springdoc-openapi-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ protected synchronized OpenAPI getOpenApi() {
123123

124124
Map<String, Object> findControllerAdvice = openAPIBuilder.getControllerAdviceMap();
125125
// calculate generic responses
126-
responseBuilder.buildGenericResponse(openAPIBuilder.getComponents(), findControllerAdvice);
126+
responseBuilder.buildGenericResponse(openAPIBuilder.getCalculatedOpenAPI().getComponents(), findControllerAdvice);
127127

128128
getPaths(mappingsMap);
129129
openApi = openAPIBuilder.getCalculatedOpenAPI();
@@ -151,8 +151,8 @@ protected synchronized OpenAPI getOpenApi() {
151151
protected void calculatePath(HandlerMethod handlerMethod, String operationPath,
152152
Set<RequestMethod> requestMethods) {
153153
OpenAPI openAPI = openAPIBuilder.getCalculatedOpenAPI();
154-
Components components = openAPIBuilder.getComponents();
155-
Paths paths = openAPIBuilder.getPaths();
154+
Components components = openAPI.getComponents();
155+
Paths paths = openAPI.getPaths();
156156

157157
Map<HttpMethod, Operation> operationMap = null;
158158
if (paths.containsKey(operationPath)) {
@@ -195,7 +195,7 @@ protected void calculatePath(HandlerMethod handlerMethod, String operationPath,
195195
calculateJsonView(apiOperation, methodAttributes, method);
196196

197197
if (apiOperation != null) {
198-
openAPI = operationParser.parse(components, apiOperation, operation, openAPI, methodAttributes);
198+
openAPI = operationParser.parse(apiOperation, operation, openAPI, methodAttributes);
199199
}
200200

201201
// compute tags
@@ -211,7 +211,7 @@ protected void calculatePath(HandlerMethod handlerMethod, String operationPath,
211211
methodAttributes.getJsonViewAnnotationForRequestBody())
212212
.ifPresent(operation::setRequestBody);
213213
// requests
214-
operation = requestBuilder.build(components, handlerMethod, requestMethod, operation, methodAttributes, openAPI);
214+
operation = requestBuilder.build(handlerMethod, requestMethod, operation, methodAttributes, openAPI);
215215

216216
// responses
217217
ApiResponses apiResponses = responseBuilder.build(components, handlerMethod, operation, methodAttributes);
@@ -221,7 +221,7 @@ protected void calculatePath(HandlerMethod handlerMethod, String operationPath,
221221

222222
// callbacks
223223
if (!CollectionUtils.isEmpty(apiCallbacks)) {
224-
operationParser.buildCallbacks(apiCallbacks, components, openAPI, methodAttributes)
224+
operationParser.buildCallbacks(apiCallbacks, openAPI, methodAttributes)
225225
.ifPresent(operation::setCallbacks);
226226
}
227227

springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractRequestBuilder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ protected AbstractRequestBuilder(GenericParameterBuilder parameterBuilder, Reque
134134
}
135135

136136

137-
public Operation build(Components components, HandlerMethod handlerMethod, RequestMethod requestMethod,
137+
public Operation build(HandlerMethod handlerMethod, RequestMethod requestMethod,
138138
Operation operation, MethodAttributes methodAttributes, OpenAPI openAPI) {
139139
// Documentation
140140
String operationId = operationBuilder.getOperationId(handlerMethod.getMethod().getName(),
@@ -152,6 +152,7 @@ public Operation build(Components components, HandlerMethod handlerMethod, Reque
152152
List<Parameter> operationParameters = (operation.getParameters() != null) ? operation.getParameters()
153153
: new ArrayList<>();
154154
Map<String, io.swagger.v3.oas.annotations.Parameter> parametersDocMap = getApiParameters(handlerMethod.getMethod());
155+
Components components = openAPI.getComponents();
155156

156157
for (int i = 0; i < pNames.length; i++) {
157158
// check if query param

springdoc-openapi-common/src/main/java/org/springdoc/core/OpenAPIBuilder.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,6 @@ public static String splitCamelCase(String str) {
128128
.toLowerCase(Locale.ROOT);
129129
}
130130

131-
public Components getComponents() {
132-
return calculatedOpenAPI.getComponents();
133-
}
134-
135-
public Paths getPaths() {
136-
return calculatedOpenAPI.getPaths();
137-
}
138-
139131
public void build() {
140132
Optional<OpenAPIDefinition> apiDef = getOpenAPIDefinition();
141133

springdoc-openapi-common/src/main/java/org/springdoc/core/OperationBuilder.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ public OperationBuilder(GenericParameterBuilder parameterBuilder, RequestBodyBui
7676
this.propertyResolverUtils = propertyResolverUtils;
7777
}
7878

79-
public OpenAPI parse(Components components, io.swagger.v3.oas.annotations.Operation apiOperation,
79+
public OpenAPI parse(io.swagger.v3.oas.annotations.Operation apiOperation,
8080
Operation operation, OpenAPI openAPI, MethodAttributes methodAttributes) {
81+
Components components = openAPI.getComponents();
8182
if (StringUtils.isNotBlank(apiOperation.summary())) {
8283
operation.setSummary(propertyResolverUtils.resolve(apiOperation.summary()));
8384
}
@@ -132,7 +133,7 @@ public boolean isHidden(Method method) {
132133
}
133134

134135
public Optional<Map<String, Callback>> buildCallbacks(
135-
Set<io.swagger.v3.oas.annotations.callbacks.Callback> apiCallbacks, Components components, OpenAPI openAPI,
136+
Set<io.swagger.v3.oas.annotations.callbacks.Callback> apiCallbacks, OpenAPI openAPI,
136137
MethodAttributes methodAttributes) {
137138
Map<String, Callback> callbacks = new LinkedHashMap<>();
138139

@@ -157,7 +158,7 @@ public Optional<Map<String, Callback>> buildCallbacks(
157158
PathItem pathItemObject = new PathItem();
158159
for (io.swagger.v3.oas.annotations.Operation callbackOperation : methodCallback.operation()) {
159160
Operation callbackNewOperation = new Operation();
160-
parse(components, callbackOperation, callbackNewOperation, openAPI, methodAttributes);
161+
parse(callbackOperation, callbackNewOperation, openAPI, methodAttributes);
161162
setPathItemOperation(pathItemObject, callbackOperation.method(), callbackNewOperation);
162163
}
163164
callbackObject.addPathItem(methodCallback.callbackUrlExpression(), pathItemObject);

0 commit comments

Comments
 (0)