有没有人知道如何使用无形的测试工作。使用无形的类型级别过滤
package net.jtownson.swakka.jsonschema
import org.scalatest.FlatSpec
import org.scalatest.Matchers._
class OptionalFieldSpec extends FlatSpec {
case class A(i: Int, j: Option[Int])
"an extractor of some kind" should "get the (non)optional fields from a case class" in {
extractNonOptionalFieldNames[A] shouldBe List("i")
extractOptionalFieldNames[A] shouldBe List("j")
}
def extractNonOptionalFieldNames[T <: Product](/* implicit typeclass instances? */): List[String] = ???
def extractOptionalFieldNames[T <: Product]: List[String] = ???
}
我有一个不运行时实例或它的仿制药,因为我在对的情况下A类,它是独立于任何特定实例的创建工作JsonSchema。该模式有一个所需的字段,该字段是非可选字段的列表。例如
{
"type" -> "object",
"required" -> ["i"],
"properties" -> {
"i" -> {
"type" -> "integer",
"format" -> "int32"
}
}
}
你想'LabelledGeneric' - 这将使你的字段名的类型级证人,以及它们的类型。除此之外,似乎你只是想过滤这个HList。 – Alec