{"_id":"@aurora-is-near/openapi-client","_rev":"6-c2dcc9313a82b6430ae6a210b886be6b","name":"@aurora-is-near/openapi-client","dist-tags":{"latest":"1.5.0"},"versions":{"1.2.4":{"name":"@aurora-is-near/openapi-client","version":"1.2.4","author":{"name":"Alex Mendes"},"license":"UNLICENSED","_id":"@aurora-is-near/openapi-client@1.2.4","maintainers":[{"name":"chris-aurora","email":"chris.gutkowski@aurora.dev"},{"name":"aurorasec","email":"security@aurora.dev"},{"name":"aurealis","email":"diego.figueroa@aurora.dev"},{"name":"alexmendes","email":"alexanderhmendes@gmail.com"}],"bin":{"oac":"bin/index.js"},"dist":{"shasum":"8244bbd78f3adc195c354926e55622522a1ec0cc","tarball":"https://registry.npmjs.org/@aurora-is-near/openapi-client/-/openapi-client-1.2.4.tgz","fileCount":27,"integrity":"sha512-MVF/DNR9PvmXEaNDNZoX475h1G33LrmIvXPJzDheHW3HkQoSuNhrDIu8K4wEHY9shWOi2FX8E5+ETpvC2th02A==","signatures":[{"sig":"MEUCIHlZUzNrMSo73pYMRNpQhNov/qGGjmWcigAW2iFJyFA7AiEA67Sadhs2EJiORP0KCI1a6vKpQrXQmE5ZfCnjvdClfP8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54112},"main":"index.js","husky":{"hooks":{"commit-msg":"commitlint -E HUSKY_GIT_PARAMS"}},"types":"index.d.ts","gitHead":"c06acbfb8c7c298eb8bdd8f3daa972926cb7fe09","scripts":{"oac":"./bin/index.js","lint":"eslint --ext .js,.ts .","test":"jest","typecheck":"tsc --noEmit"},"_npmUser":{"name":"alexmendes","actor":{"name":"alexmendes","type":"user","email":"alexanderhmendes@gmail.com"},"email":"alexanderhmendes@gmail.com"},"_npmVersion":"10.9.2","description":"A type-safe OpenAPI client generator.","directories":{},"resolutions":{"wrap-ansi":"^7.0.0","strip-ansi":"^6.0.1","string-width":"^4.2.0"},"sideEffects":false,"_nodeVersion":"20.19.3","dependencies":{"qs":"^6.10.3","yaml":"^2.7.0","axios":"^1.8.2","chalk":"^4.1.2","yargs":"^17.7.2","fs-extra":"^11.1.0","typeconv":"^1.7.0","@types/qs":"^6.9.7","fast-glob":"^3.2.11","handlebars":"^4.7.7","jwt-decode":"^3.1.2","change-case":"^4.1.2","pascal-case":"^3.1.2","app-root-path":"^3.1.0","openapi-types":"^11.0.0","openapi-typescript":"^6.7.4","exponential-backoff":"^3.1.1"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","husky":"^4.2.5","eslint":"^8.57.0","ts-jest":"^29.1.0","prettier":"^3.2.5","commitlint":"^8.3.5","typescript":"^5.1.0","@types/jest":"^29.0.0","jsonwebtoken":"^8.5.1","semantic-release":"^24.0.0","@types/jsonwebtoken":"^8.5.8","@aurora-is-near/eslint-config":"^1.5.2","@commitlint/config-conventional":"^8.3.4","@aurora-is-near/semantic-release-config":"^1.5.2"},"peerDependencies":{"typescript":"*"},"_npmOperationalInternal":{"tmp":"tmp/openapi-client_1.2.4_1752085610614_0.4663091732466307","host":"s3://npm-registry-packages-npm-production"}},"1.3.0":{"name":"@aurora-is-near/openapi-client","version":"1.3.0","author":{"name":"Alex Mendes"},"license":"UNLICENSED","_id":"@aurora-is-near/openapi-client@1.3.0","maintainers":[{"name":"chris-aurora","email":"chris.gutkowski@aurora.dev"},{"name":"aurorasec","email":"security@aurora.dev"},{"name":"aurealis","email":"diego.figueroa@aurora.dev"},{"name":"alexmendes","email":"alexanderhmendes@gmail.com"}],"bin":{"oac":"bin/index.js"},"dist":{"shasum":"f0f5fc20e0889ceb57c43ce2151382cb0743001a","tarball":"https://registry.npmjs.org/@aurora-is-near/openapi-client/-/openapi-client-1.3.0.tgz","fileCount":27,"integrity":"sha512-Ks5ULB2tt5hOXFpknj1BFweMirOpsdL/PSdCYojY0iPRHZ/lCELvaZMydMT9S+3P2GCVP7R3vYp9yNb2Tuab2g==","signatures":[{"sig":"MEQCIEhjJBFy9+akjewxvjehvkEBCw7L6WQ3igvZ/x3cdnBYAiB60YcYvbfTyeTWJgN8HTgjRCMuy6CNak6zy0C9Rfj9CQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54162},"main":"index.js","husky":{"hooks":{"commit-msg":"commitlint -E HUSKY_GIT_PARAMS"}},"types":"index.d.ts","gitHead":"7024616b1bd2edaa1afaa98136f71446476dc53c","scripts":{"oac":"./bin/index.js","lint":"eslint --ext .js,.ts .","test":"jest","typecheck":"tsc --noEmit"},"_npmUser":{"name":"alexmendes","email":"alexanderhmendes@gmail.com"},"_npmVersion":"10.9.2","description":"A type-safe OpenAPI client generator.","directories":{},"resolutions":{"wrap-ansi":"^7.0.0","strip-ansi":"^6.0.1","string-width":"^4.2.0"},"sideEffects":false,"_nodeVersion":"20.19.4","dependencies":{"qs":"^6.10.3","yaml":"^2.7.0","axios":"^1.8.2","chalk":"^4.1.2","yargs":"^17.7.2","fs-extra":"^11.1.0","typeconv":"^1.7.0","@types/qs":"^6.9.7","fast-glob":"^3.2.11","handlebars":"^4.7.7","jwt-decode":"^3.1.2","change-case":"^4.1.2","pascal-case":"^3.1.2","app-root-path":"^3.1.0","openapi-types":"^11.0.0","openapi-typescript":"^6.7.4","exponential-backoff":"^3.1.1"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","husky":"^4.2.5","eslint":"^8.57.0","ts-jest":"^29.1.0","prettier":"^3.2.5","commitlint":"^8.3.5","typescript":"^5.1.0","@types/jest":"^29.0.0","jsonwebtoken":"^8.5.1","semantic-release":"^24.2.6","@types/jsonwebtoken":"^8.5.8","@aurora-is-near/eslint-config":"^1.5.2","@commitlint/config-conventional":"^8.3.4","@aurora-is-near/semantic-release-config":"^1.5.2"},"peerDependencies":{"typescript":"*"},"_npmOperationalInternal":{"tmp":"tmp/openapi-client_1.3.0_1754553351632_0.6774417880087675","host":"s3://npm-registry-packages-npm-production"}},"1.3.1":{"name":"@aurora-is-near/openapi-client","version":"1.3.1","author":{"name":"Alex Mendes"},"license":"UNLICENSED","_id":"@aurora-is-near/openapi-client@1.3.1","maintainers":[{"name":"chris-aurora","email":"chris.gutkowski@aurora.dev"},{"name":"aurorasec","email":"security@aurora.dev"},{"name":"aurealis","email":"diego.figueroa@aurora.dev"},{"name":"alexmendes","email":"alexanderhmendes@gmail.com"}],"bin":{"oac":"bin/index.js"},"dist":{"shasum":"ba86b0fc278a985ee634395b02b174c6694c7625","tarball":"https://registry.npmjs.org/@aurora-is-near/openapi-client/-/openapi-client-1.3.1.tgz","fileCount":27,"integrity":"sha512-fmfGpcu/S4aa8W7YJ9dhOyprZ3uI2iOwiX9MIvOeMXBf7bbofoY6iqIuewBEpQGt/LZXMS+IkqM7DlCaBPe2OA==","signatures":[{"sig":"MEUCIQDp773ohJlaPcxbHq5x3SR9R9L6vaBau6no0BrBY/qHngIgSyUKrfDCEexTXX4ALoao79qG7KvEqUXjge/AHASn+B8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54326},"main":"index.js","husky":{"hooks":{"commit-msg":"commitlint -E HUSKY_GIT_PARAMS"}},"types":"index.d.ts","gitHead":"6eb3fa7933bb28d2e2cee92fb73b59bed1c83192","scripts":{"oac":"./bin/index.js","lint":"eslint --ext .js,.ts .","test":"jest","typecheck":"tsc --noEmit"},"_npmUser":{"name":"alexmendes","email":"alexanderhmendes@gmail.com"},"_npmVersion":"10.9.2","description":"A type-safe OpenAPI client generator.","directories":{},"resolutions":{"wrap-ansi":"^7.0.0","strip-ansi":"^6.0.1","string-width":"^4.2.0"},"sideEffects":false,"_nodeVersion":"20.19.4","dependencies":{"qs":"^6.10.3","yaml":"^2.7.0","axios":"^1.8.2","chalk":"^4.1.2","yargs":"^17.7.2","fs-extra":"^11.1.0","typeconv":"^1.7.0","@types/qs":"^6.9.7","fast-glob":"^3.2.11","handlebars":"^4.7.7","jwt-decode":"^3.1.2","change-case":"^4.1.2","pascal-case":"^3.1.2","app-root-path":"^3.1.0","openapi-types":"^11.0.0","openapi-typescript":"^6.7.4","exponential-backoff":"^3.1.1"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","husky":"^4.2.5","eslint":"^8.57.0","ts-jest":"^29.1.0","prettier":"^3.2.5","commitlint":"^8.3.5","typescript":"^5.1.0","@types/jest":"^29.0.0","jsonwebtoken":"^8.5.1","semantic-release":"^24.2.6","@types/jsonwebtoken":"^8.5.8","@aurora-is-near/eslint-config":"^1.5.2","@commitlint/config-conventional":"^8.3.4","@aurora-is-near/semantic-release-config":"^1.5.2"},"peerDependencies":{"typescript":"*"},"_npmOperationalInternal":{"tmp":"tmp/openapi-client_1.3.1_1754590531863_0.4784750962773059","host":"s3://npm-registry-packages-npm-production"}},"1.4.0":{"name":"@aurora-is-near/openapi-client","version":"1.4.0","author":{"name":"Alex Mendes"},"license":"UNLICENSED","_id":"@aurora-is-near/openapi-client@1.4.0","maintainers":[{"name":"chris-aurora","email":"chris.gutkowski@aurora.dev"},{"name":"aurorasec","email":"security@aurora.dev"},{"name":"aurealis","email":"diego.figueroa@aurora.dev"},{"name":"alexmendes","email":"alexanderhmendes@gmail.com"}],"bin":{"oac":"bin/index.js"},"dist":{"shasum":"14fc789713a59b76a5ab76c267c36a163b1d1d79","tarball":"https://registry.npmjs.org/@aurora-is-near/openapi-client/-/openapi-client-1.4.0.tgz","fileCount":27,"integrity":"sha512-tZjoBjK32+iGL75ztKiwV8xF7BEcck23bWeJ0VUJ3M1XBaqHi6fXlh0gW3ggO79Bj+Ob9Yl27bm1vBm1VVcCLw==","signatures":[{"sig":"MEYCIQCusXASDj/HFyvSWzWd/6ixAA25A1MgeSuxDTmi4kblawIhAPJpP26zXU1vXIV2V16ZkA2yAjzeHht2F9uVXVjOPd8V","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54463},"main":"index.js","husky":{"hooks":{"commit-msg":"commitlint -E HUSKY_GIT_PARAMS"}},"types":"index.d.ts","gitHead":"b31940a69a369b6f11bb62cbb754e5a001ebb824","scripts":{"oac":"./bin/index.js","lint":"eslint --ext .js,.ts .","test":"jest","typecheck":"tsc --noEmit"},"_npmUser":{"name":"alexmendes","email":"alexanderhmendes@gmail.com"},"_npmVersion":"10.9.2","description":"A type-safe OpenAPI client generator.","directories":{},"resolutions":{"wrap-ansi":"^7.0.0","strip-ansi":"^6.0.1","string-width":"^4.2.0"},"sideEffects":false,"_nodeVersion":"20.19.4","dependencies":{"qs":"^6.10.3","yaml":"^2.7.0","axios":"^1.8.2","chalk":"^4.1.2","yargs":"^17.7.2","fs-extra":"^11.1.0","typeconv":"^1.7.0","@types/qs":"^6.9.7","fast-glob":"^3.2.11","handlebars":"^4.7.7","jwt-decode":"^3.1.2","change-case":"^4.1.2","pascal-case":"^3.1.2","app-root-path":"^3.1.0","openapi-types":"^11.0.0","openapi-typescript":"^6.7.4","exponential-backoff":"^3.1.1"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","husky":"^4.2.5","eslint":"^8.57.0","ts-jest":"^29.1.0","prettier":"^3.2.5","commitlint":"^8.3.5","typescript":"^5.1.0","@types/jest":"^29.0.0","jsonwebtoken":"^8.5.1","semantic-release":"^24.2.6","@types/jsonwebtoken":"^8.5.8","@aurora-is-near/eslint-config":"^1.5.2","@commitlint/config-conventional":"^8.3.4","@aurora-is-near/semantic-release-config":"^1.5.2"},"peerDependencies":{"typescript":"*"},"_npmOperationalInternal":{"tmp":"tmp/openapi-client_1.4.0_1755256522036_0.9197210523206751","host":"s3://npm-registry-packages-npm-production"}},"1.5.0":{"name":"@aurora-is-near/openapi-client","version":"1.5.0","author":{"name":"Alex Mendes"},"license":"UNLICENSED","_id":"@aurora-is-near/openapi-client@1.5.0","maintainers":[{"name":"chris-aurora","email":"chris.gutkowski@aurora.dev"},{"name":"aurorasec","email":"security@aurora.dev"},{"name":"aurealis","email":"diego.figueroa@aurora.dev"},{"name":"alexmendes","email":"alexanderhmendes@gmail.com"}],"bin":{"oac":"bin/index.js"},"dist":{"shasum":"f530d26f3b6b05fb416ffe6f9571941b10fb5e8e","tarball":"https://registry.npmjs.org/@aurora-is-near/openapi-client/-/openapi-client-1.5.0.tgz","fileCount":27,"integrity":"sha512-6cfz1cqDpO5B4TaGtQGybJlYf+tVvraNe3a0NJaEgd2a5dHsTd5s2mocqycHr5cPTBfLRrAXR2X5Lpuy+xJznA==","signatures":[{"sig":"MEYCIQDaLX5GU0w2Nk18Yk6by2GQZ0U/0Vnl+xiuYcuvdGj/VgIhALOoG+eqkt5hcJwGyvcgf+9BVroL4Q1krPRA5yCa1Kka","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":55734},"main":"index.js","husky":{"hooks":{"commit-msg":"commitlint -E HUSKY_GIT_PARAMS"}},"types":"index.d.ts","gitHead":"043956f7e3bf82c4d8b4a2f748a23e9b7a0f6343","scripts":{"oac":"./bin/index.js","lint":"eslint --ext .js,.ts .","test":"jest","typecheck":"tsc --noEmit"},"_npmUser":{"name":"alexmendes","email":"alexanderhmendes@gmail.com"},"_npmVersion":"10.9.2","description":"A type-safe OpenAPI client generator.","directories":{},"resolutions":{"wrap-ansi":"^7.0.0","strip-ansi":"^6.0.1","string-width":"^4.2.0"},"sideEffects":false,"_nodeVersion":"20.20.2","dependencies":{"qs":"^6.10.3","yaml":"^2.7.0","axios":"^1.8.2","chalk":"^4.1.2","yargs":"^17.7.2","fs-extra":"^11.1.0","typeconv":"^1.7.0","@types/qs":"^6.9.7","fast-glob":"^3.2.11","handlebars":"^4.7.7","jwt-decode":"^3.1.2","change-case":"^4.1.2","pascal-case":"^3.1.2","app-root-path":"^3.1.0","openapi-types":"^11.0.0","openapi-typescript":"^6.7.4","exponential-backoff":"^3.1.1"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","husky":"^4.2.5","eslint":"^8.57.0","ts-jest":"^29.1.0","prettier":"^3.2.5","commitlint":"^8.3.5","typescript":"^5.1.0","@types/jest":"^29.0.0","jsonwebtoken":"^8.5.1","semantic-release":"^24.2.6","@types/jsonwebtoken":"^8.5.8","@aurora-is-near/eslint-config":"^1.5.2","@commitlint/config-conventional":"^8.3.4","@aurora-is-near/semantic-release-config":"^1.5.2"},"peerDependencies":{"typescript":"*"},"_npmOperationalInternal":{"tmp":"tmp/openapi-client_1.5.0_1775220562539_0.2181836694755237","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2025-07-09T18:26:50.554Z","modified":"2026-05-12T13:01:34.575Z","1.2.4":"2025-07-09T18:26:50.804Z","1.3.0":"2025-08-07T07:55:51.868Z","1.3.1":"2025-08-07T18:15:32.045Z","1.4.0":"2025-08-15T11:15:22.298Z","1.5.0":"2026-04-03T12:49:22.690Z"},"author":{"name":"Alex Mendes"},"license":"UNLICENSED","description":"A type-safe OpenAPI client generator.","maintainers":[{"email":"chris.gutkowski@aurora.dev","name":"chris-aurora"},{"email":"security@aurora.dev","name":"aurorasec"},{"email":"alexanderhmendes@gmail.com","name":"alexmendes"}],"readme":"# OpenAPI client\n\nA type-safe [OpenAPI](https://swagger.io/specification/) client generator.\n\n**Table of Contents**\n\n- [Installation](#installation)\n- [Generating the client](#generating-the-client)\n- [Usage](#usage)\n- [Typescript](#typescript)\n- [Authorization](#authorization)\n- [Error handling](#error-handling)\n- [Debugging](#debugging)\n- [Mocking](#mocking)\n\n## Installation\n\n```sh\nyarn add @aurora-is-near/openapi-client\n```\n\n## Generating the client\n\nThis repository exposes a command line tool that you can run to generate the\nOpenAPI client. After installing the package you can generate the client from\nan OpenAPI specification with the following command:\n\n```text\nyarn oac http://example.api.com/docs.json\n```\n\nAlternatively, you can use a JSON file:\n\n```text\nyarn oac -f spec.json\n```\n\nWhere `spec.json` is the location of the OpenAPI specification file from which\nyou want to generate the client.\n\n### Custom output directory\n\nThe process described above will output the generated client files to\n`node_modules/.oac`.\n\nAlternatively, you can specify a custom output directory using the `--out`\nargument, for example:\n\n```text\nyarn oac http://example.api.com/docs.json --out src/client\n```\n\nIf using this pattern then for the remainder of these docs where we refer to\nimporting from `@aurora-is-near/openapi-client` you should instead import\nfrom the index file of your custom output folder, for example:\n\n```js\nimport { createMyApiClient } from './generated';\n```\n\n## Usage\n\nOnce the API client has been generated it can be instantiated as follows:\n\n```js\nimport { createMyApiClient } from '@aurora-is-near/openapi-client';\n\nconst client = createMyApiClient({\n  baseURL: 'http://example.api.com',\n  getAccessToken: () => 'my-access-token',\n  refreshAccessToken: () => 'my-new-access-token',\n  onError: console.error,\n});\n```\n\nWhere `createMyApiClient` is generated based on the title in the OpenAPI spec.\nFor example, if the title is \"Mobile BFF\" then this function will be\n`createMobileBffClient`.\n\nThe client object exposes functions for each API operation, as defined by the\nOpenAPI specification. Each function is called with an object containing the\nfollowing properties:\n\n### `params`\n\nAn object containing properties that are mapped to any named route parameters.\nFor example, if you have the route `/user/:name`, then the `name` property should\nbe passed in as `params: { name: 'Alex' }`.\n\n### `query`\n\nAn object containing a property for each query string parameter.\n\n### `data`\n\nAn object containing key-value to submit as the request body\n(i.e. for POST or PUT requests).\n\n---\n\nFor example, given the following (simplified) OpenAPI specification:\n\n```json\n{\n  \"openapi\": \"3.0.1\",\n  \"info\": {\n    \"title\": \"My API\"\n  },\n  \"paths\": {\n    \"/example/{id}/get-stuff\": {\n      \"get\": {\n        \"operationId\": \"myExampleOperation\",\n        \"parameters\": [\n          {\n            \"name\": \"id\",\n            \"in\": \"path\"\n          },\n          {\n            \"name\": \"limit\",\n            \"in\": \"query\"\n          }\n        ]\n      }\n    }\n  }\n}\n```\n\nWhen we run this code:\n\n```js\nimport { createMyApiClient } from '@aurora-is-near/openapi-client';\n\nconst client = createMyApiClient({\n  baseURL: 'http://example.api.com',\n});\n\nclient.myExampleOperation({\n  params: { id: 123 },\n  query: { limit: 1 },\n});\n```\n\nA request like this would be made:\n\n```text\nGET /example/123/get-stuff?limit=1\n```\n\n### Query parameter serialization\n\nArrays are serialized in the brackets format, for example:\n\n```js\nimport { createMyApiClient } from '@aurora-is-near/openapi-client';\n\nconst client = createMyApiClient({\n  baseURL: 'http://example.api.com',\n});\n\nclient.search({\n  params: { id: 123 },\n  query: {\n    text: 'hello',\n    filter: ['world'],\n    sort: {\n      asc: 'foo',\n    }\n  },\n});\n```\n\nBecomes:\n\n```text\nGET /example/123/get-stuff?text=hello&filter[]=world&sort[asc]=foo\n```\n\nA custom serializer can be passed in via the `paramsSerializer` property, for\nexample:\n\n```js\nimport qs from 'qs';\nimport { createMyApiClient } from '@aurora-is-near/openapi-client';\n\nconst client = createMyApiClient({\n  baseURL: 'http://example.api.com',\n  paramsSerializer: (params) => {\n    return qs.stringify(params, {\n      encodeValuesOnly: true,\n      arrayFormat: 'brackets',\n    });\n  },\n});\n```\n\n## Typescript\n\nTwo types are generated for each API operation. One for the options\n(`params`, `query` and `data`) and one for the response, for example:\n\n```js\nimport { createMyApiClient, MyApiMethods } from '@aurora-is-near/openapi-client';\n\nconst client = createMyApiClient({\n  baseURL: 'http://example.api.com',\n});\n\nexport const getMyExample = (\n  options: MyApiMethods['myExampleOperation']['options']\n): MyApiMethods['myExampleOperation']['response'] => (\n  client.myExampleOperation(options)\n);\n```\n\nTypes are also generated for each [OpenAPI component](https://swagger.io/docs/specification/components/)\npresent in your specification. These can be imported from\n`MyApiModels`.\n\n`MyApi` is generated based on the [title](https://swagger.io/specification/#info-object)\nof the API as defined in the OpenAPI specification, transformed to pascal case.\n\nFor example, given the following specification:\n\n```json\n{\n  \"openapi\": \"3.0.1\",\n  \"info\": {\n    \"title\": \"Mobile BFF\"\n  },\n  \"components\": {\n    \"schemas\": {\n      \"Post\": {\n        \"properties\": {\n          \"title\": {\n            \"type\": \"string\"\n          }\n        },\n        \"type\": \"object\",\n        \"required\": [\"title\"]\n      }\n    }\n  }\n}\n```\n\nthe `Post` model can be referenced as follows:\n\n```ts\nimport { MobileBff } from '@aurora-is-near/openapi-client';\n\nconst post: MobileBffModels['Post'] = {\n  title: 'My Post',\n};\n```\n\n## Authorization\n\nThe API client supports JWT token-based authentication. Any access token\nprovided via the `getAccessToken()` function will be automatically attached to\nrequests that require it. That is, those marked where the operation in the\nOpenAPI specs has a `security` property.\n\nIf a request fails an attempt is made to refresh the token by calling the\n`refreshAccessToken()` function and the request is retried. If the retry fails a\n401 error will be thrown, at which point the consuming application can handle\nthis error as appropriate (e.g. redirect the user to sign in again). If the\naccess token has expired an attempt will be made to refresh the token\nbefore making the initial request, thus saving on unnecessary API calls.\n\nYou can optionally modify the `refreshStatusCodes` to be respected. For example,\nyou may want to log an error and attempt a refresh when a 403 is returned, as\nwell as a 401:\n\n```js\nimport { createMyApiClient } from '@aurora-is-near/openapi-client';\n\nconst client = createMyApiClient({\n  baseURL: 'http://example.api.com',\n  refreshStatusCodes: [401, 403],\n});\n```\n\n## Error handling\n\n### HTTP errors\n\nAny HTTP errors encountered when using the client will be thrown as error object\nthat includes the following properties:\n\n| Property     | Description                                                            |\n|--------------|------------------------------------------------------------------------|\n| `statusCode` | The HTTP status code.                                                  |\n| `name`       | The name of the error (e.g. `BadRequest`).                             |\n| `message`    | An error message.                                                      |\n| `errors`     | An array containing any validation errors (see below).                 |\n| `type`       | A key that can be set via the API to uniquely identify the type of error (e.g. `/probs/the-thing-expired`). |\n\nIf the request resulted in validation errors, such as a query parameter being\nin the wrong format, then `errors` will include one or more objects with the\nfollowing properties:\n\n| Property     | Description                                             |\n|--------------|---------------------------------------------------------|\n| `property`   | The name of the property that failed validation.        |\n| `constraint` | The name of the constraint that failed.                 |\n| `message`    | A message explaining why the constraint failed.         |\n\nThe `isOpenApiClientError()` function may be used to determine if an error is\nan expected OpenAPI client error (i.e. an HTTP error), for example:\n\n```js\nimport { createMyApiClient, isOpenApiClientError }\nfrom '@aurora-is-near/openapi-client';\n\nconst client = createMyApiClient({\n  baseURL: 'http://example.api.com',\n});\n\ntry {\n  await client.myExampleOperation();\n} catch(err) {\n  if (!isOpenApiClientError(err)) {\n    throw err;\n  }\n\n  if (err.type === '/probs/the-thing-expired') {\n    // Handle this specific case\n\n    return;\n  }\n\n  console.error(`HTTP Error: ${err.statusCode}`);\n}\n```\n\nErrors will be logged to the console. To implement custom error handling you\ncan pass `onError()` and `onClientError()` callbacks when setting up the client,\nto handle server errors (5xx) and client errors (4xx), respectively. By default\nserver errors will be logged via `console.error` and client errors via\n`console.warn`.\n\n### Timeout errors\n\nAny timeout errors encountered when using the client will be thrown as an error object\nthat includes the following properties:\n\n| Property     | Description                                                      |\n|--------------|------------------------------------------------------------------|\n| `code`       | The timeout code  see: <https://www.npmjs.com/package/axios#error-types>.                                                               |\n| `name`       | The name of the error - OpenApiClientTimeoutError.               |\n| `message`    | An error message.                                                |\n\nThe `isOpenApiClientTimeoutError()` function may be used to determine if an error is\nan expected OpenAPI timeout error, for example:\n\n```js\nimport { createMyApiClient, isOpenApiClientTimeoutError }\nfrom '@aurora-is-near/openapi-client';\n\nconst client = createMyApiClient({\n  baseURL: 'http://example.api.com',\n});\n\ntry {\n  await client.myExampleOperation();\n} catch(err) {\n  if (!isOpenApiClientTimeoutError(err)) {\n    throw err;\n  }\n\n  console.error(`Request timed out: ${err.code}`);\n}\n```\n\nBy default errors will be logged to the console as a warning via `console.warn`.\nTo implement custom error handling you can pass an `onTimeoutError()` callback\nwhen setting up the client.\n\n## Accept header\n\nThe API client will send an `Accept` header with every request in the format:\n\n```text\napplication/vnd.[NAME]+json; version=[VERSION]\n```\n\nWhere `NAME` is generated based on the [title](https://swagger.io/specification/#info-object)\ndefined in the OpenAPI specification, transformed to lower case, and `VERSION` is\nthe version from the package.json of your repository.\n\nThis header is here in case the API wants to respond differently, or perhaps\nlog some error based on the version recieved.\n\n## Debugging\n\nTo log all outgoing requests you can pass in an `onRequest()` function, which is\ncalled with details about every request. For example:\n\n```js\nimport { createMyApiClient } from '@aurora-is-near/openapi-client';\n\nconst client = createMyApiClient({\n  baseURL: 'http://example.api.com',\n  onRequest: ({ method, url }) => {\n    console.debug(`${method.toUpperCase()} ${url.href}`);\n  },\n});\n```\n\n## Request timeout\n\nTo prevent requests remaining unresolved for a long period, a default timeout of\n15000ms is set on all requests.\n\nThis may be overridden using the `timeout` argument on open api\nclient creation.\n\n```js\nimport { createMyApiClient } from '@aurora-is-near/openapi-client';\n\nconst client = createMyApiClient({\n  baseURL: 'http://example.api.com',\n  timeout: 5000,\n});\n```\n\nThe timeout can be specified as a number or an object of type `Timeout` which is\nan object that has optional keys for the method name with the value a number. The\ncorresponding value will be attached to the method request via an interceptor.\n\n## Mocking\n\nYou can create a type-safe mock API client by installing the `jest-mock-extended`\npackage:\n\n```text\nyarn add jest-mock-extended -D\n```\n\nCreating a file containing something like the following, where the `MyApi`\nin `createMyApiClient` and `MyApiClient` is swapped\nout for the title in the OpenAPI spec, converted to pascal case\n(e.g. `createMobileBffClient` and `MobileBffClient`):\n\n```js\n// jest.mockApiClient.ts\nimport { DeepMockProxy, mockDeep } from 'jest-mock-extended';\nimport {\n  getMyApiOperations,\n  createMyApiClient,\n  MyApiClient,\n} from '@aurora-is-near/openapi-client';\n\nconst noop = {} as MyApiClient;\nconst operations = getMyApiOperations(noop);\n\njest.mock('@aurora-is-near/openapi-client', () => ({\n  ...jest.requireActual('@aurora-is-near/openapi-client'),\n  createMyApiClient: jest.fn(),\n}));\n\nconst mockClient = mockDeep<OpenApiClient>() as DeepMockProxy<OpenApiClient> & {\n  [x: string]: jest.Mock;\n};\n\n(createMyApiClient as jest.Mock).mockReturnValue(mockClient);\n\nObject.keys(operations).forEach((key) => {\n  mockClient[key].mockImplementation(() => {\n    console.warn(\n      `No mock return value set for API client operation ${key}. ` +\n        'Try adding a mock resolved value, for example: ' +\n        `\\`apiClient.${key}.mockResolvedValue({ foo: 'bar' })\\``,\n    );\n  });\n});\n```\n\nAdding the following to your Jest\n[`setupFilesAfterEnv`](https://jestjs.io/docs/configuration#setupfilesafterenv-array)\narray:\n\n```js\nmodule.exports = {\n  setupFilesAfterEnv: [\n    './node_modules/@aurora-is-near/openapi-client/mock.ts',\n  ],\n};\n```\n\nThen in your tests you can then create a mock client by calling the\n`createMyApiClient()` function. All operations will have been replaced with\nJest mocks, meaning you can mock API responses like so:\n\n```ts\nconst client = createMyApiClient({ baseURL: 'http://example.api.com' });\n\nclient.myOperation.mockResolvedValue({ foo: 'bar' });\n```\n","readmeFilename":"README.md"}