Skip to content

Commit 84282d3

Browse files
committed
feat(kotlin-spring): add kotlin-springboot-4 sample with Jackson 3
1 parent a52e78d commit 84282d3

34 files changed

Lines changed: 2070 additions & 0 deletions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
generatorName: kotlin-spring
2+
outputDir: samples/server/petstore/kotlin-springboot-4
3+
library: spring-boot
4+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
5+
templateDir: modules/openapi-generator/src/main/resources/kotlin-spring
6+
additionalProperties:
7+
documentationProvider: none
8+
annotationLibrary: none
9+
useSwaggerUI: "false"
10+
serviceImplementation: "true"
11+
serializableModel: "true"
12+
beanValidations: "true"
13+
useSpringBoot4: "true"
14+
useJackson3: "true"
15+
requestMappingMode: api_interface
16+
gradleBuildFile: "true"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.openapi-generator-ignore
2+
README.md
3+
build.gradle.kts
4+
gradle/wrapper/gradle-wrapper.jar
5+
gradle/wrapper/gradle-wrapper.properties
6+
gradlew
7+
gradlew.bat
8+
pom.xml
9+
settings.gradle
10+
src/main/kotlin/org/openapitools/Application.kt
11+
src/main/kotlin/org/openapitools/api/ApiUtil.kt
12+
src/main/kotlin/org/openapitools/api/Exceptions.kt
13+
src/main/kotlin/org/openapitools/api/PetApiController.kt
14+
src/main/kotlin/org/openapitools/api/PetApiService.kt
15+
src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt
16+
src/main/kotlin/org/openapitools/api/StoreApiController.kt
17+
src/main/kotlin/org/openapitools/api/StoreApiService.kt
18+
src/main/kotlin/org/openapitools/api/StoreApiServiceImpl.kt
19+
src/main/kotlin/org/openapitools/api/UserApiController.kt
20+
src/main/kotlin/org/openapitools/api/UserApiService.kt
21+
src/main/kotlin/org/openapitools/api/UserApiServiceImpl.kt
22+
src/main/kotlin/org/openapitools/model/Category.kt
23+
src/main/kotlin/org/openapitools/model/ModelApiResponse.kt
24+
src/main/kotlin/org/openapitools/model/Order.kt
25+
src/main/kotlin/org/openapitools/model/Pet.kt
26+
src/main/kotlin/org/openapitools/model/Tag.kt
27+
src/main/kotlin/org/openapitools/model/User.kt
28+
src/main/resources/application.yaml
29+
src/test/kotlin/org/openapitools/api/PetApiTest.kt
30+
src/test/kotlin/org/openapitools/api/StoreApiTest.kt
31+
src/test/kotlin/org/openapitools/api/UserApiTest.kt
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.21.0-SNAPSHOT
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# openAPIPetstore
2+
3+
This Kotlin based [Spring Boot](https://spring.io/projects/spring-boot) application has been generated using the [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator).
4+
5+
## Getting Started
6+
7+
This document assumes you have either maven or gradle available, either via the wrapper or otherwise. This does not come with a gradle / maven wrapper checked in.
8+
9+
By default a [`pom.xml`](pom.xml) file will be generated. If you specified `gradleBuildFile=true` when generating this project, a `build.gradle.kts` will also be generated. Note this uses [Gradle Kotlin DSL](https://github.com/gradle/kotlin-dsl).
10+
11+
To build the project using maven, run:
12+
```bash
13+
mvn package && java -jar target/openapi-spring-1.0.0.jar
14+
```
15+
16+
To build the project using gradle, run:
17+
```bash
18+
gradle build && java -jar build/libs/openapi-spring-1.0.0.jar
19+
```
20+
21+
If all builds successfully, the server should run on [http://localhost:8080/](http://localhost:8080/)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
3+
group = "org.openapitools"
4+
version = "1.0.0"
5+
java.sourceCompatibility = JavaVersion.VERSION_17
6+
7+
repositories {
8+
mavenCentral()
9+
}
10+
11+
tasks.withType<KotlinCompile> {
12+
kotlinOptions.jvmTarget = "17"
13+
}
14+
15+
plugins {
16+
val kotlinVersion = "2.2.0"
17+
id("org.jetbrains.kotlin.jvm") version kotlinVersion
18+
id("org.jetbrains.kotlin.plugin.jpa") version kotlinVersion
19+
id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion
20+
id("org.springframework.boot") version "4.0.1"
21+
id("io.spring.dependency-management") version "1.1.7"
22+
}
23+
24+
dependencies {
25+
implementation("org.jetbrains.kotlin:kotlin-stdlib")
26+
implementation("org.jetbrains.kotlin:kotlin-reflect")
27+
implementation("org.springframework.boot:spring-boot-starter-webmvc")
28+
29+
implementation("com.google.code.findbugs:jsr305:3.0.2")
30+
implementation("tools.jackson.dataformat:jackson-dataformat-yaml")
31+
implementation("tools.jackson.dataformat:jackson-dataformat-xml")
32+
implementation("tools.jackson.module:jackson-module-kotlin")
33+
implementation("org.springframework.data:spring-data-commons")
34+
implementation("jakarta.validation:jakarta.validation-api")
35+
implementation("jakarta.annotation:jakarta.annotation-api:3.0.0")
36+
37+
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
38+
testImplementation("org.springframework.boot:spring-boot-starter-test") {
39+
exclude(module = "junit")
40+
}
41+
}
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

samples/server/petstore/kotlin-springboot-4/gradlew

Lines changed: 249 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)