swaggerhub-cli 0.12.1 → 0.14.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.
Files changed (48) hide show
  1. package/README.md +239 -126
  2. package/oclif.manifest.json +372 -175
  3. package/package.json +8 -5
  4. package/src/commands/api/clone.js +65 -0
  5. package/src/commands/api/create.js +2 -2
  6. package/src/commands/api/delete.js +1 -1
  7. package/src/commands/api/get.js +2 -2
  8. package/src/commands/api/publish.js +1 -1
  9. package/src/commands/api/setdefault.js +1 -1
  10. package/src/commands/api/update.js +3 -3
  11. package/src/commands/api/validate/download-rules.js +5 -5
  12. package/src/commands/api/validate/index.js +2 -2
  13. package/src/commands/api/validate/local.js +3 -3
  14. package/src/commands/configure.js +2 -2
  15. package/src/commands/domain/clone.js +65 -0
  16. package/src/commands/domain/create.js +6 -6
  17. package/src/commands/domain/delete.js +1 -1
  18. package/src/commands/domain/get.js +1 -1
  19. package/src/commands/domain/publish.js +13 -6
  20. package/src/commands/domain/rename.js +77 -0
  21. package/src/commands/domain/setdefault.js +1 -1
  22. package/src/commands/domain/unpublish.js +1 -1
  23. package/src/commands/domain/update.js +3 -3
  24. package/src/commands/integration/create.js +2 -2
  25. package/src/commands/integration/delete.js +1 -1
  26. package/src/commands/integration/execute.js +1 -1
  27. package/src/commands/integration/get.js +2 -2
  28. package/src/commands/integration/list.js +1 -1
  29. package/src/commands/integration/update.js +1 -1
  30. package/src/commands/project/api/add.js +2 -2
  31. package/src/commands/project/api/remove.js +3 -3
  32. package/src/commands/project/create.js +4 -4
  33. package/src/commands/project/delete.js +2 -2
  34. package/src/commands/project/domain/add.js +2 -2
  35. package/src/commands/project/domain/remove.js +3 -3
  36. package/src/commands/project/get.js +1 -1
  37. package/src/commands/project/list.js +27 -8
  38. package/src/commands/project/member/list.js +2 -2
  39. package/src/commands/spectral/download.js +1 -1
  40. package/src/commands/spectral/upload.js +1 -1
  41. package/src/support/command/base-command.js +1 -1
  42. package/src/support/command/update-command.js +20 -4
  43. package/src/support/http/index.js +2 -1
  44. package/src/support/http/proxy-agent.js +25 -0
  45. package/src/support/inquirer/prompt-templates.js +1 -1
  46. package/src/support/isOnPrem.js +2 -2
  47. package/src/template-strings/errors.js +4 -4
  48. package/src/template-strings/info.js +8 -2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "swaggerhub-cli",
3
3
  "description": "SwaggerHub CLI",
4
- "version": "0.12.1",
4
+ "version": "0.14.0",
5
5
  "author": "SmartBear",
6
6
  "bin": {
7
7
  "swaggerhub": "./bin/run"
@@ -14,10 +14,13 @@
14
14
  "archiver": "^7.0.1",
15
15
  "deep-extend": "^0.6.0",
16
16
  "fs-extra": "^11.1.1",
17
+ "http-proxy-agent": "^9.1.0",
18
+ "https-proxy-agent": "^9.1.0",
17
19
  "inquirer": "^8.2.5",
18
20
  "js-yaml": "^5.2.2",
19
21
  "json-templates": "^5.0.0",
20
22
  "node-fetch": "^2.6.12",
23
+ "proxy-from-env": "^2.1.0",
21
24
  "semver": "^7.6.0",
22
25
  "unzipper": "^0.12.3"
23
26
  },
@@ -25,10 +28,10 @@
25
28
  "@faker-js/faker": "^10.0.0",
26
29
  "@oclif/test": "^3.2.15",
27
30
  "chai": "^6.3.0",
28
- "eslint": "^10.10.0",
31
+ "eslint": "^10.13.0",
29
32
  "eslint-plugin-chai-friendly": "^1.0.0",
