From 5849f70b3ad104fb9360f4bd052da0d77850e45d Mon Sep 17 00:00:00 2001 From: jeevitha011 <118245189+jeevitha011@users.noreply.github.com> Date: Tue, 14 May 2024 11:37:19 +0530 Subject: [PATCH] Removing register compile target (#27) * remove register compile target, update readme --- CHANGELOG.md | 6 ++++++ README.md | 24 ++---------------------- index.js | 17 ----------------- package.json | 4 ++-- test/lib/compile/openapi.test.js | 3 +-- 5 files changed, 11 insertions(+), 43 deletions(-) delete mode 100644 index.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ac00f6..b287a88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). The format is based on [Keep a Changelog](http://keepachangelog.com/). +## Version 1.0.3 - 14.05.2024 + +### Changed + +- Removed registering compile target + ## Version 1.0.2 - 02.05.2024 ### Fixed diff --git a/README.md b/README.md index 2dec441..fb14e67 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ The `@cap-js/openapi` is a package that provides support for OpenAPI document co ### Table of Contents - [Requirements and Setup](#requirements-and-setup) -- [Generate OpenAPI document](#generate-openapi-document) - [Contributing](#contributing) - [Code of Conduct](#code-of-conduct) - [Licensing](#licensing) @@ -25,29 +24,10 @@ $ npm install @cap-js/openapi ### Usage ```sh -require("@cap-js/openapi").register() +const processor = require('@cap-js/asyncapi/lib/compile') +processor(csn) ``` -## Generate OpenAPI document - -### 1. Usage of programatic API - -To invoke `cds compile --to openapi` programatically: - -```sh -await cds.compile().to.openapi() -``` - -### 2. Usage from CLI - -Run the following command in the CLI to generate the OpenAPI document. - -```sh -$ cds compile --to openapi -``` - -For more information, visit [capire](https://cap.cloud.sap/docs/advanced/openapi#cli) - ## Contributing This 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). diff --git a/index.js b/index.js deleted file mode 100644 index a9bb076..0000000 --- a/index.js +++ /dev/null @@ -1,17 +0,0 @@ -const cds = require('@sap/cds') - -function _lazyRegisterCompileTarget() { - const value = require('./lib/compile/index') - Object.defineProperty(this, "openapi", { value }) - return value -} - -const register = () => { - Object.defineProperty(cds.compile.to, "openapi", { - get: _lazyRegisterCompileTarget, - configurable: true - }) - } - - -module.exports = { register } diff --git a/package.json b/package.json index c69e936..94c8d62 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cap-js/openapi", - "version": "1.0.2", + "version": "1.0.3", "description": "CAP tool for OpenAPI", "repository": { "type": "git", @@ -15,7 +15,7 @@ ], "author": "SAP SE (https://www.sap.com)", "license": "SEE LICENSE IN LICENSE", - "main": "index.js", + "main": "lib/compile/index.js", "files": [ "lib/", "LICENSE" diff --git a/test/lib/compile/openapi.test.js b/test/lib/compile/openapi.test.js index c98330c..59919da 100644 --- a/test/lib/compile/openapi.test.js +++ b/test/lib/compile/openapi.test.js @@ -1,6 +1,5 @@ -require('../../..').register(); +const toOpenApi = require('../../../lib/compile'); const cds = require('@sap/cds') -const { compile: { to: { openapi: toOpenApi } } } = cds const someOpenApi = { openapi: '3.0.2', info: {}, servers: [{}], tags: [{}], paths: {}, components: {} } const SCENARIO = Object.freeze({