You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Obey annotations when flattening ParameterObject fields. Fixes#2787
When creating the flattened parameter definitions for an item annotated
with `@ParameterObject`, the `@Schema` and `@Property` annotations on
any fields prior to the final child-node of each branch of the parameter
tree are not taken into consideration. This results in the field name in
the code being used even where annotations may override that, prevents
the fields being hidden where one of the parent fields is marked as
hidden but the child field isn't hidden, and marks a field as mandatory
even where the field would only be mandatory if the parent object had
been declared through a sibling of the target field being set. To
overcome this, whilst the flattened parameter map is being built, each
field is now being inspected for a `@Parameter` annotation or - where
the `@Parameter` annotation isn't found - a `@Schema` annotation. Where
a custom name is included in either of those annotations then the
overridden field name is used in the flattened definition. If either
annotation declares the field as hidden then the field and all child
fields are removed from the resulting definition, and a field is no
longer set as mandatory unless the parent field was also declared as
mandatory, or resolved as non-null and was set in an automatic state. To
ensure that the post-processing steps don't re-apply `required`
properties on parameters that have purposefully had them removed, the
delegate now tracks any annotations what should not be shown as being on
the parameter, and excludes them from the annotation list during
subsequent calls.
Copy file name to clipboardExpand all lines: springdoc-openapi-starter-common/src/main/java/org/springdoc/core/extractor/DelegatingMethodParameter.java
+19-4
Original file line number
Diff line number
Diff line change
@@ -93,6 +93,11 @@ public class DelegatingMethodParameter extends MethodParameter {
93
93
*/
94
94
privatefinalAnnotation[] methodAnnotations;
95
95
96
+
/**
97
+
* The annotations to mask from the list of annotations on this method parameter.
98
+
*/
99
+
privatefinalAnnotation[] maskedAnnotations;
100
+
96
101
/**
97
102
* The Is not required.
98
103
*/
@@ -105,17 +110,19 @@ public class DelegatingMethodParameter extends MethodParameter {
105
110
* @param parameterName the parameter name
106
111
* @param additionalParameterAnnotations the additional parameter annotations
107
112
* @param methodAnnotations the method annotations
113
+
* @param maskedAnnotations any annotations that should not be included in the final list of annotations
108
114
* @param isParameterObject the is parameter object
Copy file name to clipboardExpand all lines: springdoc-openapi-starter-common/src/main/java/org/springdoc/core/extractor/MethodParameterPojoExtractor.java
0 commit comments