Skip to content

Commit e22d079

Browse files
authored
ensure correct value for hasParams (#21209)
* turn hasParams into getter * restore hasRequiredParams
1 parent d38898a commit e22d079

8 files changed

+11
-14
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenOperation.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
public class CodegenOperation {
2626
public final List<CodegenProperty> responseHeaders = new ArrayList<CodegenProperty>();
27-
public boolean hasAuthMethods, hasConsumes, hasProduces, hasParams, hasOptionalParams, hasRequiredParams,
27+
public boolean hasAuthMethods, hasConsumes, hasProduces, hasOptionalParams, hasRequiredParams,
2828
returnTypeIsPrimitive, returnSimpleType, subresourceOperation, isMap,
2929
isArray, isMultipart, isVoid = false,
3030
hasVersionHeaders = false, hasVersionQueryParams = false,
@@ -81,6 +81,15 @@ private static boolean nonEmpty(Map<?, ?> params) {
8181
return params != null && !params.isEmpty();
8282
}
8383

84+
/**
85+
* Check if there's at least one parameter
86+
*
87+
* @return true if parameter exists, false otherwise
88+
*/
89+
public boolean getHasParams() {
90+
return nonEmpty(allParams);
91+
}
92+
8493
/**
8594
* Check if there's at least one body parameter
8695
*
@@ -362,7 +371,6 @@ public String toString() {
362371
sb.append(", hasAuthMethods=").append(hasAuthMethods);
363372
sb.append(", hasConsumes=").append(hasConsumes);
364373
sb.append(", hasProduces=").append(hasProduces);
365-
sb.append(", hasParams=").append(hasParams);
366374
sb.append(", hasOptionalParams=").append(hasOptionalParams);
367375
sb.append(", hasRequiredParams=").append(hasRequiredParams);
368376
sb.append(", returnTypeIsPrimitive=").append(returnTypeIsPrimitive);
@@ -445,7 +453,6 @@ public boolean equals(Object o) {
445453
return hasAuthMethods == that.hasAuthMethods &&
446454
hasConsumes == that.hasConsumes &&
447455
hasProduces == that.hasProduces &&
448-
hasParams == that.hasParams &&
449456
hasOptionalParams == that.hasOptionalParams &&
450457
hasRequiredParams == that.hasRequiredParams &&
451458
returnTypeIsPrimitive == that.returnTypeIsPrimitive &&
@@ -522,7 +529,7 @@ public boolean equals(Object o) {
522529
@Override
523530
public int hashCode() {
524531

525-
return Objects.hash(responseHeaders, hasAuthMethods, hasConsumes, hasProduces, hasParams, hasOptionalParams,
532+
return Objects.hash(responseHeaders, hasAuthMethods, hasConsumes, hasProduces, hasOptionalParams,
526533
hasRequiredParams, returnTypeIsPrimitive, returnSimpleType, subresourceOperation, isMap,
527534
isArray, isMultipart, isVoid, isResponseBinary, isResponseFile, isResponseOptional, hasReference,
528535
hasDefaultResponse, hasOnlyDefaultResponse, isRestfulIndex, isRestfulShow, isRestfulCreate, isRestfulUpdate, isRestfulDestroy,

modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4834,9 +4834,6 @@ public CodegenOperation fromOperation(String path,
48344834
// legacy support
48354835
op.nickname = op.operationId;
48364836

4837-
if (op.allParams.size() > 0) {
4838-
op.hasParams = true;
4839-
}
48404837
op.hasRequiredParams = op.requiredParams.size() > 0;
48414838

48424839
// check if the operation has only a single parameter
@@ -8678,6 +8675,5 @@ protected void handleConstantParams(CodegenOperation operation) {
86788675
operation.allParams.add(p);
86798676
}
86808677
}
8681-
operation.hasParams = !operation.allParams.isEmpty();
86828678
}
86838679
}

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2386,7 +2386,6 @@ protected void handleImplicitHeaders(CodegenOperation operation) {
23862386
operation.allParams.add(p);
23872387
}
23882388
}
2389-
operation.hasParams = !operation.allParams.isEmpty();
23902389
}
23912390

23922391
private boolean shouldBeImplicitHeader(CodegenParameter parameter) {

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElixirClientCodegen.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,6 @@ public ExtendedCodegenOperation(CodegenOperation o) {
712712
this.hasAuthMethods = o.hasAuthMethods;
713713
this.hasConsumes = o.hasConsumes;
714714
this.hasProduces = o.hasProduces;
715-
this.hasParams = o.hasParams;
716715
this.hasOptionalParams = o.hasOptionalParams;
717716
this.returnTypeIsPrimitive = o.returnTypeIsPrimitive;
718717
this.returnSimpleType = o.returnSimpleType;

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ErlangClientCodegen.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,6 @@ public ExtendedCodegenOperation(CodegenOperation o) {
417417
this.hasAuthMethods = o.hasAuthMethods;
418418
this.hasConsumes = o.hasConsumes;
419419
this.hasProduces = o.hasProduces;
420-
this.hasParams = o.hasParams;
421420
this.hasOptionalParams = o.hasOptionalParams;
422421
this.returnTypeIsPrimitive = o.returnTypeIsPrimitive;
423422
this.returnSimpleType = o.returnSimpleType;

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ErlangProperCodegen.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,6 @@ class ExtendedCodegenOperation extends CodegenOperation {
507507
this.hasAuthMethods = o.hasAuthMethods;
508508
this.hasConsumes = o.hasConsumes;
509509
this.hasProduces = o.hasProduces;
510-
this.hasParams = o.hasParams;
511510
this.hasOptionalParams = o.hasOptionalParams;
512511
this.returnTypeIsPrimitive = o.returnTypeIsPrimitive;
513512
this.returnSimpleType = o.returnSimpleType;

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,6 @@ public ExtendedCodegenOperation(CodegenOperation o) {
13791379
this.hasAuthMethods = o.hasAuthMethods;
13801380
this.hasConsumes = o.hasConsumes;
13811381
this.hasProduces = o.hasProduces;
1382-
this.hasParams = o.hasParams;
13831382
this.hasOptionalParams = o.hasOptionalParams;
13841383
this.hasRequiredParams = o.hasRequiredParams;
13851384
this.returnTypeIsPrimitive = o.returnTypeIsPrimitive;

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,6 @@ public ExtendedCodegenOperation(CodegenOperation o) {
348348
this.hasAuthMethods = o.hasAuthMethods;
349349
this.hasConsumes = o.hasConsumes;
350350
this.hasProduces = o.hasProduces;
351-
this.hasParams = o.hasParams;
352351
this.hasOptionalParams = o.hasOptionalParams;
353352
this.hasRequiredParams = o.hasRequiredParams;
354353
this.returnTypeIsPrimitive = o.returnTypeIsPrimitive;

0 commit comments

Comments
 (0)