PMT-19: In progress
This commit is contained in:
parent
88c1b196b1
commit
4d5785cdab
3 changed files with 47 additions and 2 deletions
6
.openapi-generator-java-sources.ignore
Normal file
6
.openapi-generator-java-sources.ignore
Normal file
|
@ -0,0 +1,6 @@
|
|||
*
|
||||
**/*
|
||||
!**/pom.xml
|
||||
!**/README.md
|
||||
!**/.openapi-generator-ignore
|
||||
!**/src/main/java/de/hmmh/**/*
|
|
@ -2,6 +2,7 @@ import com.github.spotbugs.snom.Confidence
|
|||
import com.github.spotbugs.snom.Effort
|
||||
import com.github.spotbugs.snom.SpotBugsTask
|
||||
import org.hidetake.gradle.swagger.generator.GenerateSwaggerCode
|
||||
import org.openapitools.codegen.languages.JavaClientCodegen
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@ -14,6 +15,7 @@ plugins {
|
|||
id("org.springframework.boot") version "3.3.3"
|
||||
id("io.spring.dependency-management") version "1.1.6"
|
||||
id("org.hidetake.swagger.generator") version "2.19.2"
|
||||
id("org.openapi.generator") version "7.8.0"
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
|
@ -23,7 +25,7 @@ checkstyle {
|
|||
}
|
||||
|
||||
spotbugs {
|
||||
toolVersion = "4.8.6"
|
||||
toolVersion = "4.8.6"
|
||||
effort.set(Effort.MAX)
|
||||
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 {
|
||||
|
||||
withType<Checkstyle> {
|
||||
|
@ -96,17 +126,19 @@ tasks {
|
|||
}
|
||||
}
|
||||
withType<SpotBugsTask> {
|
||||
|
||||
|
||||
excludeFilter.set(file("${rootDir}/src/main/resources/spotbugs-exclude.xml"))
|
||||
}
|
||||
processResources {
|
||||
dependsOn(generateSwaggerCode)
|
||||
dependsOn(openApiGenerate)
|
||||
}
|
||||
withType<Test> {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
named("compileJava").configure {
|
||||
dependsOn(swaggerSources.getByName("pmt").code)
|
||||
dependsOn(openApiGenerate)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,5 +146,7 @@ sourceSets {
|
|||
main {
|
||||
java.srcDir("${swaggerSources.getByName("pmt").code.outputDir}/src/main/java")
|
||||
resources.srcDir("${swaggerSources.getByName("pmt").code.outputDir}/src/main/resources")
|
||||
|
||||
java.srcDir("${openApiGenerate.outputDir}/src/main/java")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package de.hmmh.pmt;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import de.hmmh.pmt.employee.ApiClient;
|
||||
import de.hmmh.pmt.oas.DefaultApi;
|
||||
import de.hmmh.pmt.dtos.HelloOut;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -13,6 +15,9 @@ import java.util.Optional;
|
|||
@Controller
|
||||
@RequestMapping("${openapi.projectManagement.base-path:/api/v1}")
|
||||
public class ApiController implements DefaultApi {
|
||||
|
||||
@Autowired
|
||||
private ApiClient apiClient;
|
||||
|
||||
@Override
|
||||
public Optional<ObjectMapper> getObjectMapper() {
|
||||
|
|
Loading…
Reference in a new issue