PMT-19: In progress
Some checks failed
Quality Check / Linting (push) Failing after 1m31s
Quality Check / Static Analysis (push) Failing after 1m30s
Quality Check / Testing (push) Failing after 1m30s
Quality Check / Validate OAS (push) Successful in 4m17s

This commit is contained in:
Dominik Säume 2024-09-27 16:07:03 +02:00
parent 88c1b196b1
commit 4d5785cdab
Signed by: SZUT-Dominik
GPG key ID: 67D15BB250B41E7C
3 changed files with 47 additions and 2 deletions

View file

@ -0,0 +1,6 @@
*
**/*
!**/pom.xml
!**/README.md
!**/.openapi-generator-ignore
!**/src/main/java/de/hmmh/**/*

View file

@ -2,6 +2,7 @@ import com.github.spotbugs.snom.Confidence
import com.github.spotbugs.snom.Effort import com.github.spotbugs.snom.Effort
import com.github.spotbugs.snom.SpotBugsTask import com.github.spotbugs.snom.SpotBugsTask
import org.hidetake.gradle.swagger.generator.GenerateSwaggerCode import org.hidetake.gradle.swagger.generator.GenerateSwaggerCode
import org.openapitools.codegen.languages.JavaClientCodegen
repositories { repositories {
mavenCentral() mavenCentral()
@ -14,6 +15,7 @@ plugins {
id("org.springframework.boot") version "3.3.3" id("org.springframework.boot") version "3.3.3"
id("io.spring.dependency-management") version "1.1.6" id("io.spring.dependency-management") version "1.1.6"
id("org.hidetake.swagger.generator") version "2.19.2" id("org.hidetake.swagger.generator") version "2.19.2"
id("org.openapi.generator") version "7.8.0"
} }
checkstyle { checkstyle {
@ -23,7 +25,7 @@ checkstyle {
} }
spotbugs { spotbugs {
toolVersion = "4.8.6" toolVersion = "4.8.6"
effort.set(Effort.MAX) effort.set(Effort.MAX)
reportLevel.set(Confidence.LOW) reportLevel.set(Confidence.LOW)
} }
@ -87,6 +89,34 @@ swaggerSources {
} }
} }
openApiGenerate {
remoteInputSpec = "https://employee.szut.dev/v3/api-docs.yaml"
apiPackage = "ignored"
modelPackage = "ignored"
invokerPackage = "de.hmmh.pmt.employee"
groupId = "de.hmmh"
packageName = "de.hmmh.pmt"
generatorName = "java"
generateModelTests = false
generateApiTests = false
generateApiDocumentation = false
generateModelDocumentation = false
library = JavaClientCodegen.RESTTEMPLATE
ignoreFileOverride.set(".openapi-generator-java-sources.ignore")
configOptions.putAll(
mapOf(
JavaClientCodegen.GENERATE_CLIENT_AS_BEAN to "true",
JavaClientCodegen.ANNOTATION_LIBRARY to "swagger2",
JavaClientCodegen.OPENAPI_NULLABLE to "false",
JavaClientCodegen.PERFORM_BEANVALIDATION to "true",
JavaClientCodegen.USE_BEANVALIDATION to "true",
JavaClientCodegen.USE_JAKARTA_EE to "true",
)
)
}
tasks { tasks {
withType<Checkstyle> { withType<Checkstyle> {
@ -96,17 +126,19 @@ tasks {
} }
} }
withType<SpotBugsTask> { withType<SpotBugsTask> {
excludeFilter.set(file("${rootDir}/src/main/resources/spotbugs-exclude.xml")) excludeFilter.set(file("${rootDir}/src/main/resources/spotbugs-exclude.xml"))
} }
processResources { processResources {
dependsOn(generateSwaggerCode) dependsOn(generateSwaggerCode)
dependsOn(openApiGenerate)
} }
withType<Test> { withType<Test> {
useJUnitPlatform() useJUnitPlatform()
} }
named("compileJava").configure { named("compileJava").configure {
dependsOn(swaggerSources.getByName("pmt").code) dependsOn(swaggerSources.getByName("pmt").code)
dependsOn(openApiGenerate)
} }
} }
@ -114,5 +146,7 @@ sourceSets {
main { main {
java.srcDir("${swaggerSources.getByName("pmt").code.outputDir}/src/main/java") java.srcDir("${swaggerSources.getByName("pmt").code.outputDir}/src/main/java")
resources.srcDir("${swaggerSources.getByName("pmt").code.outputDir}/src/main/resources") resources.srcDir("${swaggerSources.getByName("pmt").code.outputDir}/src/main/resources")
java.srcDir("${openApiGenerate.outputDir}/src/main/java")
} }
} }

View file

@ -1,9 +1,11 @@
package de.hmmh.pmt; package de.hmmh.pmt;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import de.hmmh.pmt.employee.ApiClient;
import de.hmmh.pmt.oas.DefaultApi; import de.hmmh.pmt.oas.DefaultApi;
import de.hmmh.pmt.dtos.HelloOut; import de.hmmh.pmt.dtos.HelloOut;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -13,6 +15,9 @@ import java.util.Optional;
@Controller @Controller
@RequestMapping("${openapi.projectManagement.base-path:/api/v1}") @RequestMapping("${openapi.projectManagement.base-path:/api/v1}")
public class ApiController implements DefaultApi { public class ApiController implements DefaultApi {
@Autowired
private ApiClient apiClient;
@Override @Override
public Optional<ObjectMapper> getObjectMapper() { public Optional<ObjectMapper> getObjectMapper() {