swaggerhub-cli 0.7.2 → 0.8.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 +79 -44
- package/oclif.manifest.json +98 -38
- package/package.json +14 -14
- package/src/commands/api/{validate.js → validate/index.js} +14 -33
- package/src/commands/api/validate/local.js +60 -0
- package/src/requests/standardization.js +20 -0
- package/src/support/command/base-validate-command.js +40 -0
package/README.md
CHANGED
|
@@ -110,6 +110,7 @@ USAGE
|
|
|
110
110
|
* [`swaggerhub api:unpublish OWNER/API_NAME/VERSION`](#swaggerhub-apiunpublish)
|
|
111
111
|
* [`swaggerhub api:update OWNER/API_NAME/[VERSION]`](#swaggerhub-apiupdate)
|
|
112
112
|
* [`swaggerhub api:validate OWNER/API_NAME/[VERSION]`](#swaggerhub-apivalidate)
|
|
113
|
+
* [`swaggerhub api:validate:local`](#swaggerhub-apivalidatelocal)
|
|
113
114
|
* [`swaggerhub configure`](#swaggerhub-configure)
|
|
114
115
|
* [`swaggerhub domain:create OWNER/DOMAIN_NAME/[VERSION]`](#swaggerhub-domaincreate)
|
|
115
116
|
* [`swaggerhub domain:delete OWNER/DOMAIN_NAME/[VERSION]`](#swaggerhub-domaindelete)
|
|
@@ -183,7 +184,7 @@ EXAMPLES
|
|
|
183
184
|
$ swaggerhub api:create organization/api/1.0.0 --published=publish --setdefault --file api.json
|
|
184
185
|
```
|
|
185
186
|
|
|
186
|
-
_See code: [src/commands/api/create.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
187
|
+
_See code: [src/commands/api/create.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/api/create.js)_
|
|
187
188
|
|
|
188
189
|
## `swaggerhub api:delete`
|
|
189
190
|
|
|
@@ -212,7 +213,7 @@ EXAMPLES
|
|
|
212
213
|
$ swaggerhub api:delete organization/api --force
|
|
213
214
|
```
|
|
214
215
|
|
|
215
|
-
_See code: [src/commands/api/delete.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
216
|
+
_See code: [src/commands/api/delete.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/api/delete.js)_
|
|
216
217
|
|
|
217
218
|
## `swaggerhub api:get`
|
|
218
219
|
|
|
@@ -242,7 +243,7 @@ EXAMPLES
|
|
|
242
243
|
$ swaggerhub api:get organization/api/1.0.0 --json
|
|
243
244
|
```
|
|
244
245
|
|
|
245
|
-
_See code: [src/commands/api/get.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
246
|
+
_See code: [src/commands/api/get.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/api/get.js)_
|
|
246
247
|
|
|
247
248
|
## `swaggerhub api:publish`
|
|
248
249
|
|
|
@@ -268,7 +269,7 @@ EXAMPLES
|
|
|
268
269
|
$ swaggerhub api:publish organization/api/1.0.0 --force
|
|
269
270
|
```
|
|
270
271
|
|
|
271
|
-
_See code: [src/commands/api/publish.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
272
|
+
_See code: [src/commands/api/publish.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/api/publish.js)_
|
|
272
273
|
|
|
273
274
|
## `swaggerhub api:setdefault`
|
|
274
275
|
|
|
@@ -291,7 +292,7 @@ EXAMPLES
|
|
|
291
292
|
$ swaggerhub api:setdefault organization/api/2.0.0
|
|
292
293
|
```
|
|
293
294
|
|
|
294
|
-
_See code: [src/commands/api/setdefault.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
295
|
+
_See code: [src/commands/api/setdefault.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/api/setdefault.js)_
|
|
295
296
|
|
|
296
297
|
## `swaggerhub api:unpublish`
|
|
297
298
|
|
|
@@ -314,7 +315,7 @@ EXAMPLES
|
|
|
314
315
|
$ swaggerhub api:unpublish organization/api/1.0.0
|
|
315
316
|
```
|
|
316
317
|
|
|
317
|
-
_See code: [src/commands/api/unpublish.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
318
|
+
_See code: [src/commands/api/unpublish.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/api/unpublish.js)_
|
|
318
319
|
|
|
319
320
|
## `swaggerhub api:update`
|
|
320
321
|
|
|
@@ -358,15 +359,15 @@ EXAMPLES
|
|
|
358
359
|
$ swaggerhub api:update organization/api/1.0.0 --visibility=private
|
|
359
360
|
```
|
|
360
361
|
|
|
361
|
-
_See code: [src/commands/api/update.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
362
|
+
_See code: [src/commands/api/update.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/api/update.js)_
|
|
362
363
|
|
|
363
364
|
## `swaggerhub api:validate`
|
|
364
365
|
|
|
365
|
-
|
|
366
|
+
Get validation result for an API version
|
|
366
367
|
|
|
367
368
|
```
|
|
368
369
|
USAGE
|
|
369
|
-
$ swaggerhub api:validate OWNER/API_NAME/[VERSION] [-h] [-c]
|
|
370
|
+
$ swaggerhub api:validate OWNER/API_NAME/[VERSION] [-h] [-c] [-j]
|
|
370
371
|
|
|
371
372
|
ARGUMENTS
|
|
372
373
|
OWNER/API_NAME/[VERSION] API to fetch validation errors for from Swaggerhub
|
|
@@ -374,9 +375,10 @@ ARGUMENTS
|
|
|
374
375
|
FLAGS
|
|
375
376
|
-c, --fail-on-critical Exit with error code 1 if there are critical standardization errors present
|
|
376
377
|
-h, --help Show CLI help.
|
|
378
|
+
-j, --json Print output in JSON instead of table format
|
|
377
379
|
|
|
378
380
|
DESCRIPTION
|
|
379
|
-
|
|
381
|
+
Get validation result for an API version
|
|
380
382
|
When VERSION is not included in the argument, the default version will be validated.
|
|
381
383
|
An error will occur if the API version does not exist.
|
|
382
384
|
If the flag `-c` or `--failOnCritical` is used and there are standardization
|
|
@@ -386,12 +388,42 @@ DESCRIPTION
|
|
|
386
388
|
EXAMPLES
|
|
387
389
|
$ swaggerhub api:validate organization/api/1.0.0
|
|
388
390
|
|
|
389
|
-
$ swaggerhub api:validate -c organization/api/1.0.0
|
|
391
|
+
$ swaggerhub api:validate -c -j organization/api/1.0.0
|
|
390
392
|
|
|
391
|
-
$ swaggerhub api:validate --fail-on-critical organization/api
|
|
393
|
+
$ swaggerhub api:validate --fail-on-critical --json organization/api
|
|
392
394
|
```
|
|
393
395
|
|
|
394
|
-
_See code: [src/commands/api/validate.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
396
|
+
_See code: [src/commands/api/validate/index.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/api/validate/index.js)_
|
|
397
|
+
|
|
398
|
+
## `swaggerhub api:validate:local`
|
|
399
|
+
|
|
400
|
+
Runs a scan against a local API definition using the organization's standardization configuration on SwaggerHub.
|
|
401
|
+
|
|
402
|
+
```
|
|
403
|
+
USAGE
|
|
404
|
+
$ swaggerhub api:validate:local -f <value> -o <value> [-h] [-c] [-j]
|
|
405
|
+
|
|
406
|
+
FLAGS
|
|
407
|
+
-c, --fail-on-critical Exit with error code 1 if there are critical standardization errors present
|
|
408
|
+
-f, --file=<value> (required) Path of API definition file to run scan against
|
|
409
|
+
-h, --help Show CLI help.
|
|
410
|
+
-j, --json Print output in JSON instead of table format
|
|
411
|
+
-o, --organization=<value> (required) Which organization's standardization settings to use for linting the target
|
|
412
|
+
definition
|
|
413
|
+
|
|
414
|
+
DESCRIPTION
|
|
415
|
+
Runs a scan against a local API definition using the organization's standardization configuration on SwaggerHub.
|
|
416
|
+
If the flag `-c` or `--failOnCritical` is used and there are standardization
|
|
417
|
+
errors with `Critical` severity present, the command will exit with error code `1`.
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
EXAMPLES
|
|
421
|
+
$ swaggerhub api:validate:local -o myOrg -f ./my-api.yaml -c -j
|
|
422
|
+
|
|
423
|
+
$ swaggerhub api:validate:local --organization myOrg --file ./my-api/json --fail-on-critical --json
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
_See code: [src/commands/api/validate/local.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/api/validate/local.js)_
|
|
395
427
|
|
|
396
428
|
## `swaggerhub configure`
|
|
397
429
|
|
|
@@ -414,7 +446,7 @@ DESCRIPTION
|
|
|
414
446
|
settings.
|
|
415
447
|
```
|
|
416
448
|
|
|
417
|
-
_See code: [src/commands/configure.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
449
|
+
_See code: [src/commands/configure.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/configure.js)_
|
|
418
450
|
|
|
419
451
|
## `swaggerhub domain:create`
|
|
420
452
|
|
|
@@ -455,7 +487,7 @@ EXAMPLES
|
|
|
455
487
|
$ swaggerhub domain:create organization/domain/1.0.0 --publish --setdefault --file domain.json
|
|
456
488
|
```
|
|
457
489
|
|
|
458
|
-
_See code: [src/commands/domain/create.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
490
|
+
_See code: [src/commands/domain/create.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/domain/create.js)_
|
|
459
491
|
|
|
460
492
|
## `swaggerhub domain:delete`
|
|
461
493
|
|
|
@@ -484,7 +516,7 @@ EXAMPLES
|
|
|
484
516
|
$ swaggerhub domain:delete organization/domain --force
|
|
485
517
|
```
|
|
486
518
|
|
|
487
|
-
_See code: [src/commands/domain/delete.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
519
|
+
_See code: [src/commands/domain/delete.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/domain/delete.js)_
|
|
488
520
|
|
|
489
521
|
## `swaggerhub domain:get`
|
|
490
522
|
|
|
@@ -513,7 +545,7 @@ EXAMPLES
|
|
|
513
545
|
$ swaggerhub domain:get organization/domain/1.0.0 --json
|
|
514
546
|
```
|
|
515
547
|
|
|
516
|
-
_See code: [src/commands/domain/get.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
548
|
+
_See code: [src/commands/domain/get.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/domain/get.js)_
|
|
517
549
|
|
|
518
550
|
## `swaggerhub domain:publish`
|
|
519
551
|
|
|
@@ -536,7 +568,7 @@ EXAMPLES
|
|
|
536
568
|
$ swaggerhub domain:publish organization/domain/1.0.0
|
|
537
569
|
```
|
|
538
570
|
|
|
539
|
-
_See code: [src/commands/domain/publish.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
571
|
+
_See code: [src/commands/domain/publish.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/domain/publish.js)_
|
|
540
572
|
|
|
541
573
|
## `swaggerhub domain:setdefault`
|
|
542
574
|
|
|
@@ -559,7 +591,7 @@ EXAMPLES
|
|
|
559
591
|
$ swaggerhub domain:setdefault organization/domain/2.0.0
|
|
560
592
|
```
|
|
561
593
|
|
|
562
|
-
_See code: [src/commands/domain/setdefault.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
594
|
+
_See code: [src/commands/domain/setdefault.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/domain/setdefault.js)_
|
|
563
595
|
|
|
564
596
|
## `swaggerhub domain:unpublish`
|
|
565
597
|
|
|
@@ -582,7 +614,7 @@ EXAMPLES
|
|
|
582
614
|
$ swaggerhub domain:unpublish organization/domain/1.0.0
|
|
583
615
|
```
|
|
584
616
|
|
|
585
|
-
_See code: [src/commands/domain/unpublish.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
617
|
+
_See code: [src/commands/domain/unpublish.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/domain/unpublish.js)_
|
|
586
618
|
|
|
587
619
|
## `swaggerhub domain:update`
|
|
588
620
|
|
|
@@ -626,7 +658,7 @@ EXAMPLES
|
|
|
626
658
|
$ swaggerhub domain:update organization/domain/1.0.0 --visibility=private
|
|
627
659
|
```
|
|
628
660
|
|
|
629
|
-
_See code: [src/commands/domain/update.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
661
|
+
_See code: [src/commands/domain/update.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/domain/update.js)_
|
|
630
662
|
|
|
631
663
|
## `swaggerhub help`
|
|
632
664
|
|
|
@@ -646,7 +678,7 @@ DESCRIPTION
|
|
|
646
678
|
Display help for swaggerhub.
|
|
647
679
|
```
|
|
648
680
|
|
|
649
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.
|
|
681
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.12/src/commands/help.ts)_
|
|
650
682
|
|
|
651
683
|
## `swaggerhub integration:create`
|
|
652
684
|
|
|
@@ -674,7 +706,7 @@ EXAMPLES
|
|
|
674
706
|
$ swaggerhub integration:create organization/api/1.0.0 --file config.json
|
|
675
707
|
```
|
|
676
708
|
|
|
677
|
-
_See code: [src/commands/integration/create.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
709
|
+
_See code: [src/commands/integration/create.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/integration/create.js)_
|
|
678
710
|
|
|
679
711
|
## `swaggerhub integration:delete`
|
|
680
712
|
|
|
@@ -697,7 +729,7 @@ EXAMPLES
|
|
|
697
729
|
$ swaggerhub integration:delete organization/api/1.0.0/503c2db6-448a-4678-a310-f465429e9704
|
|
698
730
|
```
|
|
699
731
|
|
|
700
|
-
_See code: [src/commands/integration/delete.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
732
|
+
_See code: [src/commands/integration/delete.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/integration/delete.js)_
|
|
701
733
|
|
|
702
734
|
## `swaggerhub integration:execute`
|
|
703
735
|
|
|
@@ -720,7 +752,7 @@ EXAMPLES
|
|
|
720
752
|
$ swaggerhub integration:execute organization/api/1.0.0/503c2db6-448a-4678-a310-f465429e9704
|
|
721
753
|
```
|
|
722
754
|
|
|
723
|
-
_See code: [src/commands/integration/execute.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
755
|
+
_See code: [src/commands/integration/execute.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/integration/execute.js)_
|
|
724
756
|
|
|
725
757
|
## `swaggerhub integration:get`
|
|
726
758
|
|
|
@@ -743,7 +775,7 @@ EXAMPLES
|
|
|
743
775
|
$ swaggerhub integration:get organization/api/1.0.0/503c2db6-448a-4678-a310-f465429e9704
|
|
744
776
|
```
|
|
745
777
|
|
|
746
|
-
_See code: [src/commands/integration/get.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
778
|
+
_See code: [src/commands/integration/get.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/integration/get.js)_
|
|
747
779
|
|
|
748
780
|
## `swaggerhub integration:list`
|
|
749
781
|
|
|
@@ -766,7 +798,7 @@ EXAMPLES
|
|
|
766
798
|
$ swaggerhub integration:list organization/api/1.0.0
|
|
767
799
|
```
|
|
768
800
|
|
|
769
|
-
_See code: [src/commands/integration/list.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
801
|
+
_See code: [src/commands/integration/list.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/integration/list.js)_
|
|
770
802
|
|
|
771
803
|
## `swaggerhub integration:update`
|
|
772
804
|
|
|
@@ -790,7 +822,7 @@ EXAMPLES
|
|
|
790
822
|
$ swaggerhub integration:update organization/api/1.0.0/503c2db6-448a-4678-abcd-0123456789abc --file config.json
|
|
791
823
|
```
|
|
792
824
|
|
|
793
|
-
_See code: [src/commands/integration/update.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
825
|
+
_See code: [src/commands/integration/update.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/integration/update.js)_
|
|
794
826
|
|
|
795
827
|
## `swaggerhub plugins`
|
|
796
828
|
|
|
@@ -798,11 +830,14 @@ List installed plugins.
|
|
|
798
830
|
|
|
799
831
|
```
|
|
800
832
|
USAGE
|
|
801
|
-
$ swaggerhub plugins [--core]
|
|
833
|
+
$ swaggerhub plugins [--json] [--core]
|
|
802
834
|
|
|
803
835
|
FLAGS
|
|
804
836
|
--core Show core plugins.
|
|
805
837
|
|
|
838
|
+
GLOBAL FLAGS
|
|
839
|
+
--json Format output as json.
|
|
840
|
+
|
|
806
841
|
DESCRIPTION
|
|
807
842
|
List installed plugins.
|
|
808
843
|
|
|
@@ -810,7 +845,7 @@ EXAMPLES
|
|
|
810
845
|
$ swaggerhub plugins
|
|
811
846
|
```
|
|
812
847
|
|
|
813
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/
|
|
848
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.1.6/src/commands/plugins/index.ts)_
|
|
814
849
|
|
|
815
850
|
## `swaggerhub plugins:install`
|
|
816
851
|
|
|
@@ -875,7 +910,7 @@ EXAMPLES
|
|
|
875
910
|
$ swaggerhub plugins:inspect myplugin
|
|
876
911
|
```
|
|
877
912
|
|
|
878
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/
|
|
913
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.1.6/src/commands/plugins/inspect.ts)_
|
|
879
914
|
|
|
880
915
|
## `swaggerhub plugins:install`
|
|
881
916
|
|
|
@@ -915,7 +950,7 @@ EXAMPLES
|
|
|
915
950
|
$ swaggerhub plugins:install someuser/someplugin
|
|
916
951
|
```
|
|
917
952
|
|
|
918
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/
|
|
953
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.1.6/src/commands/plugins/install.ts)_
|
|
919
954
|
|
|
920
955
|
## `swaggerhub plugins:link`
|
|
921
956
|
|
|
@@ -944,7 +979,7 @@ EXAMPLES
|
|
|
944
979
|
$ swaggerhub plugins:link myplugin
|
|
945
980
|
```
|
|
946
981
|
|
|
947
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/
|
|
982
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.1.6/src/commands/plugins/link.ts)_
|
|
948
983
|
|
|
949
984
|
## `swaggerhub plugins:uninstall`
|
|
950
985
|
|
|
@@ -992,7 +1027,7 @@ ALIASES
|
|
|
992
1027
|
$ swaggerhub plugins:remove
|
|
993
1028
|
```
|
|
994
1029
|
|
|
995
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/
|
|
1030
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.1.6/src/commands/plugins/uninstall.ts)_
|
|
996
1031
|
|
|
997
1032
|
## `swaggerhub plugins:uninstall`
|
|
998
1033
|
|
|
@@ -1033,7 +1068,7 @@ DESCRIPTION
|
|
|
1033
1068
|
Update installed plugins.
|
|
1034
1069
|
```
|
|
1035
1070
|
|
|
1036
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/
|
|
1071
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.1.6/src/commands/plugins/update.ts)_
|
|
1037
1072
|
|
|
1038
1073
|
## `swaggerhub project:api:add`
|
|
1039
1074
|
|
|
@@ -1057,7 +1092,7 @@ EXAMPLES
|
|
|
1057
1092
|
$ swaggerhub project:api:add organization/project_name my_api
|
|
1058
1093
|
```
|
|
1059
1094
|
|
|
1060
|
-
_See code: [src/commands/project/api/add.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
1095
|
+
_See code: [src/commands/project/api/add.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/project/api/add.js)_
|
|
1061
1096
|
|
|
1062
1097
|
## `swaggerhub project:api:remove`
|
|
1063
1098
|
|
|
@@ -1081,7 +1116,7 @@ EXAMPLES
|
|
|
1081
1116
|
$ swaggerhub project:api:remove organization/project_name my_api
|
|
1082
1117
|
```
|
|
1083
1118
|
|
|
1084
|
-
_See code: [src/commands/project/api/remove.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
1119
|
+
_See code: [src/commands/project/api/remove.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/project/api/remove.js)_
|
|
1085
1120
|
|
|
1086
1121
|
## `swaggerhub project:create`
|
|
1087
1122
|
|
|
@@ -1117,7 +1152,7 @@ EXAMPLES
|
|
|
1117
1152
|
$ swaggerhub project:create organization/new_project_name -a "testapi1" -d "testdomain3" --description "description"
|
|
1118
1153
|
```
|
|
1119
1154
|
|
|
1120
|
-
_See code: [src/commands/project/create.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
1155
|
+
_See code: [src/commands/project/create.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/project/create.js)_
|
|
1121
1156
|
|
|
1122
1157
|
## `swaggerhub project:delete`
|
|
1123
1158
|
|
|
@@ -1140,7 +1175,7 @@ EXAMPLES
|
|
|
1140
1175
|
$ swaggerhub project:delete organization/project_name
|
|
1141
1176
|
```
|
|
1142
1177
|
|
|
1143
|
-
_See code: [src/commands/project/delete.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
1178
|
+
_See code: [src/commands/project/delete.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/project/delete.js)_
|
|
1144
1179
|
|
|
1145
1180
|
## `swaggerhub project:domain:add`
|
|
1146
1181
|
|
|
@@ -1164,7 +1199,7 @@ EXAMPLES
|
|
|
1164
1199
|
$ swaggerhub project:domain:add organization/project_name my_domain
|
|
1165
1200
|
```
|
|
1166
1201
|
|
|
1167
|
-
_See code: [src/commands/project/domain/add.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
1202
|
+
_See code: [src/commands/project/domain/add.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/project/domain/add.js)_
|
|
1168
1203
|
|
|
1169
1204
|
## `swaggerhub project:domain:remove`
|
|
1170
1205
|
|
|
@@ -1188,7 +1223,7 @@ EXAMPLES
|
|
|
1188
1223
|
$ swaggerhub project:domain:remove organization/project_name my_domain
|
|
1189
1224
|
```
|
|
1190
1225
|
|
|
1191
|
-
_See code: [src/commands/project/domain/remove.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
1226
|
+
_See code: [src/commands/project/domain/remove.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/project/domain/remove.js)_
|
|
1192
1227
|
|
|
1193
1228
|
## `swaggerhub project:get`
|
|
1194
1229
|
|
|
@@ -1211,7 +1246,7 @@ EXAMPLES
|
|
|
1211
1246
|
$ swaggerhub project:get organization/project_name
|
|
1212
1247
|
```
|
|
1213
1248
|
|
|
1214
|
-
_See code: [src/commands/project/get.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
1249
|
+
_See code: [src/commands/project/get.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/project/get.js)_
|
|
1215
1250
|
|
|
1216
1251
|
## `swaggerhub project:list`
|
|
1217
1252
|
|
|
@@ -1236,7 +1271,7 @@ EXAMPLES
|
|
|
1236
1271
|
$ swaggerhub project:list organization
|
|
1237
1272
|
```
|
|
1238
1273
|
|
|
1239
|
-
_See code: [src/commands/project/list.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
1274
|
+
_See code: [src/commands/project/list.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/project/list.js)_
|
|
1240
1275
|
|
|
1241
1276
|
## `swaggerhub project:member:list`
|
|
1242
1277
|
|
|
@@ -1259,7 +1294,7 @@ EXAMPLES
|
|
|
1259
1294
|
$ swaggerhub project:member:list organisation/project_name
|
|
1260
1295
|
```
|
|
1261
1296
|
|
|
1262
|
-
_See code: [src/commands/project/member/list.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.
|
|
1297
|
+
_See code: [src/commands/project/member/list.js](https://github.com/SmartBear/swaggerhub-cli/blob/v0.8.0/src/commands/project/member/list.js)_
|
|
1263
1298
|
<!-- commandsstop -->
|
|
1264
1299
|
|
|
1265
1300
|
# Plugins
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.8.0",
|
|
3
3
|
"commands": {
|
|
4
4
|
"configure": {
|
|
5
5
|
"id": "configure",
|
|
@@ -337,43 +337,6 @@
|
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
339
|
},
|
|
340
|
-
"api:validate": {
|
|
341
|
-
"id": "api:validate",
|
|
342
|
-
"description": "get validation result for an API version\nWhen VERSION is not included in the argument, the default version will be validated.\nAn error will occur if the API version does not exist.\nIf the flag `-c` or `--failOnCritical` is used and there are standardization\nerrors with `Critical` severity present, the command will exit with error code `1`.\n",
|
|
343
|
-
"strict": true,
|
|
344
|
-
"pluginName": "swaggerhub-cli",
|
|
345
|
-
"pluginAlias": "swaggerhub-cli",
|
|
346
|
-
"pluginType": "core",
|
|
347
|
-
"aliases": [],
|
|
348
|
-
"examples": [
|
|
349
|
-
"swaggerhub api:validate organization/api/1.0.0",
|
|
350
|
-
"swaggerhub api:validate -c organization/api/1.0.0",
|
|
351
|
-
"swaggerhub api:validate --fail-on-critical organization/api"
|
|
352
|
-
],
|
|
353
|
-
"flags": {
|
|
354
|
-
"help": {
|
|
355
|
-
"name": "help",
|
|
356
|
-
"type": "boolean",
|
|
357
|
-
"char": "h",
|
|
358
|
-
"description": "Show CLI help.",
|
|
359
|
-
"allowNo": false
|
|
360
|
-
},
|
|
361
|
-
"fail-on-critical": {
|
|
362
|
-
"name": "fail-on-critical",
|
|
363
|
-
"type": "boolean",
|
|
364
|
-
"char": "c",
|
|
365
|
-
"description": "Exit with error code 1 if there are critical standardization errors present",
|
|
366
|
-
"allowNo": false
|
|
367
|
-
}
|
|
368
|
-
},
|
|
369
|
-
"args": {
|
|
370
|
-
"OWNER/API_NAME/[VERSION]": {
|
|
371
|
-
"name": "OWNER/API_NAME/[VERSION]",
|
|
372
|
-
"description": "API to fetch validation errors for from Swaggerhub",
|
|
373
|
-
"required": true
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
},
|
|
377
340
|
"domain:create": {
|
|
378
341
|
"id": "domain:create",
|
|
379
342
|
"description": "creates a new domain / domain version from a YAML/JSON file\nThe domain version from the file will be used unless the version is specified in the command argument.\nAn error will occur if the domain version already exists.\n",
|
|
@@ -1001,6 +964,103 @@
|
|
|
1001
964
|
}
|
|
1002
965
|
}
|
|
1003
966
|
},
|
|
967
|
+
"api:validate": {
|
|
968
|
+
"id": "api:validate",
|
|
969
|
+
"description": "Get validation result for an API version\nWhen VERSION is not included in the argument, the default version will be validated.\nAn error will occur if the API version does not exist.\nIf the flag `-c` or `--failOnCritical` is used and there are standardization\nerrors with `Critical` severity present, the command will exit with error code `1`.\n",
|
|
970
|
+
"strict": true,
|
|
971
|
+
"pluginName": "swaggerhub-cli",
|
|
972
|
+
"pluginAlias": "swaggerhub-cli",
|
|
973
|
+
"pluginType": "core",
|
|
974
|
+
"aliases": [],
|
|
975
|
+
"examples": [
|
|
976
|
+
"swaggerhub api:validate organization/api/1.0.0",
|
|
977
|
+
"swaggerhub api:validate -c -j organization/api/1.0.0",
|
|
978
|
+
"swaggerhub api:validate --fail-on-critical --json organization/api"
|
|
979
|
+
],
|
|
980
|
+
"flags": {
|
|
981
|
+
"help": {
|
|
982
|
+
"name": "help",
|
|
983
|
+
"type": "boolean",
|
|
984
|
+
"char": "h",
|
|
985
|
+
"description": "Show CLI help.",
|
|
986
|
+
"allowNo": false
|
|
987
|
+
},
|
|
988
|
+
"fail-on-critical": {
|
|
989
|
+
"name": "fail-on-critical",
|
|
990
|
+
"type": "boolean",
|
|
991
|
+
"char": "c",
|
|
992
|
+
"description": "Exit with error code 1 if there are critical standardization errors present",
|
|
993
|
+
"allowNo": false
|
|
994
|
+
},
|
|
995
|
+
"json": {
|
|
996
|
+
"name": "json",
|
|
997
|
+
"type": "boolean",
|
|
998
|
+
"char": "j",
|
|
999
|
+
"description": "Print output in JSON instead of table format",
|
|
1000
|
+
"allowNo": false
|
|
1001
|
+
}
|
|
1002
|
+
},
|
|
1003
|
+
"args": {
|
|
1004
|
+
"OWNER/API_NAME/[VERSION]": {
|
|
1005
|
+
"name": "OWNER/API_NAME/[VERSION]",
|
|
1006
|
+
"description": "API to fetch validation errors for from Swaggerhub",
|
|
1007
|
+
"required": true
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
},
|
|
1011
|
+
"api:validate:local": {
|
|
1012
|
+
"id": "api:validate:local",
|
|
1013
|
+
"description": "Runs a scan against a local API definition using the organization's standardization configuration on SwaggerHub.\nIf the flag `-c` or `--failOnCritical` is used and there are standardization\nerrors with `Critical` severity present, the command will exit with error code `1`.\n",
|
|
1014
|
+
"strict": true,
|
|
1015
|
+
"pluginName": "swaggerhub-cli",
|
|
1016
|
+
"pluginAlias": "swaggerhub-cli",
|
|
1017
|
+
"pluginType": "core",
|
|
1018
|
+
"aliases": [],
|
|
1019
|
+
"examples": [
|
|
1020
|
+
"swaggerhub api:validate:local -o myOrg -f ./my-api.yaml -c -j ",
|
|
1021
|
+
"swaggerhub api:validate:local --organization myOrg --file ./my-api/json --fail-on-critical --json"
|
|
1022
|
+
],
|
|
1023
|
+
"flags": {
|
|
1024
|
+
"help": {
|
|
1025
|
+
"name": "help",
|
|
1026
|
+
"type": "boolean",
|
|
1027
|
+
"char": "h",
|
|
1028
|
+
"description": "Show CLI help.",
|
|
1029
|
+
"allowNo": false
|
|
1030
|
+
},
|
|
1031
|
+
"fail-on-critical": {
|
|
1032
|
+
"name": "fail-on-critical",
|
|
1033
|
+
"type": "boolean",
|
|
1034
|
+
"char": "c",
|
|
1035
|
+
"description": "Exit with error code 1 if there are critical standardization errors present",
|
|
1036
|
+
"allowNo": false
|
|
1037
|
+
},
|
|
1038
|
+
"json": {
|
|
1039
|
+
"name": "json",
|
|
1040
|
+
"type": "boolean",
|
|
1041
|
+
"char": "j",
|
|
1042
|
+
"description": "Print output in JSON instead of table format",
|
|
1043
|
+
"allowNo": false
|
|
1044
|
+
},
|
|
1045
|
+
"file": {
|
|
1046
|
+
"name": "file",
|
|
1047
|
+
"type": "option",
|
|
1048
|
+
"char": "f",
|
|
1049
|
+
"description": "Path of API definition file to run scan against",
|
|
1050
|
+
"required": true,
|
|
1051
|
+
"multiple": false
|
|
1052
|
+
},
|
|
1053
|
+
"organization": {
|
|
1054
|
+
"name": "organization",
|
|
1055
|
+
"type": "option",
|
|
1056
|
+
"char": "o",
|
|
1057
|
+
"description": "Which organization's standardization settings to use for linting the target definition",
|
|
1058
|
+
"required": true,
|
|
1059
|
+
"multiple": false
|
|
1060
|
+
}
|
|
1061
|
+
},
|
|
1062
|
+
"args": {}
|
|
1063
|
+
},
|
|
1004
1064
|
"project:api:add": {
|
|
1005
1065
|
"id": "project:api:add",
|
|
1006
1066
|
"description": "Adds an API to an existing project.",
|
package/package.json
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swaggerhub-cli",
|
|
3
3
|
"description": "SwaggerHub CLI",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.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/core": "^2.8.
|
|
12
|
-
"@oclif/plugin-help": "^5.2.
|
|
13
|
-
"@oclif/plugin-plugins": "^
|
|
11
|
+
"@oclif/core": "^2.8.11",
|
|
12
|
+
"@oclif/plugin-help": "^5.2.11",
|
|
13
|
+
"@oclif/plugin-plugins": "^3.1.6",
|
|
14
14
|
"deep-extend": "^0.6.0",
|
|
15
|
-
"fs-extra": "^11.1.
|
|
16
|
-
"inquirer": "^8.
|
|
15
|
+
"fs-extra": "^11.1.1",
|
|
16
|
+
"inquirer": "^8.2.5",
|
|
17
17
|
"js-yaml": "^4.1.0",
|
|
18
|
-
"json-templates": "^
|
|
19
|
-
"node-fetch": "^2.6.
|
|
20
|
-
"semver": "^7.3
|
|
18
|
+
"json-templates": "^5.0.0",
|
|
19
|
+
"node-fetch": "^2.6.12",
|
|
20
|
+
"semver": "^7.5.3"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@oclif/test": "^2.3.
|
|
23
|
+
"@oclif/test": "^2.3.26",
|
|
24
24
|
"chai": "^4.3.7",
|
|
25
|
-
"eslint": "^8.
|
|
25
|
+
"eslint": "^8.44.0",
|
|
26
26
|
"eslint-plugin-chai-friendly": "^0.7.2",
|
|
27
27
|
"eslint-plugin-immutable": "^1.0.0",
|
|
28
28
|
"eslint-plugin-mocha": "^10.1.0",
|
|
29
29
|
"eslint-plugin-node": "^11.1.0",
|
|
30
|
-
"globby": "^
|
|
31
|
-
"husky": "^
|
|
30
|
+
"globby": "^13.2.1",
|
|
31
|
+
"husky": "^8.0.3",
|
|
32
32
|
"mocha": "^10.2.0",
|
|
33
|
-
"nock": "^13.3.
|
|
33
|
+
"nock": "^13.3.1",
|
|
34
34
|
"nyc": "^15.1.0",
|
|
35
35
|
"rewire": "^6.0.0",
|
|
36
36
|
"tmp": "^0.2.1"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
const { Args
|
|
2
|
-
const
|
|
3
|
-
const { getApiIdentifierArg } = require('
|
|
4
|
-
const { getApi } = require('
|
|
5
|
-
const { pipeAsync } = require('
|
|
6
|
-
const { getResponseContent } = require('
|
|
7
|
-
const { isOnPrem } = require('
|
|
1
|
+
const { Args } = require('@oclif/core')
|
|
2
|
+
const BaseValidateCommand = require('../../../support/command/base-validate-command')
|
|
3
|
+
const { getApiIdentifierArg } = require('../../../support/command/parse-input')
|
|
4
|
+
const { getApi } = require('../../../requests/api')
|
|
5
|
+
const { pipeAsync } = require('../../../utils/general')
|
|
6
|
+
const { getResponseContent } = require('../../../support/command/handle-response')
|
|
7
|
+
const { isOnPrem } = require('../../../support/isOnPrem')
|
|
8
8
|
|
|
9
|
-
class ValidateCommand extends
|
|
9
|
+
class ValidateCommand extends BaseValidateCommand {
|
|
10
10
|
async run() {
|
|
11
11
|
const { args, flags } = await this.parse(ValidateCommand)
|
|
12
12
|
const apiPath = getApiIdentifierArg(args)
|
|
@@ -17,21 +17,8 @@ class ValidateCommand extends BaseCommand {
|
|
|
17
17
|
if (validationResult.validation.length === 0 && isOnPrem()) {
|
|
18
18
|
validationResult = await this.getFallbackValidationResult(validPath)
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const validationResultsStr = validationResult.validation
|
|
23
|
-
.map(err => {
|
|
24
|
-
if (err.severity.toUpperCase() === 'CRITICAL') hasCritical = true
|
|
25
|
-
return `${err.line}: \t${err.severity} \t${err.description}`
|
|
26
|
-
})
|
|
27
|
-
.join('\n')
|
|
28
|
-
if (validationResult.validation.length) {
|
|
29
|
-
this.log('line \tseverity \tdescription\n')
|
|
30
|
-
}
|
|
31
|
-
this.log(validationResultsStr)
|
|
32
|
-
|
|
33
|
-
if (hasCritical && flags['fail-on-critical']) this.exit(1)
|
|
34
|
-
this.exit(0)
|
|
20
|
+
this.printValidationOutput(flags, validationResult)
|
|
21
|
+
this.exitWithCode(flags, validationResult)
|
|
35
22
|
}
|
|
36
23
|
|
|
37
24
|
getValidationResult(apiPath) {
|
|
@@ -52,10 +39,9 @@ class ValidateCommand extends BaseCommand {
|
|
|
52
39
|
options: {}
|
|
53
40
|
})
|
|
54
41
|
}
|
|
55
|
-
|
|
56
42
|
}
|
|
57
43
|
|
|
58
|
-
ValidateCommand.description = `
|
|
44
|
+
ValidateCommand.description = `Get validation result for an API version
|
|
59
45
|
When VERSION is not included in the argument, the default version will be validated.
|
|
60
46
|
An error will occur if the API version does not exist.
|
|
61
47
|
If the flag \`-c\` or \`--failOnCritical\` is used and there are standardization
|
|
@@ -64,8 +50,8 @@ errors with \`Critical\` severity present, the command will exit with error code
|
|
|
64
50
|
|
|
65
51
|
ValidateCommand.examples = [
|
|
66
52
|
'swaggerhub api:validate organization/api/1.0.0',
|
|
67
|
-
'swaggerhub api:validate -c organization/api/1.0.0',
|
|
68
|
-
'swaggerhub api:validate --fail-on-critical organization/api'
|
|
53
|
+
'swaggerhub api:validate -c -j organization/api/1.0.0',
|
|
54
|
+
'swaggerhub api:validate --fail-on-critical --json organization/api'
|
|
69
55
|
]
|
|
70
56
|
|
|
71
57
|
ValidateCommand.args = {
|
|
@@ -76,11 +62,6 @@ ValidateCommand.args = {
|
|
|
76
62
|
}
|
|
77
63
|
|
|
78
64
|
ValidateCommand.flags = {
|
|
79
|
-
|
|
80
|
-
char: 'c',
|
|
81
|
-
description: 'Exit with error code 1 if there are critical standardization errors present',
|
|
82
|
-
default: false
|
|
83
|
-
}),
|
|
84
|
-
...BaseCommand.flags
|
|
65
|
+
...BaseValidateCommand.flags
|
|
85
66
|
}
|
|
86
67
|
module.exports = ValidateCommand
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const { Flags } = require('@oclif/core')
|
|
2
|
+
const BaseValidateCommand = require('../../../support/command/base-validate-command')
|
|
3
|
+
const { pipeAsync } = require('../../../utils/general')
|
|
4
|
+
const { getResponseContent } = require('../../../support/command/handle-response')
|
|
5
|
+
const { postStandardization } = require('../../../requests/standardization')
|
|
6
|
+
const { parseDefinition, getSpecification, getVersion } = require('../../../utils/definitions')
|
|
7
|
+
const { readFileSync } = require('fs-extra')
|
|
8
|
+
|
|
9
|
+
class ValidateLocalCommand extends BaseValidateCommand {
|
|
10
|
+
async run() {
|
|
11
|
+
const { flags } = await this.parse(ValidateLocalCommand)
|
|
12
|
+
this.validateDefinition(flags['file'])
|
|
13
|
+
const definition = readFileSync(flags['file'])
|
|
14
|
+
const validationResult = await this.getValidationResult(flags['organization'], definition)
|
|
15
|
+
this.printValidationOutput(flags, validationResult)
|
|
16
|
+
this.exitWithCode(flags, validationResult)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Rudimentary checks to check that file is
|
|
20
|
+
// at least an OpenAPI/AsyncAPI definition
|
|
21
|
+
// and is valid yaml/json
|
|
22
|
+
validateDefinition(pathToFile) {
|
|
23
|
+
const definition = parseDefinition(pathToFile)
|
|
24
|
+
getSpecification(definition)
|
|
25
|
+
getVersion(definition)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getValidationResult(orgName, body) {
|
|
29
|
+
return this.executeHttp({
|
|
30
|
+
execute: () => postStandardization([orgName, 'scan'], body),
|
|
31
|
+
onResolve: pipeAsync(getResponseContent, JSON.parse),
|
|
32
|
+
options: {}
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
}
|
|
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
|
|
39
|
+
errors with \`Critical\` severity present, the command will exit with error code \`1\`.
|
|
40
|
+
`
|
|
41
|
+
|
|
42
|
+
ValidateLocalCommand.examples = [
|
|
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',
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
ValidateLocalCommand.flags = {
|
|
48
|
+
'file': Flags.string({
|
|
49
|
+
char: 'f',
|
|
50
|
+
description: 'Path of API definition file to run scan against',
|
|
51
|
+
required: true
|
|
52
|
+
}),
|
|
53
|
+
'organization': Flags.string({
|
|
54
|
+
char: 'o',
|
|
55
|
+
description: 'Which organization\'s standardization settings to use for linting the target definition',
|
|
56
|
+
required: true
|
|
57
|
+
}),
|
|
58
|
+
...BaseValidateCommand.flags
|
|
59
|
+
}
|
|
60
|
+
module.exports = ValidateLocalCommand
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const config = require('../config')
|
|
2
|
+
const http = require('../support/http')
|
|
3
|
+
const { hasJsonStructure } = require('../utils/general')
|
|
4
|
+
|
|
5
|
+
const postStandardization = (pathParams, body) => {
|
|
6
|
+
const { SWAGGERHUB_URL, SWAGGERHUB_API_KEY } = config.getConfig()
|
|
7
|
+
const isJson = hasJsonStructure(body)
|
|
8
|
+
|
|
9
|
+
return http({
|
|
10
|
+
url: [SWAGGERHUB_URL, 'standardization', ...pathParams],
|
|
11
|
+
auth: SWAGGERHUB_API_KEY,
|
|
12
|
+
contentType: isJson ? 'json' : 'yaml',
|
|
13
|
+
method: 'POST',
|
|
14
|
+
body
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = {
|
|
19
|
+
postStandardization
|
|
20
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const { Flags, ux } = require('@oclif/core')
|
|
2
|
+
const BaseCommand = require('../../support/command/base-command')
|
|
3
|
+
|
|
4
|
+
class BaseValidateCommand extends BaseCommand {
|
|
5
|
+
|
|
6
|
+
exitWithCode(flags, validationResult) {
|
|
7
|
+
const hasCritical = validationResult.validation.some(err => err.severity.toUpperCase() === 'CRITICAL')
|
|
8
|
+
const exitCode = hasCritical && flags['fail-on-critical'] ? 1 : 0
|
|
9
|
+
this.exit(exitCode)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
printValidationOutput(flags, validationResult) {
|
|
13
|
+
if (validationResult.validation.length && !flags['json']) {
|
|
14
|
+
ux.table(validationResult.validation, {
|
|
15
|
+
line: {},
|
|
16
|
+
severity: {},
|
|
17
|
+
description: {},
|
|
18
|
+
}, {
|
|
19
|
+
printLine: this.log.bind(this)
|
|
20
|
+
})
|
|
21
|
+
} else {
|
|
22
|
+
this.log(JSON.stringify(validationResult, null, 2))
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
BaseValidateCommand.flags = {
|
|
28
|
+
'fail-on-critical': Flags.boolean({
|
|
29
|
+
char: 'c',
|
|
30
|
+
description: 'Exit with error code 1 if there are critical standardization errors present',
|
|
31
|
+
default: false
|
|
32
|
+
}),
|
|
33
|
+
'json': Flags.boolean({
|
|
34
|
+
char: 'j',
|
|
35
|
+
description: 'Print output in JSON instead of table format',
|
|
36
|
+
default: false
|
|
37
|
+
}),
|
|
38
|
+
...BaseCommand.flags
|
|
39
|
+
}
|
|
40
|
+
module.exports = BaseValidateCommand
|