{"id":17299189,"url":"https://github.com/fiorix/jsonschema2go","last_synced_at":"2025-03-22T18:34:42.858Z","repository":{"id":57498579,"uuid":"143656840","full_name":"fiorix/jsonschema2go","owner":"fiorix","description":"Code generator for JSON schema","archived":false,"fork":false,"pushed_at":"2018-11-07T23:18:27.000Z","size":36,"stargazers_count":39,"open_issues_count":1,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-18T14:04:47.279Z","etag":null,"topics":["code-generation","golang","json-schema","thrift"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fiorix.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}},"created_at":"2018-08-06T00:09:28.000Z","updated_at":"2024-09-13T14:11:15.000Z","dependencies_parsed_at":"2022-09-06T16:22:21.880Z","dependency_job_id":null,"html_url":"https://github.com/fiorix/jsonschema2go","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/fiorix%2Fjsonschema2go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiorix%2Fjsonschema2go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiorix%2Fjsonschema2go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiorix%2Fjsonschema2go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fiorix","download_url":"https://codeload.github.com/fiorix/jsonschema2go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245003788,"owners_count":20545661,"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":["code-generation","golang","json-schema","thrift"],"created_at":"2024-10-15T11:21:30.251Z","updated_at":"2025-03-22T18:34:42.583Z","avatar_url":"https://github.com/fiorix.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jsonschema2go\n\n[![Build Status](https://secure.travis-ci.org/fiorix/jsonschema2go.png)](http://travis-ci.org/fiorix/jsonschema2go)\n\njsonschema2go is a code generator for JSON schemas. Supports schemas from local files or URL, and generates Go code, or thrift spec.\n\nThis is a very naive and incomplete implementation. I wrote this code specifically to codegen the [NVD JSON schema](https://nvd.nist.gov/vuln/data-feeds#JSON_FEED), based on a few requirements:\n\n* The output is a single file\n* Consistent output given same input\n* Capable of generating at least Go and Thrift\n\n### Download, install\n\nRequires Go 1.10 or newer. The generated thrift spec requires thrift compiler 0.11 or newer.\n\nAssuming you have a working Go environment:\n\n```\ngo get github.com/fiorix/jsonschema2go\ngo install github.com/fiorix/jsonschema2go\n```\n\nOutput binary is $GOPATH/bin/jsonschema2go.\n\n### Usage\n\n```\nuse: ./jsonschema2go [flags] schema.json\nThe input schema may be a local file or URL.\n  -gen string\n    \tset output format: go, thrift (default \"go\")\n  -gofmt\n    \trun gofmt on generated go code\n  -gopkg string\n    \tset name of generated go package (default \"schema\")\n  -goptr\n    \tgenerate go struct fields as pointers\n  -o string\n    \tset name of output file (default \"-\")\n  -thriftns string\n    \tset comma separated list of thrift namespaces (default \"go schema,py schema\")\n```\n\n---\n\nGenerate Go code:\n\n```\njsonschema2go -gen go https://csrc.nist.gov/schema/nvd/feed/1.0/nvd_cve_feed_json_1.0.schema\n```\n\nGenerate Thrift spec:\n\n```\njsonschema2go -gen thrift https://csrc.nist.gov/schema/nvd/feed/1.0/nvd_cve_feed_json_1.0.schema\n```\n\n### Generated type names\n\nNaming is hard. In jsonschema2go I made the choice to name generated Go and Thrift types after their respective filenames. In JSON schema, the body of the document is a type, like a struct, and it has no name. Hence using the filename with some normalization to idiomatic Go, with an adjusted list of keywords (e.g. CVE) for initialisms.\n\nYou can see what it looks like in the golden files in the testdata directory.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffiorix%2Fjsonschema2go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffiorix%2Fjsonschema2go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffiorix%2Fjsonschema2go/lists"}