Skip to content
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

Maven plugin should be configurable regarding the order of the parameters in a REST endpoint #1957

Open
cristalp opened this issue Aug 22, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@cristalp
Copy link
Contributor

cristalp commented Aug 22, 2024

We use Swagger annotations and a different Maven plugin to generate OpenAPI from our Java code. But we want to migrate to Eclipse MicroProfile annotations and the Smallrye toolchain.

There is a difference in the generated OpenAPI regarding the order of the parameters in a REST endpoint.

For instance:

  public Response endpoint(
      @Parameter(description = "The foo") @PathParam("foo") final String foo,
      @Parameter(description = "The bar") @PathParam("bar") final String bar) {
    return null;
  }
  • The Swagger toolchain lists parameters as they are defined in the Java code. So OpenAPI first contains foo and then bar.
  • The Smallrye toolchain lists parameters alphabetically. So OpenAPI first contains bar and then foo.

While this could be called nitpicking, I do believe that the order of the parameters is important. Main parameters (like an ID) should come first and optional parameters should come later.

In order not to break existing behavior, the Maven plugin should contain a flag defining how parameters are sorted. For instance orderParametersAlphabetically which defaults to true. If it's false, the order is defined by their order in the Java code.

@MikeEdgar
Copy link
Member

This is a reasonable request. We currently support it when @Parameter is on the method rather than the arguments, but that results in duplication because the name at least is needed on the @Parameter to link it to the correct argument.

@MikeEdgar MikeEdgar added the enhancement New feature or request label Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants