{"id":15152770,"url":"https://github.com/redborian/go-types-to-jsonschema","last_synced_at":"2025-08-03T14:09:13.126Z","repository":{"id":57626825,"uuid":"164203774","full_name":"redborian/go-types-to-jsonschema","owner":"redborian","description":"Command-line tool to convert YAML-annotated types specified in go file to JSON schema","archived":false,"fork":false,"pushed_at":"2019-04-09T21:14:13.000Z","size":90,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T00:34:23.113Z","etag":null,"topics":["abstract-syntax-tree","golang","json-schema","yaml"],"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/redborian.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-05T10:15:08.000Z","updated_at":"2022-03-29T05:47:05.000Z","dependencies_parsed_at":"2022-08-31T11:03:54.143Z","dependency_job_id":null,"html_url":"https://github.com/redborian/go-types-to-jsonschema","commit_stats":null,"previous_names":["redborian/go-yaml-to-jsonschema"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redborian%2Fgo-types-to-jsonschema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redborian%2Fgo-types-to-jsonschema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redborian%2Fgo-types-to-jsonschema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redborian%2Fgo-types-to-jsonschema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/redborian","download_url":"https://codeload.github.com/redborian/go-types-to-jsonschema/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237944074,"owners_count":19391588,"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":["abstract-syntax-tree","golang","json-schema","yaml"],"created_at":"2024-09-26T16:22:51.179Z","updated_at":"2025-02-09T11:30:43.869Z","avatar_url":"https://github.com/redborian.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go annotated types to JSON schema converter\n[![Go Report Card](https://goreportcard.com/badge/github.com/redborian/go-types-to-jsonschema)](https://goreportcard.com/report/github.com/redborian/go-types-to-jsonschema)\n[![Go Doc](https://godoc.org/github.com/redborian/go-types-to-jsonschema?status.svg)](https://godoc.org/github.com/redborian/go-types-to-jsonschema)\n\nCommand-line tool to convert annotated go types specified in a package to json schema. It parses the Go file into an abstract-syntax-tree and generates its corresponding [json-schema](https://json-schema.org/) output. If any of the types depend on types from other packages, they will also be recursively converted.\n\n## How it works\nThe tool uses go parser to parse all the go files in the provided package. If it accesses types from other packages, it recursively processes those as well. It uses `go get` and `go list` commands to fetch and list files in a package. It is smart enough to not process types that are not relevant.\n\n## Example\n### Package contents\n```go\npackage types\n\ntype Person struct {\n  Name     string    `yaml:\"name\"`\n  Age      int       `yaml:\"age,omitempty\"`\n  Address  *Address  `yaml:\"address,omitempty\"`\n}\n\ntype Car struct {\n  Make     string    `json:\"make\"`\n}\n\ntype Address struct {\n}\n```\n\n### Command to run\n```\n$\u003e go build\n$\u003e go-types-to-json --package-name=\"github.com/pkg/name\" --output-file=\"output.json\" --types=\"Person,Car\"\n```\n\n### Contents of output.json\n```json\n{\n  \"definitions\": {\n    \"Person\": {\n      \"properties\": {\n        \"name\": {\n          \"type\": \"string\"\n        },\n        \"age\": {\n          \"type\": \"number\"\n        },\n        \"address\": {\n          \"$ref\": \"#/definitions/Address\"\n        }\n      },\n      \"required\": [\"name\"]\n    },\n    \"Address\": { },\n    \"Car\": {\n      \"properties\": {\n        \"make\": {\n          \"type\": \"string\"\n        }\n      },\n      \"required\": [\"make\"]\n    }\n  }\n}\n```\n\nNote: This is not an official Google product\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredborian%2Fgo-types-to-jsonschema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredborian%2Fgo-types-to-jsonschema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredborian%2Fgo-types-to-jsonschema/lists"}