diff --git a/README.md b/README.md index d66f45c..3de5d9f 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ libraryDependencies += "io.github.ramytanios" %% "json-schema-lib" % "" - **Map support** - `Map[String, V]` maps to `{ "type": "object", "additionalProperties": ... }` - **Option support** - Optional fields automatically excluded from required list - **Circe integration** - Built-in JSON encoding for schemas +- **`$schema` declaration** - Annotate the root schema with a JSON Schema draft URI via `withSchemaVersion` ## Example @@ -56,13 +57,16 @@ case class Profile( // object Profile: // given JsonSchema[Profile] = DeriveJsonSchema.derived -val json = JsonSchema[Profile].schema.toJson +val json = JsonSchema[Profile].schema + .withSchemaVersion(JsonSchemaVersion.Draft202012) + .toJson ``` **Generated JSON Schema:** ```json { + "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "title": "User profile", "properties": { diff --git a/build.sbt b/build.sbt index 906e256..a53cf2c 100644 --- a/build.sbt +++ b/build.sbt @@ -23,13 +23,15 @@ ThisBuild / scmInfo := Some( ) lazy val V = new { - val circe = "0.14.15" - val munit = "1.2.1" + val circe = "0.14.15" + val munit = "1.2.1" + val http4s = "0.23.30" + val catsEffect = "3.5.4" } lazy val root = (project in file(".")) - .aggregate(libJVM, libJS) + .aggregate(libJVM, libJS, excel, excelExample) .settings(publish / skip := true) lazy val lib = crossProject(JSPlatform, JVMPlatform) @@ -52,3 +54,31 @@ lazy val lib = crossProject(JSPlatform, JVMPlatform) lazy val libJVM = lib.jvm lazy val libJS = lib.js + +lazy val excel = + (project in file("excel")) + .dependsOn(libJVM) + .settings( + name := "json-schema-lib-excel", + libraryDependencies ++= Seq( + "io.circe" %% "circe-core" % V.circe, + "org.http4s" %% "http4s-dsl" % V.http4s, + "org.typelevel" %% "cats-effect" % V.catsEffect, + "org.scalameta" %% "munit" % V.munit % Test + ), + scalacOptions -= "-Xfatal-warnings" + ) + +lazy val excelExample = + (project in file("excel-example")) + .dependsOn(excel) + .settings( + name := "json-schema-lib-excel-example", + publish / skip := true, + libraryDependencies ++= Seq( + "org.http4s" %% "http4s-ember-server" % V.http4s, + "org.http4s" %% "http4s-ember-client" % V.http4s, + "org.http4s" %% "http4s-circe" % V.http4s, + ), + scalacOptions -= "-Xfatal-warnings" + ) diff --git a/excel-example/manifest.xml b/excel-example/manifest.xml new file mode 100644 index 0000000..671235b --- /dev/null +++ b/excel-example/manifest.xml @@ -0,0 +1,137 @@ + + + + + + a1b2c3d4-e5f6-7890-abcd-ef1234567891 + 1.0.0.0 + ExcelMain (local dev) + en-US + + + + + + + + + + + + + + + + + + + + + + + ReadWriteDocument + + + + + + + + + + + + + + + + + + + + + + + + + + +