{"id":15492124,"url":"https://github.com/imjuni/simple-tjscli","last_synced_at":"2025-07-11T14:12:33.030Z","repository":{"id":39715506,"uuid":"251609594","full_name":"imjuni/simple-tjscli","owner":"imjuni","description":"CLI to generate JSON schema from TypeScript interface","archived":false,"fork":false,"pushed_at":"2023-03-08T17:47:25.000Z","size":1038,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-16T03:56:04.842Z","etag":null,"topics":["cli","fastify","fastifyjs","generator","json-schema","json-schema-generator","jsonschema","jsonschema-generator","swagger","swagger-ui","typescript"],"latest_commit_sha":null,"homepage":"https://imjuni.github.io/simple-tjscli","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/imjuni.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,"governance":null}},"created_at":"2020-03-31T13:23:30.000Z","updated_at":"2025-02-18T19:35:40.000Z","dependencies_parsed_at":"2023-09-22T05:28:44.994Z","dependency_job_id":null,"html_url":"https://github.com/imjuni/simple-tjscli","commit_stats":null,"previous_names":["imjuni/tjscli"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjuni%2Fsimple-tjscli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjuni%2Fsimple-tjscli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjuni%2Fsimple-tjscli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjuni%2Fsimple-tjscli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imjuni","download_url":"https://codeload.github.com/imjuni/simple-tjscli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250307558,"owners_count":21409097,"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":["cli","fastify","fastifyjs","generator","json-schema","json-schema-generator","jsonschema","jsonschema-generator","swagger","swagger-ui","typescript"],"created_at":"2024-10-02T07:58:55.588Z","updated_at":"2025-04-22T19:26:03.521Z","avatar_url":"https://github.com/imjuni.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple-tjscli\n\n[![Download Status](https://img.shields.io/npm/dw/simple-tjscli.svg)](https://npmcharts.com/compare/simple-tjscli?minimal=true) [![Github Star](https://img.shields.io/github/stars/imjuni/simple-tjscli.svg?style=popout)](https://github.com/imjuni/simple-tjscli) [![Github Issues](https://img.shields.io/github/issues-raw/imjuni/simple-tjscli.svg)](https://github.com/imjuni/simple-tjscli/issues) [![NPM version](https://img.shields.io/npm/v/simple-tjscli.svg)](https://www.npmjs.com/package/simple-tjscli) [![License](https://img.shields.io/npm/l/simple-tjscli.svg)](https://github.com/imjuni/simple-tjscli/blob/master/LICENSE) [![simple-tjscli](https://circleci.com/gh/imjuni/simple-tjscli.svg?style=shield)](https://app.circleci.com/pipelines/github/imjuni/simple-tjscli?branch=master)\n\nsimple-tjscli is interactive cli tool for JSONSchema generation from TypeScript interface. simple-tjscli using two generator that [YousefED/typescript-json-schema](https://github.com/YousefED/typescript-json-schema) and [vega/ts-json-schema-generator](https://github.com/vega/ts-json-schema-generator). You can select one tool after generate JSONSchema from TypeScript interface.\n\n## Only One Time 🙆\n\nTypeScript interface convert to JSON schema.\n\n```ts\nexport interface Song {\n  /**\n   * song name\n   * @minLength 2\n   * @maxLength 256\n   * */\n  name: string;\n\n  /**\n   * song length represent using second unit\n   * @type integer\n   * @maximum 1200\n   * */\n  seconds: string;\n}\n```\n\nJSON schema generate from interface below,\n\n```json\n{\n  \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"name\": { \"type\": \"string\", \"description\": \"song name\", \"minLength\": 2, \"maxLength\": 256 },\n    \"seconds\": { \"type\": \"string\", \"description\": \"song length represent using second unit\", \"maximum\": 1200 }\n  },\n  \"required\": [\"name\", \"seconds\"]\n}\n```\n\nAlso You can create TypeScript variable like that(apply TypeScript template),\n\n```ts\nimport { JSONSchema7 } from 'json-schema';\n\nconst Song = {\n  $schema: 'http://json-schema.org/draft-07/schema#',\n  type: 'object',\n  properties: {\n    name: { type: 'string', description: 'song name', minLength: 2, maxLength: 256 },\n    seconds: { type: 'string', description: 'song length represent using second unit', maximum: 1200 },\n  },\n  required: ['name', 'seconds'],\n};\n\nexport default Song;\n```\n\nYes, simple-tjscli on counter part of [json-schema-to-ts](https://www.npmjs.com/package/json-schema-to-ts).\n\n## fastify.js\n\nIf you use [fastify.js](https://www.fastify.io), simple-tjscli is a good parter to management of schemas. simple-tjscli generate definitions for addSchema function. So you define TypeScript interface after generate validation and [@fastify/swagger](https://github.com/fastify/fastify-swagger). Yes, simple-tjscli is a one of option like [fluent-json-schema](https://github.com/fastify/fluent-json-schema), [typebox](https://github.com/sinclairzx81/typebox), [json-schema-to-ts](https://github.com/ThomasAribart/json-schema-to-ts)\n\n```mermaid\ngraph LR\n    A[TypeScript \u003cbr /\u003einterface] --\u003e|simple-tjscli| B[JSON schema]\n    B --\u003e|route| C[fastify.js]\n    C --\u003e|ajv| D[validateion \u003cbr /\u003eRequest/Response \u003cbr /\u003eDTO]\n    C --\u003e|\"@\"fastify/swagger| E[Swagger.io \u003cbr /\u003eDocumentation]\n```\n\nOnly One conversion\n\n## Install\n\n```bash\nnpm install simple-tjscli --save-dev\n```\n\n## Usage\n\nSee below example.\n\n```bash\n# interfactive mode\n$ npx tjscli tsj -i\n\n# Pass file and type\n$ npx tjscli tsj -f hello.ts -t IPrompt\n\n# Watch mode\n$ npx tjscli tsj-w --watch [watching directory]\n```\n\nMost case, interactive mode or watch mode satisfy your need. tjscli ask to you that interface file to convert JSONSchema.\n\n## Example Project\n\n[maeum](https://github.com/imjuni/maeum) is example project. maeum using simple-tjscli and fast-maker.\n\n```bash\n# Clone the boilerplate:\ngit clone --depth=1 \\\n  https://github.com/imjuni/maeum \\\n  your-project-name\n\ncd your-project-name\nnpm install\n\n# run simple-tjscli watch mode\nnpm run tjs-w\n```\n\n## Options\n\n| name                   | shortcut |               type                | generator | desc.                                                                                              |\n| ---------------------- | -------- | :-------------------------------: | :-------: | :------------------------------------------------------------------------------------------------- |\n| --cwd                  | -w       |              string               | tsj, tjs  | working directory                                                                                  |\n| --config               | -c       |              string               | tsj, tjs  | configuration file path. [example](https://github.com/imjuni/tjscli/blob/master/example/.tjsclirc) |\n| --project              | -p       |              string               | tsj, tjs  | tsconfig.json file path                                                                            |\n| --files                | -f       |             string[]              | tsj, tjs  | target file                                                                                        |\n| --types                | -t       |             string[]              | tsj, tjs  | target type                                                                                        |\n| --sync                 | -s       |              boolean              | tsj, tjs  | sync mode, schema have same directory structure in input file                                      |\n| --interactive          | -i       |              boolean              | tsj, tjs  | interactive mode, ask input file and type                                                          |\n| --noBanner             | -b       |              boolean              | tsj, tjs  | no banner in generated schema                                                                      |\n| --output               | -o       |              string               | tsj, tjs  | output directory                                                                                   |\n| --outputType           | -u       |        enum('json', 'ts')         | tsj, tjs  | output schema type                                                                                 |\n| --extName              | -e       |              string               | tsj, tjs  | output file extension                                                                              |\n| --prefix               | -x       |              string               | tsj, tjs  | output file name prefix, ex\u003e JSC -\u003e JSC_IMajor.ts                                                  |\n| --overwrite            |          |              string               | tsj, tjs  | If already exists schema file, overwrite schema                                                    |\n| --template             |          |              string               | tsj, tjs  | template string for output typescript file                                                         |\n| --templatePath         |          |              string               | tsj, tjs  | template file path for output typescript file                                                      |\n| --verbose              | -v       |              boolean              | tsj, tjs  | verbose message                                                                                    |\n| --watch                |          |              string               |    tsj    | only work in watch mode. watch directory                                                           |\n| --debounceTime         |          |              number               |    tsj    | only work in watch mode. watch file debounceTime. default 1000ms                                   |\n| --seperateDefinitions  |          |              boolean              |    tsj    | create definitions.ts file using definitions value in generated json-schema                        |\n| --skipTypeCheck        |          |              boolean              |    tsj    | ts-json-schema-generator option                                                                    |\n| --topRef               |          |              boolean              |    tsj    | ts-json-schema-generator option                                                                    |\n| --expose               |          |   enum('all', 'none', 'export')   |    tsj    | ts-json-schema-generator option                                                                    |\n| --jsDoc                |          | enum('none', 'extended', 'basic') |    tsj    | ts-json-schema-generator option                                                                    |\n| --extraTags            |          |             string[]              |    tsj    | ts-json-schema-generator option                                                                    |\n| --additionalProperties |          |              boolean              |    tsj    | ts-json-schema-generator option                                                                    |\n\n## Programming Interface\n\n| function                   | desc.                                                                                                                  |\n| -------------------------- | ---------------------------------------------------------------------------------------------------------------------- |\n| generateJSONSchemaUsingTSJ | generate json-schema using [vega/ts-json-schema-generator](https://github.com/vega/ts-json-schema-generator)           |\n| generateJSONSchemaUsingTJS | generate json-schema using [YousefED/typescript-json-schema](https://github.com/YousefED/typescript-json-schema)       |\n| watchJSONSchemaUsingTSJ    | watch for generate json-schema using [vega/ts-json-schema-generator](https://github.com/vega/ts-json-schema-generator) |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimjuni%2Fsimple-tjscli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimjuni%2Fsimple-tjscli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimjuni%2Fsimple-tjscli/lists"}