Skip to content

Commit 510eac0

Browse files
author
springdoc
committed
project update
1 parent 05fae35 commit 510eac0

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

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

+23-13
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,16 @@ protected void calculatePath(OpenAPIBuilder openAPIBuilder, HandlerMethod handle
126126
handlerMethod.getMethod(), io.swagger.v3.oas.annotations.parameters.RequestBody.class);
127127

128128
// RequestBody in Operation
129-
requestBodyBuilder.buildRequestBodyFromDoc(requestBodyDoc, methodAttributes.getClassConsumes(),
130-
methodAttributes.getMethodConsumes(), components, null).ifPresent(operation::setRequestBody);
129+
requestBodyBuilder
130+
.buildRequestBodyFromDoc(requestBodyDoc, methodAttributes.getClassConsumes(),
131+
methodAttributes.getMethodConsumes(), components, null)
132+
.ifPresent(operation::setRequestBody);
131133

132134
// requests
133135
operation = requestBuilder.build(components, handlerMethod, requestMethod, operation, methodAttributes);
134136

135137
// responses
136-
ApiResponses apiResponses = responseBuilder.build(components, handlerMethod, operation,
137-
methodAttributes);
138+
ApiResponses apiResponses = responseBuilder.build(components, handlerMethod, operation, methodAttributes);
138139
operation.setResponses(apiResponses);
139140

140141
List<io.swagger.v3.oas.annotations.callbacks.Callback> apiCallbacks = ReflectionUtils
@@ -156,22 +157,31 @@ private Operation getExistingOperation(Map<HttpMethod, Operation> operationMap,
156157
Operation existingOperation = null;
157158
if (!CollectionUtils.isEmpty(operationMap)) {
158159
// Get existing operation definition
159-
if (RequestMethod.GET.equals(requestMethod)) {
160+
switch (requestMethod) {
161+
case GET:
160162
existingOperation = operationMap.get(HttpMethod.GET);
161-
} else if (RequestMethod.POST.equals(requestMethod)) {
163+
break;
164+
case POST:
162165
existingOperation = operationMap.get(HttpMethod.POST);
163-
} else if (RequestMethod.PUT.equals(requestMethod)) {
166+
break;
167+
case PUT:
164168
existingOperation = operationMap.get(HttpMethod.PUT);
165-
} else if (RequestMethod.DELETE.equals(requestMethod)) {
169+
break;
170+
case DELETE:
166171
existingOperation = operationMap.get(HttpMethod.DELETE);
167-
} else if (RequestMethod.PATCH.equals(requestMethod)) {
172+
break;
173+
case PATCH:
168174
existingOperation = operationMap.get(HttpMethod.PATCH);
169-
} else if (RequestMethod.TRACE.equals(requestMethod)) {
170-
existingOperation = operationMap.get(HttpMethod.TRACE);
171-
} else if (RequestMethod.HEAD.equals(requestMethod)) {
175+
break;
176+
case HEAD:
172177
existingOperation = operationMap.get(HttpMethod.HEAD);
173-
} else if (RequestMethod.OPTIONS.equals(requestMethod)) {
178+
break;
179+
case OPTIONS:
174180
existingOperation = operationMap.get(HttpMethod.OPTIONS);
181+
break;
182+
default:
183+
// Do nothing here
184+
break;
175185
}
176186
}
177187
return existingOperation;

0 commit comments

Comments
 (0)