{"id":17004644,"url":"https://github.com/dinoboff/schemabuilder","last_synced_at":"2026-05-16T00:39:40.130Z","repository":{"id":20483056,"uuid":"23761087","full_name":"dinoboff/schemabuilder","owner":"dinoboff","description":"Helper to build json schema definitions","archived":false,"fork":false,"pushed_at":"2015-01-06T16:07:20.000Z","size":180,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T12:58:09.150Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dinoboff.png","metadata":{"files":{"readme":"README.rst","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}},"created_at":"2014-09-07T13:58:32.000Z","updated_at":"2015-01-06T16:07:20.000Z","dependencies_parsed_at":"2022-07-31T21:38:06.960Z","dependency_job_id":null,"html_url":"https://github.com/dinoboff/schemabuilder","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinoboff%2Fschemabuilder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinoboff%2Fschemabuilder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinoboff%2Fschemabuilder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinoboff%2Fschemabuilder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dinoboff","download_url":"https://codeload.github.com/dinoboff/schemabuilder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244937835,"owners_count":20535127,"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-10-14T04:44:06.270Z","updated_at":"2025-10-24T22:03:48.642Z","avatar_url":"https://github.com/dinoboff.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"===================\nJSON-Schema builder\n===================\n\nHelpers to build you define JSON schema for either validation or publication.\n\nRequirements\n============\n\nIt requires Python 2.7 and ``jsonschema``. ``jsonschema`` or ``setuptools``\nshould be installed with Python.\n\n\nInstall\n=======\n\nUsing pip::\n\n    pip install schemabuilder\n\nOr easy_install::\n\n    easty_install schemabuilder\n\n\nYou may install it manually::\n\n    git clone https://github.com/dinoboff/schemabuilder.git\n    cd schemabuilder\n    python setup.py install\n\n\nUsage\n=====\n\nPrimitives\n----------\n\nJSON schema primitives are represented by object of type:\n\n* ``schemabuilder.Str``\n* ``schemabuilder.Bool``\n* ``schemabuilder.Number``\n* ``schemabuilder.Int``\n* ``schemabuilder.Object``\n* ``schemabuilder.Array``\n\n\n.. code-block:: python\n\n    \u003e\u003e\u003e import schemabuilder as jsb\n    \u003e\u003e\u003e import pprint\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e name = jsb.Str(pattern=\"^[a-zA-Z][- 'a-zA-Z0-9]+\")\n    \u003e\u003e\u003e email = jsb.Str(format=\"email\")\n    \u003e\u003e\u003e user = jsb.Object(properties={\n    ...   'name': name(required=True),\n    ...   'email': email(),\n    ...   'home': jsb.Str(format='uri'),\n    ... })\n    \u003e\u003e\u003e pprint.pprint(user.to_dict())\n    {'properties': {'email': {'type': 'string'},\n                    'home': {'format': 'uri', 'type': 'string'},\n                    'name': {'type': 'string'}},\n     'required': ['name'],\n     'type': 'object'}\n\n\nSchema\n------\n\nSchema collects those definitions for validation (using ``jsonschema``) or\npublication.\n\n.. code-block:: python\n\n    \u003e\u003e\u003e import schemabuilder as jsb\n    \u003e\u003e\u003e import pprint\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e my_schemas = jsb.Schema(id='http://example.com/schemas.json#')\n    \u003e\u003e\u003e name = my_schemas.define(\n    ...   'name', jsb.Str(pattern=\"^[a-zA-Z][- 'a-zA-Z0-9]+\")\n    ... )\n    \u003e\u003e\u003e email = my_schemas.define('email', jsb.Str(format=\"email\"))\n    \u003e\u003e\u003e user = my_schemas.define('user', jsb.Object(properties={\n    ...   'name': name(required=True),\n    ...   'email': email(required=True),\n    ... }))\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e user.validate({'name': 'bob'})\n    Traceback (most recent call last):\n      File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\n      File \"schemabuilder/schema.py\", line 50, in validate\n        validator.validate(data)\n      File \"/Users/bob/pyenv/lib/python2.7/site-packages/jsonschema/validators.py\", line 117, in validate\n        raise error\n    jsonschema.exceptions.ValidationError: 'email' is a required property\n    \n    Failed validating 'required' in schema:\n        {'properties': {'email': {'$ref': '#/definitions/email'},\n                        'name': {'$ref': '#/definitions/name'}},\n         'required': ['name', 'email'],\n         'type': 'object'}\n    \n    On instance:\n        {'name': 'bob'}\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e user.validate({'name': 'bob', 'email': 'bob@example.com'})\n    \u003e\u003e\u003e\n    \u003e\u003e\u003e import json\n    \u003e\u003e\u003e print json.dumps(my_schemas.to_dict(), indent=4)\n    {\n        \"definitions\": {\n            \"email\": {\n                \"type\": \"string\", \n                \"format\": \"email\"\n            }, \n            \"user\": {\n                \"required\": [\n                    \"name\", \n                    \"email\"\n                ], \n                \"type\": \"object\", \n                \"properties\": {\n                    \"name\": {\n                        \"$ref\": \"#/definitions/name\"\n                    }, \n                    \"email\": {\n                        \"$ref\": \"#/definitions/email\"\n                    }\n                }\n            }, \n            \"name\": {\n                \"pattern\": \"^[a-zA-Z][- 'a-zA-Z0-9]+\", \n                \"type\": \"string\"\n            }\n        }, \n        \"id\": \"http://example.com/schemas.json#\", \n        \"$schema\": \"http://json-schema.org/draft-04/schema#\"\n    }\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdinoboff%2Fschemabuilder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdinoboff%2Fschemabuilder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdinoboff%2Fschemabuilder/lists"}