mirror of
https://github.com/LukeHagar/redocly-cli.git
synced 2025-12-10 04:21:20 +00:00
fix: count operation tags in stats command vs only global (#219)
* fix: extend tags count logic * chore: moved total calculation to DefinitionRoot
This commit is contained in:
@@ -21,7 +21,7 @@ const statsAccumulator: StatsAccumulator = {
|
|||||||
links: { metric: '🔗 Links', total: 0, color: 'cyan', items: new Set() },
|
links: { metric: '🔗 Links', total: 0, color: 'cyan', items: new Set() },
|
||||||
pathItems: { metric: '➡️ Path Items', total: 0, color: 'green' },
|
pathItems: { metric: '➡️ Path Items', total: 0, color: 'green' },
|
||||||
operations: { metric: '👷 Operations', total: 0, color: 'yellow' },
|
operations: { metric: '👷 Operations', total: 0, color: 'yellow' },
|
||||||
tags: { metric: '🔖 Tags', total: 0, color: 'white' },
|
tags: { metric: '🔖 Tags', total: 0, color: 'white', items: new Set() },
|
||||||
}
|
}
|
||||||
|
|
||||||
function printStatsStylish(statsAccumulator: StatsAccumulator) {
|
function printStatsStylish(statsAccumulator: StatsAccumulator) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Oas3Parameter, OasRef } from '../../typings/openapi';
|
import { Oas3Parameter, OasRef, Oas3Tag } from '../../typings/openapi';
|
||||||
import { Oas2Parameter } from '../../typings/swagger';
|
import { Oas2Parameter } from '../../typings/swagger';
|
||||||
import { StatsAccumulator } from '../../typings/common';
|
import { StatsAccumulator } from '../../typings/common';
|
||||||
|
|
||||||
@@ -6,21 +6,36 @@ export const Stats = (statsAccumulator: StatsAccumulator) => {
|
|||||||
return {
|
return {
|
||||||
ExternalDocs: { leave() { statsAccumulator.externalDocs.total++; }},
|
ExternalDocs: { leave() { statsAccumulator.externalDocs.total++; }},
|
||||||
ref: { enter(ref: OasRef) { statsAccumulator.refs.items!.add(ref['$ref']); }},
|
ref: { enter(ref: OasRef) { statsAccumulator.refs.items!.add(ref['$ref']); }},
|
||||||
Tag: { enter() { statsAccumulator.tags.total++; }},
|
Tag: { leave(tag: Oas3Tag) { statsAccumulator.tags.items!.add(tag.name); }},
|
||||||
Link: { leave(link: any) { statsAccumulator.links.items!.add(link.operationId); }},
|
Link: { leave(link: any) { statsAccumulator.links.items!.add(link.operationId); }},
|
||||||
PathMap: {
|
DefinitionRoot: {
|
||||||
leave() {
|
leave() {
|
||||||
statsAccumulator.parameters.total = statsAccumulator.parameters.items!.size;
|
statsAccumulator.parameters.total = statsAccumulator.parameters.items!.size;
|
||||||
statsAccumulator.refs.total = statsAccumulator.refs.items!.size;
|
statsAccumulator.refs.total = statsAccumulator.refs.items!.size;
|
||||||
statsAccumulator.links.total = statsAccumulator.links.items!.size;
|
statsAccumulator.links.total = statsAccumulator.links.items!.size;
|
||||||
|
statsAccumulator.tags.total = statsAccumulator.tags.items!.size;
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
WebhooksMap: {
|
||||||
|
Operation: {
|
||||||
|
leave(operation: any) {
|
||||||
|
operation.tags.forEach((tag: string) => { statsAccumulator.tags.items!.add(tag); })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
PathMap: {
|
||||||
PathItem: {
|
PathItem: {
|
||||||
leave() { statsAccumulator.pathItems.total++; },
|
leave() { statsAccumulator.pathItems.total++; },
|
||||||
Operation: { leave() { statsAccumulator.operations.total++; }},
|
Operation: {
|
||||||
|
leave(operation: any) {
|
||||||
|
statsAccumulator.operations.total++;
|
||||||
|
operation.tags.forEach((tag: string) => { statsAccumulator.tags.items!.add(tag); })
|
||||||
|
}
|
||||||
|
},
|
||||||
Parameter: { leave(parameter: Oas2Parameter | Oas3Parameter) {
|
Parameter: { leave(parameter: Oas2Parameter | Oas3Parameter) {
|
||||||
statsAccumulator.parameters.items!.add(parameter.name)
|
statsAccumulator.parameters.items!.add(parameter.name)
|
||||||
}}
|
}},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
NamedSchemas: {
|
NamedSchemas: {
|
||||||
Schema: { leave() { statsAccumulator.schemas.total++; }}
|
Schema: { leave() { statsAccumulator.schemas.total++; }}
|
||||||
|
|||||||
Reference in New Issue
Block a user