{"id":18889767,"url":"https://github.com/scottlogic/openapi-forge-javascript","last_synced_at":"2026-02-25T09:30:21.402Z","repository":{"id":65624408,"uuid":"563486568","full_name":"ScottLogic/openapi-forge-javascript","owner":"ScottLogic","description":"⚒️ OpenAPI Forge generator for JavaScript clients","archived":false,"fork":false,"pushed_at":"2023-03-29T10:01:40.000Z","size":181,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-31T06:12:07.524Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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-11-08T18:02:49.000Z","updated_at":"2023-03-29T14:18:53.000Z","dependencies_parsed_at":"2024-11-08T07:50:55.198Z","dependency_job_id":"90ea84e2-633c-4f5e-a4f9-eb01c84edb00","html_url":"https://github.com/ScottLogic/openapi-forge-javascript","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScottLogic%2Fopenapi-forge-javascript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScottLogic%2Fopenapi-forge-javascript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScottLogic%2Fopenapi-forge-javascript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScottLogic%2Fopenapi-forge-javascript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ScottLogic","download_url":"https://codeload.github.com/ScottLogic/openapi-forge-javascript/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239861128,"owners_count":19709163,"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:49.378Z","updated_at":"2026-02-25T09:30:21.372Z","avatar_url":"https://github.com/ScottLogic.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenAPI Forge - JavaScript\n\nThis repository is the JavaScript 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- [OpenAPI Forge - JavaScript](#openapi-forge---javascript)\n  - [Example](#example)\n    - [Running with node (\\\u003e= v18)](#running-with-node--v18)\n    - [Running in the browser](#running-in-the-browser)\n  - [Configuration](#configuration)\n  - [Development](#development)\n    - [Running](#running)\n    - [Testing](#testing)\n    - [Linting](#linting)\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 quikcly 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-javascript \\\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.js` in the `api` folder:\n\n```javascript\nconst ApiPet = require(\"./apiPet\");\nconst Configuration = require(\"./configuration\");\nconst transport = require(\"./fetch\");\n\n// create an 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.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% node index.js\nFido\n```\n\n### Running in the browser\n\nYou'll need to 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## Configuration\n\nOpenAPI Forge is opinionated in its approach, we don't provide a vast range of configuration options, just the essentials! You can list the generator-specific configuration options by running the `generate-options` command as follows:\n\n```\n% openapi-forge generator-options openapi-forge-javascript\nThis generator has a number of additional options which can be supplied when executing the 'forge' command.\n\nOptions:\n  --generator.moduleFormat \u003cvalue\u003e  The module format to use for the generated code. (choices: \"commonjs\", \"esmodule\",\n                                    default: \"commonjs\")\n```\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-javascript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscottlogic%2Fopenapi-forge-javascript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscottlogic%2Fopenapi-forge-javascript/lists"}