@@ -124,7 +124,42 @@ public static IServiceCollection AddSimApi(this IServiceCollection builder,
124124 } ) ;
125125 }
126126
127- x . CustomSchemaIds ( type => type . FullName ? . Replace ( "+" , "." ) ) ;
127+ x . CustomSchemaIds ( type =>
128+ {
129+ string GetSimpleTypeName ( Type t )
130+ {
131+ if ( t . IsArray )
132+ {
133+ var elementType = t . GetElementType ( ) ;
134+ return $ "{ GetSimpleTypeName ( elementType ) } []";
135+ }
136+
137+ if ( t . IsPrimitive || t == typeof ( string ) || t == typeof ( DateTime ) || t == typeof ( Guid ) )
138+ {
139+ return t . Name switch
140+ {
141+ "String" => "string" ,
142+ "Int32" => "int" ,
143+ "Int64" => "long" ,
144+ "Boolean" => "boolean" ,
145+ "DateTime" => "DateTime" ,
146+ "Guid" => "Guid" ,
147+ _ => t . Name
148+ } ;
149+ }
150+
151+ return t . Name ;
152+ }
153+
154+ if ( ! type . IsGenericType ) return GetSimpleTypeName ( type ) ;
155+ var baseName = type . GetGenericTypeDefinition ( ) . Name . Split ( '`' ) [ 0 ] ;
156+ var genericArgs = type . GetGenericArguments ( )
157+ . Select ( GetSimpleTypeName )
158+ . ToArray ( ) ;
159+ return genericArgs . Length > 0
160+ ? $ "{ baseName } <{ string . Join ( "," , genericArgs ) } >"
161+ : baseName ;
162+ } ) ;
128163 x . OperationFilter < SimApiResponseOperationFilter > ( ) ;
129164 x . OperationFilter < SimApiSignOperationFilter > ( ) ;
130165 x . OperationFilter < AesBodyOperationFilter > ( ) ;
@@ -159,19 +194,13 @@ public static IServiceCollection AddSimApi(this IServiceCollection builder,
159194 switch ( auth )
160195 {
161196 case "SimApiAuth" :
162- x . AddSecurityDefinition ( "HeaderToken " ,
197+ x . AddSecurityDefinition ( "SimApiAuth " ,
163198 new OpenApiSecurityScheme
164199 {
165200 Name = "Token" ,
166201 In = ParameterLocation . Header ,
167202 Type = SecuritySchemeType . ApiKey
168203 } ) ;
169- x . AddSecurityRequirement ( docs => new OpenApiSecurityRequirement
170- {
171- {
172- new OpenApiSecuritySchemeReference ( "HeaderToken" ) , new List < string > ( )
173- }
174- } ) ;
175204 break ;
176205 case "ClientCredentials" :
177206 oauthFlows . ClientCredentials = new OpenApiOAuthFlow
@@ -220,12 +249,6 @@ public static IServiceCollection AddSimApi(this IServiceCollection builder,
220249 Description = docOptions . ApiAuth . Description ,
221250 In = ParameterLocation . Header
222251 } ) ;
223- x . AddSecurityRequirement ( docs => new OpenApiSecurityRequirement
224- {
225- {
226- new OpenApiSecuritySchemeReference ( "oauth2" ) , new List < string > ( )
227- }
228- } ) ;
229252 }
230253 } ) ;
231254 }
0 commit comments