-
-
Notifications
You must be signed in to change notification settings - Fork 7k
[BUG] [Spring] Invalid Interface generation when parameters are removed by x-spring-paginated #21274
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
Comments
so it's no longer an issue with the latest master? so the issue was uncovered with v7.13.0 ? |
@wing328, so it seems. I looked around issues and commits in the v7.13.0 to master diff but I guess I'm not familiar enough with the repo to understand what might have changed to remove the issue from master. Test with v7.13.0Command docker container run --rm -v "${pwd}:/local" openapitools/openapi-generator-cli:v7.13.0 generate -i /local/src/main/resources/openapi/parameters-issue.yaml -g spring -o /local/out -p interfaceOnly=true,skipDefaultInterface=true,useSpringBoot3=true,reactive=true,delegatePattern=true,dateLibrary=java8,useResponseEntity=false Generated class/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.13.0).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.api;
import org.springframework.data.domain.Pageable;
import org.springdoc.core.annotations.ParameterObject;
import org.openapitools.model.ResourceListResponse;
import io.swagger.v3.oas.annotations.ExternalDocumentation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import org.springframework.http.codec.multipart.Part;
import jakarta.validation.Valid;
import jakarta.validation.constraints.*;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import jakarta.annotation.Generated;
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2025-05-13T12:24:42.553318647Z[Etc/UTC]", comments = "Generator version: 7.13.0")
@Validated
@Tag(name = "resource", description = "the resource API")
public interface ResourceApi {
/**
* GET /resource : Retrieves a resource with pagination parameters
* Retrieves a resource with pagination parameters
*
* @return Successful operation (status code 200)
*/
@Operation(
operationId = "retrieveResource",
summary = "Retrieves a resource with pagination parameters",
description = "Retrieves a resource with pagination parameters",
responses = {
@ApiResponse(responseCode = "200", description = "Successful operation", content = {
@Content(mediaType = "application/json", schema = @Schema(implementation = ResourceListResponse.class))
})
}
)
@RequestMapping(
method = RequestMethod.GET,
value = "/resource",
produces = { "application/json" }
)
@ResponseStatus(HttpStatus.OK)
Mono<ResourceListResponse> _retrieveResource(
,
@Parameter(hidden = true) final ServerWebExchange exchange,
@ParameterObject final Pageable pageable
);
} Test with masterCommanddocker container run --rm -v "${pwd}:/local" openapitools/openapi-generator-cli:latest generate -i /local/src/main/resources/openapi/parameters-issue.yaml -g spring -o /local/out -p interfaceOnly=true,skipDefaultInterface=true,useSpringBoot3=true,reactive=true,delegatePattern=true,dateLibrary=java8,useResponseEntity=false Generated class/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.14.0-SNAPSHOT).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.api;
import org.springframework.data.domain.Pageable;
import org.springdoc.core.annotations.ParameterObject;
import org.openapitools.model.ResourceListResponse;
import io.swagger.v3.oas.annotations.ExternalDocumentation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import org.springframework.http.codec.multipart.Part;
import jakarta.validation.Valid;
import jakarta.validation.constraints.*;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import jakarta.annotation.Generated;
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2025-05-13T12:23:10.289906160Z[Etc/UTC]", comments = "Generator version: 7.14.0-SNAPSHOT")
@Validated
@Tag(name = "resource", description = "the resource API")
public interface ResourceApi {
/**
* GET /resource : Retrieves a resource with pagination parameters
* Retrieves a resource with pagination parameters
*
* @return Successful operation (status code 200)
*/
@Operation(
operationId = "retrieveResource",
summary = "Retrieves a resource with pagination parameters",
description = "Retrieves a resource with pagination parameters",
responses = {
@ApiResponse(responseCode = "200", description = "Successful operation", content = {
@Content(mediaType = "application/json", schema = @Schema(implementation = ResourceListResponse.class))
})
}
)
@RequestMapping(
method = RequestMethod.GET,
value = "/resource",
produces = { "application/json" }
)
@ResponseStatus(HttpStatus.OK)
Mono<ResourceListResponse> _retrieveResource(
@Parameter(hidden = true) final ServerWebExchange exchange,@ParameterObject final Pageable pageable
);
} |
Bug Report Checklist
Description
The interface for an API that is annotated with
x-spring-paginated
and has no other query parameters than page and size is generated with a method parameter list that contains an extra comma (,
), causing compilation errors.The expected class should not have the extra comma.
Passing extra parameters, any empty array of parameters or no parameters at all doesn't cause the issue.
No validation problems.
It seems that is working on the latest master but don't see any changes to the spring generator classes done after release 7.13.0.
No validation issues for the spec:
openapi-generator version
OpenAPI declaration file content or url
Generation Details
Configuration:
Steps to reproduce
src/main/resources/openapi/parameters-issue.yaml
mvn openapi-generator:generate@generate-parameters-issue-api
Related issues/PRs
I wasn't able to find any similar issue
Suggest a fix
Might it be that the way the pageable-related parameters are removed leaves the list in a state that is not considered completely empty by the template that renders the class?
The text was updated successfully, but these errors were encountered: