specshield 1.0.7 → 1.0.8

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 (2) hide show
  1. package/README.md +153 -92
  2. package/package.json +32 -24
package/README.md CHANGED
@@ -5,7 +5,89 @@
5
5
  [![license](https://img.shields.io/badge/license-MIT-blue)](#license)
6
6
  [![node](https://img.shields.io/badge/node-%3E%3D18-green)](https://nodejs.org)
7
7
 
8
- Compare OpenAPI and Swagger specs, detect breaking changes, and fail CI before incompatible API changes reach production.
8
+ ## 🚀 Prevent Breaking API Changes Before They Reach Production
9
+
10
+ **SpecShield is a Pact alternative for OpenAPI** that helps developers
11
+ **detect breaking API changes in CI/CD** and act as a powerful
12
+ **OpenAPI diff tool for modern backend teams.**
13
+
14
+ ---
15
+
16
+ ## 👀 See it in action
17
+
18
+ ```bash
19
+ $ specshield compare base.yaml target.yaml --fail-on-breaking
20
+
21
+ ✖ BREAKING CHANGES DETECTED
22
+
23
+ 1. DELETE /users endpoint removed
24
+ 2. POST /payments request field "amount" changed from optional to required
25
+ 3. GET /orders/{id} response field "status" type changed: string -> object
26
+
27
+ Summary
28
+ - Breaking changes : 3
29
+ - Modifications : 1
30
+ - Additions : 2
31
+ - Warnings : 0
32
+
33
+ CI Result: FAILED
34
+ Exit Code: 1
35
+ ```
36
+
37
+ These are the kinds of changes that break clients in production.
38
+ SpecShield catches them early so your CI can block unsafe deployments.
39
+
40
+ ### Safe change example
41
+
42
+ ```bash
43
+ $ specshield compare base.yaml target.yaml --fail-on-breaking
44
+
45
+ ✔ NO BREAKING CHANGES FOUND
46
+
47
+ Summary
48
+ - Breaking changes : 0
49
+ - Modifications : 1
50
+ - Additions : 3
51
+ - Warnings : 1
52
+
53
+ CI Result: PASSED
54
+ Exit Code: 0
55
+ ```
56
+
57
+ ---
58
+
59
+ ## ⚡ 30-second quick start
60
+
61
+ ```bash
62
+ npm install -g specshield
63
+ specshield compare base.yaml target.yaml --fail-on-breaking
64
+ ```
65
+
66
+ 👉 No account required for local compare
67
+
68
+ ---
69
+
70
+ ## 💡 Useful for
71
+
72
+ - Preventing accidental API breakage in pull requests
73
+ - Failing CI when breaking changes are introduced
74
+ - Tracking API drift across versions
75
+ - Enforcing contracts between consumer and provider services
76
+
77
+ ---
78
+
79
+ ## 🌐 Upgrade to Remote
80
+
81
+ Local compare is free and unlimited.
82
+
83
+ Remote mode unlocks:
84
+
85
+ - 📊 API change history
86
+ - 👥 Team collaboration
87
+ - 🚦 Deployment gating (`can-i-deploy`)
88
+ - 🔗 Contract testing across services
89
+
90
+ 👉 https://specshield.io
9
91
 
10
92
  ---
11
93
 
@@ -15,7 +97,7 @@ Compare OpenAPI and Swagger specs, detect breaking changes, and fail CI before i
15
97
  - [Installation](#installation)
16
98
  - [Local Compare](#local-compare)
17
99
  - [Authentication](#authentication)
18
- - [Generate an API Token](#generate-an-api-token)
100
+ - [Generate an API Token](#generate-an-api-token)
19
101
  - [Remote Compare](#remote-compare)
20
102
  - [Contracts — Consumer-Driven Testing](#contracts--consumer-driven-testing)
21
103
  - [Contract File Format](#contract-file-format)
@@ -37,12 +119,11 @@ Compare OpenAPI and Swagger specs, detect breaking changes, and fail CI before i
37
119
 
38
120
  ## What is SpecShield CLI?
39
121
 
40
- SpecShield CLI is a command-line tool for comparing two OpenAPI/Swagger specifications and detecting what changed between them. It classifies changes into:
122
+ SpecShield CLI is a developer-first **OpenAPI diff tool** and
123
+ **contract testing solution** that helps prevent breaking API changes.
41
124
 
42
- - **Breaking changes** removed endpoints, changed required fields, incompatible type changes
43
- - **Modifications** changed behavior that may or may not break clients
44
- - **Additions** — new endpoints or fields
45
- - **Warnings** — low-severity notices
125
+ It works as a lightweight **Pact alternative for OpenAPI**, designed for
126
+ modern microservices and CI/CD pipelines.
46
127
 
47
128
  It works in two modes:
48
129
 
@@ -131,7 +212,7 @@ This validates the token against the SpecShield API and saves it to `~/.specshie
131
212
 
132
213
  **Example output:**
133
214
 
134
- ```
215
+ ```text
135
216
  ✔ Logged in successfully.
136
217
 
137
218
  Customer: Jane Smith
@@ -198,14 +279,12 @@ specshield compare base.yaml target.yaml --remote --json --output result.json
198
279
 
199
280
  The CLI reads your API token (from flag, env var, or stored config) and sends it as an `X-Api-Key` header with each request. If no token is found, the command exits with an error:
200
281
 
201
- ```
282
+ ```text
202
283
  Error: No API key found. Run: specshield login --api-key <KEY>
203
284
  ```
204
285
 
205
286
  ---
206
287
 
207
- ---
208
-
209
288
  ## Contracts — Consumer-Driven Testing
210
289
 
211
290
  SpecShield Contracts lets consumer teams publish API expectations (contracts) to a central registry. Provider teams then verify their service satisfies those contracts before deploying.
@@ -217,8 +296,6 @@ SpecShield Contracts lets consumer teams publish API expectations (contracts) to
217
296
 
218
297
  All contract commands require an API token. See [Authentication](#authentication).
219
298
 
220
- ---
221
-
222
299
  ### Contract File Format
223
300
 
224
301
  Create a `.json` file describing the expected API interactions:
@@ -270,32 +347,30 @@ Create a `.json` file describing the expected API interactions:
270
347
 
271
348
  The `consumer.name`, `provider.name`, and `contractName` fields are used to identify the contract in the registry. CLI flags (`--consumer`, `--provider`, `--contract-name`) override file values if provided.
272
349
 
273
- ---
274
-
275
350
  ### Publish a Contract
276
351
 
277
352
  ```bash
278
- specshield contracts publish \
279
- --file ./contracts/create-payment.json \
353
+ specshield contracts publish \\
354
+ --file ./contracts/create-payment.json \\
280
355
  --org acme
281
356
  ```
282
357
 
283
358
  With all flags explicitly set (flags override file values):
284
359
 
285
360
  ```bash
286
- specshield contracts publish \
287
- --file ./contracts/create-payment.json \
288
- --org acme \
289
- --consumer checkout-ui \
290
- --provider payment-service \
291
- --contract-name create-payment \
292
- --consumer-version 1.2.0 \
361
+ specshield contracts publish \\
362
+ --file ./contracts/create-payment.json \\
363
+ --org acme \\
364
+ --consumer checkout-ui \\
365
+ --provider payment-service \\
366
+ --contract-name create-payment \\
367
+ --consumer-version 1.2.0 \\
293
368
  --tag main
294
369
  ```
295
370
 
296
371
  **Example output:**
297
372
 
298
- ```
373
+ ```text
299
374
  ✔ Contract Published Successfully
300
375
  ─────────────────────────────────────────────────────
301
376
  Contract ID : 42
@@ -324,8 +399,6 @@ specshield contracts publish \
324
399
  | `--server <url>` | SpecShield server URL (default: `https://specshield.io`) |
325
400
  | `--api-token <token>` | API token |
326
401
 
327
- ---
328
-
329
402
  ### List Contracts
330
403
 
331
404
  ```bash
@@ -341,9 +414,9 @@ specshield contracts list --provider payment-service
341
414
  Filter by consumer, org, status:
342
415
 
343
416
  ```bash
344
- specshield contracts list \
345
- --consumer checkout-ui \
346
- --provider payment-service \
417
+ specshield contracts list \\
418
+ --consumer checkout-ui \\
419
+ --provider payment-service \\
347
420
  --status PUBLISHED
348
421
  ```
349
422
 
@@ -355,7 +428,7 @@ specshield contracts list --json
355
428
 
356
429
  **Example output:**
357
430
 
358
- ```
431
+ ```text
359
432
  SpecShield Contract Registry
360
433
  ─────────────────────────────────────────────────────
361
434
  Showing 2 of 2 contracts
@@ -379,23 +452,21 @@ specshield contracts list --json
379
452
  | `--size <n>` | Page size (default: `20`) |
380
453
  | `--json` | Output raw JSON |
381
454
 
382
- ---
383
-
384
455
  ### Get Latest Contract
385
456
 
386
457
  ```bash
387
- specshield contracts latest \
388
- --consumer checkout-ui \
389
- --provider payment-service \
458
+ specshield contracts latest \\
459
+ --consumer checkout-ui \\
460
+ --provider payment-service \\
390
461
  --contract-name create-payment
391
462
  ```
392
463
 
393
464
  Print the full contract content (interactions, body, etc.):
394
465
 
395
466
  ```bash
396
- specshield contracts latest \
397
- --consumer checkout-ui \
398
- --provider payment-service \
467
+ specshield contracts latest \\
468
+ --consumer checkout-ui \\
469
+ --provider payment-service \\
399
470
  --json
400
471
  ```
401
472
 
@@ -409,40 +480,38 @@ specshield contracts latest \
409
480
  | `--contract-name <name>` | Contract name |
410
481
  | `--json` | Print full contract JSON |
411
482
 
412
- ---
413
-
414
483
  ### Verify a Contract
415
484
 
416
485
  Run the contract against a live provider. SpecShield replays each interaction against the `--base-url` and compares the response to the expected values.
417
486
 
418
487
  ```bash
419
- specshield contracts verify \
420
- --contract-id 42 \
488
+ specshield contracts verify \\
489
+ --contract-id 42 \\
421
490
  --base-url http://localhost:8080
422
491
  ```
423
492
 
424
493
  With version and environment tags:
425
494
 
426
495
  ```bash
427
- specshield contracts verify \
428
- --contract-id 42 \
429
- --base-url https://payment-service.staging.internal \
430
- --provider-version v2.1.0 \
496
+ specshield contracts verify \\
497
+ --contract-id 42 \\
498
+ --base-url https://payment-service.staging.internal \\
499
+ --provider-version v2.1.0 \\
431
500
  --env staging
432
501
  ```
433
502
 
434
503
  Output raw JSON (for CI parsing):
435
504
 
436
505
  ```bash
437
- specshield contracts verify \
438
- --contract-id 42 \
439
- --base-url http://localhost:8080 \
506
+ specshield contracts verify \\
507
+ --contract-id 42 \\
508
+ --base-url http://localhost:8080 \\
440
509
  --json
441
510
  ```
442
511
 
443
512
  **Example output (pass):**
444
513
 
445
- ```
514
+ ```text
446
515
  ✔ Verification PASSED (1/1 interactions)
447
516
  ─────────────────────────────────────────────────────
448
517
  Verification ID : 101
@@ -456,7 +525,7 @@ specshield contracts verify \
456
525
 
457
526
  **Example output (fail):**
458
527
 
459
- ```
528
+ ```text
460
529
  ✖ Verification FAILED (0/1 interactions passed, 1 failed)
461
530
  ─────────────────────────────────────────────────────
462
531
  Verification ID : 102
@@ -485,8 +554,6 @@ specshield contracts verify \
485
554
  | `--mode <mode>` | `LIVE` or `REPLAY` (default: `LIVE`) |
486
555
  | `--json` | Output raw JSON |
487
556
 
488
- ---
489
-
490
557
  ### Verification History
491
558
 
492
559
  ```bash
@@ -495,7 +562,7 @@ specshield contracts history --contract-id 42
495
562
 
496
563
  **Example output:**
497
564
 
498
- ```
565
+ ```text
499
566
  Verification History — Contract 42
500
567
  ─────────────────────────────────────────────────────
501
568
 
@@ -513,30 +580,28 @@ specshield contracts history --contract-id 42
513
580
  | `--contract-id <id>` | Contract ID (required) |
514
581
  | `--json` | Output raw JSON |
515
582
 
516
- ---
517
-
518
583
  ### Can I Deploy?
519
584
 
520
585
  Check whether a provider version has passing verifications for all associated contracts:
521
586
 
522
587
  ```bash
523
- specshield contracts can-i-deploy \
524
- --provider payment-service \
588
+ specshield contracts can-i-deploy \\
589
+ --provider payment-service \\
525
590
  --version v2.1.0
526
591
  ```
527
592
 
528
593
  Scoped to a specific environment:
529
594
 
530
595
  ```bash
531
- specshield contracts can-i-deploy \
532
- --provider payment-service \
533
- --version v2.1.0 \
596
+ specshield contracts can-i-deploy \\
597
+ --provider payment-service \\
598
+ --version v2.1.0 \\
534
599
  --env production
535
600
  ```
536
601
 
537
602
  **Example output (allowed):**
538
603
 
539
- ```
604
+ ```text
540
605
  ✔ PASS: payment-service v2.1.0 is deployable in production
541
606
  ─────────────────────────────────────────────────────
542
607
 
@@ -547,7 +612,7 @@ specshield contracts can-i-deploy \
547
612
 
548
613
  **Example output (blocked):**
549
614
 
550
- ```
615
+ ```text
551
616
  ✖ FAIL: payment-service v2.1.0 is NOT deployable in production
552
617
  ─────────────────────────────────────────────────────
553
618
 
@@ -570,35 +635,31 @@ specshield contracts can-i-deploy \
570
635
  | `--env <environment>` | Target environment |
571
636
  | `--json` | Output raw JSON |
572
637
 
573
- ---
574
-
575
638
  ### Full Publish → Verify → Deploy Workflow
576
639
 
577
640
  ```bash
578
641
  # 1. Consumer team publishes a contract
579
- specshield contracts publish \
580
- --file ./contracts/create-payment.json \
642
+ specshield contracts publish \\
643
+ --file ./contracts/create-payment.json \\
581
644
  --org acme
582
645
 
583
646
  # 2. Provider team starts their service locally
584
647
  ./gradlew bootRun &
585
648
 
586
649
  # 3. Provider team verifies the contract
587
- specshield contracts verify \
588
- --contract-id 42 \
589
- --base-url http://localhost:8080 \
590
- --provider-version v2.1.0 \
650
+ specshield contracts verify \\
651
+ --contract-id 42 \\
652
+ --base-url http://localhost:8080 \\
653
+ --provider-version v2.1.0 \\
591
654
  --env staging
592
655
 
593
656
  # 4. Gate the deployment
594
- specshield contracts can-i-deploy \
595
- --provider payment-service \
596
- --version v2.1.0 \
657
+ specshield contracts can-i-deploy \\
658
+ --provider payment-service \\
659
+ --version v2.1.0 \\
597
660
  --env staging
598
661
  ```
599
662
 
600
- ---
601
-
602
663
  ### Contracts in CI/CD
603
664
 
604
665
  #### GitHub Actions — Publish on consumer change
@@ -625,9 +686,9 @@ jobs:
625
686
  env:
626
687
  SPECSHIELD_API_KEY: ${{ secrets.SPECSHIELD_API_KEY }}
627
688
  run: |
628
- specshield contracts publish \
629
- --file ./contracts/create-payment.json \
630
- --org acme \
689
+ specshield contracts publish \\
690
+ --file ./contracts/create-payment.json \\
691
+ --org acme \\
631
692
  --tag ${{ github.ref_name }}
632
693
  ```
633
694
 
@@ -659,19 +720,19 @@ jobs:
659
720
  env:
660
721
  SPECSHIELD_API_KEY: ${{ secrets.SPECSHIELD_API_KEY }}
661
722
  run: |
662
- specshield contracts verify \
663
- --contract-id ${{ vars.PAYMENT_CONTRACT_ID }} \
664
- --base-url http://localhost:8080 \
665
- --provider-version ${{ github.sha }} \
723
+ specshield contracts verify \\
724
+ --contract-id ${{ vars.PAYMENT_CONTRACT_ID }} \\
725
+ --base-url http://localhost:8080 \\
726
+ --provider-version ${{ github.sha }} \\
666
727
  --env staging
667
728
 
668
729
  - name: Can I deploy?
669
730
  env:
670
731
  SPECSHIELD_API_KEY: ${{ secrets.SPECSHIELD_API_KEY }}
671
732
  run: |
672
- specshield contracts can-i-deploy \
673
- --provider payment-service \
674
- --version ${{ github.sha }} \
733
+ specshield contracts can-i-deploy \\
734
+ --provider payment-service \\
735
+ --version ${{ github.sha }} \\
675
736
  --env staging
676
737
  ```
677
738
 
@@ -763,8 +824,8 @@ jobs:
763
824
 
764
825
  - name: Compare specs
765
826
  run: |
766
- specshield compare /tmp/base-spec.yaml api/openapi.yaml \
767
- --fail-on-breaking \
827
+ specshield compare /tmp/base-spec.yaml api/openapi.yaml \\
828
+ --fail-on-breaking \\
768
829
  --output spec-diff.json
769
830
 
770
831
  - name: Upload diff report
@@ -784,9 +845,9 @@ Add your API token as a GitHub Actions secret named `SPECSHIELD_API_KEY`, then:
784
845
  env:
785
846
  SPECSHIELD_API_KEY: ${{ secrets.SPECSHIELD_API_KEY }}
786
847
  run: |
787
- specshield compare /tmp/base-spec.yaml api/openapi.yaml \
788
- --remote \
789
- --fail-on-breaking \
848
+ specshield compare /tmp/base-spec.yaml api/openapi.yaml \\
849
+ --remote \\
850
+ --fail-on-breaking \\
790
851
  --output spec-diff.json
791
852
  ```
792
853
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "specshield",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "CLI to compare OpenAPI/Swagger specs and detect breaking changes for CI/CD pipelines and local developer workflows.",
5
5
  "main": "src/cli.js",
6
6
  "bin": {
@@ -13,29 +13,37 @@
13
13
  "lint": "eslint src tests --ext .js"
14
14
  },
15
15
  "keywords": [
16
- "openapi",
17
- "swagger",
18
- "openapi-diff",
19
- "swagger-diff",
20
- "api-diff",
21
- "api-breaking-changes",
22
- "breaking-change-detection",
23
- "contract-testing",
24
- "api-contract",
25
- "api-versioning",
26
- "api-governance",
27
- "ci-cd",
28
- "devops",
29
- "github-actions",
30
- "automation",
31
- "cli",
32
- "developer-tools",
33
- "yaml",
34
- "json",
35
- "schema-diff",
36
- "rest-api",
37
- "openapi-cli"
38
- ],
16
+ "openapi",
17
+ "swagger",
18
+ "api-diff",
19
+ "openapi-diff",
20
+ "swagger-diff",
21
+ "api-diff-tool",
22
+ "breaking-change-detection",
23
+ "api-breaking-changes",
24
+ "prevent-breaking-api",
25
+ "api-regression",
26
+ "api-compatibility",
27
+ "contract-testing",
28
+ "consumer-driven-contract",
29
+ "api-contract",
30
+ "contract-verification",
31
+ "can-i-deploy",
32
+ "ci-cd",
33
+ "devops",
34
+ "github-actions",
35
+ "cli",
36
+ "developer-tools",
37
+ "openapi-compare",
38
+ "swagger-compare",
39
+ "pact-alternative",
40
+ "api-contract-testing",
41
+ "microservices",
42
+ "api-quality",
43
+ "api-governance",
44
+ "yaml",
45
+ "json"
46
+ ],
39
47
  "license": "MIT",
40
48
  "files": [
41
49
  "bin",