diff --git a/src/main/kotlin/com/cjbooms/fabrikt/generators/model/JacksonModelGenerator.kt b/src/main/kotlin/com/cjbooms/fabrikt/generators/model/JacksonModelGenerator.kt index c1fdb22f..f7885cb3 100644 --- a/src/main/kotlin/com/cjbooms/fabrikt/generators/model/JacksonModelGenerator.kt +++ b/src/main/kotlin/com/cjbooms/fabrikt/generators/model/JacksonModelGenerator.kt @@ -199,15 +199,7 @@ class JacksonModelGenerator( val inlinedModels = buildInLinedModels(props, enclosingSchema, apiDocUrl) inlinedModels + currentModel } - is PropertyInfo.ObjectRefField -> - when { - it.schema.isReferenceObjectDefinition() -> - it.schema.topLevelProperties(HTTP_SETTINGS, enclosingSchema).let { props -> - buildInLinedModels(props, enclosingSchema, apiDocUrl) + - standardDataClass(it.schema.safeName().toModelClassName(), props) - } - else -> emptySet() - } + is PropertyInfo.ObjectRefField -> emptySet() // Not an inlined definition, so do nothing is PropertyInfo.MapField -> buildMapModel(it)?.let { mapModel -> setOf(mapModel) } ?: emptySet() is PropertyInfo.AdditionalProperties -> diff --git a/src/test/resources/examples/enumPolymorphicDiscriminator/api.yaml b/src/test/resources/examples/enumPolymorphicDiscriminator/api.yaml index b0f17ace..13caccc1 100644 --- a/src/test/resources/examples/enumPolymorphicDiscriminator/api.yaml +++ b/src/test/resources/examples/enumPolymorphicDiscriminator/api.yaml @@ -5,6 +5,11 @@ info: version: "" components: schemas: + Wrapper: + type: object + properties: + polymorph: + $ref: '#/components/schemas/PolymorphicEnumDiscriminator' PolymorphicEnumDiscriminator: type: object discriminator: diff --git a/src/test/resources/examples/enumPolymorphicDiscriminator/models/Models.kt b/src/test/resources/examples/enumPolymorphicDiscriminator/models/Models.kt index 9de083e2..86d3e406 100644 --- a/src/test/resources/examples/enumPolymorphicDiscriminator/models/Models.kt +++ b/src/test/resources/examples/enumPolymorphicDiscriminator/models/Models.kt @@ -4,6 +4,7 @@ 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 @@ -81,3 +82,10 @@ enum class EnumDiscriminator( sealed class PolymorphicEnumDiscriminator() { abstract val someEnum: EnumDiscriminator } + +data class Wrapper( + @param:JsonProperty("polymorph") + @get:JsonProperty("polymorph") + @get:Valid + val polymorph: PolymorphicEnumDiscriminator? = null +) diff --git a/src/test/resources/examples/githubApi/resources/reflection-config.json b/src/test/resources/examples/githubApi/resources/reflection-config.json index b9724b71..7bb53b63 100644 --- a/src/test/resources/examples/githubApi/resources/reflection-config.json +++ b/src/test/resources/examples/githubApi/resources/reflection-config.json @@ -135,7 +135,7 @@ "allDeclaredFields" : true, "allPublicFields" : true }, { - "name" : "examples.githubApi.models.Author", + "name" : "examples.githubApi.models.PullRequest", "allDeclaredConstructors" : true, "allPublicConstructors" : true, "allDeclaredMethods" : true, @@ -143,7 +143,7 @@ "allDeclaredFields" : true, "allPublicFields" : true }, { - "name" : "examples.githubApi.models.PullRequest", + "name" : "examples.githubApi.models.Author", "allDeclaredConstructors" : true, "allPublicConstructors" : true, "allDeclaredMethods" : true,