softwaremill / softwaremill/tapir

Derived schema name for `List[T]` is `scala.collection.immutable.:: [BUG]

Open
#3,194 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
1.5k
Forks
468
Avg merge
5h 37m
Merged PRs (30d)
34

Description

Tapir version: 1.7.3

Scala version: 2.12.15

When deriving a List[T] where T is defined inside of a companion object, the generated schema for List[T] is scala.collection.immutable.:: { head, tl }

How to reproduce?

import sttp.tapir.Schema
import sttp.tapir.generic.auto._

object TestSchema extends App {

  case class Container(values: List[Container.Value])

  object Container {
    case class Value(key: String, value: String)
  }

  case class Root(containers: List[Container])
  val s = implicitly[Schema[Root]]

  println(s.show)
}

This prints:

schema is SProduct(List(SProductField(FieldName(containers,containers),Schema(SArray(Schema(SProduct(List(SProductField(FieldName(values,values),Schema(SCoproduct(List(Schema(SProduct(List(SProductField(FieldName(head,head),Schema(SProduct(List(SProductField(FieldName(key,key),Schema(SString(),None,false,None,None,None,None,false,false,All(List()),AttributeMap(Map()))), SProductField(FieldName(value,value),Schema(SString(),None,false,None,None,None,None,false,false,All(List()),AttributeMap(Map()))))),Some(SName(whoco.sourcing.services.chat.TestSchema.Container.Value,List())),false,None,None,None,None,false,false,All(List()),AttributeMap(Map()))), SProductField(FieldName(tl,tl),Schema(SRef(SName(scala.collection.immutable.List,List(Value))),None,false,None,None,None,None,false,false,All(List()),AttributeMap(Map()))))),Some(SName(scala.collection.immutable.::,List(Value))),false,None,None,None,None,false,false,All(List()),AttributeMap(Map())), Schema(SProduct(List()),Some(SName(scala.collection.immutable.Nil,List())),false,None,None,None,None,false,false,All(List()),AttributeMap(Map()))),None),Some(SName(scala.collection.immutable.List,List(Value))),false,None,None,None,None,false,false,All(List()),AttributeMap(Map()))))),Some(SName(whoco.sourcing.services.chat.TestSchema.Container,List())),false,None,None,None,None,false,false,All(List()),AttributeMap(Map()))),None,true,None,None,None,None,false,false,All(List()),AttributeMap(Map())))))

Note the references to the implementation details of Scala List.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Scala reproduction using sttp.tapir.Schema and sttp.tapir.generic.auto._, then trace the schema derivation entry points for List[T] and companion-object types. Done means deriving Container and Root no longer exposes scala.collection.immutable.:: or other List implementation details in the generated schema.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
api, backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.