|
1 | 1 | /*
|
2 |
| - * Copyright 2014-2020 the original author or authors. |
| 2 | + * Copyright 2014-2022 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
23 | 23 | import java.util.List;
|
24 | 24 | import java.util.Map;
|
25 | 25 | import java.util.Map.Entry;
|
| 26 | +import java.util.Set; |
| 27 | +import java.util.stream.Collectors; |
26 | 28 |
|
27 | 29 | import org.springframework.http.HttpHeaders;
|
28 | 30 | import org.springframework.http.HttpMethod;
|
@@ -151,16 +153,20 @@ private boolean isPutOrPost(OperationRequest request) {
|
151 | 153 |
|
152 | 154 | private void writeParts(OperationRequest request, PrintWriter writer) {
|
153 | 155 | writer.println();
|
| 156 | + Set<String> partNames = request.getParts().stream().map(OperationRequestPart::getName) |
| 157 | + .collect(Collectors.toSet()); |
154 | 158 | for (Entry<String, List<String>> parameter : request.getParameters().entrySet()) {
|
155 |
| - if (parameter.getValue().isEmpty()) { |
156 |
| - writePartBoundary(writer); |
157 |
| - writePart(parameter.getKey(), "", null, null, writer); |
158 |
| - } |
159 |
| - else { |
160 |
| - for (String value : parameter.getValue()) { |
| 159 | + if (!partNames.contains(parameter.getKey())) { |
| 160 | + if (parameter.getValue().isEmpty()) { |
161 | 161 | writePartBoundary(writer);
|
162 |
| - writePart(parameter.getKey(), value, null, null, writer); |
163 |
| - writer.println(); |
| 162 | + writePart(parameter.getKey(), "", null, null, writer); |
| 163 | + } |
| 164 | + else { |
| 165 | + for (String value : parameter.getValue()) { |
| 166 | + writePartBoundary(writer); |
| 167 | + writePart(parameter.getKey(), value, null, null, writer); |
| 168 | + writer.println(); |
| 169 | + } |
164 | 170 | }
|
165 | 171 | }
|
166 | 172 | }
|
|
0 commit comments