{"id":21740168,"url":"https://github.com/bserdar/jsonschema2oca","last_synced_at":"2025-06-10T21:04:22.115Z","repository":{"id":67456091,"uuid":"333619151","full_name":"bserdar/jsonschema2oca","owner":"bserdar","description":"Experimental JSON schema decomposition to OCA","archived":false,"fork":false,"pushed_at":"2021-02-10T04:43:52.000Z","size":7681,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2023-04-30T20:32:49.864Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bserdar.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2021-01-28T02:13:10.000Z","updated_at":"2024-06-19T08:05:17.213Z","dependencies_parsed_at":"2023-05-20T16:30:51.905Z","dependency_job_id":null,"html_url":"https://github.com/bserdar/jsonschema2oca","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bserdar%2Fjsonschema2oca","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bserdar%2Fjsonschema2oca/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bserdar%2Fjsonschema2oca/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bserdar%2Fjsonschema2oca/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bserdar","download_url":"https://codeload.github.com/bserdar/jsonschema2oca/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244717339,"owners_count":20498284,"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","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":[],"created_at":"2024-11-26T06:12:26.085Z","updated_at":"2025-03-21T01:13:16.027Z","avatar_url":"https://github.com/bserdar.png","language":"Go","readme":"# Experimental JSON schema to OCA layers translator\n\nThis tool compiles a JSON schema and decomposes it to OCA-compliant\nlayers. These layers are:\n\n  * Schema base, containing normalized field names and object\n    structure,\n  * An index overlay that assigns names to fields defined in the schema base,\n  * A type overlay that assigns JSON types to the fields of the schema\n    base,\n  * A format overlay that contains the JSON format directives for the\n    fields.\n    \n## OCA Info\n\n\u003e OCA is an architecture that presents a schema as a multi-dimensional object consisting of a stable schema base and interoperable overlays. \n\nOCA information: https://wiki.trustoverip.org/display/HOME/Semantic+Domain+Group\n\nOCA is flat. It is primarily intended for data capture. However, OCA\nmay have many use cases in data exchange/data processing use-cases where\ndata is rarely flat. This RFC proposes changes to the OCA schema to\nsupport nested and array-like structures, that is, JSON:\n\nhttps://github.com/bserdar/oca-spec/tree/format/RFCs/003-bserdar-schema-format\n\nSo if goes from this:\n\n![OCA](img/schema-base-and-overlays.png)\n\nTo this:\n\n![OCA](img/schema-base-and-overlays-linked.png)\n    \n## Building\n\nUse the go build system. Clone the repository and run:\n\n  go build \n\n## Running\n\nAfter building:\n\n```\n  jsonschema2oca \u003centity mappings file\u003e \u003ctarget prefix\u003e\n``` \n  \nThe entity mappings file is a JSON file of the form:\n\n```\n{\n  \"EntityName\" : {\n    \"reference\": \"schema reference\",\n    \"blinding\": [\n       field names,...\n    ]\n  },\n  ...\n}\n```\n\nThe program will write OCA layers for each entity.\n\nFor the FHIR schema this is defined as:\n\n```\n{\n      \"Account\": {\n        \"reference\": \"testdata/fhir.schema.json#/definitions/Account\",\n        \"blinding\": []\n       },\n      ...\n}\n```\n\nThe program builds the schema for each of these entities using their\nschema references, decomposes each entity into its base + overlays,\nand writes the resulting files. \n\nAt this point, the program does not support allOf, anyOf, if,\npatternProperties, additionalItems constructs of the JSON schema.\n\n## Cyclic references\n\nThe program recursively descends the compiled schema. If it detects\nany cycles, it will print this out. You have to break all cycles by\ndefining additional entries in the entity mappings so that cycles can\nbe rewritten as references.\n\nFor instance, if the schema objects are defined as:\n```\n A -\u003e B -\u003e C -\u003e A\n```\n\nand entities as:\n```\n{\n  \"EntityB\" : \"#/B\",\n}\n```\n\nthen the unfolding of B is unbounded. So define another entity to\nbreak the loop:\n\n```\n{\n  \"EntityB\": \"#/B\",\n  \"EntityA\": \"#/A\"\n}\n```\n\nWith this input, the unfolding of B will contain all elements of C,\nbut will have a reference to A.\n\n\n## OCA Compliance\n\nThe generated OCA schemas are compliant to \n\nhttps://github.com/bserdar/oca-spec/tree/format/RFCs/003-bserdar-schema-format\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbserdar%2Fjsonschema2oca","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbserdar%2Fjsonschema2oca","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbserdar%2Fjsonschema2oca/lists"}