{"id":15211468,"url":"https://github.com/tariel-x/polyschema","last_synced_at":"2026-03-08T18:32:15.967Z","repository":{"id":81192608,"uuid":"146183522","full_name":"tariel-x/polyschema","owner":"tariel-x","description":"JSON-Schema based type resolver for golang","archived":false,"fork":false,"pushed_at":"2018-09-01T22:37:48.000Z","size":20,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-12-14T14:10:31.832Z","etag":null,"topics":["json","json-schema","polymorphism","subtyping","type-checker","type-system","types"],"latest_commit_sha":null,"homepage":"","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/tariel-x.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":"2018-08-26T13:36:45.000Z","updated_at":"2024-06-19T10:21:20.273Z","dependencies_parsed_at":null,"dependency_job_id":"fac4b52f-4836-4899-a519-ca4da1d16900","html_url":"https://github.com/tariel-x/polyschema","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/tariel-x%2Fpolyschema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tariel-x%2Fpolyschema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tariel-x%2Fpolyschema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tariel-x%2Fpolyschema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tariel-x","download_url":"https://codeload.github.com/tariel-x/polyschema/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242988055,"owners_count":20217539,"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":["json","json-schema","polymorphism","subtyping","type-checker","type-system","types"],"created_at":"2024-09-28T08:41:39.091Z","updated_at":"2025-12-06T18:01:09.545Z","avatar_url":"https://github.com/tariel-x.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Polyschema\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/tariel-x/polyschema)](https://goreportcard.com/report/github.com/tariel-x/polyschema)\n\nJSON-Schema based type resolver for golang.\n\nType here is any standard json-schema. However standard specification do not consider \nany other cases except data validation via schema. This library provides realization of \nsubtyping and type-checking concept for schemas.\n\nSubtype `B` of type `A` here is the new schema describing document `b` which can be \nsuccessfully valided with both `A` and `B`. Though document `a` described by `A` is not \ncommitted to be valid for schema `B`. This is called structural type system.\n\n### Example\n\n**Type A**\n\n```json\n{ \"type\": \"string\" }\n```\n\n**Type B**\n\n```json\n{ \"type\": \"string\", \"maxLength\": 10 }\n```\n\n**Type C**\n\n```json\n{ \"type\": \"integer\" }\n```\n\nType `B` is the subtype of `A`: `A :\u003e B`. \nBut `C` is neither subtype not equal type of `A`.\n\n### Complex example\n\n**Type A**\n\n```json\n{\n  \"title\": \"Person\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"name\": {\n      \"type\": \"string\"\n    }\n  },\n  \"required\": [\n    \"name\"\n  ]\n}\n```\n\n**Type B**\n\n```json\n{\n  \"title\": \"Student\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"name\": {\n      \"type\": \"string\"\n    },\n    \"course\": {\n      \"type\": \"integer\"\n    }\n  },\n  \"required\": [\n    \"name\",\n    \"course\"\n  ]\n}\n```\n\n**Type C**\n\n```json\n{\n  \"title\": \"Person_not_strict\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"name\": {\n      \"type\": \"string\"\n    }\n  }\n}\n```\n\nType `B` is the subtype of `A`: `A :\u003e B`. \nBut `C` is neither subtype not equal type of `A`.\n\n## Usage of the package\n\nInstall\n\n`go get -u github.com/tariel-x/polyschema`\n\nUse\n\n```go\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\n\t\"github.com/tariel-x/polyschema\"\n)\n\nfunc main() {\n\ttypeA := polyschema.JsonSchema{}\n\ttypeB := polyschema.JsonSchema{}\n\ttypeC := polyschema.JsonSchema{}\n\n\tjson.Unmarshal([]byte(`{ \"type\": \"string\" }`), \u0026typeA)\n\tjson.Unmarshal([]byte(`{ \"type\": \"string\", \"maxLength\": 10 }`), \u0026typeB)\n\tjson.Unmarshal([]byte(`{ \"type\": \"integer\" }`), \u0026typeC)\n\n\tfmt.Println(\"A :\u003e B \", polyschema.Subtype(typeA, typeB)) // 1, that means subtype\n\tfmt.Println(\"A :\u003e C \", polyschema.Subtype(typeA, typeC)) // -1, that means not subtype\n\tfmt.Println(\"A = A \", polyschema.Subtype(typeA, typeA)) // 0, that means identity\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftariel-x%2Fpolyschema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftariel-x%2Fpolyschema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftariel-x%2Fpolyschema/lists"}