Skip to content

[BUG] Schema derivation for parametrized data #1303

@oskin1

Description

@oskin1

Tapir version: 0.18.0-M4

Scala version: 2.12.13

Describe the bug

Schema derived for parametrized case classes is always fixed to a random parameter

How to reproduce?

final case class Items[A](items: List[A], total: Int)
object Items {
  implicit def schema[A: Schema]: Schema[Items[A]]    = Schema.derived[Items[A]]
  implicit def validator[A: Schema]: Validator[Items[A]] = schema.validator
}

Results in the following openapi spec:

    Items_A:
      required:
      - total
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/TransactionInfo'
        total:
          type: integer

And then Items_A is referenced not only where Items[TransactionInfo] is used but everywhere Items[X] appears.

Additional information

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions