Subject: [PATCH] boot4_2_version
---
Index: src/main/java/ru/javaops/bootjava/app/config/WebConfig.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/java/ru/javaops/bootjava/app/config/WebConfig.java b/src/main/java/ru/javaops/bootjava/app/config/WebConfig.java
new file mode 100644
--- /dev/null	(date 1765549390887)
+++ b/src/main/java/ru/javaops/bootjava/app/config/WebConfig.java	(date 1765549390887)
@@ -0,0 +1,21 @@
+package ru.javaops.bootjava.app.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.ApiVersionConfigurer;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+@Configuration
+public class WebConfig implements WebMvcConfigurer {
+
+    public static final String VERSION_HEADER = "API-Version";
+    public static final String CURRENT_VERSION = "1.0";
+
+    @Override
+    public void configureApiVersioning(ApiVersionConfigurer configurer) {
+        configurer
+                .useRequestHeader(VERSION_HEADER)
+                .setVersionRequired(false)
+                .setDefaultVersion(CURRENT_VERSION)
+                .addSupportedVersions(CURRENT_VERSION);
+    }
+}
\ No newline at end of file
Index: src/test/java/ru/javaops/bootjava/AbstractControllerTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/test/java/ru/javaops/bootjava/AbstractControllerTest.java b/src/test/java/ru/javaops/bootjava/AbstractControllerTest.java
--- a/src/test/java/ru/javaops/bootjava/AbstractControllerTest.java	(revision 02d57fecf895c1e7d2edcda14e0a155fe6808617)
+++ b/src/test/java/ru/javaops/bootjava/AbstractControllerTest.java	(date 1768987236011)
@@ -8,6 +8,7 @@
 import org.springframework.test.web.servlet.ResultActions;
 import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
 import org.springframework.transaction.annotation.Transactional;
+import ru.javaops.bootjava.app.config.WebConfig;
 
 //https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-testing-spring-boot-applications
 @SpringBootTest
@@ -21,6 +22,7 @@
     private MockMvc mockMvc;
 
     protected ResultActions perform(MockHttpServletRequestBuilder builder) throws Exception {
+        builder.header(WebConfig.VERSION_HEADER, WebConfig.CURRENT_VERSION);
         return mockMvc.perform(builder);
     }
 }
Index: src/main/java/ru/javaops/bootjava/user/web/ProfileController.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/java/ru/javaops/bootjava/user/web/ProfileController.java b/src/main/java/ru/javaops/bootjava/user/web/ProfileController.java
--- a/src/main/java/ru/javaops/bootjava/user/web/ProfileController.java	(revision 02d57fecf895c1e7d2edcda14e0a155fe6808617)
+++ b/src/main/java/ru/javaops/bootjava/user/web/ProfileController.java	(date 1768987235996)
@@ -10,6 +10,7 @@
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
 import ru.javaops.bootjava.app.AuthUser;
+import ru.javaops.bootjava.app.config.WebConfig;
 import ru.javaops.bootjava.user.UsersUtil;
 import ru.javaops.bootjava.user.model.User;
 import ru.javaops.bootjava.user.to.UserTo;
@@ -20,7 +21,7 @@
 import static ru.javaops.bootjava.common.validation.ValidationUtil.checkNew;
 
 @RestController
-@RequestMapping(value = ProfileController.REST_URL, produces = MediaType.APPLICATION_JSON_VALUE)
+@RequestMapping(value = ProfileController.REST_URL, produces = MediaType.APPLICATION_JSON_VALUE, version = WebConfig.CURRENT_VERSION)
 @Slf4j
 public class ProfileController extends AbstractUserController {
     static final String REST_URL = "/api/profile";
Index: src/main/java/ru/javaops/bootjava/user/web/AdminUserController.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/java/ru/javaops/bootjava/user/web/AdminUserController.java b/src/main/java/ru/javaops/bootjava/user/web/AdminUserController.java
--- a/src/main/java/ru/javaops/bootjava/user/web/AdminUserController.java	(revision 02d57fecf895c1e7d2edcda14e0a155fe6808617)
+++ b/src/main/java/ru/javaops/bootjava/user/web/AdminUserController.java	(date 1768987235995)
@@ -8,6 +8,7 @@
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
+import ru.javaops.bootjava.app.config.WebConfig;
 import ru.javaops.bootjava.user.model.User;
 
 import java.net.URI;
@@ -17,7 +18,7 @@
 import static ru.javaops.bootjava.common.validation.ValidationUtil.checkNew;
 
 @RestController
-@RequestMapping(value = AdminUserController.REST_URL, produces = MediaType.APPLICATION_JSON_VALUE)
+@RequestMapping(value = AdminUserController.REST_URL, produces = MediaType.APPLICATION_JSON_VALUE, version = WebConfig.CURRENT_VERSION)
 public class AdminUserController extends AbstractUserController {
 
     static final String REST_URL = "/api/admin/users";
Index: src/main/resources/application.yaml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml
--- a/src/main/resources/application.yaml	(revision 02d57fecf895c1e7d2edcda14e0a155fe6808617)
+++ b/src/main/resources/application.yaml	(date 1768987282996)
@@ -39,10 +39,12 @@
       enabled: true
       force: true
 
+#  mvc.apiversion.use.header: API-Version
+
 logging:
   level:
     root: WARN
     ru.javaops.bootjava: DEBUG
     org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver: DEBUG
 
-springdoc.swagger-ui.path: /
+#springdoc.swagger-ui.path: /
