{"id":19755850,"url":"https://github.com/cap-js/openapi","last_synced_at":"2026-01-08T12:10:07.810Z","repository":{"id":229971082,"uuid":"740361497","full_name":"cap-js/openapi","owner":"cap-js","description":"CAP Library for OpenAPI","archived":false,"fork":false,"pushed_at":"2025-06-10T11:56:56.000Z","size":292,"stargazers_count":1,"open_issues_count":0,"forks_count":5,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-06-10T12:42:02.205Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cap-js.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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,"zenodo":null}},"created_at":"2024-01-08T07:32:46.000Z","updated_at":"2025-06-10T11:56:59.000Z","dependencies_parsed_at":"2024-04-22T09:43:44.532Z","dependency_job_id":"0413bf92-1b71-4177-b80d-56d1f1a4e5e0","html_url":"https://github.com/cap-js/openapi","commit_stats":null,"previous_names":["cap-js/openapi"],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/cap-js/openapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cap-js%2Fopenapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cap-js%2Fopenapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cap-js%2Fopenapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cap-js%2Fopenapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cap-js","download_url":"https://codeload.github.com/cap-js/openapi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cap-js%2Fopenapi/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259645123,"owners_count":22889528,"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","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":[],"created_at":"2024-11-12T03:13:42.330Z","updated_at":"2026-01-08T12:10:07.804Z","avatar_url":"https://github.com/cap-js.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![REUSE status](https://api.reuse.software/badge/github.com/cap-js/openapi)](https://api.reuse.software/info/github.com/cap-js/openapi)\n\n# OpenAPI\n\n## About this project\n\nThe `@cap-js/openapi` is a package that provides support for OpenAPI document compilation.\n\n### Table of Contents\n\n- [OpenAPI](#openapi)\n  - [About this project](#about-this-project)\n    - [Table of Contents](#table-of-contents)\n  - [Requirements and Setup](#requirements-and-setup)\n    - [Installation](#installation)\n    - [Usage](#usage)\n      - [Customizing OpenAPI Output](#customizing-openapi-output)\n  - [Contributing](#contributing)\n  - [Code of Conduct](#code-of-conduct)\n  - [Licensing](#licensing)\n\n## Requirements and Setup\n\n### Installation\n\n```sh\n$ npm install @cap-js/openapi\n```\n\n### Usage\n\n```js\nconst cds = require('@sap/cds')\nconst { compile } = require('@cap-js/openapi')\n```\n\n```js\nconst csn = await cds.load(cds.env.folders.srv)\nconst openapiDocument = compile(csn)\n```\n\n#### Customizing OpenAPI Output\n\nYou can synchronously hook into the compilation process using the `after:compile.to.openapi` event to modify the generated OpenAPI document:\n\n```js\ncds.on('after:compile.to.openapi', ({ csn, options, result }) =\u003e {\n  // Add custom vendor extensions\n  result['x-api-id'] = 'my-api-id'\n\n  // Enhance the info section\n  result.info.contact = {\n    name: 'API Support',\n    email: 'support@example.com'\n  }\n  result.info.license = {\n    name: 'Apache 2.0',\n    url: 'https://www.apache.org/licenses/LICENSE-2.0.html'\n  }\n\n  // Add additional servers for different environments\n  result.servers.push({\n    url: 'https://api-dev.example.com',\n    description: 'Development server'\n  })\n})\n```\n\nThe event handler receives an object with:\n- `csn` - The input CSN model\n- `options` - The compilation options used\n- `result` - The generated OpenAPI document (can be modified by reference)\n\nIn the same vein, you can also subscribe to `compile.to.openapi`, to modify the incoming CSN before it is converted:\n\n```js\ncds.on('compile.to.openapi', ({ csn, options }) =\u003e {\n  // exclude MySecretEntity from output\n  delete csn.definitions.MySecretEntity\n})\n```\n\nThe handler for events should never be async to avoid race conditions between the handler and the conversion process!\n\n\n## Contributing\n\nThis project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/cap-js/openapi/issues). Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md).\n\n## Code of Conduct\n\nWe as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its [Code of Conduct](https://github.com/cap-js/.github/blob/main/CODE_OF_CONDUCT.md) at all times.\n\n## Licensing\n\nCopyright 2023 SAP SE or an SAP affiliate company and contributors. Please see our [LICENSE](LICENSE) for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available [via the REUSE tool](https://api.reuse.software/info/github.com/cap-js/openapi).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcap-js%2Fopenapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcap-js%2Fopenapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcap-js%2Fopenapi/lists"}