diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 57b5ada..30380d9 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -9,3 +9,6 @@ # Scala Steward: Reformat with scalafmt 3.8.2 c1761dd17f98157d61fc8639d12803b6eafc1346 + +# Scala Steward: Reformat with scalafmt 3.8.6 +8d4a7e5b2b3fd99670574854b1fe2c3e531a1f1f diff --git a/.scalafmt.conf b/.scalafmt.conf index 1acea3e..f0e328c 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = 3.8.3 +version = 3.8.6 maxColumn = 140 rewrite.rules = [RedundantBraces, RedundantParens, SortImports] runner.dialect = scala3 diff --git a/build.sbt b/build.sbt index 24d0dca..afad9d6 100644 --- a/build.sbt +++ b/build.sbt @@ -104,9 +104,8 @@ lazy val examples = (projectMatrix in file("examples")) .dependsOn(ox) val compileDocs: TaskKey[Unit] = taskKey[Unit]("Compiles docs module throwing away its output") -compileDocs := { +compileDocs := (docs.jvm(scala2.head) / mdoc).toTask(" --out target/sttp-openai-docs").value -} lazy val docs = (projectMatrix in file("generated-docs")) // important: it must not be docs/ .enablePlugins(MdocPlugin) diff --git a/core/src/main/scala/sttp/openai/requests/completions/chat/ChatRequestBody.scala b/core/src/main/scala/sttp/openai/requests/completions/chat/ChatRequestBody.scala index a95d5ba..4901451 100644 --- a/core/src/main/scala/sttp/openai/requests/completions/chat/ChatRequestBody.scala +++ b/core/src/main/scala/sttp/openai/requests/completions/chat/ChatRequestBody.scala @@ -33,15 +33,12 @@ object ChatRequestBody { /** OpenAI's JSON schema support imposes two requirements: * - * 1. All fields must be `required`: - * https://platform.openai.com/docs/guides/structured-outputs/all-fields-must-be-required - * + * 1. All fields must be `required`: https://platform.openai.com/docs/guides/structured-outputs/all-fields-must-be-required * 2. `additionalProperties: false` must always be set in objects: * https://platform.openai.com/docs/guides/structured-outputs/additionalproperties-false-must-always-be-set-in-objects * - * We implement these by folding over the JSON structure. - * However, if a schema uses discriminated unions (indicated by a `discriminator` property), - * we skip forcing `additionalProperties: false` to preserve flexibility in selecting sub-schemas. + * We implement these by folding over the JSON structure. However, if a schema uses discriminated unions (indicated by a + * `discriminator` property), we skip forcing `additionalProperties: false` to preserve flexibility in selecting sub-schemas. */ private val schemaFolder: Json.Folder[Json] = new Json.Folder[Json] { lazy val onNull = Json.Null @@ -50,21 +47,20 @@ object ChatRequestBody { def onString(value: String): Json = Json.fromString(value) def onArray(value: Vector[Json]): Json = Json.fromValues(value.map(_.foldWith(this))) def onObject(value: JsonObject): Json = { - val state = value.toList.foldRight(FolderState(Nil, false, Nil)) { - case ((k, v), acc) => - if (k == "properties") - acc.copy( - fields = (k, v.foldWith(this)) :: acc.fields, - addAdditionalProperties = true, - requiredProperties = v.asObject.fold(List.empty[String])(_.keys.toList) - ) - else if (k == "type") - acc.copy( - fields = (k, v.foldWith(this)) :: acc.fields, - addAdditionalProperties = acc.addAdditionalProperties || v.asString.contains("object") - ) - else - acc.copy(fields = (k, v.foldWith(this)) :: acc.fields) + val state = value.toList.foldRight(FolderState(Nil, false, Nil)) { case ((k, v), acc) => + if (k == "properties") + acc.copy( + fields = (k, v.foldWith(this)) :: acc.fields, + addAdditionalProperties = true, + requiredProperties = v.asObject.fold(List.empty[String])(_.keys.toList) + ) + else if (k == "type") + acc.copy( + fields = (k, v.foldWith(this)) :: acc.fields, + addAdditionalProperties = acc.addAdditionalProperties || v.asString.contains("object") + ) + else + acc.copy(fields = (k, v.foldWith(this)) :: acc.fields) } // Detect if this object is part of a discriminated union by checking for a "discriminator" property.