{"id":18889771,"url":"https://github.com/scottlogic/openapi-forge-typescript","last_synced_at":"2025-04-14T23:30:58.701Z","repository":{"id":41301974,"uuid":"499563054","full_name":"ScottLogic/openapi-forge-typescript","owner":"ScottLogic","description":"⚒️ OpenAPI Forge generator for TypeScript clients ","archived":false,"fork":false,"pushed_at":"2023-06-07T13:52:36.000Z","size":240,"stargazers_count":0,"open_issues_count":4,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T11:39:08.855Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/ScottLogic.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":"2022-06-03T15:34:56.000Z","updated_at":"2023-03-29T14:18:43.000Z","dependencies_parsed_at":"2024-11-08T07:51:00.621Z","dependency_job_id":"c38dfadb-5a1d-4471-bc76-7bcc9ed23270","html_url":"https://github.com/ScottLogic/openapi-forge-typescript","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScottLogic%2Fopenapi-forge-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScottLogic%2Fopenapi-forge-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScottLogic%2Fopenapi-forge-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScottLogic%2Fopenapi-forge-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ScottLogic","download_url":"https://codeload.github.com/ScottLogic/openapi-forge-typescript/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248978487,"owners_count":21192800,"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-08T07:50:50.107Z","updated_at":"2025-04-14T23:30:58.374Z","avatar_url":"https://github.com/ScottLogic.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenAPI Forge - TypeScript\n\nThis repository is the TypeScript generator for the [OpenAPI Forge](https://github.com/ScottLogic/openapi-forge), see that repository for usage instructions:\n\nhttps://github.com/ScottLogic/openapi-forge\n\nThe client API it generates is suitable for running in the browser (after being bundled appropriately), or via node. The generated code uses the Fetch API, and as a result you'll need to use node v18 or greater.\n\n## Example\n\nYou should consult the [OpenAPI Forge](https://github.com/ScottLogic/openapi-forge) repository for a complete user guide. The following is a very brief example that quickly gets you up-and-running with this generator.\n\nRun the `forge` command to generate a client API using this generator as follows:\n\n```\n$ openapi-forge forge \\\n                https://petstore3.swagger.io/api/v3/openapi.json \\\n                openapi-forge-typescript \\\n                -o api\n```\n\nThis will generate various files in the `api` folder.\n\n### Running with node (\u003e= v18)\n\nAdd the following `index.ts` in the `api` folder:\n\n```typescript\nimport ApiPet from \"./apiPet\";\nimport Configuration from \"./configuration\";\nimport transport from \"./fetch\";\n\n// create API client\nconst config = new Configuration(transport);\nconfig.basePath = \"https://petstore3.swagger.io\";\nconst api = new ApiPet(config);\n\n// use it!\n(async () =\u003e {\n  await api.addPet({\n    id: 1,\n    name: \"Fido\",\n    photoUrls: [],\n  });\n\n  const pet = await api.getPetById(1);\n  console.log(pet.data.name);\n})();\n```\n\nTo test the API, this example adds a Pet named “Fido” to the Pet Store, then retrieves it via its id, logging the name. You can run the example as follows:\n\n```\n% npx ts-node index.ts\nFido\n```\n\n### Running in the browser\n\nThe first step is to transpile from TypeScript to JavaScript:\n\n```\n% tsc\n```\n\nFollowing this, bundle the files into a single script. There are various tools that can be used for this purpose, but browserify is one of the simplest:\n\n```\n% npx browserify index.js -o bundle.js\n```\n\nNext create a simple HTML file that loads this script:\n\n```\n\u003chtml\u003e\n\u003cscript src=\"bundle.js\"\u003e\u003c/script\u003e\n\u003c/html\u003e\n```\n\nLoad the above page in a browser and you should see `Fido` logged to the console.\n\n## Development\n\nThe OpenAPI Forge project [details the process for creating a new generator](https://github.com/ScottLogic/openapi-forge#generator-development). The documentation gives a few generator-specific instructions.\n\n### Running\n\nTo run this generator, you also need to have [OpenAPI Forge] installed, or the repository checked out. Assuming you have it installed as a global module, you can run this generator as follows:\n\n```\n$ openapi-forge forge \\\n                https://petstore3.swagger.io/api/v3/openapi.json \\\n                . \\\n                -o api \\\n```\n\nThis generates an API from the Pet Store swagger definition, using the generator within the current folder (`.`), outputting the results to the `api` folder.\n\n### Testing\n\nThe standard test script is used to execute the BDD-style tests against this generator.\n\n```\nnpm run test\n```\n\nThe script expects that the openapi-forge project (which is where the BDD feature files are located) is checked out at the same folder-level as this project.\n\n### Linting\n\nTwo scripts are available to help you find linting errors:\n\n```\nnpm run lint:check:all\n```\n\nThis runs eslint in check mode which will raise errors found but not try and fix them. This is also ran on a PR and a push to main. It will fail if any errors were found.\n\n```\nnpm run lint:write:all\n```\n\nThis runs eslint in write mode which will raise errors found and try to fix them.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscottlogic%2Fopenapi-forge-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscottlogic%2Fopenapi-forge-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscottlogic%2Fopenapi-forge-typescript/lists"}