Skip to content

Commit c43095e

Browse files
algolia-botmillotp
andcommitted
fix(specs): typoTolerance can be a boolean string (generated)
algolia/api-clients-automation#4900 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Pierre Millot <pierre.millot@algolia.com>
1 parent cd1b5aa commit c43095e

File tree

6 files changed

+32
-20
lines changed

6 files changed

+32
-20
lines changed

src/main/scala/algoliasearch/recommend/Distinct.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,35 +41,35 @@ sealed trait Distinct
4141

4242
object Distinct {
4343

44-
case class BooleanValue(value: Boolean) extends Distinct
45-
4644
case class IntValue(value: Int) extends Distinct
4745

48-
def apply(value: Boolean): Distinct = {
49-
Distinct.BooleanValue(value)
50-
}
46+
case class BooleanValue(value: Boolean) extends Distinct
5147

5248
def apply(value: Int): Distinct = {
5349
Distinct.IntValue(value)
5450
}
5551

52+
def apply(value: Boolean): Distinct = {
53+
Distinct.BooleanValue(value)
54+
}
55+
5656
}
5757

5858
object DistinctSerializer extends Serializer[Distinct] {
5959
override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), Distinct] = {
6060

6161
case (TypeInfo(clazz, _), json) if clazz == classOf[Distinct] =>
6262
json match {
63-
case JBool(value) => Distinct.BooleanValue(value)
6463
case JInt(value) => Distinct.IntValue(value.toInt)
64+
case JBool(value) => Distinct.BooleanValue(value)
6565
case _ => throw new MappingException("Can't convert " + json + " to Distinct")
6666
}
6767
}
6868

6969
override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: Distinct =>
7070
value match {
71-
case Distinct.BooleanValue(value) => JBool(value)
7271
case Distinct.IntValue(value) => JInt(value)
72+
case Distinct.BooleanValue(value) => JBool(value)
7373
}
7474
}
7575
}

src/main/scala/algoliasearch/recommend/TypoTolerance.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@ object TypoToleranceSerializer extends Serializer[TypoTolerance] {
5858

5959
case (TypeInfo(clazz, _), json) if clazz == classOf[TypoTolerance] =>
6060
json match {
61-
case JBool(value) => TypoTolerance.BooleanValue(value)
6261
case value: JString => Extraction.extract[TypoToleranceEnum](value)
62+
case JBool(value) => TypoTolerance.BooleanValue(value)
6363
case _ => throw new MappingException("Can't convert " + json + " to TypoTolerance")
6464
}
6565
}
6666

6767
override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: TypoTolerance =>
6868
value match {
69-
case TypoTolerance.BooleanValue(value) => JBool(value)
7069
case value: TypoToleranceEnum => JString(value.toString)
70+
case TypoTolerance.BooleanValue(value) => JBool(value)
7171
}
7272
}
7373
}

src/main/scala/algoliasearch/recommend/TypoToleranceEnum.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ object TypoToleranceEnum {
4545
case object Strict extends TypoToleranceEnum {
4646
override def toString = "strict"
4747
}
48-
val values: Seq[TypoToleranceEnum] = Seq(Min, Strict)
48+
case object `True` extends TypoToleranceEnum {
49+
override def toString = "true"
50+
}
51+
case object `False` extends TypoToleranceEnum {
52+
override def toString = "false"
53+
}
54+
val values: Seq[TypoToleranceEnum] = Seq(Min, Strict, `True`, `False`)
4955

5056
def withName(name: String): TypoToleranceEnum = TypoToleranceEnum.values
5157
.find(_.toString == name)

src/main/scala/algoliasearch/search/Distinct.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,35 +45,35 @@ sealed trait Distinct
4545

4646
object Distinct {
4747

48-
case class BooleanValue(value: Boolean) extends Distinct
49-
5048
case class IntValue(value: Int) extends Distinct
5149

52-
def apply(value: Boolean): Distinct = {
53-
Distinct.BooleanValue(value)
54-
}
50+
case class BooleanValue(value: Boolean) extends Distinct
5551

5652
def apply(value: Int): Distinct = {
5753
Distinct.IntValue(value)
5854
}
5955

56+
def apply(value: Boolean): Distinct = {
57+
Distinct.BooleanValue(value)
58+
}
59+
6060
}
6161

6262
object DistinctSerializer extends Serializer[Distinct] {
6363
override def deserialize(implicit format: Formats): PartialFunction[(TypeInfo, JValue), Distinct] = {
6464

6565
case (TypeInfo(clazz, _), json) if clazz == classOf[Distinct] =>
6666
json match {
67-
case JBool(value) => Distinct.BooleanValue(value)
6867
case JInt(value) => Distinct.IntValue(value.toInt)
68+
case JBool(value) => Distinct.BooleanValue(value)
6969
case _ => throw new MappingException("Can't convert " + json + " to Distinct")
7070
}
7171
}
7272

7373
override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: Distinct =>
7474
value match {
75-
case Distinct.BooleanValue(value) => JBool(value)
7675
case Distinct.IntValue(value) => JInt(value)
76+
case Distinct.BooleanValue(value) => JBool(value)
7777
}
7878
}
7979
}

src/main/scala/algoliasearch/search/TypoTolerance.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,16 @@ object TypoToleranceSerializer extends Serializer[TypoTolerance] {
6262

6363
case (TypeInfo(clazz, _), json) if clazz == classOf[TypoTolerance] =>
6464
json match {
65-
case JBool(value) => TypoTolerance.BooleanValue(value)
6665
case value: JString => Extraction.extract[TypoToleranceEnum](value)
66+
case JBool(value) => TypoTolerance.BooleanValue(value)
6767
case _ => throw new MappingException("Can't convert " + json + " to TypoTolerance")
6868
}
6969
}
7070

7171
override def serialize(implicit format: Formats): PartialFunction[Any, JValue] = { case value: TypoTolerance =>
7272
value match {
73-
case TypoTolerance.BooleanValue(value) => JBool(value)
7473
case value: TypoToleranceEnum => JString(value.toString)
74+
case TypoTolerance.BooleanValue(value) => JBool(value)
7575
}
7676
}
7777
}

src/main/scala/algoliasearch/search/TypoToleranceEnum.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,13 @@ object TypoToleranceEnum {
4949
case object Strict extends TypoToleranceEnum {
5050
override def toString = "strict"
5151
}
52-
val values: Seq[TypoToleranceEnum] = Seq(Min, Strict)
52+
case object `True` extends TypoToleranceEnum {
53+
override def toString = "true"
54+
}
55+
case object `False` extends TypoToleranceEnum {
56+
override def toString = "false"
57+
}
58+
val values: Seq[TypoToleranceEnum] = Seq(Min, Strict, `True`, `False`)
5359

5460
def withName(name: String): TypoToleranceEnum = TypoToleranceEnum.values
5561
.find(_.toString == name)

0 commit comments

Comments
 (0)