mirror of
https://github.com/LukeHagar/redocly-cli.git
synced 2025-12-06 04:21:09 +00:00
fix: add webhooks to stats and fix crash for webhooks tags (#1663)
* fix: add webhooks to stats and fix crash for webhooks tags * chore: add changeset * Update packages/cli/src/wrapper.ts * Update .changeset/short-onions-live.md * update snapshots * Update .changeset/short-onions-live.md Co-authored-by: Adam Altman <adam@redocly.com> --------- Co-authored-by: Andrew Tatomyr <andrew.tatomyr@redocly.com> Co-authored-by: Adam Altman <adam@redocly.com>
This commit is contained in:
5
.changeset/short-onions-live.md
Normal file
5
.changeset/short-onions-live.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@redocly/cli": patch
|
||||
---
|
||||
|
||||
Added support for webhooks in stats and fixed a crash that occurred when tags were not included in webhooks.
|
||||
@@ -92,6 +92,7 @@ Document: openapi.yaml stats:
|
||||
👉 Parameters: 0
|
||||
🔗 Links: 0
|
||||
🔀 Path Items: 2
|
||||
🎣 Webhooks: 0
|
||||
👷 Operations: 2
|
||||
🔖 Tags: 0
|
||||
|
||||
|
||||
@@ -26,6 +26,10 @@ exports[`E2E stats stats should produce correct JSON output 1`] = `
|
||||
"metric": "🔀 Path Items",
|
||||
"total": 5
|
||||
},
|
||||
"webhooks": {
|
||||
"metric": "🎣 Webhooks",
|
||||
"total": 0
|
||||
},
|
||||
"operations": {
|
||||
"metric": "👷 Operations",
|
||||
"total": 8
|
||||
|
||||
@@ -9,6 +9,7 @@ exports[`E2E stats stats should produce correct Markdown format 1`] = `
|
||||
| 👉 Parameters | 6 |
|
||||
| 🔗 Links | 0 |
|
||||
| 🔀 Path Items | 5 |
|
||||
| 🎣 Webhooks | 0 |
|
||||
| 👷 Operations | 8 |
|
||||
| 🔖 Tags | 3 |
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ Document: museum.yaml stats:
|
||||
👉 Parameters: 6
|
||||
🔗 Links: 0
|
||||
🔀 Path Items: 5
|
||||
🎣 Webhooks: 0
|
||||
👷 Operations: 8
|
||||
🔖 Tags: 3
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ const statsAccumulator: StatsAccumulator = {
|
||||
parameters: { metric: '👉 Parameters', total: 0, color: 'yellow', items: new Set() },
|
||||
links: { metric: '🔗 Links', total: 0, color: 'cyan', items: new Set() },
|
||||
pathItems: { metric: '🔀 Path Items', total: 0, color: 'green' },
|
||||
webhooks: { metric: '🎣 Webhooks', total: 0, color: 'green' },
|
||||
operations: { metric: '👷 Operations', total: 0, color: 'yellow' },
|
||||
tags: { metric: '🔖 Tags', total: 0, color: 'white', items: new Set() },
|
||||
};
|
||||
|
||||
@@ -35,9 +35,11 @@ export const Stats = (statsAccumulator: StatsAccumulator) => {
|
||||
WebhooksMap: {
|
||||
Operation: {
|
||||
leave(operation: any) {
|
||||
operation.tags.forEach((tag: string) => {
|
||||
statsAccumulator.tags.items!.add(tag);
|
||||
});
|
||||
statsAccumulator.webhooks.total++;
|
||||
operation.tags &&
|
||||
operation.tags.forEach((tag: string) => {
|
||||
statsAccumulator.tags.items!.add(tag);
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -13,5 +13,6 @@ export type StatsName =
|
||||
| 'pathItems'
|
||||
| 'links'
|
||||
| 'schemas'
|
||||
| 'webhooks'
|
||||
| 'parameters';
|
||||
export type StatsAccumulator = Record<StatsName, StatsRow>;
|
||||
|
||||
Reference in New Issue
Block a user