Skip to content

ensure correct value for hasParams #21209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

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

/**
* Check if there's at least one parameter
*
* @return true if parameter exists, false otherwise
*/
public boolean getHasParams() {
return nonEmpty(allParams);
}

/**
* Check if there's at least one body parameter
*
Expand Down Expand Up @@ -362,7 +371,6 @@ public String toString() {
sb.append(", hasAuthMethods=").append(hasAuthMethods);
sb.append(", hasConsumes=").append(hasConsumes);
sb.append(", hasProduces=").append(hasProduces);
sb.append(", hasParams=").append(hasParams);
sb.append(", hasOptionalParams=").append(hasOptionalParams);
sb.append(", hasRequiredParams=").append(hasRequiredParams);
sb.append(", returnTypeIsPrimitive=").append(returnTypeIsPrimitive);
Expand Down Expand Up @@ -445,7 +453,6 @@ public boolean equals(Object o) {
return hasAuthMethods == that.hasAuthMethods &&
hasConsumes == that.hasConsumes &&
hasProduces == that.hasProduces &&
hasParams == that.hasParams &&
hasOptionalParams == that.hasOptionalParams &&
hasRequiredParams == that.hasRequiredParams &&
returnTypeIsPrimitive == that.returnTypeIsPrimitive &&
Expand Down Expand Up @@ -522,7 +529,7 @@ public boolean equals(Object o) {
@Override
public int hashCode() {

return Objects.hash(responseHeaders, hasAuthMethods, hasConsumes, hasProduces, hasParams, hasOptionalParams,
return Objects.hash(responseHeaders, hasAuthMethods, hasConsumes, hasProduces, hasOptionalParams,
hasRequiredParams, returnTypeIsPrimitive, returnSimpleType, subresourceOperation, isMap,
isArray, isMultipart, isVoid, isResponseBinary, isResponseFile, isResponseOptional, hasReference,
hasDefaultResponse, hasOnlyDefaultResponse, isRestfulIndex, isRestfulShow, isRestfulCreate, isRestfulUpdate, isRestfulDestroy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4834,9 +4834,6 @@ public CodegenOperation fromOperation(String path,
// legacy support
op.nickname = op.operationId;

if (op.allParams.size() > 0) {
op.hasParams = true;
}
op.hasRequiredParams = op.requiredParams.size() > 0;

// check if the operation has only a single parameter
Expand Down Expand Up @@ -8678,6 +8675,5 @@ protected void handleConstantParams(CodegenOperation operation) {
operation.allParams.add(p);
}
}
operation.hasParams = !operation.allParams.isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2386,7 +2386,6 @@ protected void handleImplicitHeaders(CodegenOperation operation) {
operation.allParams.add(p);
}
}
operation.hasParams = !operation.allParams.isEmpty();
}

private boolean shouldBeImplicitHeader(CodegenParameter parameter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,6 @@ public ExtendedCodegenOperation(CodegenOperation o) {
this.hasAuthMethods = o.hasAuthMethods;
this.hasConsumes = o.hasConsumes;
this.hasProduces = o.hasProduces;
this.hasParams = o.hasParams;
this.hasOptionalParams = o.hasOptionalParams;
this.returnTypeIsPrimitive = o.returnTypeIsPrimitive;
this.returnSimpleType = o.returnSimpleType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ public ExtendedCodegenOperation(CodegenOperation o) {
this.hasAuthMethods = o.hasAuthMethods;
this.hasConsumes = o.hasConsumes;
this.hasProduces = o.hasProduces;
this.hasParams = o.hasParams;
this.hasOptionalParams = o.hasOptionalParams;
this.returnTypeIsPrimitive = o.returnTypeIsPrimitive;
this.returnSimpleType = o.returnSimpleType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,6 @@ class ExtendedCodegenOperation extends CodegenOperation {
this.hasAuthMethods = o.hasAuthMethods;
this.hasConsumes = o.hasConsumes;
this.hasProduces = o.hasProduces;
this.hasParams = o.hasParams;
this.hasOptionalParams = o.hasOptionalParams;
this.returnTypeIsPrimitive = o.returnTypeIsPrimitive;
this.returnSimpleType = o.returnSimpleType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,6 @@ public ExtendedCodegenOperation(CodegenOperation o) {
this.hasAuthMethods = o.hasAuthMethods;
this.hasConsumes = o.hasConsumes;
this.hasProduces = o.hasProduces;
this.hasParams = o.hasParams;
this.hasOptionalParams = o.hasOptionalParams;
this.hasRequiredParams = o.hasRequiredParams;
this.returnTypeIsPrimitive = o.returnTypeIsPrimitive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ public ExtendedCodegenOperation(CodegenOperation o) {
this.hasAuthMethods = o.hasAuthMethods;
this.hasConsumes = o.hasConsumes;
this.hasProduces = o.hasProduces;
this.hasParams = o.hasParams;
this.hasOptionalParams = o.hasOptionalParams;
this.hasRequiredParams = o.hasRequiredParams;
this.returnTypeIsPrimitive = o.returnTypeIsPrimitive;
Expand Down
Loading