swaggerhub-cli 0.6.5 → 0.7.0
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 +535 -291
- package/bin/run +3 -3
- package/oclif.manifest.json +1165 -1
- package/package.json +19 -26
- package/src/commands/api/create.js +12 -11
- package/src/commands/api/delete.js +9 -8
- package/src/commands/api/get.js +10 -9
- package/src/commands/api/publish.js +12 -9
- package/src/commands/api/setdefault.js +8 -6
- package/src/commands/api/unpublish.js +8 -6
- package/src/commands/api/update.js +12 -11
- package/src/commands/api/validate.js +31 -13
- package/src/commands/domain/create.js +12 -11
- package/src/commands/domain/delete.js +9 -8
- package/src/commands/domain/get.js +9 -8
- package/src/commands/domain/publish.js +8 -6
- package/src/commands/domain/setdefault.js +8 -6
- package/src/commands/domain/unpublish.js +8 -6
- package/src/commands/domain/update.js +12 -11
- package/src/commands/integration/create.js +10 -9
- package/src/commands/integration/delete.js +8 -6
- package/src/commands/integration/execute.js +8 -6
- package/src/commands/integration/get.js +8 -6
- package/src/commands/integration/list.js +11 -10
- package/src/commands/integration/update.js +9 -8
- package/src/commands/project/api/add.js +10 -12
- package/src/commands/project/api/remove.js +10 -11
- package/src/commands/project/create.js +11 -10
- package/src/commands/project/delete.js +8 -6
- package/src/commands/project/domain/add.js +10 -12
- package/src/commands/project/domain/remove.js +10 -11
- package/src/commands/project/get.js +8 -6
- package/src/commands/project/list.js +10 -9
- package/src/commands/project/member/list.js +10 -9
- package/src/config/index.js +1 -2
- package/src/help.js +1 -1
- package/src/index.js +2 -1
- package/src/support/command/base-command.js +2 -2
- package/src/support/command/handle-response.js +1 -1
- package/src/support/command/parse-input.js +1 -1
- package/src/support/command/update-command.js +1 -1
- package/src/support/http/index.js +1 -3
- package/src/support/isOnPrem.js +10 -0
- package/src/utils/definitions.js +4 -2
- package/src/utils/general.js +29 -1
package/package.json
CHANGED
|
@@ -1,49 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swaggerhub-cli",
|
|
3
3
|
"description": "SwaggerHub CLI",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"author": "SmartBear",
|
|
6
6
|
"bin": {
|
|
7
7
|
"swaggerhub": "./bin/run"
|
|
8
8
|
},
|
|
9
9
|
"bugs": "https://github.com/SmartBear/swaggerhub-cli/issues",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@oclif/
|
|
12
|
-
"@oclif/
|
|
13
|
-
"@oclif/
|
|
14
|
-
"@oclif/plugin-help": "^3.3.1",
|
|
15
|
-
"@oclif/plugin-plugins": "^2.0.11",
|
|
16
|
-
"cli-ux": "^5.6.3",
|
|
11
|
+
"@oclif/core": "^2.8.0",
|
|
12
|
+
"@oclif/plugin-help": "^5.2.8",
|
|
13
|
+
"@oclif/plugin-plugins": "^2.4.3",
|
|
17
14
|
"deep-extend": "^0.6.0",
|
|
18
|
-
"fs-extra": "^
|
|
19
|
-
"inquirer": "^8.
|
|
15
|
+
"fs-extra": "^11.1.0",
|
|
16
|
+
"inquirer": "^8.0.0",
|
|
20
17
|
"js-yaml": "^4.1.0",
|
|
21
|
-
"json-templates": "^4.
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"semver": "^7.3.5"
|
|
18
|
+
"json-templates": "^4.2.0",
|
|
19
|
+
"node-fetch": "^2.6.9",
|
|
20
|
+
"semver": "^7.3.8"
|
|
25
21
|
},
|
|
26
22
|
"devDependencies": {
|
|
27
|
-
"@oclif/
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"chai": "^
|
|
31
|
-
"eslint": "^7.28.0",
|
|
32
|
-
"eslint-plugin-chai-friendly": "^0.7.1",
|
|
23
|
+
"@oclif/test": "^2.3.13",
|
|
24
|
+
"chai": "^4.3.7",
|
|
25
|
+
"eslint": "^8.32.0",
|
|
26
|
+
"eslint-plugin-chai-friendly": "^0.7.2",
|
|
33
27
|
"eslint-plugin-immutable": "^1.0.0",
|
|
34
|
-
"eslint-plugin-mocha": "^
|
|
28
|
+
"eslint-plugin-mocha": "^10.1.0",
|
|
35
29
|
"eslint-plugin-node": "^11.1.0",
|
|
36
|
-
"eslint_d": "^10.1.3",
|
|
37
30
|
"globby": "^11.0.3",
|
|
38
31
|
"husky": "^6.0.0",
|
|
39
|
-
"mocha": "^
|
|
40
|
-
"nock": "^13.
|
|
32
|
+
"mocha": "^10.2.0",
|
|
33
|
+
"nock": "^13.3.0",
|
|
41
34
|
"nyc": "^15.1.0",
|
|
42
35
|
"rewire": "^6.0.0",
|
|
43
36
|
"tmp": "^0.2.1"
|
|
44
37
|
},
|
|
45
38
|
"engines": {
|
|
46
|
-
"node": ">=
|
|
39
|
+
"node": ">=16.0.0"
|
|
47
40
|
},
|
|
48
41
|
"files": [
|
|
49
42
|
"/bin",
|
|
@@ -89,9 +82,9 @@
|
|
|
89
82
|
"repository": "SmartBear/swaggerhub-cli",
|
|
90
83
|
"scripts": {
|
|
91
84
|
"postpack": "rm -f oclif.manifest.json",
|
|
92
|
-
"prepack": "oclif
|
|
85
|
+
"prepack": "npx oclif manifest",
|
|
93
86
|
"test": "nyc mocha --forbid-only \"test/**/*.test.js\"",
|
|
94
|
-
"lint": "
|
|
87
|
+
"lint": "eslint ./src ./test",
|
|
95
88
|
"postinstall": "node ./src/check-node-version"
|
|
96
89
|
},
|
|
97
90
|
"husky": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { Flags, Args } = require('@oclif/core')
|
|
2
2
|
const { readFileSync } = require('fs-extra')
|
|
3
3
|
const { getApi, postApi } = require('../../requests/api')
|
|
4
4
|
const { getApiIdentifierArg, splitPathParams } = require('../../support/command/parse-input')
|
|
@@ -59,7 +59,7 @@ class CreateAPICommand extends UpdateCommand {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
async run() {
|
|
62
|
-
const { args, flags } = this.parse(CreateAPICommand)
|
|
62
|
+
const { args, flags } = await this.parse(CreateAPICommand)
|
|
63
63
|
const definition = parseDefinition(flags.file)
|
|
64
64
|
const specification = getSpecification(definition)
|
|
65
65
|
const apiVersion = getVersion(definition)
|
|
@@ -103,31 +103,32 @@ CreateAPICommand.examples = [
|
|
|
103
103
|
'swaggerhub api:create organization/api/1.0.0 --published=publish --setdefault --file api.json'
|
|
104
104
|
]
|
|
105
105
|
|
|
106
|
-
CreateAPICommand.args =
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
106
|
+
CreateAPICommand.args = {
|
|
107
|
+
'OWNER/API_NAME/[VERSION]': Args.string({
|
|
108
|
+
required: true,
|
|
109
|
+
description: 'API to create on SwaggerHub'
|
|
110
|
+
})
|
|
111
|
+
}
|
|
111
112
|
|
|
112
113
|
CreateAPICommand.flags = {
|
|
113
|
-
file:
|
|
114
|
+
file: Flags.string({
|
|
114
115
|
char: 'f',
|
|
115
116
|
description: 'file location of API to create',
|
|
116
117
|
required: true
|
|
117
118
|
}),
|
|
118
|
-
visibility:
|
|
119
|
+
visibility: Flags.string({
|
|
119
120
|
description: 'visibility of API in SwaggerHub',
|
|
120
121
|
options: ['public', 'private'],
|
|
121
122
|
default: 'private'
|
|
122
123
|
}),
|
|
123
|
-
published:
|
|
124
|
+
published: Flags.string({
|
|
124
125
|
description: 'sets the lifecycle setting of the API version',
|
|
125
126
|
options: ['publish', 'unpublish'],
|
|
126
127
|
default: 'unpublish',
|
|
127
128
|
required: false,
|
|
128
129
|
dependsOn: ['file']
|
|
129
130
|
}),
|
|
130
|
-
setdefault:
|
|
131
|
+
setdefault: Flags.boolean({
|
|
131
132
|
description: 'sets API version to be the default',
|
|
132
133
|
default: false,
|
|
133
134
|
required: false,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { Flags, Args } = require('@oclif/core')
|
|
2
2
|
const { deleteApi } = require('../../requests/api')
|
|
3
3
|
const { getApiIdentifierArg, splitPathParams } = require('../../support/command/parse-input')
|
|
4
4
|
const BaseCommand = require('../../support/command/base-command')
|
|
@@ -7,7 +7,7 @@ const inquirer = require('inquirer')
|
|
|
7
7
|
class DeleteAPICommand extends BaseCommand {
|
|
8
8
|
|
|
9
9
|
async run() {
|
|
10
|
-
const { args, flags } = this.parse(DeleteAPICommand)
|
|
10
|
+
const { args, flags } = await this.parse(DeleteAPICommand)
|
|
11
11
|
const apiPath = getApiIdentifierArg(args)
|
|
12
12
|
const [owner, name, version] = splitPathParams(apiPath)
|
|
13
13
|
|
|
@@ -46,14 +46,15 @@ DeleteAPICommand.examples = [
|
|
|
46
46
|
'swaggerhub api:delete organization/api --force'
|
|
47
47
|
]
|
|
48
48
|
|
|
49
|
-
DeleteAPICommand.args =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
49
|
+
DeleteAPICommand.args = {
|
|
50
|
+
'OWNER/API_NAME/[VERSION]': Args.string({
|
|
51
|
+
required: true,
|
|
52
|
+
description: 'API to delete on SwaggerHub'
|
|
53
|
+
})
|
|
54
|
+
}
|
|
54
55
|
|
|
55
56
|
DeleteAPICommand.flags = {
|
|
56
|
-
force:
|
|
57
|
+
force: Flags.boolean({
|
|
57
58
|
char: 'f',
|
|
58
59
|
description: 'delete API without prompting for confirmation'
|
|
59
60
|
}),
|
package/src/commands/api/get.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { Flags, Args } = require('@oclif/core')
|
|
2
2
|
const { getApiIdentifierArg, reqType, resolvedParam } = require('../../support/command/parse-input')
|
|
3
3
|
const { hasJsonStructure, prettyPrintJSON } = require('../../utils/general')
|
|
4
4
|
const { getApi } = require('../../requests/api')
|
|
@@ -21,7 +21,7 @@ class GetAPICommand extends BaseCommand {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
async run() {
|
|
24
|
-
const { args, flags } = this.parse(GetAPICommand)
|
|
24
|
+
const { args, flags } = await this.parse(GetAPICommand)
|
|
25
25
|
const requestedApiPath = getApiIdentifierArg(args)
|
|
26
26
|
const apiPath = await this.ensureVersion(requestedApiPath)
|
|
27
27
|
const queryParams = resolvedParam(flags)
|
|
@@ -45,18 +45,19 @@ GetAPICommand.examples = [
|
|
|
45
45
|
'swaggerhub api:get organization/api/1.0.0 --json'
|
|
46
46
|
]
|
|
47
47
|
|
|
48
|
-
GetAPICommand.args =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
48
|
+
GetAPICommand.args = {
|
|
49
|
+
'OWNER/API_NAME/[VERSION]': Args.string({
|
|
50
|
+
required: true,
|
|
51
|
+
description: 'API to fetch from Swaggerhub'
|
|
52
|
+
})
|
|
53
|
+
}
|
|
53
54
|
|
|
54
55
|
GetAPICommand.flags = {
|
|
55
|
-
json:
|
|
56
|
+
json: Flags.boolean({
|
|
56
57
|
char: 'j',
|
|
57
58
|
description: 'returns the API in JSON format.'
|
|
58
59
|
}),
|
|
59
|
-
resolved:
|
|
60
|
+
resolved: Flags.boolean({
|
|
60
61
|
char: 'r',
|
|
61
62
|
description: 'gets the resolved API definition (supported in v1.25+). '
|
|
62
63
|
}),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { Flags, Args } = require('@oclif/core')
|
|
2
2
|
const { getApiIdentifierArg, splitPathParams } = require('../../support/command/parse-input')
|
|
3
3
|
const BaseCommand = require('../../support/command/base-command')
|
|
4
4
|
const UpdateCommand = require('../../support/command/update-command')
|
|
@@ -6,7 +6,7 @@ const inquirer = require('inquirer')
|
|
|
6
6
|
|
|
7
7
|
class PublishCommand extends UpdateCommand {
|
|
8
8
|
async run() {
|
|
9
|
-
const { args, flags } = this.parse(PublishCommand)
|
|
9
|
+
const { args, flags } = await this.parse(PublishCommand)
|
|
10
10
|
const apiPath = getApiIdentifierArg(args)
|
|
11
11
|
const [owner, name, version] = splitPathParams(apiPath)
|
|
12
12
|
|
|
@@ -18,7 +18,9 @@ class PublishCommand extends UpdateCommand {
|
|
|
18
18
|
{
|
|
19
19
|
type: 'confirm',
|
|
20
20
|
name: 'answer',
|
|
21
|
-
message: `You are about to publish an API referencing unpublished Domains.
|
|
21
|
+
message: `You are about to publish an API referencing unpublished Domains.
|
|
22
|
+
If those Domains change, it may affect your API definition.
|
|
23
|
+
Do you wish to continue?`,
|
|
22
24
|
default: false
|
|
23
25
|
}
|
|
24
26
|
])
|
|
@@ -33,14 +35,15 @@ PublishCommand.examples = [
|
|
|
33
35
|
'swaggerhub api:publish organization/api/1.0.0 --force'
|
|
34
36
|
]
|
|
35
37
|
|
|
36
|
-
PublishCommand.args =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
38
|
+
PublishCommand.args = {
|
|
39
|
+
'OWNER/API_NAME/VERSION': Args.string({
|
|
40
|
+
required: true,
|
|
41
|
+
description: 'API to publish on Swaggerhub'
|
|
42
|
+
})
|
|
43
|
+
}
|
|
41
44
|
|
|
42
45
|
PublishCommand.flags = {
|
|
43
|
-
force:
|
|
46
|
+
force: Flags.boolean({
|
|
44
47
|
char: 'f',
|
|
45
48
|
description: 'publish API without prompting for confirmation'
|
|
46
49
|
}),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { Args } = require('@oclif/core')
|
|
1
2
|
const { getApiIdentifierArg, splitPathParams } = require('../../support/command/parse-input')
|
|
2
3
|
const BaseCommand = require('../../support/command/base-command')
|
|
3
4
|
const UpdateCommand = require('../../support/command/update-command')
|
|
@@ -5,7 +6,7 @@ const UpdateCommand = require('../../support/command/update-command')
|
|
|
5
6
|
class SetDefaultCommand extends UpdateCommand {
|
|
6
7
|
|
|
7
8
|
async run() {
|
|
8
|
-
const { args } = this.parse(SetDefaultCommand)
|
|
9
|
+
const { args } = await this.parse(SetDefaultCommand)
|
|
9
10
|
const apiPath = getApiIdentifierArg(args)
|
|
10
11
|
const [owner, name, version] = splitPathParams(apiPath)
|
|
11
12
|
|
|
@@ -19,11 +20,12 @@ SetDefaultCommand.examples = [
|
|
|
19
20
|
'swaggerhub api:setdefault organization/api/2.0.0'
|
|
20
21
|
]
|
|
21
22
|
|
|
22
|
-
SetDefaultCommand.args =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
23
|
+
SetDefaultCommand.args = {
|
|
24
|
+
'OWNER/API_NAME/VERSION': Args.string({
|
|
25
|
+
required: true,
|
|
26
|
+
description: 'API to set as default on Swaggerhub'
|
|
27
|
+
})
|
|
28
|
+
}
|
|
27
29
|
|
|
28
30
|
SetDefaultCommand.flags = BaseCommand.flags
|
|
29
31
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { Args } = require('@oclif/core')
|
|
1
2
|
const { getApiIdentifierArg, splitPathParams } = require('../../support/command/parse-input')
|
|
2
3
|
const BaseCommand = require('../../support/command/base-command')
|
|
3
4
|
const UpdateCommand = require('../../support/command/update-command')
|
|
@@ -5,7 +6,7 @@ const UpdateCommand = require('../../support/command/update-command')
|
|
|
5
6
|
class UnpublishCommand extends UpdateCommand {
|
|
6
7
|
|
|
7
8
|
async run() {
|
|
8
|
-
const { args } = this.parse(UnpublishCommand)
|
|
9
|
+
const { args } = await this.parse(UnpublishCommand)
|
|
9
10
|
const apiPath = getApiIdentifierArg(args)
|
|
10
11
|
const [owner, name, version] = splitPathParams(apiPath)
|
|
11
12
|
|
|
@@ -19,11 +20,12 @@ UnpublishCommand.examples = [
|
|
|
19
20
|
'swaggerhub api:unpublish organization/api/1.0.0'
|
|
20
21
|
]
|
|
21
22
|
|
|
22
|
-
UnpublishCommand.args =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
23
|
+
UnpublishCommand.args = {
|
|
24
|
+
'OWNER/API_NAME/VERSION': Args.string({
|
|
25
|
+
required: true,
|
|
26
|
+
description: 'API identifier'
|
|
27
|
+
})
|
|
28
|
+
}
|
|
27
29
|
|
|
28
30
|
UnpublishCommand.flags = BaseCommand.flags
|
|
29
31
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { Flags, Args } = require('@oclif/core')
|
|
2
2
|
const { readFileSync } = require('fs-extra')
|
|
3
3
|
const { getApi, postApi } = require('../../requests/api')
|
|
4
4
|
const { getApiIdentifierArg, splitPathParams } = require('../../support/command/parse-input')
|
|
@@ -30,7 +30,7 @@ class UpdateAPICommand extends UpdateCommand {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
async run() {
|
|
33
|
-
const { args, flags } = this.parse(UpdateAPICommand)
|
|
33
|
+
const { args, flags } = await this.parse(UpdateAPICommand)
|
|
34
34
|
|
|
35
35
|
if (!Object.keys(flags).length) {
|
|
36
36
|
return this.error('No updates specified', { exit: 1 })
|
|
@@ -77,29 +77,30 @@ UpdateAPICommand.examples = [
|
|
|
77
77
|
'swaggerhub api:update organization/api/1.0.0 --visibility=private',
|
|
78
78
|
]
|
|
79
79
|
|
|
80
|
-
UpdateAPICommand.args =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
80
|
+
UpdateAPICommand.args = {
|
|
81
|
+
'OWNER/API_NAME/[VERSION]': Args.string({
|
|
82
|
+
required: true,
|
|
83
|
+
description: 'API to update on SwaggerHub'
|
|
84
|
+
})
|
|
85
|
+
}
|
|
85
86
|
|
|
86
87
|
UpdateAPICommand.flags = {
|
|
87
|
-
file:
|
|
88
|
+
file: Flags.string({
|
|
88
89
|
char: 'f',
|
|
89
90
|
description: 'file location of API to update',
|
|
90
91
|
required: false,
|
|
91
92
|
multiple: false
|
|
92
93
|
}),
|
|
93
|
-
visibility:
|
|
94
|
+
visibility: Flags.string({
|
|
94
95
|
description: 'visibility of API in SwaggerHub',
|
|
95
96
|
options: ['public', 'private']
|
|
96
97
|
}),
|
|
97
|
-
published:
|
|
98
|
+
published: Flags.string({
|
|
98
99
|
description: 'sets the lifecycle setting of the API version',
|
|
99
100
|
options: ['publish', 'unpublish'],
|
|
100
101
|
required: false,
|
|
101
102
|
}),
|
|
102
|
-
setdefault:
|
|
103
|
+
setdefault: Flags.boolean({
|
|
103
104
|
description: 'sets API version to be the default',
|
|
104
105
|
required: false
|
|
105
106
|
}),
|
|
@@ -1,20 +1,27 @@
|
|
|
1
|
+
const { Args, Flags } = require('@oclif/core')
|
|
1
2
|
const BaseCommand = require('../../support/command/base-command')
|
|
2
3
|
const { getApiIdentifierArg } = require('../../support/command/parse-input')
|
|
3
4
|
const { getApi } = require('../../requests/api')
|
|
4
5
|
const { pipeAsync } = require('../../utils/general')
|
|
5
6
|
const { getResponseContent } = require('../../support/command/handle-response')
|
|
7
|
+
const { isOnPrem } = require('../../support/isOnPrem')
|
|
6
8
|
|
|
7
9
|
class ValidateCommand extends BaseCommand {
|
|
8
10
|
async run() {
|
|
9
|
-
const { args } = this.parse(ValidateCommand)
|
|
11
|
+
const { args, flags } = await this.parse(ValidateCommand)
|
|
10
12
|
const apiPath = getApiIdentifierArg(args)
|
|
11
13
|
const validPath = await this.ensureVersion(apiPath)
|
|
12
|
-
|
|
14
|
+
// eslint-disable-next-line immutable/no-let
|
|
15
|
+
let validationResult = await this.getValidationResult(validPath)
|
|
16
|
+
// Required to support On-Prem 2.4.1
|
|
17
|
+
if (validationResult.validation.length === 0 && isOnPrem()) {
|
|
18
|
+
validationResult = await this.getFallbackValidationResult(validPath)
|
|
19
|
+
}
|
|
13
20
|
// eslint-disable-next-line immutable/no-let
|
|
14
21
|
let hasCritical = false
|
|
15
22
|
const validationResultsStr = validationResult.validation
|
|
16
23
|
.map(err => {
|
|
17
|
-
if (err.severity === 'CRITICAL') hasCritical = true
|
|
24
|
+
if (err.severity.toUpperCase() === 'CRITICAL') hasCritical = true
|
|
18
25
|
return `${err.line}: \t${err.severity} \t${err.description}`
|
|
19
26
|
})
|
|
20
27
|
.join('\n')
|
|
@@ -23,7 +30,7 @@ class ValidateCommand extends BaseCommand {
|
|
|
23
30
|
}
|
|
24
31
|
this.log(validationResultsStr)
|
|
25
32
|
|
|
26
|
-
if (hasCritical) this.exit(1)
|
|
33
|
+
if (hasCritical && flags['fail-on-critical']) this.exit(1)
|
|
27
34
|
this.exit(0)
|
|
28
35
|
}
|
|
29
36
|
|
|
@@ -31,7 +38,7 @@ class ValidateCommand extends BaseCommand {
|
|
|
31
38
|
return this.executeHttp({
|
|
32
39
|
execute: () => getApi([apiPath, 'standardization']),
|
|
33
40
|
onResolve: pipeAsync(getResponseContent, JSON.parse),
|
|
34
|
-
onReject: () =>
|
|
41
|
+
onReject: () => ({ validation: [] }),
|
|
35
42
|
options: {}
|
|
36
43
|
})
|
|
37
44
|
}
|
|
@@ -41,6 +48,7 @@ class ValidateCommand extends BaseCommand {
|
|
|
41
48
|
return this.executeHttp({
|
|
42
49
|
execute: () => getApi([apiPath, 'validation']),
|
|
43
50
|
onResolve: pipeAsync(getResponseContent, JSON.parse),
|
|
51
|
+
onReject: () => ({ validation: [] }),
|
|
44
52
|
options: {}
|
|
45
53
|
})
|
|
46
54
|
}
|
|
@@ -50,19 +58,29 @@ class ValidateCommand extends BaseCommand {
|
|
|
50
58
|
ValidateCommand.description = `get validation result for an API version
|
|
51
59
|
When VERSION is not included in the argument, the default version will be validated.
|
|
52
60
|
An error will occur if the API version does not exist.
|
|
61
|
+
If the flag \`-c\` or \`--failOnCritical\` is used and there are standardization
|
|
62
|
+
errors with \`Critical\` severity present, the command will exit with error code \`1\`.
|
|
53
63
|
`
|
|
54
64
|
|
|
55
65
|
ValidateCommand.examples = [
|
|
56
66
|
'swaggerhub api:validate organization/api/1.0.0',
|
|
57
|
-
'swaggerhub api:validate organization/api'
|
|
67
|
+
'swaggerhub api:validate -c organization/api/1.0.0',
|
|
68
|
+
'swaggerhub api:validate --fail-on-critical organization/api'
|
|
58
69
|
]
|
|
59
70
|
|
|
60
|
-
ValidateCommand.args =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
ValidateCommand.flags = BaseCommand.flags
|
|
71
|
+
ValidateCommand.args = {
|
|
72
|
+
'OWNER/API_NAME/[VERSION]': Args.string({
|
|
73
|
+
required: true,
|
|
74
|
+
description: 'API to fetch validation errors for from Swaggerhub'
|
|
75
|
+
})
|
|
76
|
+
}
|
|
67
77
|
|
|
78
|
+
ValidateCommand.flags = {
|
|
79
|
+
'fail-on-critical': Flags.boolean({
|
|
80
|
+
char: 'c',
|
|
81
|
+
description: 'Exit with error code 1 if there are critical standardization errors present',
|
|
82
|
+
default: false
|
|
83
|
+
}),
|
|
84
|
+
...BaseCommand.flags
|
|
85
|
+
}
|
|
68
86
|
module.exports = ValidateCommand
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { Flags, Args } = require('@oclif/core')
|
|
2
2
|
const { readFileSync } = require('fs-extra')
|
|
3
3
|
const { getDomain, postDomain } = require('../../requests/domain')
|
|
4
4
|
const { getDomainIdentifierArg, splitPathParams } = require('../../support/command/parse-input')
|
|
@@ -59,7 +59,7 @@ class CreateDomainCommand extends UpdateCommand {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
async run() {
|
|
62
|
-
const { args, flags } = this.parse(CreateDomainCommand)
|
|
62
|
+
const { args, flags } = await this.parse(CreateDomainCommand)
|
|
63
63
|
const definition = parseDefinition(flags.file)
|
|
64
64
|
const domainVersion = getVersion(definition)
|
|
65
65
|
const doaminPath = getDomainIdentifierArg(args)
|
|
@@ -101,31 +101,32 @@ CreateDomainCommand.examples = [
|
|
|
101
101
|
'swaggerhub domain:create organization/domain/1.0.0 --publish --setdefault --file domain.json'
|
|
102
102
|
]
|
|
103
103
|
|
|
104
|
-
CreateDomainCommand.args =
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
104
|
+
CreateDomainCommand.args = {
|
|
105
|
+
'OWNER/DOMAIN_NAME/[VERSION]': Args.string({
|
|
106
|
+
required: true,
|
|
107
|
+
description: 'Domain to create on SwaggerHub'
|
|
108
|
+
})
|
|
109
|
+
}
|
|
109
110
|
|
|
110
111
|
CreateDomainCommand.flags = {
|
|
111
|
-
file:
|
|
112
|
+
file: Flags.string({
|
|
112
113
|
char: 'f',
|
|
113
114
|
description: 'file location of domain to create',
|
|
114
115
|
required: true
|
|
115
116
|
}),
|
|
116
|
-
visibility:
|
|
117
|
+
visibility: Flags.string({
|
|
117
118
|
description: 'visibility of domain in SwaggerHub',
|
|
118
119
|
options: ['public', 'private'],
|
|
119
120
|
default: 'private'
|
|
120
121
|
}),
|
|
121
|
-
published:
|
|
122
|
+
published: Flags.string({
|
|
122
123
|
description: 'sets the lifecycle setting of the domain version',
|
|
123
124
|
options: ['publish', 'unpublish'],
|
|
124
125
|
default: 'unpublish',
|
|
125
126
|
required: false,
|
|
126
127
|
dependsOn: ['file']
|
|
127
128
|
}),
|
|
128
|
-
setdefault:
|
|
129
|
+
setdefault: Flags.boolean({
|
|
129
130
|
description: 'sets domain version to be the default',
|
|
130
131
|
default: false,
|
|
131
132
|
required: false,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { Flags, Args } = require('@oclif/core')
|
|
2
2
|
const { deleteDomain } = require('../../requests/domain')
|
|
3
3
|
const { getDomainIdentifierArg, splitPathParams } = require('../../support/command/parse-input')
|
|
4
4
|
const BaseCommand = require('../../support/command/base-command')
|
|
@@ -7,7 +7,7 @@ const inquirer = require('inquirer')
|
|
|
7
7
|
class DeleteDomainCommand extends BaseCommand {
|
|
8
8
|
|
|
9
9
|
async run() {
|
|
10
|
-
const { args, flags } = this.parse(DeleteDomainCommand)
|
|
10
|
+
const { args, flags } = await this.parse(DeleteDomainCommand)
|
|
11
11
|
const domainPath = getDomainIdentifierArg(args)
|
|
12
12
|
const [owner, name, version] = splitPathParams(domainPath)
|
|
13
13
|
|
|
@@ -46,14 +46,15 @@ DeleteDomainCommand.examples = [
|
|
|
46
46
|
'swaggerhub domain:delete organization/domain --force'
|
|
47
47
|
]
|
|
48
48
|
|
|
49
|
-
DeleteDomainCommand.args =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
49
|
+
DeleteDomainCommand.args = {
|
|
50
|
+
'OWNER/DOMAIN_NAME/[VERSION]': Args.string({
|
|
51
|
+
required: true,
|
|
52
|
+
description: 'Domain to delete on SwaggerHub'
|
|
53
|
+
})
|
|
54
|
+
}
|
|
54
55
|
|
|
55
56
|
DeleteDomainCommand.flags = {
|
|
56
|
-
force:
|
|
57
|
+
force: Flags.boolean({
|
|
57
58
|
char: 'f',
|
|
58
59
|
description: 'delete domain without prompting for confirmation'
|
|
59
60
|
}),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { Flags, Args } = require('@oclif/core')
|
|
2
2
|
const { getDomainIdentifierArg, reqType, resolvedParam, splitPathParams } = require('../../support/command/parse-input')
|
|
3
3
|
const { hasJsonStructure, prettyPrintJSON } = require('../../utils/general')
|
|
4
4
|
const { getDomain } = require('../../requests/domain')
|
|
@@ -26,7 +26,7 @@ class GetDomainCommand extends BaseCommand {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
async run() {
|
|
29
|
-
const { args, flags } = this.parse(GetDomainCommand)
|
|
29
|
+
const { args, flags } = await this.parse(GetDomainCommand)
|
|
30
30
|
const requestedDomainPath = getDomainIdentifierArg(args)
|
|
31
31
|
const requestedPathParams = splitPathParams(requestedDomainPath)
|
|
32
32
|
const pathParams = await this.ensureVersion(requestedPathParams)
|
|
@@ -51,14 +51,15 @@ GetDomainCommand.examples = [
|
|
|
51
51
|
'swaggerhub domain:get organization/domain/1.0.0 --json'
|
|
52
52
|
]
|
|
53
53
|
|
|
54
|
-
GetDomainCommand.args =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
54
|
+
GetDomainCommand.args = {
|
|
55
|
+
'OWNER/DOMAIN_NAME/[VERSION]': Args.string({
|
|
56
|
+
required: true,
|
|
57
|
+
description: 'Domain to fetch from SwaggerHub'
|
|
58
|
+
})
|
|
59
|
+
}
|
|
59
60
|
|
|
60
61
|
GetDomainCommand.flags = {
|
|
61
|
-
json:
|
|
62
|
+
json: Flags.boolean({
|
|
62
63
|
char: 'j',
|
|
63
64
|
description: 'returns the domain in JSON format.'
|
|
64
65
|
}),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { Args } = require('@oclif/core')
|
|
1
2
|
const { getDomainIdentifierArg, splitPathParams } = require('../../support/command/parse-input')
|
|
2
3
|
const BaseCommand = require('../../support/command/base-command')
|
|
3
4
|
const UpdateCommand = require('../../support/command/update-command')
|
|
@@ -5,7 +6,7 @@ const UpdateCommand = require('../../support/command/update-command')
|
|
|
5
6
|
class PublishCommand extends UpdateCommand {
|
|
6
7
|
|
|
7
8
|
async run() {
|
|
8
|
-
const { args } = this.parse(PublishCommand)
|
|
9
|
+
const { args } = await this.parse(PublishCommand)
|
|
9
10
|
const domainPath = getDomainIdentifierArg(args)
|
|
10
11
|
const [owner, name, version] = splitPathParams(domainPath)
|
|
11
12
|
|
|
@@ -19,11 +20,12 @@ PublishCommand.examples = [
|
|
|
19
20
|
'swaggerhub domain:publish organization/domain/1.0.0'
|
|
20
21
|
]
|
|
21
22
|
|
|
22
|
-
PublishCommand.args =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
23
|
+
PublishCommand.args = {
|
|
24
|
+
'OWNER/DOMAIN_NAME/VERSION': Args.string({
|
|
25
|
+
required: true,
|
|
26
|
+
description: 'Domain to publish on SwaggerHub'
|
|
27
|
+
})
|
|
28
|
+
}
|
|
27
29
|
|
|
28
30
|
PublishCommand.flags = BaseCommand.flags
|
|
29
31
|
|