Skip to content

Commit

Permalink
[core] Prevent NPE when enpoint did not define responses (#1617)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekc authored and jmini committed Dec 7, 2018
1 parent 774013c commit 922532d
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,7 @@
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import java.util.Map;
import java.util.*;
import java.util.regex.Pattern;

import static org.openapitools.codegen.utils.StringUtils.escape;
Expand Down Expand Up @@ -1036,6 +1028,7 @@ public void preprocessOpenAPI(OpenAPI openAPI) {
continue;
}
for (Operation operation : path.readOperations()) {
LOGGER.info("Processing operation " + operation.getOperationId());
if (hasBodyParameter(openAPI, operation) || hasFormParameter(openAPI, operation)) {
String defaultContentType = hasFormParameter(openAPI, operation) ? "application/x-www-form-urlencoded" : "application/json";
List<String> consumes = new ArrayList<String>(getConsumesInfo(openAPI, operation));
Expand All @@ -1052,8 +1045,9 @@ public void preprocessOpenAPI(OpenAPI openAPI) {
protected static String getAccept(OpenAPI openAPI, Operation operation) {
String accepts = null;
String defaultContentType = "application/json";
ArrayList<String> produces = new ArrayList<String>(getProducesInfo(openAPI, operation));
if (produces != null && !produces.isEmpty()) {
Set<String> producesInfo = getProducesInfo(openAPI, operation);
if (producesInfo != null && !producesInfo.isEmpty()) {
ArrayList<String> produces = new ArrayList<String>(producesInfo);
StringBuilder sb = new StringBuilder();
for (String produce : produces) {
if (defaultContentType.equalsIgnoreCase(produce)) {
Expand Down

0 comments on commit 922532d

Please sign in to comment.