{"id":14986532,"url":"https://github.com/imp-dance/openapi-to-rtk-query","last_synced_at":"2026-02-08T00:34:50.173Z","repository":{"id":195332894,"uuid":"692698544","full_name":"imp-dance/openapi-to-rtk-query","owner":"imp-dance","description":"Create RTK Query API code from an OpenAPI 3.x schema","archived":false,"fork":false,"pushed_at":"2023-09-24T11:54:35.000Z","size":653,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-01T04:46:17.545Z","etag":null,"topics":["bun","codegen","codegenerator","generator","open-api","openapi","rtk","rtk-query","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imp-dance.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-09-17T09:57:47.000Z","updated_at":"2023-09-30T11:28:53.000Z","dependencies_parsed_at":"2023-09-24T13:32:55.076Z","dependency_job_id":null,"html_url":"https://github.com/imp-dance/openapi-to-rtk-query","commit_stats":{"total_commits":21,"total_committers":2,"mean_commits":10.5,"dds":0.04761904761904767,"last_synced_commit":"1e93bf36f5d6e930b8863a898c1d5781e4af8c84"},"previous_names":["imp-dance/bun-cli-testing","imp-dance/openapi-to-rtk-query"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/imp-dance/openapi-to-rtk-query","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imp-dance%2Fopenapi-to-rtk-query","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imp-dance%2Fopenapi-to-rtk-query/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imp-dance%2Fopenapi-to-rtk-query/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imp-dance%2Fopenapi-to-rtk-query/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imp-dance","download_url":"https://codeload.github.com/imp-dance/openapi-to-rtk-query/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imp-dance%2Fopenapi-to-rtk-query/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29214394,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-08T00:10:47.190Z","status":"ssl_error","status_checked_at":"2026-02-08T00:10:43.589Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["bun","codegen","codegenerator","generator","open-api","openapi","rtk","rtk-query","typescript"],"created_at":"2024-09-24T14:13:05.737Z","updated_at":"2026-02-08T00:34:50.158Z","avatar_url":"https://github.com/imp-dance.png","language":"TypeScript","readme":"# openapi-to-rtk-query\n\nCreates **RTK Query** API code from an **OpenAPI 3.x schema**.\n\n\u003e  If you are actually looking for a service like this, you should use [RTK Query's official codegen guide](https://redux-toolkit.js.org/rtk-query/usage/code-generation). This is just a test project.\n\n## **Example**\n\n```shell\n$  bunx --bun blup --src \"https://developer.spotify.com/_data/documentation/web-api/reference/open-api-schema.yml\" --outDir \"./out\"\n```\n\n**CLI args**\n\n* **`--src`** (`-s`)*: The source of the OpenAPI schema. Can be a URL or a relative path. Make sure to start with `http`/`https` if it is a URL.\n* **`--outDir`** (`-o`)*: The output directory for the resulting files. Relative current working directory\n* **`--baseUrl`** (`-b`)?: The base URL for the API. Defaults to `https://api.example.com`. \n\n### Set up API schema\n\n\u003e This tool will do its best to generate code that is usable even if your schema does not contains tags or summaries - but adding this will greatly enhance the quality of the code produced in regards to naming and categorizing the queries and mutations.\n\n#### Tags\n\nTo get the most out of this utility, your openapi schema should [utilize tags](https://swagger.io/docs/specification/grouping-operations-with-tags/).\nTags should be defined both at top level, and used in the relevant endpoints that you want to group into one API.\n\nWe might generate the same query in multiple places if you add multiple tags, but that will also mean that query invalidation will work better - and it's a quick\njob for you to remove duplicate endpoints from the APIs that you don't want it in afterwards.\n\nIf you don't have tags in your schema, we will use the first path segment to group your endpoints, which might be sub-optimal.\n\n#### Summary\n\nYour endpoints should contain a summary. This summary will be used to name your queries and mutations:\n\n```typescript\n\"Create User\"\n// ==\u003e\nuseCreateUserQuery();\n\n\"Update multiple users\"\n// ==\u003e\nuseUpdateMultipleUsersMutation();\n```\n\n### Example output\n\nYou can check out the [out folder](https://github.com/imp-dance/openapi-to-rtk-query/tree/main/out) to see a full example output, when executed on the [Spotify OpenAPI schema](https://developer.spotify.com/reference/web-api/open-api-schema.yaml).\n\n**_marketsApi.ts_**\n```typescript \nimport { baseApi } from \"./baseApi\";\nimport { GetAvailableMarketsResponse } from \"./types\";\n\nexport const marketsApi = baseApi.injectEndpoints({\n  endpoints: (builder) =\u003e ({\n    getAvailableMarkets: builder.query\u003cGetAvailableMarketsResponse, unknown\u003e({\n      query: (args) =\u003e ({\n        url: `/markets`,\n        method: \"GET\",\n      }),\n      providesTags: () =\u003e [\"Markets\"],\n    }),\n  }),\n});\n\nexport const { useGetAvailableMarketsQuery } = marketsApi;\n```\n\n**_baseApi.ts_**\n```typescript\nimport { createApi, fetchBaseQuery } from \"@reduxjs/toolkit/dist/query/react\";\nconst tags = [\n  \"Albums\",\n  \"Artists\",\n  \"Audiobooks\",\n  \"Categories\",\n  \"Chapters\",\n  \"Episodes\",\n  \"Library\",\n  \"Genres\",\n  \"Markets\",\n  \"Player\",\n  \"Playlists\",\n  \"Search\",\n  \"Shows\",\n  \"Tracks\",\n  \"Users\",\n] as const;\n\nexport const baseApi = createApi({\n  tagTypes: tags,\n  reducerPath: \"baseApi\",\n  baseQuery: fetchBaseQuery({ baseUrl: \"https://api.example.com\" }),\n  endpoints: (builder) =\u003e ({}),\n});\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimp-dance%2Fopenapi-to-rtk-query","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimp-dance%2Fopenapi-to-rtk-query","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimp-dance%2Fopenapi-to-rtk-query/lists"}