Skip to content

Commit

Permalink
Split openapi (SAP#1719)
Browse files Browse the repository at this point in the history
* split http-client

* changes

* fix test error

* add missing dependency

* fix dep check

* fix import path

* revert fix import path

* remarks review

* lint error

* fix

* split open api

* add missing dep
  • Loading branch information
deekshas8 authored Oct 20, 2021
1 parent fcd55c3 commit feedd62
Show file tree
Hide file tree
Showing 67 changed files with 268 additions and 94 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
"workspaces": [
"packages/analytics",
"packages/connectivity",
"packages/core",
"packages/http-client",
"packages/openapi",
"packages/core",
"packages/eslint-config",
"packages/generator",
"packages/test-util",
Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@sap-cloud-sdk/util": "^1.50.0",
"@sap-cloud-sdk/connectivity": "^1.50.0",
"@sap-cloud-sdk/http-client": "^1.50.0",
"@sap-cloud-sdk/openapi": "^1.50.0",
"@types/jsonwebtoken": "^8.3.8",
"axios": "^0.23.0",
"bignumber.js": "^9.0.0",
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,3 @@ export {
uriConverters
} from './odata-v2';
export * from './odata-v4';
export * from './openapi';
1 change: 0 additions & 1 deletion packages/core/src/openapi/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* This is a generated file powered by the SAP Cloud SDK for JavaScript.
*/
import { OpenApiRequestBuilder } from '../../../../../src';
import { OpenApiRequestBuilder } from '@sap-cloud-sdk/openapi';
/**
* Representation of the 'DefaultApi'.
* This API is part of the 'no-schema-service' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* This is a generated file powered by the SAP Cloud SDK for JavaScript.
*/
import { OpenApiRequestBuilder } from '../../../../../src';
import { OpenApiRequestBuilder } from '@sap-cloud-sdk/openapi';
import type { TestEntity } from './schema';
/**
* Representation of the 'DefaultApi'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* This is a generated file powered by the SAP Cloud SDK for JavaScript.
*/
import { OpenApiRequestBuilder } from '../../../../../src';
import { OpenApiRequestBuilder } from '@sap-cloud-sdk/openapi';
/**
* Representation of the 'DefaultApi'.
* This API is part of the 'test-service' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* This is a generated file powered by the SAP Cloud SDK for JavaScript.
*/
import { OpenApiRequestBuilder } from '../../../../../src';
import { OpenApiRequestBuilder } from '@sap-cloud-sdk/openapi';
import type { TestEntity } from './schema';
/**
* Representation of the 'EntityApi'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* This is a generated file powered by the SAP Cloud SDK for JavaScript.
*/
import { OpenApiRequestBuilder } from '../../../../../src';
import { OpenApiRequestBuilder } from '@sap-cloud-sdk/openapi';
/**
* Representation of the 'ExtensionApi'.
* This API is part of the 'test-service' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* This is a generated file powered by the SAP Cloud SDK for JavaScript.
*/
import { OpenApiRequestBuilder } from '../../../../../src';
import { OpenApiRequestBuilder } from '@sap-cloud-sdk/openapi';
/**
* Representation of the 'TagDotApi'.
* This API is part of the 'test-service' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* This is a generated file powered by the SAP Cloud SDK for JavaScript.
*/
import { OpenApiRequestBuilder } from '../../../../../src';
import { OpenApiRequestBuilder } from '@sap-cloud-sdk/openapi';
/**
* Representation of the 'TagSpaceApi'.
* This API is part of the 'test-service' service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* This is a generated file powered by the SAP Cloud SDK for JavaScript.
*/
import { OpenApiRequestBuilder } from '../../../../../src';
import { OpenApiRequestBuilder } from '@sap-cloud-sdk/openapi';
import type {
SimpleTestEntity,
ComplexTestEntity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('apiFile', () => {
]
};
expect(apiFile(api, 'MyserviceName')).toMatchInlineSnapshot(`
"import { OpenApiRequestBuilder } from '@sap-cloud-sdk/core';
"import { OpenApiRequestBuilder } from '@sap-cloud-sdk/openapi';
/**
* Representation of the 'TestApi'.
* This API is part of the 'MyserviceName' service.
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('apiFile', () => {
]
};
expect(apiFile(api, 'MyserviceName')).toMatchInlineSnapshot(`
"import { OpenApiRequestBuilder } from '@sap-cloud-sdk/core';
"import { OpenApiRequestBuilder } from '@sap-cloud-sdk/openapi';
import type { QueryParameterType, RefType, ResponseType } from './schema';
/**
* Representation of the 'TestApi'.
Expand Down Expand Up @@ -166,7 +166,7 @@ describe('apiFile', () => {
};

expect(apiFile(api, 'TestService')).toMatchInlineSnapshot(`
"import { OpenApiRequestBuilder } from '@sap-cloud-sdk/core';
"import { OpenApiRequestBuilder } from '@sap-cloud-sdk/openapi';
/**
* Representation of the 'TestApi'.
* This API is part of the 'TestService' service.
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi-generator/src/file-serializer/api-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function getImports(api: OpenApiApi): Import[] {
};
const coreImports = {
names: ['OpenApiRequestBuilder'],
moduleIdentifier: '@sap-cloud-sdk/core'
moduleIdentifier: '@sap-cloud-sdk/openapi'
};

return [coreImports, refImports];
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi-generator/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export async function generateWithParsedOptions(

if (!options.packageJson) {
logger.info(
"Finished generation. Don't forget to add @sap-cloud-sdk/core to your dependencies."
"Finished generation. Don't forget to add @sap-cloud-sdk/openapi to your dependencies."
);
}
}
Expand Down
55 changes: 55 additions & 0 deletions packages/openapi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!-- sap-cloud-sdk-logo -->
<!-- This block is inserted by scripts/replace-common-readme.ts. Do not adjust it manually. -->
<a href="https://sap.com/s4sdk"><img src="https://help.sap.com/doc/2324e9c3b28748a4ae2ad08166d77675/1.0/en-US/logo-with-js.svg" alt="SAP Cloud SDK for JavaScript Logo" height="122.92" width="226.773"/></a>
<!-- sap-cloud-sdk-logo-stop -->

# @sap-cloud-sdk/openapi

This package contains the OpenAPI request builder for different types of HTTP requests.
.
## Installation

```
$ npm install @sap-cloud-sdk/openapi
```

## Usage

The openapi package is not intended for direct usage.

For more detailed overview visit our [Execute OpenAPI request documentation](https://sap.github.io/cloud-sdk/docs/js/features/openapi/execute-openapi-request).

<!-- sap-cloud-sdk-common-readme -->
<!-- This block is inserted by scripts/replace-common-readme.ts. Do not adjust it manually. -->
## Support

The recommended way to get in touch with us is to create an issue in our [github repository](https://github.com/SAP/cloud-sdk-js/issues).
Select the issue category `Bug`, `Feature` or `Question` depending on the nature of your request.
We try to provide fixes, features and answers as soon as possible.

We also monitor questions on [StackOverflow](https://stackoverflow.com/questions/tagged/sap-cloud-sdk?tab=Newest) and [ansers.sap.com](https://answers.sap.com/tags/73555000100800000895) but prefer issues on github.

## Contribute

If you would like to contribute to the SAP Cloud SDK, please make yourself familiar with our [contributing guidelines](https://github.com/SAP/cloud-sdk-js/blob/main/CONTRIBUTING.md) and follow the given instructions.

## Links

- [Github](https://github.com/SAP/cloud-sdk-js)
- [Github - Releases](https://github.com/SAP/cloud-sdk-js/releases)

<br>

- [SAP Cloud SDK Documentation portal](https://sap.github.io/cloud-sdk/)
- [SAP Cloud SDK Documentation portal - Getting started guide](https://sap.github.io/cloud-sdk/docs/js/getting-started)
- [SAP Cloud SDK Documentation portal - API documentation](https://sap.github.io/cloud-sdk/docs/js/api-reference-js-ts)

<br>

- [developers.sap.com - Product Overview](https://developers.sap.com/topics/cloud-sdk.html)
- [developers.sap.com - Tutorials](https://developers.sap.com/tutorial-navigator.html?tag=products:technology-platform/sap-cloud-sdk/sap-cloud-sdk&tag=topic:javascript)

## License

The SAP Cloud SDK is released under the [Apache License Version 2.0.](http://www.apache.org/licenses/)
<!-- sap-cloud-sdk-common-readme-stop -->
6 changes: 6 additions & 0 deletions packages/openapi/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// eslint-disable-next-line
const commonConfig = require('../../test-resources/jest.common.config');
module.exports = {
...commonConfig,
displayName: 'openapi'
};
45 changes: 45 additions & 0 deletions packages/openapi/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "@sap-cloud-sdk/openapi",
"version": "1.50.0",
"description": "SAP Cloud SDK for JavaScript openapi",
"homepage": "https://sap.github.io/cloud-sdk/docs/js/overview-cloud-sdk-for-javascript",
"license": "Apache-2.0",
"keywords": [
"sap-cloud-sdk",
"cloud-sdk",
"sap-cloud-platform",
"open-api"
],
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"publishConfig": {
"access": "public"
},
"files": [
"dist/**/*.js",
"dist/**/*.js.map",
"dist/**/*.d.ts",
"dist/**/*.d.ts.map",
"usage-analytics.js"
],
"repository": "github:SAP/cloud-sdk-js",
"scripts": {
"compile": "yarn tsc -b",
"prepare": "yarn compile",
"postinstall": "node usage-analytics.js",
"test": "yarn jest",
"coverage": "yarn jest --coverage",
"check:dependencies": "depcheck ."
},
"dependencies": {
"@sap-cloud-sdk/analytics": "^1.50.0",
"@sap-cloud-sdk/util": "^1.50.0",
"@sap-cloud-sdk/connectivity": "^1.50.0",
"@sap-cloud-sdk/http-client": "^1.50.0",
"axios": "^0.21.1"
},
"devDependencies": {
"@sap-cloud-sdk/core": "^1.50.0",
"nock": "^13.0.11"
}
}
8 changes: 8 additions & 0 deletions packages/openapi/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export { OpenApiRequestBuilder } from './openapi-request-builder';
export {
ParametersType,
FunctionReturnType,
UnwrapAxiosResponse,
UnPromisify,
ConstructorType
} from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import {
onlyIssuerXsuaaUrl,
providerXsuaaUrl,
providerServiceToken
} from '../../test/test-util';
import { wrapJwtInHeader } from '../../../connectivity/src/scp-cf/jwt';
import { parseDestination } from '../../../connectivity/src/scp-cf/destination/destination';
} from '@sap-cloud-sdk/core/test/test-util';
import { wrapJwtInHeader } from '@sap-cloud-sdk/connectivity/src/scp-cf/jwt';
import { parseDestination } from '@sap-cloud-sdk/connectivity/src/scp-cf/destination/destination';
import { OpenApiRequestBuilder } from './openapi-request-builder';

const destination = {
Expand Down
File renamed without changes.
18 changes: 18 additions & 0 deletions packages/openapi/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"tsBuildInfoFile": "./dist/.tsbuildinfo",
"composite": true
},
"include": ["src/**/*.ts"],
"exclude": ["dist/**/*", "test/**/*", "**/*.spec.ts", "node_modules/**/*"],
"files": [],
"references": [
{ "path": "../util" },
{ "path": "../analytics" },
{ "path": "../connectivity" },
{ "path": "../http-client" }
]
}
4 changes: 4 additions & 0 deletions packages/openapi/tsdoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
"extends": ["../../tsdoc.json"]
}
12 changes: 12 additions & 0 deletions packages/openapi/usage-analytics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
try {
// See docs/specs/0005_analytics-lifecycle-trick.md
const analytics = require('@sap-cloud-sdk/analytics');
const path = require('path');

const pathOfPostinstallScript = path.resolve(__dirname);
analytics.performUsageAnalytics(pathOfPostinstallScript, {
event_type: 'npm_install_openapi'
});
} catch (e) {
console.log('Looks like a local install to me.');
}
1 change: 1 addition & 0 deletions scripts/check-public-api-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ For a deatailed explaination what is happening here have a look at `0007-public-
async function checkApiPackages() {
await checkApiOfPackage(resolve(__dirname, '../packages/connectivity'));
await checkApiOfPackage(resolve(__dirname, '../packages/http-client'));
await checkApiOfPackage(resolve(__dirname, '../packages/openapi'));
}

checkApiPackages();
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenApiRequestBuilder } from '@sap-cloud-sdk/core';
import { OpenApiRequestBuilder } from '@sap-cloud-sdk/openapi';
/**
* Representation of the 'DefaultApi'.
* This API is part of the 'no-schema-service' service.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* This is a generated file powered by the SAP Cloud SDK for JavaScript.
*/
import { OpenApiRequestBuilder } from '@sap-cloud-sdk/core';
import { OpenApiRequestBuilder } from '@sap-cloud-sdk/openapi';
/**
* Representation of the 'DefaultApi'.
* This API is part of the 'no-schema-service' service.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenApiRequestBuilder } from '@sap-cloud-sdk/core';
import { OpenApiRequestBuilder } from '@sap-cloud-sdk/openapi';
import type { TestEntity } from './schema';
/**
* Representation of the 'DefaultApi'.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit feedd62

Please sign in to comment.