Simplified the header merge logic
(2011)
@@ -32,16 +32,13 @@ import springfox.documentation.service.Parameter;
import springfox.documentation.service.ResponseMessage;
import springfox.documentation.service.SecurityReference;
import springfox.documentation.service.VendorExtension;
-import springfox.documentation.service.Header;
import java.util.List;
-import java.util.Map;
import java.util.Set;
-import static com.google.common.base.Strings.*;
+import static com.google.common.base.Strings.emptyToNull;
import static com.google.common.collect.Lists.*;
import static com.google.common.collect.Sets.*;
-import static com.google.common.collect.Maps.*;
import static springfox.documentation.builders.BuilderDefaults.*;
public class OperationBuilder {
@@ -299,19 +296,13 @@ public class OperationBuilder {
ResponseMessage responseMessage = responsesByCode.get(each.getCode());
String message = defaultIfAbsent(emptyToNull(each.getMessage()), responseMessage.getMessage());
ModelReference responseWithModel = defaultIfAbsent(each.getResponseModel(), responseMessage.getResponseModel());
- Map<String, Header> headers = newHashMap();
- if (responseMessage.getHeaders() != null) {
- headers.putAll(responseMessage.getHeaders());
- }
- if (each.getHeaders() != null ){
- headers.putAll(each.getHeaders());
- }
merged.remove(responseMessage);
merged.add(new ResponseMessageBuilder()
.code(each.getCode())
.message(message)
.responseModel(responseWithModel)
- .headersWithDescription(headers)
+ .headersWithDescription(responseMessage.getHeaders())
+ .headersWithDescription(each.getHeaders())
.build());
} else {
merged.add(each);
