{"id":20557242,"url":"https://github.com/nodecg/json-schema-defaults","last_synced_at":"2025-08-01T08:10:41.204Z","repository":{"id":65552652,"uuid":"593678894","full_name":"nodecg/json-schema-defaults","owner":"nodecg","description":"A library and CLI tool for generating a default value from a JSON schema","archived":false,"fork":false,"pushed_at":"2023-01-27T18:52:43.000Z","size":825,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-16T18:38:19.658Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/nodecg.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2023-01-26T15:45:31.000Z","updated_at":"2023-01-26T15:47:22.000Z","dependencies_parsed_at":"2023-02-15T12:01:13.662Z","dependency_job_id":null,"html_url":"https://github.com/nodecg/json-schema-defaults","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodecg%2Fjson-schema-defaults","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodecg%2Fjson-schema-defaults/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodecg%2Fjson-schema-defaults/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodecg%2Fjson-schema-defaults/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nodecg","download_url":"https://codeload.github.com/nodecg/json-schema-defaults/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242163857,"owners_count":20082224,"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-11-16T03:35:55.221Z","updated_at":"2025-03-06T06:46:02.990Z","avatar_url":"https://github.com/nodecg.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON Schema Defaults\n\n\u003e A library and CLI tool for generating a default value from a JSON schema\n\n## Installation\n\n```sh\nnpm install @nodecg/json-schema-defaults\n```\n\n## Usage\n\n- Node (TypeScript/ESM)\n\n  ```js\n  import defaults from 'json-schema-defaults';\n  defaults({ ... });\n  ```\n\n- CLI\n\n  If installed globally:\n\n  ```sh\n  json-schema-defaults schema.json\n  ```\n\n  If locally:\n\n  ```sh\n  ./node_modules/.bin/json-schema-defaults schema.json\n  ```\n\n  Custom indentation (defaults to 2):\n\n  ```sh\n  json-schema-defaults --indent 4 schema.json\n  ```\n\n  Write into a file:\n\n  ```sh\n  json-schema-defaults schema.json \u003e defaults.json\n  ```\n\n## Documentation\n\nCall `defaults` with JSON Schema. The default values will be extracted as a JSON.\n\n```ts\nconst json = defaults({\n  \"title\": \"Album Options\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"sort\": {\n      \"type\": \"string\",\n      \"default\": \"id\"\n    },\n    \"per_page\": {\n      \"default\": 30,\n      \"type\": \"integer\"\n    }\n  }\n});\n\n// would return\n{\n  sort: 'id',\n  per_page: 30\n}\n```\n\nFor more examples, see the tests.\n\n## Development\n\nRun tests\n\n```sh\nnpm test\n```\n\n## Contributors\n\n- Eugene Tsypkin @jhony-chikens (original author of [`json-schema-defaults`](https://www.npmjs.com/package/json-schema-defaults) on npm)\n- Alex Van Camp @alvancamp\n\n## License\n\n(c) 2023 The NodeCG Project. Released under the terms of the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodecg%2Fjson-schema-defaults","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnodecg%2Fjson-schema-defaults","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodecg%2Fjson-schema-defaults/lists"}