2121 * * * *
2222 * * *
2323 * *
24- *
24+ *
2525 */
2626
2727package org .springdoc .core .customizers ;
3131
3232import io .swagger .v3 .core .util .AnnotationsUtils ;
3333import io .swagger .v3 .oas .annotations .enums .ParameterIn ;
34+ import io .swagger .v3 .oas .models .Components ;
3435import io .swagger .v3 .oas .models .Operation ;
3536import io .swagger .v3 .oas .models .media .Content ;
3637import io .swagger .v3 .oas .models .media .MediaType ;
6162 *
6263 * @author bnasslahsen
6364 */
64- public class ActuatorOperationCustomizer implements GlobalOperationCustomizer {
65+ public class ActuatorOperationCustomizer implements GlobalOperationComponentsCustomizer {
6566
6667 /**
6768 * The constant OPERATION.
@@ -94,11 +95,11 @@ public ActuatorOperationCustomizer(SpringDocConfigProperties springDocConfigProp
9495 }
9596
9697 @ Override
97- public Operation customize (Operation operation , HandlerMethod handlerMethod ) {
98+ public Operation customize (Operation operation , Components components , HandlerMethod handlerMethod ) {
9899 if (operationHasValidTag (operation )) {
99100 Field operationField = FieldUtils .getDeclaredField (handlerMethod .getBean ().getClass (), OPERATION ,true );
100101 if (operationField != null ) {
101- processOperationField (handlerMethod , operation , operationField );
102+ processOperationField (handlerMethod , operation , components , operationField );
102103 }
103104 setOperationSummary (operation , handlerMethod );
104105 }
@@ -120,16 +121,17 @@ private boolean operationHasValidTag(Operation operation) {
120121 *
121122 * @param handlerMethod the handler method
122123 * @param operation the operation
124+ * @param components the components
123125 * @param operationField the operation field
124126 */
125- private void processOperationField (HandlerMethod handlerMethod , Operation operation , Field operationField ) {
127+ private void processOperationField (HandlerMethod handlerMethod , Operation operation , Components components , Field operationField ) {
126128 try {
127129 Object actuatorOperation = operationField .get (handlerMethod .getBean ());
128130 Field actuatorOperationField = FieldUtils .getDeclaredField (actuatorOperation .getClass (), OPERATION , true );
129131 if (actuatorOperationField != null ) {
130132 AbstractDiscoveredOperation discoveredOperation =
131133 (AbstractDiscoveredOperation ) actuatorOperationField .get (actuatorOperation );
132- handleOperationMethod (discoveredOperation .getOperationMethod (), operation );
134+ handleOperationMethod (discoveredOperation .getOperationMethod (), components , operation );
133135 }
134136 }
135137 catch (IllegalAccessException e ) {
@@ -141,25 +143,26 @@ private void processOperationField(HandlerMethod handlerMethod, Operation operat
141143 * Handle operation method.
142144 *
143145 * @param operationMethod the operation method
146+ * @param components the components
144147 * @param operation the operation
145148 */
146- private void handleOperationMethod (OperationMethod operationMethod , Operation operation ) {
149+ private void handleOperationMethod (OperationMethod operationMethod , Components components , Operation operation ) {
147150 String operationId = operationMethod .getMethod ().getName ();
148151 operation .setOperationId (operationId );
149152
150153 switch (operationMethod .getOperationType ()) {
151154 case READ :
152- addParameters (operationMethod , operation , ParameterIn .QUERY );
155+ addParameters (operationMethod , operation , components , ParameterIn .QUERY );
153156 break ;
154157 case WRITE :
155- addWriteParameters (operationMethod , operation );
158+ addWriteParameters (operationMethod ,components , operation );
156159 operation .setResponses (new ApiResponses ()
157160 .addApiResponse (String .valueOf (HttpStatus .NO_CONTENT .value ()), new ApiResponse ().description (HttpStatus .NO_CONTENT .getReasonPhrase ()))
158161 .addApiResponse (String .valueOf (HttpStatus .BAD_REQUEST .value ()), new ApiResponse ().description (HttpStatus .BAD_REQUEST .getReasonPhrase ())));
159162 break ;
160163 case DELETE :
161164 operation .setResponses (new ApiResponses ().addApiResponse (String .valueOf (HttpStatus .NO_CONTENT .value ()), new ApiResponse ().description (HttpStatus .NO_CONTENT .getReasonPhrase ())));
162- addParameters (operationMethod , operation , ParameterIn .QUERY );
165+ addParameters (operationMethod , operation , components , ParameterIn .QUERY );
163166 break ;
164167 default :
165168 break ;
@@ -171,13 +174,14 @@ private void handleOperationMethod(OperationMethod operationMethod, Operation op
171174 *
172175 * @param operationMethod the operation method
173176 * @param operation the operation
177+ * @param components the components
174178 * @param parameterIn the parameter in
175179 */
176- private void addParameters (OperationMethod operationMethod , Operation operation , ParameterIn parameterIn ) {
180+ private void addParameters (OperationMethod operationMethod , Operation operation , Components components , ParameterIn parameterIn ) {
177181 for (OperationParameter operationParameter : operationMethod .getParameters ()) {
178182 Parameter parameter = getParameterFromField (operationParameter );
179183 if (parameter == null ) continue ;
180- Schema <?> schema = resolveSchema (parameter );
184+ Schema <?> schema = resolveSchema (parameter , components );
181185 if (parameter .getAnnotation (Selector .class ) != null ) {
182186 operation .addParametersItem (new io .swagger .v3 .oas .models .parameters .PathParameter ()
183187 .name (parameter .getName ())
@@ -197,13 +201,14 @@ else if (isValidParameterType(parameter)) {
197201 * Add write parameters.
198202 *
199203 * @param operationMethod the operation method
204+ * @param components the components
200205 * @param operation the operation
201206 */
202- private void addWriteParameters (OperationMethod operationMethod , Operation operation ) {
207+ private void addWriteParameters (OperationMethod operationMethod , Components components , Operation operation ) {
203208 for (OperationParameter operationParameter : operationMethod .getParameters ()) {
204209 Parameter parameter = getParameterFromField (operationParameter );
205210 if (parameter == null ) continue ;
206- Schema <?> schema = resolveSchema (parameter );
211+ Schema <?> schema = resolveSchema (parameter , components );
207212 if (parameter .getAnnotation (Selector .class ) != null ) {
208213 operation .addParametersItem (new io .swagger .v3 .oas .models .parameters .PathParameter ()
209214 .name (parameter .getName ())
@@ -237,11 +242,12 @@ private Parameter getParameterFromField(OperationParameter operationParameter) {
237242 /**
238243 * Resolve schema schema.
239244 *
240- * @param parameter the parameter
245+ * @param parameter the parameter
246+ * @param components
241247 * @return the schema
242248 */
243- private Schema <?> resolveSchema (Parameter parameter ) {
244- Schema schema = AnnotationsUtils .resolveSchemaFromType (parameter .getType (), null , null , springDocConfigProperties .isOpenapi31 ());
249+ private Schema <?> resolveSchema (Parameter parameter , Components components ) {
250+ Schema schema = AnnotationsUtils .resolveSchemaFromType (parameter .getType (), components , null , springDocConfigProperties .isOpenapi31 ());
245251 if (springDocConfigProperties .isOpenapi31 ()) handleSchemaTypes (schema );
246252 return schema ;
247253 }
@@ -271,4 +277,8 @@ private void setOperationSummary(Operation operation, HandlerMethod handlerMetho
271277 }
272278 }
273279
280+ @ Override
281+ public Operation customize (Operation operation , HandlerMethod handlerMethod ) {
282+ return this .customize (operation , null , handlerMethod );
283+ }
274284}
0 commit comments