{"id":18960805,"url":"https://github.com/layer5io/rtk-query-codegen","last_synced_at":"2025-09-05T16:32:40.478Z","repository":{"id":213172105,"uuid":"732967982","full_name":"layer5io/rtk-query-codegen","owner":"layer5io","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-21T20:28:38.000Z","size":179,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-08T14:09:23.917Z","etag":null,"topics":["redux-toolki-query","redux-toolkit","rtk","rtk-queary-api","rtk-query"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/layer5io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING-gitflow.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-12-18T09:14:16.000Z","updated_at":"2024-07-02T02:11:39.000Z","dependencies_parsed_at":"2023-12-19T04:05:13.459Z","dependency_job_id":"4b93a718-cd3f-4f8c-927f-715c4840aa89","html_url":"https://github.com/layer5io/rtk-query-codegen","commit_stats":null,"previous_names":["layer5io/rtk-query-codegen"],"tags_count":2,"template":false,"template_full_name":"layer5io/layer5-repo-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/layer5io%2Frtk-query-codegen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/layer5io%2Frtk-query-codegen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/layer5io%2Frtk-query-codegen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/layer5io%2Frtk-query-codegen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/layer5io","download_url":"https://codeload.github.com/layer5io/rtk-query-codegen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232049364,"owners_count":18465261,"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":["redux-toolki-query","redux-toolkit","rtk","rtk-queary-api","rtk-query"],"created_at":"2024-11-08T14:09:32.317Z","updated_at":"2025-01-01T04:40:16.539Z","avatar_url":"https://github.com/layer5io.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenAPI API Client Generation and Compilation\n\nGenerate an API client from an OpenAPI schema in YAML format and create a rtk-query api client. This package streamlines this process and ensures a smooth workflow.\n\n## Dependencies\n\n1. **Node.js and npm:** Ensure you have Node.js and npm installed on your system. You can download them from [nodejs.org](https://nodejs.org/).\n\n## Installation\n\n```bash\n  npm install @layer5/rtk-query-codegen\n```\n\n## Usage\n\nRun the script using the following command:\n\n```bash\nrtk-query-codegen -i /path/to/schema.yml -o /path/to/generated-api.js -c /path/to/codegen-config.json\n```\n\n## Config File Options\n\n### Simple usage\n\n```\n {\n  apiFile: string\n  schemaFile: string\n  apiImport?: string\n  exportName?: string\n  argSuffix?: string\n  responseSuffix?: string\n  hooks?:\n    | boolean\n    | { queries: boolean; lazyQueries: boolean; mutations: boolean }\n  tag?: boolean\n  outputFile: string\n  filterEndpoints?:\n    | string\n    | RegExp\n    | EndpointMatcherFunction\n    | Array\u003cstring | RegExp | EndpointMatcherFunction\u003e\n  endpointOverrides?: EndpointOverrides[]\n  flattenArg?: boolean\n}\n```\n\n### Filtering endpoints\n\nIf you only want to include a few endpoints, you can use the `filterEndpoints` config option to filter your endpoints.\n\n```\n {\n  // ...\n  // should only have endpoints loginUser, placeOrder, getOrderById, deleteOrder\n  filterEndpoints: ['loginUser', /Order/],\n}\n```\n\n### Endpoint overrides\n\nIf an endpoint is generated as a mutation instead of a query or the other way round, you can override that.\n\n```\n{\n  // ...\n  \"endpointOverrides\": [\n    {\n      \"pattern\": \"loginUser\",\n      \"type\": \"mutation\"\n    }\n  ]\n}\n```\n\n### Generating hooks\n\nSetting `hooks: true` will generate `useQuery` and `useMutation` hook exports. If you also want `useLazyQuery` hooks generated or more granular control, you can also pass an object in the shape of: `{ queries: boolean; lazyQueries: boolean; mutations: boolean }`.\n\n### Multiple output files\n\n```\n\n  schemaFile: 'https://petstore3.swagger.io/api/v3/openapi.json',\n  apiFile: './src/store/emptyApi.ts',\n  outputFiles: {\n    './src/store/user.ts': {\n      filterEndpoints: [/user/i],\n    },\n    './src/store/order.ts': {\n      filterEndpoints: [/order/i],\n    },\n    './src/store/pet.ts': {\n      filterEndpoints: [/pet/i],\n    },\n  },\n}\n```\n\n## The Api.js file\n\nThe api.js file contains the generated api endpoints , it injects them into the base rtk client . And then exports all the hooks to use them .\nIf we need to override an api endpoint we can injectEnpoints in a separate file .\n\n## Troubleshooting\n\n- If any of the steps fail, the script will exit with a non-zero status code, indicating a failure. Review the error messages to diagnose and resolve any issues.\n\n- Ensure that the Bash script is executable by running `chmod +x generate-api.sh`.\n\n## Important Notes\n\n- Make sure the OpenAPI schema (`schema.yml`) is updated with latest changes and doesnt contain any breaking changes .\n\n- Always validate and test the generated API client to ensure it functions as expected.\n\n\u003cdiv\u003e\u0026nbsp;\u003c/div\u003e\n\n## Join the Layer5 community!\n\n\u003ca name=\"contributing\"\u003e\u003c/a\u003e\u003ca name=\"community\"\u003e\u003c/a\u003e\nOur projects are community-built and welcome collaboration. 👍 Be sure to see the \u003ca href=\"https://docs.google.com/document/d/17OPtDE_rdnPQxmk2Kauhm3GwXF1R5dZ3Cj8qZLKdo5E/edit\"\u003eLayer5 Community Welcome Guide\u003c/a\u003e for a tour of resources available to you and jump into our \u003ca href=\"http://slack.layer5.io\"\u003eSlack\u003c/a\u003e!\n\n\u003cp style=\"clear:both;\"\u003e\n\u003ca href =\"https://layer5.io/community/meshmates\"\u003e\u003cimg alt=\"MeshMates\" src=\".github/readme/images/layer5-community-sign.png\" style=\"margin-right:10px; margin-bottom:15px;\" width=\"28%\" align=\"left\"/\u003e\u003c/a\u003e\n\u003ch3\u003eFind your MeshMate\u003c/h3\u003e\n\n\u003cp\u003eMeshMates are experienced Layer5 community members, who will help you learn your way around, discover live projects and expand your community network. \nBecome a \u003cb\u003eMeshtee\u003c/b\u003e today!\u003c/p\u003e\n\nFind out more on the \u003ca href=\"https://layer5.io/community\"\u003eLayer5 community\u003c/a\u003e. \u003cbr /\u003e\n\u003cbr /\u003e\u003cbr /\u003e\u003cbr /\u003e\u003cbr /\u003e\n\n\u003c/p\u003e\n\n\u003cdiv\u003e\u0026nbsp;\u003c/div\u003e\n\n\u003ca href=\"https://slack.meshery.io\"\u003e\n\n\u003cpicture align=\"right\"\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\".github/readme/images//slack-dark-128.png\"  width=\"110px\" align=\"right\" style=\"margin-left:10px;margin-top:10px;\"\u003e\n  \u003csource media=\"(prefers-color-scheme: light)\" srcset=\".github/readme/images//slack-128.png\" width=\"110px\" align=\"right\" style=\"margin-left:10px;padding-top:5px;\"\u003e\n  \u003cimg alt=\"Shows an illustrated light mode meshery logo in light color mode and a dark mode meshery logo dark color mode.\" src=\".github/readme/images//slack-128.png\" width=\"110px\" align=\"right\" style=\"margin-left:10px;padding-top:13px;\"\u003e\n\u003c/picture\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://meshery.io/community\"\u003e\u003cimg alt=\"Layer5 Community\" src=\".github/readme/images//community.svg\" style=\"margin-right:8px;padding-top:5px;\" width=\"140px\" align=\"left\" /\u003e\u003c/a\u003e\n\n\u003cp\u003e\n✔️ \u003cem\u003e\u003cstrong\u003eJoin\u003c/strong\u003e\u003c/em\u003e any or all of the weekly meetings on \u003ca href=\"https://calendar.google.com/calendar/b/1?cid=bGF5ZXI1LmlvX2VoMmFhOWRwZjFnNDBlbHZvYzc2MmpucGhzQGdyb3VwLmNhbGVuZGFyLmdvb2dsZS5jb20\"\u003ecommunity calendar\u003c/a\u003e.\u003cbr /\u003e\n✔️ \u003cem\u003e\u003cstrong\u003eWatch\u003c/strong\u003e\u003c/em\u003e community \u003ca href=\"https://www.youtube.com/playlist?list=PL3A-A6hPO2IMPPqVjuzgqNU5xwnFFn3n0\"\u003emeeting recordings\u003c/a\u003e.\u003cbr /\u003e\n✔️ \u003cem\u003e\u003cstrong\u003eAccess\u003c/strong\u003e\u003c/em\u003e the \u003ca href=\"https://drive.google.com/drive/u/4/folders/0ABH8aabN4WAKUk9PVA\"\u003eCommunity Drive\u003c/a\u003e by completing a community \u003ca href=\"https://layer5.io/newcomer\"\u003eMember Form\u003c/a\u003e.\u003cbr /\u003e\n✔️ \u003cem\u003e\u003cstrong\u003eDiscuss\u003c/strong\u003e\u003c/em\u003e in the \u003ca href=\"https://discuss.layer5.io\"\u003eCommunity Forum\u003c/a\u003e.\u003cbr /\u003e\n✔️\u003cem\u003e\u003cstrong\u003eExplore more\u003c/strong\u003e\u003c/em\u003e in the \u003ca href=\"https://layer5.io/community/handbook\"\u003eCommunity Handbook\u003c/a\u003e.\u003cbr /\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003ci\u003eNot sure where to start?\u003c/i\u003e Grab an open issue with the \u003ca href=\"https://github.com/issues?q=is%3Aopen+is%3Aissue+archived%3Afalse+org%3Alayer5io+org%3Ameshery+org%3Aservice-mesh-performance+org%3Aservice-mesh-patterns+label%3A%22help+wanted%22+\"\u003ehelp-wanted label\u003c/a\u003e.\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flayer5io%2Frtk-query-codegen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flayer5io%2Frtk-query-codegen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flayer5io%2Frtk-query-codegen/lists"}