{"_id":"@atlassian/koa-oas3","name":"@atlassian/koa-oas3","dist-tags":{"latest":"4.0.0"},"versions":{"4.0.0":{"name":"@atlassian/koa-oas3","version":"4.0.0","main":"lib/index.js","types":"lib/index.d.js","author":{"email":"tli@atlassian.com"},"license":"Apache-2.0","publishConfig":{"registry":"https://packages.atlassian.com/api/npm/npm-public/"},"scripts":{"build":"tsc","test":"jest --coverage --no-watchman","test:watch":"jest --coverage --watch","prepublishOnly":"rm -rf lib && yarn build","release":"yarn prepublishOnly && changeset publish"},"jest":{"testEnvironmentOptions":{"url":"http://localhost/"},"transform":{"^.+\\.tsx?$":"ts-jest"},"testRegex":"(/__tests__/.*(test|spec))\\.(jsx?|tsx?)$","moduleFileExtensions":["ts","tsx","js","jsx","node"]},"dependencies":{"js-yaml":"^4.1.0","jsonfile":"^6.1.0","koa-bodyparser":"^4.2.1","koa-compose":"^4.1.0","oas-validator":"^5.0.3","oas3-chow-chow":"^4.0.0","qs":"^6.14.0"},"devDependencies":{"@changesets/cli":"^2.29.5","@types/jest":"^30.0.0","@types/js-yaml":"^4.0.9","@types/jsonfile":"^6.1.4","@types/koa":"^2.15.0","@types/koa-bodyparser":"^4.3.12","@types/qs":"^6.14.0","jest":"^30.0.2","koa":"^3.0.0","node-mocks-http":"^1.17.2","ts-jest":"^29.4.0","typescript":"^5.8.3"},"peerDependencies":{"koa":">=2 <4"},"_id":"@atlassian/koa-oas3@4.0.0","description":"Request and Response validator for OpenAPI Specification 3. Note: Starting from version 4, it's transferred to be under `@atlassian` scope.","_integrity":"sha512-RYFnX/rB27/9xDOhx4NDz8us4w2YkRZtK2VqIYVb22r7U12VkCvtP//TKiALv0WzMZt5VlyeA8Ntg+ZBUdeFrg==","_resolved":"/tmp/package-1-68d0a410-d4ae8b93098bdc6b6af9b488-1.tgz","_from":"file:/tmp/package-1-68d0a410-d4ae8b93098bdc6b6af9b488-1.tgz","_nodeVersion":"20.19.4","_npmVersion":"10.8.2","dist":{"integrity":"sha512-RYFnX/rB27/9xDOhx4NDz8us4w2YkRZtK2VqIYVb22r7U12VkCvtP//TKiALv0WzMZt5VlyeA8Ntg+ZBUdeFrg==","shasum":"b1bea3f36e90c799804d4c4dc56e9dc25c7179f9","tarball":"https://registry.npmjs.org/@atlassian/koa-oas3/-/koa-oas3-4.0.0.tgz","fileCount":31,"unpackedSize":73515,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAkaZ6Lwz9mM7NN6vpFH8MDAv/R28WQJ+W8bsMyH+6pwAiEAl+GLQ9t3wgB2MGRntbzzs+glUXef8A1MfLuY3Et5VSc="}]},"_npmUser":{"name":"atlassianartifactteam","email":"eng-development-tooling-secrets-and-artifacts@atlassian.com"},"directories":{},"maintainers":[{"name":"atlassianartifactteam","email":"eng-development-tooling-secrets-and-artifacts@atlassian.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/koa-oas3_4.0.0_1758503957428_0.392900777188832"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-22T01:19:17.370Z","4.0.0":"2025-09-22T01:19:17.600Z","modified":"2025-09-22T01:19:17.851Z"},"maintainers":[{"name":"atlassianartifactteam","email":"eng-development-tooling-secrets-and-artifacts@atlassian.com"}],"description":"Request and Response validator for OpenAPI Specification 3. Note: Starting from version 4, it's transferred to be under `@atlassian` scope.","author":{"email":"tli@atlassian.com"},"license":"Apache-2.0","readme":"# @atlassian/koa-oas3\n\nRequest and Response validator for OpenAPI Specification 3.\nNote: Starting from version 4, it's transferred to be under `@atlassian` scope.\n\n## Installation\n\n### npm\n\n```sh\nnpm install --save @atlassian/koa-oas3\n```\n\n### yarn\n\n```sh\nyarn add @atlassian/koa-oas3\n```\n\n## API\n\nBy default, this library will use `koa-bodyparser` to parse request body. See config of `requestBodyHandler`.\n\n```ts\nimport * as bodyParser from 'koa-bodyparser';\nimport { oas } from '@atlassian/koa-oas3';\n\nconst app = new Koa();\napp.use(bodyParser());\nconst oasMw = await oas({\n  file: `${__dirname}/../openapi.yaml`,\n  endpoint: '/openapi.json',\n  uiEndpoint: '/'\n});\napp.use(oasMw);\n\napp.listen(8080);\n```\n\n### oas(option)\n\n#### options\n\n- `file` - The absolute path to your Openapi file\n- `spec` - javascript object defining the api, either this or `file` must be given.\n- `enableUi`(default: true) - Whether to enable serving Openapi JSON and UI\n- `endpoint`(default: /openapi.json) - The endpoint for serving Openapi JSON\n- `uiEndpoint`:(default: /openapi.html) - The endpoint for serving Openapi UI\n- `validateResponse`:(default: false) - Validate response against Openapi schemas\n- `validatePaths`:(default ['/']) - Only endpoints starting with the values specified here will be validated\n- `swaggerUiBundleBasePath`: (default use swagger-ui-dist from [unpkg](https://unpkg.com/)) - [swaggerUiAssetPath](https://www.npmjs.com/package/swagger-ui-dist) needed for loading the swagger-ui\n- `validationOptions`: Optional - options for sending to oas3-chow-chow/AJV\n- `oasValidatorOptions`: Optional - options for sending to oas-validator. https://github.com/Mermade/oas-kit/blob/main/docs/options.md\n- `qsParseOptions: { [key: string]: any}`: Optional - Options to be passed to the [query string](https://github.com/ljharb/qs) parse command. Default: `{ comma: true }`\n- `errorHandler: (error: Error, ctx: Context) => void,`: Optional - custom error hanlder.\n- `requestBodyHandler: { [key: string]: koa.Middleware }`: Optional - custom body handler. Defaults:\n\n```ts\n{\n  'application/json': bodyParser({\n    extendTypes: {\n      json: ['application/json']\n    },\n    enableTypes: ['json']\n  }),\n  'text/*': bodyParser({\n    extendTypes: {\n      text: ['text/*']\n    },\n    enableTypes: ['text']\n  }),\n  'application/x-www-form-urlencoded': bodyParser({\n    extendTypes: {\n      form: ['application/x-www-form-urlencoded']\n    },\n    enableTypes: ['form']\n  })\n}\n```\n\n### Contributors\n\nPull requests, issues and comments welcome. For pull requests:\n\n- Add tests for new features and bug fixes\n- Follow the existing style\n- Separate unrelated changes into multiple pull requests\n- See the existing issues for things to start contributing.\n- Generate changeset using `yarn changeset`\n- If there are dependency changes, update lock file with `yarn install`\n\nFor bigger changes, make sure you start a discussion first by creating an issue and explaining the intended change.\n\nAtlassian requires contributors to sign a Contributor License Agreement, known as a CLA. This serves as a record stating that the contributor is entitled to contribute the code/documentation/translation to the project and is willing to have it used in distributions and derivative works (or is willing to transfer ownership).\n\nPrior to accepting your contributions we ask that you please follow the appropriate link below to digitally sign the CLA. The Corporate CLA is for those who are contributing as a member of an organization and the individual CLA is for those contributing as an individual.\n\n- [CLA for corporate contributors](https://na2.docusign.net/Member/PowerFormSigning.aspx?PowerFormId=e1c17c66-ca4d-4aab-a953-2c231af4a20b)\n- [CLA for individuals](https://na2.docusign.net/Member/PowerFormSigning.aspx?PowerFormId=3f94fbdc-2fbe-46ac-b14c-5d152700ae5d)\n","readmeFilename":"README.md","_rev":"1-bb607138a17987a04c664fa667d89b9c"}