From c5292a9d54cadaf100791f7313c9d3ad9301aa0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Magalh=C3=A3es?= Date: Mon, 16 Dec 2024 16:09:33 -0300 Subject: [PATCH] fix: natural order of parameters Issues #2092 and #1957. Fixes the natural ordering inconsistency when the @Parameters annotation is not used. Method parameters and BeanParam were sorted in alphabetical order if they were not declared with @Parameter within the @Parameters annotation. --- .../runtime/scanner/spi/AbstractParameterProcessor.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/io/smallrye/openapi/runtime/scanner/spi/AbstractParameterProcessor.java b/core/src/main/java/io/smallrye/openapi/runtime/scanner/spi/AbstractParameterProcessor.java index e3c8d58ee..e256f957d 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/scanner/spi/AbstractParameterProcessor.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/scanner/spi/AbstractParameterProcessor.java @@ -110,7 +110,7 @@ public abstract class AbstractParameterProcessor { protected Map> matrixParams = new LinkedHashMap<>(); private Set processedMatrixSegments = new HashSet<>(); - private List preferredOrder; + private List preferredOrder = new ArrayList<>(); /** * Used for collecting and merging any scanned {@link Parameter} annotations @@ -234,6 +234,7 @@ protected void reset() { params.clear(); formParams.clear(); matrixParams.clear(); + preferredOrder.clear(); } protected ResourceParameters process(ClassInfo resourceClass, MethodInfo resourceMethod) { @@ -1373,6 +1374,10 @@ protected void readParameter(ParameterContextKey key, } if (preferredOrder != null) { + if (context.oaiParam == null && context.name != null) { + context.oaiParam = new ParameterImpl(); + context.oaiParam.setName(context.name); + } preferredOrder.add(context.oaiParam); } }