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. Fixesspringdoc#2817
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, or the child
field is specifically set as required in the Schema or Parameter
annotation.
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