@apimatic/cli 1.0.1-alpha.2 → 1.0.1-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -48
- package/lib/client-utils/sdk-client.d.ts +1 -1
- package/lib/client-utils/sdk-client.js +3 -3
- package/lib/commands/api/index.js +4 -5
- package/lib/commands/api/transform.d.ts +1 -0
- package/lib/commands/api/transform.js +25 -8
- package/lib/commands/api/validate.js +12 -6
- package/lib/commands/auth/index.js +5 -5
- package/lib/commands/auth/login.js +4 -2
- package/lib/commands/auth/logout.js +1 -1
- package/lib/commands/auth/status.js +1 -1
- package/lib/commands/portal/generate.d.ts +1 -0
- package/lib/commands/portal/generate.js +21 -11
- package/lib/commands/portal/index.js +3 -3
- package/lib/commands/sdk/generate.d.ts +1 -0
- package/lib/commands/sdk/generate.js +33 -18
- package/lib/commands/sdk/index.js +2 -2
- package/lib/controllers/api/transform.d.ts +1 -1
- package/lib/controllers/api/transform.js +5 -5
- package/lib/controllers/api/validate.d.ts +1 -1
- package/lib/controllers/portal/generate.d.ts +1 -1
- package/lib/controllers/portal/generate.js +3 -6
- package/lib/controllers/sdk/generate.d.ts +1 -1
- package/lib/controllers/sdk/generate.js +3 -3
- package/lib/types/api/transform.d.ts +1 -1
- package/lib/types/portal/generate.d.ts +3 -2
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
- package/CHANGELOG.md +0 -13
package/README.md
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
@apimatic/cli
|
|
2
2
|
=============
|
|
3
|
-
|
|
4
3
|
The official CLI for APIMatic.
|
|
5
|
-
|
|
6
4
|
[](https://oclif.io)
|
|
7
5
|
[](https://npmjs.org/package/@apimatic/cli)
|
|
8
6
|
[](https://npmjs.org/package/@apimatic/cli)
|
|
9
7
|
[](https://github.com/apimatic/apimatic-cli/blob/master/package.json)
|
|
10
|
-
|
|
11
8
|
<!-- toc -->
|
|
12
9
|
* [Usage](#usage)
|
|
13
10
|
* [Commands](#commands)
|
|
@@ -19,14 +16,13 @@ $ npm install -g @apimatic/cli
|
|
|
19
16
|
$ apimatic COMMAND
|
|
20
17
|
running command...
|
|
21
18
|
$ apimatic (-v|--version|version)
|
|
22
|
-
@apimatic/cli/1.0.1-alpha.
|
|
19
|
+
@apimatic/cli/1.0.1-alpha.6 linux-x64 node-v16.13.0
|
|
23
20
|
$ apimatic --help [COMMAND]
|
|
24
21
|
USAGE
|
|
25
22
|
$ apimatic COMMAND
|
|
26
23
|
...
|
|
27
24
|
```
|
|
28
25
|
<!-- usagestop -->
|
|
29
|
-
|
|
30
26
|
# Commands
|
|
31
27
|
<!-- commands -->
|
|
32
28
|
* [`apimatic api`](#apimatic-api)
|
|
@@ -45,7 +41,7 @@ USAGE
|
|
|
45
41
|
|
|
46
42
|
## `apimatic api`
|
|
47
43
|
|
|
48
|
-
|
|
44
|
+
Manage APIs
|
|
49
45
|
|
|
50
46
|
```
|
|
51
47
|
USAGE
|
|
@@ -55,21 +51,22 @@ EXAMPLE
|
|
|
55
51
|
$ apimatic api --help
|
|
56
52
|
```
|
|
57
53
|
|
|
58
|
-
_See code: [src/commands/api/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.
|
|
54
|
+
_See code: [src/commands/api/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.6/src/commands/api/index.ts)_
|
|
59
55
|
|
|
60
56
|
## `apimatic api:transform`
|
|
61
57
|
|
|
62
|
-
|
|
58
|
+
Transform API specifications from one format to another. Supports [10+ different formats](https://www.apimatic.io/transformer/#supported-formats) including OpenApi/Swagger, RAML, WSDL and Postman Collections.
|
|
63
59
|
|
|
64
60
|
```
|
|
65
61
|
USAGE
|
|
66
62
|
$ apimatic api:transform
|
|
67
63
|
|
|
68
64
|
OPTIONS
|
|
69
|
-
|
|
65
|
+
-f, --force overwrite if same file exist in the destination
|
|
66
|
+
--auth-key=auth-key override current authentication state with an authentication key
|
|
70
67
|
|
|
71
|
-
--destination=destination [default: /home/runner/work/apimatic-cli/apimatic-cli/cli
|
|
72
|
-
transformed file
|
|
68
|
+
--destination=destination [default: /home/runner/work/apimatic-cli/apimatic-cli/cli] directory to download
|
|
69
|
+
transformed file to
|
|
73
70
|
|
|
74
71
|
--file=file path to the API specification file to transform
|
|
75
72
|
|
|
@@ -77,38 +74,47 @@ OPTIONS
|
|
|
77
74
|
(OpenApi3Json|OpenApi3Yaml|APIMATIC|WADL2009|WADL2006|WSDL|
|
|
78
75
|
Swagger10|Swagger20|SwaggerYaml|RAML|RAML10|Postman10|Postman20)
|
|
79
76
|
|
|
80
|
-
--url=url URL to the API specification file to transform
|
|
77
|
+
--url=url URL to the API specification file to transform. Can be used in place of the --file option
|
|
78
|
+
if the API specification is publicly available.
|
|
81
79
|
|
|
82
|
-
|
|
80
|
+
EXAMPLES
|
|
83
81
|
$ apimatic api:transform --format="OpenApi3Json" --file="./specs/sample.json" --destination="D:/"
|
|
84
82
|
Success! Your transformed file is located at D:/Transformed_OpenApi3Json.json
|
|
83
|
+
|
|
84
|
+
$ apimatic api:transform --format=RAML --url="https://petstore.swagger.io/v2/swagger.json" --destination="D:/"
|
|
85
|
+
Success! Your transformed file is located at D:/swagger_raml.yaml
|
|
85
86
|
```
|
|
86
87
|
|
|
87
|
-
_See code: [src/commands/api/transform.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.
|
|
88
|
+
_See code: [src/commands/api/transform.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.6/src/commands/api/transform.ts)_
|
|
88
89
|
|
|
89
90
|
## `apimatic api:validate`
|
|
90
91
|
|
|
91
|
-
|
|
92
|
+
Validate the syntactic and semantic correctness of an API specification
|
|
92
93
|
|
|
93
94
|
```
|
|
94
95
|
USAGE
|
|
95
96
|
$ apimatic api:validate
|
|
96
97
|
|
|
97
98
|
OPTIONS
|
|
98
|
-
--auth-key=auth-key override current
|
|
99
|
-
--file=file
|
|
100
|
-
--url=url URL to the specification file to validate
|
|
99
|
+
--auth-key=auth-key override current authentication state with an authentication key
|
|
100
|
+
--file=file Path to the API specification file to validate
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
--url=url URL to the specification file to validate. Can be used in place of the --file option if the API
|
|
103
|
+
specification is publicly available.
|
|
104
|
+
|
|
105
|
+
EXAMPLES
|
|
103
106
|
$ apimatic api:validate --file="./specs/sample.json"
|
|
104
107
|
Specification file provided is valid
|
|
108
|
+
|
|
109
|
+
$ apimatic api:validate --url=https://petstore.swagger.io/v2/swagger.json
|
|
110
|
+
Specification file provided is valid
|
|
105
111
|
```
|
|
106
112
|
|
|
107
|
-
_See code: [src/commands/api/validate.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.
|
|
113
|
+
_See code: [src/commands/api/validate.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.6/src/commands/api/validate.ts)_
|
|
108
114
|
|
|
109
115
|
## `apimatic auth`
|
|
110
116
|
|
|
111
|
-
|
|
117
|
+
Manage this CLI's authentication state.
|
|
112
118
|
|
|
113
119
|
```
|
|
114
120
|
USAGE
|
|
@@ -118,11 +124,11 @@ EXAMPLE
|
|
|
118
124
|
$ apimatic auth --help
|
|
119
125
|
```
|
|
120
126
|
|
|
121
|
-
_See code: [src/commands/auth/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.
|
|
127
|
+
_See code: [src/commands/auth/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.6/src/commands/auth/index.ts)_
|
|
122
128
|
|
|
123
129
|
## `apimatic auth:login`
|
|
124
130
|
|
|
125
|
-
|
|
131
|
+
Login using your APIMatic credentials or an API Key
|
|
126
132
|
|
|
127
133
|
```
|
|
128
134
|
USAGE
|
|
@@ -131,19 +137,22 @@ USAGE
|
|
|
131
137
|
OPTIONS
|
|
132
138
|
--auth-key=auth-key Set authentication key for all commands
|
|
133
139
|
|
|
134
|
-
|
|
140
|
+
EXAMPLES
|
|
135
141
|
$ apimatic auth:login
|
|
136
142
|
Please enter your registered email: apimatic-user@gmail.com
|
|
137
143
|
Please enter your password: *********
|
|
138
144
|
|
|
139
145
|
You have successfully logged into APIMatic
|
|
146
|
+
|
|
147
|
+
$ apimatic auth:login --auth-key=xxxxxx
|
|
148
|
+
Authentication key successfully set
|
|
140
149
|
```
|
|
141
150
|
|
|
142
|
-
_See code: [src/commands/auth/login.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.
|
|
151
|
+
_See code: [src/commands/auth/login.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.6/src/commands/auth/login.ts)_
|
|
143
152
|
|
|
144
153
|
## `apimatic auth:logout`
|
|
145
154
|
|
|
146
|
-
|
|
155
|
+
Clear local login credentials
|
|
147
156
|
|
|
148
157
|
```
|
|
149
158
|
USAGE
|
|
@@ -154,11 +163,11 @@ EXAMPLE
|
|
|
154
163
|
Logged out
|
|
155
164
|
```
|
|
156
165
|
|
|
157
|
-
_See code: [src/commands/auth/logout.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.
|
|
166
|
+
_See code: [src/commands/auth/logout.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.6/src/commands/auth/logout.ts)_
|
|
158
167
|
|
|
159
168
|
## `apimatic auth:status`
|
|
160
169
|
|
|
161
|
-
|
|
170
|
+
View current authentication state
|
|
162
171
|
|
|
163
172
|
```
|
|
164
173
|
USAGE
|
|
@@ -169,7 +178,7 @@ EXAMPLE
|
|
|
169
178
|
Currently logged in as apimatic-client@gmail.com
|
|
170
179
|
```
|
|
171
180
|
|
|
172
|
-
_See code: [src/commands/auth/status.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.
|
|
181
|
+
_See code: [src/commands/auth/status.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.6/src/commands/auth/status.ts)_
|
|
173
182
|
|
|
174
183
|
## `apimatic autocomplete [SHELL]`
|
|
175
184
|
|
|
@@ -209,11 +218,11 @@ OPTIONS
|
|
|
209
218
|
--all see all commands in CLI
|
|
210
219
|
```
|
|
211
220
|
|
|
212
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.
|
|
221
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.10/src/commands/help.ts)_
|
|
213
222
|
|
|
214
223
|
## `apimatic portal`
|
|
215
224
|
|
|
216
|
-
|
|
225
|
+
Manage API documentation portals
|
|
217
226
|
|
|
218
227
|
```
|
|
219
228
|
USAGE
|
|
@@ -223,32 +232,33 @@ EXAMPLE
|
|
|
223
232
|
$apimatic portal --help
|
|
224
233
|
```
|
|
225
234
|
|
|
226
|
-
_See code: [src/commands/portal/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.
|
|
235
|
+
_See code: [src/commands/portal/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.6/src/commands/portal/index.ts)_
|
|
227
236
|
|
|
228
237
|
## `apimatic portal:generate`
|
|
229
238
|
|
|
230
|
-
Generate static
|
|
239
|
+
Generate and download a static API Documentation portal. Requires an input directory containing API specifications, a config file and optionally, markdown guides. For details, refer to the [documentation](https://portal-api-docs.apimatic.io/#/http/generating-api-portal/build-file)
|
|
231
240
|
|
|
232
241
|
```
|
|
233
242
|
USAGE
|
|
234
243
|
$ apimatic portal:generate
|
|
235
244
|
|
|
236
245
|
OPTIONS
|
|
237
|
-
|
|
238
|
-
--
|
|
239
|
-
--
|
|
240
|
-
--
|
|
246
|
+
-f, --force overwrite if a portal exists in the destination
|
|
247
|
+
--auth-key=auth-key override current authentication state with an authentication key
|
|
248
|
+
--destination=destination [default: /home/runner/work/apimatic-cli/apimatic-cli/cli] path to the downloaded portal
|
|
249
|
+
--folder=folder path to the input directory containing API specifications and config files
|
|
250
|
+
--zip download the generated portal as a .zip archive
|
|
241
251
|
|
|
242
252
|
EXAMPLE
|
|
243
253
|
$ apimatic portal:generate --folder="./portal/" --destination="D:/"
|
|
244
254
|
Your portal has been generated at D:/
|
|
245
255
|
```
|
|
246
256
|
|
|
247
|
-
_See code: [src/commands/portal/generate.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.
|
|
257
|
+
_See code: [src/commands/portal/generate.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.6/src/commands/portal/generate.ts)_
|
|
248
258
|
|
|
249
259
|
## `apimatic sdk`
|
|
250
260
|
|
|
251
|
-
|
|
261
|
+
Generate and manage SDKs for APIs
|
|
252
262
|
|
|
253
263
|
```
|
|
254
264
|
USAGE
|
|
@@ -258,7 +268,7 @@ EXAMPLE
|
|
|
258
268
|
$apimatic sdk --help
|
|
259
269
|
```
|
|
260
270
|
|
|
261
|
-
_See code: [src/commands/sdk/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.
|
|
271
|
+
_See code: [src/commands/sdk/index.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.6/src/commands/sdk/index.ts)_
|
|
262
272
|
|
|
263
273
|
## `apimatic sdk:generate`
|
|
264
274
|
|
|
@@ -269,9 +279,13 @@ USAGE
|
|
|
269
279
|
$ apimatic sdk:generate
|
|
270
280
|
|
|
271
281
|
OPTIONS
|
|
272
|
-
|
|
273
|
-
--
|
|
274
|
-
|
|
282
|
+
-f, --force overwrite if an SDK already exists in the destination
|
|
283
|
+
--auth-key=auth-key override current authentication state with an authentication key
|
|
284
|
+
|
|
285
|
+
--destination=destination [default: /home/runner/work/apimatic-cli/apimatic-cli/cli] directory to download the
|
|
286
|
+
generated SDK to
|
|
287
|
+
|
|
288
|
+
--file=file path to the API specification to generate SDKs for
|
|
275
289
|
|
|
276
290
|
--platform=platform (required) language platform for sdk
|
|
277
291
|
Simple: CSHARP|JAVA|PYTHON|RUBY|PHP|TYPESCRIPT
|
|
@@ -279,14 +293,21 @@ OPTIONS
|
|
|
279
293
|
JAVA_ECLIPSE_JRE_LIB|PHP_GENERIC_LIB|PYTHON_GENERIC_LIB|RUBY_GENERIC_LIB|
|
|
280
294
|
TS_GENERIC_LIB
|
|
281
295
|
|
|
282
|
-
--url=url URL to the API specification to generate
|
|
296
|
+
--url=url URL to the API specification to generate SDKs for. Can be used in place of the --file
|
|
297
|
+
option if the API specification is publicly available.
|
|
283
298
|
|
|
284
|
-
--zip
|
|
299
|
+
--zip download the generated SDK as a .zip archive
|
|
285
300
|
|
|
286
|
-
|
|
301
|
+
EXAMPLES
|
|
287
302
|
$ apimatic sdk:generate --platform="CSHARP" --file="./specs/sample.json"
|
|
288
|
-
SDK
|
|
303
|
+
Generating SDK... done
|
|
304
|
+
Downloading SDK... done
|
|
305
|
+
Success! Your SDK is located at swagger_sdk_csharp
|
|
306
|
+
$ apimatic sdk:generate --platform="CSHARP" --url=https://petstore.swagger.io/v2/swagger.json
|
|
307
|
+
Generating SDK... done
|
|
308
|
+
Downloading SDK... done
|
|
309
|
+
Success! Your SDK is located at swagger_sdk_csharp
|
|
289
310
|
```
|
|
290
311
|
|
|
291
|
-
_See code: [src/commands/sdk/generate.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.
|
|
312
|
+
_See code: [src/commands/sdk/generate.ts](https://github.com/apimatic/apimatic-cli/blob/v1.0.1-alpha.6/src/commands/sdk/generate.ts)_
|
|
292
313
|
<!-- commandsstop -->
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SDKClient = void 0;
|
|
4
4
|
const base64 = require("base-64");
|
|
5
5
|
const axios_1 = require("axios");
|
|
6
|
-
const
|
|
6
|
+
const sdk_1 = require("@apimatic/sdk");
|
|
7
7
|
const auth_manager_1 = require("./auth-manager");
|
|
8
8
|
const env_1 = require("../config/env");
|
|
9
9
|
class SDKClient {
|
|
@@ -84,7 +84,7 @@ class SDKClient {
|
|
|
84
84
|
}
|
|
85
85
|
async getClient(overrideAuthKey, configDir) {
|
|
86
86
|
if (overrideAuthKey) {
|
|
87
|
-
return new
|
|
87
|
+
return new sdk_1.Client({
|
|
88
88
|
timeout: 0,
|
|
89
89
|
authorization: `X-Auth-Key ${overrideAuthKey}`
|
|
90
90
|
});
|
|
@@ -95,7 +95,7 @@ class SDKClient {
|
|
|
95
95
|
storedAuthInfo = { email: "", authKey: "" };
|
|
96
96
|
}
|
|
97
97
|
if (storedAuthInfo.authKey !== "") {
|
|
98
|
-
return new
|
|
98
|
+
return new sdk_1.Client({
|
|
99
99
|
timeout: 0,
|
|
100
100
|
authorization: `X-Auth-Key ${storedAuthInfo.authKey}`
|
|
101
101
|
});
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const command_1 = require("@oclif/command");
|
|
4
4
|
class Api extends command_1.Command {
|
|
5
5
|
async run() {
|
|
6
|
-
this.log(`
|
|
6
|
+
this.log(`Manage APIs
|
|
7
7
|
|
|
8
8
|
USAGE
|
|
9
9
|
$ apimatic api
|
|
@@ -12,11 +12,10 @@ EXAMPLE
|
|
|
12
12
|
$ apimatic api --help
|
|
13
13
|
|
|
14
14
|
COMMANDS
|
|
15
|
-
api:transform
|
|
16
|
-
|
|
17
|
-
api:validate Validates the provided API specification file for any syntactical and semantic errors`);
|
|
15
|
+
api:transform Transform API specifications from one format to another. Supports [10+ different formats](https://www.apimatic.io/transformer/#supported-formats) including OpenApi/Swagger, RAML, WSDL and Postman Collections.
|
|
16
|
+
api:validate Validate the syntactic and semantic correctness of an API specification`);
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
exports.default = Api;
|
|
21
|
-
Api.description = "
|
|
20
|
+
Api.description = "Manage APIs";
|
|
22
21
|
Api.examples = ["$ apimatic api --help"];
|
|
@@ -7,6 +7,7 @@ export default class Transform extends Command {
|
|
|
7
7
|
file: flags.IOptionFlag<string>;
|
|
8
8
|
url: flags.IOptionFlag<string>;
|
|
9
9
|
destination: flags.IOptionFlag<string>;
|
|
10
|
+
force: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
10
11
|
"auth-key": flags.IOptionFlag<string | undefined>;
|
|
11
12
|
};
|
|
12
13
|
run(): Promise<void>;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const fs = require("fs-extra");
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const cli_ux_1 = require("cli-ux");
|
|
6
|
-
const
|
|
6
|
+
const sdk_1 = require("@apimatic/sdk");
|
|
7
7
|
const command_1 = require("@oclif/command");
|
|
8
8
|
const sdk_client_1 = require("../../client-utils/sdk-client");
|
|
9
9
|
const utils_1 = require("../../utils/utils");
|
|
@@ -15,10 +15,12 @@ class Transform extends command_1.Command {
|
|
|
15
15
|
const fileName = flags.file ? utils_1.getFileNameFromPath(flags.file) : utils_1.getFileNameFromPath(flags.url);
|
|
16
16
|
const destinationFormat = transform_1.DestinationFormats[flags.format];
|
|
17
17
|
const destinationFilePath = path.join(flags.destination, `${fileName}_${flags.format}.${destinationFormat}`.toLowerCase());
|
|
18
|
-
if
|
|
18
|
+
// Check if destination file already exist and throw error if force flag is not set
|
|
19
|
+
if (fs.existsSync(destinationFilePath) && !flags.force) {
|
|
19
20
|
throw new Error(`Can't download transformed file to path ${destinationFilePath}, because it already exists`);
|
|
20
21
|
}
|
|
21
22
|
try {
|
|
23
|
+
// Check if paths provided are valid
|
|
22
24
|
if (flags.file && !(await fs.pathExists(flags.file))) {
|
|
23
25
|
throw new Error(`Transformation file: ${flags.file} does not exist`);
|
|
24
26
|
}
|
|
@@ -27,7 +29,7 @@ class Transform extends command_1.Command {
|
|
|
27
29
|
}
|
|
28
30
|
const overrideAuthKey = flags["auth-key"] ? flags["auth-key"] : null;
|
|
29
31
|
const client = await sdk_client_1.SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
|
|
30
|
-
const transformationController = new
|
|
32
|
+
const transformationController = new sdk_1.TransformationController(client);
|
|
31
33
|
const { id, apiValidationSummary } = await transform_2.getTransformationId(flags, transformationController);
|
|
32
34
|
transform_2.printValidationMessages(apiValidationSummary, this.warn, this.error);
|
|
33
35
|
const savedTransformationFile = await transform_2.downloadTransformationFile({
|
|
@@ -69,10 +71,13 @@ class Transform extends command_1.Command {
|
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
exports.default = Transform;
|
|
72
|
-
Transform.description = `
|
|
74
|
+
Transform.description = `Transform API specifications from one format to another. Supports [10+ different formats](https://www.apimatic.io/transformer/#supported-formats) including OpenApi/Swagger, RAML, WSDL and Postman Collections.`;
|
|
73
75
|
Transform.examples = [
|
|
74
76
|
`$ apimatic api:transform --format="OpenApi3Json" --file="./specs/sample.json" --destination="D:/"
|
|
75
77
|
Success! Your transformed file is located at D:/Transformed_OpenApi3Json.json
|
|
78
|
+
`,
|
|
79
|
+
`$ apimatic api:transform --format=RAML --url="https://petstore.swagger.io/v2/swagger.json" --destination="D:/"
|
|
80
|
+
Success! Your transformed file is located at D:/swagger_raml.yaml
|
|
76
81
|
`
|
|
77
82
|
];
|
|
78
83
|
Transform.flags = {
|
|
@@ -83,8 +88,20 @@ Transform.flags = {
|
|
|
83
88
|
(OpenApi3Json|OpenApi3Yaml|APIMATIC|WADL2009|WADL2006|WSDL|
|
|
84
89
|
Swagger10|Swagger20|SwaggerYaml|RAML|RAML10|Postman10|Postman20)`
|
|
85
90
|
}),
|
|
86
|
-
file: command_1.flags.string({
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
file: command_1.flags.string({
|
|
92
|
+
parse: (input) => path.resolve(input),
|
|
93
|
+
default: "",
|
|
94
|
+
description: "path to the API specification file to transform"
|
|
95
|
+
}),
|
|
96
|
+
url: command_1.flags.string({
|
|
97
|
+
default: "",
|
|
98
|
+
description: "URL to the API specification file to transform. Can be used in place of the --file option if the API specification is publicly available."
|
|
99
|
+
}),
|
|
100
|
+
destination: command_1.flags.string({
|
|
101
|
+
parse: (input) => path.resolve(input),
|
|
102
|
+
default: path.resolve("./"),
|
|
103
|
+
description: "directory to download transformed file to"
|
|
104
|
+
}),
|
|
105
|
+
force: command_1.flags.boolean({ char: "f", default: false, description: "overwrite if same file exist in the destination" }),
|
|
106
|
+
"auth-key": command_1.flags.string({ description: "override current authentication state with an authentication key" })
|
|
90
107
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const fs = require("fs-extra");
|
|
4
|
-
const
|
|
4
|
+
const sdk_1 = require("@apimatic/sdk");
|
|
5
5
|
const command_1 = require("@oclif/command");
|
|
6
6
|
const sdk_client_1 = require("../../client-utils/sdk-client");
|
|
7
7
|
const utils_1 = require("../../utils/utils");
|
|
@@ -16,7 +16,7 @@ class Validate extends command_1.Command {
|
|
|
16
16
|
}
|
|
17
17
|
const overrideAuthKey = flags["auth-key"] ? flags["auth-key"] : null;
|
|
18
18
|
const client = await sdk_client_1.SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
|
|
19
|
-
const apiValidationController = new
|
|
19
|
+
const apiValidationController = new sdk_1.APIValidationExternalApisController(client);
|
|
20
20
|
const validationSummary = await validate_1.getValidation(flags, apiValidationController);
|
|
21
21
|
transform_1.printValidationMessages(validationSummary, this.warn, this.error);
|
|
22
22
|
validationSummary.success
|
|
@@ -44,15 +44,21 @@ class Validate extends command_1.Command {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
exports.default = Validate;
|
|
47
|
-
Validate.description = "
|
|
47
|
+
Validate.description = "Validate the syntactic and semantic correctness of an API specification";
|
|
48
48
|
Validate.examples = [
|
|
49
49
|
`$ apimatic api:validate --file="./specs/sample.json"
|
|
50
50
|
Specification file provided is valid
|
|
51
|
+
`,
|
|
52
|
+
`$ apimatic api:validate --url=https://petstore.swagger.io/v2/swagger.json
|
|
53
|
+
Specification file provided is valid
|
|
51
54
|
`
|
|
52
55
|
];
|
|
53
56
|
Validate.flags = {
|
|
54
|
-
file: command_1.flags.string({ default: "", description: "
|
|
55
|
-
url: command_1.flags.string({
|
|
57
|
+
file: command_1.flags.string({ default: "", description: "Path to the API specification file to validate" }),
|
|
58
|
+
url: command_1.flags.string({
|
|
59
|
+
default: "",
|
|
60
|
+
description: "URL to the specification file to validate. Can be used in place of the --file option if the API specification is publicly available."
|
|
61
|
+
}),
|
|
56
62
|
// docs: flags.boolean({ default: false, description: "Validate specification for docs generation" }), // Next tier, not included in API spec
|
|
57
|
-
"auth-key": command_1.flags.string({ description: "override current
|
|
63
|
+
"auth-key": command_1.flags.string({ description: "override current authentication state with an authentication key" })
|
|
58
64
|
};
|
|
@@ -5,7 +5,7 @@ class Auth extends command_1.Command {
|
|
|
5
5
|
constructor() {
|
|
6
6
|
super(...arguments);
|
|
7
7
|
this.run = async () => {
|
|
8
|
-
this.log(`
|
|
8
|
+
this.log(`Manage this CLI's authentication state.
|
|
9
9
|
|
|
10
10
|
USAGE
|
|
11
11
|
$ apimatic auth
|
|
@@ -14,12 +14,12 @@ EXAMPLE
|
|
|
14
14
|
$ apimatic auth --help
|
|
15
15
|
|
|
16
16
|
COMMANDS
|
|
17
|
-
auth:login
|
|
18
|
-
auth:logout
|
|
19
|
-
auth:status
|
|
17
|
+
auth:login Login using your APIMatic credentials or an API Key
|
|
18
|
+
auth:logout Clear local login credentials
|
|
19
|
+
auth:status View current authentication state`);
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
exports.default = Auth;
|
|
24
|
-
Auth.description = "
|
|
24
|
+
Auth.description = "Manage this CLI's authentication state.";
|
|
25
25
|
Auth.examples = ["$ apimatic auth --help"];
|
|
@@ -44,14 +44,16 @@ class Login extends command_1.Command {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
exports.default = Login;
|
|
47
|
-
Login.description = "
|
|
47
|
+
Login.description = "Login using your APIMatic credentials or an API Key";
|
|
48
48
|
Login.examples = [
|
|
49
49
|
`$ apimatic auth:login
|
|
50
50
|
Please enter your registered email: apimatic-user@gmail.com
|
|
51
51
|
Please enter your password: *********
|
|
52
52
|
|
|
53
53
|
You have successfully logged into APIMatic
|
|
54
|
-
|
|
54
|
+
`,
|
|
55
|
+
`$ apimatic auth:login --auth-key=xxxxxx
|
|
56
|
+
Authentication key successfully set`
|
|
55
57
|
];
|
|
56
58
|
Login.flags = {
|
|
57
59
|
"auth-key": command_1.flags.string({ default: "", description: "Set authentication key for all commands" })
|
|
@@ -15,7 +15,7 @@ class Status extends command_1.Command {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
exports.default = Status;
|
|
18
|
-
Status.description = "
|
|
18
|
+
Status.description = "View current authentication state";
|
|
19
19
|
Status.examples = [
|
|
20
20
|
`$ apimatic auth:status
|
|
21
21
|
Currently logged in as apimatic-client@gmail.com
|
|
@@ -4,6 +4,7 @@ export default class PortalGenerate extends Command {
|
|
|
4
4
|
static flags: {
|
|
5
5
|
folder: flags.IOptionFlag<string>;
|
|
6
6
|
destination: flags.IOptionFlag<string>;
|
|
7
|
+
force: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
7
8
|
zip: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
8
9
|
"auth-key": flags.IOptionFlag<string>;
|
|
9
10
|
};
|
|
@@ -4,7 +4,7 @@ const fs = require("fs-extra");
|
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const cli_ux_1 = require("cli-ux");
|
|
6
6
|
const command_1 = require("@oclif/command");
|
|
7
|
-
const
|
|
7
|
+
const sdk_1 = require("@apimatic/sdk");
|
|
8
8
|
const sdk_client_1 = require("../../client-utils/sdk-client");
|
|
9
9
|
const generate_1 = require("../../controllers/portal/generate");
|
|
10
10
|
const utils_1 = require("../../utils/utils");
|
|
@@ -12,9 +12,17 @@ class PortalGenerate extends command_1.Command {
|
|
|
12
12
|
async run() {
|
|
13
13
|
const { flags } = this.parse(PortalGenerate);
|
|
14
14
|
const zip = flags.zip;
|
|
15
|
-
const
|
|
16
|
-
const
|
|
15
|
+
const sourceFolderPath = flags.folder;
|
|
16
|
+
const portalFolderPath = path.join(flags.destination, "generated_portal");
|
|
17
|
+
const zippedPortalPath = path.join(flags.destination, "generated_portal.zip");
|
|
17
18
|
const overrideAuthKey = flags["auth-key"] ? flags["auth-key"] : null;
|
|
19
|
+
// Check if at destination, portal already exists and throw error if force flag is not set for both zip and extracted
|
|
20
|
+
if (fs.existsSync(portalFolderPath) && !flags.force && !zip) {
|
|
21
|
+
throw new Error(`Can't download portal to path ${portalFolderPath}, because it already exists`);
|
|
22
|
+
}
|
|
23
|
+
else if (fs.existsSync(zippedPortalPath) && !flags.force && zip) {
|
|
24
|
+
throw new Error(`Can't download portal to path ${zippedPortalPath}, because it already exists`);
|
|
25
|
+
}
|
|
18
26
|
try {
|
|
19
27
|
if (!(await fs.pathExists(flags.destination))) {
|
|
20
28
|
throw new Error(`Destination path ${flags.destination} does not exist`);
|
|
@@ -23,11 +31,12 @@ class PortalGenerate extends command_1.Command {
|
|
|
23
31
|
throw new Error(`Portal build folder ${flags.folder} does not exist`);
|
|
24
32
|
}
|
|
25
33
|
const client = await sdk_client_1.SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
|
|
26
|
-
const docsPortalController = new
|
|
27
|
-
const zippedBuildFilePath = await utils_1.zipDirectory(
|
|
34
|
+
const docsPortalController = new sdk_1.DocsPortalManagementController(client);
|
|
35
|
+
const zippedBuildFilePath = await utils_1.zipDirectory(sourceFolderPath, flags.destination);
|
|
28
36
|
const generatePortalParams = {
|
|
29
37
|
zippedBuildFilePath,
|
|
30
|
-
|
|
38
|
+
portalFolderPath,
|
|
39
|
+
zippedPortalPath,
|
|
31
40
|
docsPortalController,
|
|
32
41
|
overrideAuthKey,
|
|
33
42
|
zip
|
|
@@ -69,22 +78,23 @@ class PortalGenerate extends command_1.Command {
|
|
|
69
78
|
}
|
|
70
79
|
}
|
|
71
80
|
exports.default = PortalGenerate;
|
|
72
|
-
PortalGenerate.description = "Generate static
|
|
81
|
+
PortalGenerate.description = "Generate and download a static API Documentation portal. Requires an input directory containing API specifications, a config file and optionally, markdown guides. For details, refer to the [documentation](https://portal-api-docs.apimatic.io/#/http/generating-api-portal/build-file)";
|
|
73
82
|
PortalGenerate.flags = {
|
|
74
83
|
folder: command_1.flags.string({
|
|
75
84
|
parse: (input) => path.resolve(input),
|
|
76
85
|
default: "",
|
|
77
|
-
description: "
|
|
86
|
+
description: "path to the input directory containing API specifications and config files"
|
|
78
87
|
}),
|
|
79
88
|
destination: command_1.flags.string({
|
|
80
89
|
parse: (input) => path.resolve(input),
|
|
81
|
-
default: "./",
|
|
90
|
+
default: path.resolve("./"),
|
|
82
91
|
description: "path to the downloaded portal"
|
|
83
92
|
}),
|
|
84
|
-
|
|
93
|
+
force: command_1.flags.boolean({ char: "f", default: false, description: "overwrite if a portal exists in the destination" }),
|
|
94
|
+
zip: command_1.flags.boolean({ default: false, description: "download the generated portal as a .zip archive" }),
|
|
85
95
|
"auth-key": command_1.flags.string({
|
|
86
96
|
default: "",
|
|
87
|
-
description: "override current
|
|
97
|
+
description: "override current authentication state with an authentication key"
|
|
88
98
|
})
|
|
89
99
|
};
|
|
90
100
|
PortalGenerate.examples = [
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const command_1 = require("@oclif/command");
|
|
4
4
|
class SDK extends command_1.Command {
|
|
5
5
|
async run() {
|
|
6
|
-
this.log(`
|
|
6
|
+
this.log(`Manage API documentation portals
|
|
7
7
|
|
|
8
8
|
USAGE
|
|
9
9
|
$ apimatic portal
|
|
@@ -12,9 +12,9 @@ EXAMPLE
|
|
|
12
12
|
$apimatic portal --help
|
|
13
13
|
|
|
14
14
|
COMMANDS
|
|
15
|
-
portal:generate Generate static
|
|
15
|
+
portal:generate Generate and download a static API Documentation portal. Requires an input directory containing API specifications, a config file and optionally, markdown guides. For details, refer to the [documentation](https://portal-api-docs.apimatic.io/#/http/generating-api-portal/build-file)`);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
exports.default = SDK;
|
|
19
|
-
SDK.description = "
|
|
19
|
+
SDK.description = "Manage API documentation portals";
|
|
20
20
|
SDK.examples = ["$apimatic portal --help"];
|
|
@@ -6,6 +6,7 @@ export default class SdkGenerate extends Command {
|
|
|
6
6
|
file: flags.IOptionFlag<string>;
|
|
7
7
|
url: flags.IOptionFlag<string>;
|
|
8
8
|
destination: flags.IOptionFlag<string>;
|
|
9
|
+
force: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
9
10
|
zip: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
|
|
10
11
|
"auth-key": flags.IOptionFlag<string>;
|
|
11
12
|
};
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const fs = require("fs-extra");
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const cli_ux_1 = require("cli-ux");
|
|
6
|
-
const
|
|
6
|
+
const sdk_1 = require("@apimatic/sdk");
|
|
7
7
|
const command_1 = require("@oclif/command");
|
|
8
8
|
const sdk_client_1 = require("../../client-utils/sdk-client");
|
|
9
9
|
const utils_1 = require("../../utils/utils");
|
|
@@ -12,6 +12,16 @@ class SdkGenerate extends command_1.Command {
|
|
|
12
12
|
async run() {
|
|
13
13
|
const { flags } = this.parse(SdkGenerate);
|
|
14
14
|
const zip = flags.zip;
|
|
15
|
+
const fileName = flags.file ? utils_1.getFileNameFromPath(flags.file) : utils_1.getFileNameFromPath(flags.url);
|
|
16
|
+
const sdkFolderPath = path.join(flags.destination, `${fileName}_sdk_${flags.platform}`.toLowerCase());
|
|
17
|
+
const zippedSDKPath = path.join(flags.destination, `${fileName}_sdk_${flags.platform}.zip`.toLowerCase());
|
|
18
|
+
// Check if at destination, SDK already exists and throw error if force flag is not set for both zip and extracted
|
|
19
|
+
if (fs.existsSync(sdkFolderPath) && !flags.force && !zip) {
|
|
20
|
+
throw new Error(`Can't download SDK to path ${sdkFolderPath}, because it already exists`);
|
|
21
|
+
}
|
|
22
|
+
else if (fs.existsSync(zippedSDKPath) && !flags.force && zip) {
|
|
23
|
+
throw new Error(`Can't download SDK to path ${zippedSDKPath}, because it already exists`);
|
|
24
|
+
}
|
|
15
25
|
try {
|
|
16
26
|
if (!(await fs.pathExists(path.resolve(flags.destination)))) {
|
|
17
27
|
throw new Error(`Destination path ${flags.destination} does not exist`);
|
|
@@ -19,18 +29,9 @@ class SdkGenerate extends command_1.Command {
|
|
|
19
29
|
else if (!(await fs.pathExists(path.resolve(flags.file)))) {
|
|
20
30
|
throw new Error(`Specification file ${flags.file} does not exist`);
|
|
21
31
|
}
|
|
22
|
-
const fileName = flags.file ? utils_1.getFileNameFromPath(flags.file) : utils_1.getFileNameFromPath(flags.url);
|
|
23
|
-
const sdkFolderPath = path.join(flags.destination, `${fileName}_sdk_${flags.platform}`.toLowerCase());
|
|
24
|
-
const zippedSDKPath = path.join(flags.destination, `${fileName}_sdk_${flags.platform}.zip`.toLowerCase());
|
|
25
|
-
if (fs.existsSync(zippedSDKPath) && zip) {
|
|
26
|
-
throw new Error(`Can't generate SDK to path ${zippedSDKPath}, because it already exists`);
|
|
27
|
-
}
|
|
28
|
-
else if (fs.existsSync(sdkFolderPath) && !zip) {
|
|
29
|
-
throw new Error(`Can't generate SDK to path ${sdkFolderPath}, because it already exists`);
|
|
30
|
-
}
|
|
31
32
|
const overrideAuthKey = flags["auth-key"] ? flags["auth-key"] : null;
|
|
32
33
|
const client = await sdk_client_1.SDKClient.getInstance().getClient(overrideAuthKey, this.config.configDir);
|
|
33
|
-
const sdkGenerationController = new
|
|
34
|
+
const sdkGenerationController = new sdk_1.CodeGenerationExternalApisController(client);
|
|
34
35
|
// Get generation id for the specification and platform
|
|
35
36
|
const codeGenId = await generate_1.getSDKGenerationId(flags, sdkGenerationController);
|
|
36
37
|
// If user wanted to download the SDK as well
|
|
@@ -94,22 +95,36 @@ Legacy: CS_NET_STANDARD_LIB|CS_PORTABLE_NET_LIB|CS_UNIVERSAL_WINDOWS_PLATFORM_LI
|
|
|
94
95
|
file: command_1.flags.string({
|
|
95
96
|
parse: (input) => path.resolve(input),
|
|
96
97
|
default: "",
|
|
97
|
-
description: "path to the API specification to generate
|
|
98
|
+
description: "path to the API specification to generate SDKs for"
|
|
99
|
+
}),
|
|
100
|
+
url: command_1.flags.string({
|
|
101
|
+
default: "",
|
|
102
|
+
description: "URL to the API specification to generate SDKs for. Can be used in place of the --file option if the API specification is publicly available."
|
|
98
103
|
}),
|
|
99
|
-
url: command_1.flags.string({ default: "", description: "URL to the API specification to generate SDK" }),
|
|
100
104
|
destination: command_1.flags.string({
|
|
101
105
|
parse: (input) => path.resolve(input),
|
|
102
|
-
default: "./",
|
|
103
|
-
description: "
|
|
106
|
+
default: path.resolve("./"),
|
|
107
|
+
description: "directory to download the generated SDK to"
|
|
108
|
+
}),
|
|
109
|
+
force: command_1.flags.boolean({
|
|
110
|
+
char: "f",
|
|
111
|
+
default: false,
|
|
112
|
+
description: "overwrite if an SDK already exists in the destination"
|
|
104
113
|
}),
|
|
105
|
-
zip: command_1.flags.boolean({ default: false, description: "
|
|
114
|
+
zip: command_1.flags.boolean({ default: false, description: "download the generated SDK as a .zip archive" }),
|
|
106
115
|
"auth-key": command_1.flags.string({
|
|
107
116
|
default: "",
|
|
108
|
-
description: "override current
|
|
117
|
+
description: "override current authentication state with an authentication key"
|
|
109
118
|
})
|
|
110
119
|
};
|
|
111
120
|
SdkGenerate.examples = [
|
|
112
121
|
`$ apimatic sdk:generate --platform="CSHARP" --file="./specs/sample.json"
|
|
113
|
-
SDK
|
|
122
|
+
Generating SDK... done
|
|
123
|
+
Downloading SDK... done
|
|
124
|
+
Success! Your SDK is located at swagger_sdk_csharp`,
|
|
125
|
+
`$ apimatic sdk:generate --platform="CSHARP" --url=https://petstore.swagger.io/v2/swagger.json
|
|
126
|
+
Generating SDK... done
|
|
127
|
+
Downloading SDK... done
|
|
128
|
+
Success! Your SDK is located at swagger_sdk_csharp
|
|
114
129
|
`
|
|
115
130
|
];
|
|
@@ -4,7 +4,7 @@ const command_1 = require("@oclif/command");
|
|
|
4
4
|
class SDK extends command_1.Command {
|
|
5
5
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
6
6
|
async run() {
|
|
7
|
-
this.log(`
|
|
7
|
+
this.log(`Generate and manage SDKs for APIs
|
|
8
8
|
|
|
9
9
|
USAGE
|
|
10
10
|
$ apimatic sdk
|
|
@@ -17,5 +17,5 @@ COMMANDS
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
exports.default = SDK;
|
|
20
|
-
SDK.description = "
|
|
20
|
+
SDK.description = "Generate and manage SDKs for APIs";
|
|
21
21
|
SDK.examples = ["$apimatic sdk --help"];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Command from "@oclif/command";
|
|
2
|
-
import { ApiValidationSummary, ExportFormats, Transformation, TransformationController } from "@apimatic/
|
|
2
|
+
import { ApiValidationSummary, ExportFormats, Transformation, TransformationController } from "@apimatic/sdk";
|
|
3
3
|
import { DownloadTransformationParams, TransformationIdParams } from "../../types/api/transform";
|
|
4
4
|
export declare const getTransformationId: ({ file, url, format }: TransformationIdParams, transformationController: TransformationController) => Promise<Transformation>;
|
|
5
5
|
export declare const downloadTransformationFile: ({ id, destinationFilePath, transformationController }: DownloadTransformationParams) => Promise<string>;
|
|
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.printValidationMessages = exports.getValidFormat = exports.downloadTransformationFile = exports.getTransformationId = void 0;
|
|
4
4
|
const cli_ux_1 = require("cli-ux");
|
|
5
5
|
const fs = require("fs-extra");
|
|
6
|
-
const
|
|
6
|
+
const sdk_1 = require("@apimatic/sdk");
|
|
7
7
|
const utils_1 = require("../../utils/utils");
|
|
8
8
|
exports.getTransformationId = async ({ file, url, format }, transformationController) => {
|
|
9
9
|
cli_ux_1.default.action.start("Transforming API specification");
|
|
10
10
|
let generation;
|
|
11
11
|
if (file) {
|
|
12
|
-
const fileDescriptor = new
|
|
12
|
+
const fileDescriptor = new sdk_1.FileWrapper(fs.createReadStream(file));
|
|
13
13
|
generation = await transformationController.transformViaFile(fileDescriptor, format);
|
|
14
14
|
}
|
|
15
15
|
else if (url) {
|
|
@@ -39,11 +39,11 @@ exports.downloadTransformationFile = async ({ id, destinationFilePath, transform
|
|
|
39
39
|
};
|
|
40
40
|
// Get valid platform from user's input, convert simple platform to valid Platforms enum value
|
|
41
41
|
exports.getValidFormat = (format) => {
|
|
42
|
-
if (Object.keys(
|
|
43
|
-
return
|
|
42
|
+
if (Object.keys(sdk_1.ExportFormats).find((exportFormat) => exportFormat === format)) {
|
|
43
|
+
return sdk_1.ExportFormats[format];
|
|
44
44
|
}
|
|
45
45
|
else {
|
|
46
|
-
const formats = Object.keys(
|
|
46
|
+
const formats = Object.keys(sdk_1.ExportFormats).join("|");
|
|
47
47
|
throw new Error(`Please provide a valid platform i.e. ${formats}`);
|
|
48
48
|
}
|
|
49
49
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Command from "@oclif/command";
|
|
2
|
-
import { APIValidationExternalApisController, ApiValidationSummary } from "@apimatic/
|
|
2
|
+
import { APIValidationExternalApisController, ApiValidationSummary } from "@apimatic/sdk";
|
|
3
3
|
import { GetValidationParams } from "../../types/api/validate";
|
|
4
4
|
export declare const getValidation: ({ file, url }: GetValidationParams, apiValidationController: APIValidationExternalApisController) => Promise<ApiValidationSummary>;
|
|
5
5
|
export declare const printValidationMessages: ({ warnings, errors }: ApiValidationSummary, warn: Command["warn"], error: Command["error"]) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { GeneratePortalParams } from "../../types/portal/generate";
|
|
2
|
-
export declare const downloadDocsPortal: ({ zippedBuildFilePath,
|
|
2
|
+
export declare const downloadDocsPortal: ({ zippedBuildFilePath, portalFolderPath, zippedPortalPath, overrideAuthKey, zip }: GeneratePortalParams, configDir: string) => Promise<string>;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.downloadDocsPortal = void 0;
|
|
4
4
|
const fs = require("fs-extra");
|
|
5
5
|
const FormData = require("form-data");
|
|
6
|
-
const path = require("path");
|
|
7
6
|
const cli_ux_1 = require("cli-ux");
|
|
8
7
|
const auth_manager_1 = require("../../client-utils/auth-manager");
|
|
9
8
|
const env_1 = require("../../config/env");
|
|
@@ -22,9 +21,7 @@ const downloadPortalAxios = async (zippedBuildFilePath, overrideAuthKey, configD
|
|
|
22
21
|
return data;
|
|
23
22
|
};
|
|
24
23
|
// Download Docs Portal
|
|
25
|
-
exports.downloadDocsPortal = async ({ zippedBuildFilePath,
|
|
26
|
-
const zippedPortalPath = path.join(generatedPortalFolderPath, "generated_portal.zip");
|
|
27
|
-
const portalPath = path.join(generatedPortalFolderPath, "generated_portal");
|
|
24
|
+
exports.downloadDocsPortal = async ({ zippedBuildFilePath, portalFolderPath, zippedPortalPath, overrideAuthKey, zip }, configDir) => {
|
|
28
25
|
cli_ux_1.default.action.start("Downloading portal");
|
|
29
26
|
// Check if the build file exists for the user or not
|
|
30
27
|
if (!(await fs.pathExists(zippedBuildFilePath))) {
|
|
@@ -41,11 +38,11 @@ exports.downloadDocsPortal = async ({ zippedBuildFilePath, generatedPortalFolder
|
|
|
41
38
|
// if ((data as NodeJS.ReadableStream).readable) {
|
|
42
39
|
// await writeFileUsingReadableStream(data as NodeJS.ReadableStream, zippedPortalPath);
|
|
43
40
|
if (!zip) {
|
|
44
|
-
await utils_1.unzipFile(fs.createReadStream(zippedPortalPath),
|
|
41
|
+
await utils_1.unzipFile(fs.createReadStream(zippedPortalPath), portalFolderPath);
|
|
45
42
|
await utils_1.deleteFile(zippedPortalPath);
|
|
46
43
|
}
|
|
47
44
|
cli_ux_1.default.action.stop();
|
|
48
|
-
return zip ? zippedPortalPath :
|
|
45
|
+
return zip ? zippedPortalPath : portalFolderPath;
|
|
49
46
|
// } else {
|
|
50
47
|
// throw new Error("Couldn't download the portal");
|
|
51
48
|
// }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodeGenerationExternalApisController } from "@apimatic/
|
|
1
|
+
import { CodeGenerationExternalApisController } from "@apimatic/sdk";
|
|
2
2
|
import { GenerationIdParams, DownloadSDKParams } from "../../types/sdk/generate";
|
|
3
3
|
export declare const getSDKGenerationId: ({ file, url, platform }: GenerationIdParams, sdkGenerationController: CodeGenerationExternalApisController) => Promise<string>;
|
|
4
4
|
export declare const downloadGeneratedSDK: ({ codeGenId, zippedSDKPath, sdkFolderPath, zip }: DownloadSDKParams, sdkGenerationController: CodeGenerationExternalApisController) => Promise<string>;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.downloadGeneratedSDK = exports.getSDKGenerationId = void 0;
|
|
4
4
|
const fs = require("fs-extra");
|
|
5
5
|
const cli_ux_1 = require("cli-ux");
|
|
6
|
-
const
|
|
6
|
+
const sdk_1 = require("@apimatic/sdk");
|
|
7
7
|
const core_1 = require("@apimatic/core");
|
|
8
8
|
const generate_1 = require("../../types/sdk/generate");
|
|
9
9
|
const utils_1 = require("../../utils/utils");
|
|
@@ -34,11 +34,11 @@ const getSDKPlatform = (platform) => {
|
|
|
34
34
|
if (Object.keys(generate_1.SimplePlatforms).includes(platform)) {
|
|
35
35
|
return generate_1.SimplePlatforms[platform];
|
|
36
36
|
}
|
|
37
|
-
else if (Object.values(
|
|
37
|
+
else if (Object.values(sdk_1.Platforms).includes(platform)) {
|
|
38
38
|
return platform;
|
|
39
39
|
}
|
|
40
40
|
else {
|
|
41
|
-
const platforms = Object.keys(generate_1.SimplePlatforms).concat(Object.values(
|
|
41
|
+
const platforms = Object.keys(generate_1.SimplePlatforms).concat(Object.values(sdk_1.Platforms)).join("|");
|
|
42
42
|
throw new Error(`Please provide a valid platform i.e. ${platforms}`);
|
|
43
43
|
}
|
|
44
44
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { DocsPortalManagementController } from "@apimatic/
|
|
1
|
+
import { DocsPortalManagementController } from "@apimatic/sdk";
|
|
2
2
|
export declare type GeneratePortalParams = {
|
|
3
3
|
zippedBuildFilePath: string;
|
|
4
|
-
|
|
4
|
+
portalFolderPath: string;
|
|
5
|
+
zippedPortalPath: string;
|
|
5
6
|
docsPortalController: DocsPortalManagementController;
|
|
6
7
|
overrideAuthKey: string | null;
|
|
7
8
|
zip: boolean;
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"1.0.1-alpha.
|
|
1
|
+
{"version":"1.0.1-alpha.6","commands":{"api":{"id":"api","description":"Manage APIs","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic api --help"],"flags":{},"args":[]},"api:transform":{"id":"api:transform","description":"Transform API specifications from one format to another. Supports [10+ different formats](https://www.apimatic.io/transformer/#supported-formats) including OpenApi/Swagger, RAML, WSDL and Postman Collections.","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic api:transform --format=\"OpenApi3Json\" --file=\"./specs/sample.json\" --destination=\"D:/\"\nSuccess! Your transformed file is located at D:/Transformed_OpenApi3Json.json\n","$ apimatic api:transform --format=RAML --url=\"https://petstore.swagger.io/v2/swagger.json\" --destination=\"D:/\"\nSuccess! Your transformed file is located at D:/swagger_raml.yaml\n"],"flags":{"format":{"name":"format","type":"option","description":"specification format to transform API specification into\n(OpenApi3Json|OpenApi3Yaml|APIMATIC|WADL2009|WADL2006|WSDL|\nSwagger10|Swagger20|SwaggerYaml|RAML|RAML10|Postman10|Postman20)","required":true},"file":{"name":"file","type":"option","description":"path to the API specification file to transform","default":""},"url":{"name":"url","type":"option","description":"URL to the API specification file to transform. Can be used in place of the --file option if the API specification is publicly available.","default":""},"destination":{"name":"destination","type":"option","description":"directory to download transformed file to","default":"/home/runner/work/apimatic-cli/apimatic-cli/cli"},"force":{"name":"force","type":"boolean","char":"f","description":"overwrite if same file exist in the destination","allowNo":false},"auth-key":{"name":"auth-key","type":"option","description":"override current authentication state with an authentication key"}},"args":[]},"api:validate":{"id":"api:validate","description":"Validate the syntactic and semantic correctness of an API specification","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic api:validate --file=\"./specs/sample.json\"\nSpecification file provided is valid\n","$ apimatic api:validate --url=https://petstore.swagger.io/v2/swagger.json\nSpecification file provided is valid\n"],"flags":{"file":{"name":"file","type":"option","description":"Path to the API specification file to validate","default":""},"url":{"name":"url","type":"option","description":"URL to the specification file to validate. Can be used in place of the --file option if the API specification is publicly available.","default":""},"auth-key":{"name":"auth-key","type":"option","description":"override current authentication state with an authentication key"}},"args":[]},"auth":{"id":"auth","description":"Manage this CLI's authentication state.","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic auth --help"],"flags":{},"args":[]},"auth:login":{"id":"auth:login","description":"Login using your APIMatic credentials or an API Key","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic auth:login\nPlease enter your registered email: apimatic-user@gmail.com\nPlease enter your password: *********\n\nYou have successfully logged into APIMatic\n","$ apimatic auth:login --auth-key=xxxxxx\nAuthentication key successfully set"],"flags":{"auth-key":{"name":"auth-key","type":"option","description":"Set authentication key for all commands","default":""}},"args":[]},"auth:logout":{"id":"auth:logout","description":"Clear local login credentials","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic auth:logout\nLogged out\n"],"flags":{},"args":[]},"auth:status":{"id":"auth:status","description":"View current authentication state","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic auth:status\nCurrently logged in as apimatic-client@gmail.com\n"],"flags":{},"args":[]},"portal:generate":{"id":"portal:generate","description":"Generate and download a static API Documentation portal. Requires an input directory containing API specifications, a config file and optionally, markdown guides. For details, refer to the [documentation](https://portal-api-docs.apimatic.io/#/http/generating-api-portal/build-file)","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic portal:generate --folder=\"./portal/\" --destination=\"D:/\"\nYour portal has been generated at D:/\n"],"flags":{"folder":{"name":"folder","type":"option","description":"path to the input directory containing API specifications and config files","default":""},"destination":{"name":"destination","type":"option","description":"path to the downloaded portal","default":"/home/runner/work/apimatic-cli/apimatic-cli/cli"},"force":{"name":"force","type":"boolean","char":"f","description":"overwrite if a portal exists in the destination","allowNo":false},"zip":{"name":"zip","type":"boolean","description":"download the generated portal as a .zip archive","allowNo":false},"auth-key":{"name":"auth-key","type":"option","description":"override current authentication state with an authentication key","default":""}},"args":[]},"portal":{"id":"portal","description":"Manage API documentation portals","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$apimatic portal --help"],"flags":{},"args":[]},"sdk:generate":{"id":"sdk:generate","description":"Generate SDK for your APIs","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$ apimatic sdk:generate --platform=\"CSHARP\" --file=\"./specs/sample.json\"\nGenerating SDK... done\nDownloading SDK... done\nSuccess! Your SDK is located at swagger_sdk_csharp","$ apimatic sdk:generate --platform=\"CSHARP\" --url=https://petstore.swagger.io/v2/swagger.json\nGenerating SDK... done\nDownloading SDK... done\nSuccess! Your SDK is located at swagger_sdk_csharp\n"],"flags":{"platform":{"name":"platform","type":"option","description":"language platform for sdk\nSimple: CSHARP|JAVA|PYTHON|RUBY|PHP|TYPESCRIPT\nLegacy: CS_NET_STANDARD_LIB|CS_PORTABLE_NET_LIB|CS_UNIVERSAL_WINDOWS_PLATFORM_LIB|\n JAVA_ECLIPSE_JRE_LIB|PHP_GENERIC_LIB|PYTHON_GENERIC_LIB|RUBY_GENERIC_LIB|\n TS_GENERIC_LIB","required":true},"file":{"name":"file","type":"option","description":"path to the API specification to generate SDKs for","default":""},"url":{"name":"url","type":"option","description":"URL to the API specification to generate SDKs for. Can be used in place of the --file option if the API specification is publicly available.","default":""},"destination":{"name":"destination","type":"option","description":"directory to download the generated SDK to","default":"/home/runner/work/apimatic-cli/apimatic-cli/cli"},"force":{"name":"force","type":"boolean","char":"f","description":"overwrite if an SDK already exists in the destination","allowNo":false},"zip":{"name":"zip","type":"boolean","description":"download the generated SDK as a .zip archive","allowNo":false},"auth-key":{"name":"auth-key","type":"option","description":"override current authentication state with an authentication key","default":""}},"args":[]},"sdk":{"id":"sdk","description":"Generate and manage SDKs for APIs","pluginName":"@apimatic/cli","pluginType":"core","aliases":[],"examples":["$apimatic sdk --help"],"flags":{},"args":[]}}}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apimatic/cli",
|
|
3
3
|
"description": "The official CLI for APIMatic.",
|
|
4
|
-
"version": "1.0.1-alpha.
|
|
4
|
+
"version": "1.0.1-alpha.6",
|
|
5
5
|
"author": "APIMatic",
|
|
6
6
|
"bin": {
|
|
7
7
|
"apimatic": "./bin/run"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"lint:fix": "eslint --fix \"src/**/*.{js,ts}\" --quiet"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@apimatic/
|
|
48
|
+
"@apimatic/sdk": "^0.0.1-alpha.1",
|
|
49
49
|
"@oclif/command": "^1.8.0",
|
|
50
50
|
"@oclif/config": "^1.17.0",
|
|
51
51
|
"@oclif/plugin-autocomplete": "^0.3.0",
|
package/CHANGELOG.md
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
## [1.0.1-alpha.2](https://github.com/apimatic/apimatic-cli/compare/v1.0.1-alpha.1...v1.0.1-alpha.2) (2021-11-30)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
### Bug Fixes
|
|
5
|
-
|
|
6
|
-
* **refactor:** refactor code ([d7cb486](https://github.com/apimatic/apimatic-cli/commit/d7cb4863bcfd44f297f0525e0c7eae7ecef12695))
|
|
7
|
-
|
|
8
|
-
## [1.0.1-alpha.1](https://github.com/apimatic/apimatic-cli/compare/v1.0.0...v1.0.1-alpha.1) (2021-11-26)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Bug Fixes
|
|
12
|
-
|
|
13
|
-
* **release:** add lock file to gitignore restore check_build workflow ([2eb959a](https://github.com/apimatic/apimatic-cli/commit/2eb959afc2a7ee2317959fc8525930acde2989dc))
|