Skip to content

Commit

Permalink
fix string compare in haskell generator (#18410)
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 authored Apr 17, 2024
1 parent dd97def commit 7609273
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,14 @@ public void preprocessOpenAPI(OpenAPI openAPI) {

/**
* Internal method to set the generateToSchema parameter.
*
* <p>
* Basically we're generating ToSchema instances (generically) for all schemas.
* However, if any of the contained datatypes doesn't have the ToSchema instance,
* we cannot generate it for its "ancestor" type.
* This is the case with the "Data.Aeson.Value" type: it doesn't (and cannot) have
* a Swagger-compatible ToSchema instance. So we have to detect its presence "downstream"
* the current schema, and if we find it we just don't generate any ToSchema instance.
*
* @param model
*/
private void setGenerateToSchema(CodegenModel model) {
Expand All @@ -356,7 +357,7 @@ private void setGenerateToSchema(CodegenModel model) {

List<CodegenModel> children = model.getChildren();
if (children != null) {
for(CodegenModel child : children) {
for (CodegenModel child : children) {
setGenerateToSchema(child);
}
}
Expand Down Expand Up @@ -512,7 +513,7 @@ public CodegenOperation fromOperation(String resourcePath, String httpMethod, Op
// Query parameters appended to routes
for (CodegenParameter param : op.queryParams) {
String paramType = param.dataType;
if (param.contentType == "application/json") {
if ("application/json".equals(param.contentType)) {
if (param.isArray) {
paramType = "[JSONQueryParam " + paramType.substring(1, paramType.length() - 1) + "]";
} else {
Expand Down Expand Up @@ -554,7 +555,7 @@ public CodegenOperation fromOperation(String resourcePath, String httpMethod, Op
path.add("Header \"" + param.baseName + "\" " + param.dataType);

String paramType = param.dataType;
if (param.contentType == "application/json") {
if ("application/json".equals(param.contentType)) {
if (param.isArray) {
paramType = "(JSONQueryParam " + paramType.substring(1, paramType.length() - 1) + ")";
} else {
Expand Down Expand Up @@ -721,5 +722,7 @@ public void postProcessFile(File file, String fileType) {
}

@Override
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.HASKELL; }
public GeneratorLanguage generatorLanguage() {
return GeneratorLanguage.HASKELL;
}
}

0 comments on commit 7609273

Please sign in to comment.