{"id":15988419,"url":"https://github.com/insertish/oapi","last_synced_at":"2025-10-27T05:10:48.378Z","repository":{"id":42208033,"uuid":"471956520","full_name":"insertish/oapi","owner":"insertish","description":"Generate typed API libraries from OpenAPI specifications.","archived":false,"fork":false,"pushed_at":"2025-08-29T13:18:44.000Z","size":69,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-03T15:27:53.466Z","etag":null,"topics":["openapi","revolt","typescript"],"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/insertish.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-03-20T11:16:41.000Z","updated_at":"2025-08-29T13:18:47.000Z","dependencies_parsed_at":"2024-06-19T00:16:39.431Z","dependency_job_id":"5def1ca7-1082-4a39-b4fd-2a2fb249b044","html_url":"https://github.com/insertish/oapi","commit_stats":{"total_commits":15,"total_committers":2,"mean_commits":7.5,"dds":0.06666666666666665,"last_synced_commit":"e29da6fcf447d484a50d127665a80e0d515af66c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/insertish/oapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insertish%2Foapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insertish%2Foapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insertish%2Foapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insertish%2Foapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/insertish","download_url":"https://codeload.github.com/insertish/oapi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insertish%2Foapi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281216687,"owners_count":26463033,"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","status":"online","status_checked_at":"2025-10-27T02:00:05.855Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["openapi","revolt","typescript"],"created_at":"2024-10-08T04:03:43.068Z","updated_at":"2025-10-27T05:10:48.372Z","avatar_url":"https://github.com/insertish.png","language":"TypeScript","readme":"# OAPI Client\n\nThis is a CLI for auto-generating an API library for a given OpenAPI spec which uses JSON primarily and conforms to Revolt's API style.\n\nThank you to [bree](https://bree.dev/) for helping me figure out all the especially difficult types.\n\n## Goals\n\n- Commit programming atrocities internally.\n- Pretend everything is fine externally.\n- Provide a simple strongly typed API experience to the user.\n\n## Example\n\nHere's what you can achieve with this library:\n\n```typescript\nimport { API } from \"your-api\";\n\nlet id = \"user_id\";\n\n// By default, we use the first server specified in the API spec.\nnew API()\n\t// Path parameters are specified using template strings.\n\t.get(`/users/${id}`)\n\t.then((user) =\u003e {\n\t\t// User is still fully typed!\n\t\treturn user.username;\n\t})\n\t.then(console.log);\n```\n\nConflict resolution is also automatic, so conflicting prefixes will not cause issues:\n\n```typescript\nimport { API } from \"your-api\";\n\n// For a route /some/{string}:\nnew API().get(\"/some/this is an example\").then((x) =\u003e {\n\tx; // number\n});\n\n// For a route /some/{string}/conflicting:\nnew API().get(\"/some/this is an example/conflicting\").then((x) =\u003e {\n\tx; // string\n});\n```\n\nYou can also provide your query and body parameters at the same time:\n\n```typescript\nimport { API } from \"your-api\";\n\n// PATCH /users/@me?preserve=true\n// Body: { username: string }\nnew API().patch(`/users/@me`, {\n\t// Specify query parameters\n\tpreserve: true,\n\t// Or body parameters\n\tusername: \"something\",\n});\n```\n\nThis removes the overhead of having to remember exactly what goes where and provides a much nicer (and still strongly typed) API experience.\n\nCurrently this only supports rauth and Revolt authentication, but you can still provide your own Axios config or add your own authentication.\n\n```typescript\nnew API({\n\tbaseURL: \"https://example.com\",\n\tauthentication: {\n\t\trauth: \"session token\",\n\t},\n});\n```\n\n## Setup Guide\n\nCreate a new project and configure it:\n\n```sh\nyarn init\nyarn add @insertish/oapi axios lodash.defaultsdeep\nyarn add --dev typescript openapi-typescript @types/lodash.defaultsdeep\n```\n\nPlace your OpenAPI specification at the root of your API library at `OpenAPI.json`.\n\nUpdate your `package.json` to include the following:\n\n```json\n{\n    [...],\n    \"scripts\": {\n        \"build\": \"oapilib \u0026\u0026 tsc\"\n    }\n}\n```\n\n**Note**: you may want to use `STRICT=1 opailib`, see \"Strict Mode\" below.\n\nSetup Typescript:\n\n```sh\nyarn exec tsc -- --init\n```\n\nChange `tsconfig.json` to include:\n\n```json\n{\n\t\"compilerOptions\": {\n\t\t\"outDir\": \"./dist\",\n\t\t\"rootDir\": \"./src\",\n\t\t\"declaration\": true\n\t}\n}\n```\n\nCreate a new `src` directory.\n\nNow generate the library: (`src` folder will be overwritten!)\n\n```sh\nyarn build\n```\n\n## Replace `anyOf` with `oneOf`\n\nIf your spec uses `anyOf`, the values are mapped as an intersection while you may actually want all of these values to be treated as if they were `oneOf`, or otherwise a union.\n\nYou can specify the environment variable `REWRITE_ANYOF` to any truthy value.\n\n```sh\nREWRITE_ANYOF=1 oapilib\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsertish%2Foapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finsertish%2Foapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsertish%2Foapi/lists"}