{"_id":"@aurora-interactive/oas-fastify","name":"@aurora-interactive/oas-fastify","dist-tags":{"latest":"5.0.0"},"versions":{"5.0.0":{"version":"5.0.0","name":"@aurora-interactive/oas-fastify","description":"OAS 3.x to Fastify routes automation","author":{"name":"Ahmad Nassri","email":"email@ahmadnassri.com","url":"https://www.ahmadnassri.com"},"homepage":"https://github.com/ahmadnassri/node-oas-fastify","repository":{"type":"git","url":"git+https://github.com/ahmadnassri/node-oas-fastify.git"},"funding":{"type":"individual","url":"https://github.com/sponsors/ahmadnassri"},"license":"MIT","main":"lib/index.js","keywords":["oas","fastify"],"bugs":{"url":"https://github.com/ahmadnassri/node-oas-fastify/issues"},"scripts":{"test":"npm run test:cli -- test","test:cli":"node --experimental-test-coverage --test","test:watch":"npm run test:cli -- --watch test","test:ci":"npm run test:cli -- --test-reporter node-test-github-reporter test"},"dependencies":{"fastify-plugin":"^5.0.0"},"devDependencies":{"node-test-github-reporter":"^1.1.3"},"_id":"@aurora-interactive/oas-fastify@5.0.0","gitHead":"4e16fa6b9c868abbd00b3b8e655a27c88f3ba496","_nodeVersion":"22.4.0","_npmVersion":"10.8.1","dist":{"integrity":"sha512-okc8nPfkuji9HuZqL/fXUdCs9hIFCTGTU+2GS3RNWFIjdZSt/PuYPB2oWcy8iga/i31udlnqJR1OKofvjzmizA==","shasum":"c1d5a2d0d9a2f65e4991ac9978278cb407d5f4a6","tarball":"https://registry.npmjs.org/@aurora-interactive/oas-fastify/-/oas-fastify-5.0.0.tgz","fileCount":8,"unpackedSize":10681,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHxc2Vz20yCfw/ghcmoeYTBURoOH8NSgtePh0U6nPliZAiAOZRIlJCb5Wa4ZFbLe6gmx6qRIgt3eKwLjk8wpQJXGcQ=="}]},"_npmUser":{"name":"aurora-interactive-services","email":"npmjs@mail.aurora-interactive.online"},"directories":{},"maintainers":[{"name":"aurora-interactive-services","email":"npmjs@mail.aurora-interactive.online"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/oas-fastify_5.0.0_1726702885146_0.6787130627226812"},"_hasShrinkwrap":false}},"time":{"created":"2024-09-18T23:41:25.055Z","5.0.0":"2024-09-18T23:41:25.299Z","modified":"2024-09-18T23:41:25.595Z"},"maintainers":[{"name":"aurora-interactive-services","email":"npmjs@mail.aurora-interactive.online"}],"description":"OAS 3.x to Fastify routes automation","homepage":"https://github.com/ahmadnassri/node-oas-fastify","keywords":["oas","fastify"],"repository":{"type":"git","url":"git+https://github.com/ahmadnassri/node-oas-fastify.git"},"author":{"name":"Ahmad Nassri","email":"email@ahmadnassri.com","url":"https://www.ahmadnassri.com"},"bugs":{"url":"https://github.com/ahmadnassri/node-oas-fastify/issues"},"license":"MIT","readme":"# OAS to Fastify Plugin\n\nOAS 3.x to Fastify routes automation\n\n[![license][license-img]][license-url]\n[![release][release-img]][release-url]\n[![super linter][super-linter-img]][super-linter-url]\n[![test][test-img]][test-url]\n[![semantic][semantic-img]][semantic-url]\n\n## Usage\n\n``` js\nconst fastify = require('fastify')()\nconst spec = require('./petstore.json')\n\n// your handler object properties map to the OAS \"operationId\"\nconst handler = {\n  listPets: () => { ... }\n  createPets: () => { ... }\n  showPetById: () => { ... }\n}\n\nfastify.register(require('oas-fastify'), { spec, handler }) \n```\n\n#### Yaml Support?\n\n<details>\n  <summary>This package does not support OAS Yaml format, but you can easily convert to JSON before calling `oas-fastify`</summary>\n\n###### using [`js-yaml`][]\n\n``` js\nconst yaml = require('js-yaml')\nconst fs   = require('fs')\n\nconst spec = yaml.safeLoad(fs.readFileSync('openapi.yml', 'utf8'))\n\n\nfastify.register(require('oas-fastify'), { spec, handler }) \n```\n\n###### using [`apidevtools/swagger-cli`][]\n\n``` bash\nnpx apidevtools/swagger-cli bundle spec/openapi.yml --outfile spec.json\n```\n\n</details>\n\n### Options\n\nThe plugin accepts an `options` object with the following properties:\n\n-   **`spec`**: a valid [OpenAPI Specification][] **JSON** object\n-   **`handler`**: an object with properties that map to the spec's `operationId` names, with the values as functions that will handle the request\n\n###### Example\n\n``` js\nconst spec = {\n  \"paths\": {\n    \"/pets\": {\n      \"get\": {\n        \"operationId\": \"listPets\",\n        ...\n      }\n    }\n  }\n}\n\nconst handler = {\n  listPets: function (request, reply, fastify) {\n    // fastify instance passed in for convenience\n\n    reply.send({ hello: 'world' })\n  }\n}\n```\n\n  [`js-yaml`]: https://www.npmjs.com/package/js-yaml\n  [`apidevtools/swagger-cli`]: https://www.npmjs.com/package/@apidevtools/swagger-cli\n  [OpenAPI Specification]: https://github.com/OAI/OpenAPI-Specification/\n\n----\n> Author: [Ahmad Nassri](https://www.ahmadnassri.com/) &bull;\n> Twitter: [@AhmadNassri](https://twitter.com/AhmadNassri)\n\n[license-url]: LICENSE\n[license-img]: https://badgen.net/github/license/ahmadnassri/node-oas-fastify\n\n[release-url]: https://github.com/ahmadnassri/node-oas-fastify/releases\n[release-img]: https://badgen.net/github/release/ahmadnassri/node-oas-fastify\n\n[super-linter-url]: https://github.com/ahmadnassri/node-oas-fastify/actions?query=workflow%3Asuper-linter\n[super-linter-img]: https://github.com/ahmadnassri/node-oas-fastify/workflows/super-linter/badge.svg\n\n[test-url]: https://github.com/ahmadnassri/node-oas-fastify/actions?query=workflow%3Atest\n[test-img]: https://github.com/ahmadnassri/node-oas-fastify/workflows/test/badge.svg\n\n[semantic-url]: https://github.com/ahmadnassri/node-oas-fastify/actions?query=workflow%3Arelease\n[semantic-img]: https://badgen.net/badge/📦/semantically%20released/blue\n","readmeFilename":"README.md"}