{"id":15557277,"url":"https://github.com/icholy/openapi-ts","last_synced_at":"2025-10-12T18:30:23.643Z","repository":{"id":66103645,"uuid":"399332990","full_name":"icholy/openapi-ts","owner":"icholy","description":null,"archived":true,"fork":false,"pushed_at":"2024-06-19T23:58:32.000Z","size":371,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-03T15:16:48.853Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/icholy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"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":"2021-08-24T04:21:25.000Z","updated_at":"2024-07-28T19:53:23.000Z","dependencies_parsed_at":"2023-11-14T21:24:45.459Z","dependency_job_id":"f4baaba4-e962-4b27-8f70-25680f9ab05e","html_url":"https://github.com/icholy/openapi-ts","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icholy%2Fopenapi-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icholy%2Fopenapi-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icholy%2Fopenapi-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icholy%2Fopenapi-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/icholy","download_url":"https://codeload.github.com/icholy/openapi-ts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236261792,"owners_count":19120776,"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-10-02T15:16:59.511Z","updated_at":"2025-10-12T18:30:23.283Z","avatar_url":"https://github.com/icholy.png","language":"TypeScript","readme":"# openapi-ts\n\n\u003e Library for generating TypeScript interfaces from OpenAPI v3 documents.\n\n* This library is library is incomplete, it implements the subset of the spec that I personally need.\n\n## CLI:\n\nThe package comes with a cli tool with a basic transformer implementation.\n\n```\n$ openapi-ts ./openapi.json\n```\n\n## Basic Usage:\n\n``` ts\nimport { load, analyse, transform } from \"@icholy/openapi-ts\";\n\nfunction main() {\n  const doc = await load(\"openapi.json\");\n  const details = analyse(doc);\n  console.log(transform(details));\n}\n```\n\n## Custom Transform\n\n``` ts\nimport {\n  load,\n  analyse,\n  Schema,\n  Printer,\n  DocumentDetails\n} from \"@icholy/openapi-ts\";\n\nfunction main() {\n  const doc = await load(\"openapi.json\");\n  const details = analyse(doc);\n  console.log(transform(details));\n}\n\nfunction transform(doc: DocumentDetails): string {\n  const print = new Printer();\n  \n  // output component schemas\n  for (const [name, schema] of Object.entries(doc.schemas)) {\n    print.schema(schema, name);\n  }\n\n  // output body types with random names\n  for (const op of doc.operations) {\n    // usually the name is inferred from the op's method/path\n    print.schema(op.params.body, \"InterfaceNameHere\");\n  }\n  \n  // output a custom type\n  const schema = new Schema(\"object\");\n  schema.setProperty(\"a\", new Schema(\"string\", { required: true }));\n  schema.setProperty(\"b\", new Schema(\"SomeOtherType\"));\n  print.schema(schema, \"MyType\");\n\n  // output types for each route\n  return print.code();\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficholy%2Fopenapi-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficholy%2Fopenapi-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficholy%2Fopenapi-ts/lists"}