Skip to content

Commit 9cc5d37

Browse files
committed
add files
1 parent b582f16 commit 9cc5d37

4 files changed

Lines changed: 119 additions & 0 deletions

File tree

  • samples/server/others/kotlin-server/polymorphism-and-discriminator/src/main/kotlin/org/openapitools/server
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.openapitools.server
2+
3+
import io.javalin.Javalin
4+
import io.javalin.apibuilder.ApiBuilder.*
5+
6+
7+
fun main() {
8+
9+
val app = Javalin
10+
.create { config ->
11+
config.router.apiBuilder {
12+
}
13+
}
14+
15+
app.start()
16+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Basic polymorphism example with discriminator
3+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
4+
*
5+
* The version of the OpenAPI document: 1.0
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
package org.openapitools.server.models
13+
14+
15+
/**
16+
* A pet cat
17+
* @param huntingSkill The measured skill for hunting
18+
* @param petType
19+
*/
20+
data class Cat(
21+
/* The measured skill for hunting */
22+
23+
@field:com.fasterxml.jackson.annotation.JsonProperty("huntingSkill")
24+
val huntingSkill: Cat.HuntingSkill,
25+
26+
@field:com.fasterxml.jackson.annotation.JsonProperty("petType")
27+
override val petType: kotlin.String = "cat",
28+
29+
) : Pet(petType = petType)
30+
{
31+
/**
32+
* The measured skill for hunting
33+
* Values: clueless,lazy,adventurous,aggressive
34+
*/
35+
enum class HuntingSkill(val value: kotlin.String){
36+
clueless("clueless"),
37+
lazy("lazy"),
38+
adventurous("adventurous"),
39+
aggressive("aggressive");
40+
}
41+
}
42+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Basic polymorphism example with discriminator
3+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
4+
*
5+
* The version of the OpenAPI document: 1.0
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
package org.openapitools.server.models
13+
14+
15+
/**
16+
* A pet dog
17+
* @param petType
18+
* @param packSize the size of the pack the dog is from
19+
*/
20+
data class Dog(
21+
22+
@field:com.fasterxml.jackson.annotation.JsonProperty("petType")
23+
override val petType: kotlin.String = "dog",
24+
/* the size of the pack the dog is from */
25+
26+
@field:com.fasterxml.jackson.annotation.JsonProperty("packSize")
27+
val packSize: kotlin.Int = 0
28+
) : Pet(petType = petType)
29+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Basic polymorphism example with discriminator
3+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
4+
*
5+
* The version of the OpenAPI document: 1.0
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
package org.openapitools.server.models
13+
14+
import org.openapitools.server.models.Cat
15+
import org.openapitools.server.models.Dog
16+
17+
/**
18+
*
19+
* @param petType
20+
*/
21+
@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)
22+
@com.fasterxml.jackson.annotation.JsonSubTypes(
23+
com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = Cat::class, name = "cat"),
24+
com.fasterxml.jackson.annotation.JsonSubTypes.Type(value = Dog::class, name = "dog")
25+
)
26+
sealed class Pet(
27+
28+
@field:com.fasterxml.jackson.annotation.JsonProperty("petType")
29+
open val petType: kotlin.String
30+
31+
)
32+

0 commit comments

Comments
 (0)