diff --git a/src/test/kotlin/com/cjbooms/fabrikt/generators/ModelGeneratorTest.kt b/src/test/kotlin/com/cjbooms/fabrikt/generators/ModelGeneratorTest.kt index 024ddb10..d4b1fad2 100644 --- a/src/test/kotlin/com/cjbooms/fabrikt/generators/ModelGeneratorTest.kt +++ b/src/test/kotlin/com/cjbooms/fabrikt/generators/ModelGeneratorTest.kt @@ -7,10 +7,12 @@ import com.cjbooms.fabrikt.cli.ModelCodeGenOptionType import com.cjbooms.fabrikt.cli.ValidationLibrary import com.cjbooms.fabrikt.configurations.Packages import com.cjbooms.fabrikt.generators.model.JacksonModelGenerator +import com.cjbooms.fabrikt.model.KotlinSourceSet import com.cjbooms.fabrikt.model.Models import com.cjbooms.fabrikt.model.SourceApi import com.cjbooms.fabrikt.util.Linter import com.cjbooms.fabrikt.util.ModelNameRegistry +import com.cjbooms.fabrikt.util.ResourceHelper.readFolder import com.cjbooms.fabrikt.util.ResourceHelper.readTextResource import com.squareup.kotlinpoet.FileSpec import org.assertj.core.api.Assertions.assertThat @@ -20,6 +22,9 @@ import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.assertThrows import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.MethodSource +import java.io.File +import java.nio.file.Files +import java.nio.file.Path import java.nio.file.Paths import java.util.stream.Stream @@ -89,14 +94,27 @@ class ModelGeneratorTest { val basePackage = "examples.${testCaseName.replace("/", ".")}" val apiLocation = javaClass.getResource("/examples/$testCaseName/api.yaml")!! val sourceApi = SourceApi(apiLocation.readText(), baseDir = Paths.get(apiLocation.toURI())) - val expectedModels = readTextResource("/examples/$testCaseName/models/Models.kt") + val expectedModels = readFolder(Path.of("src/test/resources/examples/$testCaseName/models/")) val models = JacksonModelGenerator( Packages(basePackage), sourceApi, - ).generate().toSingleFile() + ).generate() - assertThat(models).isEqualTo(expectedModels) + val sourceSet = setOf(KotlinSourceSet(models.files, Paths.get(""))) + val tempDirectory = Files.createTempDirectory("model_generator_test_${testCaseName.replace("/", ".")}") + sourceSet.forEach { + it.writeFileTo(tempDirectory.toFile()) + } + + val tempFolderContents = + readFolder(tempDirectory.resolve(basePackage.replace(".", File.separator)).resolve("models")) + tempFolderContents.forEach { + assertThat(expectedModels).containsKeys(it.key) + assertThat(expectedModels[it.key]).isEqualTo(it.value) + } + + tempDirectory.toFile().deleteRecursively() } @Test diff --git a/src/test/kotlin/com/cjbooms/fabrikt/util/ResourceHelper.kt b/src/test/kotlin/com/cjbooms/fabrikt/util/ResourceHelper.kt index 1d2d65ce..7384d842 100644 --- a/src/test/kotlin/com/cjbooms/fabrikt/util/ResourceHelper.kt +++ b/src/test/kotlin/com/cjbooms/fabrikt/util/ResourceHelper.kt @@ -1,8 +1,15 @@ package com.cjbooms.fabrikt.util import java.io.FileNotFoundException +import java.nio.file.Path +import kotlin.io.path.listDirectoryEntries +import kotlin.io.path.name +import kotlin.io.path.readText object ResourceHelper { fun readTextResource(path: String): String = (javaClass.getResource(path) ?: throw FileNotFoundException(path)).readText() + + fun readFolder(path: Path): Map = + path.listDirectoryEntries().associate { it.name to it.readText() } } diff --git a/src/test/resources/examples/anyOfOneOfAllOf/models/ComplexParent.kt b/src/test/resources/examples/anyOfOneOfAllOf/models/ComplexParent.kt new file mode 100644 index 00000000..9009fb6c --- /dev/null +++ b/src/test/resources/examples/anyOfOneOfAllOf/models/ComplexParent.kt @@ -0,0 +1,32 @@ +package examples.anyOfOneOfAllOf.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import java.math.BigDecimal +import javax.validation.constraints.NotNull +import kotlin.Any +import kotlin.Int +import kotlin.String + +public data class ComplexParent( + @param:JsonProperty("oneOf") + @get:JsonProperty("oneOf") + public val oneOf: Any? = null, + @param:JsonProperty("first_nested_any_of_prop") + @get:JsonProperty("first_nested_any_of_prop") + public val firstNestedAnyOfProp: String? = null, + @param:JsonProperty("second_nested_any_of_prop") + @get:JsonProperty("second_nested_any_of_prop") + public val secondNestedAnyOfProp: String? = null, + @param:JsonProperty("required_string") + @get:JsonProperty("required_string") + @get:NotNull + public val requiredString: String, + @param:JsonProperty("required_int") + @get:JsonProperty("required_int") + @get:NotNull + public val requiredInt: Int, + @param:JsonProperty("top_level_prop") + @get:JsonProperty("top_level_prop") + @get:NotNull + public val topLevelProp: BigDecimal, +) diff --git a/src/test/resources/examples/anyOfOneOfAllOf/models/ComplexSecondOneA.kt b/src/test/resources/examples/anyOfOneOfAllOf/models/ComplexSecondOneA.kt new file mode 100644 index 00000000..3860edb5 --- /dev/null +++ b/src/test/resources/examples/anyOfOneOfAllOf/models/ComplexSecondOneA.kt @@ -0,0 +1,12 @@ +package examples.anyOfOneOfAllOf.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.String + +public data class ComplexSecondOneA( + @param:JsonProperty("more_nested_prop_one") + @get:JsonProperty("more_nested_prop_one") + @get:NotNull + public val moreNestedPropOne: String, +) diff --git a/src/test/resources/examples/anyOfOneOfAllOf/models/ContainsNestedAnyOf.kt b/src/test/resources/examples/anyOfOneOfAllOf/models/ContainsNestedAnyOf.kt new file mode 100644 index 00000000..b6298c99 --- /dev/null +++ b/src/test/resources/examples/anyOfOneOfAllOf/models/ContainsNestedAnyOf.kt @@ -0,0 +1,13 @@ +package examples.anyOfOneOfAllOf.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class ContainsNestedAnyOf( + @param:JsonProperty("first_nested_any_of_prop") + @get:JsonProperty("first_nested_any_of_prop") + public val firstNestedAnyOfProp: String? = null, + @param:JsonProperty("second_nested_any_of_prop") + @get:JsonProperty("second_nested_any_of_prop") + public val secondNestedAnyOfProp: String? = null, +) diff --git a/src/test/resources/examples/anyOfOneOfAllOf/models/FirstAnyA.kt b/src/test/resources/examples/anyOfOneOfAllOf/models/FirstAnyA.kt new file mode 100644 index 00000000..2b805997 --- /dev/null +++ b/src/test/resources/examples/anyOfOneOfAllOf/models/FirstAnyA.kt @@ -0,0 +1,10 @@ +package examples.anyOfOneOfAllOf.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class FirstAnyA( + @param:JsonProperty("first_nested_any_of_prop") + @get:JsonProperty("first_nested_any_of_prop") + public val firstNestedAnyOfProp: String? = null, +) diff --git a/src/test/resources/examples/anyOfOneOfAllOf/models/FirstOneA.kt b/src/test/resources/examples/anyOfOneOfAllOf/models/FirstOneA.kt new file mode 100644 index 00000000..5af5126f --- /dev/null +++ b/src/test/resources/examples/anyOfOneOfAllOf/models/FirstOneA.kt @@ -0,0 +1,10 @@ +package examples.anyOfOneOfAllOf.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class FirstOneA( + @param:JsonProperty("first_nested_one_of_prop") + @get:JsonProperty("first_nested_one_of_prop") + public val firstNestedOneOfProp: String? = null, +) diff --git a/src/test/resources/examples/anyOfOneOfAllOf/models/FirstOneB.kt b/src/test/resources/examples/anyOfOneOfAllOf/models/FirstOneB.kt new file mode 100644 index 00000000..7babbf24 --- /dev/null +++ b/src/test/resources/examples/anyOfOneOfAllOf/models/FirstOneB.kt @@ -0,0 +1,10 @@ +package examples.anyOfOneOfAllOf.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class FirstOneB( + @param:JsonProperty("first_property") + @get:JsonProperty("first_property") + public val firstProperty: String? = null, +) diff --git a/src/test/resources/examples/anyOfOneOfAllOf/models/Models.kt b/src/test/resources/examples/anyOfOneOfAllOf/models/Models.kt deleted file mode 100644 index 367a262d..00000000 --- a/src/test/resources/examples/anyOfOneOfAllOf/models/Models.kt +++ /dev/null @@ -1,132 +0,0 @@ -package examples.anyOfOneOfAllOf.models - -import com.fasterxml.jackson.`annotation`.JsonAnyGetter -import com.fasterxml.jackson.`annotation`.JsonAnySetter -import com.fasterxml.jackson.`annotation`.JsonIgnore -import com.fasterxml.jackson.`annotation`.JsonProperty -import java.math.BigDecimal -import javax.validation.constraints.NotNull -import kotlin.Any -import kotlin.Int -import kotlin.String -import kotlin.collections.Map -import kotlin.collections.MutableMap - -public data class ComplexParent( - @param:JsonProperty("oneOf") - @get:JsonProperty("oneOf") - public val oneOf: Any? = null, - @param:JsonProperty("first_nested_any_of_prop") - @get:JsonProperty("first_nested_any_of_prop") - public val firstNestedAnyOfProp: String? = null, - @param:JsonProperty("second_nested_any_of_prop") - @get:JsonProperty("second_nested_any_of_prop") - public val secondNestedAnyOfProp: String? = null, - @param:JsonProperty("required_string") - @get:JsonProperty("required_string") - @get:NotNull - public val requiredString: String, - @param:JsonProperty("required_int") - @get:JsonProperty("required_int") - @get:NotNull - public val requiredInt: Int, - @param:JsonProperty("top_level_prop") - @get:JsonProperty("top_level_prop") - @get:NotNull - public val topLevelProp: BigDecimal, -) - -public data class ComplexSecondOneA( - @param:JsonProperty("more_nested_prop_one") - @get:JsonProperty("more_nested_prop_one") - @get:NotNull - public val moreNestedPropOne: String, -) - -public data class ContainsNestedAnyOf( - @param:JsonProperty("first_nested_any_of_prop") - @get:JsonProperty("first_nested_any_of_prop") - public val firstNestedAnyOfProp: String? = null, - @param:JsonProperty("second_nested_any_of_prop") - @get:JsonProperty("second_nested_any_of_prop") - public val secondNestedAnyOfProp: String? = null, -) - -public data class FirstAnyA( - @param:JsonProperty("first_nested_any_of_prop") - @get:JsonProperty("first_nested_any_of_prop") - public val firstNestedAnyOfProp: String? = null, -) - -public data class FirstOneA( - @param:JsonProperty("first_nested_one_of_prop") - @get:JsonProperty("first_nested_one_of_prop") - public val firstNestedOneOfProp: String? = null, -) - -public data class FirstOneB( - @param:JsonProperty("first_property") - @get:JsonProperty("first_property") - public val firstProperty: String? = null, -) - -public data class MoreNesting( - @param:JsonProperty("more_nested_prop_one") - @get:JsonProperty("more_nested_prop_one") - @get:NotNull - public val moreNestedPropOne: String, -) - -public data class OneOfAdditionalProps( - @param:JsonProperty("second_nested_any_of_prop") - @get:JsonProperty("second_nested_any_of_prop") - public val secondNestedAnyOfProp: String? = null, - @get:JsonIgnore - public val properties: MutableMap = mutableMapOf(), -) { - @JsonAnyGetter - public fun `get`(): Map = properties - - @JsonAnySetter - public fun `set`(name: String, `value`: Any?) { - properties[name] = value - } -} - -public data class SecondAnyA( - @param:JsonProperty("second_nested_any_of_prop") - @get:JsonProperty("second_nested_any_of_prop") - public val secondNestedAnyOfProp: String? = null, -) - -public data class SecondOneB( - @param:JsonProperty("second_property") - @get:JsonProperty("second_property") - public val secondProperty: String? = null, - @param:JsonProperty("third_property") - @get:JsonProperty("third_property") - public val thirdProperty: String? = null, - @param:JsonProperty("forth_property") - @get:JsonProperty("forth_property") - public val forthProperty: Any? = null, -) - -public data class SimpleOneOfs( - @param:JsonProperty("oneof_property") - @get:JsonProperty("oneof_property") - public val oneofProperty: Any? = null, - @param:JsonProperty("primitive_oneof_property") - @get:JsonProperty("primitive_oneof_property") - public val primitiveOneofProperty: Any? = null, -) - -public data class SimpleTypeWithRequiredProps( - @param:JsonProperty("required_string") - @get:JsonProperty("required_string") - @get:NotNull - public val requiredString: String, - @param:JsonProperty("required_int") - @get:JsonProperty("required_int") - @get:NotNull - public val requiredInt: Int, -) diff --git a/src/test/resources/examples/anyOfOneOfAllOf/models/MoreNesting.kt b/src/test/resources/examples/anyOfOneOfAllOf/models/MoreNesting.kt new file mode 100644 index 00000000..2a58cbbc --- /dev/null +++ b/src/test/resources/examples/anyOfOneOfAllOf/models/MoreNesting.kt @@ -0,0 +1,12 @@ +package examples.anyOfOneOfAllOf.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.String + +public data class MoreNesting( + @param:JsonProperty("more_nested_prop_one") + @get:JsonProperty("more_nested_prop_one") + @get:NotNull + public val moreNestedPropOne: String, +) diff --git a/src/test/resources/examples/anyOfOneOfAllOf/models/OneOfAdditionalProps.kt b/src/test/resources/examples/anyOfOneOfAllOf/models/OneOfAdditionalProps.kt new file mode 100644 index 00000000..2d8925cc --- /dev/null +++ b/src/test/resources/examples/anyOfOneOfAllOf/models/OneOfAdditionalProps.kt @@ -0,0 +1,26 @@ +package examples.anyOfOneOfAllOf.models + +import com.fasterxml.jackson.`annotation`.JsonAnyGetter +import com.fasterxml.jackson.`annotation`.JsonAnySetter +import com.fasterxml.jackson.`annotation`.JsonIgnore +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.Any +import kotlin.String +import kotlin.collections.Map +import kotlin.collections.MutableMap + +public data class OneOfAdditionalProps( + @param:JsonProperty("second_nested_any_of_prop") + @get:JsonProperty("second_nested_any_of_prop") + public val secondNestedAnyOfProp: String? = null, + @get:JsonIgnore + public val properties: MutableMap = mutableMapOf(), +) { + @JsonAnyGetter + public fun `get`(): Map = properties + + @JsonAnySetter + public fun `set`(name: String, `value`: Any?) { + properties[name] = value + } +} diff --git a/src/test/resources/examples/anyOfOneOfAllOf/models/SecondAnyA.kt b/src/test/resources/examples/anyOfOneOfAllOf/models/SecondAnyA.kt new file mode 100644 index 00000000..2f00d989 --- /dev/null +++ b/src/test/resources/examples/anyOfOneOfAllOf/models/SecondAnyA.kt @@ -0,0 +1,10 @@ +package examples.anyOfOneOfAllOf.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class SecondAnyA( + @param:JsonProperty("second_nested_any_of_prop") + @get:JsonProperty("second_nested_any_of_prop") + public val secondNestedAnyOfProp: String? = null, +) diff --git a/src/test/resources/examples/anyOfOneOfAllOf/models/SecondOneB.kt b/src/test/resources/examples/anyOfOneOfAllOf/models/SecondOneB.kt new file mode 100644 index 00000000..447436b4 --- /dev/null +++ b/src/test/resources/examples/anyOfOneOfAllOf/models/SecondOneB.kt @@ -0,0 +1,17 @@ +package examples.anyOfOneOfAllOf.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.Any +import kotlin.String + +public data class SecondOneB( + @param:JsonProperty("second_property") + @get:JsonProperty("second_property") + public val secondProperty: String? = null, + @param:JsonProperty("third_property") + @get:JsonProperty("third_property") + public val thirdProperty: String? = null, + @param:JsonProperty("forth_property") + @get:JsonProperty("forth_property") + public val forthProperty: Any? = null, +) diff --git a/src/test/resources/examples/anyOfOneOfAllOf/models/SimpleOneOfs.kt b/src/test/resources/examples/anyOfOneOfAllOf/models/SimpleOneOfs.kt new file mode 100644 index 00000000..ff4d1c36 --- /dev/null +++ b/src/test/resources/examples/anyOfOneOfAllOf/models/SimpleOneOfs.kt @@ -0,0 +1,13 @@ +package examples.anyOfOneOfAllOf.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.Any + +public data class SimpleOneOfs( + @param:JsonProperty("oneof_property") + @get:JsonProperty("oneof_property") + public val oneofProperty: Any? = null, + @param:JsonProperty("primitive_oneof_property") + @get:JsonProperty("primitive_oneof_property") + public val primitiveOneofProperty: Any? = null, +) diff --git a/src/test/resources/examples/anyOfOneOfAllOf/models/SimpleTypeWithRequiredProps.kt b/src/test/resources/examples/anyOfOneOfAllOf/models/SimpleTypeWithRequiredProps.kt new file mode 100644 index 00000000..41d2a4da --- /dev/null +++ b/src/test/resources/examples/anyOfOneOfAllOf/models/SimpleTypeWithRequiredProps.kt @@ -0,0 +1,17 @@ +package examples.anyOfOneOfAllOf.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.Int +import kotlin.String + +public data class SimpleTypeWithRequiredProps( + @param:JsonProperty("required_string") + @get:JsonProperty("required_string") + @get:NotNull + public val requiredString: String, + @param:JsonProperty("required_int") + @get:JsonProperty("required_int") + @get:NotNull + public val requiredInt: Int, +) diff --git a/src/test/resources/examples/arrays/models/ArrayComplexInLined.kt b/src/test/resources/examples/arrays/models/ArrayComplexInLined.kt new file mode 100644 index 00000000..c70a3796 --- /dev/null +++ b/src/test/resources/examples/arrays/models/ArrayComplexInLined.kt @@ -0,0 +1,14 @@ +package examples.arrays.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import javax.validation.constraints.NotNull +import kotlin.collections.List + +public data class ArrayComplexInLined( + @param:JsonProperty("quantities") + @get:JsonProperty("quantities") + @get:NotNull + @get:Valid + public val quantities: List, +) diff --git a/src/test/resources/examples/arrays/models/ArrayComplexInLinedQuantities.kt b/src/test/resources/examples/arrays/models/ArrayComplexInLinedQuantities.kt new file mode 100644 index 00000000..19caff15 --- /dev/null +++ b/src/test/resources/examples/arrays/models/ArrayComplexInLinedQuantities.kt @@ -0,0 +1,10 @@ +package examples.arrays.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class ArrayComplexInLinedQuantities( + @param:JsonProperty("prop_one") + @get:JsonProperty("prop_one") + public val propOne: String? = null, +) diff --git a/src/test/resources/examples/arrays/models/ArrayRef.kt b/src/test/resources/examples/arrays/models/ArrayRef.kt new file mode 100644 index 00000000..96379aa2 --- /dev/null +++ b/src/test/resources/examples/arrays/models/ArrayRef.kt @@ -0,0 +1,10 @@ +package examples.arrays.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.Int + +public data class ArrayRef( + @param:JsonProperty("grams") + @get:JsonProperty("grams") + public val grams: Int? = null, +) diff --git a/src/test/resources/examples/arrays/models/ArraySimpleInLined.kt b/src/test/resources/examples/arrays/models/ArraySimpleInLined.kt new file mode 100644 index 00000000..be7745cd --- /dev/null +++ b/src/test/resources/examples/arrays/models/ArraySimpleInLined.kt @@ -0,0 +1,13 @@ +package examples.arrays.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.Long +import kotlin.collections.List + +public data class ArraySimpleInLined( + @param:JsonProperty("quantities") + @get:JsonProperty("quantities") + @get:NotNull + public val quantities: List, +) diff --git a/src/test/resources/examples/arrays/models/ContainsArrayOfArrays.kt b/src/test/resources/examples/arrays/models/ContainsArrayOfArrays.kt new file mode 100644 index 00000000..31266fb8 --- /dev/null +++ b/src/test/resources/examples/arrays/models/ContainsArrayOfArrays.kt @@ -0,0 +1,12 @@ +package examples.arrays.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import kotlin.collections.List + +public data class ContainsArrayOfArrays( + @param:JsonProperty("array_of_arrays") + @get:JsonProperty("array_of_arrays") + @get:Valid + public val arrayOfArrays: List>? = null, +) diff --git a/src/test/resources/examples/arrays/models/ContainsArrayRef.kt b/src/test/resources/examples/arrays/models/ContainsArrayRef.kt new file mode 100644 index 00000000..314c611b --- /dev/null +++ b/src/test/resources/examples/arrays/models/ContainsArrayRef.kt @@ -0,0 +1,14 @@ +package examples.arrays.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import javax.validation.constraints.NotNull +import kotlin.collections.List + +public data class ContainsArrayRef( + @param:JsonProperty("weight_on_mars") + @get:JsonProperty("weight_on_mars") + @get:NotNull + @get:Valid + public val weightOnMars: List, +) diff --git a/src/test/resources/examples/arrays/models/Models.kt b/src/test/resources/examples/arrays/models/Models.kt deleted file mode 100644 index e4398f16..00000000 --- a/src/test/resources/examples/arrays/models/Models.kt +++ /dev/null @@ -1,57 +0,0 @@ -package examples.arrays.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import javax.validation.Valid -import javax.validation.constraints.NotNull -import kotlin.Int -import kotlin.Long -import kotlin.String -import kotlin.collections.List - -public data class ArrayComplexInLined( - @param:JsonProperty("quantities") - @get:JsonProperty("quantities") - @get:NotNull - @get:Valid - public val quantities: List, -) - -public data class ArrayComplexInLinedQuantities( - @param:JsonProperty("prop_one") - @get:JsonProperty("prop_one") - public val propOne: String? = null, -) - -public data class ArrayRef( - @param:JsonProperty("grams") - @get:JsonProperty("grams") - public val grams: Int? = null, -) - -public data class ArraySimpleInLined( - @param:JsonProperty("quantities") - @get:JsonProperty("quantities") - @get:NotNull - public val quantities: List, -) - -public data class ContainsArrayOfArrays( - @param:JsonProperty("array_of_arrays") - @get:JsonProperty("array_of_arrays") - @get:Valid - public val arrayOfArrays: List>? = null, -) - -public data class ContainsArrayRef( - @param:JsonProperty("weight_on_mars") - @get:JsonProperty("weight_on_mars") - @get:NotNull - @get:Valid - public val weightOnMars: List, -) - -public data class Something( - @param:JsonProperty("some_value") - @get:JsonProperty("some_value") - public val someValue: Int? = null, -) diff --git a/src/test/resources/examples/arrays/models/Something.kt b/src/test/resources/examples/arrays/models/Something.kt new file mode 100644 index 00000000..65d5730a --- /dev/null +++ b/src/test/resources/examples/arrays/models/Something.kt @@ -0,0 +1,10 @@ +package examples.arrays.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.Int + +public data class Something( + @param:JsonProperty("some_value") + @get:JsonProperty("some_value") + public val someValue: Int? = null, +) diff --git a/src/test/resources/examples/binary/models/Models.kt b/src/test/resources/examples/binary/models/BinaryData.kt similarity index 53% rename from src/test/resources/examples/binary/models/Models.kt rename to src/test/resources/examples/binary/models/BinaryData.kt index 77016fca..b99999f3 100644 --- a/src/test/resources/examples/binary/models/Models.kt +++ b/src/test/resources/examples/binary/models/BinaryData.kt @@ -4,7 +4,7 @@ import com.fasterxml.jackson.`annotation`.JsonProperty import kotlin.ByteArray public data class BinaryData( - @param:JsonProperty("binaryValue") - @get:JsonProperty("binaryValue") - public val binaryValue: ByteArray? = null, + @param:JsonProperty("binaryValue") + @get:JsonProperty("binaryValue") + public val binaryValue: ByteArray? = null, ) diff --git a/src/test/resources/examples/customExtensions/models/InnerMergePatch.kt b/src/test/resources/examples/customExtensions/models/InnerMergePatch.kt new file mode 100644 index 00000000..d08c541b --- /dev/null +++ b/src/test/resources/examples/customExtensions/models/InnerMergePatch.kt @@ -0,0 +1,11 @@ +package examples.customExtensions.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String +import org.openapitools.jackson.nullable.JsonNullable + +public data class InnerMergePatch( + @param:JsonProperty("p") + @get:JsonProperty("p") + public val p: JsonNullable = JsonNullable.undefined(), +) diff --git a/src/test/resources/examples/customExtensions/models/InnerNotMergePatch.kt b/src/test/resources/examples/customExtensions/models/InnerNotMergePatch.kt new file mode 100644 index 00000000..fe13697a --- /dev/null +++ b/src/test/resources/examples/customExtensions/models/InnerNotMergePatch.kt @@ -0,0 +1,10 @@ +package examples.customExtensions.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class InnerNotMergePatch( + @param:JsonProperty("p") + @get:JsonProperty("p") + public val p: String? = null, +) diff --git a/src/test/resources/examples/customExtensions/models/InnerOnlyMergePatchInline.kt b/src/test/resources/examples/customExtensions/models/InnerOnlyMergePatchInline.kt new file mode 100644 index 00000000..3c2f344b --- /dev/null +++ b/src/test/resources/examples/customExtensions/models/InnerOnlyMergePatchInline.kt @@ -0,0 +1,11 @@ +package examples.customExtensions.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid + +public data class InnerOnlyMergePatchInline( + @param:JsonProperty("inner") + @get:JsonProperty("inner") + @get:Valid + public val `inner`: InnerOnlyMergePatchInlineInner? = null, +) diff --git a/src/test/resources/examples/customExtensions/models/InnerOnlyMergePatchInlineInner.kt b/src/test/resources/examples/customExtensions/models/InnerOnlyMergePatchInlineInner.kt new file mode 100644 index 00000000..5ee04864 --- /dev/null +++ b/src/test/resources/examples/customExtensions/models/InnerOnlyMergePatchInlineInner.kt @@ -0,0 +1,11 @@ +package examples.customExtensions.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String +import org.openapitools.jackson.nullable.JsonNullable + +public data class InnerOnlyMergePatchInlineInner( + @param:JsonProperty("p") + @get:JsonProperty("p") + public val p: JsonNullable = JsonNullable.undefined(), +) diff --git a/src/test/resources/examples/customExtensions/models/InnerOnlyMergePatchRef.kt b/src/test/resources/examples/customExtensions/models/InnerOnlyMergePatchRef.kt new file mode 100644 index 00000000..6f3bae6e --- /dev/null +++ b/src/test/resources/examples/customExtensions/models/InnerOnlyMergePatchRef.kt @@ -0,0 +1,11 @@ +package examples.customExtensions.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid + +public data class InnerOnlyMergePatchRef( + @param:JsonProperty("inner") + @get:JsonProperty("inner") + @get:Valid + public val `inner`: InnerMergePatch? = null, +) diff --git a/src/test/resources/examples/customExtensions/models/Models.kt b/src/test/resources/examples/customExtensions/models/Models.kt deleted file mode 100644 index ee998969..00000000 --- a/src/test/resources/examples/customExtensions/models/Models.kt +++ /dev/null @@ -1,152 +0,0 @@ -package examples.customExtensions.models - -import com.fasterxml.jackson.`annotation`.JsonInclude -import com.fasterxml.jackson.`annotation`.JsonProperty -import org.openapitools.jackson.nullable.JsonNullable -import javax.validation.Valid -import javax.validation.constraints.NotNull -import kotlin.String - -public data class InnerMergePatch( - @param:JsonProperty("p") - @get:JsonProperty("p") - public val p: JsonNullable = JsonNullable.undefined(), -) - -public data class InnerNotMergePatch( - @param:JsonProperty("p") - @get:JsonProperty("p") - public val p: String? = null, -) - -public data class InnerOnlyMergePatchInline( - @param:JsonProperty("inner") - @get:JsonProperty("inner") - @get:Valid - public val `inner`: InnerOnlyMergePatchInlineInner? = null, -) - -public data class InnerOnlyMergePatchInlineInner( - @param:JsonProperty("p") - @get:JsonProperty("p") - public val p: JsonNullable = JsonNullable.undefined(), -) - -public data class InnerOnlyMergePatchRef( - @param:JsonProperty("inner") - @get:JsonProperty("inner") - @get:Valid - public val `inner`: InnerMergePatch? = null, -) - -public data class NestedMergePatchInline( - @param:JsonProperty("inner") - @get:JsonProperty("inner") - @get:Valid - public val `inner`: JsonNullable = JsonNullable.undefined(), -) - -public data class NestedMergePatchInlineInner( - @param:JsonProperty("p") - @get:JsonProperty("p") - public val p: JsonNullable = JsonNullable.undefined(), -) - -public data class NestedMergePatchRef( - @param:JsonProperty("inner") - @get:JsonProperty("inner") - @get:Valid - public val `inner`: JsonNullable = JsonNullable.undefined(), -) - -public data class NoMergePatchInline( - @param:JsonProperty("inner") - @get:JsonProperty("inner") - @get:Valid - public val `inner`: NoMergePatchInlineInner? = null, -) - -public data class NoMergePatchInlineInner( - @param:JsonProperty("p") - @get:JsonProperty("p") - public val p: String? = null, -) - -public data class NoMergePatchRef( - @param:JsonProperty("inner") - @get:JsonProperty("inner") - @get:Valid - public val `inner`: InnerNotMergePatch? = null, -) - -public data class NullabilityCheck( - @param:JsonProperty("not-null-no-default-not-required") - @get:JsonProperty("not-null-no-default-not-required") - public val notNullNoDefaultNotRequired: JsonNullable = JsonNullable.undefined(), - @param:JsonProperty("nullable-no-default-not-required") - @get:JsonProperty("nullable-no-default-not-required") - public val nullableNoDefaultNotRequired: JsonNullable = JsonNullable.undefined(), - @param:JsonProperty("not-null-with-default-not-required") - @get:JsonProperty("not-null-with-default-not-required") - @get:NotNull - public val notNullWithDefaultNotRequired: JsonNullable = JsonNullable.of(""), - @param:JsonProperty("nullable-with-default-not-required") - @get:JsonProperty("nullable-with-default-not-required") - public val nullableWithDefaultNotRequired: JsonNullable = JsonNullable.of(""), - @param:JsonProperty("not-null-no-default-required") - @get:JsonProperty("not-null-no-default-required") - @get:NotNull - public val notNullNoDefaultRequired: String, - @param:JsonProperty("nullable-no-default-required") - @get:JsonProperty("nullable-no-default-required") - public val nullableNoDefaultRequired: String?, - @param:JsonProperty("not-null-with-default-required") - @get:JsonProperty("not-null-with-default-required") - @get:NotNull - public val notNullWithDefaultRequired: String, - @param:JsonProperty("nullable-with-default-required") - @get:JsonProperty("nullable-with-default-required") - public val nullableWithDefaultRequired: String?, -) - -public data class ParentWithIncludeNonNullExtension( - @param:JsonProperty("simpleNullable") - @get:JsonProperty("simpleNullable") - @param:JsonInclude(JsonInclude.Include.NON_NULL) - public val simpleNullable: String? = null, - @param:JsonProperty("simpleRequired") - @get:JsonProperty("simpleRequired") - @get:NotNull - public val simpleRequired: String, - @param:JsonProperty("childWithout") - @get:JsonProperty("childWithout") - @get:Valid - @param:JsonInclude(JsonInclude.Include.NON_NULL) - public val childWithout: ParentWithIncludeNonNullExtensionChildWithout? = null, -) - -public data class ParentWithIncludeNonNullExtensionChildWithout( - @param:JsonProperty("direct") - @get:JsonProperty("direct") - public val direct: String? = null, -) - -public data class TopLevelLevelMergePatchInline( - @param:JsonProperty("inner") - @get:JsonProperty("inner") - @get:Valid - public val `inner`: JsonNullable = JsonNullable.undefined(), -) - -public data class TopLevelLevelMergePatchInlineInner( - @param:JsonProperty("p") - @get:JsonProperty("p") - public val p: String? = null, -) - -public data class TopLevelLevelMergePatchRef( - @param:JsonProperty("inner") - @get:JsonProperty("inner") - @get:Valid - public val `inner`: JsonNullable = JsonNullable.undefined(), -) diff --git a/src/test/resources/examples/customExtensions/models/NestedMergePatchInline.kt b/src/test/resources/examples/customExtensions/models/NestedMergePatchInline.kt new file mode 100644 index 00000000..058c7502 --- /dev/null +++ b/src/test/resources/examples/customExtensions/models/NestedMergePatchInline.kt @@ -0,0 +1,12 @@ +package examples.customExtensions.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import org.openapitools.jackson.nullable.JsonNullable + +public data class NestedMergePatchInline( + @param:JsonProperty("inner") + @get:JsonProperty("inner") + @get:Valid + public val `inner`: JsonNullable = JsonNullable.undefined(), +) diff --git a/src/test/resources/examples/customExtensions/models/NestedMergePatchInlineInner.kt b/src/test/resources/examples/customExtensions/models/NestedMergePatchInlineInner.kt new file mode 100644 index 00000000..cffd78fc --- /dev/null +++ b/src/test/resources/examples/customExtensions/models/NestedMergePatchInlineInner.kt @@ -0,0 +1,11 @@ +package examples.customExtensions.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String +import org.openapitools.jackson.nullable.JsonNullable + +public data class NestedMergePatchInlineInner( + @param:JsonProperty("p") + @get:JsonProperty("p") + public val p: JsonNullable = JsonNullable.undefined(), +) diff --git a/src/test/resources/examples/customExtensions/models/NestedMergePatchRef.kt b/src/test/resources/examples/customExtensions/models/NestedMergePatchRef.kt new file mode 100644 index 00000000..5ee6a6eb --- /dev/null +++ b/src/test/resources/examples/customExtensions/models/NestedMergePatchRef.kt @@ -0,0 +1,12 @@ +package examples.customExtensions.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import org.openapitools.jackson.nullable.JsonNullable + +public data class NestedMergePatchRef( + @param:JsonProperty("inner") + @get:JsonProperty("inner") + @get:Valid + public val `inner`: JsonNullable = JsonNullable.undefined(), +) diff --git a/src/test/resources/examples/customExtensions/models/NoMergePatchInline.kt b/src/test/resources/examples/customExtensions/models/NoMergePatchInline.kt new file mode 100644 index 00000000..47b42a65 --- /dev/null +++ b/src/test/resources/examples/customExtensions/models/NoMergePatchInline.kt @@ -0,0 +1,11 @@ +package examples.customExtensions.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid + +public data class NoMergePatchInline( + @param:JsonProperty("inner") + @get:JsonProperty("inner") + @get:Valid + public val `inner`: NoMergePatchInlineInner? = null, +) diff --git a/src/test/resources/examples/customExtensions/models/NoMergePatchInlineInner.kt b/src/test/resources/examples/customExtensions/models/NoMergePatchInlineInner.kt new file mode 100644 index 00000000..08af591d --- /dev/null +++ b/src/test/resources/examples/customExtensions/models/NoMergePatchInlineInner.kt @@ -0,0 +1,10 @@ +package examples.customExtensions.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class NoMergePatchInlineInner( + @param:JsonProperty("p") + @get:JsonProperty("p") + public val p: String? = null, +) diff --git a/src/test/resources/examples/customExtensions/models/NoMergePatchRef.kt b/src/test/resources/examples/customExtensions/models/NoMergePatchRef.kt new file mode 100644 index 00000000..0b21c090 --- /dev/null +++ b/src/test/resources/examples/customExtensions/models/NoMergePatchRef.kt @@ -0,0 +1,11 @@ +package examples.customExtensions.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid + +public data class NoMergePatchRef( + @param:JsonProperty("inner") + @get:JsonProperty("inner") + @get:Valid + public val `inner`: InnerNotMergePatch? = null, +) diff --git a/src/test/resources/examples/customExtensions/models/NullabilityCheck.kt b/src/test/resources/examples/customExtensions/models/NullabilityCheck.kt new file mode 100644 index 00000000..da2705e3 --- /dev/null +++ b/src/test/resources/examples/customExtensions/models/NullabilityCheck.kt @@ -0,0 +1,36 @@ +package examples.customExtensions.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.String +import org.openapitools.jackson.nullable.JsonNullable + +public data class NullabilityCheck( + @param:JsonProperty("not-null-no-default-not-required") + @get:JsonProperty("not-null-no-default-not-required") + public val notNullNoDefaultNotRequired: JsonNullable = JsonNullable.undefined(), + @param:JsonProperty("nullable-no-default-not-required") + @get:JsonProperty("nullable-no-default-not-required") + public val nullableNoDefaultNotRequired: JsonNullable = JsonNullable.undefined(), + @param:JsonProperty("not-null-with-default-not-required") + @get:JsonProperty("not-null-with-default-not-required") + @get:NotNull + public val notNullWithDefaultNotRequired: JsonNullable = JsonNullable.of(""), + @param:JsonProperty("nullable-with-default-not-required") + @get:JsonProperty("nullable-with-default-not-required") + public val nullableWithDefaultNotRequired: JsonNullable = JsonNullable.of(""), + @param:JsonProperty("not-null-no-default-required") + @get:JsonProperty("not-null-no-default-required") + @get:NotNull + public val notNullNoDefaultRequired: String, + @param:JsonProperty("nullable-no-default-required") + @get:JsonProperty("nullable-no-default-required") + public val nullableNoDefaultRequired: String?, + @param:JsonProperty("not-null-with-default-required") + @get:JsonProperty("not-null-with-default-required") + @get:NotNull + public val notNullWithDefaultRequired: String, + @param:JsonProperty("nullable-with-default-required") + @get:JsonProperty("nullable-with-default-required") + public val nullableWithDefaultRequired: String?, +) diff --git a/src/test/resources/examples/customExtensions/models/ParentWithIncludeNonNullExtension.kt b/src/test/resources/examples/customExtensions/models/ParentWithIncludeNonNullExtension.kt new file mode 100644 index 00000000..b501043e --- /dev/null +++ b/src/test/resources/examples/customExtensions/models/ParentWithIncludeNonNullExtension.kt @@ -0,0 +1,23 @@ +package examples.customExtensions.models + +import com.fasterxml.jackson.`annotation`.JsonInclude +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import javax.validation.constraints.NotNull +import kotlin.String + +public data class ParentWithIncludeNonNullExtension( + @param:JsonProperty("simpleNullable") + @get:JsonProperty("simpleNullable") + @param:JsonInclude(JsonInclude.Include.NON_NULL) + public val simpleNullable: String? = null, + @param:JsonProperty("simpleRequired") + @get:JsonProperty("simpleRequired") + @get:NotNull + public val simpleRequired: String, + @param:JsonProperty("childWithout") + @get:JsonProperty("childWithout") + @get:Valid + @param:JsonInclude(JsonInclude.Include.NON_NULL) + public val childWithout: ParentWithIncludeNonNullExtensionChildWithout? = null, +) diff --git a/src/test/resources/examples/customExtensions/models/ParentWithIncludeNonNullExtensionChildWithout.kt b/src/test/resources/examples/customExtensions/models/ParentWithIncludeNonNullExtensionChildWithout.kt new file mode 100644 index 00000000..16c29e2b --- /dev/null +++ b/src/test/resources/examples/customExtensions/models/ParentWithIncludeNonNullExtensionChildWithout.kt @@ -0,0 +1,10 @@ +package examples.customExtensions.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class ParentWithIncludeNonNullExtensionChildWithout( + @param:JsonProperty("direct") + @get:JsonProperty("direct") + public val direct: String? = null, +) diff --git a/src/test/resources/examples/customExtensions/models/TopLevelLevelMergePatchInline.kt b/src/test/resources/examples/customExtensions/models/TopLevelLevelMergePatchInline.kt new file mode 100644 index 00000000..ca571df7 --- /dev/null +++ b/src/test/resources/examples/customExtensions/models/TopLevelLevelMergePatchInline.kt @@ -0,0 +1,12 @@ +package examples.customExtensions.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import org.openapitools.jackson.nullable.JsonNullable + +public data class TopLevelLevelMergePatchInline( + @param:JsonProperty("inner") + @get:JsonProperty("inner") + @get:Valid + public val `inner`: JsonNullable = JsonNullable.undefined(), +) diff --git a/src/test/resources/examples/customExtensions/models/TopLevelLevelMergePatchInlineInner.kt b/src/test/resources/examples/customExtensions/models/TopLevelLevelMergePatchInlineInner.kt new file mode 100644 index 00000000..c02fdb28 --- /dev/null +++ b/src/test/resources/examples/customExtensions/models/TopLevelLevelMergePatchInlineInner.kt @@ -0,0 +1,10 @@ +package examples.customExtensions.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class TopLevelLevelMergePatchInlineInner( + @param:JsonProperty("p") + @get:JsonProperty("p") + public val p: String? = null, +) diff --git a/src/test/resources/examples/customExtensions/models/TopLevelLevelMergePatchRef.kt b/src/test/resources/examples/customExtensions/models/TopLevelLevelMergePatchRef.kt new file mode 100644 index 00000000..36c14e9e --- /dev/null +++ b/src/test/resources/examples/customExtensions/models/TopLevelLevelMergePatchRef.kt @@ -0,0 +1,12 @@ +package examples.customExtensions.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import org.openapitools.jackson.nullable.JsonNullable + +public data class TopLevelLevelMergePatchRef( + @param:JsonProperty("inner") + @get:JsonProperty("inner") + @get:Valid + public val `inner`: JsonNullable = JsonNullable.undefined(), +) diff --git a/src/test/resources/examples/deepNestedSharingReferences/models/Address.kt b/src/test/resources/examples/deepNestedSharingReferences/models/Address.kt new file mode 100644 index 00000000..e16351d5 --- /dev/null +++ b/src/test/resources/examples/deepNestedSharingReferences/models/Address.kt @@ -0,0 +1,10 @@ +package examples.deepNestedSharingReferences.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class Address( + @param:JsonProperty("eircode") + @get:JsonProperty("eircode") + public val eircode: String? = null, +) diff --git a/src/test/resources/examples/deepNestedSharingReferences/models/Company.kt b/src/test/resources/examples/deepNestedSharingReferences/models/Company.kt new file mode 100644 index 00000000..87a1fe41 --- /dev/null +++ b/src/test/resources/examples/deepNestedSharingReferences/models/Company.kt @@ -0,0 +1,15 @@ +package examples.deepNestedSharingReferences.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid + +public data class Company( + @param:JsonProperty("owner") + @get:JsonProperty("owner") + @get:Valid + public val owner: Person? = null, + @param:JsonProperty("employee") + @get:JsonProperty("employee") + @get:Valid + public val employee: Person? = null, +) diff --git a/src/test/resources/examples/deepNestedSharingReferences/models/Department.kt b/src/test/resources/examples/deepNestedSharingReferences/models/Department.kt new file mode 100644 index 00000000..55a18656 --- /dev/null +++ b/src/test/resources/examples/deepNestedSharingReferences/models/Department.kt @@ -0,0 +1,15 @@ +package examples.deepNestedSharingReferences.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid + +public data class Department( + @param:JsonProperty("supervisor") + @get:JsonProperty("supervisor") + @get:Valid + public val supervisor: Person? = null, + @param:JsonProperty("manager") + @get:JsonProperty("manager") + @get:Valid + public val manager: Person? = null, +) diff --git a/src/test/resources/examples/deepNestedSharingReferences/models/Models.kt b/src/test/resources/examples/deepNestedSharingReferences/models/Models.kt deleted file mode 100644 index 92acfc82..00000000 --- a/src/test/resources/examples/deepNestedSharingReferences/models/Models.kt +++ /dev/null @@ -1,40 +0,0 @@ -package examples.deepNestedSharingReferences.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import javax.validation.Valid -import kotlin.String - -public data class Address( - @param:JsonProperty("eircode") - @get:JsonProperty("eircode") - public val eircode: String? = null, -) - -public data class Company( - @param:JsonProperty("owner") - @get:JsonProperty("owner") - @get:Valid - public val owner: Person? = null, - @param:JsonProperty("employee") - @get:JsonProperty("employee") - @get:Valid - public val employee: Person? = null, -) - -public data class Department( - @param:JsonProperty("supervisor") - @get:JsonProperty("supervisor") - @get:Valid - public val supervisor: Person? = null, - @param:JsonProperty("manager") - @get:JsonProperty("manager") - @get:Valid - public val manager: Person? = null, -) - -public data class Person( - @param:JsonProperty("home_address") - @get:JsonProperty("home_address") - @get:Valid - public val homeAddress: Address? = null, -) diff --git a/src/test/resources/examples/deepNestedSharingReferences/models/Person.kt b/src/test/resources/examples/deepNestedSharingReferences/models/Person.kt new file mode 100644 index 00000000..d4929ec8 --- /dev/null +++ b/src/test/resources/examples/deepNestedSharingReferences/models/Person.kt @@ -0,0 +1,11 @@ +package examples.deepNestedSharingReferences.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid + +public data class Person( + @param:JsonProperty("home_address") + @get:JsonProperty("home_address") + @get:Valid + public val homeAddress: Address? = null, +) diff --git a/src/test/resources/examples/defaultValues/models/Models.kt b/src/test/resources/examples/defaultValues/models/Models.kt deleted file mode 100644 index ec06304f..00000000 --- a/src/test/resources/examples/defaultValues/models/Models.kt +++ /dev/null @@ -1,80 +0,0 @@ -package examples.defaultValues.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import com.fasterxml.jackson.`annotation`.JsonValue -import java.net.URI -import java.util.Base64 -import javax.validation.constraints.NotNull -import kotlin.Boolean -import kotlin.ByteArray -import kotlin.Int -import kotlin.String -import kotlin.collections.Map - -public data class PersonWithDefaults( - @param:JsonProperty("required_so_default_ignored") - @get:JsonProperty("required_so_default_ignored") - @get:NotNull - public val requiredSoDefaultIgnored: String, - @param:JsonProperty("integer_default") - @get:JsonProperty("integer_default") - @get:NotNull - public val integerDefault: Int = 18, - @param:JsonProperty("enum_default") - @get:JsonProperty("enum_default") - @get:NotNull - public val enumDefault: PersonWithDefaultsEnumDefault = PersonWithDefaultsEnumDefault.TALL, - @param:JsonProperty("enum_quoted_default") - @get:JsonProperty("enum_quoted_default") - @get:NotNull - public val enumQuotedDefault: PersonWithDefaultsEnumQuotedDefault = - PersonWithDefaultsEnumQuotedDefault.`2X`, - @param:JsonProperty("boolean_default") - @get:JsonProperty("boolean_default") - @get:NotNull - public val booleanDefault: Boolean = true, - @param:JsonProperty("string_phrase") - @get:JsonProperty("string_phrase") - @get:NotNull - public val stringPhrase: String = "Cowabunga Dude", - @param:JsonProperty("uri_type") - @get:JsonProperty("uri_type") - @get:NotNull - public val uriType: URI = URI("about:blank"), - @param:JsonProperty("byte_type") - @get:JsonProperty("byte_type") - @get:NotNull - public val byteType: ByteArray = Base64.getDecoder().decode("U3dhZ2dlciByb2Nrcw=="), -) - -public enum class PersonWithDefaultsEnumDefault( - @JsonValue - public val `value`: String, -) { - TALL("tall"), - SHORT("short"), - ; - - public companion object { - private val mapping: Map = - values().associateBy(PersonWithDefaultsEnumDefault::value) - - public fun fromValue(`value`: String): PersonWithDefaultsEnumDefault? = mapping[value] - } -} - -public enum class PersonWithDefaultsEnumQuotedDefault( - @JsonValue - public val `value`: String, -) { - `1X`("1x"), - `2X`("2x"), - ; - - public companion object { - private val mapping: Map = - values().associateBy(PersonWithDefaultsEnumQuotedDefault::value) - - public fun fromValue(`value`: String): PersonWithDefaultsEnumQuotedDefault? = mapping[value] - } -} diff --git a/src/test/resources/examples/defaultValues/models/PersonWithDefaults.kt b/src/test/resources/examples/defaultValues/models/PersonWithDefaults.kt new file mode 100644 index 00000000..40b7bf22 --- /dev/null +++ b/src/test/resources/examples/defaultValues/models/PersonWithDefaults.kt @@ -0,0 +1,46 @@ +package examples.defaultValues.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import java.net.URI +import java.util.Base64 +import javax.validation.constraints.NotNull +import kotlin.Boolean +import kotlin.ByteArray +import kotlin.Int +import kotlin.String + +public data class PersonWithDefaults( + @param:JsonProperty("required_so_default_ignored") + @get:JsonProperty("required_so_default_ignored") + @get:NotNull + public val requiredSoDefaultIgnored: String, + @param:JsonProperty("integer_default") + @get:JsonProperty("integer_default") + @get:NotNull + public val integerDefault: Int = 18, + @param:JsonProperty("enum_default") + @get:JsonProperty("enum_default") + @get:NotNull + public val enumDefault: PersonWithDefaultsEnumDefault = PersonWithDefaultsEnumDefault.TALL, + @param:JsonProperty("enum_quoted_default") + @get:JsonProperty("enum_quoted_default") + @get:NotNull + public val enumQuotedDefault: PersonWithDefaultsEnumQuotedDefault = + PersonWithDefaultsEnumQuotedDefault.`2X`, + @param:JsonProperty("boolean_default") + @get:JsonProperty("boolean_default") + @get:NotNull + public val booleanDefault: Boolean = true, + @param:JsonProperty("string_phrase") + @get:JsonProperty("string_phrase") + @get:NotNull + public val stringPhrase: String = "Cowabunga Dude", + @param:JsonProperty("uri_type") + @get:JsonProperty("uri_type") + @get:NotNull + public val uriType: URI = URI("about:blank"), + @param:JsonProperty("byte_type") + @get:JsonProperty("byte_type") + @get:NotNull + public val byteType: ByteArray = Base64.getDecoder().decode("U3dhZ2dlciByb2Nrcw=="), +) diff --git a/src/test/resources/examples/defaultValues/models/PersonWithDefaultsEnumDefault.kt b/src/test/resources/examples/defaultValues/models/PersonWithDefaultsEnumDefault.kt new file mode 100644 index 00000000..82279982 --- /dev/null +++ b/src/test/resources/examples/defaultValues/models/PersonWithDefaultsEnumDefault.kt @@ -0,0 +1,21 @@ +package examples.defaultValues.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class PersonWithDefaultsEnumDefault( + @JsonValue + public val `value`: String, +) { + TALL("tall"), + SHORT("short"), + ; + + public companion object { + private val mapping: Map = + values().associateBy(PersonWithDefaultsEnumDefault::value) + + public fun fromValue(`value`: String): PersonWithDefaultsEnumDefault? = mapping[value] + } +} diff --git a/src/test/resources/examples/defaultValues/models/PersonWithDefaultsEnumQuotedDefault.kt b/src/test/resources/examples/defaultValues/models/PersonWithDefaultsEnumQuotedDefault.kt new file mode 100644 index 00000000..32edd21b --- /dev/null +++ b/src/test/resources/examples/defaultValues/models/PersonWithDefaultsEnumQuotedDefault.kt @@ -0,0 +1,21 @@ +package examples.defaultValues.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class PersonWithDefaultsEnumQuotedDefault( + @JsonValue + public val `value`: String, +) { + `1X`("1x"), + `2X`("2x"), + ; + + public companion object { + private val mapping: Map = + values().associateBy(PersonWithDefaultsEnumQuotedDefault::value) + + public fun fromValue(`value`: String): PersonWithDefaultsEnumQuotedDefault? = mapping[value] + } +} diff --git a/src/test/resources/examples/discriminatedOneOf/models/Models.kt b/src/test/resources/examples/discriminatedOneOf/models/Models.kt deleted file mode 100644 index ff10e716..00000000 --- a/src/test/resources/examples/discriminatedOneOf/models/Models.kt +++ /dev/null @@ -1,81 +0,0 @@ -package examples.discriminatedOneOf.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import com.fasterxml.jackson.`annotation`.JsonSubTypes -import com.fasterxml.jackson.`annotation`.JsonTypeInfo -import com.fasterxml.jackson.`annotation`.JsonValue -import javax.validation.Valid -import javax.validation.constraints.NotNull -import kotlin.String -import kotlin.collections.Map - -public data class SomeObj( - @param:JsonProperty("state") - @get:JsonProperty("state") - @get:NotNull - @get:Valid - public val state: State, -) - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "status", - visible = true, -) -@JsonSubTypes( - JsonSubTypes.Type(value = StateA::class, name = "a"), - JsonSubTypes.Type( - value = - StateB::class, - name = "b", - ), -) -public sealed interface State - -public data class StateA( - @get:JsonProperty("status") - @get:NotNull - @param:JsonProperty("status") - public val status: Status = Status.A, -) : State - -public data class StateB( - @get:JsonProperty("mode") - @get:NotNull - public val mode: StateBMode, - @get:JsonProperty("status") - @get:NotNull - @param:JsonProperty("status") - public val status: Status = Status.B, -) : State - -public enum class StateBMode( - @JsonValue - public val `value`: String, -) { - MODE1("mode1"), - MODE2("mode2"), - ; - - public companion object { - private val mapping: Map = values().associateBy(StateBMode::value) - - public fun fromValue(`value`: String): StateBMode? = mapping[value] - } -} - -public enum class Status( - @JsonValue - public val `value`: String, -) { - A("a"), - B("b"), - ; - - public companion object { - private val mapping: Map = values().associateBy(Status::value) - - public fun fromValue(`value`: String): Status? = mapping[value] - } -} diff --git a/src/test/resources/examples/discriminatedOneOf/models/SomeObj.kt b/src/test/resources/examples/discriminatedOneOf/models/SomeObj.kt new file mode 100644 index 00000000..88babb35 --- /dev/null +++ b/src/test/resources/examples/discriminatedOneOf/models/SomeObj.kt @@ -0,0 +1,13 @@ +package examples.discriminatedOneOf.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import javax.validation.constraints.NotNull + +public data class SomeObj( + @param:JsonProperty("state") + @get:JsonProperty("state") + @get:NotNull + @get:Valid + public val state: State, +) diff --git a/src/test/resources/examples/discriminatedOneOf/models/State.kt b/src/test/resources/examples/discriminatedOneOf/models/State.kt new file mode 100644 index 00000000..de02a829 --- /dev/null +++ b/src/test/resources/examples/discriminatedOneOf/models/State.kt @@ -0,0 +1,14 @@ +package examples.discriminatedOneOf.models + +import com.fasterxml.jackson.`annotation`.JsonSubTypes +import com.fasterxml.jackson.`annotation`.JsonTypeInfo + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "status", + visible = true, +) +@JsonSubTypes(JsonSubTypes.Type(value = StateA::class, name = "a"),JsonSubTypes.Type(value = + StateB::class, name = "b")) +public sealed interface State diff --git a/src/test/resources/examples/discriminatedOneOf/models/StateA.kt b/src/test/resources/examples/discriminatedOneOf/models/StateA.kt new file mode 100644 index 00000000..8a0c6145 --- /dev/null +++ b/src/test/resources/examples/discriminatedOneOf/models/StateA.kt @@ -0,0 +1,11 @@ +package examples.discriminatedOneOf.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull + +public data class StateA( + @get:JsonProperty("status") + @get:NotNull + @param:JsonProperty("status") + public val status: Status = Status.A, +) : State diff --git a/src/test/resources/examples/discriminatedOneOf/models/StateB.kt b/src/test/resources/examples/discriminatedOneOf/models/StateB.kt new file mode 100644 index 00000000..8cb9f56b --- /dev/null +++ b/src/test/resources/examples/discriminatedOneOf/models/StateB.kt @@ -0,0 +1,14 @@ +package examples.discriminatedOneOf.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull + +public data class StateB( + @get:JsonProperty("mode") + @get:NotNull + public val mode: StateBMode, + @get:JsonProperty("status") + @get:NotNull + @param:JsonProperty("status") + public val status: Status = Status.B, +) : State diff --git a/src/test/resources/examples/discriminatedOneOf/models/StateBMode.kt b/src/test/resources/examples/discriminatedOneOf/models/StateBMode.kt new file mode 100644 index 00000000..4240d03e --- /dev/null +++ b/src/test/resources/examples/discriminatedOneOf/models/StateBMode.kt @@ -0,0 +1,20 @@ +package examples.discriminatedOneOf.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class StateBMode( + @JsonValue + public val `value`: String, +) { + MODE1("mode1"), + MODE2("mode2"), + ; + + public companion object { + private val mapping: Map = values().associateBy(StateBMode::value) + + public fun fromValue(`value`: String): StateBMode? = mapping[value] + } +} diff --git a/src/test/resources/examples/discriminatedOneOf/models/Status.kt b/src/test/resources/examples/discriminatedOneOf/models/Status.kt new file mode 100644 index 00000000..05424e37 --- /dev/null +++ b/src/test/resources/examples/discriminatedOneOf/models/Status.kt @@ -0,0 +1,20 @@ +package examples.discriminatedOneOf.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class Status( + @JsonValue + public val `value`: String, +) { + A("a"), + B("b"), + ; + + public companion object { + private val mapping: Map = values().associateBy(Status::value) + + public fun fromValue(`value`: String): Status? = mapping[value] + } +} diff --git a/src/test/resources/examples/duplicatePropertyHandling/models/ContainsNestedAnyOfWithDupes.kt b/src/test/resources/examples/duplicatePropertyHandling/models/ContainsNestedAnyOfWithDupes.kt new file mode 100644 index 00000000..3cc6e037 --- /dev/null +++ b/src/test/resources/examples/duplicatePropertyHandling/models/ContainsNestedAnyOfWithDupes.kt @@ -0,0 +1,13 @@ +package examples.duplicatePropertyHandling.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class ContainsNestedAnyOfWithDupes( + @param:JsonProperty("child_duplicate") + @get:JsonProperty("child_duplicate") + public val childDuplicate: String? = null, + @param:JsonProperty("top_level_duplicate") + @get:JsonProperty("top_level_duplicate") + public val topLevelDuplicate: String? = null, +) diff --git a/src/test/resources/examples/duplicatePropertyHandling/models/DuplicatesParent.kt b/src/test/resources/examples/duplicatePropertyHandling/models/DuplicatesParent.kt new file mode 100644 index 00000000..d5901f74 --- /dev/null +++ b/src/test/resources/examples/duplicatePropertyHandling/models/DuplicatesParent.kt @@ -0,0 +1,13 @@ +package examples.duplicatePropertyHandling.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class DuplicatesParent( + @param:JsonProperty("child_duplicate") + @get:JsonProperty("child_duplicate") + public val childDuplicate: String? = null, + @param:JsonProperty("top_level_duplicate") + @get:JsonProperty("top_level_duplicate") + public val topLevelDuplicate: String? = null, +) diff --git a/src/test/resources/examples/duplicatePropertyHandling/models/FirstOneD.kt b/src/test/resources/examples/duplicatePropertyHandling/models/FirstOneD.kt new file mode 100644 index 00000000..89d0b68e --- /dev/null +++ b/src/test/resources/examples/duplicatePropertyHandling/models/FirstOneD.kt @@ -0,0 +1,10 @@ +package examples.duplicatePropertyHandling.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class FirstOneD( + @param:JsonProperty("child_duplicate") + @get:JsonProperty("child_duplicate") + public val childDuplicate: String? = null, +) diff --git a/src/test/resources/examples/duplicatePropertyHandling/models/Models.kt b/src/test/resources/examples/duplicatePropertyHandling/models/Models.kt deleted file mode 100644 index 7482c0d9..00000000 --- a/src/test/resources/examples/duplicatePropertyHandling/models/Models.kt +++ /dev/null @@ -1,37 +0,0 @@ -package examples.duplicatePropertyHandling.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import kotlin.String - -public data class ContainsNestedAnyOfWithDupes( - @param:JsonProperty("child_duplicate") - @get:JsonProperty("child_duplicate") - public val childDuplicate: String? = null, - @param:JsonProperty("top_level_duplicate") - @get:JsonProperty("top_level_duplicate") - public val topLevelDuplicate: String? = null, -) - -public data class DuplicatesParent( - @param:JsonProperty("child_duplicate") - @get:JsonProperty("child_duplicate") - public val childDuplicate: String? = null, - @param:JsonProperty("top_level_duplicate") - @get:JsonProperty("top_level_duplicate") - public val topLevelDuplicate: String? = null, -) - -public data class FirstOneD( - @param:JsonProperty("child_duplicate") - @get:JsonProperty("child_duplicate") - public val childDuplicate: String? = null, -) - -public data class TheDuplicator( - @param:JsonProperty("top_level_duplicate") - @get:JsonProperty("top_level_duplicate") - public val topLevelDuplicate: String? = null, - @param:JsonProperty("child_duplicate") - @get:JsonProperty("child_duplicate") - public val childDuplicate: String? = null, -) diff --git a/src/test/resources/examples/duplicatePropertyHandling/models/TheDuplicator.kt b/src/test/resources/examples/duplicatePropertyHandling/models/TheDuplicator.kt new file mode 100644 index 00000000..0ff1c6f6 --- /dev/null +++ b/src/test/resources/examples/duplicatePropertyHandling/models/TheDuplicator.kt @@ -0,0 +1,13 @@ +package examples.duplicatePropertyHandling.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class TheDuplicator( + @param:JsonProperty("top_level_duplicate") + @get:JsonProperty("top_level_duplicate") + public val topLevelDuplicate: String? = null, + @param:JsonProperty("child_duplicate") + @get:JsonProperty("child_duplicate") + public val childDuplicate: String? = null, +) diff --git a/src/test/resources/examples/enumExamples/models/BarBar.kt b/src/test/resources/examples/enumExamples/models/BarBar.kt new file mode 100644 index 00000000..ed037f4f --- /dev/null +++ b/src/test/resources/examples/enumExamples/models/BarBar.kt @@ -0,0 +1,10 @@ +package examples.enumExamples.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class BarBar( + @param:JsonProperty("bar_prop") + @get:JsonProperty("bar_prop") + public val barProp: String? = null, +) diff --git a/src/test/resources/examples/enumExamples/models/ContentType.kt b/src/test/resources/examples/enumExamples/models/ContentType.kt new file mode 100644 index 00000000..c1833e63 --- /dev/null +++ b/src/test/resources/examples/enumExamples/models/ContentType.kt @@ -0,0 +1,21 @@ +package examples.enumExamples.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class ContentType( + @JsonValue + public val `value`: String, +) { + APPLICATION_JSON("application/json"), + APPLICATION_X_SOME_TYPE_JSON("application/x.some-type+json"), + APPLICATION_X_SOME_OTHER_TYPE_JSON_VERSION_2("application/x.some-other-type+json;version=2"), + ; + + public companion object { + private val mapping: Map = values().associateBy(ContentType::value) + + public fun fromValue(`value`: String): ContentType? = mapping[value] + } +} diff --git a/src/test/resources/examples/enumExamples/models/EnumHolder.kt b/src/test/resources/examples/enumExamples/models/EnumHolder.kt new file mode 100644 index 00000000..7485ad84 --- /dev/null +++ b/src/test/resources/examples/enumExamples/models/EnumHolder.kt @@ -0,0 +1,25 @@ +package examples.enumExamples.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.collections.List + +public data class EnumHolder( + @param:JsonProperty("array_of_enums") + @get:JsonProperty("array_of_enums") + public val arrayOfEnums: List? = null, + @param:JsonProperty("inlined_enum") + @get:JsonProperty("inlined_enum") + public val inlinedEnum: EnumHolderInlinedEnum? = null, + @param:JsonProperty("inlined_extensible_enum") + @get:JsonProperty("inlined_extensible_enum") + public val inlinedExtensibleEnum: EnumHolderInlinedExtensibleEnum? = null, + @param:JsonProperty("enum_ref") + @get:JsonProperty("enum_ref") + public val enumRef: EnumObject? = null, + @param:JsonProperty("extensible_enum_ref") + @get:JsonProperty("extensible_enum_ref") + public val extensibleEnumRef: ExtensibleEnumObject? = null, + @param:JsonProperty("list_enums") + @get:JsonProperty("list_enums") + public val listEnums: List? = null, +) diff --git a/src/test/resources/examples/enumExamples/models/EnumHolderArrayOfEnums.kt b/src/test/resources/examples/enumExamples/models/EnumHolderArrayOfEnums.kt new file mode 100644 index 00000000..d0071020 --- /dev/null +++ b/src/test/resources/examples/enumExamples/models/EnumHolderArrayOfEnums.kt @@ -0,0 +1,21 @@ +package examples.enumExamples.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class EnumHolderArrayOfEnums( + @JsonValue + public val `value`: String, +) { + ARRAY_ENUM_ONE("array_enum_one"), + ARRAY_ENUM_TWO("array_enum_two"), + ; + + public companion object { + private val mapping: Map = + values().associateBy(EnumHolderArrayOfEnums::value) + + public fun fromValue(`value`: String): EnumHolderArrayOfEnums? = mapping[value] + } +} diff --git a/src/test/resources/examples/enumExamples/models/EnumHolderInlinedEnum.kt b/src/test/resources/examples/enumExamples/models/EnumHolderInlinedEnum.kt new file mode 100644 index 00000000..988a0eb3 --- /dev/null +++ b/src/test/resources/examples/enumExamples/models/EnumHolderInlinedEnum.kt @@ -0,0 +1,22 @@ +package examples.enumExamples.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class EnumHolderInlinedEnum( + @JsonValue + public val `value`: String, +) { + INLINED_ONE("inlined_one"), + INLINED_TWO("inlined_two"), + INLINED_THREE("inlined_three"), + ; + + public companion object { + private val mapping: Map = + values().associateBy(EnumHolderInlinedEnum::value) + + public fun fromValue(`value`: String): EnumHolderInlinedEnum? = mapping[value] + } +} diff --git a/src/test/resources/examples/enumExamples/models/EnumHolderInlinedExtensibleEnum.kt b/src/test/resources/examples/enumExamples/models/EnumHolderInlinedExtensibleEnum.kt new file mode 100644 index 00000000..9a1da304 --- /dev/null +++ b/src/test/resources/examples/enumExamples/models/EnumHolderInlinedExtensibleEnum.kt @@ -0,0 +1,22 @@ +package examples.enumExamples.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class EnumHolderInlinedExtensibleEnum( + @JsonValue + public val `value`: String, +) { + INLINED_ONE("inlined_one"), + INLINED_TWO("inlined_two"), + INLINED_THREE("inlined_three"), + ; + + public companion object { + private val mapping: Map = + values().associateBy(EnumHolderInlinedExtensibleEnum::value) + + public fun fromValue(`value`: String): EnumHolderInlinedExtensibleEnum? = mapping[value] + } +} diff --git a/src/test/resources/examples/enumExamples/models/EnumObject.kt b/src/test/resources/examples/enumExamples/models/EnumObject.kt new file mode 100644 index 00000000..ebe2ce76 --- /dev/null +++ b/src/test/resources/examples/enumExamples/models/EnumObject.kt @@ -0,0 +1,24 @@ +package examples.enumExamples.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class EnumObject( + @JsonValue + public val `value`: String, +) { + ONE("one"), + TWO("two"), + THREE("three"), + `4`("4"), + _5("-5"), + _6("_6"), + ; + + public companion object { + private val mapping: Map = values().associateBy(EnumObject::value) + + public fun fromValue(`value`: String): EnumObject? = mapping[value] + } +} diff --git a/src/test/resources/examples/enumExamples/models/ExtensibleEnumObject.kt b/src/test/resources/examples/enumExamples/models/ExtensibleEnumObject.kt new file mode 100644 index 00000000..bf1eaf50 --- /dev/null +++ b/src/test/resources/examples/enumExamples/models/ExtensibleEnumObject.kt @@ -0,0 +1,21 @@ +package examples.enumExamples.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class ExtensibleEnumObject( + @JsonValue + public val `value`: String, +) { + ACTIVE("active"), + INACTIVE("inactive"), + ; + + public companion object { + private val mapping: Map = + values().associateBy(ExtensibleEnumObject::value) + + public fun fromValue(`value`: String): ExtensibleEnumObject? = mapping[value] + } +} diff --git a/src/test/resources/examples/enumExamples/models/FooBars.kt b/src/test/resources/examples/enumExamples/models/FooBars.kt new file mode 100644 index 00000000..5aa41003 --- /dev/null +++ b/src/test/resources/examples/enumExamples/models/FooBars.kt @@ -0,0 +1,15 @@ +package examples.enumExamples.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import kotlin.collections.List + +public data class FooBars( + @param:JsonProperty("prop_one") + @get:JsonProperty("prop_one") + public val propOne: List? = null, + @param:JsonProperty("prop_two") + @get:JsonProperty("prop_two") + @get:Valid + public val propTwo: List? = null, +) diff --git a/src/test/resources/examples/enumExamples/models/FooBarsBar.kt b/src/test/resources/examples/enumExamples/models/FooBarsBar.kt new file mode 100644 index 00000000..580248db --- /dev/null +++ b/src/test/resources/examples/enumExamples/models/FooBarsBar.kt @@ -0,0 +1,10 @@ +package examples.enumExamples.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class FooBarsBar( + @param:JsonProperty("bar_prop") + @get:JsonProperty("bar_prop") + public val barProp: String? = null, +) diff --git a/src/test/resources/examples/enumExamples/models/FooBarsFoo.kt b/src/test/resources/examples/enumExamples/models/FooBarsFoo.kt new file mode 100644 index 00000000..a4dca00b --- /dev/null +++ b/src/test/resources/examples/enumExamples/models/FooBarsFoo.kt @@ -0,0 +1,20 @@ +package examples.enumExamples.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class FooBarsFoo( + @JsonValue + public val `value`: String, +) { + X("X"), + Y("Y"), + ; + + public companion object { + private val mapping: Map = values().associateBy(FooBarsFoo::value) + + public fun fromValue(`value`: String): FooBarsFoo? = mapping[value] + } +} diff --git a/src/test/resources/examples/enumExamples/models/FooFoo.kt b/src/test/resources/examples/enumExamples/models/FooFoo.kt new file mode 100644 index 00000000..70da7c42 --- /dev/null +++ b/src/test/resources/examples/enumExamples/models/FooFoo.kt @@ -0,0 +1,20 @@ +package examples.enumExamples.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class FooFoo( + @JsonValue + public val `value`: String, +) { + X("X"), + Y("Y"), + ; + + public companion object { + private val mapping: Map = values().associateBy(FooFoo::value) + + public fun fromValue(`value`: String): FooFoo? = mapping[value] + } +} diff --git a/src/test/resources/examples/enumExamples/models/Models.kt b/src/test/resources/examples/enumExamples/models/Models.kt deleted file mode 100644 index 6f3beb74..00000000 --- a/src/test/resources/examples/enumExamples/models/Models.kt +++ /dev/null @@ -1,182 +0,0 @@ -package examples.enumExamples.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import com.fasterxml.jackson.`annotation`.JsonValue -import javax.validation.Valid -import kotlin.String -import kotlin.collections.List -import kotlin.collections.Map - -public data class BarBar( - @param:JsonProperty("bar_prop") - @get:JsonProperty("bar_prop") - public val barProp: String? = null, -) - -public enum class ContentType( - @JsonValue - public val `value`: String, -) { - APPLICATION_JSON("application/json"), - APPLICATION_X_SOME_TYPE_JSON("application/x.some-type+json"), - APPLICATION_X_SOME_OTHER_TYPE_JSON_VERSION_2("application/x.some-other-type+json;version=2"), - ; - - public companion object { - private val mapping: Map = values().associateBy(ContentType::value) - - public fun fromValue(`value`: String): ContentType? = mapping[value] - } -} - -public data class EnumHolder( - @param:JsonProperty("array_of_enums") - @get:JsonProperty("array_of_enums") - public val arrayOfEnums: List? = null, - @param:JsonProperty("inlined_enum") - @get:JsonProperty("inlined_enum") - public val inlinedEnum: EnumHolderInlinedEnum? = null, - @param:JsonProperty("inlined_extensible_enum") - @get:JsonProperty("inlined_extensible_enum") - public val inlinedExtensibleEnum: EnumHolderInlinedExtensibleEnum? = null, - @param:JsonProperty("enum_ref") - @get:JsonProperty("enum_ref") - public val enumRef: EnumObject? = null, - @param:JsonProperty("extensible_enum_ref") - @get:JsonProperty("extensible_enum_ref") - public val extensibleEnumRef: ExtensibleEnumObject? = null, - @param:JsonProperty("list_enums") - @get:JsonProperty("list_enums") - public val listEnums: List? = null, -) - -public enum class EnumHolderArrayOfEnums( - @JsonValue - public val `value`: String, -) { - ARRAY_ENUM_ONE("array_enum_one"), - ARRAY_ENUM_TWO("array_enum_two"), - ; - - public companion object { - private val mapping: Map = - values().associateBy(EnumHolderArrayOfEnums::value) - - public fun fromValue(`value`: String): EnumHolderArrayOfEnums? = mapping[value] - } -} - -public enum class EnumHolderInlinedEnum( - @JsonValue - public val `value`: String, -) { - INLINED_ONE("inlined_one"), - INLINED_TWO("inlined_two"), - INLINED_THREE("inlined_three"), - ; - - public companion object { - private val mapping: Map = - values().associateBy(EnumHolderInlinedEnum::value) - - public fun fromValue(`value`: String): EnumHolderInlinedEnum? = mapping[value] - } -} - -public enum class EnumHolderInlinedExtensibleEnum( - @JsonValue - public val `value`: String, -) { - INLINED_ONE("inlined_one"), - INLINED_TWO("inlined_two"), - INLINED_THREE("inlined_three"), - ; - - public companion object { - private val mapping: Map = - values().associateBy(EnumHolderInlinedExtensibleEnum::value) - - public fun fromValue(`value`: String): EnumHolderInlinedExtensibleEnum? = mapping[value] - } -} - -public enum class EnumObject( - @JsonValue - public val `value`: String, -) { - ONE("one"), - TWO("two"), - THREE("three"), - `4`("4"), - _5("-5"), - _6("_6"), - ; - - public companion object { - private val mapping: Map = values().associateBy(EnumObject::value) - - public fun fromValue(`value`: String): EnumObject? = mapping[value] - } -} - -public enum class ExtensibleEnumObject( - @JsonValue - public val `value`: String, -) { - ACTIVE("active"), - INACTIVE("inactive"), - ; - - public companion object { - private val mapping: Map = - values().associateBy(ExtensibleEnumObject::value) - - public fun fromValue(`value`: String): ExtensibleEnumObject? = mapping[value] - } -} - -public data class FooBars( - @param:JsonProperty("prop_one") - @get:JsonProperty("prop_one") - public val propOne: List? = null, - @param:JsonProperty("prop_two") - @get:JsonProperty("prop_two") - @get:Valid - public val propTwo: List? = null, -) - -public data class FooBarsBar( - @param:JsonProperty("bar_prop") - @get:JsonProperty("bar_prop") - public val barProp: String? = null, -) - -public enum class FooBarsFoo( - @JsonValue - public val `value`: String, -) { - X("X"), - Y("Y"), - ; - - public companion object { - private val mapping: Map = values().associateBy(FooBarsFoo::value) - - public fun fromValue(`value`: String): FooBarsFoo? = mapping[value] - } -} - -public enum class FooFoo( - @JsonValue - public val `value`: String, -) { - X("X"), - Y("Y"), - ; - - public companion object { - private val mapping: Map = values().associateBy(FooFoo::value) - - public fun fromValue(`value`: String): FooFoo? = mapping[value] - } -} diff --git a/src/test/resources/examples/enumPolymorphicDiscriminator/models/ChildDefinition.kt b/src/test/resources/examples/enumPolymorphicDiscriminator/models/ChildDefinition.kt new file mode 100644 index 00000000..b9f5553b --- /dev/null +++ b/src/test/resources/examples/enumPolymorphicDiscriminator/models/ChildDefinition.kt @@ -0,0 +1,86 @@ +package examples.enumPolymorphicDiscriminator.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import com.fasterxml.jackson.`annotation`.JsonSubTypes +import com.fasterxml.jackson.`annotation`.JsonTypeInfo +import javax.validation.Valid +import javax.validation.constraints.NotNull +import kotlin.String +import kotlin.collections.List + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "some_enum", + visible = true, +) +@JsonSubTypes(JsonSubTypes.Type(value = DiscriminatedChild1::class, name = + "obj_one_only"),JsonSubTypes.Type(value = DiscriminatedChild2::class, name = + "obj_two_first"),JsonSubTypes.Type(value = DiscriminatedChild2::class, name = + "obj_two_second"),JsonSubTypes.Type(value = DiscriminatedChild3::class, name = "obj_three")) +public sealed class ChildDefinition( + public open val inlineObj: ChildDefinitionInlineObj? = null, + public open val inlineArray: List? = null, + public open val inlineEnum: ChildDefinitionInlineEnum? = null, +) { + public abstract val someEnum: ChildDiscriminator +} + +public data class DiscriminatedChild1( + @param:JsonProperty("inline_obj") + @get:JsonProperty("inline_obj") + @get:Valid + override val inlineObj: ChildDefinitionInlineObj? = null, + @param:JsonProperty("inline_array") + @get:JsonProperty("inline_array") + @get:Valid + override val inlineArray: List? = null, + @param:JsonProperty("inline_enum") + @get:JsonProperty("inline_enum") + override val inlineEnum: ChildDefinitionInlineEnum? = null, + @param:JsonProperty("some_prop") + @get:JsonProperty("some_prop") + public val someProp: String? = null, + @get:JsonProperty("some_enum") + @get:NotNull + @param:JsonProperty("some_enum") + override val someEnum: ChildDiscriminator = ChildDiscriminator.OBJ_ONE_ONLY, +) : ChildDefinition(inlineObj, inlineArray, inlineEnum) + +public data class DiscriminatedChild2( + @get:JsonProperty("some_enum") + @get:NotNull + override val someEnum: ChildDiscriminator, + @param:JsonProperty("inline_obj") + @get:JsonProperty("inline_obj") + @get:Valid + override val inlineObj: ChildDefinitionInlineObj? = null, + @param:JsonProperty("inline_array") + @get:JsonProperty("inline_array") + @get:Valid + override val inlineArray: List? = null, + @param:JsonProperty("inline_enum") + @get:JsonProperty("inline_enum") + override val inlineEnum: ChildDefinitionInlineEnum? = null, + @param:JsonProperty("some_prop") + @get:JsonProperty("some_prop") + public val someProp: String? = null, +) : ChildDefinition(inlineObj, inlineArray, inlineEnum) + +public data class DiscriminatedChild3( + @param:JsonProperty("inline_obj") + @get:JsonProperty("inline_obj") + @get:Valid + override val inlineObj: ChildDefinitionInlineObj? = null, + @param:JsonProperty("inline_array") + @get:JsonProperty("inline_array") + @get:Valid + override val inlineArray: List? = null, + @param:JsonProperty("inline_enum") + @get:JsonProperty("inline_enum") + override val inlineEnum: ChildDefinitionInlineEnum? = null, + @get:JsonProperty("some_enum") + @get:NotNull + @param:JsonProperty("some_enum") + override val someEnum: ChildDiscriminator = ChildDiscriminator.OBJ_THREE, +) : ChildDefinition(inlineObj, inlineArray, inlineEnum) diff --git a/src/test/resources/examples/enumPolymorphicDiscriminator/models/ChildDefinitionInlineArray.kt b/src/test/resources/examples/enumPolymorphicDiscriminator/models/ChildDefinitionInlineArray.kt new file mode 100644 index 00000000..dddc4be4 --- /dev/null +++ b/src/test/resources/examples/enumPolymorphicDiscriminator/models/ChildDefinitionInlineArray.kt @@ -0,0 +1,10 @@ +package examples.enumPolymorphicDiscriminator.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class ChildDefinitionInlineArray( + @param:JsonProperty("str") + @get:JsonProperty("str") + public val str: String? = null, +) diff --git a/src/test/resources/examples/enumPolymorphicDiscriminator/models/ChildDefinitionInlineEnum.kt b/src/test/resources/examples/enumPolymorphicDiscriminator/models/ChildDefinitionInlineEnum.kt new file mode 100644 index 00000000..f0d79503 --- /dev/null +++ b/src/test/resources/examples/enumPolymorphicDiscriminator/models/ChildDefinitionInlineEnum.kt @@ -0,0 +1,22 @@ +package examples.enumPolymorphicDiscriminator.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class ChildDefinitionInlineEnum( + @JsonValue + public val `value`: String, +) { + ONE("one"), + TWO("two"), + THREE("three"), + ; + + public companion object { + private val mapping: Map = + values().associateBy(ChildDefinitionInlineEnum::value) + + public fun fromValue(`value`: String): ChildDefinitionInlineEnum? = mapping[value] + } +} diff --git a/src/test/resources/examples/enumPolymorphicDiscriminator/models/ChildDefinitionInlineObj.kt b/src/test/resources/examples/enumPolymorphicDiscriminator/models/ChildDefinitionInlineObj.kt new file mode 100644 index 00000000..e22b8538 --- /dev/null +++ b/src/test/resources/examples/enumPolymorphicDiscriminator/models/ChildDefinitionInlineObj.kt @@ -0,0 +1,10 @@ +package examples.enumPolymorphicDiscriminator.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class ChildDefinitionInlineObj( + @param:JsonProperty("str") + @get:JsonProperty("str") + public val str: String? = null, +) diff --git a/src/test/resources/examples/enumPolymorphicDiscriminator/models/ChildDiscriminator.kt b/src/test/resources/examples/enumPolymorphicDiscriminator/models/ChildDiscriminator.kt new file mode 100644 index 00000000..4a6e0e1f --- /dev/null +++ b/src/test/resources/examples/enumPolymorphicDiscriminator/models/ChildDiscriminator.kt @@ -0,0 +1,23 @@ +package examples.enumPolymorphicDiscriminator.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class ChildDiscriminator( + @JsonValue + public val `value`: String, +) { + OBJ_ONE_ONLY("obj_one_only"), + OBJ_TWO_FIRST("obj_two_first"), + OBJ_TWO_SECOND("obj_two_second"), + OBJ_THREE("obj_three"), + ; + + public companion object { + private val mapping: Map = + values().associateBy(ChildDiscriminator::value) + + public fun fromValue(`value`: String): ChildDiscriminator? = mapping[value] + } +} diff --git a/src/test/resources/examples/enumPolymorphicDiscriminator/models/Models.kt b/src/test/resources/examples/enumPolymorphicDiscriminator/models/Models.kt deleted file mode 100644 index d3044f8a..00000000 --- a/src/test/resources/examples/enumPolymorphicDiscriminator/models/Models.kt +++ /dev/null @@ -1,156 +0,0 @@ -package examples.enumPolymorphicDiscriminator.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import com.fasterxml.jackson.`annotation`.JsonSubTypes -import com.fasterxml.jackson.`annotation`.JsonTypeInfo -import com.fasterxml.jackson.`annotation`.JsonValue -import javax.validation.Valid -import javax.validation.constraints.NotNull -import kotlin.String -import kotlin.collections.List -import kotlin.collections.Map - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "some_enum", - visible = true, -) -@JsonSubTypes( - JsonSubTypes.Type( - value = DiscriminatedChild1::class, - name = - "obj_one_only", - ), - JsonSubTypes.Type( - value = DiscriminatedChild2::class, - name = - "obj_two_first", - ), - JsonSubTypes.Type( - value = DiscriminatedChild2::class, - name = - "obj_two_second", - ), - JsonSubTypes.Type(value = DiscriminatedChild3::class, name = "obj_three"), -) -public sealed class ChildDefinition( - public open val inlineObj: ChildDefinitionInlineObj? = null, - public open val inlineArray: List? = null, - public open val inlineEnum: ChildDefinitionInlineEnum? = null, -) { - public abstract val someEnum: ChildDiscriminator -} - -public data class ChildDefinitionInlineArray( - @param:JsonProperty("str") - @get:JsonProperty("str") - public val str: String? = null, -) - -public enum class ChildDefinitionInlineEnum( - @JsonValue - public val `value`: String, -) { - ONE("one"), - TWO("two"), - THREE("three"), - ; - - public companion object { - private val mapping: Map = - values().associateBy(ChildDefinitionInlineEnum::value) - - public fun fromValue(`value`: String): ChildDefinitionInlineEnum? = mapping[value] - } -} - -public data class ChildDefinitionInlineObj( - @param:JsonProperty("str") - @get:JsonProperty("str") - public val str: String? = null, -) - -public enum class ChildDiscriminator( - @JsonValue - public val `value`: String, -) { - OBJ_ONE_ONLY("obj_one_only"), - OBJ_TWO_FIRST("obj_two_first"), - OBJ_TWO_SECOND("obj_two_second"), - OBJ_THREE("obj_three"), - ; - - public companion object { - private val mapping: Map = - values().associateBy(ChildDiscriminator::value) - - public fun fromValue(`value`: String): ChildDiscriminator? = mapping[value] - } -} - -public data class DiscriminatedChild1( - @param:JsonProperty("inline_obj") - @get:JsonProperty("inline_obj") - @get:Valid - override val inlineObj: ChildDefinitionInlineObj? = null, - @param:JsonProperty("inline_array") - @get:JsonProperty("inline_array") - @get:Valid - override val inlineArray: List? = null, - @param:JsonProperty("inline_enum") - @get:JsonProperty("inline_enum") - override val inlineEnum: ChildDefinitionInlineEnum? = null, - @param:JsonProperty("some_prop") - @get:JsonProperty("some_prop") - public val someProp: String? = null, - @get:JsonProperty("some_enum") - @get:NotNull - @param:JsonProperty("some_enum") - override val someEnum: ChildDiscriminator = ChildDiscriminator.OBJ_ONE_ONLY, -) : ChildDefinition(inlineObj, inlineArray, inlineEnum) - -public data class DiscriminatedChild2( - @get:JsonProperty("some_enum") - @get:NotNull - override val someEnum: ChildDiscriminator, - @param:JsonProperty("inline_obj") - @get:JsonProperty("inline_obj") - @get:Valid - override val inlineObj: ChildDefinitionInlineObj? = null, - @param:JsonProperty("inline_array") - @get:JsonProperty("inline_array") - @get:Valid - override val inlineArray: List? = null, - @param:JsonProperty("inline_enum") - @get:JsonProperty("inline_enum") - override val inlineEnum: ChildDefinitionInlineEnum? = null, - @param:JsonProperty("some_prop") - @get:JsonProperty("some_prop") - public val someProp: String? = null, -) : ChildDefinition(inlineObj, inlineArray, inlineEnum) - -public data class DiscriminatedChild3( - @param:JsonProperty("inline_obj") - @get:JsonProperty("inline_obj") - @get:Valid - override val inlineObj: ChildDefinitionInlineObj? = null, - @param:JsonProperty("inline_array") - @get:JsonProperty("inline_array") - @get:Valid - override val inlineArray: List? = null, - @param:JsonProperty("inline_enum") - @get:JsonProperty("inline_enum") - override val inlineEnum: ChildDefinitionInlineEnum? = null, - @get:JsonProperty("some_enum") - @get:NotNull - @param:JsonProperty("some_enum") - override val someEnum: ChildDiscriminator = ChildDiscriminator.OBJ_THREE, -) : ChildDefinition(inlineObj, inlineArray, inlineEnum) - -public data class Responses( - @param:JsonProperty("entries") - @get:JsonProperty("entries") - @get:Valid - public val entries: List? = null, -) diff --git a/src/test/resources/examples/enumPolymorphicDiscriminator/models/Responses.kt b/src/test/resources/examples/enumPolymorphicDiscriminator/models/Responses.kt new file mode 100644 index 00000000..63232c0e --- /dev/null +++ b/src/test/resources/examples/enumPolymorphicDiscriminator/models/Responses.kt @@ -0,0 +1,12 @@ +package examples.enumPolymorphicDiscriminator.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import kotlin.collections.List + +public data class Responses( + @param:JsonProperty("entries") + @get:JsonProperty("entries") + @get:Valid + public val entries: List? = null, +) diff --git a/src/test/resources/examples/externalReferences/targeted/models/ContainingExternalReference.kt b/src/test/resources/examples/externalReferences/targeted/models/ContainingExternalReference.kt new file mode 100644 index 00000000..b87a7d84 --- /dev/null +++ b/src/test/resources/examples/externalReferences/targeted/models/ContainingExternalReference.kt @@ -0,0 +1,11 @@ +package examples.externalReferences.targeted.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid + +public data class ContainingExternalReference( + @param:JsonProperty("some-external-reference") + @get:JsonProperty("some-external-reference") + @get:Valid + public val someExternalReference: ExternalObject? = null, +) diff --git a/src/test/resources/examples/externalReferences/targeted/models/ExternalObject.kt b/src/test/resources/examples/externalReferences/targeted/models/ExternalObject.kt new file mode 100644 index 00000000..320062f5 --- /dev/null +++ b/src/test/resources/examples/externalReferences/targeted/models/ExternalObject.kt @@ -0,0 +1,15 @@ +package examples.externalReferences.targeted.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid + +public data class ExternalObject( + @param:JsonProperty("another") + @get:JsonProperty("another") + @get:Valid + public val another: ExternalObjectTwo? = null, + @param:JsonProperty("one_of") + @get:JsonProperty("one_of") + @get:Valid + public val oneOf: ParentOneOf? = null, +) diff --git a/src/test/resources/examples/externalReferences/targeted/models/ExternalObjectFour.kt b/src/test/resources/examples/externalReferences/targeted/models/ExternalObjectFour.kt new file mode 100644 index 00000000..c8dc5ecc --- /dev/null +++ b/src/test/resources/examples/externalReferences/targeted/models/ExternalObjectFour.kt @@ -0,0 +1,10 @@ +package examples.externalReferences.targeted.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class ExternalObjectFour( + @param:JsonProperty("blah") + @get:JsonProperty("blah") + public val blah: String? = null, +) diff --git a/src/test/resources/examples/externalReferences/targeted/models/ExternalObjectThree.kt b/src/test/resources/examples/externalReferences/targeted/models/ExternalObjectThree.kt new file mode 100644 index 00000000..39e986cf --- /dev/null +++ b/src/test/resources/examples/externalReferences/targeted/models/ExternalObjectThree.kt @@ -0,0 +1,16 @@ +package examples.externalReferences.targeted.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.String + +public data class ExternalObjectThree( + @param:JsonProperty("enum") + @get:JsonProperty("enum") + @get:NotNull + public val `enum`: ExternalObjectThreeEnum, + @param:JsonProperty("description") + @get:JsonProperty("description") + @get:NotNull + public val description: String, +) diff --git a/src/test/resources/examples/externalReferences/targeted/models/ExternalObjectThreeEnum.kt b/src/test/resources/examples/externalReferences/targeted/models/ExternalObjectThreeEnum.kt new file mode 100644 index 00000000..17310b0f --- /dev/null +++ b/src/test/resources/examples/externalReferences/targeted/models/ExternalObjectThreeEnum.kt @@ -0,0 +1,22 @@ +package examples.externalReferences.targeted.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class ExternalObjectThreeEnum( + @JsonValue + public val `value`: String, +) { + ONE("one"), + TWO("two"), + THREE("three"), + ; + + public companion object { + private val mapping: Map = + values().associateBy(ExternalObjectThreeEnum::value) + + public fun fromValue(`value`: String): ExternalObjectThreeEnum? = mapping[value] + } +} diff --git a/src/test/resources/examples/externalReferences/targeted/models/ExternalObjectTwo.kt b/src/test/resources/examples/externalReferences/targeted/models/ExternalObjectTwo.kt new file mode 100644 index 00000000..1f412bc4 --- /dev/null +++ b/src/test/resources/examples/externalReferences/targeted/models/ExternalObjectTwo.kt @@ -0,0 +1,28 @@ +package examples.externalReferences.targeted.models + +import com.fasterxml.jackson.`annotation`.JsonAnyGetter +import com.fasterxml.jackson.`annotation`.JsonAnySetter +import com.fasterxml.jackson.`annotation`.JsonIgnore +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import kotlin.String +import kotlin.collections.List +import kotlin.collections.Map +import kotlin.collections.MutableMap + +public data class ExternalObjectTwo( + @param:JsonProperty("list-others") + @get:JsonProperty("list-others") + @get:Valid + public val listOthers: List? = null, + @get:JsonIgnore + public val properties: MutableMap?> = mutableMapOf(), +) { + @JsonAnyGetter + public fun `get`(): Map?> = properties + + @JsonAnySetter + public fun `set`(name: String, `value`: Map?) { + properties[name] = value + } +} diff --git a/src/test/resources/examples/externalReferences/targeted/models/Models.kt b/src/test/resources/examples/externalReferences/targeted/models/Models.kt deleted file mode 100644 index 3f65fce8..00000000 --- a/src/test/resources/examples/externalReferences/targeted/models/Models.kt +++ /dev/null @@ -1,122 +0,0 @@ -package examples.externalReferences.targeted.models - -import com.fasterxml.jackson.`annotation`.JsonAnyGetter -import com.fasterxml.jackson.`annotation`.JsonAnySetter -import com.fasterxml.jackson.`annotation`.JsonIgnore -import com.fasterxml.jackson.`annotation`.JsonProperty -import com.fasterxml.jackson.`annotation`.JsonSubTypes -import com.fasterxml.jackson.`annotation`.JsonTypeInfo -import com.fasterxml.jackson.`annotation`.JsonValue -import javax.validation.Valid -import javax.validation.constraints.NotNull -import kotlin.String -import kotlin.collections.List -import kotlin.collections.Map -import kotlin.collections.MutableMap - -public data class ContainingExternalReference( - @param:JsonProperty("some-external-reference") - @get:JsonProperty("some-external-reference") - @get:Valid - public val someExternalReference: ExternalObject? = null, -) - -public data class ExternalObject( - @param:JsonProperty("another") - @get:JsonProperty("another") - @get:Valid - public val another: ExternalObjectTwo? = null, - @param:JsonProperty("one_of") - @get:JsonProperty("one_of") - @get:Valid - public val oneOf: ParentOneOf? = null, -) - -public data class ExternalObjectFour( - @param:JsonProperty("blah") - @get:JsonProperty("blah") - public val blah: String? = null, -) - -public data class ExternalObjectThree( - @param:JsonProperty("enum") - @get:JsonProperty("enum") - @get:NotNull - public val `enum`: ExternalObjectThreeEnum, - @param:JsonProperty("description") - @get:JsonProperty("description") - @get:NotNull - public val description: String, -) - -public enum class ExternalObjectThreeEnum( - @JsonValue - public val `value`: String, -) { - ONE("one"), - TWO("two"), - THREE("three"), - ; - - public companion object { - private val mapping: Map = - values().associateBy(ExternalObjectThreeEnum::value) - - public fun fromValue(`value`: String): ExternalObjectThreeEnum? = mapping[value] - } -} - -public data class ExternalObjectTwo( - @param:JsonProperty("list-others") - @get:JsonProperty("list-others") - @get:Valid - public val listOthers: List? = null, - @get:JsonIgnore - public val properties: MutableMap?> = mutableMapOf(), -) { - @JsonAnyGetter - public fun `get`(): Map?> = properties - - @JsonAnySetter - public fun `set`(name: String, `value`: Map?) { - properties[name] = value - } -} - -public data class OneOfOne( - @param:JsonProperty("oneOfOne") - @get:JsonProperty("oneOfOne") - public val oneOfOne: String? = null, - @get:JsonProperty("discriminator") - @get:NotNull - @param:JsonProperty("discriminator") - override val discriminator: String = "OneOfOne", -) : ParentOneOf() - -public data class OneOfTwo( - @param:JsonProperty("oneOfTwo") - @get:JsonProperty("oneOfTwo") - public val oneOfTwo: String? = null, - @get:JsonProperty("discriminator") - @get:NotNull - @param:JsonProperty("discriminator") - override val discriminator: String = "OneOfTwo", -) : ParentOneOf() - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "discriminator", - visible = true, -) -@JsonSubTypes( - JsonSubTypes.Type(value = OneOfOne::class, name = "OneOfOne"), - JsonSubTypes.Type( - value = - OneOfTwo::class, - name = "OneOfTwo", - ), -) -public sealed class ParentOneOf() { - public abstract val discriminator: String -} diff --git a/src/test/resources/examples/externalReferences/targeted/models/ParentOneOf.kt b/src/test/resources/examples/externalReferences/targeted/models/ParentOneOf.kt new file mode 100644 index 00000000..fa22a79c --- /dev/null +++ b/src/test/resources/examples/externalReferences/targeted/models/ParentOneOf.kt @@ -0,0 +1,39 @@ +package examples.externalReferences.targeted.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import com.fasterxml.jackson.`annotation`.JsonSubTypes +import com.fasterxml.jackson.`annotation`.JsonTypeInfo +import javax.validation.constraints.NotNull +import kotlin.String + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "discriminator", + visible = true, +) +@JsonSubTypes(JsonSubTypes.Type(value = OneOfOne::class, name = "OneOfOne"),JsonSubTypes.Type(value + = OneOfTwo::class, name = "OneOfTwo")) +public sealed class ParentOneOf() { + public abstract val discriminator: String +} + +public data class OneOfOne( + @param:JsonProperty("oneOfOne") + @get:JsonProperty("oneOfOne") + public val oneOfOne: String? = null, + @get:JsonProperty("discriminator") + @get:NotNull + @param:JsonProperty("discriminator") + override val discriminator: String = "OneOfOne", +) : ParentOneOf() + +public data class OneOfTwo( + @param:JsonProperty("oneOfTwo") + @get:JsonProperty("oneOfTwo") + public val oneOfTwo: String? = null, + @get:JsonProperty("discriminator") + @get:NotNull + @param:JsonProperty("discriminator") + override val discriminator: String = "OneOfTwo", +) : ParentOneOf() diff --git a/src/test/resources/examples/githubApi/models/Author.kt b/src/test/resources/examples/githubApi/models/Author.kt new file mode 100644 index 00000000..75584e80 --- /dev/null +++ b/src/test/resources/examples/githubApi/models/Author.kt @@ -0,0 +1,13 @@ +package examples.githubApi.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class Author( + @param:JsonProperty("name") + @get:JsonProperty("name") + public val name: String? = null, + @param:JsonProperty("email") + @get:JsonProperty("email") + public val email: String? = null, +) diff --git a/src/test/resources/examples/githubApi/models/BulkEntityDetails.kt b/src/test/resources/examples/githubApi/models/BulkEntityDetails.kt new file mode 100644 index 00000000..635e99e3 --- /dev/null +++ b/src/test/resources/examples/githubApi/models/BulkEntityDetails.kt @@ -0,0 +1,31 @@ +package examples.githubApi.models + +import com.fasterxml.jackson.`annotation`.JsonAnyGetter +import com.fasterxml.jackson.`annotation`.JsonAnySetter +import com.fasterxml.jackson.`annotation`.JsonIgnore +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import javax.validation.constraints.NotNull +import kotlin.Any +import kotlin.String +import kotlin.collections.List +import kotlin.collections.Map +import kotlin.collections.MutableMap + +public data class BulkEntityDetails( + @param:JsonProperty("entities") + @get:JsonProperty("entities") + @get:NotNull + @get:Valid + public val entities: List, + @get:JsonIgnore + public val properties: MutableMap = mutableMapOf(), +) { + @JsonAnyGetter + public fun `get`(): Map = properties + + @JsonAnySetter + public fun `set`(name: String, `value`: Any?) { + properties[name] = value + } +} diff --git a/src/test/resources/examples/githubApi/models/Contributor.kt b/src/test/resources/examples/githubApi/models/Contributor.kt new file mode 100644 index 00000000..5ca7f667 --- /dev/null +++ b/src/test/resources/examples/githubApi/models/Contributor.kt @@ -0,0 +1,47 @@ +package examples.githubApi.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import java.time.OffsetDateTime +import javax.validation.constraints.NotNull +import kotlin.String + +public data class Contributor( + @param:JsonProperty("id") + @get:JsonProperty("id") + public val id: String? = null, + @param:JsonProperty("audit_actor") + @get:JsonProperty("audit_actor") + public val auditActor: String? = null, + @param:JsonProperty("created") + @get:JsonProperty("created") + public val created: OffsetDateTime? = null, + @param:JsonProperty("created_by") + @get:JsonProperty("created_by") + public val createdBy: String? = null, + @param:JsonProperty("created_by_uid") + @get:JsonProperty("created_by_uid") + public val createdByUid: String? = null, + @param:JsonProperty("modified") + @get:JsonProperty("modified") + public val modified: OffsetDateTime? = null, + @param:JsonProperty("modified_by") + @get:JsonProperty("modified_by") + public val modifiedBy: String? = null, + @param:JsonProperty("modified_by_uid") + @get:JsonProperty("modified_by_uid") + public val modifiedByUid: String? = null, + @param:JsonProperty("status") + @get:JsonProperty("status") + @get:NotNull + public val status: ContributorStatus, + @param:JsonProperty("etag") + @get:JsonProperty("etag") + public val etag: String? = null, + @param:JsonProperty("username") + @get:JsonProperty("username") + @get:NotNull + public val username: String, + @param:JsonProperty("name") + @get:JsonProperty("name") + public val name: String? = null, +) diff --git a/src/test/resources/examples/githubApi/models/ContributorQueryResult.kt b/src/test/resources/examples/githubApi/models/ContributorQueryResult.kt new file mode 100644 index 00000000..39ef7e75 --- /dev/null +++ b/src/test/resources/examples/githubApi/models/ContributorQueryResult.kt @@ -0,0 +1,23 @@ +package examples.githubApi.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import java.net.URI +import javax.validation.Valid +import javax.validation.constraints.NotNull +import javax.validation.constraints.Size +import kotlin.collections.List + +public data class ContributorQueryResult( + @param:JsonProperty("prev") + @get:JsonProperty("prev") + public val prev: URI? = null, + @param:JsonProperty("next") + @get:JsonProperty("next") + public val next: URI? = null, + @param:JsonProperty("items") + @get:JsonProperty("items") + @get:NotNull + @get:Size(min = 0) + @get:Valid + public val items: List, +) diff --git a/src/test/resources/examples/githubApi/models/ContributorStatus.kt b/src/test/resources/examples/githubApi/models/ContributorStatus.kt new file mode 100644 index 00000000..8616f7dc --- /dev/null +++ b/src/test/resources/examples/githubApi/models/ContributorStatus.kt @@ -0,0 +1,21 @@ +package examples.githubApi.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class ContributorStatus( + @JsonValue + public val `value`: String, +) { + ACTIVE("active"), + INACTIVE("inactive"), + ; + + public companion object { + private val mapping: Map = + values().associateBy(ContributorStatus::value) + + public fun fromValue(`value`: String): ContributorStatus? = mapping[value] + } +} diff --git a/src/test/resources/examples/githubApi/models/EntityDetails.kt b/src/test/resources/examples/githubApi/models/EntityDetails.kt new file mode 100644 index 00000000..3f6c424c --- /dev/null +++ b/src/test/resources/examples/githubApi/models/EntityDetails.kt @@ -0,0 +1,28 @@ +package examples.githubApi.models + +import com.fasterxml.jackson.`annotation`.JsonAnyGetter +import com.fasterxml.jackson.`annotation`.JsonAnySetter +import com.fasterxml.jackson.`annotation`.JsonIgnore +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.Any +import kotlin.String +import kotlin.collections.Map +import kotlin.collections.MutableMap + +public data class EntityDetails( + @param:JsonProperty("id") + @get:JsonProperty("id") + @get:NotNull + public val id: String, + @get:JsonIgnore + public val properties: MutableMap = mutableMapOf(), +) { + @JsonAnyGetter + public fun `get`(): Map = properties + + @JsonAnySetter + public fun `set`(name: String, `value`: Any?) { + properties[name] = value + } +} diff --git a/src/test/resources/examples/githubApi/models/Event.kt b/src/test/resources/examples/githubApi/models/Event.kt new file mode 100644 index 00000000..2ac36ec8 --- /dev/null +++ b/src/test/resources/examples/githubApi/models/Event.kt @@ -0,0 +1,32 @@ +package examples.githubApi.models + +import com.fasterxml.jackson.`annotation`.JsonAnyGetter +import com.fasterxml.jackson.`annotation`.JsonAnySetter +import com.fasterxml.jackson.`annotation`.JsonIgnore +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.Any +import kotlin.String +import kotlin.collections.Map +import kotlin.collections.MutableMap + +public data class Event( + @param:JsonProperty("entity_id") + @get:JsonProperty("entity_id") + @get:NotNull + public val entityId: String, + @param:JsonProperty("data") + @get:JsonProperty("data") + @get:NotNull + public val `data`: Map, + @get:JsonIgnore + public val properties: MutableMap = mutableMapOf(), +) { + @JsonAnyGetter + public fun `get`(): Map = properties + + @JsonAnySetter + public fun `set`(name: String, `value`: Any?) { + properties[name] = value + } +} diff --git a/src/test/resources/examples/githubApi/models/EventResults.kt b/src/test/resources/examples/githubApi/models/EventResults.kt new file mode 100644 index 00000000..2caeca93 --- /dev/null +++ b/src/test/resources/examples/githubApi/models/EventResults.kt @@ -0,0 +1,33 @@ +package examples.githubApi.models + +import com.fasterxml.jackson.`annotation`.JsonAnyGetter +import com.fasterxml.jackson.`annotation`.JsonAnySetter +import com.fasterxml.jackson.`annotation`.JsonIgnore +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import javax.validation.constraints.NotNull +import javax.validation.constraints.Size +import kotlin.Any +import kotlin.String +import kotlin.collections.List +import kotlin.collections.Map +import kotlin.collections.MutableMap + +public data class EventResults( + @param:JsonProperty("change_events") + @get:JsonProperty("change_events") + @get:NotNull + @get:Size(min = 0) + @get:Valid + public val changeEvents: List, + @get:JsonIgnore + public val properties: MutableMap = mutableMapOf(), +) { + @JsonAnyGetter + public fun `get`(): Map = properties + + @JsonAnySetter + public fun `set`(name: String, `value`: Any?) { + properties[name] = value + } +} diff --git a/src/test/resources/examples/githubApi/models/Models.kt b/src/test/resources/examples/githubApi/models/Models.kt deleted file mode 100644 index 31f1a64b..00000000 --- a/src/test/resources/examples/githubApi/models/Models.kt +++ /dev/null @@ -1,447 +0,0 @@ -package examples.githubApi.models - -import com.fasterxml.jackson.`annotation`.JsonAnyGetter -import com.fasterxml.jackson.`annotation`.JsonAnySetter -import com.fasterxml.jackson.`annotation`.JsonIgnore -import com.fasterxml.jackson.`annotation`.JsonProperty -import com.fasterxml.jackson.`annotation`.JsonValue -import java.net.URI -import java.time.OffsetDateTime -import javax.validation.Valid -import javax.validation.constraints.NotNull -import javax.validation.constraints.Size -import kotlin.Any -import kotlin.String -import kotlin.collections.List -import kotlin.collections.Map -import kotlin.collections.MutableMap - -public data class Author( - @param:JsonProperty("name") - @get:JsonProperty("name") - public val name: String? = null, - @param:JsonProperty("email") - @get:JsonProperty("email") - public val email: String? = null, -) - -public data class BulkEntityDetails( - @param:JsonProperty("entities") - @get:JsonProperty("entities") - @get:NotNull - @get:Valid - public val entities: List, - @get:JsonIgnore - public val properties: MutableMap = mutableMapOf(), -) { - @JsonAnyGetter - public fun `get`(): Map = properties - - @JsonAnySetter - public fun `set`(name: String, `value`: Any?) { - properties[name] = value - } -} - -public data class Contributor( - @param:JsonProperty("id") - @get:JsonProperty("id") - public val id: String? = null, - @param:JsonProperty("audit_actor") - @get:JsonProperty("audit_actor") - public val auditActor: String? = null, - @param:JsonProperty("created") - @get:JsonProperty("created") - public val created: OffsetDateTime? = null, - @param:JsonProperty("created_by") - @get:JsonProperty("created_by") - public val createdBy: String? = null, - @param:JsonProperty("created_by_uid") - @get:JsonProperty("created_by_uid") - public val createdByUid: String? = null, - @param:JsonProperty("modified") - @get:JsonProperty("modified") - public val modified: OffsetDateTime? = null, - @param:JsonProperty("modified_by") - @get:JsonProperty("modified_by") - public val modifiedBy: String? = null, - @param:JsonProperty("modified_by_uid") - @get:JsonProperty("modified_by_uid") - public val modifiedByUid: String? = null, - @param:JsonProperty("status") - @get:JsonProperty("status") - @get:NotNull - public val status: ContributorStatus, - @param:JsonProperty("etag") - @get:JsonProperty("etag") - public val etag: String? = null, - @param:JsonProperty("username") - @get:JsonProperty("username") - @get:NotNull - public val username: String, - @param:JsonProperty("name") - @get:JsonProperty("name") - public val name: String? = null, -) - -public data class ContributorQueryResult( - @param:JsonProperty("prev") - @get:JsonProperty("prev") - public val prev: URI? = null, - @param:JsonProperty("next") - @get:JsonProperty("next") - public val next: URI? = null, - @param:JsonProperty("items") - @get:JsonProperty("items") - @get:NotNull - @get:Size(min = 0) - @get:Valid - public val items: List, -) - -public enum class ContributorStatus( - @JsonValue - public val `value`: String, -) { - ACTIVE("active"), - INACTIVE("inactive"), - ; - - public companion object { - private val mapping: Map = - values().associateBy(ContributorStatus::value) - - public fun fromValue(`value`: String): ContributorStatus? = mapping[value] - } -} - -public data class EntityDetails( - @param:JsonProperty("id") - @get:JsonProperty("id") - @get:NotNull - public val id: String, - @get:JsonIgnore - public val properties: MutableMap = mutableMapOf(), -) { - @JsonAnyGetter - public fun `get`(): Map = properties - - @JsonAnySetter - public fun `set`(name: String, `value`: Any?) { - properties[name] = value - } -} - -public data class Event( - @param:JsonProperty("entity_id") - @get:JsonProperty("entity_id") - @get:NotNull - public val entityId: String, - @param:JsonProperty("data") - @get:JsonProperty("data") - @get:NotNull - public val `data`: Map, - @get:JsonIgnore - public val properties: MutableMap = mutableMapOf(), -) { - @JsonAnyGetter - public fun `get`(): Map = properties - - @JsonAnySetter - public fun `set`(name: String, `value`: Any?) { - properties[name] = value - } -} - -public data class EventResults( - @param:JsonProperty("change_events") - @get:JsonProperty("change_events") - @get:NotNull - @get:Size(min = 0) - @get:Valid - public val changeEvents: List, - @get:JsonIgnore - public val properties: MutableMap = mutableMapOf(), -) { - @JsonAnyGetter - public fun `get`(): Map = properties - - @JsonAnySetter - public fun `set`(name: String, `value`: Any?) { - properties[name] = value - } -} - -public data class Organisation( - @param:JsonProperty("id") - @get:JsonProperty("id") - public val id: String? = null, - @param:JsonProperty("audit_actor") - @get:JsonProperty("audit_actor") - public val auditActor: String? = null, - @param:JsonProperty("created") - @get:JsonProperty("created") - public val created: OffsetDateTime? = null, - @param:JsonProperty("created_by") - @get:JsonProperty("created_by") - public val createdBy: String? = null, - @param:JsonProperty("created_by_uid") - @get:JsonProperty("created_by_uid") - public val createdByUid: String? = null, - @param:JsonProperty("modified") - @get:JsonProperty("modified") - public val modified: OffsetDateTime? = null, - @param:JsonProperty("modified_by") - @get:JsonProperty("modified_by") - public val modifiedBy: String? = null, - @param:JsonProperty("modified_by_uid") - @get:JsonProperty("modified_by_uid") - public val modifiedByUid: String? = null, - @param:JsonProperty("status") - @get:JsonProperty("status") - @get:NotNull - public val status: OrganisationStatus, - @param:JsonProperty("etag") - @get:JsonProperty("etag") - public val etag: String? = null, - @param:JsonProperty("name") - @get:JsonProperty("name") - @get:NotNull - public val name: String, - @param:JsonProperty("icon") - @get:JsonProperty("icon") - public val icon: String? = null, - @param:JsonProperty("hooks") - @get:JsonProperty("hooks") - @get:Valid - public val hooks: List? = null, -) - -public data class OrganisationQueryResult( - @param:JsonProperty("prev") - @get:JsonProperty("prev") - public val prev: URI? = null, - @param:JsonProperty("next") - @get:JsonProperty("next") - public val next: URI? = null, - @param:JsonProperty("items") - @get:JsonProperty("items") - @get:NotNull - @get:Size(min = 0) - @get:Valid - public val items: List, -) - -public enum class OrganisationStatus( - @JsonValue - public val `value`: String, -) { - ACTIVE("active"), - INACTIVE("inactive"), - ; - - public companion object { - private val mapping: Map = - values().associateBy(OrganisationStatus::value) - - public fun fromValue(`value`: String): OrganisationStatus? = mapping[value] - } -} - -public data class PullRequest( - @param:JsonProperty("id") - @get:JsonProperty("id") - public val id: String? = null, - @param:JsonProperty("audit_actor") - @get:JsonProperty("audit_actor") - public val auditActor: String? = null, - @param:JsonProperty("created") - @get:JsonProperty("created") - public val created: OffsetDateTime? = null, - @param:JsonProperty("created_by") - @get:JsonProperty("created_by") - public val createdBy: String? = null, - @param:JsonProperty("created_by_uid") - @get:JsonProperty("created_by_uid") - public val createdByUid: String? = null, - @param:JsonProperty("modified") - @get:JsonProperty("modified") - public val modified: OffsetDateTime? = null, - @param:JsonProperty("modified_by") - @get:JsonProperty("modified_by") - public val modifiedBy: String? = null, - @param:JsonProperty("modified_by_uid") - @get:JsonProperty("modified_by_uid") - public val modifiedByUid: String? = null, - @param:JsonProperty("status") - @get:JsonProperty("status") - @get:NotNull - public val status: PullRequestStatus, - @param:JsonProperty("etag") - @get:JsonProperty("etag") - public val etag: String? = null, - @param:JsonProperty("title") - @get:JsonProperty("title") - @get:NotNull - public val title: String, - @param:JsonProperty("description") - @get:JsonProperty("description") - public val description: String? = null, - @param:JsonProperty("author") - @get:JsonProperty("author") - @get:Valid - public val author: Author? = null, -) - -public data class PullRequestQueryResult( - @param:JsonProperty("prev") - @get:JsonProperty("prev") - public val prev: URI? = null, - @param:JsonProperty("next") - @get:JsonProperty("next") - public val next: URI? = null, - @param:JsonProperty("items") - @get:JsonProperty("items") - @get:NotNull - @get:Size(min = 0) - @get:Valid - public val items: List, -) - -public enum class PullRequestStatus( - @JsonValue - public val `value`: String, -) { - ACTIVE("active"), - INACTIVE("inactive"), - ; - - public companion object { - private val mapping: Map = - values().associateBy(PullRequestStatus::value) - - public fun fromValue(`value`: String): PullRequestStatus? = mapping[value] - } -} - -public data class Repository( - @param:JsonProperty("id") - @get:JsonProperty("id") - public val id: String? = null, - @param:JsonProperty("audit_actor") - @get:JsonProperty("audit_actor") - public val auditActor: String? = null, - @param:JsonProperty("created") - @get:JsonProperty("created") - public val created: OffsetDateTime? = null, - @param:JsonProperty("created_by") - @get:JsonProperty("created_by") - public val createdBy: String? = null, - @param:JsonProperty("created_by_uid") - @get:JsonProperty("created_by_uid") - public val createdByUid: String? = null, - @param:JsonProperty("modified") - @get:JsonProperty("modified") - public val modified: OffsetDateTime? = null, - @param:JsonProperty("modified_by") - @get:JsonProperty("modified_by") - public val modifiedBy: String? = null, - @param:JsonProperty("modified_by_uid") - @get:JsonProperty("modified_by_uid") - public val modifiedByUid: String? = null, - @param:JsonProperty("status") - @get:JsonProperty("status") - @get:NotNull - public val status: RepositoryStatus, - @param:JsonProperty("etag") - @get:JsonProperty("etag") - public val etag: String? = null, - @param:JsonProperty("slug") - @get:JsonProperty("slug") - @get:NotNull - public val slug: String, - @param:JsonProperty("name") - @get:JsonProperty("name") - @get:NotNull - public val name: String, - @param:JsonProperty("visibility") - @get:JsonProperty("visibility") - public val visibility: RepositoryVisibility? = null, - @param:JsonProperty("tags") - @get:JsonProperty("tags") - public val tags: List? = null, -) - -public data class RepositoryQueryResult( - @param:JsonProperty("prev") - @get:JsonProperty("prev") - public val prev: URI? = null, - @param:JsonProperty("next") - @get:JsonProperty("next") - public val next: URI? = null, - @param:JsonProperty("items") - @get:JsonProperty("items") - @get:NotNull - @get:Size(min = 0) - @get:Valid - public val items: List, -) - -public enum class RepositoryStatus( - @JsonValue - public val `value`: String, -) { - ACTIVE("active"), - INACTIVE("inactive"), - ; - - public companion object { - private val mapping: Map = - values().associateBy(RepositoryStatus::value) - - public fun fromValue(`value`: String): RepositoryStatus? = mapping[value] - } -} - -public enum class RepositoryVisibility( - @JsonValue - public val `value`: String, -) { - PRIVATE("Private"), - PUBLIC("Public"), - ; - - public companion object { - private val mapping: Map = - values().associateBy(RepositoryVisibility::value) - - public fun fromValue(`value`: String): RepositoryVisibility? = mapping[value] - } -} - -public enum class StatusQueryParam( - @JsonValue - public val `value`: String, -) { - ACTIVE("active"), - INACTIVE("inactive"), - ALL("all"), - ; - - public companion object { - private val mapping: Map = - values().associateBy(StatusQueryParam::value) - - public fun fromValue(`value`: String): StatusQueryParam? = mapping[value] - } -} - -public data class Webhook( - @param:JsonProperty("url") - @get:JsonProperty("url") - @get:NotNull - public val url: String, - @param:JsonProperty("name") - @get:JsonProperty("name") - public val name: String? = null, -) diff --git a/src/test/resources/examples/githubApi/models/Organisation.kt b/src/test/resources/examples/githubApi/models/Organisation.kt new file mode 100644 index 00000000..31f64bb9 --- /dev/null +++ b/src/test/resources/examples/githubApi/models/Organisation.kt @@ -0,0 +1,53 @@ +package examples.githubApi.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import java.time.OffsetDateTime +import javax.validation.Valid +import javax.validation.constraints.NotNull +import kotlin.String +import kotlin.collections.List + +public data class Organisation( + @param:JsonProperty("id") + @get:JsonProperty("id") + public val id: String? = null, + @param:JsonProperty("audit_actor") + @get:JsonProperty("audit_actor") + public val auditActor: String? = null, + @param:JsonProperty("created") + @get:JsonProperty("created") + public val created: OffsetDateTime? = null, + @param:JsonProperty("created_by") + @get:JsonProperty("created_by") + public val createdBy: String? = null, + @param:JsonProperty("created_by_uid") + @get:JsonProperty("created_by_uid") + public val createdByUid: String? = null, + @param:JsonProperty("modified") + @get:JsonProperty("modified") + public val modified: OffsetDateTime? = null, + @param:JsonProperty("modified_by") + @get:JsonProperty("modified_by") + public val modifiedBy: String? = null, + @param:JsonProperty("modified_by_uid") + @get:JsonProperty("modified_by_uid") + public val modifiedByUid: String? = null, + @param:JsonProperty("status") + @get:JsonProperty("status") + @get:NotNull + public val status: OrganisationStatus, + @param:JsonProperty("etag") + @get:JsonProperty("etag") + public val etag: String? = null, + @param:JsonProperty("name") + @get:JsonProperty("name") + @get:NotNull + public val name: String, + @param:JsonProperty("icon") + @get:JsonProperty("icon") + public val icon: String? = null, + @param:JsonProperty("hooks") + @get:JsonProperty("hooks") + @get:Valid + public val hooks: List? = null, +) diff --git a/src/test/resources/examples/githubApi/models/OrganisationQueryResult.kt b/src/test/resources/examples/githubApi/models/OrganisationQueryResult.kt new file mode 100644 index 00000000..e6d3cae7 --- /dev/null +++ b/src/test/resources/examples/githubApi/models/OrganisationQueryResult.kt @@ -0,0 +1,23 @@ +package examples.githubApi.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import java.net.URI +import javax.validation.Valid +import javax.validation.constraints.NotNull +import javax.validation.constraints.Size +import kotlin.collections.List + +public data class OrganisationQueryResult( + @param:JsonProperty("prev") + @get:JsonProperty("prev") + public val prev: URI? = null, + @param:JsonProperty("next") + @get:JsonProperty("next") + public val next: URI? = null, + @param:JsonProperty("items") + @get:JsonProperty("items") + @get:NotNull + @get:Size(min = 0) + @get:Valid + public val items: List, +) diff --git a/src/test/resources/examples/githubApi/models/OrganisationStatus.kt b/src/test/resources/examples/githubApi/models/OrganisationStatus.kt new file mode 100644 index 00000000..abda5cd8 --- /dev/null +++ b/src/test/resources/examples/githubApi/models/OrganisationStatus.kt @@ -0,0 +1,21 @@ +package examples.githubApi.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class OrganisationStatus( + @JsonValue + public val `value`: String, +) { + ACTIVE("active"), + INACTIVE("inactive"), + ; + + public companion object { + private val mapping: Map = + values().associateBy(OrganisationStatus::value) + + public fun fromValue(`value`: String): OrganisationStatus? = mapping[value] + } +} diff --git a/src/test/resources/examples/githubApi/models/PullRequest.kt b/src/test/resources/examples/githubApi/models/PullRequest.kt new file mode 100644 index 00000000..6913e8f4 --- /dev/null +++ b/src/test/resources/examples/githubApi/models/PullRequest.kt @@ -0,0 +1,52 @@ +package examples.githubApi.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import java.time.OffsetDateTime +import javax.validation.Valid +import javax.validation.constraints.NotNull +import kotlin.String + +public data class PullRequest( + @param:JsonProperty("id") + @get:JsonProperty("id") + public val id: String? = null, + @param:JsonProperty("audit_actor") + @get:JsonProperty("audit_actor") + public val auditActor: String? = null, + @param:JsonProperty("created") + @get:JsonProperty("created") + public val created: OffsetDateTime? = null, + @param:JsonProperty("created_by") + @get:JsonProperty("created_by") + public val createdBy: String? = null, + @param:JsonProperty("created_by_uid") + @get:JsonProperty("created_by_uid") + public val createdByUid: String? = null, + @param:JsonProperty("modified") + @get:JsonProperty("modified") + public val modified: OffsetDateTime? = null, + @param:JsonProperty("modified_by") + @get:JsonProperty("modified_by") + public val modifiedBy: String? = null, + @param:JsonProperty("modified_by_uid") + @get:JsonProperty("modified_by_uid") + public val modifiedByUid: String? = null, + @param:JsonProperty("status") + @get:JsonProperty("status") + @get:NotNull + public val status: PullRequestStatus, + @param:JsonProperty("etag") + @get:JsonProperty("etag") + public val etag: String? = null, + @param:JsonProperty("title") + @get:JsonProperty("title") + @get:NotNull + public val title: String, + @param:JsonProperty("description") + @get:JsonProperty("description") + public val description: String? = null, + @param:JsonProperty("author") + @get:JsonProperty("author") + @get:Valid + public val author: Author? = null, +) diff --git a/src/test/resources/examples/githubApi/models/PullRequestQueryResult.kt b/src/test/resources/examples/githubApi/models/PullRequestQueryResult.kt new file mode 100644 index 00000000..2e4641a6 --- /dev/null +++ b/src/test/resources/examples/githubApi/models/PullRequestQueryResult.kt @@ -0,0 +1,23 @@ +package examples.githubApi.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import java.net.URI +import javax.validation.Valid +import javax.validation.constraints.NotNull +import javax.validation.constraints.Size +import kotlin.collections.List + +public data class PullRequestQueryResult( + @param:JsonProperty("prev") + @get:JsonProperty("prev") + public val prev: URI? = null, + @param:JsonProperty("next") + @get:JsonProperty("next") + public val next: URI? = null, + @param:JsonProperty("items") + @get:JsonProperty("items") + @get:NotNull + @get:Size(min = 0) + @get:Valid + public val items: List, +) diff --git a/src/test/resources/examples/githubApi/models/PullRequestStatus.kt b/src/test/resources/examples/githubApi/models/PullRequestStatus.kt new file mode 100644 index 00000000..c57da1f9 --- /dev/null +++ b/src/test/resources/examples/githubApi/models/PullRequestStatus.kt @@ -0,0 +1,21 @@ +package examples.githubApi.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class PullRequestStatus( + @JsonValue + public val `value`: String, +) { + ACTIVE("active"), + INACTIVE("inactive"), + ; + + public companion object { + private val mapping: Map = + values().associateBy(PullRequestStatus::value) + + public fun fromValue(`value`: String): PullRequestStatus? = mapping[value] + } +} diff --git a/src/test/resources/examples/githubApi/models/Repository.kt b/src/test/resources/examples/githubApi/models/Repository.kt new file mode 100644 index 00000000..3900c57a --- /dev/null +++ b/src/test/resources/examples/githubApi/models/Repository.kt @@ -0,0 +1,55 @@ +package examples.githubApi.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import java.time.OffsetDateTime +import javax.validation.constraints.NotNull +import kotlin.String +import kotlin.collections.List + +public data class Repository( + @param:JsonProperty("id") + @get:JsonProperty("id") + public val id: String? = null, + @param:JsonProperty("audit_actor") + @get:JsonProperty("audit_actor") + public val auditActor: String? = null, + @param:JsonProperty("created") + @get:JsonProperty("created") + public val created: OffsetDateTime? = null, + @param:JsonProperty("created_by") + @get:JsonProperty("created_by") + public val createdBy: String? = null, + @param:JsonProperty("created_by_uid") + @get:JsonProperty("created_by_uid") + public val createdByUid: String? = null, + @param:JsonProperty("modified") + @get:JsonProperty("modified") + public val modified: OffsetDateTime? = null, + @param:JsonProperty("modified_by") + @get:JsonProperty("modified_by") + public val modifiedBy: String? = null, + @param:JsonProperty("modified_by_uid") + @get:JsonProperty("modified_by_uid") + public val modifiedByUid: String? = null, + @param:JsonProperty("status") + @get:JsonProperty("status") + @get:NotNull + public val status: RepositoryStatus, + @param:JsonProperty("etag") + @get:JsonProperty("etag") + public val etag: String? = null, + @param:JsonProperty("slug") + @get:JsonProperty("slug") + @get:NotNull + public val slug: String, + @param:JsonProperty("name") + @get:JsonProperty("name") + @get:NotNull + public val name: String, + @param:JsonProperty("visibility") + @get:JsonProperty("visibility") + public val visibility: RepositoryVisibility? = null, + @param:JsonProperty("tags") + @get:JsonProperty("tags") + public val tags: List? = null, +) diff --git a/src/test/resources/examples/githubApi/models/RepositoryQueryResult.kt b/src/test/resources/examples/githubApi/models/RepositoryQueryResult.kt new file mode 100644 index 00000000..677d52e8 --- /dev/null +++ b/src/test/resources/examples/githubApi/models/RepositoryQueryResult.kt @@ -0,0 +1,23 @@ +package examples.githubApi.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import java.net.URI +import javax.validation.Valid +import javax.validation.constraints.NotNull +import javax.validation.constraints.Size +import kotlin.collections.List + +public data class RepositoryQueryResult( + @param:JsonProperty("prev") + @get:JsonProperty("prev") + public val prev: URI? = null, + @param:JsonProperty("next") + @get:JsonProperty("next") + public val next: URI? = null, + @param:JsonProperty("items") + @get:JsonProperty("items") + @get:NotNull + @get:Size(min = 0) + @get:Valid + public val items: List, +) diff --git a/src/test/resources/examples/githubApi/models/RepositoryStatus.kt b/src/test/resources/examples/githubApi/models/RepositoryStatus.kt new file mode 100644 index 00000000..83f8aa23 --- /dev/null +++ b/src/test/resources/examples/githubApi/models/RepositoryStatus.kt @@ -0,0 +1,21 @@ +package examples.githubApi.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class RepositoryStatus( + @JsonValue + public val `value`: String, +) { + ACTIVE("active"), + INACTIVE("inactive"), + ; + + public companion object { + private val mapping: Map = + values().associateBy(RepositoryStatus::value) + + public fun fromValue(`value`: String): RepositoryStatus? = mapping[value] + } +} diff --git a/src/test/resources/examples/githubApi/models/RepositoryVisibility.kt b/src/test/resources/examples/githubApi/models/RepositoryVisibility.kt new file mode 100644 index 00000000..a46f42a8 --- /dev/null +++ b/src/test/resources/examples/githubApi/models/RepositoryVisibility.kt @@ -0,0 +1,21 @@ +package examples.githubApi.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class RepositoryVisibility( + @JsonValue + public val `value`: String, +) { + PRIVATE("Private"), + PUBLIC("Public"), + ; + + public companion object { + private val mapping: Map = + values().associateBy(RepositoryVisibility::value) + + public fun fromValue(`value`: String): RepositoryVisibility? = mapping[value] + } +} diff --git a/src/test/resources/examples/githubApi/models/StatusQueryParam.kt b/src/test/resources/examples/githubApi/models/StatusQueryParam.kt new file mode 100644 index 00000000..bb8b637f --- /dev/null +++ b/src/test/resources/examples/githubApi/models/StatusQueryParam.kt @@ -0,0 +1,22 @@ +package examples.githubApi.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class StatusQueryParam( + @JsonValue + public val `value`: String, +) { + ACTIVE("active"), + INACTIVE("inactive"), + ALL("all"), + ; + + public companion object { + private val mapping: Map = + values().associateBy(StatusQueryParam::value) + + public fun fromValue(`value`: String): StatusQueryParam? = mapping[value] + } +} diff --git a/src/test/resources/examples/githubApi/models/Webhook.kt b/src/test/resources/examples/githubApi/models/Webhook.kt new file mode 100644 index 00000000..559ddad1 --- /dev/null +++ b/src/test/resources/examples/githubApi/models/Webhook.kt @@ -0,0 +1,15 @@ +package examples.githubApi.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.String + +public data class Webhook( + @param:JsonProperty("url") + @get:JsonProperty("url") + @get:NotNull + public val url: String, + @param:JsonProperty("name") + @get:JsonProperty("name") + public val name: String? = null, +) diff --git a/src/test/resources/examples/inLinedObject/models/FirstInlineObject.kt b/src/test/resources/examples/inLinedObject/models/FirstInlineObject.kt new file mode 100644 index 00000000..634c2b7a --- /dev/null +++ b/src/test/resources/examples/inLinedObject/models/FirstInlineObject.kt @@ -0,0 +1,11 @@ +package examples.inLinedObject.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid + +public data class FirstInlineObject( + @param:JsonProperty("generation") + @get:JsonProperty("generation") + @get:Valid + public val generation: FirstInlineObjectGeneration? = null, +) diff --git a/src/test/resources/examples/inLinedObject/models/FirstInlineObjectCallHome.kt b/src/test/resources/examples/inLinedObject/models/FirstInlineObjectCallHome.kt new file mode 100644 index 00000000..f32056e1 --- /dev/null +++ b/src/test/resources/examples/inLinedObject/models/FirstInlineObjectCallHome.kt @@ -0,0 +1,12 @@ +package examples.inLinedObject.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.String + +public data class FirstInlineObjectCallHome( + @param:JsonProperty("url") + @get:JsonProperty("url") + @get:NotNull + public val url: String, +) diff --git a/src/test/resources/examples/inLinedObject/models/FirstInlineObjectDatabaseView.kt b/src/test/resources/examples/inLinedObject/models/FirstInlineObjectDatabaseView.kt new file mode 100644 index 00000000..a4087b6f --- /dev/null +++ b/src/test/resources/examples/inLinedObject/models/FirstInlineObjectDatabaseView.kt @@ -0,0 +1,12 @@ +package examples.inLinedObject.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.String + +public data class FirstInlineObjectDatabaseView( + @param:JsonProperty("view_name") + @get:JsonProperty("view_name") + @get:NotNull + public val viewName: String, +) diff --git a/src/test/resources/examples/inLinedObject/models/FirstInlineObjectGeneration.kt b/src/test/resources/examples/inLinedObject/models/FirstInlineObjectGeneration.kt new file mode 100644 index 00000000..2a498203 --- /dev/null +++ b/src/test/resources/examples/inLinedObject/models/FirstInlineObjectGeneration.kt @@ -0,0 +1,19 @@ +package examples.inLinedObject.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import kotlin.String + +public data class FirstInlineObjectGeneration( + @param:JsonProperty("call_home") + @get:JsonProperty("call_home") + @get:Valid + public val callHome: FirstInlineObjectCallHome? = null, + @param:JsonProperty("database_view") + @get:JsonProperty("database_view") + @get:Valid + public val databaseView: FirstInlineObjectDatabaseView? = null, + @param:JsonProperty("direct") + @get:JsonProperty("direct") + public val direct: String? = null, +) diff --git a/src/test/resources/examples/inLinedObject/models/Models.kt b/src/test/resources/examples/inLinedObject/models/Models.kt deleted file mode 100644 index 9c2d9805..00000000 --- a/src/test/resources/examples/inLinedObject/models/Models.kt +++ /dev/null @@ -1,100 +0,0 @@ -package examples.inLinedObject.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import javax.validation.Valid -import javax.validation.constraints.NotNull -import kotlin.String -import kotlin.collections.List - -public data class FirstInlineObject( - @param:JsonProperty("generation") - @get:JsonProperty("generation") - @get:Valid - public val generation: FirstInlineObjectGeneration? = null, -) - -public data class FirstInlineObjectCallHome( - @param:JsonProperty("url") - @get:JsonProperty("url") - @get:NotNull - public val url: String, -) - -public data class FirstInlineObjectDatabaseView( - @param:JsonProperty("view_name") - @get:JsonProperty("view_name") - @get:NotNull - public val viewName: String, -) - -public data class FirstInlineObjectGeneration( - @param:JsonProperty("call_home") - @get:JsonProperty("call_home") - @get:Valid - public val callHome: FirstInlineObjectCallHome? = null, - @param:JsonProperty("database_view") - @get:JsonProperty("database_view") - @get:Valid - public val databaseView: FirstInlineObjectDatabaseView? = null, - @param:JsonProperty("direct") - @get:JsonProperty("direct") - public val direct: String? = null, -) - -public data class SecondInlineObject( - @param:JsonProperty("generation") - @get:JsonProperty("generation") - @get:Valid - public val generation: SecondInlineObjectGeneration? = null, -) - -public data class SecondInlineObjectCallHome( - @param:JsonProperty("url") - @get:JsonProperty("url") - @get:NotNull - public val url: String, -) - -public data class SecondInlineObjectDatabaseView( - @param:JsonProperty("view_name") - @get:JsonProperty("view_name") - @get:NotNull - public val viewName: String, -) - -public data class SecondInlineObjectGeneration( - @param:JsonProperty("call_home") - @get:JsonProperty("call_home") - @get:Valid - public val callHome: SecondInlineObjectCallHome? = null, - @param:JsonProperty("database_view") - @get:JsonProperty("database_view") - @get:Valid - public val databaseView: SecondInlineObjectDatabaseView? = null, - @param:JsonProperty("direct") - @get:JsonProperty("direct") - public val direct: String? = null, -) - -public data class ThirdInlineObject( - @param:JsonProperty("generation") - @get:JsonProperty("generation") - @get:Valid - public val generation: ThirdInlineObjectGeneration? = null, -) - -public data class ThirdInlineObjectGeneration( - @param:JsonProperty("urls") - @get:JsonProperty("urls") - @get:Valid - public val urls: List? = null, - @param:JsonProperty("view_name") - @get:JsonProperty("view_name") - public val viewName: String? = null, -) - -public data class ThirdInlineObjectUrls( - @param:JsonProperty("version") - @get:JsonProperty("version") - public val version: String? = null, -) diff --git a/src/test/resources/examples/inLinedObject/models/SecondInlineObject.kt b/src/test/resources/examples/inLinedObject/models/SecondInlineObject.kt new file mode 100644 index 00000000..899da0f3 --- /dev/null +++ b/src/test/resources/examples/inLinedObject/models/SecondInlineObject.kt @@ -0,0 +1,11 @@ +package examples.inLinedObject.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid + +public data class SecondInlineObject( + @param:JsonProperty("generation") + @get:JsonProperty("generation") + @get:Valid + public val generation: SecondInlineObjectGeneration? = null, +) diff --git a/src/test/resources/examples/inLinedObject/models/SecondInlineObjectCallHome.kt b/src/test/resources/examples/inLinedObject/models/SecondInlineObjectCallHome.kt new file mode 100644 index 00000000..c3f0ebdd --- /dev/null +++ b/src/test/resources/examples/inLinedObject/models/SecondInlineObjectCallHome.kt @@ -0,0 +1,12 @@ +package examples.inLinedObject.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.String + +public data class SecondInlineObjectCallHome( + @param:JsonProperty("url") + @get:JsonProperty("url") + @get:NotNull + public val url: String, +) diff --git a/src/test/resources/examples/inLinedObject/models/SecondInlineObjectDatabaseView.kt b/src/test/resources/examples/inLinedObject/models/SecondInlineObjectDatabaseView.kt new file mode 100644 index 00000000..bacefa72 --- /dev/null +++ b/src/test/resources/examples/inLinedObject/models/SecondInlineObjectDatabaseView.kt @@ -0,0 +1,12 @@ +package examples.inLinedObject.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.String + +public data class SecondInlineObjectDatabaseView( + @param:JsonProperty("view_name") + @get:JsonProperty("view_name") + @get:NotNull + public val viewName: String, +) diff --git a/src/test/resources/examples/inLinedObject/models/SecondInlineObjectGeneration.kt b/src/test/resources/examples/inLinedObject/models/SecondInlineObjectGeneration.kt new file mode 100644 index 00000000..f0a92a8f --- /dev/null +++ b/src/test/resources/examples/inLinedObject/models/SecondInlineObjectGeneration.kt @@ -0,0 +1,19 @@ +package examples.inLinedObject.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import kotlin.String + +public data class SecondInlineObjectGeneration( + @param:JsonProperty("call_home") + @get:JsonProperty("call_home") + @get:Valid + public val callHome: SecondInlineObjectCallHome? = null, + @param:JsonProperty("database_view") + @get:JsonProperty("database_view") + @get:Valid + public val databaseView: SecondInlineObjectDatabaseView? = null, + @param:JsonProperty("direct") + @get:JsonProperty("direct") + public val direct: String? = null, +) diff --git a/src/test/resources/examples/inLinedObject/models/ThirdInlineObject.kt b/src/test/resources/examples/inLinedObject/models/ThirdInlineObject.kt new file mode 100644 index 00000000..73f5b705 --- /dev/null +++ b/src/test/resources/examples/inLinedObject/models/ThirdInlineObject.kt @@ -0,0 +1,11 @@ +package examples.inLinedObject.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid + +public data class ThirdInlineObject( + @param:JsonProperty("generation") + @get:JsonProperty("generation") + @get:Valid + public val generation: ThirdInlineObjectGeneration? = null, +) diff --git a/src/test/resources/examples/inLinedObject/models/ThirdInlineObjectGeneration.kt b/src/test/resources/examples/inLinedObject/models/ThirdInlineObjectGeneration.kt new file mode 100644 index 00000000..58e67d84 --- /dev/null +++ b/src/test/resources/examples/inLinedObject/models/ThirdInlineObjectGeneration.kt @@ -0,0 +1,16 @@ +package examples.inLinedObject.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import kotlin.String +import kotlin.collections.List + +public data class ThirdInlineObjectGeneration( + @param:JsonProperty("urls") + @get:JsonProperty("urls") + @get:Valid + public val urls: List? = null, + @param:JsonProperty("view_name") + @get:JsonProperty("view_name") + public val viewName: String? = null, +) diff --git a/src/test/resources/examples/inLinedObject/models/ThirdInlineObjectUrls.kt b/src/test/resources/examples/inLinedObject/models/ThirdInlineObjectUrls.kt new file mode 100644 index 00000000..4ffce1d6 --- /dev/null +++ b/src/test/resources/examples/inLinedObject/models/ThirdInlineObjectUrls.kt @@ -0,0 +1,10 @@ +package examples.inLinedObject.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class ThirdInlineObjectUrls( + @param:JsonProperty("version") + @get:JsonProperty("version") + public val version: String? = null, +) diff --git a/src/test/resources/examples/inlinedAggregatedObjects/models/Company.kt b/src/test/resources/examples/inlinedAggregatedObjects/models/Company.kt new file mode 100644 index 00000000..5997bd9e --- /dev/null +++ b/src/test/resources/examples/inlinedAggregatedObjects/models/Company.kt @@ -0,0 +1,12 @@ +package examples.inlinedAggregatedObjects.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.String + +public data class Company( + @param:JsonProperty("companyName") + @get:JsonProperty("companyName") + @get:NotNull + public val companyName: String, +) diff --git a/src/test/resources/examples/inlinedAggregatedObjects/models/Dog.kt b/src/test/resources/examples/inlinedAggregatedObjects/models/Dog.kt new file mode 100644 index 00000000..3f191da6 --- /dev/null +++ b/src/test/resources/examples/inlinedAggregatedObjects/models/Dog.kt @@ -0,0 +1,15 @@ +package examples.inlinedAggregatedObjects.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid + +public data class Dog( + @param:JsonProperty("owner") + @get:JsonProperty("owner") + @get:Valid + public val owner: Person? = null, + @param:JsonProperty("walker") + @get:JsonProperty("walker") + @get:Valid + public val walker: DogWalker? = null, +) diff --git a/src/test/resources/examples/inlinedAggregatedObjects/models/DogWalker.kt b/src/test/resources/examples/inlinedAggregatedObjects/models/DogWalker.kt new file mode 100644 index 00000000..3fcecbfb --- /dev/null +++ b/src/test/resources/examples/inlinedAggregatedObjects/models/DogWalker.kt @@ -0,0 +1,16 @@ +package examples.inlinedAggregatedObjects.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.String + +public data class DogWalker( + @param:JsonProperty("name") + @get:JsonProperty("name") + @get:NotNull + public val name: String, + @param:JsonProperty("companyName") + @get:JsonProperty("companyName") + @get:NotNull + public val companyName: String, +) diff --git a/src/test/resources/examples/inlinedAggregatedObjects/models/Models.kt b/src/test/resources/examples/inlinedAggregatedObjects/models/Models.kt deleted file mode 100644 index deecc15b..00000000 --- a/src/test/resources/examples/inlinedAggregatedObjects/models/Models.kt +++ /dev/null @@ -1,42 +0,0 @@ -package examples.inlinedAggregatedObjects.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import javax.validation.Valid -import javax.validation.constraints.NotNull -import kotlin.String - -public data class Company( - @param:JsonProperty("companyName") - @get:JsonProperty("companyName") - @get:NotNull - public val companyName: String, -) - -public data class Dog( - @param:JsonProperty("owner") - @get:JsonProperty("owner") - @get:Valid - public val owner: Person? = null, - @param:JsonProperty("walker") - @get:JsonProperty("walker") - @get:Valid - public val walker: DogWalker? = null, -) - -public data class DogWalker( - @param:JsonProperty("name") - @get:JsonProperty("name") - @get:NotNull - public val name: String, - @param:JsonProperty("companyName") - @get:JsonProperty("companyName") - @get:NotNull - public val companyName: String, -) - -public data class Person( - @param:JsonProperty("name") - @get:JsonProperty("name") - @get:NotNull - public val name: String, -) diff --git a/src/test/resources/examples/inlinedAggregatedObjects/models/Person.kt b/src/test/resources/examples/inlinedAggregatedObjects/models/Person.kt new file mode 100644 index 00000000..87eca206 --- /dev/null +++ b/src/test/resources/examples/inlinedAggregatedObjects/models/Person.kt @@ -0,0 +1,12 @@ +package examples.inlinedAggregatedObjects.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.String + +public data class Person( + @param:JsonProperty("name") + @get:JsonProperty("name") + @get:NotNull + public val name: String, +) diff --git a/src/test/resources/examples/instantDateTime/models/FirstModel.kt b/src/test/resources/examples/instantDateTime/models/FirstModel.kt new file mode 100644 index 00000000..70202b90 --- /dev/null +++ b/src/test/resources/examples/instantDateTime/models/FirstModel.kt @@ -0,0 +1,14 @@ +package examples.instantDateTime.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import java.time.Instant +import kotlin.collections.List + +public data class FirstModel( + @param:JsonProperty("date") + @get:JsonProperty("date") + public val date: Instant? = null, + @param:JsonProperty("extra_first_attr") + @get:JsonProperty("extra_first_attr") + public val extraFirstAttr: List? = null, +) diff --git a/src/test/resources/examples/instantDateTime/models/Models.kt b/src/test/resources/examples/instantDateTime/models/Models.kt deleted file mode 100644 index 63cdf71f..00000000 --- a/src/test/resources/examples/instantDateTime/models/Models.kt +++ /dev/null @@ -1,26 +0,0 @@ -package examples.instantDateTime.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import java.time.Instant -import javax.validation.Valid -import javax.validation.constraints.NotNull -import javax.validation.constraints.Size -import kotlin.collections.List - -public data class FirstModel( - @param:JsonProperty("date") - @get:JsonProperty("date") - public val date: Instant? = null, - @param:JsonProperty("extra_first_attr") - @get:JsonProperty("extra_first_attr") - public val extraFirstAttr: List? = null, -) - -public data class QueryResult( - @param:JsonProperty("items") - @get:JsonProperty("items") - @get:NotNull - @get:Size(min = 0) - @get:Valid - public val items: List, -) diff --git a/src/test/resources/examples/instantDateTime/models/QueryResult.kt b/src/test/resources/examples/instantDateTime/models/QueryResult.kt new file mode 100644 index 00000000..60cac76e --- /dev/null +++ b/src/test/resources/examples/instantDateTime/models/QueryResult.kt @@ -0,0 +1,16 @@ +package examples.instantDateTime.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import javax.validation.constraints.NotNull +import javax.validation.constraints.Size +import kotlin.collections.List + +public data class QueryResult( + @param:JsonProperty("items") + @get:JsonProperty("items") + @get:NotNull + @get:Size(min = 0) + @get:Valid + public val items: List, +) diff --git a/src/test/resources/examples/mapExamples/models/BasicObject.kt b/src/test/resources/examples/mapExamples/models/BasicObject.kt new file mode 100644 index 00000000..767d5fa1 --- /dev/null +++ b/src/test/resources/examples/mapExamples/models/BasicObject.kt @@ -0,0 +1,10 @@ +package examples.mapExamples.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class BasicObject( + @param:JsonProperty("one") + @get:JsonProperty("one") + public val one: String? = null, +) diff --git a/src/test/resources/examples/mapExamples/models/ComplexObjectWithMapsOfMaps.kt b/src/test/resources/examples/mapExamples/models/ComplexObjectWithMapsOfMaps.kt new file mode 100644 index 00000000..2ab8f57c --- /dev/null +++ b/src/test/resources/examples/mapExamples/models/ComplexObjectWithMapsOfMaps.kt @@ -0,0 +1,18 @@ +package examples.mapExamples.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import kotlin.String +import kotlin.collections.List +import kotlin.collections.Map + +public data class ComplexObjectWithMapsOfMaps( + @param:JsonProperty("list-others") + @get:JsonProperty("list-others") + @get:Valid + public val listOthers: List? = null, + @param:JsonProperty("map-of-maps") + @get:JsonProperty("map-of-maps") + @get:Valid + public val mapOfMaps: Map?>? = null, +) diff --git a/src/test/resources/examples/mapExamples/models/ComplexObjectWithRefTypedMap.kt b/src/test/resources/examples/mapExamples/models/ComplexObjectWithRefTypedMap.kt new file mode 100644 index 00000000..82b55115 --- /dev/null +++ b/src/test/resources/examples/mapExamples/models/ComplexObjectWithRefTypedMap.kt @@ -0,0 +1,29 @@ +package examples.mapExamples.models + +import com.fasterxml.jackson.`annotation`.JsonAnyGetter +import com.fasterxml.jackson.`annotation`.JsonAnySetter +import com.fasterxml.jackson.`annotation`.JsonIgnore +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.Int +import kotlin.String +import kotlin.collections.Map +import kotlin.collections.MutableMap + +public data class ComplexObjectWithRefTypedMap( + @param:JsonProperty("text") + @get:JsonProperty("text") + public val text: String? = null, + @param:JsonProperty("code") + @get:JsonProperty("code") + public val code: Int? = null, + @get:JsonIgnore + public val properties: MutableMap = mutableMapOf(), +) { + @JsonAnyGetter + public fun `get`(): Map = properties + + @JsonAnySetter + public fun `set`(name: String, `value`: SomeRef?) { + properties[name] = value + } +} diff --git a/src/test/resources/examples/mapExamples/models/ComplexObjectWithTypedMap.kt b/src/test/resources/examples/mapExamples/models/ComplexObjectWithTypedMap.kt new file mode 100644 index 00000000..c0b208fa --- /dev/null +++ b/src/test/resources/examples/mapExamples/models/ComplexObjectWithTypedMap.kt @@ -0,0 +1,29 @@ +package examples.mapExamples.models + +import com.fasterxml.jackson.`annotation`.JsonAnyGetter +import com.fasterxml.jackson.`annotation`.JsonAnySetter +import com.fasterxml.jackson.`annotation`.JsonIgnore +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.Int +import kotlin.String +import kotlin.collections.Map +import kotlin.collections.MutableMap + +public data class ComplexObjectWithTypedMap( + @param:JsonProperty("text") + @get:JsonProperty("text") + public val text: String? = null, + @param:JsonProperty("code") + @get:JsonProperty("code") + public val code: Int? = null, + @get:JsonIgnore + public val properties: MutableMap = mutableMapOf(), +) { + @JsonAnyGetter + public fun `get`(): Map = properties + + @JsonAnySetter + public fun `set`(name: String, `value`: ComplexObjectWithTypedMapValue?) { + properties[name] = value + } +} diff --git a/src/test/resources/examples/mapExamples/models/ComplexObjectWithTypedMapValue.kt b/src/test/resources/examples/mapExamples/models/ComplexObjectWithTypedMapValue.kt new file mode 100644 index 00000000..e84733d1 --- /dev/null +++ b/src/test/resources/examples/mapExamples/models/ComplexObjectWithTypedMapValue.kt @@ -0,0 +1,14 @@ +package examples.mapExamples.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.Int +import kotlin.String + +public data class ComplexObjectWithTypedMapValue( + @param:JsonProperty("other_text") + @get:JsonProperty("other_text") + public val otherText: String? = null, + @param:JsonProperty("other_number") + @get:JsonProperty("other_number") + public val otherNumber: Int? = null, +) diff --git a/src/test/resources/examples/mapExamples/models/ComplexObjectWithUntypedMap.kt b/src/test/resources/examples/mapExamples/models/ComplexObjectWithUntypedMap.kt new file mode 100644 index 00000000..4e9623e9 --- /dev/null +++ b/src/test/resources/examples/mapExamples/models/ComplexObjectWithUntypedMap.kt @@ -0,0 +1,30 @@ +package examples.mapExamples.models + +import com.fasterxml.jackson.`annotation`.JsonAnyGetter +import com.fasterxml.jackson.`annotation`.JsonAnySetter +import com.fasterxml.jackson.`annotation`.JsonIgnore +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.Any +import kotlin.Int +import kotlin.String +import kotlin.collections.Map +import kotlin.collections.MutableMap + +public data class ComplexObjectWithUntypedMap( + @param:JsonProperty("text") + @get:JsonProperty("text") + public val text: String? = null, + @param:JsonProperty("code") + @get:JsonProperty("code") + public val code: Int? = null, + @get:JsonIgnore + public val properties: MutableMap = mutableMapOf(), +) { + @JsonAnyGetter + public fun `get`(): Map = properties + + @JsonAnySetter + public fun `set`(name: String, `value`: Any?) { + properties[name] = value + } +} diff --git a/src/test/resources/examples/mapExamples/models/ExternalObjectFour.kt b/src/test/resources/examples/mapExamples/models/ExternalObjectFour.kt new file mode 100644 index 00000000..5b8963a8 --- /dev/null +++ b/src/test/resources/examples/mapExamples/models/ExternalObjectFour.kt @@ -0,0 +1,10 @@ +package examples.mapExamples.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class ExternalObjectFour( + @param:JsonProperty("blah") + @get:JsonProperty("blah") + public val blah: String? = null, +) diff --git a/src/test/resources/examples/mapExamples/models/InlinedComplexObjectWithTypedMapValue.kt b/src/test/resources/examples/mapExamples/models/InlinedComplexObjectWithTypedMapValue.kt new file mode 100644 index 00000000..ec7ca48e --- /dev/null +++ b/src/test/resources/examples/mapExamples/models/InlinedComplexObjectWithTypedMapValue.kt @@ -0,0 +1,14 @@ +package examples.mapExamples.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.Int +import kotlin.String + +public data class InlinedComplexObjectWithTypedMapValue( + @param:JsonProperty("other_text") + @get:JsonProperty("other_text") + public val otherText: String? = null, + @param:JsonProperty("other_number") + @get:JsonProperty("other_number") + public val otherNumber: Int? = null, +) diff --git a/src/test/resources/examples/mapExamples/models/InlinedTypedObjectMapValue.kt b/src/test/resources/examples/mapExamples/models/InlinedTypedObjectMapValue.kt new file mode 100644 index 00000000..76232107 --- /dev/null +++ b/src/test/resources/examples/mapExamples/models/InlinedTypedObjectMapValue.kt @@ -0,0 +1,14 @@ +package examples.mapExamples.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.Int +import kotlin.String + +public data class InlinedTypedObjectMapValue( + @param:JsonProperty("code") + @get:JsonProperty("code") + public val code: Int? = null, + @param:JsonProperty("text") + @get:JsonProperty("text") + public val text: String? = null, +) diff --git a/src/test/resources/examples/mapExamples/models/MapHolder.kt b/src/test/resources/examples/mapExamples/models/MapHolder.kt new file mode 100644 index 00000000..213ccc23 --- /dev/null +++ b/src/test/resources/examples/mapExamples/models/MapHolder.kt @@ -0,0 +1,67 @@ +package examples.mapExamples.models + +import com.fasterxml.jackson.`annotation`.JsonAnyGetter +import com.fasterxml.jackson.`annotation`.JsonAnySetter +import com.fasterxml.jackson.`annotation`.JsonIgnore +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import kotlin.Any +import kotlin.String +import kotlin.collections.Map +import kotlin.collections.MutableMap + +public data class MapHolder( + @param:JsonProperty("wild_card") + @get:JsonProperty("wild_card") + public val wildCard: Map? = null, + @param:JsonProperty("string_map") + @get:JsonProperty("string_map") + public val stringMap: Map? = null, + @param:JsonProperty("typed_object_map") + @get:JsonProperty("typed_object_map") + @get:Valid + public val typedObjectMap: Map? = null, + @param:JsonProperty("object_map") + @get:JsonProperty("object_map") + public val objectMap: Map?>? = null, + @param:JsonProperty("inlined_string_map") + @get:JsonProperty("inlined_string_map") + public val inlinedStringMap: Map? = null, + @param:JsonProperty("inlined_object_map") + @get:JsonProperty("inlined_object_map") + public val inlinedObjectMap: Map?>? = null, + @param:JsonProperty("inlined_unknown_map") + @get:JsonProperty("inlined_unknown_map") + public val inlinedUnknownMap: Map? = null, + @param:JsonProperty("inlined_typed_object_map") + @get:JsonProperty("inlined_typed_object_map") + @get:Valid + public val inlinedTypedObjectMap: Map? = null, + @param:JsonProperty("complex_object_with_untyped_map") + @get:JsonProperty("complex_object_with_untyped_map") + @get:Valid + public val complexObjectWithUntypedMap: ComplexObjectWithUntypedMap? = null, + @param:JsonProperty("complex_object_with_typed_map") + @get:JsonProperty("complex_object_with_typed_map") + @get:Valid + public val complexObjectWithTypedMap: ComplexObjectWithTypedMap? = null, + @param:JsonProperty("inlined_complex_object_with_untyped_map") + @get:JsonProperty("inlined_complex_object_with_untyped_map") + @get:Valid + public val inlinedComplexObjectWithUntypedMap: MapHolderInlinedComplexObjectWithUntypedMap? = + null, + @param:JsonProperty("inlined_complex_object_with_typed_map") + @get:JsonProperty("inlined_complex_object_with_typed_map") + @get:Valid + public val inlinedComplexObjectWithTypedMap: MapHolderInlinedComplexObjectWithTypedMap? = null, + @get:JsonIgnore + public val properties: MutableMap?> = mutableMapOf(), +) { + @JsonAnyGetter + public fun `get`(): Map?> = properties + + @JsonAnySetter + public fun `set`(name: String, `value`: Map?) { + properties[name] = value + } +} diff --git a/src/test/resources/examples/mapExamples/models/MapHolderInlinedComplexObjectWithTypedMap.kt b/src/test/resources/examples/mapExamples/models/MapHolderInlinedComplexObjectWithTypedMap.kt new file mode 100644 index 00000000..5f9826d0 --- /dev/null +++ b/src/test/resources/examples/mapExamples/models/MapHolderInlinedComplexObjectWithTypedMap.kt @@ -0,0 +1,30 @@ +package examples.mapExamples.models + +import com.fasterxml.jackson.`annotation`.JsonAnyGetter +import com.fasterxml.jackson.`annotation`.JsonAnySetter +import com.fasterxml.jackson.`annotation`.JsonIgnore +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.Int +import kotlin.String +import kotlin.collections.Map +import kotlin.collections.MutableMap + +public data class MapHolderInlinedComplexObjectWithTypedMap( + @param:JsonProperty("text") + @get:JsonProperty("text") + public val text: String? = null, + @param:JsonProperty("code") + @get:JsonProperty("code") + public val code: Int? = null, + @get:JsonIgnore + public val properties: MutableMap = + mutableMapOf(), +) { + @JsonAnyGetter + public fun `get`(): Map = properties + + @JsonAnySetter + public fun `set`(name: String, `value`: InlinedComplexObjectWithTypedMapValue?) { + properties[name] = value + } +} diff --git a/src/test/resources/examples/mapExamples/models/MapHolderInlinedComplexObjectWithUntypedMap.kt b/src/test/resources/examples/mapExamples/models/MapHolderInlinedComplexObjectWithUntypedMap.kt new file mode 100644 index 00000000..86dea060 --- /dev/null +++ b/src/test/resources/examples/mapExamples/models/MapHolderInlinedComplexObjectWithUntypedMap.kt @@ -0,0 +1,30 @@ +package examples.mapExamples.models + +import com.fasterxml.jackson.`annotation`.JsonAnyGetter +import com.fasterxml.jackson.`annotation`.JsonAnySetter +import com.fasterxml.jackson.`annotation`.JsonIgnore +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.Any +import kotlin.Int +import kotlin.String +import kotlin.collections.Map +import kotlin.collections.MutableMap + +public data class MapHolderInlinedComplexObjectWithUntypedMap( + @param:JsonProperty("text") + @get:JsonProperty("text") + public val text: String? = null, + @param:JsonProperty("code") + @get:JsonProperty("code") + public val code: Int? = null, + @get:JsonIgnore + public val properties: MutableMap = mutableMapOf(), +) { + @JsonAnyGetter + public fun `get`(): Map = properties + + @JsonAnySetter + public fun `set`(name: String, `value`: Any?) { + properties[name] = value + } +} diff --git a/src/test/resources/examples/mapExamples/models/Models.kt b/src/test/resources/examples/mapExamples/models/Models.kt deleted file mode 100644 index 14ad6e5b..00000000 --- a/src/test/resources/examples/mapExamples/models/Models.kt +++ /dev/null @@ -1,233 +0,0 @@ -package examples.mapExamples.models - -import com.fasterxml.jackson.`annotation`.JsonAnyGetter -import com.fasterxml.jackson.`annotation`.JsonAnySetter -import com.fasterxml.jackson.`annotation`.JsonIgnore -import com.fasterxml.jackson.`annotation`.JsonProperty -import javax.validation.Valid -import kotlin.Any -import kotlin.Int -import kotlin.String -import kotlin.collections.List -import kotlin.collections.Map -import kotlin.collections.MutableMap - -public data class BasicObject( - @param:JsonProperty("one") - @get:JsonProperty("one") - public val one: String? = null, -) - -public data class ComplexObjectWithMapsOfMaps( - @param:JsonProperty("list-others") - @get:JsonProperty("list-others") - @get:Valid - public val listOthers: List? = null, - @param:JsonProperty("map-of-maps") - @get:JsonProperty("map-of-maps") - @get:Valid - public val mapOfMaps: Map?>? = null, -) - -public data class ComplexObjectWithRefTypedMap( - @param:JsonProperty("text") - @get:JsonProperty("text") - public val text: String? = null, - @param:JsonProperty("code") - @get:JsonProperty("code") - public val code: Int? = null, - @get:JsonIgnore - public val properties: MutableMap = mutableMapOf(), -) { - @JsonAnyGetter - public fun `get`(): Map = properties - - @JsonAnySetter - public fun `set`(name: String, `value`: SomeRef?) { - properties[name] = value - } -} - -public data class ComplexObjectWithTypedMap( - @param:JsonProperty("text") - @get:JsonProperty("text") - public val text: String? = null, - @param:JsonProperty("code") - @get:JsonProperty("code") - public val code: Int? = null, - @get:JsonIgnore - public val properties: MutableMap = mutableMapOf(), -) { - @JsonAnyGetter - public fun `get`(): Map = properties - - @JsonAnySetter - public fun `set`(name: String, `value`: ComplexObjectWithTypedMapValue?) { - properties[name] = value - } -} - -public data class ComplexObjectWithTypedMapValue( - @param:JsonProperty("other_text") - @get:JsonProperty("other_text") - public val otherText: String? = null, - @param:JsonProperty("other_number") - @get:JsonProperty("other_number") - public val otherNumber: Int? = null, -) - -public data class ComplexObjectWithUntypedMap( - @param:JsonProperty("text") - @get:JsonProperty("text") - public val text: String? = null, - @param:JsonProperty("code") - @get:JsonProperty("code") - public val code: Int? = null, - @get:JsonIgnore - public val properties: MutableMap = mutableMapOf(), -) { - @JsonAnyGetter - public fun `get`(): Map = properties - - @JsonAnySetter - public fun `set`(name: String, `value`: Any?) { - properties[name] = value - } -} - -public data class ExternalObjectFour( - @param:JsonProperty("blah") - @get:JsonProperty("blah") - public val blah: String? = null, -) - -public data class InlinedComplexObjectWithTypedMapValue( - @param:JsonProperty("other_text") - @get:JsonProperty("other_text") - public val otherText: String? = null, - @param:JsonProperty("other_number") - @get:JsonProperty("other_number") - public val otherNumber: Int? = null, -) - -public data class InlinedTypedObjectMapValue( - @param:JsonProperty("code") - @get:JsonProperty("code") - public val code: Int? = null, - @param:JsonProperty("text") - @get:JsonProperty("text") - public val text: String? = null, -) - -public data class MapHolder( - @param:JsonProperty("wild_card") - @get:JsonProperty("wild_card") - public val wildCard: Map? = null, - @param:JsonProperty("string_map") - @get:JsonProperty("string_map") - public val stringMap: Map? = null, - @param:JsonProperty("typed_object_map") - @get:JsonProperty("typed_object_map") - @get:Valid - public val typedObjectMap: Map? = null, - @param:JsonProperty("object_map") - @get:JsonProperty("object_map") - public val objectMap: Map?>? = null, - @param:JsonProperty("inlined_string_map") - @get:JsonProperty("inlined_string_map") - public val inlinedStringMap: Map? = null, - @param:JsonProperty("inlined_object_map") - @get:JsonProperty("inlined_object_map") - public val inlinedObjectMap: Map?>? = null, - @param:JsonProperty("inlined_unknown_map") - @get:JsonProperty("inlined_unknown_map") - public val inlinedUnknownMap: Map? = null, - @param:JsonProperty("inlined_typed_object_map") - @get:JsonProperty("inlined_typed_object_map") - @get:Valid - public val inlinedTypedObjectMap: Map? = null, - @param:JsonProperty("complex_object_with_untyped_map") - @get:JsonProperty("complex_object_with_untyped_map") - @get:Valid - public val complexObjectWithUntypedMap: ComplexObjectWithUntypedMap? = null, - @param:JsonProperty("complex_object_with_typed_map") - @get:JsonProperty("complex_object_with_typed_map") - @get:Valid - public val complexObjectWithTypedMap: ComplexObjectWithTypedMap? = null, - @param:JsonProperty("inlined_complex_object_with_untyped_map") - @get:JsonProperty("inlined_complex_object_with_untyped_map") - @get:Valid - public val inlinedComplexObjectWithUntypedMap: MapHolderInlinedComplexObjectWithUntypedMap? = - null, - @param:JsonProperty("inlined_complex_object_with_typed_map") - @get:JsonProperty("inlined_complex_object_with_typed_map") - @get:Valid - public val inlinedComplexObjectWithTypedMap: MapHolderInlinedComplexObjectWithTypedMap? = null, - @get:JsonIgnore - public val properties: MutableMap?> = mutableMapOf(), -) { - @JsonAnyGetter - public fun `get`(): Map?> = properties - - @JsonAnySetter - public fun `set`(name: String, `value`: Map?) { - properties[name] = value - } -} - -public data class MapHolderInlinedComplexObjectWithTypedMap( - @param:JsonProperty("text") - @get:JsonProperty("text") - public val text: String? = null, - @param:JsonProperty("code") - @get:JsonProperty("code") - public val code: Int? = null, - @get:JsonIgnore - public val properties: MutableMap = - mutableMapOf(), -) { - @JsonAnyGetter - public fun `get`(): Map = properties - - @JsonAnySetter - public fun `set`(name: String, `value`: InlinedComplexObjectWithTypedMapValue?) { - properties[name] = value - } -} - -public data class MapHolderInlinedComplexObjectWithUntypedMap( - @param:JsonProperty("text") - @get:JsonProperty("text") - public val text: String? = null, - @param:JsonProperty("code") - @get:JsonProperty("code") - public val code: Int? = null, - @get:JsonIgnore - public val properties: MutableMap = mutableMapOf(), -) { - @JsonAnyGetter - public fun `get`(): Map = properties - - @JsonAnySetter - public fun `set`(name: String, `value`: Any?) { - properties[name] = value - } -} - -public data class SomeRef( - @param:JsonProperty("other_text") - @get:JsonProperty("other_text") - public val otherText: String? = null, - @param:JsonProperty("other_number") - @get:JsonProperty("other_number") - public val otherNumber: Int? = null, -) - -public data class TypedObjectMapValue( - @param:JsonProperty("code") - @get:JsonProperty("code") - public val code: Int? = null, - @param:JsonProperty("text") - @get:JsonProperty("text") - public val text: String? = null, -) diff --git a/src/test/resources/examples/mapExamples/models/SomeRef.kt b/src/test/resources/examples/mapExamples/models/SomeRef.kt new file mode 100644 index 00000000..92034c22 --- /dev/null +++ b/src/test/resources/examples/mapExamples/models/SomeRef.kt @@ -0,0 +1,14 @@ +package examples.mapExamples.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.Int +import kotlin.String + +public data class SomeRef( + @param:JsonProperty("other_text") + @get:JsonProperty("other_text") + public val otherText: String? = null, + @param:JsonProperty("other_number") + @get:JsonProperty("other_number") + public val otherNumber: Int? = null, +) diff --git a/src/test/resources/examples/mapExamples/models/TypedObjectMapValue.kt b/src/test/resources/examples/mapExamples/models/TypedObjectMapValue.kt new file mode 100644 index 00000000..920f4e87 --- /dev/null +++ b/src/test/resources/examples/mapExamples/models/TypedObjectMapValue.kt @@ -0,0 +1,14 @@ +package examples.mapExamples.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.Int +import kotlin.String + +public data class TypedObjectMapValue( + @param:JsonProperty("code") + @get:JsonProperty("code") + public val code: Int? = null, + @param:JsonProperty("text") + @get:JsonProperty("text") + public val text: String? = null, +) diff --git a/src/test/resources/examples/mapExamplesNonNullValues/models/Container.kt b/src/test/resources/examples/mapExamplesNonNullValues/models/Container.kt new file mode 100644 index 00000000..3433eebe --- /dev/null +++ b/src/test/resources/examples/mapExamplesNonNullValues/models/Container.kt @@ -0,0 +1,24 @@ +package examples.mapExamplesNonNullValues.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import javax.validation.constraints.NotNull +import kotlin.Any +import kotlin.String +import kotlin.collections.Map + +public data class Container( + @param:JsonProperty("string_map") + @get:JsonProperty("string_map") + @get:NotNull + public val stringMap: Map, + @param:JsonProperty("typed_object_map") + @get:JsonProperty("typed_object_map") + @get:NotNull + @get:Valid + public val typedObjectMap: Map, + @param:JsonProperty("object_map") + @get:JsonProperty("object_map") + @get:NotNull + public val objectMap: Map>, +) diff --git a/src/test/resources/examples/mapExamplesNonNullValues/models/Models.kt b/src/test/resources/examples/mapExamplesNonNullValues/models/Models.kt deleted file mode 100644 index 2ea94b49..00000000 --- a/src/test/resources/examples/mapExamplesNonNullValues/models/Models.kt +++ /dev/null @@ -1,34 +0,0 @@ -package examples.mapExamplesNonNullValues.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import javax.validation.Valid -import javax.validation.constraints.NotNull -import kotlin.Any -import kotlin.Int -import kotlin.String -import kotlin.collections.Map - -public data class Container( - @param:JsonProperty("string_map") - @get:JsonProperty("string_map") - @get:NotNull - public val stringMap: Map, - @param:JsonProperty("typed_object_map") - @get:JsonProperty("typed_object_map") - @get:NotNull - @get:Valid - public val typedObjectMap: Map, - @param:JsonProperty("object_map") - @get:JsonProperty("object_map") - @get:NotNull - public val objectMap: Map>, -) - -public data class TypedObjectMapValue( - @param:JsonProperty("code") - @get:JsonProperty("code") - public val code: Int? = null, - @param:JsonProperty("text") - @get:JsonProperty("text") - public val text: String? = null, -) diff --git a/src/test/resources/examples/mapExamplesNonNullValues/models/TypedObjectMapValue.kt b/src/test/resources/examples/mapExamplesNonNullValues/models/TypedObjectMapValue.kt new file mode 100644 index 00000000..c4d48702 --- /dev/null +++ b/src/test/resources/examples/mapExamplesNonNullValues/models/TypedObjectMapValue.kt @@ -0,0 +1,14 @@ +package examples.mapExamplesNonNullValues.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.Int +import kotlin.String + +public data class TypedObjectMapValue( + @param:JsonProperty("code") + @get:JsonProperty("code") + public val code: Int? = null, + @param:JsonProperty("text") + @get:JsonProperty("text") + public val text: String? = null, +) diff --git a/src/test/resources/examples/mixingCamelSnakeLispCase/models/MixingCamelSnakeLispCase.kt b/src/test/resources/examples/mixingCamelSnakeLispCase/models/MixingCamelSnakeLispCase.kt new file mode 100644 index 00000000..ab21df13 --- /dev/null +++ b/src/test/resources/examples/mixingCamelSnakeLispCase/models/MixingCamelSnakeLispCase.kt @@ -0,0 +1,19 @@ +package examples.mixingCamelSnakeLispCase.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class MixingCamelSnakeLispCase( + @param:JsonProperty("camelCase") + @get:JsonProperty("camelCase") + public val camelCase: String? = null, + @param:JsonProperty("snake_case") + @get:JsonProperty("snake_case") + public val snakeCase: String? = null, + @param:JsonProperty("lisp-case") + @get:JsonProperty("lisp-case") + public val lispCase: String? = null, + @param:JsonProperty("PascalCase") + @get:JsonProperty("PascalCase") + public val pascalCase: String? = null, +) diff --git a/src/test/resources/examples/mixingCamelSnakeLispCase/models/Models.kt b/src/test/resources/examples/mixingCamelSnakeLispCase/models/Models.kt deleted file mode 100644 index f18de514..00000000 --- a/src/test/resources/examples/mixingCamelSnakeLispCase/models/Models.kt +++ /dev/null @@ -1,19 +0,0 @@ -package examples.mixingCamelSnakeLispCase.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import kotlin.String - -public data class MixingCamelSnakeLispCase( - @param:JsonProperty("camelCase") - @get:JsonProperty("camelCase") - public val camelCase: String? = null, - @param:JsonProperty("snake_case") - @get:JsonProperty("snake_case") - public val snakeCase: String? = null, - @param:JsonProperty("lisp-case") - @get:JsonProperty("lisp-case") - public val lispCase: String? = null, - @param:JsonProperty("PascalCase") - @get:JsonProperty("PascalCase") - public val pascalCase: String? = null, -) diff --git a/src/test/resources/examples/nestedPolymorphicModels/models/CommonObject.kt b/src/test/resources/examples/nestedPolymorphicModels/models/CommonObject.kt new file mode 100644 index 00000000..ba8c1930 --- /dev/null +++ b/src/test/resources/examples/nestedPolymorphicModels/models/CommonObject.kt @@ -0,0 +1,16 @@ +package examples.nestedPolymorphicModels.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.String + +public data class CommonObject( + @param:JsonProperty("filed1") + @get:JsonProperty("filed1") + @get:NotNull + public val filed1: String, + @param:JsonProperty("field2") + @get:JsonProperty("field2") + @get:NotNull + public val field2: String, +) diff --git a/src/test/resources/examples/nestedPolymorphicModels/models/FirstLevelChild.kt b/src/test/resources/examples/nestedPolymorphicModels/models/FirstLevelChild.kt new file mode 100644 index 00000000..115f55ac --- /dev/null +++ b/src/test/resources/examples/nestedPolymorphicModels/models/FirstLevelChild.kt @@ -0,0 +1,104 @@ +package examples.nestedPolymorphicModels.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import com.fasterxml.jackson.`annotation`.JsonSubTypes +import com.fasterxml.jackson.`annotation`.JsonTypeInfo +import javax.validation.constraints.NotNull +import kotlin.Boolean +import kotlin.Int +import kotlin.String + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "firstLevelDiscriminator", + visible = true, +) +@JsonSubTypes(JsonSubTypes.Type(value = SecondLevelChild1::class, name = + "secondLevelChild1"),JsonSubTypes.Type(value = SecondLevelChild2::class, name = + "secondLevelChild2")) +public sealed class FirstLevelChild( + @param:JsonProperty("rootField1") + @get:JsonProperty("rootField1") + @get:NotNull + override val rootField1: String, + @param:JsonProperty("rootField2") + @get:JsonProperty("rootField2") + override val rootField2: Boolean? = null, + public open val firstLevelField1: String, + public open val firstLevelField2: Int? = null, + @get:JsonProperty("rootDiscriminator") + @get:NotNull + @param:JsonProperty("rootDiscriminator") + override val rootDiscriminator: RootDiscriminator = RootDiscriminator.FIRST_LEVEL_CHILD, +) : RootType(rootField1, rootField2) { + public abstract val firstLevelDiscriminator: FirstLevelDiscriminator +} + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "secondLevelDiscriminator", + visible = true, +) +@JsonSubTypes(JsonSubTypes.Type(value = ThirdLevelChild11::class, name = + "thirdLevelChild1"),JsonSubTypes.Type(value = ThirdLevelChild12::class, name = + "thirdLevelChild2")) +public sealed class SecondLevelChild1( + @param:JsonProperty("rootField1") + @get:JsonProperty("rootField1") + @get:NotNull + override val rootField1: String, + @param:JsonProperty("rootField2") + @get:JsonProperty("rootField2") + override val rootField2: Boolean? = null, + @param:JsonProperty("firstLevelField1") + @get:JsonProperty("firstLevelField1") + @get:NotNull + override val firstLevelField1: String, + @param:JsonProperty("firstLevelField2") + @get:JsonProperty("firstLevelField2") + override val firstLevelField2: Int? = null, + public open val metadata: SecondLevelMetadata, + @get:JsonProperty("firstLevelDiscriminator") + @get:NotNull + @param:JsonProperty("firstLevelDiscriminator") + override val firstLevelDiscriminator: FirstLevelDiscriminator = + FirstLevelDiscriminator.SECOND_LEVEL_CHILD1, +) : FirstLevelChild(rootField1, rootField2, firstLevelField1, firstLevelField2) { + public abstract val secondLevelDiscriminator: SecondLevelDiscriminator +} + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "secondLevelDiscriminator", + visible = true, +) +@JsonSubTypes(JsonSubTypes.Type(value = ThirdLevelChild21::class, name = + "thirdLevelChild1"),JsonSubTypes.Type(value = ThirdLevelChild22::class, name = + "thirdLevelChild2")) +public sealed class SecondLevelChild2( + @param:JsonProperty("rootField1") + @get:JsonProperty("rootField1") + @get:NotNull + override val rootField1: String, + @param:JsonProperty("rootField2") + @get:JsonProperty("rootField2") + override val rootField2: Boolean? = null, + @param:JsonProperty("firstLevelField1") + @get:JsonProperty("firstLevelField1") + @get:NotNull + override val firstLevelField1: String, + @param:JsonProperty("firstLevelField2") + @get:JsonProperty("firstLevelField2") + override val firstLevelField2: Int? = null, + public open val metadata: SecondLevelMetadata, + @get:JsonProperty("firstLevelDiscriminator") + @get:NotNull + @param:JsonProperty("firstLevelDiscriminator") + override val firstLevelDiscriminator: FirstLevelDiscriminator = + FirstLevelDiscriminator.SECOND_LEVEL_CHILD2, +) : FirstLevelChild(rootField1, rootField2, firstLevelField1, firstLevelField2) { + public abstract val secondLevelDiscriminator: SecondLevelDiscriminator +} diff --git a/src/test/resources/examples/nestedPolymorphicModels/models/FirstLevelDiscriminator.kt b/src/test/resources/examples/nestedPolymorphicModels/models/FirstLevelDiscriminator.kt new file mode 100644 index 00000000..f350efd8 --- /dev/null +++ b/src/test/resources/examples/nestedPolymorphicModels/models/FirstLevelDiscriminator.kt @@ -0,0 +1,21 @@ +package examples.nestedPolymorphicModels.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class FirstLevelDiscriminator( + @JsonValue + public val `value`: String, +) { + SECOND_LEVEL_CHILD1("secondLevelChild1"), + SECOND_LEVEL_CHILD2("secondLevelChild2"), + ; + + public companion object { + private val mapping: Map = + values().associateBy(FirstLevelDiscriminator::value) + + public fun fromValue(`value`: String): FirstLevelDiscriminator? = mapping[value] + } +} diff --git a/src/test/resources/examples/nestedPolymorphicModels/models/Models.kt b/src/test/resources/examples/nestedPolymorphicModels/models/Models.kt deleted file mode 100644 index e75d6f6a..00000000 --- a/src/test/resources/examples/nestedPolymorphicModels/models/Models.kt +++ /dev/null @@ -1,338 +0,0 @@ -package examples.nestedPolymorphicModels.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import com.fasterxml.jackson.`annotation`.JsonSubTypes -import com.fasterxml.jackson.`annotation`.JsonTypeInfo -import com.fasterxml.jackson.`annotation`.JsonValue -import javax.validation.Valid -import javax.validation.constraints.NotNull -import kotlin.Boolean -import kotlin.Int -import kotlin.String -import kotlin.collections.Map - -public data class CommonObject( - @param:JsonProperty("filed1") - @get:JsonProperty("filed1") - @get:NotNull - public val filed1: String, - @param:JsonProperty("field2") - @get:JsonProperty("field2") - @get:NotNull - public val field2: String, -) - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "firstLevelDiscriminator", - visible = true, -) -@JsonSubTypes( - JsonSubTypes.Type( - value = SecondLevelChild1::class, - name = - "secondLevelChild1", - ), - JsonSubTypes.Type( - value = SecondLevelChild2::class, - name = - "secondLevelChild2", - ), -) -public sealed class FirstLevelChild( - @param:JsonProperty("rootField1") - @get:JsonProperty("rootField1") - @get:NotNull - override val rootField1: String, - @param:JsonProperty("rootField2") - @get:JsonProperty("rootField2") - override val rootField2: Boolean? = null, - public open val firstLevelField1: String, - public open val firstLevelField2: Int? = null, - @get:JsonProperty("rootDiscriminator") - @get:NotNull - @param:JsonProperty("rootDiscriminator") - override val rootDiscriminator: RootDiscriminator = RootDiscriminator.FIRST_LEVEL_CHILD, -) : RootType(rootField1, rootField2) { - public abstract val firstLevelDiscriminator: FirstLevelDiscriminator -} - -public enum class FirstLevelDiscriminator( - @JsonValue - public val `value`: String, -) { - SECOND_LEVEL_CHILD1("secondLevelChild1"), - SECOND_LEVEL_CHILD2("secondLevelChild2"), - ; - - public companion object { - private val mapping: Map = - values().associateBy(FirstLevelDiscriminator::value) - - public fun fromValue(`value`: String): FirstLevelDiscriminator? = mapping[value] - } -} - -public enum class RootDiscriminator( - @JsonValue - public val `value`: String, -) { - FIRST_LEVEL_CHILD("firstLevelChild"), - ; - - public companion object { - private val mapping: Map = - values().associateBy(RootDiscriminator::value) - - public fun fromValue(`value`: String): RootDiscriminator? = mapping[value] - } -} - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "rootDiscriminator", - visible = true, -) -@JsonSubTypes(JsonSubTypes.Type(value = FirstLevelChild::class, name = "firstLevelChild")) -public sealed class RootType( - public open val rootField1: String, - public open val rootField2: Boolean? = null, -) { - public abstract val rootDiscriminator: RootDiscriminator -} - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "secondLevelDiscriminator", - visible = true, -) -@JsonSubTypes( - JsonSubTypes.Type( - value = ThirdLevelChild11::class, - name = - "thirdLevelChild1", - ), - JsonSubTypes.Type( - value = ThirdLevelChild12::class, - name = - "thirdLevelChild2", - ), -) -public sealed class SecondLevelChild1( - @param:JsonProperty("rootField1") - @get:JsonProperty("rootField1") - @get:NotNull - override val rootField1: String, - @param:JsonProperty("rootField2") - @get:JsonProperty("rootField2") - override val rootField2: Boolean? = null, - @param:JsonProperty("firstLevelField1") - @get:JsonProperty("firstLevelField1") - @get:NotNull - override val firstLevelField1: String, - @param:JsonProperty("firstLevelField2") - @get:JsonProperty("firstLevelField2") - override val firstLevelField2: Int? = null, - public open val metadata: SecondLevelMetadata, - @get:JsonProperty("firstLevelDiscriminator") - @get:NotNull - @param:JsonProperty("firstLevelDiscriminator") - override val firstLevelDiscriminator: FirstLevelDiscriminator = - FirstLevelDiscriminator.SECOND_LEVEL_CHILD1, -) : FirstLevelChild(rootField1, rootField2, firstLevelField1, firstLevelField2) { - public abstract val secondLevelDiscriminator: SecondLevelDiscriminator -} - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "secondLevelDiscriminator", - visible = true, -) -@JsonSubTypes( - JsonSubTypes.Type( - value = ThirdLevelChild21::class, - name = - "thirdLevelChild1", - ), - JsonSubTypes.Type( - value = ThirdLevelChild22::class, - name = - "thirdLevelChild2", - ), -) -public sealed class SecondLevelChild2( - @param:JsonProperty("rootField1") - @get:JsonProperty("rootField1") - @get:NotNull - override val rootField1: String, - @param:JsonProperty("rootField2") - @get:JsonProperty("rootField2") - override val rootField2: Boolean? = null, - @param:JsonProperty("firstLevelField1") - @get:JsonProperty("firstLevelField1") - @get:NotNull - override val firstLevelField1: String, - @param:JsonProperty("firstLevelField2") - @get:JsonProperty("firstLevelField2") - override val firstLevelField2: Int? = null, - public open val metadata: SecondLevelMetadata, - @get:JsonProperty("firstLevelDiscriminator") - @get:NotNull - @param:JsonProperty("firstLevelDiscriminator") - override val firstLevelDiscriminator: FirstLevelDiscriminator = - FirstLevelDiscriminator.SECOND_LEVEL_CHILD2, -) : FirstLevelChild(rootField1, rootField2, firstLevelField1, firstLevelField2) { - public abstract val secondLevelDiscriminator: SecondLevelDiscriminator -} - -public enum class SecondLevelDiscriminator( - @JsonValue - public val `value`: String, -) { - THIRD_LEVEL_CHILD1("thirdLevelChild1"), - THIRD_LEVEL_CHILD2("thirdLevelChild2"), - ; - - public companion object { - private val mapping: Map = - values().associateBy(SecondLevelDiscriminator::value) - - public fun fromValue(`value`: String): SecondLevelDiscriminator? = mapping[value] - } -} - -public data class SecondLevelMetadata( - @param:JsonProperty("obj") - @get:JsonProperty("obj") - @get:NotNull - @get:Valid - public val obj: CommonObject, -) - -public data class ThirdLevelChild11( - @param:JsonProperty("rootField1") - @get:JsonProperty("rootField1") - @get:NotNull - override val rootField1: String, - @param:JsonProperty("rootField2") - @get:JsonProperty("rootField2") - override val rootField2: Boolean? = null, - @param:JsonProperty("firstLevelField1") - @get:JsonProperty("firstLevelField1") - @get:NotNull - override val firstLevelField1: String, - @param:JsonProperty("firstLevelField2") - @get:JsonProperty("firstLevelField2") - override val firstLevelField2: Int? = null, - @param:JsonProperty("metadata") - @get:JsonProperty("metadata") - @get:NotNull - @get:Valid - override val metadata: SecondLevelMetadata, - @param:JsonProperty("creationDate") - @get:JsonProperty("creationDate") - @get:NotNull - public val creationDate: Int, - @get:JsonProperty("secondLevelDiscriminator") - @get:NotNull - @param:JsonProperty("secondLevelDiscriminator") - override val secondLevelDiscriminator: SecondLevelDiscriminator = - SecondLevelDiscriminator.THIRD_LEVEL_CHILD1, -) : SecondLevelChild1(rootField1, rootField2, firstLevelField1, firstLevelField2, metadata) - -public data class ThirdLevelChild12( - @param:JsonProperty("rootField1") - @get:JsonProperty("rootField1") - @get:NotNull - override val rootField1: String, - @param:JsonProperty("rootField2") - @get:JsonProperty("rootField2") - override val rootField2: Boolean? = null, - @param:JsonProperty("firstLevelField1") - @get:JsonProperty("firstLevelField1") - @get:NotNull - override val firstLevelField1: String, - @param:JsonProperty("firstLevelField2") - @get:JsonProperty("firstLevelField2") - override val firstLevelField2: Int? = null, - @param:JsonProperty("metadata") - @get:JsonProperty("metadata") - @get:NotNull - @get:Valid - override val metadata: SecondLevelMetadata, - @param:JsonProperty("isDeleted") - @get:JsonProperty("isDeleted") - @get:NotNull - public val isDeleted: Boolean, - @get:JsonProperty("secondLevelDiscriminator") - @get:NotNull - @param:JsonProperty("secondLevelDiscriminator") - override val secondLevelDiscriminator: SecondLevelDiscriminator = - SecondLevelDiscriminator.THIRD_LEVEL_CHILD2, -) : SecondLevelChild1(rootField1, rootField2, firstLevelField1, firstLevelField2, metadata) - -public data class ThirdLevelChild21( - @param:JsonProperty("rootField1") - @get:JsonProperty("rootField1") - @get:NotNull - override val rootField1: String, - @param:JsonProperty("rootField2") - @get:JsonProperty("rootField2") - override val rootField2: Boolean? = null, - @param:JsonProperty("firstLevelField1") - @get:JsonProperty("firstLevelField1") - @get:NotNull - override val firstLevelField1: String, - @param:JsonProperty("firstLevelField2") - @get:JsonProperty("firstLevelField2") - override val firstLevelField2: Int? = null, - @param:JsonProperty("metadata") - @get:JsonProperty("metadata") - @get:NotNull - @get:Valid - override val metadata: SecondLevelMetadata, - @param:JsonProperty("creationDate") - @get:JsonProperty("creationDate") - @get:NotNull - public val creationDate: Int, - @get:JsonProperty("secondLevelDiscriminator") - @get:NotNull - @param:JsonProperty("secondLevelDiscriminator") - override val secondLevelDiscriminator: SecondLevelDiscriminator = - SecondLevelDiscriminator.THIRD_LEVEL_CHILD1, -) : SecondLevelChild2(rootField1, rootField2, firstLevelField1, firstLevelField2, metadata) - -public data class ThirdLevelChild22( - @param:JsonProperty("rootField1") - @get:JsonProperty("rootField1") - @get:NotNull - override val rootField1: String, - @param:JsonProperty("rootField2") - @get:JsonProperty("rootField2") - override val rootField2: Boolean? = null, - @param:JsonProperty("firstLevelField1") - @get:JsonProperty("firstLevelField1") - @get:NotNull - override val firstLevelField1: String, - @param:JsonProperty("firstLevelField2") - @get:JsonProperty("firstLevelField2") - override val firstLevelField2: Int? = null, - @param:JsonProperty("metadata") - @get:JsonProperty("metadata") - @get:NotNull - @get:Valid - override val metadata: SecondLevelMetadata, - @param:JsonProperty("isDeleted") - @get:JsonProperty("isDeleted") - @get:NotNull - public val isDeleted: Boolean, - @get:JsonProperty("secondLevelDiscriminator") - @get:NotNull - @param:JsonProperty("secondLevelDiscriminator") - override val secondLevelDiscriminator: SecondLevelDiscriminator = - SecondLevelDiscriminator.THIRD_LEVEL_CHILD2, -) : SecondLevelChild2(rootField1, rootField2, firstLevelField1, firstLevelField2, metadata) diff --git a/src/test/resources/examples/nestedPolymorphicModels/models/RootDiscriminator.kt b/src/test/resources/examples/nestedPolymorphicModels/models/RootDiscriminator.kt new file mode 100644 index 00000000..4bc7e209 --- /dev/null +++ b/src/test/resources/examples/nestedPolymorphicModels/models/RootDiscriminator.kt @@ -0,0 +1,20 @@ +package examples.nestedPolymorphicModels.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class RootDiscriminator( + @JsonValue + public val `value`: String, +) { + FIRST_LEVEL_CHILD("firstLevelChild"), + ; + + public companion object { + private val mapping: Map = + values().associateBy(RootDiscriminator::value) + + public fun fromValue(`value`: String): RootDiscriminator? = mapping[value] + } +} diff --git a/src/test/resources/examples/nestedPolymorphicModels/models/RootType.kt b/src/test/resources/examples/nestedPolymorphicModels/models/RootType.kt new file mode 100644 index 00000000..c8e8b39a --- /dev/null +++ b/src/test/resources/examples/nestedPolymorphicModels/models/RootType.kt @@ -0,0 +1,50 @@ +package examples.nestedPolymorphicModels.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import com.fasterxml.jackson.`annotation`.JsonSubTypes +import com.fasterxml.jackson.`annotation`.JsonTypeInfo +import javax.validation.constraints.NotNull +import kotlin.Boolean +import kotlin.Int +import kotlin.String + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "rootDiscriminator", + visible = true, +) +@JsonSubTypes(JsonSubTypes.Type(value = FirstLevelChild::class, name = "firstLevelChild")) +public sealed class RootType( + public open val rootField1: String, + public open val rootField2: Boolean? = null, +) { + public abstract val rootDiscriminator: RootDiscriminator +} + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "firstLevelDiscriminator", + visible = true, +) +@JsonSubTypes(JsonSubTypes.Type(value = SecondLevelChild1::class, name = + "secondLevelChild1"),JsonSubTypes.Type(value = SecondLevelChild2::class, name = + "secondLevelChild2")) +public sealed class FirstLevelChild( + @param:JsonProperty("rootField1") + @get:JsonProperty("rootField1") + @get:NotNull + override val rootField1: String, + @param:JsonProperty("rootField2") + @get:JsonProperty("rootField2") + override val rootField2: Boolean? = null, + public open val firstLevelField1: String, + public open val firstLevelField2: Int? = null, + @get:JsonProperty("rootDiscriminator") + @get:NotNull + @param:JsonProperty("rootDiscriminator") + override val rootDiscriminator: RootDiscriminator = RootDiscriminator.FIRST_LEVEL_CHILD, +) : RootType(rootField1, rootField2) { + public abstract val firstLevelDiscriminator: FirstLevelDiscriminator +} diff --git a/src/test/resources/examples/nestedPolymorphicModels/models/SecondLevelChild1.kt b/src/test/resources/examples/nestedPolymorphicModels/models/SecondLevelChild1.kt new file mode 100644 index 00000000..2669f304 --- /dev/null +++ b/src/test/resources/examples/nestedPolymorphicModels/models/SecondLevelChild1.kt @@ -0,0 +1,106 @@ +package examples.nestedPolymorphicModels.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import com.fasterxml.jackson.`annotation`.JsonSubTypes +import com.fasterxml.jackson.`annotation`.JsonTypeInfo +import javax.validation.Valid +import javax.validation.constraints.NotNull +import kotlin.Boolean +import kotlin.Int +import kotlin.String + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "secondLevelDiscriminator", + visible = true, +) +@JsonSubTypes(JsonSubTypes.Type(value = ThirdLevelChild11::class, name = + "thirdLevelChild1"),JsonSubTypes.Type(value = ThirdLevelChild12::class, name = + "thirdLevelChild2")) +public sealed class SecondLevelChild1( + @param:JsonProperty("rootField1") + @get:JsonProperty("rootField1") + @get:NotNull + override val rootField1: String, + @param:JsonProperty("rootField2") + @get:JsonProperty("rootField2") + override val rootField2: Boolean? = null, + @param:JsonProperty("firstLevelField1") + @get:JsonProperty("firstLevelField1") + @get:NotNull + override val firstLevelField1: String, + @param:JsonProperty("firstLevelField2") + @get:JsonProperty("firstLevelField2") + override val firstLevelField2: Int? = null, + public open val metadata: SecondLevelMetadata, + @get:JsonProperty("firstLevelDiscriminator") + @get:NotNull + @param:JsonProperty("firstLevelDiscriminator") + override val firstLevelDiscriminator: FirstLevelDiscriminator = + FirstLevelDiscriminator.SECOND_LEVEL_CHILD1, +) : FirstLevelChild(rootField1, rootField2, firstLevelField1, firstLevelField2) { + public abstract val secondLevelDiscriminator: SecondLevelDiscriminator +} + +public data class ThirdLevelChild11( + @param:JsonProperty("rootField1") + @get:JsonProperty("rootField1") + @get:NotNull + override val rootField1: String, + @param:JsonProperty("rootField2") + @get:JsonProperty("rootField2") + override val rootField2: Boolean? = null, + @param:JsonProperty("firstLevelField1") + @get:JsonProperty("firstLevelField1") + @get:NotNull + override val firstLevelField1: String, + @param:JsonProperty("firstLevelField2") + @get:JsonProperty("firstLevelField2") + override val firstLevelField2: Int? = null, + @param:JsonProperty("metadata") + @get:JsonProperty("metadata") + @get:NotNull + @get:Valid + override val metadata: SecondLevelMetadata, + @param:JsonProperty("creationDate") + @get:JsonProperty("creationDate") + @get:NotNull + public val creationDate: Int, + @get:JsonProperty("secondLevelDiscriminator") + @get:NotNull + @param:JsonProperty("secondLevelDiscriminator") + override val secondLevelDiscriminator: SecondLevelDiscriminator = + SecondLevelDiscriminator.THIRD_LEVEL_CHILD1, +) : SecondLevelChild1(rootField1, rootField2, firstLevelField1, firstLevelField2, metadata) + +public data class ThirdLevelChild12( + @param:JsonProperty("rootField1") + @get:JsonProperty("rootField1") + @get:NotNull + override val rootField1: String, + @param:JsonProperty("rootField2") + @get:JsonProperty("rootField2") + override val rootField2: Boolean? = null, + @param:JsonProperty("firstLevelField1") + @get:JsonProperty("firstLevelField1") + @get:NotNull + override val firstLevelField1: String, + @param:JsonProperty("firstLevelField2") + @get:JsonProperty("firstLevelField2") + override val firstLevelField2: Int? = null, + @param:JsonProperty("metadata") + @get:JsonProperty("metadata") + @get:NotNull + @get:Valid + override val metadata: SecondLevelMetadata, + @param:JsonProperty("isDeleted") + @get:JsonProperty("isDeleted") + @get:NotNull + public val isDeleted: Boolean, + @get:JsonProperty("secondLevelDiscriminator") + @get:NotNull + @param:JsonProperty("secondLevelDiscriminator") + override val secondLevelDiscriminator: SecondLevelDiscriminator = + SecondLevelDiscriminator.THIRD_LEVEL_CHILD2, +) : SecondLevelChild1(rootField1, rootField2, firstLevelField1, firstLevelField2, metadata) diff --git a/src/test/resources/examples/nestedPolymorphicModels/models/SecondLevelChild2.kt b/src/test/resources/examples/nestedPolymorphicModels/models/SecondLevelChild2.kt new file mode 100644 index 00000000..2decca9d --- /dev/null +++ b/src/test/resources/examples/nestedPolymorphicModels/models/SecondLevelChild2.kt @@ -0,0 +1,106 @@ +package examples.nestedPolymorphicModels.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import com.fasterxml.jackson.`annotation`.JsonSubTypes +import com.fasterxml.jackson.`annotation`.JsonTypeInfo +import javax.validation.Valid +import javax.validation.constraints.NotNull +import kotlin.Boolean +import kotlin.Int +import kotlin.String + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "secondLevelDiscriminator", + visible = true, +) +@JsonSubTypes(JsonSubTypes.Type(value = ThirdLevelChild21::class, name = + "thirdLevelChild1"),JsonSubTypes.Type(value = ThirdLevelChild22::class, name = + "thirdLevelChild2")) +public sealed class SecondLevelChild2( + @param:JsonProperty("rootField1") + @get:JsonProperty("rootField1") + @get:NotNull + override val rootField1: String, + @param:JsonProperty("rootField2") + @get:JsonProperty("rootField2") + override val rootField2: Boolean? = null, + @param:JsonProperty("firstLevelField1") + @get:JsonProperty("firstLevelField1") + @get:NotNull + override val firstLevelField1: String, + @param:JsonProperty("firstLevelField2") + @get:JsonProperty("firstLevelField2") + override val firstLevelField2: Int? = null, + public open val metadata: SecondLevelMetadata, + @get:JsonProperty("firstLevelDiscriminator") + @get:NotNull + @param:JsonProperty("firstLevelDiscriminator") + override val firstLevelDiscriminator: FirstLevelDiscriminator = + FirstLevelDiscriminator.SECOND_LEVEL_CHILD2, +) : FirstLevelChild(rootField1, rootField2, firstLevelField1, firstLevelField2) { + public abstract val secondLevelDiscriminator: SecondLevelDiscriminator +} + +public data class ThirdLevelChild21( + @param:JsonProperty("rootField1") + @get:JsonProperty("rootField1") + @get:NotNull + override val rootField1: String, + @param:JsonProperty("rootField2") + @get:JsonProperty("rootField2") + override val rootField2: Boolean? = null, + @param:JsonProperty("firstLevelField1") + @get:JsonProperty("firstLevelField1") + @get:NotNull + override val firstLevelField1: String, + @param:JsonProperty("firstLevelField2") + @get:JsonProperty("firstLevelField2") + override val firstLevelField2: Int? = null, + @param:JsonProperty("metadata") + @get:JsonProperty("metadata") + @get:NotNull + @get:Valid + override val metadata: SecondLevelMetadata, + @param:JsonProperty("creationDate") + @get:JsonProperty("creationDate") + @get:NotNull + public val creationDate: Int, + @get:JsonProperty("secondLevelDiscriminator") + @get:NotNull + @param:JsonProperty("secondLevelDiscriminator") + override val secondLevelDiscriminator: SecondLevelDiscriminator = + SecondLevelDiscriminator.THIRD_LEVEL_CHILD1, +) : SecondLevelChild2(rootField1, rootField2, firstLevelField1, firstLevelField2, metadata) + +public data class ThirdLevelChild22( + @param:JsonProperty("rootField1") + @get:JsonProperty("rootField1") + @get:NotNull + override val rootField1: String, + @param:JsonProperty("rootField2") + @get:JsonProperty("rootField2") + override val rootField2: Boolean? = null, + @param:JsonProperty("firstLevelField1") + @get:JsonProperty("firstLevelField1") + @get:NotNull + override val firstLevelField1: String, + @param:JsonProperty("firstLevelField2") + @get:JsonProperty("firstLevelField2") + override val firstLevelField2: Int? = null, + @param:JsonProperty("metadata") + @get:JsonProperty("metadata") + @get:NotNull + @get:Valid + override val metadata: SecondLevelMetadata, + @param:JsonProperty("isDeleted") + @get:JsonProperty("isDeleted") + @get:NotNull + public val isDeleted: Boolean, + @get:JsonProperty("secondLevelDiscriminator") + @get:NotNull + @param:JsonProperty("secondLevelDiscriminator") + override val secondLevelDiscriminator: SecondLevelDiscriminator = + SecondLevelDiscriminator.THIRD_LEVEL_CHILD2, +) : SecondLevelChild2(rootField1, rootField2, firstLevelField1, firstLevelField2, metadata) diff --git a/src/test/resources/examples/nestedPolymorphicModels/models/SecondLevelDiscriminator.kt b/src/test/resources/examples/nestedPolymorphicModels/models/SecondLevelDiscriminator.kt new file mode 100644 index 00000000..e72dc945 --- /dev/null +++ b/src/test/resources/examples/nestedPolymorphicModels/models/SecondLevelDiscriminator.kt @@ -0,0 +1,21 @@ +package examples.nestedPolymorphicModels.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class SecondLevelDiscriminator( + @JsonValue + public val `value`: String, +) { + THIRD_LEVEL_CHILD1("thirdLevelChild1"), + THIRD_LEVEL_CHILD2("thirdLevelChild2"), + ; + + public companion object { + private val mapping: Map = + values().associateBy(SecondLevelDiscriminator::value) + + public fun fromValue(`value`: String): SecondLevelDiscriminator? = mapping[value] + } +} diff --git a/src/test/resources/examples/nestedPolymorphicModels/models/SecondLevelMetadata.kt b/src/test/resources/examples/nestedPolymorphicModels/models/SecondLevelMetadata.kt new file mode 100644 index 00000000..352974b1 --- /dev/null +++ b/src/test/resources/examples/nestedPolymorphicModels/models/SecondLevelMetadata.kt @@ -0,0 +1,13 @@ +package examples.nestedPolymorphicModels.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import javax.validation.constraints.NotNull + +public data class SecondLevelMetadata( + @param:JsonProperty("obj") + @get:JsonProperty("obj") + @get:NotNull + @get:Valid + public val obj: CommonObject, +) diff --git a/src/test/resources/examples/oneOfMarkerInterface/models/Container.kt b/src/test/resources/examples/oneOfMarkerInterface/models/Container.kt new file mode 100644 index 00000000..a9847c1e --- /dev/null +++ b/src/test/resources/examples/oneOfMarkerInterface/models/Container.kt @@ -0,0 +1,10 @@ +package examples.oneOfMarkerInterface.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.Any + +public data class Container( + @param:JsonProperty("state") + @get:JsonProperty("state") + public val state: Any? = null, +) diff --git a/src/test/resources/examples/oneOfMarkerInterface/models/Models.kt b/src/test/resources/examples/oneOfMarkerInterface/models/Models.kt deleted file mode 100644 index abf9a51f..00000000 --- a/src/test/resources/examples/oneOfMarkerInterface/models/Models.kt +++ /dev/null @@ -1,26 +0,0 @@ -package examples.oneOfMarkerInterface.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import javax.validation.constraints.NotNull -import kotlin.Any -import kotlin.String - -public data class Container( - @param:JsonProperty("state") - @get:JsonProperty("state") - public val state: Any? = null, -) - -public sealed interface State - -public data class StateA( - @get:JsonProperty("status") - @get:NotNull - public val status: String, -) : State - -public data class StateB( - @get:JsonProperty("mode") - @get:NotNull - public val mode: String, -) : State diff --git a/src/test/resources/examples/oneOfMarkerInterface/models/State.kt b/src/test/resources/examples/oneOfMarkerInterface/models/State.kt new file mode 100644 index 00000000..95d737db --- /dev/null +++ b/src/test/resources/examples/oneOfMarkerInterface/models/State.kt @@ -0,0 +1,3 @@ +package examples.oneOfMarkerInterface.models + +public sealed interface State diff --git a/src/test/resources/examples/oneOfMarkerInterface/models/StateA.kt b/src/test/resources/examples/oneOfMarkerInterface/models/StateA.kt new file mode 100644 index 00000000..d8144e62 --- /dev/null +++ b/src/test/resources/examples/oneOfMarkerInterface/models/StateA.kt @@ -0,0 +1,11 @@ +package examples.oneOfMarkerInterface.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.String + +public data class StateA( + @get:JsonProperty("status") + @get:NotNull + public val status: String, +) : State diff --git a/src/test/resources/examples/oneOfMarkerInterface/models/StateB.kt b/src/test/resources/examples/oneOfMarkerInterface/models/StateB.kt new file mode 100644 index 00000000..3d895691 --- /dev/null +++ b/src/test/resources/examples/oneOfMarkerInterface/models/StateB.kt @@ -0,0 +1,11 @@ +package examples.oneOfMarkerInterface.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.String + +public data class StateB( + @get:JsonProperty("mode") + @get:NotNull + public val mode: String, +) : State diff --git a/src/test/resources/examples/oneOfPolymorphicModels/models/ContainsOneOfPolymorphicTypes.kt b/src/test/resources/examples/oneOfPolymorphicModels/models/ContainsOneOfPolymorphicTypes.kt new file mode 100644 index 00000000..786b2644 --- /dev/null +++ b/src/test/resources/examples/oneOfPolymorphicModels/models/ContainsOneOfPolymorphicTypes.kt @@ -0,0 +1,16 @@ +package examples.oneOfPolymorphicModels.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.Valid +import kotlin.collections.List + +public data class ContainsOneOfPolymorphicTypes( + @param:JsonProperty("one_one_of") + @get:JsonProperty("one_one_of") + @get:Valid + public val oneOneOf: PolymorphicSuperTypeOne? = null, + @param:JsonProperty("many_one_of") + @get:JsonProperty("many_one_of") + @get:Valid + public val manyOneOf: List? = null, +) diff --git a/src/test/resources/examples/oneOfPolymorphicModels/models/Models.kt b/src/test/resources/examples/oneOfPolymorphicModels/models/Models.kt deleted file mode 100644 index feab6245..00000000 --- a/src/test/resources/examples/oneOfPolymorphicModels/models/Models.kt +++ /dev/null @@ -1,162 +0,0 @@ -package examples.oneOfPolymorphicModels.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import com.fasterxml.jackson.`annotation`.JsonSubTypes -import com.fasterxml.jackson.`annotation`.JsonTypeInfo -import com.fasterxml.jackson.`annotation`.JsonValue -import javax.validation.Valid -import javax.validation.constraints.NotNull -import kotlin.Int -import kotlin.String -import kotlin.collections.List -import kotlin.collections.Map - -public data class ChildTypeA( - @param:JsonProperty("some_string") - @get:JsonProperty("some_string") - @get:NotNull - public val someString: String, - @get:JsonProperty("type") - @get:NotNull - @param:JsonProperty("type") - override val type: ParentType = ParentType.CHILD_TYPE_A, -) : ParentSpec() - -public data class ChildTypeB( - @param:JsonProperty("some_int") - @get:JsonProperty("some_int") - @get:NotNull - public val someInt: Int, - @get:JsonProperty("type") - @get:NotNull - @param:JsonProperty("type") - override val type: ParentType = ParentType.CHILD_TYPE_B, -) : ParentSpec() - -public data class ContainsOneOfPolymorphicTypes( - @param:JsonProperty("one_one_of") - @get:JsonProperty("one_one_of") - @get:Valid - public val oneOneOf: PolymorphicSuperTypeOne? = null, - @param:JsonProperty("many_one_of") - @get:JsonProperty("many_one_of") - @get:Valid - public val manyOneOf: List? = null, -) - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "type", - visible = true, -) -@JsonSubTypes( - JsonSubTypes.Type( - value = ChildTypeA::class, - name = - "CHILD_TYPE_A", - ), - JsonSubTypes.Type(value = ChildTypeB::class, name = "CHILD_TYPE_B"), -) -public sealed class ParentSpec() { - public abstract val type: ParentType -} - -public enum class ParentType( - @JsonValue - public val `value`: String, -) { - CHILD_TYPE_A("CHILD_TYPE_A"), - CHILD_TYPE_B("CHILD_TYPE_B"), - ; - - public companion object { - private val mapping: Map = values().associateBy(ParentType::value) - - public fun fromValue(`value`: String): ParentType? = mapping[value] - } -} - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "shared", - visible = true, -) -@JsonSubTypes( - JsonSubTypes.Type( - value = PolymorphicTypeOneA::class, - name = - "PolymorphicTypeOneA", - ), - JsonSubTypes.Type( - value = PolymorphicTypeOneB::class, - name = - "PolymorphicTypeOneB", - ), -) -public sealed class PolymorphicSuperTypeOne() { - public abstract val shared: String -} - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "shared", - visible = true, -) -@JsonSubTypes( - JsonSubTypes.Type( - value = PolymorphicTypeTwoA::class, - name = - "PolymorphicTypeTwoA", - ), - JsonSubTypes.Type( - value = PolymorphicTypeTwoB::class, - name = - "PolymorphicTypeTwoB", - ), -) -public sealed class PolymorphicSuperTypeTwo() { - public abstract val shared: String -} - -public data class PolymorphicTypeOneA( - @param:JsonProperty("whateverA") - @get:JsonProperty("whateverA") - public val whateverA: String? = null, - @get:JsonProperty("shared") - @get:NotNull - @param:JsonProperty("shared") - override val shared: String = "PolymorphicTypeOneA", -) : PolymorphicSuperTypeOne() - -public data class PolymorphicTypeOneB( - @param:JsonProperty("whateverB") - @get:JsonProperty("whateverB") - public val whateverB: Int? = null, - @get:JsonProperty("shared") - @get:NotNull - @param:JsonProperty("shared") - override val shared: String = "PolymorphicTypeOneB", -) : PolymorphicSuperTypeOne() - -public data class PolymorphicTypeTwoA( - @param:JsonProperty("whateverC") - @get:JsonProperty("whateverC") - public val whateverC: String? = null, - @get:JsonProperty("shared") - @get:NotNull - @param:JsonProperty("shared") - override val shared: String = "PolymorphicTypeTwoA", -) : PolymorphicSuperTypeTwo() - -public data class PolymorphicTypeTwoB( - @param:JsonProperty("whateverD") - @get:JsonProperty("whateverD") - public val whateverD: Int? = null, - @get:JsonProperty("shared") - @get:NotNull - @param:JsonProperty("shared") - override val shared: String = "PolymorphicTypeTwoB", -) : PolymorphicSuperTypeTwo() diff --git a/src/test/resources/examples/oneOfPolymorphicModels/models/ParentSpec.kt b/src/test/resources/examples/oneOfPolymorphicModels/models/ParentSpec.kt new file mode 100644 index 00000000..3374c245 --- /dev/null +++ b/src/test/resources/examples/oneOfPolymorphicModels/models/ParentSpec.kt @@ -0,0 +1,42 @@ +package examples.oneOfPolymorphicModels.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import com.fasterxml.jackson.`annotation`.JsonSubTypes +import com.fasterxml.jackson.`annotation`.JsonTypeInfo +import javax.validation.constraints.NotNull +import kotlin.Int +import kotlin.String + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "type", + visible = true, +) +@JsonSubTypes(JsonSubTypes.Type(value = ChildTypeA::class, name = + "CHILD_TYPE_A"),JsonSubTypes.Type(value = ChildTypeB::class, name = "CHILD_TYPE_B")) +public sealed class ParentSpec() { + public abstract val type: ParentType +} + +public data class ChildTypeA( + @param:JsonProperty("some_string") + @get:JsonProperty("some_string") + @get:NotNull + public val someString: String, + @get:JsonProperty("type") + @get:NotNull + @param:JsonProperty("type") + override val type: ParentType = ParentType.CHILD_TYPE_A, +) : ParentSpec() + +public data class ChildTypeB( + @param:JsonProperty("some_int") + @get:JsonProperty("some_int") + @get:NotNull + public val someInt: Int, + @get:JsonProperty("type") + @get:NotNull + @param:JsonProperty("type") + override val type: ParentType = ParentType.CHILD_TYPE_B, +) : ParentSpec() diff --git a/src/test/resources/examples/oneOfPolymorphicModels/models/ParentType.kt b/src/test/resources/examples/oneOfPolymorphicModels/models/ParentType.kt new file mode 100644 index 00000000..df141c3e --- /dev/null +++ b/src/test/resources/examples/oneOfPolymorphicModels/models/ParentType.kt @@ -0,0 +1,20 @@ +package examples.oneOfPolymorphicModels.models + +import com.fasterxml.jackson.`annotation`.JsonValue +import kotlin.String +import kotlin.collections.Map + +public enum class ParentType( + @JsonValue + public val `value`: String, +) { + CHILD_TYPE_A("CHILD_TYPE_A"), + CHILD_TYPE_B("CHILD_TYPE_B"), + ; + + public companion object { + private val mapping: Map = values().associateBy(ParentType::value) + + public fun fromValue(`value`: String): ParentType? = mapping[value] + } +} diff --git a/src/test/resources/examples/oneOfPolymorphicModels/models/PolymorphicSuperTypeOne.kt b/src/test/resources/examples/oneOfPolymorphicModels/models/PolymorphicSuperTypeOne.kt new file mode 100644 index 00000000..7d30c438 --- /dev/null +++ b/src/test/resources/examples/oneOfPolymorphicModels/models/PolymorphicSuperTypeOne.kt @@ -0,0 +1,41 @@ +package examples.oneOfPolymorphicModels.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import com.fasterxml.jackson.`annotation`.JsonSubTypes +import com.fasterxml.jackson.`annotation`.JsonTypeInfo +import javax.validation.constraints.NotNull +import kotlin.Int +import kotlin.String + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "shared", + visible = true, +) +@JsonSubTypes(JsonSubTypes.Type(value = PolymorphicTypeOneA::class, name = + "PolymorphicTypeOneA"),JsonSubTypes.Type(value = PolymorphicTypeOneB::class, name = + "PolymorphicTypeOneB")) +public sealed class PolymorphicSuperTypeOne() { + public abstract val shared: String +} + +public data class PolymorphicTypeOneA( + @param:JsonProperty("whateverA") + @get:JsonProperty("whateverA") + public val whateverA: String? = null, + @get:JsonProperty("shared") + @get:NotNull + @param:JsonProperty("shared") + override val shared: String = "PolymorphicTypeOneA", +) : PolymorphicSuperTypeOne() + +public data class PolymorphicTypeOneB( + @param:JsonProperty("whateverB") + @get:JsonProperty("whateverB") + public val whateverB: Int? = null, + @get:JsonProperty("shared") + @get:NotNull + @param:JsonProperty("shared") + override val shared: String = "PolymorphicTypeOneB", +) : PolymorphicSuperTypeOne() diff --git a/src/test/resources/examples/oneOfPolymorphicModels/models/PolymorphicSuperTypeTwo.kt b/src/test/resources/examples/oneOfPolymorphicModels/models/PolymorphicSuperTypeTwo.kt new file mode 100644 index 00000000..fd8da5c9 --- /dev/null +++ b/src/test/resources/examples/oneOfPolymorphicModels/models/PolymorphicSuperTypeTwo.kt @@ -0,0 +1,41 @@ +package examples.oneOfPolymorphicModels.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import com.fasterxml.jackson.`annotation`.JsonSubTypes +import com.fasterxml.jackson.`annotation`.JsonTypeInfo +import javax.validation.constraints.NotNull +import kotlin.Int +import kotlin.String + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "shared", + visible = true, +) +@JsonSubTypes(JsonSubTypes.Type(value = PolymorphicTypeTwoA::class, name = + "PolymorphicTypeTwoA"),JsonSubTypes.Type(value = PolymorphicTypeTwoB::class, name = + "PolymorphicTypeTwoB")) +public sealed class PolymorphicSuperTypeTwo() { + public abstract val shared: String +} + +public data class PolymorphicTypeTwoA( + @param:JsonProperty("whateverC") + @get:JsonProperty("whateverC") + public val whateverC: String? = null, + @get:JsonProperty("shared") + @get:NotNull + @param:JsonProperty("shared") + override val shared: String = "PolymorphicTypeTwoA", +) : PolymorphicSuperTypeTwo() + +public data class PolymorphicTypeTwoB( + @param:JsonProperty("whateverD") + @get:JsonProperty("whateverD") + public val whateverD: Int? = null, + @get:JsonProperty("shared") + @get:NotNull + @param:JsonProperty("shared") + override val shared: String = "PolymorphicTypeTwoB", +) : PolymorphicSuperTypeTwo() diff --git a/src/test/resources/examples/openapi310/models/Models.kt b/src/test/resources/examples/openapi310/models/NewNullableFormat.kt similarity index 60% rename from src/test/resources/examples/openapi310/models/Models.kt rename to src/test/resources/examples/openapi310/models/NewNullableFormat.kt index 849359b9..2b1be26e 100644 --- a/src/test/resources/examples/openapi310/models/Models.kt +++ b/src/test/resources/examples/openapi310/models/NewNullableFormat.kt @@ -4,7 +4,7 @@ import com.fasterxml.jackson.`annotation`.JsonProperty import kotlin.String public data class NewNullableFormat( - @param:JsonProperty("version") - @get:JsonProperty("version") - public val version: String?, + @param:JsonProperty("version") + @get:JsonProperty("version") + public val version: String?, ) diff --git a/src/test/resources/examples/optionalVsRequired/models/Models.kt b/src/test/resources/examples/optionalVsRequired/models/Models.kt deleted file mode 100644 index 4b14b966..00000000 --- a/src/test/resources/examples/optionalVsRequired/models/Models.kt +++ /dev/null @@ -1,19 +0,0 @@ -package examples.optionalVsRequired.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import java.util.UUID -import javax.validation.constraints.NotNull -import kotlin.String - -public data class OptionalVsRequired( - @param:JsonProperty("name") - @get:JsonProperty("name") - @get:NotNull - public val name: String, - @param:JsonProperty("gender") - @get:JsonProperty("gender") - public val gender: UUID? = null, - @param:JsonProperty("requiredNullable") - @get:JsonProperty("requiredNullable") - public val requiredNullable: String?, -) diff --git a/src/test/resources/examples/optionalVsRequired/models/OptionalVsRequired.kt b/src/test/resources/examples/optionalVsRequired/models/OptionalVsRequired.kt new file mode 100644 index 00000000..fa68e7ec --- /dev/null +++ b/src/test/resources/examples/optionalVsRequired/models/OptionalVsRequired.kt @@ -0,0 +1,19 @@ +package examples.optionalVsRequired.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import java.util.UUID +import javax.validation.constraints.NotNull +import kotlin.String + +public data class OptionalVsRequired( + @param:JsonProperty("name") + @get:JsonProperty("name") + @get:NotNull + public val name: String, + @param:JsonProperty("gender") + @get:JsonProperty("gender") + public val gender: UUID? = null, + @param:JsonProperty("requiredNullable") + @get:JsonProperty("requiredNullable") + public val requiredNullable: String?, +) diff --git a/src/test/resources/examples/polymorphicModels/models/AnotherObject.kt b/src/test/resources/examples/polymorphicModels/models/AnotherObject.kt new file mode 100644 index 00000000..a3da21db --- /dev/null +++ b/src/test/resources/examples/polymorphicModels/models/AnotherObject.kt @@ -0,0 +1,10 @@ +package examples.polymorphicModels.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.Int + +public data class AnotherObject( + @param:JsonProperty("some_integer_propery") + @get:JsonProperty("some_integer_propery") + public val someIntegerPropery: Int? = null, +) diff --git a/src/test/resources/examples/polymorphicModels/models/Models.kt b/src/test/resources/examples/polymorphicModels/models/Models.kt deleted file mode 100644 index 6560e802..00000000 --- a/src/test/resources/examples/polymorphicModels/models/Models.kt +++ /dev/null @@ -1,135 +0,0 @@ -package examples.polymorphicModels.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import com.fasterxml.jackson.`annotation`.JsonSubTypes -import com.fasterxml.jackson.`annotation`.JsonTypeInfo -import javax.validation.constraints.NotNull -import kotlin.Int -import kotlin.String - -public data class AnotherObject( - @param:JsonProperty("some_integer_propery") - @get:JsonProperty("some_integer_propery") - public val someIntegerPropery: Int? = null, -) - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "generation", - visible = true, -) -@JsonSubTypes( - JsonSubTypes.Type( - value = PolymorphicTypeOne::class, - name = - "PolymorphicTypeOne", - ), - JsonSubTypes.Type( - value = PolymorphicTypeTwo::class, - name = - "polymorphic_type_two", - ), -) -public sealed class PolymorphicSuperType( - public open val firstName: String, - public open val lastName: String, -) { - public abstract val generation: String -} - -public data class PolymorphicTypeOne( - @param:JsonProperty("first_name") - @get:JsonProperty("first_name") - @get:NotNull - override val firstName: String, - @param:JsonProperty("last_name") - @get:JsonProperty("last_name") - @get:NotNull - override val lastName: String, - @param:JsonProperty("child_one_name") - @get:JsonProperty("child_one_name") - public val childOneName: String? = null, - @get:JsonProperty("generation") - @get:NotNull - @param:JsonProperty("generation") - override val generation: String = "PolymorphicTypeOne", -) : PolymorphicSuperType(firstName, lastName) - -public data class PolymorphicTypeOneAnotherRef( - @param:JsonProperty("first_name") - @get:JsonProperty("first_name") - @get:NotNull - override val firstName: String, - @param:JsonProperty("last_name") - @get:JsonProperty("last_name") - @get:NotNull - override val lastName: String, - @param:JsonProperty("child_one_name") - @get:JsonProperty("child_one_name") - public val childOneName: String? = null, - @get:JsonProperty("generation") - @get:NotNull - @param:JsonProperty("generation") - override val generation: String = "PolymorphicTypeOne", -) : PolymorphicSuperType(firstName, lastName) - -public data class PolymorphicTypeOneRef( - @param:JsonProperty("first_name") - @get:JsonProperty("first_name") - @get:NotNull - override val firstName: String, - @param:JsonProperty("last_name") - @get:JsonProperty("last_name") - @get:NotNull - override val lastName: String, - @param:JsonProperty("child_one_name") - @get:JsonProperty("child_one_name") - public val childOneName: String? = null, - @get:JsonProperty("generation") - @get:NotNull - @param:JsonProperty("generation") - override val generation: String = "PolymorphicTypeOne", -) : PolymorphicSuperType(firstName, lastName) - -public data class PolymorphicTypeTwo( - @param:JsonProperty("first_name") - @get:JsonProperty("first_name") - @get:NotNull - override val firstName: String, - @param:JsonProperty("last_name") - @get:JsonProperty("last_name") - @get:NotNull - override val lastName: String, - @param:JsonProperty("some_integer_propery") - @get:JsonProperty("some_integer_propery") - public val someIntegerPropery: Int? = null, - @param:JsonProperty("child_two_age") - @get:JsonProperty("child_two_age") - public val childTwoAge: Int? = null, - @get:JsonProperty("generation") - @get:NotNull - @param:JsonProperty("generation") - override val generation: String = "polymorphic_type_two", -) : PolymorphicSuperType(firstName, lastName) - -public data class PolymorphicTypeTwoRef( - @param:JsonProperty("first_name") - @get:JsonProperty("first_name") - @get:NotNull - override val firstName: String, - @param:JsonProperty("last_name") - @get:JsonProperty("last_name") - @get:NotNull - override val lastName: String, - @param:JsonProperty("some_integer_propery") - @get:JsonProperty("some_integer_propery") - public val someIntegerPropery: Int? = null, - @param:JsonProperty("child_two_age") - @get:JsonProperty("child_two_age") - public val childTwoAge: Int? = null, - @get:JsonProperty("generation") - @get:NotNull - @param:JsonProperty("generation") - override val generation: String = "polymorphic_type_two", -) : PolymorphicSuperType(firstName, lastName) diff --git a/src/test/resources/examples/polymorphicModels/models/PolymorphicSuperType.kt b/src/test/resources/examples/polymorphicModels/models/PolymorphicSuperType.kt new file mode 100644 index 00000000..795a0c7d --- /dev/null +++ b/src/test/resources/examples/polymorphicModels/models/PolymorphicSuperType.kt @@ -0,0 +1,120 @@ +package examples.polymorphicModels.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import com.fasterxml.jackson.`annotation`.JsonSubTypes +import com.fasterxml.jackson.`annotation`.JsonTypeInfo +import javax.validation.constraints.NotNull +import kotlin.Int +import kotlin.String + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "generation", + visible = true, +) +@JsonSubTypes(JsonSubTypes.Type(value = PolymorphicTypeOne::class, name = + "PolymorphicTypeOne"),JsonSubTypes.Type(value = PolymorphicTypeTwo::class, name = + "polymorphic_type_two")) +public sealed class PolymorphicSuperType( + public open val firstName: String, + public open val lastName: String, +) { + public abstract val generation: String +} + +public data class PolymorphicTypeOneRef( + @param:JsonProperty("first_name") + @get:JsonProperty("first_name") + @get:NotNull + override val firstName: String, + @param:JsonProperty("last_name") + @get:JsonProperty("last_name") + @get:NotNull + override val lastName: String, + @param:JsonProperty("child_one_name") + @get:JsonProperty("child_one_name") + public val childOneName: String? = null, + @get:JsonProperty("generation") + @get:NotNull + @param:JsonProperty("generation") + override val generation: String = "PolymorphicTypeOne", +) : PolymorphicSuperType(firstName, lastName) + +public data class PolymorphicTypeOneAnotherRef( + @param:JsonProperty("first_name") + @get:JsonProperty("first_name") + @get:NotNull + override val firstName: String, + @param:JsonProperty("last_name") + @get:JsonProperty("last_name") + @get:NotNull + override val lastName: String, + @param:JsonProperty("child_one_name") + @get:JsonProperty("child_one_name") + public val childOneName: String? = null, + @get:JsonProperty("generation") + @get:NotNull + @param:JsonProperty("generation") + override val generation: String = "PolymorphicTypeOne", +) : PolymorphicSuperType(firstName, lastName) + +public data class PolymorphicTypeTwoRef( + @param:JsonProperty("first_name") + @get:JsonProperty("first_name") + @get:NotNull + override val firstName: String, + @param:JsonProperty("last_name") + @get:JsonProperty("last_name") + @get:NotNull + override val lastName: String, + @param:JsonProperty("some_integer_propery") + @get:JsonProperty("some_integer_propery") + public val someIntegerPropery: Int? = null, + @param:JsonProperty("child_two_age") + @get:JsonProperty("child_two_age") + public val childTwoAge: Int? = null, + @get:JsonProperty("generation") + @get:NotNull + @param:JsonProperty("generation") + override val generation: String = "polymorphic_type_two", +) : PolymorphicSuperType(firstName, lastName) + +public data class PolymorphicTypeOne( + @param:JsonProperty("first_name") + @get:JsonProperty("first_name") + @get:NotNull + override val firstName: String, + @param:JsonProperty("last_name") + @get:JsonProperty("last_name") + @get:NotNull + override val lastName: String, + @param:JsonProperty("child_one_name") + @get:JsonProperty("child_one_name") + public val childOneName: String? = null, + @get:JsonProperty("generation") + @get:NotNull + @param:JsonProperty("generation") + override val generation: String = "PolymorphicTypeOne", +) : PolymorphicSuperType(firstName, lastName) + +public data class PolymorphicTypeTwo( + @param:JsonProperty("first_name") + @get:JsonProperty("first_name") + @get:NotNull + override val firstName: String, + @param:JsonProperty("last_name") + @get:JsonProperty("last_name") + @get:NotNull + override val lastName: String, + @param:JsonProperty("some_integer_propery") + @get:JsonProperty("some_integer_propery") + public val someIntegerPropery: Int? = null, + @param:JsonProperty("child_two_age") + @get:JsonProperty("child_two_age") + public val childTwoAge: Int? = null, + @get:JsonProperty("generation") + @get:NotNull + @param:JsonProperty("generation") + override val generation: String = "polymorphic_type_two", +) : PolymorphicSuperType(firstName, lastName) diff --git a/src/test/resources/examples/requiredReadOnly/models/Models.kt b/src/test/resources/examples/requiredReadOnly/models/Models.kt deleted file mode 100644 index bedc0f83..00000000 --- a/src/test/resources/examples/requiredReadOnly/models/Models.kt +++ /dev/null @@ -1,16 +0,0 @@ -package examples.requiredReadOnly.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import java.time.OffsetDateTime -import javax.validation.constraints.NotNull -import kotlin.String - -public data class RequiredReadOnly( - @param:JsonProperty("user_name") - @get:JsonProperty("user_name") - @get:NotNull - public val userName: String, - @param:JsonProperty("created") - @get:JsonProperty("created") - public val created: OffsetDateTime? = null, -) diff --git a/src/test/resources/examples/requiredReadOnly/models/RequiredReadOnly.kt b/src/test/resources/examples/requiredReadOnly/models/RequiredReadOnly.kt new file mode 100644 index 00000000..25f7e220 --- /dev/null +++ b/src/test/resources/examples/requiredReadOnly/models/RequiredReadOnly.kt @@ -0,0 +1,16 @@ +package examples.requiredReadOnly.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import java.time.OffsetDateTime +import javax.validation.constraints.NotNull +import kotlin.String + +public data class RequiredReadOnly( + @param:JsonProperty("user_name") + @get:JsonProperty("user_name") + @get:NotNull + public val userName: String, + @param:JsonProperty("created") + @get:JsonProperty("created") + public val created: OffsetDateTime? = null, +) diff --git a/src/test/resources/examples/responsesSchema/models/ErrorResponse.kt b/src/test/resources/examples/responsesSchema/models/ErrorResponse.kt new file mode 100644 index 00000000..2deb8df8 --- /dev/null +++ b/src/test/resources/examples/responsesSchema/models/ErrorResponse.kt @@ -0,0 +1,17 @@ +package examples.responsesSchema.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.Int +import kotlin.String + +public data class ErrorResponse( + @param:JsonProperty("message") + @get:JsonProperty("message") + @get:NotNull + public val message: String, + @param:JsonProperty("code") + @get:JsonProperty("code") + @get:NotNull + public val code: Int, +) diff --git a/src/test/resources/examples/responsesSchema/models/Models.kt b/src/test/resources/examples/responsesSchema/models/Models.kt deleted file mode 100644 index a7b8183f..00000000 --- a/src/test/resources/examples/responsesSchema/models/Models.kt +++ /dev/null @@ -1,24 +0,0 @@ -package examples.responsesSchema.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import javax.validation.constraints.NotNull -import kotlin.Int -import kotlin.String - -public data class ErrorResponse( - @param:JsonProperty("message") - @get:JsonProperty("message") - @get:NotNull - public val message: String, - @param:JsonProperty("code") - @get:JsonProperty("code") - @get:NotNull - public val code: Int, -) - -public data class SucccessResponse( - @param:JsonProperty("message") - @get:JsonProperty("message") - @get:NotNull - public val message: String, -) diff --git a/src/test/resources/examples/responsesSchema/models/SucccessResponse.kt b/src/test/resources/examples/responsesSchema/models/SucccessResponse.kt new file mode 100644 index 00000000..f399eda1 --- /dev/null +++ b/src/test/resources/examples/responsesSchema/models/SucccessResponse.kt @@ -0,0 +1,12 @@ +package examples.responsesSchema.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.String + +public data class SucccessResponse( + @param:JsonProperty("message") + @get:JsonProperty("message") + @get:NotNull + public val message: String, +) diff --git a/src/test/resources/examples/singleAllOf/models/Base.kt b/src/test/resources/examples/singleAllOf/models/Base.kt new file mode 100644 index 00000000..241e2ca4 --- /dev/null +++ b/src/test/resources/examples/singleAllOf/models/Base.kt @@ -0,0 +1,10 @@ +package examples.singleAllOf.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class Base( + @param:JsonProperty("foo") + @get:JsonProperty("foo") + public val foo: String? = null, +) diff --git a/src/test/resources/examples/singleAllOf/models/Models.kt b/src/test/resources/examples/singleAllOf/models/Models.kt deleted file mode 100644 index 1e4a8b03..00000000 --- a/src/test/resources/examples/singleAllOf/models/Models.kt +++ /dev/null @@ -1,16 +0,0 @@ -package examples.singleAllOf.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import kotlin.String - -public data class Base( - @param:JsonProperty("foo") - @get:JsonProperty("foo") - public val foo: String? = null, -) - -public data class Result( - @param:JsonProperty("foo") - @get:JsonProperty("foo") - public val foo: String? = null, -) diff --git a/src/test/resources/examples/singleAllOf/models/Result.kt b/src/test/resources/examples/singleAllOf/models/Result.kt new file mode 100644 index 00000000..56e46d73 --- /dev/null +++ b/src/test/resources/examples/singleAllOf/models/Result.kt @@ -0,0 +1,10 @@ +package examples.singleAllOf.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import kotlin.String + +public data class Result( + @param:JsonProperty("foo") + @get:JsonProperty("foo") + public val foo: String? = null, +) diff --git a/src/test/resources/examples/validationAnnotations/models/Models.kt b/src/test/resources/examples/validationAnnotations/models/Models.kt deleted file mode 100644 index d09b1ca9..00000000 --- a/src/test/resources/examples/validationAnnotations/models/Models.kt +++ /dev/null @@ -1,47 +0,0 @@ -package examples.validationAnnotations.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import javax.validation.constraints.DecimalMax -import javax.validation.constraints.DecimalMin -import javax.validation.constraints.NotNull -import javax.validation.constraints.Pattern -import javax.validation.constraints.Size -import kotlin.Int -import kotlin.String -import kotlin.collections.List - -public data class ValidationAnnotations( - @param:JsonProperty("user_name") - @get:JsonProperty("user_name") - @get:NotNull - @get:Pattern(regexp = "[a-zA-Z]") - public val userName: String, - @param:JsonProperty("age") - @get:JsonProperty("age") - @get:NotNull - @get:DecimalMin( - value = "0", - inclusive = false, - ) - @get:DecimalMax( - value = "100", - inclusive = true, - ) - public val age: Int, - @param:JsonProperty("bio") - @get:JsonProperty("bio") - @get:NotNull - @get:Size( - min = 20, - max = 200, - ) - public val bio: String, - @param:JsonProperty("friends") - @get:JsonProperty("friends") - @get:NotNull - @get:Size( - min = 0, - max = 10, - ) - public val friends: List, -) diff --git a/src/test/resources/examples/validationAnnotations/models/ValidationAnnotations.kt b/src/test/resources/examples/validationAnnotations/models/ValidationAnnotations.kt new file mode 100644 index 00000000..53b988c4 --- /dev/null +++ b/src/test/resources/examples/validationAnnotations/models/ValidationAnnotations.kt @@ -0,0 +1,47 @@ +package examples.validationAnnotations.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.DecimalMax +import javax.validation.constraints.DecimalMin +import javax.validation.constraints.NotNull +import javax.validation.constraints.Pattern +import javax.validation.constraints.Size +import kotlin.Int +import kotlin.String +import kotlin.collections.List + +public data class ValidationAnnotations( + @param:JsonProperty("user_name") + @get:JsonProperty("user_name") + @get:NotNull + @get:Pattern(regexp = "[a-zA-Z]") + public val userName: String, + @param:JsonProperty("age") + @get:JsonProperty("age") + @get:NotNull + @get:DecimalMin( + value = "0", + inclusive = false, + ) + @get:DecimalMax( + value = "100", + inclusive = true, + ) + public val age: Int, + @param:JsonProperty("bio") + @get:JsonProperty("bio") + @get:NotNull + @get:Size( + min = 20, + max = 200, + ) + public val bio: String, + @param:JsonProperty("friends") + @get:JsonProperty("friends") + @get:NotNull + @get:Size( + min = 0, + max = 10, + ) + public val friends: List, +) diff --git a/src/test/resources/examples/webhook/models/Models.kt b/src/test/resources/examples/webhook/models/Models.kt deleted file mode 100644 index cd2d6ca3..00000000 --- a/src/test/resources/examples/webhook/models/Models.kt +++ /dev/null @@ -1,20 +0,0 @@ -package examples.webhook.models - -import com.fasterxml.jackson.`annotation`.JsonProperty -import javax.validation.constraints.NotNull -import kotlin.Long -import kotlin.String - -public data class Pet( - @param:JsonProperty("id") - @get:JsonProperty("id") - @get:NotNull - public val id: Long, - @param:JsonProperty("name") - @get:JsonProperty("name") - @get:NotNull - public val name: String, - @param:JsonProperty("tag") - @get:JsonProperty("tag") - public val tag: String? = null, -) diff --git a/src/test/resources/examples/webhook/models/Pet.kt b/src/test/resources/examples/webhook/models/Pet.kt new file mode 100644 index 00000000..45598dff --- /dev/null +++ b/src/test/resources/examples/webhook/models/Pet.kt @@ -0,0 +1,20 @@ +package examples.webhook.models + +import com.fasterxml.jackson.`annotation`.JsonProperty +import javax.validation.constraints.NotNull +import kotlin.Long +import kotlin.String + +public data class Pet( + @param:JsonProperty("id") + @get:JsonProperty("id") + @get:NotNull + public val id: Long, + @param:JsonProperty("name") + @get:JsonProperty("name") + @get:NotNull + public val name: String, + @param:JsonProperty("tag") + @get:JsonProperty("tag") + public val tag: String? = null, +) diff --git a/src/test/resources/examples/wildCardTypes/models/Models.kt b/src/test/resources/examples/wildCardTypes/models/WildCardTypes.kt similarity index 50% rename from src/test/resources/examples/wildCardTypes/models/Models.kt rename to src/test/resources/examples/wildCardTypes/models/WildCardTypes.kt index 3d45d20e..e8acc06a 100644 --- a/src/test/resources/examples/wildCardTypes/models/Models.kt +++ b/src/test/resources/examples/wildCardTypes/models/WildCardTypes.kt @@ -7,12 +7,12 @@ import kotlin.String import kotlin.collections.Map public data class WildCardTypes( - @param:JsonProperty("user_name") - @get:JsonProperty("user_name") - @get:NotNull - public val userName: String, - @param:JsonProperty("meta") - @get:JsonProperty("meta") - @get:NotNull - public val meta: Map, + @param:JsonProperty("user_name") + @get:JsonProperty("user_name") + @get:NotNull + public val userName: String, + @param:JsonProperty("meta") + @get:JsonProperty("meta") + @get:NotNull + public val meta: Map, )