Skip to content

Discriminator property is missing in ADT element if it was re-registered from non-ADT context #61

@jakipatryk

Description

@jakipatryk

Suppose we have the following Scala code:

sealed trait Expression
object Expression {
   case object NullLiteral extends Expression
   case class StringLiteral(value: String) extends Expression
}

case class SomethingElse(stringLiteral: Expression.StringLiteral)

and we register it with OpenAPIModelRegistration that has RegistrationConfig#sumADTsShape == RegistrationConfig.SumADTsShape.WithDiscriminator:

openAPIModelRegistration.register[Expression]()
openAPIModelRegistration.register[SomethingElse]()

(order matters), then we get an incorrect result where StringLiteral doesn't have the discriminator property added. This happens because, while openAPIModelRegistration.register[Expression]() registered StringLiteral correctly, openAPIModelRegistration.register[SomethingElse]() then overwritten that with incorrect result, as StringLiteral is there used in "non-ADT context".

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions