{"id":15102724,"url":"https://github.com/lowmelvin/scala-json-schema","last_synced_at":"2026-02-10T16:16:37.102Z","repository":{"id":256085287,"uuid":"854258398","full_name":"lowmelvin/scala-json-schema","owner":"lowmelvin","description":"Scala to Json Schema. Lite.","archived":false,"fork":false,"pushed_at":"2024-12-13T16:00:08.000Z","size":50,"stargazers_count":1,"open_issues_count":8,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T13:45:45.461Z","etag":null,"topics":["circe","json-schema","scala","scala3"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lowmelvin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-08T19:37:26.000Z","updated_at":"2024-12-13T16:00:13.000Z","dependencies_parsed_at":"2024-10-20T21:22:23.190Z","dependency_job_id":"28ffd650-4b61-40af-b788-d64b662ed120","html_url":"https://github.com/lowmelvin/scala-json-schema","commit_stats":{"total_commits":17,"total_committers":2,"mean_commits":8.5,"dds":0.3529411764705882,"last_synced_commit":"d83de1f6d369aac381e467cd64b3e09a7e008164"},"previous_names":["lowmelvin/scala-json-schema"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/lowmelvin/scala-json-schema","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lowmelvin%2Fscala-json-schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lowmelvin%2Fscala-json-schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lowmelvin%2Fscala-json-schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lowmelvin%2Fscala-json-schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lowmelvin","download_url":"https://codeload.github.com/lowmelvin/scala-json-schema/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lowmelvin%2Fscala-json-schema/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280526792,"owners_count":26345572,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-22T02:00:06.515Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["circe","json-schema","scala","scala3"],"created_at":"2024-09-25T19:05:26.533Z","updated_at":"2025-10-22T22:31:40.606Z","avatar_url":"https://github.com/lowmelvin.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Scala Json Schema (Lite)\n\nThis is a minimal library to generate JSON schema from Scala ADTs.\nIt is built on top of [circe](https://circe.github.io/circe/).\n\nTo reduce complexity and maintenance, this library\ndoes the absolute minimum: It will traverse your ADT and generate\na schema with nested types and properties. No other fields are included.\n\nProduct types get the type `object` and sum types are converted into `anyOf`.\n\nYou can inject all other fields via annotation.\nAs intended, there is zero validation--you can do whatever you want.\n\n## Installation\n\nThis library is built for Scala 3.\n\n```scala\nlibraryDependencies += \"com.melvinlow\" %% \"scala-json-schema\" % \"\u003cVERSION\u003e\"\n```\n\n## Examples:\n\nEncode a product:\n\n```scala\nimport com.melvinlow.json.schema.*\nimport com.melvinlow.json.schema.generic.auto.given\n\ncase class Foo(x: Int, y: String)\n\nJsonSchema[Foo].spaces2\n// res0: String = \"\"\"{\n//   \"type\" : \"object\",\n//   \"properties\" : {\n//     \"x\" : {\n//       \"type\" : \"integer\"\n//     },\n//     \"y\" : {\n//       \"type\" : \"string\"\n//     }\n//   }\n// }\"\"\"\n```\n\nEncode a coproduct:\n\n```scala\nenum Bar:\n  case A, B\n\nJsonSchema[Bar].spaces2\n// res1: String = \"\"\"{\n//   \"anyOf\" : [\n//     {\n//       \"type\" : \"object\",\n//       \"properties\" : {\n//         \n//       }\n//     },\n//     {\n//       \"type\" : \"object\",\n//       \"properties\" : {\n//         \n//       }\n//     }\n//   ]\n// }\"\"\"\n```\n\nAdd fields via annotation (it takes as input any `String` and `Json` key-value pair):\n\n```scala\nimport com.melvinlow.json.schema.annotation.JsonSchemaField\nimport io.circe.Json\nimport io.circe.syntax.*\n\n@JsonSchemaField(\"title\", \"dog\".asJson)\n@JsonSchemaField(\"required\", Array(\"name\").asJson)\ncase class Dog(\n  @JsonSchemaField(\"minLength\", 1.asJson)\n  name: String\n)\n\nJsonSchema[Dog].spaces2\n// res2: String = \"\"\"{\n//   \"required\" : [\n//     \"name\"\n//   ],\n//   \"title\" : \"dog\",\n//   \"type\" : \"object\",\n//   \"properties\" : {\n//     \"name\" : {\n//       \"minLength\" : 1,\n//       \"type\" : \"string\"\n//     }\n//   }\n// }\"\"\"\n```\n\nCreate an encoder for a new type:\n\n```scala\nobject H:\n  @JsonSchemaField(\"description\", \"my custom int\".asJson)\n  opaque type MyInt = Int\n\ngiven JsonSchemaEncoder[H.MyInt] with\n  def schema: Json =\n    val base = Json.obj(\"type\" -\u003e \"integer\".asJson)\n    val annotations = JsonSchemaField.onType[H.MyInt]\n    base.deepMerge(Json.obj(annotations*))\n\nJsonSchema[H.MyInt].spaces2\n// res3: String = \"\"\"{\n//   \"description\" : \"my custom int\",\n//   \"type\" : \"integer\"\n// }\"\"\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flowmelvin%2Fscala-json-schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flowmelvin%2Fscala-json-schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flowmelvin%2Fscala-json-schema/lists"}