30
33
  "eslint-plugin-immutable": "^1.0.0",
31
- "eslint-plugin-mocha": "^11.3.0",
34
+ "eslint-plugin-mocha": "^12.0.0",
32
35
  "eslint-plugin-n": "^18.3.0",
33
36
  "globby": "^16.2.0",
34
37
  "husky": "^9.0.1",
@@ -40,13 +43,13 @@
40
43
  "tmp": "^0.2.7"
41
44
  },
42
45
  "engines": {
43
- "node": "^20.17.0 || >=22.9.0",
46
+ "node": ">=22.9.0",
44
47
  "npm": ">=11.9.0"
45
48
  },
46
49
  "overrides": {
47
50
  "npm": "^11.9.0",
48
51
  "glob": "^10.5.0",
49
- "serialize-javascript": "^7.0.5"
52
+ "serialize-javascript": "^7.1.4"
50
53
  },
51
54
  "files": [
52
55
  "/bin",
@@ -0,0 +1,65 @@
1
+ const BaseCommand = require('../../support/command/base-command')
2
+ const { Args, Flags } = require('@oclif/core')
3
+ const { getApiIdentifierArg, apiNameRegex } = require('../../support/command/parse-input')
4
+ const { errorMsg } = require('../../template-strings')
5
+ const { CLIError } = require('@oclif/core/lib/errors')
6
+ const { postApi } = require('../../requests/api')
7
+
8
+ const getNewVersion = args => {
9
+ const newVersion = args['NEW_VERSION']
10
+ if (!apiNameRegex.test(newVersion)) {
11
+ throw new CLIError(errorMsg.argsMustMatchFormat({ format: 'NEW_VERSION' }))
12
+ }
13
+ return newVersion
14
+ }
15
+
16
+ class CloneApiCommand extends BaseCommand {
17
+
18
+ async run() {
19
+ const { args, flags } = await this.parse(CloneApiCommand)
20
+
21
+ const apiPath = getApiIdentifierArg(args)
22
+ const newVersion = getNewVersion(args)
23
+ const body = { version: newVersion }
24
+ if (flags.visibility) body.private = flags.visibility === 'private'
25
+
26
+ this.log(`Cloning API: '${apiPath}' as version '${newVersion}'`)
27
+
28
+ await this.executeHttp({
29
+ execute: () => postApi({
30
+ pathParams: [apiPath, 'clone'],
31
+ body: JSON.stringify(body)
32
+ }),
33
+ onResolve: this.logCommandSuccess({ apiPath, newVersion }),
34
+ options: {}
35
+ })
36
+ }
37
+ }
38
+
39
+ CloneApiCommand.description = 'clone an API version as a new version'
40
+
41
+ CloneApiCommand.examples = [
42
+ 'swaggerhub api:clone organization/api/1.0.0 1.0.1',
43
+ 'swaggerhub api:clone organization/api/1.0.0 1.0.1 --visibility public'
44
+ ]
45
+
46
+ CloneApiCommand.args = {
47
+ 'OWNER/API_NAME/VERSION': Args.string({
48
+ required: true,
49
+ description: 'API version to clone'
50
+ }),
51
+ 'NEW_VERSION': Args.string({
52
+ required: true,
53
+ description: 'Version identifier of the new API version'
54
+ })
55
+ }
56
+
57
+ CloneApiCommand.flags = {
58
+ visibility: Flags.string({
59
+ description: 'visibility of the new version (defaults to the server setting)',
60
+ options: ['public', 'private']
61
+ }),
62
+ ...BaseCommand.flags
63
+ }
64
+
65
+ module.exports = CloneApiCommand
@@ -106,7 +106,7 @@ CreateAPICommand.examples = [
106
106
  CreateAPICommand.args = {
107
107
  'OWNER/API_NAME/[VERSION]': Args.string({
108
108
  required: true,
109
- description: 'API to create on SwaggerHub'
109
+ description: 'API to create on Swagger'
110
110
  })
111
111
  }
112
112
 
@@ -117,7 +117,7 @@ CreateAPICommand.flags = {
117
117
  required: true
118
118
  }),
119
119
  visibility: Flags.string({
120
- description: 'visibility of API in SwaggerHub',
120
+ description: 'visibility of API in Swagger',
121
121
  options: ['public', 'private'],
122
122
  default: 'private'
123
123
  }),
@@ -49,7 +49,7 @@ DeleteAPICommand.examples = [
49
49
  DeleteAPICommand.args = {
50
50
  'OWNER/API_NAME/[VERSION]': Args.string({
51
51
  required: true,
52
- description: 'API to delete on SwaggerHub'
52
+ description: 'API to delete on Swagger'
53
53
  })
54
54
  }
55
55
 
@@ -48,7 +48,7 @@ GetAPICommand.examples = [
48
48
  GetAPICommand.args = {
49
49
  'OWNER/API_NAME/[VERSION]': Args.string({
50
50
  required: true,
51
- description: 'API to fetch from Swaggerhub'
51
+ description: 'API to fetch from Swagger'
52
52
  })
53
53
  }
54
54
 
@@ -59,7 +59,7 @@ GetAPICommand.flags = {
59
59
  }),
60
60
  resolved: Flags.boolean({
61
61
  char: 'r',
62
- description: 'gets the resolved API definition (supported in v1.25+). '
62
+ description: 'gets the resolved API definition'
63
63
  }),
64
64
  ...BaseCommand.flags
65
65
  }
@@ -38,7 +38,7 @@ PublishCommand.examples = [
38
38
  PublishCommand.args = {
39
39
  'OWNER/API_NAME/VERSION': Args.string({
40
40
  required: true,
41
- description: 'API to publish on Swaggerhub'
41
+ description: 'API to publish on Swagger'
42
42
  })
43
43
  }
44
44
 
@@ -23,7 +23,7 @@ SetDefaultCommand.examples = [
23
23
  SetDefaultCommand.args = {
24
24
  'OWNER/API_NAME/VERSION': Args.string({
25
25
  required: true,
26
- description: 'API to set as default on Swaggerhub'
26
+ description: 'API to set as default on Swagger'
27
27
  })
28
28
  }
29
29
 
@@ -65,7 +65,7 @@ class UpdateAPICommand extends UpdateCommand {
65
65
  UpdateAPICommand.description = `update an API
66
66
  The API version from the file will be used unless the version is specified in the command argument.
67
67
  When no file is specified then the default API version will be updated.
68
- The API visibility can be changed by using visibility flag.
68
+ The API visibility can be changed by using the --visibility flag.
69
69
  `
70
70
 
71
71
  UpdateAPICommand.examples = [
@@ -80,7 +80,7 @@ UpdateAPICommand.examples = [
80
80
  UpdateAPICommand.args = {
81
81
  'OWNER/API_NAME/[VERSION]': Args.string({
82
82
  required: true,
83
- description: 'API to update on SwaggerHub'
83
+ description: 'API to update on Swagger'
84
84
  })
85
85
  }
86
86
 
@@ -92,7 +92,7 @@ UpdateAPICommand.flags = {
92
92
  multiple: false
93
93
  }),
94
94
  visibility: Flags.string({
95
- description: 'visibility of API in SwaggerHub',
95
+ description: 'visibility of API in Swagger',
96
96
  options: ['public', 'private']
97
97
  }),
98
98
  published: Flags.string({
@@ -27,11 +27,11 @@ class ValidateDownloadRulesCommand extends BaseCommand {
27
27
  }
28
28
  }
29
29
 
30
- ValidateDownloadRulesCommand.description = `Get existing SwaggerHub's organization standardization ruleset.
31
- Requires organization name argument. An error will occur if provided organization doesn't exist
30
+ ValidateDownloadRulesCommand.description = `Get an organization's existing standardization ruleset from Swagger.
31
+ Requires organization name argument. An error will occur if the provided organization doesn't exist
32
32
  or your account is not permitted to access that organization's settings.
33
- If the flag \`-s\` or \`--include-system-rules\` is used, the returned ruleset will also include SwaggerHub system rules.
34
- If the flag \`-d\` or \`--include-disabled-rules\` is used, the returned ruleset will also include disabled custom rules`
33
+ If the flag \`-s\` or \`--include-system-rules\` is used, the returned ruleset will also include Swagger system rules.
34
+ If the flag \`-d\` or \`--include-disabled-rules\` is used, the returned ruleset will also include disabled custom rules.`
35
35
 
36
36
  ValidateDownloadRulesCommand.examples = [
37
37
  'swaggerhub api:validate:download-rules myOrg -s',
@@ -41,7 +41,7 @@ ValidateDownloadRulesCommand.examples = [
41
41
  ValidateDownloadRulesCommand.args = {
42
42
  'OWNER': Args.string({
43
43
  required: true,
44
- description: 'Which organization standardization rules to fetch from SwaggerHub'
44
+ description: 'Which organization standardization rules to fetch from Swagger'
45
45
  })
46
46
  }
47
47
  ValidateDownloadRulesCommand.flags = {
@@ -52,7 +52,7 @@ class ValidateCommand extends BaseValidateCommand {
52
52
  ValidateCommand.description = `Get validation result for an API version
53
53
  When VERSION is not included in the argument, the default version will be validated.
54
54
  An error will occur if the API version does not exist.
55
- If the flag \`-c\` or \`--failOnCritical\` is used and there are standardization
55
+ If the flag \`-c\` or \`--fail-on-critical\` is used and there are standardization
56
56
  errors with \`Critical\` severity present, the command will exit with error code \`1\`.
57
57
  `
58
58
 
@@ -65,7 +65,7 @@ ValidateCommand.examples = [
65
65
  ValidateCommand.args = {
66
66
  'OWNER/API_NAME/[VERSION]': Args.string({
67
67
  required: true,
68
- description: 'API to fetch validation errors for from Swaggerhub'
68
+ description: 'API to fetch validation errors for'
69
69
  })
70
70
  }
71
71
 
@@ -34,14 +34,14 @@ class ValidateLocalCommand extends BaseValidateCommand {
34
34
  }
35
35
  }
36
36
 
37
- ValidateLocalCommand.description = `Runs a scan against a local API definition using the organization's standardization configuration on SwaggerHub.
38
- If the flag \`-c\` or \`--failOnCritical\` is used and there are standardization
37
+ ValidateLocalCommand.description = `Runs a scan against a local API definition using the organization's standardization configuration on Swagger.
38
+ If the flag \`-c\` or \`--fail-on-critical\` is used and there are standardization
39
39
  errors with \`Critical\` severity present, the command will exit with error code \`1\`.
40
40
  `
41
41
 
42
42
  ValidateLocalCommand.examples = [
43
43
  'swaggerhub api:validate:local -o myOrg -f ./my-api.yaml -c -j ',
44
- 'swaggerhub api:validate:local --organization myOrg --file ./my-api/json --fail-on-critical --json',
44
+ 'swaggerhub api:validate:local --organization myOrg --file ./my-api.json --fail-on-critical --json',
45
45
  ]
46
46
 
47
47
  ValidateLocalCommand.flags = {
@@ -18,8 +18,8 @@ class ConfigureCommand extends BaseCommand {
18
18
  }
19
19
 
20
20
  ConfigureCommand.description = `configure application settings
21
- Enter the SwaggerHub URL - default is https://api.swaggerhub.com
22
- Customers with on-premise installations need to point this to their on-premise API, which is http(s)://{swaggerhub-host}/v1
21
+ Enter the Swagger URL - default is https://api.swaggerhub.com
22
+ Customers with on-premise installations (version 2.x) need to point this to their on-premise API, which is http(s)://{swaggerhub-host}/v1
23
23
  Enter the API Key - this can be retrieved from https://app.swaggerhub.com/settings/apiKey
24
24
  You can set these as environment variables: SWAGGERHUB_URL, SWAGGERHUB_API_KEY. These take priority over config settings.
25
25
  `
@@ -0,0 +1,65 @@
1
+ const BaseCommand = require('../../support/command/base-command')
2
+ const { Args, Flags } = require('@oclif/core')
3
+ const { getDomainIdentifierArg, apiNameRegex } = require('../../support/command/parse-input')
4
+ const { errorMsg } = require('../../template-strings')
5
+ const { CLIError } = require('@oclif/core/lib/errors')
6
+ const { postDomain } = require('../../requests/domain')
7
+
8
+ const getNewVersion = args => {
9
+ const newVersion = args['NEW_VERSION']
10
+ if (!apiNameRegex.test(newVersion)) {
11
+ throw new CLIError(errorMsg.argsMustMatchFormat({ format: 'NEW_VERSION' }))
12
+ }
13
+ return newVersion
14
+ }
15
+
16
+ class CloneDomainCommand extends BaseCommand {
17
+
18
+ async run() {
19
+ const { args, flags } = await this.parse(CloneDomainCommand)
20
+
21
+ const domainPath = getDomainIdentifierArg(args)
22
+ const newVersion = getNewVersion(args)
23
+ const body = { version: newVersion }
24
+ if (flags.visibility) body.private = flags.visibility === 'private'
25
+
26
+ this.log(`Cloning domain: '${domainPath}' as version '${newVersion}'`)
27
+
28
+ await this.executeHttp({
29
+ execute: () => postDomain({
30
+ pathParams: [domainPath, 'clone'],
31
+ body: JSON.stringify(body)
32
+ }),
33
+ onResolve: this.logCommandSuccess({ domainPath, newVersion }),
34
+ options: {}
35
+ })
36
+ }
37
+ }
38
+
39
+ CloneDomainCommand.description = 'clone a domain version as a new version'
40
+
41
+ CloneDomainCommand.examples = [
42
+ 'swaggerhub domain:clone organization/domain/1.0.0 1.0.1',
43
+ 'swaggerhub domain:clone organization/domain/1.0.0 1.0.1 --visibility public'
44
+ ]
45
+
46
+ CloneDomainCommand.args = {
47
+ 'OWNER/DOMAIN_NAME/VERSION': Args.string({
48
+ required: true,
49
+ description: 'Domain version to clone'
50
+ }),
51
+ 'NEW_VERSION': Args.string({
52
+ required: true,
53
+ description: 'Version identifier of the new domain version'
54
+ })
55
+ }
56
+
57
+ CloneDomainCommand.flags = {
58
+ visibility: Flags.string({
59
+ description: 'visibility of the new version (defaults to the server setting)',
60
+ options: ['public', 'private']
61
+ }),
62
+ ...BaseCommand.flags
63
+ }
64
+
65
+ module.exports = CloneDomainCommand
@@ -62,8 +62,8 @@ class CreateDomainCommand extends UpdateCommand {
62
62
  const { args, flags } = await this.parse(CreateDomainCommand)
63
63
  const definition = parseDefinition(flags.file)
64
64
  const domainVersion = getVersion(definition)
65
- const doaminPath = getDomainIdentifierArg(args)
66
- const [owner, name, version = domainVersion] = splitPathParams(doaminPath)
65
+ const domainPath = getDomainIdentifierArg(args)
66
+ const [owner, name, version = domainVersion] = splitPathParams(domainPath)
67
67
  const type = 'domains'
68
68
 
69
69
  const argsObj = {
@@ -96,15 +96,15 @@ An error will occur if the domain version already exists.
96
96
  CreateDomainCommand.examples = [
97
97
  'swaggerhub domain:create organization/domain/1.0.0 --file domain.yaml --visibility public',
98
98
  'swaggerhub domain:create organization/domain --file domain.yaml',
99
- 'swaggerhub domain:create organization/domain/1.0.0 --publish --file domain.json',
99
+ 'swaggerhub domain:create organization/domain/1.0.0 --published=publish --file domain.json',
100
100
  'swaggerhub domain:create organization/domain/1.0.0 --setdefault --file domain.json',
101
- 'swaggerhub domain:create organization/domain/1.0.0 --publish --setdefault --file domain.json'
101
+ 'swaggerhub domain:create organization/domain/1.0.0 --published=publish --setdefault --file domain.json'
102
102
  ]
103
103
 
104
104
  CreateDomainCommand.args = {
105
105
  'OWNER/DOMAIN_NAME/[VERSION]': Args.string({
106
106
  required: true,
107
- description: 'Domain to create on SwaggerHub'
107
+ description: 'Domain to create on Swagger'
108
108
  })
109
109
  }
110
110
 
@@ -115,7 +115,7 @@ CreateDomainCommand.flags = {
115
115
  required: true
116
116
  }),
117
117
  visibility: Flags.string({
118
- description: 'visibility of domain in SwaggerHub',
118
+ description: 'visibility of domain in Swagger',
119
119
  options: ['public', 'private'],
120
120
  default: 'private'
121
121
  }),
@@ -49,7 +49,7 @@ DeleteDomainCommand.examples = [
49
49
  DeleteDomainCommand.args = {
50
50
  'OWNER/DOMAIN_NAME/[VERSION]': Args.string({
51
51
  required: true,
52
- description: 'Domain to delete on SwaggerHub'
52
+ description: 'Domain to delete on Swagger'
53
53
  })
54
54
  }
55
55
 
@@ -54,7 +54,7 @@ GetDomainCommand.examples = [
54
54
  GetDomainCommand.args = {
55
55
  'OWNER/DOMAIN_NAME/[VERSION]': Args.string({
56
56
  required: true,
57
- description: 'Domain to fetch from SwaggerHub'
57
+ description: 'Domain to fetch from Swagger'
58
58
  })
59
59
  }
60
60
 
@@ -1,4 +1,4 @@
1
- const { Args } = require('@oclif/core')
1
+ const { Flags, Args } = require('@oclif/core')
2
2
  const { getDomainIdentifierArg, 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,27 +6,34 @@ const UpdateCommand = require('../../support/command/update-command')
6
6
  class PublishCommand extends UpdateCommand {
7
7
 
8
8
  async run() {
9
- const { args } = await this.parse(PublishCommand)
9
+ const { args, flags } = await this.parse(PublishCommand)
10
10
  const domainPath = getDomainIdentifierArg(args)
11
11
  const [owner, name, version] = splitPathParams(domainPath)
12
12
 
13
- await this.updatePublish('domains', owner, name, version, true)
13
+ await this.updatePublish('domains', owner, name, version, true, flags)
14
14
  }
15
15
  }
16
16
 
17
17
  PublishCommand.description = 'publish a domain version'
18
18
 
19
19
  PublishCommand.examples = [
20
- 'swaggerhub domain:publish organization/domain/1.0.0'
20
+ 'swaggerhub domain:publish organization/domain/1.0.0',
21
+ 'swaggerhub domain:publish organization/domain/1.0.0 --force'
21
22
  ]
22
23
 
23
24
  PublishCommand.args = {
24
25
  'OWNER/DOMAIN_NAME/VERSION': Args.string({
25
26
  required: true,
26
- description: 'Domain to publish on SwaggerHub'
27
+ description: 'Domain to publish on Swagger'
27
28
  })
28
29
  }
29
30
 
30
- PublishCommand.flags = BaseCommand.flags
31
+ PublishCommand.flags = {
32
+ force: Flags.boolean({
33
+ char: 'f',
34
+ description: 'publish domain without prompting for confirmation'
35
+ }),
36
+ ...BaseCommand.flags
37
+ }
31
38
 
32
39
  module.exports = PublishCommand
@@ -0,0 +1,77 @@
1
+ const BaseCommand = require('../../support/command/base-command')
2
+ const { Args, Flags } = require('@oclif/core')
3
+ const {
4
+ noVersionRegex,
5
+ apiNameRegex
6
+ } = require('../../support/command/parse-input')
7
+ const { errorMsg } = require('../../template-strings')
8
+ const { CLIError } = require('@oclif/core/lib/errors')
9
+ const { postDomain } = require('../../requests/domain')
10
+
11
+ const getDomainToRename = args => {
12
+ const domainPath = args['OWNER/DOMAIN_NAME']
13
+ if (!noVersionRegex.test(domainPath)) {
14
+ throw new CLIError(errorMsg.argsMustMatchFormat({ format: 'OWNER/DOMAIN_NAME' }))
15
+ }
16
+ return domainPath
17
+ }
18
+
19
+ const getDomainNewName = args => {
20
+ const newName = args['DOMAIN_NEW_NAME']
21
+ if (!apiNameRegex.test(newName)) {
22
+ throw new CLIError(errorMsg.argsMustMatchFormat({ format: 'DOMAIN_NEW_NAME' }))
23
+ }
24
+ return newName
25
+ }
26
+
27
+ class RenameDomainCommand extends BaseCommand {
28
+
29
+ async run() {
30
+ const { args, flags } = await this.parse(RenameDomainCommand)
31
+
32
+ const domainPath = getDomainToRename(args)
33
+ const newName = getDomainNewName(args)
34
+ const queryParams = { newName }
35
+ if (flags.force) queryParams.force = 'true'
36
+
37
+ this.log(`Renaming domain: '${domainPath}' to '${newName}'`)
38
+
39
+ await this.executeHttp({
40
+ execute: () => postDomain({
41
+ pathParams: [domainPath, 'rename'],
42
+ queryParams,
43
+ body: '{}'
44
+ }),
45
+ onResolve: this.logCommandSuccess({ domainPath, newName }),
46
+ options: {}
47
+ })
48
+ }
49
+ }
50
+
51
+ RenameDomainCommand.description = 'rename a domain'
52
+
53
+ RenameDomainCommand.examples = [
54
+ 'swaggerhub domain:rename organization/domainOldName domainNewName',
55
+ 'swaggerhub domain:rename organization/domainOldName domainNewName --force'
56
+ ]
57
+
58
+ RenameDomainCommand.args = {
59
+ 'OWNER/DOMAIN_NAME': Args.string({
60
+ required: true,
61
+ description: 'Domain to be renamed'
62
+ }),
63
+ 'DOMAIN_NEW_NAME': Args.string({
64
+ required: true,
65
+ description: 'New name for the domain'
66
+ })
67
+ }
68
+
69
+ RenameDomainCommand.flags = {
70
+ force: Flags.boolean({
71
+ char: 'f',
72
+ description: 'rename the domain even if it is referenced by APIs or other domains'
73
+ }),
74
+ ...BaseCommand.flags
75
+ }
76
+
77
+ module.exports = RenameDomainCommand
@@ -23,7 +23,7 @@ SetDefaultDomainCommand.examples = [
23
23
  SetDefaultDomainCommand.args = {
24
24
  'OWNER/DOMAIN_NAME/VERSION': Args.string({
25
25
  required: true,
26
- description: 'Domain to set as default on SwaggerHub'
26
+ description: 'Domain to set as default on Swagger'
27
27
  })
28
28
  }
29
29
 
@@ -23,7 +23,7 @@ UnpublishCommand.examples = [
23
23
  UnpublishCommand.args = {
24
24
  'OWNER/DOMAIN_NAME/VERSION': Args.string({
25
25
  required: true,
26
- description: 'Domain to unpublish on SwaggerHub'
26
+ description: 'Domain to unpublish on Swagger'
27
27
  })
28
28
  }
29
29
 
@@ -65,7 +65,7 @@ class UpdateDomainCommand extends UpdateCommand {
65
65
  UpdateDomainCommand.description = `update a domain
66
66
  The domain version from the file will be used unless the version is specified in the command argument.
67
67
  When no file is specified then the default domain version will be updated.
68
- The domain visibility can be changed by using visibility flag.
68
+ The domain visibility can be changed by using the --visibility flag.
69
69
  `
70
70
 
71
71
  UpdateDomainCommand.examples = [
@@ -80,7 +80,7 @@ UpdateDomainCommand.examples = [
80
80
  UpdateDomainCommand.args = {
81
81
  'OWNER/DOMAIN_NAME/[VERSION]': Args.string({
82
82
  required: true,
83
- description: 'Domain to update on SwaggerHub'
83
+ description: 'Domain to update on Swagger'
84
84
  })
85
85
  }
86
86
 
@@ -92,7 +92,7 @@ UpdateDomainCommand.flags = {
92
92
  multiple: false
93
93
  }),
94
94
  visibility: Flags.string({
95
- description: 'visibility of domain in SwaggerHub',
95
+ description: 'visibility of domain in Swagger',
96
96
  options: ['public', 'private']
97
97
  }),
98
98
  published: Flags.string({
@@ -30,7 +30,7 @@ class CreateIntegrationCommand extends BaseCommand {
30
30
 
31
31
  CreateIntegrationCommand.description = `creates a new API integration from a JSON configuration file.
32
32
  See the documentation for configuration files: https://github.com/SmartBear/swaggerhub-cli/tree/main/examples/integrations
33
- When VERSION is not included in the argument, the integration will be added to be default API version.
33
+ When VERSION is not included in the argument, the integration will be added to the default API version.
34
34
  `
35
35
 
36
36
  CreateIntegrationCommand.examples = [
@@ -40,7 +40,7 @@ CreateIntegrationCommand.examples = [
40
40
  CreateIntegrationCommand.args = {
41
41
  'OWNER/API_NAME/[VERSION]': Args.string({
42
42
  required: true,
43
- description: 'API to add integration to on SwaggerHub'
43
+ description: 'API to add integration to on Swagger'
44
44
  })
45
45
  }
46
46
 
@@ -31,7 +31,7 @@ DeleteIntegrationCommand.examples = [
31
31
  DeleteIntegrationCommand.args = {
32
32
  'OWNER/API_NAME/VERSION/INTEGRATION_ID': Args.string({
33
33
  required: true,
34
- description: 'Integration to delete for given API on Swaggerhub'
34
+ description: 'Integration to delete for given API on Swagger'
35
35
  })
36
36
  }
37
37
 
@@ -31,7 +31,7 @@ ExecuteIntegrationCommand.examples = [
31
31
  ExecuteIntegrationCommand.args = {
32
32
  'OWNER/API_NAME/VERSION/INTEGRATION_ID': Args.string({
33
33
  required: true,
34
- description: 'Integration to execute for given API on Swaggerhub'
34
+ description: 'Integration to execute for given API on Swagger'
35
35
  })
36
36
  }
37
37
 
@@ -33,7 +33,7 @@ class GetIntegrationCommand extends BaseCommand {
33
33
  }
34
34
  }
35
35
 
36
- GetIntegrationCommand.description = 'retieves an integration for the given API.'
36
+ GetIntegrationCommand.description = 'retrieves an integration for the given API.'
37
37
 
38
38
  GetIntegrationCommand.examples = [
39
39
  'swaggerhub integration:get organization/api/1.0.0/503c2db6-448a-4678-a310-f465429e9704'
@@ -42,7 +42,7 @@ GetIntegrationCommand.examples = [
42
42
  GetIntegrationCommand.args = {
43
43
  'OWNER/API_NAME/VERSION/INTEGRATION_ID': Args.string({
44
44
  required: true,
45
- description: 'Integration to fetch for given API on Swaggerhub'
45
+ description: 'Integration to fetch for given API on Swagger'
46
46
  })
47
47
  }
48
48
 
@@ -52,7 +52,7 @@ ListIntegrationCommand.examples = [
52
52
  ListIntegrationCommand.args = {
53
53
  'OWNER/API_NAME/[VERSION]': Args.string({
54
54
  required: true,
55
- description: 'API to list integrations for on Swaggerhub'
55
+ description: 'API to list integrations for'
56
56
  })
57
57
  }
58
58
 
@@ -36,7 +36,7 @@ UpdateIntegrationCommand.examples = [
36
36
  UpdateIntegrationCommand.args = {
37
37
  'OWNER/API_NAME/VERSION/INTEGRATION_ID': Args.string({
38
38
  required: true,
39
- description: 'Integration to update for given API on Swaggerhub'
39
+ description: 'Integration to update for given API on Swagger'
40
40
  })
41
41
  }
42
42