{"id":14156343,"url":"https://github.com/touchifyapp/spec2ts","last_synced_at":"2025-07-13T15:30:20.764Z","repository":{"id":40721148,"uuid":"258582749","full_name":"touchifyapp/spec2ts","owner":"touchifyapp","description":"Utilies to convert specifications (JSON Schemas and Open API) to Typescript using TypeScript native compiler","archived":false,"fork":false,"pushed_at":"2024-05-02T13:23:28.000Z","size":2243,"stargazers_count":22,"open_issues_count":12,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-09T05:19:33.663Z","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/touchifyapp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-24T17:47:27.000Z","updated_at":"2024-01-14T05:36:22.000Z","dependencies_parsed_at":"2023-02-05T07:15:56.833Z","dependency_job_id":"a4f88f4d-7020-4f6c-86a6-a270589d54fa","html_url":"https://github.com/touchifyapp/spec2ts","commit_stats":null,"previous_names":[],"tags_count":141,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/touchifyapp%2Fspec2ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/touchifyapp%2Fspec2ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/touchifyapp%2Fspec2ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/touchifyapp%2Fspec2ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/touchifyapp","download_url":"https://codeload.github.com/touchifyapp/spec2ts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225893393,"owners_count":17540914,"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-08-17T08:05:23.563Z","updated_at":"2024-11-22T11:46:54.374Z","avatar_url":"https://github.com/touchifyapp.png","language":"TypeScript","funding_links":[],"categories":["others"],"sub_categories":[],"readme":"# spec2ts\n\n![CI](https://github.com/touchifyapp/spec2ts/workflows/CI/badge.svg)\n\n`spec2ts` is an utility to create TypeScript types from JSON schemas and OpenAPI v3 specifications. Unlike other code generators `spec2ts` does not use templates to generate code but uses TypeScript's built-in API to generate and pretty-print an abstract syntax tree (AST).\n\n## Features\n\n* **AST-based:** Unlike other code generators `spec2ts` does not use templates to generate code but uses TypeScript's built-in API to generate and pretty-print an abstract syntax tree.\n* **Tree-shakeable:** Individually exported types allows you to bundle only the ones you actually use.\n* **YAML or JSON:** Use YAML or JSON for your or OpenAPI Specifications and JSON Schemas.\n* **External references:** Resolves automatically external references and bundle or import them in generated files.\n* **Implementation agnostic:** Use generated types in any projet or framework.\n\n## Components\n\n- `@spec2ts/core`: Helpers methods to generate TypeScript code.\n- `@spec2ts/jsonschema`: Utility to generate types from JSON schemas. [More details](https://github.com/touchifyapp/spec2ts/blob/master/packages/jsonschema/README.md).\n- `@spec2ts/openapi`: Utility to generate types from Open API v3 specifications. [More details](https://github.com/touchifyapp/spec2ts/blob/master/packages/openapi/README.md).\n- `@spec2ts/openapi-client`: Utility to generate HTTP Client from Open API v3 specifications. [More details](https://github.com/touchifyapp/spec2ts/blob/master/packages/openapi-client/README.md).\n- `@spec2ts/cli`: CLI wrapper to generate types from Open API v3 specifications and JSON schemas. [More details](https://github.com/touchifyapp/spec2ts/blob/master/packages/cli/README.md).\n\n## Installation\n\nInstall in your project:\n```bash\nnpm install @spec2ts/cli\n```\n\n## CLI Usage\n\n```bash\n# Generate TypeScript types from JSON Schemas\nspec2ts jsonschema -o path/to/output path/to/my/*.schema.json\n\n# Generate TypeScript types from Open API specification\nspec2ts openapi -o path/to/output path/to/my/specification.yml\n\n# Generate TypeScript HTTP Client from Open API specification\nspec2ts openapi-client -o path/to/output.ts path/to/my/specification.yml\n```\n\nYou can find more details in the `@spec2ts` [documentation](https://github.com/touchifyapp/spec2ts/blob/master/packages/jsonschema/README.md).\n\n## Programmatic Usage\n\n#### Generate TypeScript types from JSON Schemas\n\n```typescript\nimport { printer } from \"@spec2ts/core\";\nimport { parseSchema, JSONSchema } from \"@spec2ts/jsonschema\";\n\nasync function generateSchema(schema: JSONSchema): Promise\u003cstring\u003e {\n    const result = await parseSchema(schema);\n    return printer.printNodes(result);\n}\n```\n\n#### Generate TypeScript types from OpenAPI Specifications\n\n```typescript\nimport { printer } from \"@spec2ts/core\";\nimport { parseOpenApiFile } from \"@spec2ts/openapi\";\n\nasync function generateSpec(path: string): Promise\u003cstring\u003e {\n    const result = await parseOpenApiFile(path);\n    return printer.printNodes(result);\n}\n```\n\n#### Generate TypeScript Client types from OpenAPI Specifications\n\n```typescript\nimport { printer } from \"@spec2ts/core\";\nimport { generateClientFile } from \"@spec2ts/openapi-client\";\n\nasync function generateClient(path: string): Promise\u003cstring\u003e {\n    const result = await generateClientFile(path);\n    return printer.printNodes(result);\n}\n```\n\n## Compatibility Matrix\n\n| TypeScript version | spec2ts version |\n|--------------------|-----------------|\n| v3.x.x             | v1              | \n| v4.x.x             | v2              | \n| v5.x.x             | v3              | \n\n## License\n\nThis project is under MIT License. See the [LICENSE](LICENSE) file for the full license text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftouchifyapp%2Fspec2ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftouchifyapp%2Fspec2ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftouchifyapp%2Fspec2ts/lists"}