{"id":20049442,"url":"https://github.com/weaming/json-schema-generator","last_synced_at":"2025-03-02T08:25:34.461Z","repository":{"id":62572926,"uuid":"138606661","full_name":"weaming/json-schema-generator","owner":"weaming","description":" Generate the initial json schema from your given example json.","archived":false,"fork":false,"pushed_at":"2019-05-28T11:16:43.000Z","size":15,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-13T04:48:04.621Z","etag":null,"topics":["json","json-schema","tool"],"latest_commit_sha":null,"homepage":"","language":"Python","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/weaming.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}},"created_at":"2018-06-25T14:31:36.000Z","updated_at":"2019-05-28T11:16:45.000Z","dependencies_parsed_at":"2022-11-04T07:38:21.789Z","dependency_job_id":null,"html_url":"https://github.com/weaming/json-schema-generator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Fjson-schema-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Fjson-schema-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Fjson-schema-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Fjson-schema-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weaming","download_url":"https://codeload.github.com/weaming/json-schema-generator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241479599,"owners_count":19969479,"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","tool"],"created_at":"2024-11-13T11:50:01.160Z","updated_at":"2025-03-02T08:25:34.394Z","avatar_url":"https://github.com/weaming.png","language":"Python","readme":"# JSON schema generator\n\nGenerate the initial json schema from your given example json.\n\n## Install\n\n    pip install json-schema-generator2\n\n## Usage\n\n```\n$ generate-json-schema help\n Usage:\n    cat sample.json | generate-json-schema\n    generate-json-schema sample.json\n    generate-json-schema sample.json \u003e output.schema.json\n```\n\n## Envrioment variables\n\n* `JSON_SCHEMA_ID`\n* `JSON_SCHEMA_TITLE`\n\n## Special rules to determine the type\n\n* suffix definitions\n    * `?`: optional\n    * `!`: `enum`\n    * `!?`: optional `enum`\n    * default: based on sample value\n* Will update `~/.config/json-schema-generator/extra.json` to every generated object.\n\n## Example\n\n```json\n{\n  \"account\": {\n    \"name\": \"\",\n    \"telephone?\": \"\",\n    \"nationality!?\": \"CHN\",\n    \"address?\": \"\",\n    \"city\": \"\",\n    \"state\": \"\",\n    \"zip code\": \"\",\n    \"balance\": 100,\n    \"child\": [{\n        \"name\": \"\",\n        \"age\": 18,\n        \"gender!\": \"BOY\"\n    }],\n    \"hobby\": [],\n    \"favorite numbers\": [3.14]\n  }\n}\n\n```\n\nAnd the content of `extra.json`:\n\n```\n{\n    \"title\": \"example title\",\n    \"description\": \"example description\"\n}\n```\n\nWill produce:\n\n```json\n{\n  \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"account\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"name\": {\n          \"type\": \"string\"\n        },\n        \"telephone\": {\n          \"type\": \"string\"\n        },\n        \"nationality\": {\n          \"type\": \"string\",\n          \"enum\": [\n            \"CHN\"\n          ]\n        },\n        \"address\": {\n          \"type\": \"string\"\n        },\n        \"city\": {\n          \"type\": \"string\"\n        },\n        \"state\": {\n          \"type\": \"string\"\n        },\n        \"zip code\": {\n          \"type\": \"string\"\n        },\n        \"balance\": {\n          \"type\": \"integer\"\n        },\n        \"child\": {\n          \"type\": \"array\",\n          \"items\": {\n            \"type\": \"object\",\n            \"properties\": {\n              \"name\": {\n                \"type\": \"string\"\n              },\n              \"age\": {\n                \"type\": \"integer\"\n              },\n              \"gender\": {\n                \"type\": \"string\",\n                \"enum\": [\n                  \"BOY\"\n                ]\n              }\n            },\n            \"required\": [\n              \"name\",\n              \"age\",\n              \"gender\"\n            ],\n            \"additionalProperties\": false,\n            \"title\": \"example title\",\n            \"description\": \"example description\"\n          }\n        },\n        \"hobby\": {\n          \"type\": \"array\"\n        },\n        \"favorite numbers\": {\n          \"type\": \"array\",\n          \"items\": {\n            \"type\": \"number\"\n          }\n        }\n      },\n      \"required\": [\n        \"name\",\n        \"city\",\n        \"state\",\n        \"zip code\",\n        \"balance\",\n        \"child\",\n        \"hobby\",\n        \"favorite numbers\"\n      ],\n      \"additionalProperties\": false,\n      \"title\": \"example title\",\n      \"description\": \"example description\"\n    }\n  },\n  \"required\": [\n    \"account\"\n  ],\n  \"additionalProperties\": false,\n  \"title\": \"example title\",\n  \"description\": \"example description\"\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweaming%2Fjson-schema-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweaming%2Fjson-schema-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweaming%2Fjson-schema-generator/lists"}