-
Notifications
You must be signed in to change notification settings - Fork 251
/
Copy pathStatsVisitor.cs
89 lines (69 loc) · 2.39 KB
/
StatsVisitor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System;
using System.Collections.Generic;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.Interfaces;
using Microsoft.OpenApi.Services;
namespace Microsoft.OpenApi.Workbench
{
internal class StatsVisitor : OpenApiVisitorBase
{
public int ParameterCount { get; set; }
public override void Visit(IOpenApiParameter parameter)
{
ParameterCount++;
}
public int SchemaCount { get; set; }
public override void Visit(OpenApiSchema schema)
{
SchemaCount++;
}
public int HeaderCount { get; set; }
public override void Visit(IDictionary<string, IOpenApiHeader> headers)
{
HeaderCount++;
}
public int PathItemCount { get; set; }
public override void Visit(IOpenApiPathItem pathItem)
{
PathItemCount++;
}
public int RequestBodyCount { get; set; }
public override void Visit(OpenApiRequestBody requestBody)
{
RequestBodyCount++;
}
public int ResponseCount { get; set; }
public override void Visit(OpenApiResponses response)
{
ResponseCount++;
}
public int OperationCount { get; set; }
public override void Visit(OpenApiOperation operation)
{
OperationCount++;
}
public int LinkCount { get; set; }
public override void Visit(IOpenApiLink link)
{
LinkCount++;
}
public int CallbackCount { get; set; }
public override void Visit(IOpenApiCallback callback)
{
CallbackCount++;
}
public string GetStatisticsReport()
{
return $"Path Items: {PathItemCount}" + Environment.NewLine
+ $"Operations: {OperationCount}" + Environment.NewLine
+ $"Parameters: {ParameterCount}" + Environment.NewLine
+ $"Request Bodies: {RequestBodyCount}" + Environment.NewLine
+ $"Responses: {ResponseCount}" + Environment.NewLine
+ $"Links: {LinkCount}" + Environment.NewLine
+ $"Callbacks: {CallbackCount}" + Environment.NewLine
+ $"Schemas: {SchemaCount}" + Environment.NewLine;
}
}
}