11/*
2- * Copyright (C) 2018-2024 smart-doc
2+ * Copyright (C) 2018-2025 smart-doc
33 *
44 * Licensed to the Apache Software Foundation (ASF) under one
55 * or more contributor license agreements. See the NOTICE file
@@ -108,15 +108,17 @@ public boolean ignoreReturnObject(String typeName, List<String> ignoreParams) {
108108 @ Override
109109 public FrameworkAnnotations registeredAnnotations () {
110110 FrameworkAnnotations annotations = FrameworkAnnotations .builder ();
111+
112+ // Header annotation
111113 HeaderAnnotation headerAnnotation = HeaderAnnotation .builder ()
112- .setAnnotationName (SpringMvcAnnotations .REQUEST_HERDER )
114+ .setAnnotationName (SpringMvcAnnotations .REQUEST_HEADER )
113115 .setValueProp (DocAnnotationConstants .VALUE_PROP )
114116 .setDefaultValueProp (DocAnnotationConstants .DEFAULT_VALUE_PROP )
115117 .setRequiredProp (DocAnnotationConstants .REQUIRED_PROP );
116118 // add header annotation
117119 annotations .setHeaderAnnotation (headerAnnotation );
118120
119- // add entry annotation
121+ // Entry annotations (Controller, RestController)
120122 Map <String , EntryAnnotation > entryAnnotations = new HashMap <>(16 );
121123 EntryAnnotation controllerAnnotation = EntryAnnotation .builder ()
122124 .setAnnotationName (SpringMvcAnnotations .CONTROLLER )
@@ -128,108 +130,43 @@ public FrameworkAnnotations registeredAnnotations() {
128130 entryAnnotations .put (restController .getAnnotationName (), restController );
129131 annotations .setEntryAnnotations (entryAnnotations );
130132
131- // add request body annotation
133+ // RequestBody annotation
132134 RequestBodyAnnotation bodyAnnotation = RequestBodyAnnotation .builder ()
133135 .setAnnotationName (SpringMvcAnnotations .REQUEST_BODY )
134136 .setAnnotationFullyName (SpringMvcAnnotations .REQUEST_BODY_FULLY );
135137 annotations .setRequestBodyAnnotation (bodyAnnotation );
136138
137- // request param annotation
138- RequestParamAnnotation requestAnnotation = RequestParamAnnotation .builder ()
139+ // RequestParam annotation
140+ RequestParamAnnotation requestParamAnnotation = RequestParamAnnotation .builder ()
139141 .setAnnotationName (SpringMvcAnnotations .REQUEST_PARAM )
140142 .setDefaultValueProp (DocAnnotationConstants .DEFAULT_VALUE_PROP )
141143 .setRequiredProp (DocAnnotationConstants .REQUIRED_PROP );
142- annotations .setRequestParamAnnotation (requestAnnotation );
144+ annotations .setRequestParamAnnotation (requestParamAnnotation );
143145
144- // request part annotation
146+ // RequestPart annotation
145147 RequestPartAnnotation requestPartAnnotation = RequestPartAnnotation .builder ()
146148 .setAnnotationName (SpringMvcAnnotations .REQUEST_PART )
147149 .setDefaultValueProp (DocAnnotationConstants .DEFAULT_VALUE_PROP )
148150 .setRequiredProp (DocAnnotationConstants .REQUIRED_PROP );
149151 annotations .setRequestPartAnnotation (requestPartAnnotation );
150152
151- // add path variable annotation
153+ // PathVariable annotation
152154 PathVariableAnnotation pathVariableAnnotation = PathVariableAnnotation .builder ()
153155 .setAnnotationName (SpringMvcAnnotations .PATH_VARIABLE )
154156 .setDefaultValueProp (DocAnnotationConstants .DEFAULT_VALUE_PROP )
155157 .setRequiredProp (DocAnnotationConstants .REQUIRED_PROP );
156158 annotations .setPathVariableAnnotation (pathVariableAnnotation );
157159
158- // add websocket server endpoint annotation
160+ // ServerEndpoint annotation (WebSocket)
159161 ServerEndpointAnnotation serverEndpointAnnotation = ServerEndpointAnnotation .builder ()
160162 .setAnnotationName (SpringMvcAnnotations .SERVER_ENDPOINT );
161163 annotations .setServerEndpointAnnotation (serverEndpointAnnotation );
162164
163165 // add mapping annotations
164- Map <String , MappingAnnotation > mappingAnnotations = new HashMap <>(16 );
165-
166- MappingAnnotation requestMappingAnnotation = MappingAnnotation .builder ()
167- .setAnnotationName (SpringMvcAnnotations .REQUEST_MAPPING )
168- .setConsumesProp ("consumes" )
169- .setProducesProp ("produces" )
170- .setMethodProp ("method" )
171- .setParamsProp ("params" )
172- .setScope ("class" , "method" )
173- .setPathProps (DocAnnotationConstants .VALUE_PROP , DocAnnotationConstants .PATH_PROP );
174- mappingAnnotations .put (requestMappingAnnotation .getAnnotationName (), requestMappingAnnotation );
175-
176- MappingAnnotation postMappingAnnotation = MappingAnnotation .builder ()
177- .setAnnotationName (SpringMvcAnnotations .POST_MAPPING )
178- .setConsumesProp ("consumes" )
179- .setProducesProp ("produces" )
180- .setMethodProp ("method" )
181- .setParamsProp ("params" )
182- .setMethodType (Methods .POST .getValue ())
183- .setPathProps (DocAnnotationConstants .VALUE_PROP , DocAnnotationConstants .PATH_PROP );
184- mappingAnnotations .put (postMappingAnnotation .getAnnotationName (), postMappingAnnotation );
185-
186- MappingAnnotation getMappingAnnotation = MappingAnnotation .builder ()
187- .setAnnotationName (SpringMvcAnnotations .GET_MAPPING )
188- .setConsumesProp ("consumes" )
189- .setProducesProp ("produces" )
190- .setMethodProp ("method" )
191- .setParamsProp ("params" )
192- .setMethodType (Methods .GET .getValue ())
193- .setPathProps (DocAnnotationConstants .VALUE_PROP , DocAnnotationConstants .PATH_PROP );
194- mappingAnnotations .put (getMappingAnnotation .getAnnotationName (), getMappingAnnotation );
195-
196- MappingAnnotation putMappingAnnotation = MappingAnnotation .builder ()
197- .setAnnotationName (SpringMvcAnnotations .PUT_MAPPING )
198- .setConsumesProp ("consumes" )
199- .setProducesProp ("produces" )
200- .setParamsProp ("params" )
201- .setMethodProp ("method" )
202- .setMethodType (Methods .PUT .getValue ())
203- .setPathProps (DocAnnotationConstants .VALUE_PROP , DocAnnotationConstants .PATH_PROP );
204- mappingAnnotations .put (putMappingAnnotation .getAnnotationName (), putMappingAnnotation );
205-
206- MappingAnnotation patchMappingAnnotation = MappingAnnotation .builder ()
207- .setAnnotationName (SpringMvcAnnotations .PATCH_MAPPING )
208- .setConsumesProp ("consumes" )
209- .setProducesProp ("produces" )
210- .setMethodProp ("method" )
211- .setParamsProp ("params" )
212- .setMethodType (Methods .PATCH .getValue ())
213- .setPathProps (DocAnnotationConstants .VALUE_PROP , DocAnnotationConstants .PATH_PROP );
214- mappingAnnotations .put (patchMappingAnnotation .getAnnotationName (), patchMappingAnnotation );
215-
216- MappingAnnotation deleteMappingAnnotation = MappingAnnotation .builder ()
217- .setAnnotationName (SpringMvcAnnotations .DELETE_MAPPING )
218- .setConsumesProp ("consumes" )
219- .setProducesProp ("produces" )
220- .setMethodProp ("method" )
221- .setParamsProp ("params" )
222- .setMethodType (Methods .DELETE .getValue ())
223- .setPathProps (DocAnnotationConstants .VALUE_PROP , DocAnnotationConstants .PATH_PROP );
224- mappingAnnotations .put (deleteMappingAnnotation .getAnnotationName (), deleteMappingAnnotation );
225-
226- MappingAnnotation feignClientAnnotation = MappingAnnotation .builder ()
227- .setAnnotationName (DocGlobalConstants .FEIGN_CLIENT )
228- .setAnnotationFullyName (DocGlobalConstants .FEIGN_CLIENT_FULLY );
229- mappingAnnotations .put (feignClientAnnotation .getAnnotationName (), feignClientAnnotation );
166+ Map <String , MappingAnnotation > mappingAnnotations = buildSpringMappingAnnotations ();
230167 annotations .setMappingAnnotations (mappingAnnotations );
231168
232- // Add Exception advice
169+ // Exception advice annotations
233170 Map <String , ExceptionAdviceAnnotation > exceptionAdviceAnnotations = new HashMap <>(16 );
234171
235172 ExceptionAdviceAnnotation controllerAdviceAnnotation = ExceptionAdviceAnnotation .builder ()
@@ -432,4 +369,89 @@ public List<ApiExceptionStatus> defaultHttpErrorStatuses() {
432369 return exceptionStatusList ;
433370 }
434371
372+ /**
373+ * Builds and returns all Spring MVC request mapping annotations
374+ * including @RequestMapping, @GetMapping, @PostMapping, etc., with consistent
375+ * attribute configurations.
376+ * @return a map of annotation name to {@link MappingAnnotation}
377+ */
378+ private Map <String , MappingAnnotation > buildSpringMappingAnnotations () {
379+ Map <String , MappingAnnotation > mappingAnnotations = new HashMap <>(16 );
380+
381+ // Common properties
382+ String consumes = DocAnnotationConstants .CONSUMES ;
383+ String produces = DocAnnotationConstants .PRODUCES ;
384+ String method = DocAnnotationConstants .METHOD ;
385+ String params = DocAnnotationConstants .PARAMS ;
386+ String [] pathProps = DocAnnotationConstants .PATH_MAPPING_PROPS ;
387+
388+ // @RequestMapping
389+ MappingAnnotation requestMapping = MappingAnnotation .builder ()
390+ .setAnnotationName (SpringMvcAnnotations .REQUEST_MAPPING )
391+ .setConsumesProp (consumes )
392+ .setProducesProp (produces )
393+ .setMethodProp (method )
394+ .setParamsProp (params )
395+ .setScope ("class" , "method" )
396+ .setPathProps (pathProps );
397+ mappingAnnotations .put (requestMapping .getAnnotationName (), requestMapping );
398+
399+ // @PostMapping
400+ MappingAnnotation postMapping = this .createMapping (SpringMvcAnnotations .POST_MAPPING , Methods .POST .getValue (),
401+ pathProps , consumes , produces , method , params );
402+ mappingAnnotations .put (postMapping .getAnnotationName (), postMapping );
403+
404+ // @GetMapping
405+ MappingAnnotation getMapping = this .createMapping (SpringMvcAnnotations .GET_MAPPING , Methods .GET .getValue (),
406+ pathProps , consumes , produces , method , params );
407+ mappingAnnotations .put (getMapping .getAnnotationName (), getMapping );
408+
409+ // @PutMapping
410+ MappingAnnotation putMapping = this .createMapping (SpringMvcAnnotations .PUT_MAPPING , Methods .PUT .getValue (),
411+ pathProps , consumes , produces , method , params );
412+ mappingAnnotations .put (putMapping .getAnnotationName (), putMapping );
413+
414+ // @PatchMapping
415+ MappingAnnotation patchMapping = this .createMapping (SpringMvcAnnotations .PATCH_MAPPING ,
416+ Methods .PATCH .getValue (), pathProps , consumes , produces , method , params );
417+ mappingAnnotations .put (patchMapping .getAnnotationName (), patchMapping );
418+
419+ // @DeleteMapping
420+ MappingAnnotation deleteMapping = this .createMapping (SpringMvcAnnotations .DELETE_MAPPING ,
421+ Methods .DELETE .getValue (), pathProps , consumes , produces , method , params );
422+ mappingAnnotations .put (deleteMapping .getAnnotationName (), deleteMapping );
423+
424+ // @FeignClient
425+ MappingAnnotation feignClient = MappingAnnotation .builder ()
426+ .setAnnotationName (DocGlobalConstants .FEIGN_CLIENT )
427+ .setAnnotationFullyName (DocGlobalConstants .FEIGN_CLIENT_FULLY )
428+ .setPathProps (DocAnnotationConstants .PATH_PROP );
429+ mappingAnnotations .put (feignClient .getAnnotationName (), feignClient );
430+
431+ return mappingAnnotations ;
432+ }
433+
434+ /**
435+ * Helper method to create common HTTP method-based mappings
436+ * (e.g., @GetMapping, @PostMapping).
437+ * @param annotationName the annotation name
438+ * @param methodType the method type
439+ * @param pathProps the path properties
440+ * @param consumes the consumes property
441+ * @param produces the produces property
442+ * @param method the HTTP method
443+ * @param params the params property
444+ */
445+ private MappingAnnotation createMapping (String annotationName , String methodType , String [] pathProps ,
446+ String consumes , String produces , String method , String params ) {
447+ return MappingAnnotation .builder ()
448+ .setAnnotationName (annotationName )
449+ .setConsumesProp (consumes )
450+ .setProducesProp (produces )
451+ .setMethodProp (method )
452+ .setParamsProp (params )
453+ .setMethodType (methodType )
454+ .setPathProps (pathProps );
455+ }
456+
435457}
0 commit comments