@@ -11,10 +11,10 @@ public class ClassNameHelper : INustacheHelper
11
11
{
12
12
private readonly Dictionary < string , string > classNameMap ;
13
13
private readonly HashSet < string > schemaDefinitionsInMultipleGroups ;
14
- private readonly Dictionary < JsonSchema4 , string > schemaToNameMapCooked ;
15
- private readonly Dictionary < JsonSchema4 , string > schemaToNameMapUnprocessed ;
14
+ private readonly Dictionary < JsonSchema , string > schemaToNameMapCooked ;
15
+ private readonly Dictionary < JsonSchema , string > schemaToNameMapUnprocessed ;
16
16
17
- public ClassNameHelper ( SwaggerDocument swaggerCooked , SwaggerDocument swaggerUnprocessed )
17
+ public ClassNameHelper ( OpenApiDocument swaggerCooked , OpenApiDocument swaggerUnprocessed )
18
18
{
19
19
classNameMap = InitClassNameMap ( swaggerCooked ) ;
20
20
@@ -28,19 +28,19 @@ public void RegisterHelper()
28
28
Helpers . Register ( nameof ( GetClassName ) , GetClassName ) ;
29
29
}
30
30
31
- private static Dictionary < JsonSchema4 , string > GenerateSchemaToNameMapUnprocessed (
32
- SwaggerDocument swaggerUnprocessed )
31
+ private static Dictionary < JsonSchema , string > GenerateSchemaToNameMapUnprocessed (
32
+ OpenApiDocument swaggerUnprocessed )
33
33
{
34
34
return swaggerUnprocessed . Definitions . ToDictionary ( x => x . Value , x => x . Key ) ;
35
35
}
36
36
37
- private static Dictionary < JsonSchema4 , string > GenerateSchemaToNameMapCooked ( SwaggerDocument swaggerCooked )
37
+ private static Dictionary < JsonSchema , string > GenerateSchemaToNameMapCooked ( OpenApiDocument swaggerCooked )
38
38
{
39
39
return swaggerCooked . Definitions . ToDictionary ( x => x . Value , x => x . Key . Replace ( "." , "" ) . ToPascalCase ( ) ) ;
40
40
}
41
41
42
42
private static HashSet < string > InitSchemaDefinitionsInMultipleGroups (
43
- Dictionary < JsonSchema4 , string > schemaToNameMap )
43
+ Dictionary < JsonSchema , string > schemaToNameMap )
44
44
{
45
45
return schemaToNameMap . Values . Select ( x =>
46
46
{
@@ -60,7 +60,7 @@ private static HashSet<string> InitSchemaDefinitionsInMultipleGroups(
60
60
. ToHashSet ( ) ;
61
61
}
62
62
63
- private Dictionary < string , string > InitClassNameMap ( SwaggerDocument doc )
63
+ private Dictionary < string , string > InitClassNameMap ( OpenApiDocument doc )
64
64
{
65
65
var map = new Dictionary < string , string > ( ) ;
66
66
foreach ( var ( k , v ) in doc . Definitions )
@@ -83,17 +83,17 @@ private Dictionary<string, string> InitClassNameMap(SwaggerDocument doc)
83
83
public void GetClassName ( RenderContext context , IList < object > arguments , IDictionary < string , object > options ,
84
84
RenderBlock fn , RenderBlock inverse )
85
85
{
86
- if ( arguments != null && arguments . Count > 0 && arguments [ 0 ] != null && arguments [ 0 ] is SwaggerOperation )
86
+ if ( arguments != null && arguments . Count > 0 && arguments [ 0 ] != null && arguments [ 0 ] is OpenApiOperation )
87
87
{
88
- context . Write ( GetClassName ( arguments [ 0 ] as SwaggerOperation ) ) ;
88
+ context . Write ( GetClassName ( arguments [ 0 ] as OpenApiOperation ) ) ;
89
89
}
90
- else if ( arguments != null && arguments . Count > 0 && arguments [ 0 ] != null && arguments [ 0 ] is JsonSchema4 )
90
+ else if ( arguments != null && arguments . Count > 0 && arguments [ 0 ] != null && arguments [ 0 ] is JsonSchema )
91
91
{
92
- context . Write ( GetClassNameForSchemaDefinition ( arguments [ 0 ] as JsonSchema4 ) ) ;
92
+ context . Write ( GetClassNameForSchemaDefinition ( arguments [ 0 ] as JsonSchema ) ) ;
93
93
}
94
94
}
95
95
96
- public string GetClassName ( SwaggerOperation operation )
96
+ public string GetClassName ( OpenApiOperation operation )
97
97
{
98
98
var groupVersionKind =
99
99
( Dictionary < string , object > ) operation . ExtensionData [ "x-kubernetes-group-version-kind" ] ;
@@ -109,15 +109,15 @@ public string GetClassName(Dictionary<string, object> groupVersionKind)
109
109
return classNameMap [ $ "{ group } _{ kind } _{ version } "] ;
110
110
}
111
111
112
- public string GetClassName ( JsonSchema4 definition )
112
+ public string GetClassName ( JsonSchema definition )
113
113
{
114
114
var groupVersionKindElements = ( object [ ] ) definition . ExtensionData [ "x-kubernetes-group-version-kind" ] ;
115
115
var groupVersionKind = ( Dictionary < string , object > ) groupVersionKindElements [ 0 ] ;
116
116
117
117
return GetClassName ( groupVersionKind ) ;
118
118
}
119
119
120
- public string GetClassNameForSchemaDefinition ( JsonSchema4 definition )
120
+ public string GetClassNameForSchemaDefinition ( JsonSchema definition )
121
121
{
122
122
if ( definition . ExtensionData != null &&
123
123
definition . ExtensionData . ContainsKey ( "x-kubernetes-group-version-kind" ) )
@@ -144,7 +144,7 @@ public string GetClassNameForSchemaDefinition(JsonSchema4 definition)
144
144
return $ "{ group } { version } { entityName } ". ToPascalCase ( ) ;
145
145
}
146
146
147
- private static Dictionary < JsonSchema4 , string > InitSchemaToNameCooked ( SwaggerDocument swaggercooked )
147
+ private static Dictionary < JsonSchema , string > InitSchemaToNameCooked ( OpenApiDocument swaggercooked )
148
148
{
149
149
return swaggercooked . Definitions . ToDictionary ( x => x . Value , x => x . Key . Replace ( "." , "" ) . ToPascalCase ( ) ) ;
150
150
}
0 commit comments