@@ -34,37 +34,38 @@ After this guide, your service will:
3434## 2) Add dependencies (pom.xml)  
3535
3636``` xml 
37+ 
3738<dependencies >
38-   <!--  Web + Bean Validation --> 
39-   <dependency >
40-     <groupId >org.springframework.boot</groupId >
41-     <artifactId >spring-boot-starter-web</artifactId >
42-   </dependency >
43-   <dependency >
44-     <groupId >org.springframework.boot</groupId >
45-     <artifactId >spring-boot-starter-validation</artifactId >
46-   </dependency >
47- 
48-   <!--  Springdoc (OpenAPI 3.1 + Swagger UI) --> 
49-   <dependency >
50-     <groupId >org.springdoc</groupId >
51-     <artifactId >springdoc-openapi-starter-webmvc-ui</artifactId >
52-     <version >2.8.13</version >
53-   </dependency >
54- 
55-   <!--  optional: configuration processor for metadata hints --> 
56-   <dependency >
57-     <groupId >org.springframework.boot</groupId >
58-     <artifactId >spring-boot-configuration-processor</artifactId >
59-     <optional >true</optional >
60-   </dependency >
61- 
62-   <!--  test (optional) --> 
63-   <dependency >
64-     <groupId >org.springframework.boot</groupId >
65-     <artifactId >spring-boot-starter-test</artifactId >
66-     <scope >test</scope >
67-   </dependency >
39+      <!--  Web + Bean Validation --> 
40+      <dependency >
41+          <groupId >org.springframework.boot</groupId >
42+          <artifactId >spring-boot-starter-web</artifactId >
43+      </dependency >
44+      <dependency >
45+          <groupId >org.springframework.boot</groupId >
46+          <artifactId >spring-boot-starter-validation</artifactId >
47+      </dependency >
48+ 
49+      <!--  Springdoc (OpenAPI 3.1 + Swagger UI) --> 
50+      <dependency >
51+          <groupId >org.springdoc</groupId >
52+          <artifactId >springdoc-openapi-starter-webmvc-ui</artifactId >
53+          <version >2.8.13</version >
54+      </dependency >
55+ 
56+      <!--  optional: configuration processor for metadata hints --> 
57+      <dependency >
58+          <groupId >org.springframework.boot</groupId >
59+          <artifactId >spring-boot-configuration-processor</artifactId >
60+          <optional >true</optional >
61+      </dependency >
62+ 
63+      <!--  test (optional) --> 
64+      <dependency >
65+          <groupId >org.springframework.boot</groupId >
66+          <artifactId >spring-boot-starter-test</artifactId >
67+          <scope >test</scope >
68+      </dependency >
6869</dependencies >
6970``` 
7071
@@ -82,22 +83,28 @@ Add your usual build plugins (compiler, surefire/failsafe, jacoco) as you prefer
8283** ` common/api/response/ServiceResponse.java ` ** 
8384
8485``` java 
85- package  <your.base>.common.api.response ;
86+ package 
87+ 
88+ < your. base> . common. api. response;
8689
8790import  java.util.Collections ;
8891import  java.util.List ;
92+ 
8993import  org.springframework.http.HttpStatus ;
9094
9195public  record ServiceResponse<T > (int  status, String  message, T  data, List<ErrorDetail >  errors) {
9296    public  static  < T >  ServiceResponse<T >  ok(T  data) {
9397        return  new  ServiceResponse<> (HttpStatus . OK. value(), " OK"  , data, Collections . emptyList());
9498    }
99+ 
95100    public  static  < T >  ServiceResponse<T >  of(HttpStatus  status, String  message, T  data) {
96101        return  new  ServiceResponse<> (status. value(), message, data, Collections . emptyList());
97102    }
103+ 
98104    public  static  < T >  ServiceResponse<T >  error(HttpStatus  status, String  message) {
99105        return  new  ServiceResponse<> (status. value(), message, null , Collections . emptyList());
100106    }
107+ 
101108    public  static  < T >  ServiceResponse<T >  error(HttpStatus  status, String  message, List<ErrorDetail >  errors) {
102109        return  new  ServiceResponse<> (status. value(), message, null , errors !=  null  ?  errors :  Collections . emptyList());
103110    }
@@ -209,36 +216,40 @@ public class SwaggerResponseCustomizer {
209216** ` ApiResponseSchemaFactory.java ` **  — builds a * composed*  wrapper per concrete ` T `  (e.g., ` CustomerDto ` ).
210217
211218``` java 
212- package  <your.base>.common.openapi ;
219+ package 
220+ 
221+ < your. base> . common. openapi;
213222
214223import static  <your.base>.common.openapi.OpenApiSchemas.* ;
215224
216225import  io.swagger.v3.oas.models.media.ComposedSchema ;
217226import  io.swagger.v3.oas.models.media.ObjectSchema ;
218227import  io.swagger.v3.oas.models.media.Schema ;
228+ 
219229import  java.util.List ;
220230
221231public  final  class  ApiResponseSchemaFactory  {
222-   private  ApiResponseSchemaFactory () {}
232+     private  ApiResponseSchemaFactory () {
233+     }
223234
224-   public  static  Schema<?>  createComposedWrapper (String  dataRefName ) {
225-     return  createComposedWrapper(dataRefName, null );
226-   }
235+      public  static  Schema<?>  createComposedWrapper (String  dataRefName ) {
236+          return  createComposedWrapper(dataRefName, null );
237+      }
227238
228-   public  static  Schema<?>  createComposedWrapper (String  dataRefName , String  classExtraAnnotation ) {
229-     var  schema =  new  ComposedSchema ();
230-     schema. setAllOf(List . of(
231-       new  Schema<> (). $ref(" #/components/schemas/"   +  SCHEMA_SERVICE_RESPONSE ),
232-       new  ObjectSchema (). addProperty(PROP_DATA , new  Schema<> (). $ref(" #/components/schemas/"   +  dataRefName))
233-     ));
234- 
235-     schema. addExtension(EXT_API_WRAPPER , true );
236-     schema. addExtension(EXT_API_WRAPPER_DATATYPE , dataRefName);
237-     if  (classExtraAnnotation !=  null  &&  ! classExtraAnnotation. isBlank()) {
238-       schema. addExtension(EXT_CLASS_EXTRA_ANNOTATION , classExtraAnnotation);
239+     public  static  Schema<?>  createComposedWrapper (String  dataRefName , String  classExtraAnnotation ) {
240+         var  schema =  new  ComposedSchema ();
241+         schema. setAllOf(List . of(
242+                 new  Schema<> (). $ref(" #/components/schemas/"   +  SCHEMA_SERVICE_RESPONSE ),
243+                 new  ObjectSchema (). addProperty(PROP_DATA , new  Schema<> (). $ref(" #/components/schemas/"   +  dataRefName))
244+         ));
245+ 
246+         schema. addExtension(EXT_API_WRAPPER , true );
247+         schema. addExtension(EXT_API_WRAPPER_DATATYPE , dataRefName);
248+         if  (classExtraAnnotation !=  null  &&  ! classExtraAnnotation. isBlank()) {
249+             schema. addExtension(EXT_CLASS_EXTRA_ANNOTATION , classExtraAnnotation);
250+         }
251+         return  schema;
239252    }
240-     return  schema;
241-   }
242253}
243254``` 
244255
0 commit comments