diff --git a/backend/pom.xml b/backend/pom.xml
index 043664a..55ba4ec 100644
--- a/backend/pom.xml
+++ b/backend/pom.xml
@@ -27,6 +27,11 @@
true
+
+ ${project.groupId}
+ open-api
+ ${project.version}
+
org.springframework.boot
spring-boot-starter-test
@@ -46,7 +51,7 @@
org.springframework.boot
spring-boot-maven-plugin
- 2.4.3
+ 2.6.3
dev.marco.example.springboot.Application
@@ -58,32 +63,6 @@
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
- 3.1.2
-
-
- merge
- initialize
-
- unpack
-
-
-
-
- ${project.groupId}
- frontend
- jar
- true
- ${project.build.directory}/classes/static
-
-
-
-
-
-
diff --git a/backend/src/main/java/dev/marco/example/springboot/Application.java b/backend/src/main/java/dev/marco/example/springboot/Application.java
index bd4d5f7..f3feba9 100644
--- a/backend/src/main/java/dev/marco/example/springboot/Application.java
+++ b/backend/src/main/java/dev/marco/example/springboot/Application.java
@@ -3,7 +3,6 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-
@SpringBootApplication
public class Application {
diff --git a/backend/src/main/java/dev/marco/example/springboot/feature/FeatureController.java b/backend/src/main/java/dev/marco/example/springboot/feature/FeatureController.java
index 7f9fe8f..325fa9f 100644
--- a/backend/src/main/java/dev/marco/example/springboot/feature/FeatureController.java
+++ b/backend/src/main/java/dev/marco/example/springboot/feature/FeatureController.java
@@ -11,7 +11,7 @@
* The goal of this controller is to show the test of the services and some REST methods
*/
@RestController
-@CrossOrigin(origins = {"${app.dev.frontend.local"})
+@CrossOrigin(origins = {"${app.dev.frontend.local}"})
public class FeatureController {
@Autowired
diff --git a/backend/src/main/java/dev/marco/example/springboot/hello/HelloController.java b/backend/src/main/java/dev/marco/example/springboot/hello/HelloController.java
index f6fda40..f03791a 100644
--- a/backend/src/main/java/dev/marco/example/springboot/hello/HelloController.java
+++ b/backend/src/main/java/dev/marco/example/springboot/hello/HelloController.java
@@ -11,7 +11,7 @@
@RestController
// we allow cors requests from our frontend environment
// note the curly braces that creates an array of strings ... required by the annotation
-@CrossOrigin(origins = {"${app.dev.frontend.local"})
+@CrossOrigin(origins = {"${app.dev.frontend.local}"})
public class HelloController {
// simple GET response for our example purpose, we return a JSON structure
diff --git a/backend/src/main/java/dev/marco/example/springboot/hello/HelloControllerApiImpl.java b/backend/src/main/java/dev/marco/example/springboot/hello/HelloControllerApiImpl.java
new file mode 100644
index 0000000..081ba63
--- /dev/null
+++ b/backend/src/main/java/dev/marco/example/springboot/hello/HelloControllerApiImpl.java
@@ -0,0 +1,24 @@
+package dev.marco.example.springboot.hello;
+
+
+import dev.marco.example.api.controller.HelloOpenApi;
+import dev.marco.example.api.model.Greeting;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class HelloControllerApiImpl implements HelloOpenApi {
+ @Override
+ public ResponseEntity getGreeting() {
+ Greeting greeting = new Greeting();
+ greeting.message("Hello from Spring Boot");
+ return ResponseEntity.ok(greeting);
+ }
+
+ @Override
+ public ResponseEntity getPersonalGreeting(String name) {
+ Greeting greeting = new Greeting();
+ greeting.message("Hello " + name + ", enjoy Spring Boot");
+ return ResponseEntity.ok(greeting);
+ }
+}
diff --git a/backend/src/main/java/application.properties b/backend/src/main/resources/application.properties
similarity index 100%
rename from backend/src/main/java/application.properties
rename to backend/src/main/resources/application.properties
diff --git a/backend/src/test/java/dev/marco/example/springboot/HelloControllerMockMvcTest.java b/backend/src/test/java/dev/marco/example/springboot/HelloControllerMockMvcTest.java
index a8509b3..249300e 100644
--- a/backend/src/test/java/dev/marco/example/springboot/HelloControllerMockMvcTest.java
+++ b/backend/src/test/java/dev/marco/example/springboot/HelloControllerMockMvcTest.java
@@ -28,5 +28,4 @@ public void shouldReturnOurText() throws Exception {
.andDo(print()) // we log the result
.andExpect(content().string(containsString(" from Spring"))); // we check that the Body of the answer contains our expectation
}
-
}
diff --git a/open-api/pom.xml b/open-api/pom.xml
new file mode 100644
index 0000000..27a3198
--- /dev/null
+++ b/open-api/pom.xml
@@ -0,0 +1,130 @@
+
+
+ 4.0.0
+
+
+ dev.marco
+ java-angular-example
+ 0.1-SNAPSHOT
+ ../pom.xml
+
+
+
+ UTF-8
+ UTF-8
+
+
+ open-api
+ jar
+ ${project.artifactId}
+
+
+
+ io.springfox
+ springfox-boot-starter
+ 3.0.0
+
+
+
+ org.hibernate
+ hibernate-validator
+ 7.0.1.Final
+
+
+
+ org.openapitools
+ jackson-databind-nullable
+ 0.2.0
+
+
+
+
+
+
+
+ org.openapitools
+ openapi-generator-maven-plugin
+ 5.1.0
+
+
+
+ generate
+
+ buildApi
+
+ ${basedir}/src/main/resources/java-angular-basic.yaml
+
+ spring
+ spring-boot
+
+ ${swagger.modelNameSuffix}
+
+ true
+ false
+ false
+ true
+ false
+ false
+ false
+
+
+
+ ApiUtil.java
+
+
+
+
+
+ true∂
+ true
+ true
+ ${swagger.modelPackage}
+ ${swagger.basePackage}.controller
+ /src/main/java
+ /src/main/java
+ true
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ properties-maven-plugin
+ 1.0.0
+
+
+ initialize
+
+ read-project-properties
+
+
+
+ ${basedir}/src/main/resources/swagger.properties
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+ false
+
+ false
+ lib/
+ true
+
+
+ ${buildNumber}
+ ${maven.build.timestamp}
+
+
+
+
+
+
+
diff --git a/open-api/src/main/resources/java-angular-basic.yaml b/open-api/src/main/resources/java-angular-basic.yaml
new file mode 100644
index 0000000..3cc4c9a
--- /dev/null
+++ b/open-api/src/main/resources/java-angular-basic.yaml
@@ -0,0 +1,48 @@
+openapi: 3.0.3 # version of the specification
+info:
+ version: '1'
+ title: Marco.dev Angular Spring Boot Example Api
+
+servers:
+ - url: http://localhost:8080
+
+paths:
+ /hello-open:
+ get:
+ summary: return a simple generic greeting
+ operationId: getGreeting
+ responses:
+ 200:
+ description: General greeting
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Greeting'
+ /hello-open/{name}:
+ parameters:
+ - in: path
+ name: name
+ schema:
+ type: string
+ required: true
+ description: "Name"
+ example: "Marco"
+ get:
+ description: return a greeting with name
+ operationId: getPersonalGreeting
+ responses:
+ 200:
+ description: Personal greeting
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Greeting'
+components:
+ schemas:
+ Greeting:
+ type: object
+ properties:
+ message:
+ type: string
+ example: 'Hello from Spring'
+ default: 'Hello visitor'
\ No newline at end of file
diff --git a/open-api/src/main/resources/swagger.properties b/open-api/src/main/resources/swagger.properties
new file mode 100644
index 0000000..d412659
--- /dev/null
+++ b/open-api/src/main/resources/swagger.properties
@@ -0,0 +1,4 @@
+swagger.yaml.path=src/main/resources
+swagger.modelNameSuffix=
+swagger.basePackage=dev.marco.example.api
+swagger.modelPackage=dev.marco.example.api.model
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 879633c..f714866 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,6 +14,7 @@
2.4.3
+ open-api
frontend
backend
@@ -22,17 +23,17 @@
org.springframework
spring-context-support
- 5.3.4
+ 5.3.14
org.springframework.boot
spring-boot-starter-web
- 2.4.3
+ 2.6.3
org.springframework.boot
spring-boot-starter-test
- 2.4.3
+ 2.6.3