Skip to content

Commit

Permalink
minor fixes to haskell http client generator (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 committed May 1, 2018
1 parent 9cb2f84 commit 4bc99b9
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ public String getSchemaType(Schema p) {

if (typeMapping.containsKey(openAPIType)) {
return typeMapping.get(openAPIType);
} else if (openAPIType == "object") {
} else if ("object".equals(openAPIType)) {
return "A.Value";
} else {
return toModelName(openAPIType);
Expand All @@ -564,8 +564,7 @@ public String toInstantiationType(Schema p) {
return "(Map.Map Text " + inner + ")";
} else if (ModelUtils.isArraySchema(p)) {
ArraySchema ap = (ArraySchema) p;
String inner = getSchemaType(ap.getItems());
return inner;
return getSchemaType(ap.getItems());
} else {
return null;
}
Expand All @@ -575,7 +574,7 @@ public String toInstantiationType(Schema p) {
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation op, Map<String, List<CodegenOperation>> operations) {

List<CodegenOperation> opList = operations.get(tag);
if (opList == null) {
if (opList == null || opList.isEmpty()) {
opList = new ArrayList<CodegenOperation>();
operations.put(tag, opList);
}
Expand Down Expand Up @@ -797,7 +796,7 @@ private void processReturnType(CodegenOperation op) {
}
}
}
if (returnType.indexOf(" ") >= 0) {
if (returnType.contains(" ")) {
returnType = "(" + returnType + ")";
}
op.vendorExtensions.put(X_RETURN_TYPE, returnType);
Expand Down Expand Up @@ -829,8 +828,8 @@ private void processInlineConsumesContentType(CodegenOperation op, Map<String, S
if (op.vendorExtensions.containsKey(X_INLINE_CONTENT_TYPE)) return;
if ((boolean) additionalProperties.get(PROP_INLINE_MIME_TYPES)
&& op.consumes.size() == 1
&& op.consumes.get(0).get(X_MEDIA_DATA_TYPE) != MIME_ANY
&& op.consumes.get(0).get(X_MEDIA_DATA_TYPE) != MIME_NO_CONTENT) {
&& !MIME_ANY.equals(op.consumes.get(0).get(X_MEDIA_DATA_TYPE))
&& !MIME_NO_CONTENT.equals(op.consumes.get(0).get(X_MEDIA_DATA_TYPE))) {
op.vendorExtensions.put(X_INLINE_CONTENT_TYPE, m);
for (CodegenParameter param : op.allParams) {
if (param.isBodyParam && param.required) {
Expand All @@ -843,8 +842,8 @@ private void processInlineConsumesContentType(CodegenOperation op, Map<String, S
private void processInlineProducesContentType(CodegenOperation op, Map<String, String> m) {
if ((boolean) additionalProperties.get(PROP_INLINE_MIME_TYPES)
&& op.produces.size() == 1
&& op.produces.get(0).get(X_MEDIA_DATA_TYPE) != MIME_ANY
&& op.produces.get(0).get(X_MEDIA_DATA_TYPE) != MIME_NO_CONTENT) {
&& !MIME_ANY.equals(op.produces.get(0).get(X_MEDIA_DATA_TYPE))
&& !MIME_NO_CONTENT.equals(op.produces.get(0).get(X_MEDIA_DATA_TYPE))) {
op.vendorExtensions.put(X_INLINE_ACCEPT, m);
}
}
Expand Down

0 comments on commit 4bc99b9

Please sign in to comment.