specshield 1.0.13 → 2.0.1
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 +471 -28
- package/package.json +7 -8
- package/src/api/bdctClient.js +115 -0
- package/src/cli.js +2 -0
- package/src/commands/bdct.js +648 -0
package/README.md
CHANGED
|
@@ -7,17 +7,16 @@
|
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
> **OpenAPI Diff ·
|
|
10
|
+
> **OpenAPI Diff · API Breaking Change Detection · Swagger Diff · Consumer-Driven Contract Testing · Pact Alternative · can-i-deploy · Bi-Directional Contract Testing · GitHub PR Checks · CI/CD**
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
14
|
## Stop Breaking APIs in Production
|
|
15
15
|
|
|
16
|
-
**SpecShield** detects breaking API changes
|
|
17
|
-
before they become production incidents.
|
|
16
|
+
**SpecShield** detects breaking API changes, runs contract tests, and gates deployments — directly in your CI/CD pipeline before they become production incidents.
|
|
18
17
|
|
|
19
18
|
```
|
|
20
|
-
OpenAPI diff + contract testing +
|
|
19
|
+
OpenAPI diff + contract testing + bi-directional contracts + GitHub PR checks — in one CLI.
|
|
21
20
|
```
|
|
22
21
|
|
|
23
22
|
No broker. No complex setup. Works in 30 seconds.
|
|
@@ -135,19 +134,21 @@ That's it. Works with any OpenAPI 3.x YAML or JSON spec.
|
|
|
135
134
|
|
|
136
135
|
## Local vs Cloud
|
|
137
136
|
|
|
138
|
-
| Feature | Local (Free) | Cloud
|
|
139
|
-
|
|
140
|
-
| Compare two spec files | ✅ | ✅ |
|
|
141
|
-
| Breaking change detection | ✅ | ✅ |
|
|
142
|
-
| JSON / human output | ✅ | ✅ |
|
|
143
|
-
| Fail CI on breaking change | ✅ | ✅ |
|
|
144
|
-
| **Compare history & dashboard** | ❌ | ✅ |
|
|
145
|
-
| **
|
|
146
|
-
| **can-i-deploy gating** | ❌ | ✅ |
|
|
147
|
-
| **
|
|
148
|
-
| **
|
|
149
|
-
|
|
150
|
-
|
|
137
|
+
| Feature | Local (Free) | Cloud Free | Cloud Pro |
|
|
138
|
+
|---|---|---|---|
|
|
139
|
+
| Compare two spec files | ✅ | ✅ | ✅ |
|
|
140
|
+
| Breaking change detection | ✅ | ✅ | ✅ |
|
|
141
|
+
| JSON / human output | ✅ | ✅ | ✅ |
|
|
142
|
+
| Fail CI on breaking change | ✅ | ✅ | ✅ |
|
|
143
|
+
| **Compare history & dashboard** | ❌ | ✅ | ✅ |
|
|
144
|
+
| **CDCT contract testing registry** | ❌ | ✅ | ✅ |
|
|
145
|
+
| **CDCT can-i-deploy gating** | ❌ | ✅ | ✅ |
|
|
146
|
+
| **GitHub App PR checks** | ❌ | ✅ | ✅ |
|
|
147
|
+
| **BDCT bi-directional contracts** | ❌ | ❌ | ✅ |
|
|
148
|
+
| **BDCT can-i-deploy gating** | ❌ | ❌ | ✅ |
|
|
149
|
+
| **BDCT compatibility matrix** | ❌ | ❌ | ✅ |
|
|
150
|
+
| **Team collaboration** | ❌ | ❌ | ✅ |
|
|
151
|
+
| **API drift trends** | ❌ | ✅ | ✅ |
|
|
151
152
|
|
|
152
153
|
---
|
|
153
154
|
|
|
@@ -190,13 +191,16 @@ Track API drift over time across your entire platform. Know what changed, when,
|
|
|
190
191
|
|
|
191
192
|
## vs. Alternatives
|
|
192
193
|
|
|
193
|
-
| Feature | SpecShield | Pact | openapi-diff |
|
|
194
|
+
| Feature | SpecShield | Pact / Pactflow | openapi-diff |
|
|
194
195
|
|---|---|---|---|
|
|
195
196
|
| OpenAPI / Swagger native | ✅ | ❌ (code-level) | ✅ |
|
|
196
197
|
| No broker required | ✅ | ❌ (needs Pact Broker) | ✅ |
|
|
197
|
-
|
|
|
198
|
+
| Consumer-driven contract testing | ✅ | ✅ | ❌ |
|
|
199
|
+
| **Bi-directional contract testing** | ✅ | ✅ (Pactflow paid) | ❌ |
|
|
198
200
|
| Breaking change detection | ✅ | ❌ | ✅ |
|
|
199
201
|
| can-i-deploy gating | ✅ | ✅ (via broker) | ❌ |
|
|
202
|
+
| **GitHub App PR checks** | ✅ | ❌ | ❌ |
|
|
203
|
+
| **Pact JSON contract import** | ✅ | ✅ | ❌ |
|
|
200
204
|
| Hosted dashboard | ✅ | ✅ (Pactflow, paid) | ❌ |
|
|
201
205
|
| Team collaboration | ✅ | ✅ (paid) | ❌ |
|
|
202
206
|
| CLI-first workflow | ✅ | ❌ | ✅ |
|
|
@@ -208,8 +212,8 @@ Track API drift over time across your entire platform. Know what changed, when,
|
|
|
208
212
|
|
|
209
213
|
| Plan | Price | What's included |
|
|
210
214
|
|---|---|---|
|
|
211
|
-
| **Free** | $0 forever | Local compare
|
|
212
|
-
| **Pro** | Coming soon | Team collaboration
|
|
215
|
+
| **Free** | $0 forever | Local compare (unlimited) · Compare history & dashboard · CDCT contracts & can-i-deploy · GitHub App PR checks |
|
|
216
|
+
| **Pro** | Coming soon | Everything in Free + BDCT bi-directional contracts · BDCT can-i-deploy & matrix · Team collaboration · Advanced reporting · Priority support |
|
|
213
217
|
|
|
214
218
|
No credit card ever required for the free plan.
|
|
215
219
|
**[Get started free →](https://specshield.io)**
|
|
@@ -291,14 +295,70 @@ specshield compare base.yaml target.yaml --remote --json --output result.json
|
|
|
291
295
|
|
|
292
296
|
---
|
|
293
297
|
|
|
294
|
-
##
|
|
298
|
+
## GitHub Integration
|
|
299
|
+
|
|
300
|
+
**Automatic API contract checks on every pull request — no workflow YAML required.**
|
|
301
|
+
|
|
302
|
+
Install the SpecShield GitHub App once and every PR that touches your OpenAPI spec gets:
|
|
303
|
+
- A GitHub check run (pass/fail) visible directly on the PR
|
|
304
|
+
- A PR comment with the full diff table — breaking changes highlighted in red
|
|
305
|
+
- Configurable `fail-on-breaking` per repository
|
|
306
|
+
|
|
307
|
+
### Install the GitHub App
|
|
308
|
+
|
|
309
|
+
1. Go to **Dashboard → GitHub Integration** at [specshield.io](https://specshield.io)
|
|
310
|
+
2. Click **Install GitHub App**
|
|
311
|
+
3. Choose the repositories to enable (or select all)
|
|
312
|
+
4. Done — no secrets, no workflow changes needed
|
|
313
|
+
|
|
314
|
+
### How It Works
|
|
315
|
+
|
|
316
|
+
When a PR is opened or updated, SpecShield:
|
|
317
|
+
|
|
318
|
+
1. Fetches the OpenAPI spec from the base branch and the PR branch
|
|
319
|
+
2. Runs the same diff engine as `specshield compare`
|
|
320
|
+
3. Posts a GitHub check run — **Passed** if no breaking changes, **Failed** if breaking changes found
|
|
321
|
+
4. Adds a PR comment with the full breakdown:
|
|
322
|
+
|
|
323
|
+
```
|
|
324
|
+
## SpecShield API Contract Check
|
|
325
|
+
|
|
326
|
+
| Change | Type | Severity |
|
|
327
|
+
|--------|------|----------|
|
|
328
|
+
| POST /payments — "amount" required field added | Request schema | BREAKING |
|
|
329
|
+
| GET /orders/{id} — "status" type changed | Response schema | BREAKING |
|
|
330
|
+
| GET /users — new query param "filter" | Addition | NON-BREAKING |
|
|
331
|
+
|
|
332
|
+
Breaking changes: 2 · Non-breaking: 1
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### Configure Per Repository
|
|
336
|
+
|
|
337
|
+
Add a `.specshield.yml` to your repo root:
|
|
338
|
+
|
|
339
|
+
```yaml
|
|
340
|
+
github:
|
|
341
|
+
specPath: api/openapi.yaml # path to your spec (default: openapi.yaml)
|
|
342
|
+
failOnBreaking: true # block PR merge on breaking changes (default: true)
|
|
343
|
+
commentOnPr: true # post breakdown comment (default: true)
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Requirements
|
|
347
|
+
|
|
348
|
+
- The spec file must exist on both the base branch and the PR branch
|
|
349
|
+
- Supported formats: OpenAPI 3.x YAML or JSON
|
|
350
|
+
- The GitHub App needs `pull_requests: write` and `checks: write` permissions (granted during install)
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## Contract Testing (CDCT)
|
|
295
355
|
|
|
296
356
|
Consumer-driven contract testing for microservices — without a broker.
|
|
297
357
|
|
|
298
358
|
**How it works:**
|
|
299
359
|
|
|
300
360
|
1. Consumer team publishes a contract (what they expect from the provider)
|
|
301
|
-
2. Provider team verifies their service satisfies it
|
|
361
|
+
2. Provider team verifies their service satisfies it by actually calling it
|
|
302
362
|
3. `can-i-deploy` gates the deployment based on verification results
|
|
303
363
|
|
|
304
364
|
### Contract File Format
|
|
@@ -389,7 +449,7 @@ specshield contracts latest --consumer checkout-ui --provider payment-service --
|
|
|
389
449
|
specshield contracts history --contract-id 42
|
|
390
450
|
```
|
|
391
451
|
|
|
392
|
-
### Full Workflow
|
|
452
|
+
### Full CDCT Workflow
|
|
393
453
|
|
|
394
454
|
```bash
|
|
395
455
|
# 1. Consumer publishes contract
|
|
@@ -404,6 +464,294 @@ specshield contracts can-i-deploy --provider payment-service --version v2.1.0
|
|
|
404
464
|
|
|
405
465
|
---
|
|
406
466
|
|
|
467
|
+
## Bi-Directional Contract Testing (BDCT)
|
|
468
|
+
|
|
469
|
+
**Spec-to-spec contract testing — no running services required.**
|
|
470
|
+
|
|
471
|
+
BDCT is the static alternative to CDCT. Instead of running the provider server, both sides publish their OpenAPI specs. SpecShield compares them and flags mismatches immediately — ideal for teams that don't run services locally or in CI.
|
|
472
|
+
|
|
473
|
+
> BDCT requires a **Pro plan**. [Upgrade at specshield.io/upgrade](https://specshield.io/upgrade)
|
|
474
|
+
|
|
475
|
+
**CDCT vs BDCT:**
|
|
476
|
+
|
|
477
|
+
| | CDCT | BDCT |
|
|
478
|
+
|---|---|---|
|
|
479
|
+
| How verification works | Replay requests against a live server | Compare OpenAPI specs statically |
|
|
480
|
+
| Provider needs to run | Yes | No |
|
|
481
|
+
| Feedback speed | After deploy to test env | Immediately on spec publish |
|
|
482
|
+
| Pact JSON contracts | Supported | Supported (auto-converted) |
|
|
483
|
+
| Best for | Runtime correctness | Early spec-level safety |
|
|
484
|
+
|
|
485
|
+
### How BDCT Works
|
|
486
|
+
|
|
487
|
+
1. Consumer team publishes an OpenAPI spec subset (the endpoints they use)
|
|
488
|
+
2. Provider team publishes their full OpenAPI spec
|
|
489
|
+
3. SpecShield compares them: endpoint presence, request schemas, response fields, status codes, types
|
|
490
|
+
4. `can-i-deploy` gates the deployment — returns `0` only when all consumers are compatible
|
|
491
|
+
|
|
492
|
+
### Publish a Provider Spec
|
|
493
|
+
|
|
494
|
+
```bash
|
|
495
|
+
specshield bdct publish-provider \
|
|
496
|
+
--org acme-store \
|
|
497
|
+
--provider payment-service \
|
|
498
|
+
--version v2.1.0 \
|
|
499
|
+
--spec ./api/openapi.yaml \
|
|
500
|
+
--env production
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
```
|
|
504
|
+
✔ Provider spec published
|
|
505
|
+
Provider : payment-service
|
|
506
|
+
Version : v2.1.0
|
|
507
|
+
Env : production
|
|
508
|
+
Auto-verifications triggered: 3
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
### Publish a Consumer Contract
|
|
512
|
+
|
|
513
|
+
The consumer contract is an OpenAPI spec that describes only the endpoints the consumer uses:
|
|
514
|
+
|
|
515
|
+
```yaml
|
|
516
|
+
# consumer-contract.yaml — only the subset checkout-ui uses
|
|
517
|
+
openapi: "3.0.0"
|
|
518
|
+
info:
|
|
519
|
+
title: checkout-ui → payment-service contract
|
|
520
|
+
version: "1.0.0"
|
|
521
|
+
paths:
|
|
522
|
+
/payments:
|
|
523
|
+
post:
|
|
524
|
+
requestBody:
|
|
525
|
+
content:
|
|
526
|
+
application/json:
|
|
527
|
+
schema:
|
|
528
|
+
type: object
|
|
529
|
+
required: [orderId, amount, currency]
|
|
530
|
+
properties:
|
|
531
|
+
orderId: { type: string }
|
|
532
|
+
amount: { type: number }
|
|
533
|
+
currency: { type: string }
|
|
534
|
+
responses:
|
|
535
|
+
"201":
|
|
536
|
+
content:
|
|
537
|
+
application/json:
|
|
538
|
+
schema:
|
|
539
|
+
type: object
|
|
540
|
+
properties:
|
|
541
|
+
paymentId: { type: string }
|
|
542
|
+
status: { type: string }
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
```bash
|
|
546
|
+
specshield bdct publish-consumer \
|
|
547
|
+
--org acme-store \
|
|
548
|
+
--consumer checkout-ui \
|
|
549
|
+
--provider payment-service \
|
|
550
|
+
--version 2.0.0 \
|
|
551
|
+
--contract ./contracts/checkout-ui-payment.yaml
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
```
|
|
555
|
+
✔ Consumer contract published
|
|
556
|
+
Consumer : checkout-ui @ 2.0.0
|
|
557
|
+
Provider : payment-service
|
|
558
|
+
Compatibility: COMPATIBLE
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
If the provider spec is already published, compatibility is checked immediately.
|
|
562
|
+
|
|
563
|
+
**Pact JSON contracts are also accepted** — SpecShield auto-converts them:
|
|
564
|
+
|
|
565
|
+
```bash
|
|
566
|
+
specshield bdct publish-consumer \
|
|
567
|
+
--org acme-store \
|
|
568
|
+
--consumer checkout-ui \
|
|
569
|
+
--provider payment-service \
|
|
570
|
+
--version 2.0.0 \
|
|
571
|
+
--contract ./pacts/checkout-ui-payment-service.json
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
### Verify Compatibility
|
|
575
|
+
|
|
576
|
+
Manually trigger a verification between a specific consumer/provider pair:
|
|
577
|
+
|
|
578
|
+
```bash
|
|
579
|
+
specshield bdct verify \
|
|
580
|
+
--org acme-store \
|
|
581
|
+
--consumer checkout-ui \
|
|
582
|
+
--consumer-version 2.0.0 \
|
|
583
|
+
--provider payment-service \
|
|
584
|
+
--provider-version v2.1.0 \
|
|
585
|
+
--env production
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
Compatible output:
|
|
589
|
+
```
|
|
590
|
+
✔ COMPATIBLE
|
|
591
|
+
|
|
592
|
+
Endpoints checked: 2
|
|
593
|
+
Compatible : 2
|
|
594
|
+
Incompatible : 0
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
Incompatible output:
|
|
598
|
+
```
|
|
599
|
+
✖ INCOMPATIBLE
|
|
600
|
+
|
|
601
|
+
Endpoints checked: 2
|
|
602
|
+
Compatible : 1
|
|
603
|
+
Incompatible : 1
|
|
604
|
+
|
|
605
|
+
Issues
|
|
606
|
+
● POST /payments [ERROR] RESPONSE_FIELD_MISSING
|
|
607
|
+
field: $.status
|
|
608
|
+
Consumer expects it — provider spec does not return it
|
|
609
|
+
|
|
610
|
+
● GET /payments/{id} [WARNING] TYPE_MISMATCH
|
|
611
|
+
field: $.amount
|
|
612
|
+
consumer: integer → provider: string
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
### Can I Deploy? (BDCT)
|
|
616
|
+
|
|
617
|
+
```bash
|
|
618
|
+
specshield bdct can-i-deploy \
|
|
619
|
+
--org acme-store \
|
|
620
|
+
--service payment-service \
|
|
621
|
+
--version v2.1.0 \
|
|
622
|
+
--env production
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
```
|
|
626
|
+
✔ DEPLOYABLE
|
|
627
|
+
|
|
628
|
+
payment-service v2.1.0 is COMPATIBLE with all 3 consumer(s)
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
```
|
|
632
|
+
✖ NOT DEPLOYABLE
|
|
633
|
+
|
|
634
|
+
payment-service v2.1.0 is INCOMPATIBLE with:
|
|
635
|
+
checkout-ui@2.0.0 (INCOMPATIBLE)
|
|
636
|
+
mobile-app@1.5.0 (INCOMPATIBLE)
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
Exit codes: `0` = deployable · `1` = blocked · `2` = error
|
|
640
|
+
|
|
641
|
+
### Compatibility Matrix
|
|
642
|
+
|
|
643
|
+
View the compatibility status across all consumer/provider pairs in your org:
|
|
644
|
+
|
|
645
|
+
```bash
|
|
646
|
+
specshield bdct matrix --org acme-store --env production
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
```
|
|
650
|
+
Compatibility Matrix (env: production)
|
|
651
|
+
|
|
652
|
+
payment-service order-service
|
|
653
|
+
checkout-ui COMPATIBLE COMPATIBLE
|
|
654
|
+
mobile-app INCOMPATIBLE COMPATIBLE
|
|
655
|
+
partner-sdk COMPATIBLE UNKNOWN
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
### List Provider Specs
|
|
659
|
+
|
|
660
|
+
```bash
|
|
661
|
+
# All providers for the org
|
|
662
|
+
specshield bdct list-providers --org acme-store
|
|
663
|
+
|
|
664
|
+
# Filter by provider name
|
|
665
|
+
specshield bdct list-providers --org acme-store --provider payment-service
|
|
666
|
+
```
|
|
667
|
+
|
|
668
|
+
```
|
|
669
|
+
Provider Specs
|
|
670
|
+
|
|
671
|
+
payment-service v2.1.0 production 2025-05-01
|
|
672
|
+
payment-service v2.0.0 staging 2025-04-20
|
|
673
|
+
order-service v1.3.0 production 2025-04-28
|
|
674
|
+
```
|
|
675
|
+
|
|
676
|
+
### List Consumer Contracts
|
|
677
|
+
|
|
678
|
+
```bash
|
|
679
|
+
# All consumers for the org
|
|
680
|
+
specshield bdct list-consumers --org acme-store
|
|
681
|
+
|
|
682
|
+
# Filter by consumer or provider
|
|
683
|
+
specshield bdct list-consumers --org acme-store --consumer checkout-ui
|
|
684
|
+
specshield bdct list-consumers --org acme-store --provider payment-service
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
### List Verifications
|
|
688
|
+
|
|
689
|
+
```bash
|
|
690
|
+
specshield bdct list-verifications \
|
|
691
|
+
--org acme-store \
|
|
692
|
+
--provider payment-service \
|
|
693
|
+
--env production \
|
|
694
|
+
--page 0 \
|
|
695
|
+
--size 20
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
```
|
|
699
|
+
BDCT Verifications
|
|
700
|
+
|
|
701
|
+
Consumer Consumer Ver Provider Provider Ver Env Status Verified At
|
|
702
|
+
checkout-ui 2.0.0 payment-service v2.1.0 production COMPATIBLE 2025-05-01 14:30
|
|
703
|
+
mobile-app 1.5.0 payment-service v2.1.0 production INCOMPATIBLE 2025-05-01 14:30
|
|
704
|
+
```
|
|
705
|
+
|
|
706
|
+
### BDCT JSON Output
|
|
707
|
+
|
|
708
|
+
All BDCT commands support `--json` for CI parsing:
|
|
709
|
+
|
|
710
|
+
```bash
|
|
711
|
+
specshield bdct can-i-deploy --org acme-store --service payment-service --version v2.1.0 --json
|
|
712
|
+
```
|
|
713
|
+
|
|
714
|
+
```json
|
|
715
|
+
{
|
|
716
|
+
"deployable": false,
|
|
717
|
+
"service": "payment-service",
|
|
718
|
+
"version": "v2.1.0",
|
|
719
|
+
"environment": "production",
|
|
720
|
+
"reason": "payment-service v2.1.0 is INCOMPATIBLE with: checkout-ui@2.0.0 (INCOMPATIBLE)",
|
|
721
|
+
"verifications": [
|
|
722
|
+
{
|
|
723
|
+
"consumerName": "checkout-ui",
|
|
724
|
+
"consumerVersion": "2.0.0",
|
|
725
|
+
"status": "INCOMPATIBLE",
|
|
726
|
+
"compatibleCount": 1,
|
|
727
|
+
"incompatibleCount": 1
|
|
728
|
+
}
|
|
729
|
+
]
|
|
730
|
+
}
|
|
731
|
+
```
|
|
732
|
+
|
|
733
|
+
### Full BDCT Workflow
|
|
734
|
+
|
|
735
|
+
```bash
|
|
736
|
+
# 1. Provider publishes spec on every release
|
|
737
|
+
specshield bdct publish-provider \
|
|
738
|
+
--org acme-store --provider payment-service \
|
|
739
|
+
--version v2.1.0 --spec ./api/openapi.yaml
|
|
740
|
+
|
|
741
|
+
# 2. Each consumer publishes their contract once (update on contract change)
|
|
742
|
+
specshield bdct publish-consumer \
|
|
743
|
+
--org acme-store --consumer checkout-ui \
|
|
744
|
+
--provider payment-service --version 2.0.0 \
|
|
745
|
+
--contract ./contracts/checkout-ui.yaml
|
|
746
|
+
|
|
747
|
+
# 3. Gate the provider deployment
|
|
748
|
+
specshield bdct can-i-deploy \
|
|
749
|
+
--org acme-store --service payment-service \
|
|
750
|
+
--version v2.1.0 --env production
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
---
|
|
754
|
+
|
|
407
755
|
## CI/CD — GitHub Actions
|
|
408
756
|
|
|
409
757
|
### On Pull Request — Catch breaking changes before merge
|
|
@@ -432,7 +780,7 @@ jobs:
|
|
|
432
780
|
run: specshield compare /tmp/base.yaml api/openapi.yaml --fail-on-breaking
|
|
433
781
|
```
|
|
434
782
|
|
|
435
|
-
### On Push — Publish consumer contract
|
|
783
|
+
### On Push — Publish consumer contract (CDCT)
|
|
436
784
|
|
|
437
785
|
```yaml
|
|
438
786
|
name: Publish Contract
|
|
@@ -462,7 +810,7 @@ jobs:
|
|
|
462
810
|
--tag ${{ github.ref_name }}
|
|
463
811
|
```
|
|
464
812
|
|
|
465
|
-
### On Push — Verify provider + gate deployment
|
|
813
|
+
### On Push — Verify provider + gate deployment (CDCT)
|
|
466
814
|
|
|
467
815
|
```yaml
|
|
468
816
|
name: Contract Verification
|
|
@@ -499,6 +847,79 @@ jobs:
|
|
|
499
847
|
--env staging
|
|
500
848
|
```
|
|
501
849
|
|
|
850
|
+
### On Push — Publish provider spec (BDCT)
|
|
851
|
+
|
|
852
|
+
```yaml
|
|
853
|
+
name: BDCT Publish Provider Spec
|
|
854
|
+
|
|
855
|
+
on:
|
|
856
|
+
push:
|
|
857
|
+
branches: [main]
|
|
858
|
+
paths:
|
|
859
|
+
- 'api/openapi.yaml'
|
|
860
|
+
|
|
861
|
+
jobs:
|
|
862
|
+
publish-bdct:
|
|
863
|
+
runs-on: ubuntu-latest
|
|
864
|
+
steps:
|
|
865
|
+
- uses: actions/checkout@v4
|
|
866
|
+
- uses: actions/setup-node@v4
|
|
867
|
+
with:
|
|
868
|
+
node-version: '20'
|
|
869
|
+
- run: npm install -g specshield
|
|
870
|
+
- name: Publish provider spec
|
|
871
|
+
env:
|
|
872
|
+
SPECSHIELD_API_KEY: ${{ secrets.SPECSHIELD_API_KEY }}
|
|
873
|
+
run: |
|
|
874
|
+
specshield bdct publish-provider \
|
|
875
|
+
--org ${{ vars.SPECSHIELD_ORG }} \
|
|
876
|
+
--provider payment-service \
|
|
877
|
+
--version ${{ github.sha }} \
|
|
878
|
+
--spec ./api/openapi.yaml \
|
|
879
|
+
--env production
|
|
880
|
+
- name: Gate deployment
|
|
881
|
+
env:
|
|
882
|
+
SPECSHIELD_API_KEY: ${{ secrets.SPECSHIELD_API_KEY }}
|
|
883
|
+
run: |
|
|
884
|
+
specshield bdct can-i-deploy \
|
|
885
|
+
--org ${{ vars.SPECSHIELD_ORG }} \
|
|
886
|
+
--service payment-service \
|
|
887
|
+
--version ${{ github.sha }} \
|
|
888
|
+
--env production
|
|
889
|
+
```
|
|
890
|
+
|
|
891
|
+
### On Contract Change — Publish consumer contract (BDCT)
|
|
892
|
+
|
|
893
|
+
```yaml
|
|
894
|
+
name: BDCT Publish Consumer Contract
|
|
895
|
+
|
|
896
|
+
on:
|
|
897
|
+
push:
|
|
898
|
+
branches: [main]
|
|
899
|
+
paths:
|
|
900
|
+
- 'contracts/bdct/**'
|
|
901
|
+
|
|
902
|
+
jobs:
|
|
903
|
+
publish-consumer:
|
|
904
|
+
runs-on: ubuntu-latest
|
|
905
|
+
steps:
|
|
906
|
+
- uses: actions/checkout@v4
|
|
907
|
+
- uses: actions/setup-node@v4
|
|
908
|
+
with:
|
|
909
|
+
node-version: '20'
|
|
910
|
+
- run: npm install -g specshield
|
|
911
|
+
- name: Publish consumer contract
|
|
912
|
+
env:
|
|
913
|
+
SPECSHIELD_API_KEY: ${{ secrets.SPECSHIELD_API_KEY }}
|
|
914
|
+
run: |
|
|
915
|
+
specshield bdct publish-consumer \
|
|
916
|
+
--org ${{ vars.SPECSHIELD_ORG }} \
|
|
917
|
+
--consumer checkout-ui \
|
|
918
|
+
--provider payment-service \
|
|
919
|
+
--version ${{ github.ref_name }} \
|
|
920
|
+
--contract ./contracts/bdct/checkout-ui-payment.yaml
|
|
921
|
+
```
|
|
922
|
+
|
|
502
923
|
---
|
|
503
924
|
|
|
504
925
|
## Config File
|
|
@@ -517,6 +938,11 @@ remote:
|
|
|
517
938
|
url: "https://specshield.io/compare"
|
|
518
939
|
timeout: 10000
|
|
519
940
|
# apiKey: "" ← use env var instead
|
|
941
|
+
|
|
942
|
+
github:
|
|
943
|
+
specPath: api/openapi.yaml
|
|
944
|
+
failOnBreaking: true
|
|
945
|
+
commentOnPr: true
|
|
520
946
|
```
|
|
521
947
|
|
|
522
948
|
CLI flags always override config file values.
|
|
@@ -542,14 +968,31 @@ specshield compare <base> <target> [options]
|
|
|
542
968
|
| `--config <path>` | Path to `.specshield.yml` |
|
|
543
969
|
| `--timeout <ms>` | Request timeout for remote mode |
|
|
544
970
|
|
|
971
|
+
```bash
|
|
972
|
+
specshield bdct <subcommand> [options]
|
|
973
|
+
```
|
|
974
|
+
|
|
975
|
+
| Subcommand | Description |
|
|
976
|
+
|---|---|
|
|
977
|
+
| `publish-provider` | Publish a provider OpenAPI spec |
|
|
978
|
+
| `publish-consumer` | Publish a consumer contract (OpenAPI subset or Pact JSON) |
|
|
979
|
+
| `verify` | Manually trigger verification for a consumer/provider pair |
|
|
980
|
+
| `can-i-deploy` | Check if a service version is safe to deploy |
|
|
981
|
+
| `matrix` | View compatibility matrix across all pairs |
|
|
982
|
+
| `list-providers` | List published provider specs |
|
|
983
|
+
| `list-consumers` | List published consumer contracts |
|
|
984
|
+
| `list-verifications` | List verification history |
|
|
985
|
+
|
|
986
|
+
All `bdct` subcommands support `--json` for machine-readable output.
|
|
987
|
+
|
|
545
988
|
---
|
|
546
989
|
|
|
547
990
|
## Exit Codes
|
|
548
991
|
|
|
549
992
|
| Code | Meaning |
|
|
550
993
|
|---|---|
|
|
551
|
-
| `0` | Clean — no breaking changes |
|
|
552
|
-
| `1` | Breaking changes found
|
|
994
|
+
| `0` | Clean — no breaking changes / deployable |
|
|
995
|
+
| `1` | Breaking changes found / not deployable |
|
|
553
996
|
| `2` | Config error, missing token, or runtime error |
|
|
554
997
|
|
|
555
998
|
---
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "specshield",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "CLI
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "CLI for OpenAPI breaking change detection, consumer-driven contract testing, and bi-directional contract verification — with can-i-deploy gating and GitHub PR checks.",
|
|
5
5
|
"main": "src/cli.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"specshield": "./bin/specshield.js"
|
|
@@ -18,11 +18,8 @@
|
|
|
18
18
|
"api-diff",
|
|
19
19
|
"openapi-diff",
|
|
20
20
|
"swagger-diff",
|
|
21
|
-
"api-diff-tool",
|
|
22
21
|
"breaking-change-detection",
|
|
23
22
|
"api-breaking-changes",
|
|
24
|
-
"prevent-breaking-api",
|
|
25
|
-
"api-regression",
|
|
26
23
|
"api-compatibility",
|
|
27
24
|
"contract-testing",
|
|
28
25
|
"consumer-driven-contract",
|
|
@@ -30,7 +27,6 @@
|
|
|
30
27
|
"contract-verification",
|
|
31
28
|
"can-i-deploy",
|
|
32
29
|
"ci-cd",
|
|
33
|
-
"devops",
|
|
34
30
|
"github-actions",
|
|
35
31
|
"cli",
|
|
36
32
|
"developer-tools",
|
|
@@ -41,8 +37,11 @@
|
|
|
41
37
|
"microservices",
|
|
42
38
|
"api-quality",
|
|
43
39
|
"api-governance",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
40
|
+
"bi-directional-contract-testing",
|
|
41
|
+
"bdct",
|
|
42
|
+
"pact-json",
|
|
43
|
+
"github-app",
|
|
44
|
+
"api-drift"
|
|
46
45
|
],
|
|
47
46
|
"license": "MIT",
|
|
48
47
|
"files": [
|