-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Parameter order is not preserved #3392
Comments
Also previous fix that doesn't work anymore #2721 |
only for information I mean ordering property inside response/request model |
There is another issue for that too 👍 |
I would propose removing the implicit sorting done in |
That would be awesome @roookeee. As of today, the parameter does preserve the as-is sorting, it sorts on parameter index if Im not mistaken. That order is disturbed only via plugins changing that. |
Okay I will have to recheck which one is "breaking" the default order then. |
Found the issue: you are correct that the order is honored but it's actually not set to the parameter index but left as the default which is the highest precedence for all parameters which leads the current code to only sort alphabetically by name again. I will do a PR to fix this and set the order to the parameter index. The comment in the linked non-working PR is fixing this issue by the way: import org.springframework.core.Ordered;
import springfox.documentation.service.ResolvedMethodParameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.ParameterBuilderPlugin;
import springfox.documentation.spi.service.contexts.ParameterContext;
public class ParameterIndexOrderReader implements ParameterBuilderPlugin {
private static final int PARAMETER_INITIAL_ORDER = Ordered.HIGHEST_PRECEDENCE;
@Override
public boolean supports(DocumentationType delimiter) {
return true;
}
@Override
public void apply(ParameterContext context) {
ResolvedMethodParameter methodParameter = context.resolvedMethodParameter();
context.parameterBuilder().order(PARAMETER_INITIAL_ORDER + methodParameter.getParameterIndex());
}
} Should I implement it like this or leave the order of the parameters untouched if I detect that another plugin customized the parameter order already (e.g. checking if all parameters still have |
I agree that this is the right approach, but I would like to point out that the context.requestParameterBuilder().parameterIndex(PARAMETER_INITIAL_ORDER + methodParameter.getParameterIndex()); Although the data structure EDIT: The |
My current workaround for this is to make a copy
... and then to have this ahead of the springfox library in the A pretty fragile workaround, but at least it gets me past this hump. |
Came up with an idea of how to sort parameters by using
|
Please update on this issue. |
We finally moved to springdoc. Everyone, please consider moving to springdoc, kindy suggesting :) |
looks still broken
Originally posted by @schrek1 in #2705 (comment)
The text was updated successfully, but these errors were encountered: