Skip to content

Commit 8ebb3cf

Browse files
committed
add generated samples
1 parent e3bb3ad commit 8ebb3cf

File tree

27 files changed

+1191
-21
lines changed

27 files changed

+1191
-21
lines changed

samples/server/others/kotlin-server/polymorphism-and-discriminator-disabled-jackson-fix/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# org.openapitools.server - Kotlin Server library for Basic polymorphism example with discriminator
1+
# org.openapitools.server - Kotlin Server library for Polymorphism example with allOf and discriminator
22

33
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
44

samples/server/others/kotlin-server/polymorphism-and-discriminator-disabled-jackson-fix/src/main/kotlin/org/openapitools/server/models/Cat.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Basic polymorphism example with discriminator
2+
* Polymorphism example with allOf and discriminator
33
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
44
*
55
* The version of the OpenAPI document: 1.0
@@ -11,21 +11,24 @@
1111
*/
1212
package org.openapitools.server.models
1313

14+
import org.openapitools.server.models.Pet
1415

1516
/**
16-
* A pet cat
17+
* A representation of a cat
1718
* @param huntingSkill The measured skill for hunting
18-
* @param petType
1919
*/
2020
data class Cat(
2121
/* The measured skill for hunting */
2222

2323
@field:com.fasterxml.jackson.annotation.JsonProperty("huntingSkill")
2424
val huntingSkill: Cat.HuntingSkill,
2525

26+
@field:com.fasterxml.jackson.annotation.JsonProperty("name")
27+
override val name: kotlin.String,
28+
2629
@field:com.fasterxml.jackson.annotation.JsonProperty("petType")
27-
val petType: kotlin.Any? = null
28-
) : Pet()
30+
override val petType: kotlin.String
31+
) : Pet(name = name, petType = petType)
2932
{
3033
/**
3134
* The measured skill for hunting
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Basic polymorphism example with discriminator
2+
* Polymorphism example with allOf and discriminator
33
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
44
*
55
* The version of the OpenAPI document: 1.0
@@ -11,19 +11,24 @@
1111
*/
1212
package org.openapitools.server.models
1313

14+
import org.openapitools.server.models.Pet
1415

1516
/**
16-
* A pet dog
17-
* @param petType
17+
* A representation of a dog
1818
* @param packSize the size of the pack the dog is from
1919
*/
2020
data class Dog(
21-
22-
@field:com.fasterxml.jackson.annotation.JsonProperty("petType")
23-
val petType: kotlin.Any?,
2421
/* the size of the pack the dog is from */
2522

2623
@field:com.fasterxml.jackson.annotation.JsonProperty("packSize")
27-
val packSize: kotlin.Int = 0
28-
) : Pet()
24+
val packSize: kotlin.Int = 0,
25+
26+
@field:com.fasterxml.jackson.annotation.JsonProperty("name")
27+
override val name: kotlin.String,
28+
29+
@field:com.fasterxml.jackson.annotation.JsonProperty("petType")
30+
override val petType: kotlin.String
31+
) : Pet(name = name, petType = petType)
32+
{
33+
}
2934

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Basic polymorphism example with discriminator
2+
* Polymorphism example with allOf and discriminator
33
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
44
*
55
* The version of the OpenAPI document: 1.0
@@ -11,16 +11,25 @@
1111
*/
1212
package org.openapitools.server.models
1313

14-
import org.openapitools.server.models.Cat
15-
import org.openapitools.server.models.Dog
1614

1715
/**
1816
*
17+
* @param name
18+
* @param petType
1919
*/
20-
@com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, include = com.fasterxml.jackson.annotation.JsonTypeInfo.As.PROPERTY, property = "petType", visible = false)
20+
@com.fasterxml.jackson.annotation.JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME, include = com.fasterxml.jackson.annotation.JsonTypeInfo.As.PROPERTY, property = "petType", visible = true)
2121
@com.fasterxml.jackson.annotation.JsonSubTypes(
22-
com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = Cat::class, name = "cat"),
23-
com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = Dog::class, name = "dog")
22+
com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = Cat::class, name = "Cat"),
23+
com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = Dog::class, name = "Dog")
24+
)
25+
sealed class Pet(
26+
27+
@field:com.fasterxml.jackson.annotation.JsonProperty("name")
28+
open val name: kotlin.String
29+
,
30+
31+
@field:com.fasterxml.jackson.annotation.JsonProperty("petType")
32+
open val petType: kotlin.String
33+
2434
)
25-
sealed class Pet
2635

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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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/configuration/EnumConverterConfiguration.kt
17+
src/main/kotlin/org/openapitools/configuration/ValidSort.kt
18+
src/main/kotlin/org/openapitools/model/Pet.kt
19+
src/main/kotlin/org/openapitools/model/PetSort.kt
20+
src/main/resources/application.yaml
21+
src/test/kotlin/org/openapitools/api/PetApiTest.kt
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.22.0-SNAPSHOT
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# openAPIPetstoreSortValidationTest
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: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
maven { url = uri("https://repo.spring.io/milestone") }
10+
}
11+
12+
tasks.withType<KotlinCompile> {
13+
kotlinOptions.jvmTarget = "17"
14+
}
15+
16+
plugins {
17+
val kotlinVersion = "1.9.25"
18+
id("org.jetbrains.kotlin.jvm") version kotlinVersion
19+
id("org.jetbrains.kotlin.plugin.jpa") version kotlinVersion
20+
id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion
21+
id("org.springframework.boot") version "3.0.2"
22+
id("io.spring.dependency-management") version "1.0.14.RELEASE"
23+
}
24+
25+
dependencies {
26+
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
27+
implementation("org.jetbrains.kotlin:kotlin-reflect")
28+
implementation("org.springframework.boot:spring-boot-starter-web")
29+
30+
implementation("com.google.code.findbugs:jsr305:3.0.2")
31+
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
32+
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml")
33+
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
34+
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
35+
implementation("org.springframework.data:spring-data-commons")
36+
implementation("jakarta.validation:jakarta.validation-api")
37+
implementation("jakarta.annotation:jakarta.annotation-api:2.1.0")
38+
39+
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
40+
testImplementation("org.springframework.boot:spring-boot-starter-test") {
41+
exclude(module = "junit")
42+
}
43+
}
Binary file not shown.

0 commit comments

Comments
 (0)