Skip to content

Commit

Permalink
extension -> extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
armanbilge committed Sep 10, 2023
1 parent 34bb537 commit 37d9a9c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions modules/core/src/main/scala/problem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final case class Problem(
message: String,
locations: List[(Int, Int)] = Nil,
path: List[String] = Nil,
extension: Option[JsonObject] = None,
extensions: Option[JsonObject] = None,
) {

override def toString = {
Expand All @@ -32,7 +32,7 @@ final case class Problem(
case (false, false) => message
}

extension.fold(s)(obj => s"$s, extension: ${obj.asJson.spaces2}")
extensions.fold(s)(obj => s"$s, extensions: ${obj.asJson.spaces2}")

}

Expand All @@ -58,14 +58,14 @@ object Problem {
if (p.path.isEmpty) Nil
else List(("path" -> p.path.asJson))

val extensionField: List[(String, Json)] =
p.extension.fold(List.empty[(String, Json)])(obj => List("extension" -> obj.asJson))
val extensionsField: List[(String, Json)] =
p.extensions.fold(List.empty[(String, Json)])(obj => List("extensions" -> obj.asJson))

Json.fromFields(
"message" -> p.message.asJson ::
locationsField :::
pathField :::
extensionField
extensionsField
)

}
Expand Down
4 changes: 2 additions & 2 deletions modules/core/src/test/scala/compiler/ProblemSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ final class ProblemSuite extends CatsEffectSuite {
}

test("extension") {
val p = Problem("foo", extension = Some(JsonObject("bar" -> 42.asJson, "baz" -> List("a", "b").asJson)))
val p = Problem("foo", extensions = Some(JsonObject("bar" -> 42.asJson, "baz" -> List("a", "b").asJson)))
assertEquals(
p.asJson, json"""
{
"message" : "foo",
"extension" : {
"extensions" : {
"bar" : 42,
"baz" : [
"a",
Expand Down

0 comments on commit 37d9a9c

Please sign in to comment.