@@ -128,7 +128,9 @@ public void GenerateParameters()
128
128
{
129
129
var apiGroupName = openApiPath . GetApiGroupName ( ) ;
130
130
131
- var fullNamespace = NamespaceFactory . CreateFull ( settings . ProjectName , settings . ContractsLocation , apiGroupName ) ;
131
+ var contractsLocation = LocationFactory . CreateWithApiGroupName ( apiGroupName , settings . ContractsLocation ) ;
132
+
133
+ var fullNamespace = NamespaceFactory . Create ( settings . ProjectName , contractsLocation ) ;
132
134
133
135
foreach ( var openApiOperation in openApiPath . Value . Operations )
134
136
{
@@ -159,7 +161,7 @@ public void GenerateParameters()
159
161
var contentWriter = new ContentWriter ( logger ) ;
160
162
contentWriter . Write (
161
163
settings . ProjectPath ,
162
- FileInfoFactory . Create ( settings . ProjectPath , settings . ContractsLocation , apiGroupName , ContentGeneratorConstants . RequestParameters , $ "{ parameterParameters . ParameterName } .cs") ,
164
+ FileInfoFactory . Create ( settings . ProjectPath , contractsLocation , ContentGeneratorConstants . RequestParameters , $ "{ parameterParameters . ParameterName } .cs") ,
163
165
ContentWriterArea . Src ,
164
166
content ) ;
165
167
}
@@ -172,7 +174,9 @@ public void GenerateEndpointInterfaces()
172
174
{
173
175
var apiGroupName = openApiPath . GetApiGroupName ( ) ;
174
176
175
- var fullNamespace = NamespaceFactory . CreateFull ( settings . ProjectName , settings . EndpointsLocation , apiGroupName , ContentGeneratorConstants . Interfaces ) ;
177
+ var endpointsLocation = LocationFactory . CreateWithApiGroupName ( apiGroupName , settings . EndpointsLocation ) ;
178
+
179
+ var fullNamespace = NamespaceFactory . Create ( settings . ProjectName , endpointsLocation ) + $ ".{ ContentGeneratorConstants . Interfaces } ";
176
180
177
181
foreach ( var openApiOperation in openApiPath . Value . Operations )
178
182
{
@@ -199,7 +203,7 @@ public void GenerateEndpointInterfaces()
199
203
var contentWriter = new ContentWriter ( logger ) ;
200
204
contentWriter . Write (
201
205
settings . ProjectPath ,
202
- FileInfoFactory . Create ( settings . ProjectPath , settings . EndpointsLocation , apiGroupName , ContentGeneratorConstants . Interfaces , $ "{ interfaceParameters . TypeName } .cs") ,
206
+ FileInfoFactory . Create ( settings . ProjectPath , endpointsLocation , ContentGeneratorConstants . Interfaces , $ "{ interfaceParameters . TypeName } .cs") ,
203
207
ContentWriterArea . Src ,
204
208
content ) ;
205
209
}
@@ -212,7 +216,10 @@ public void GenerateEndpoints()
212
216
{
213
217
var apiGroupName = openApiPath . GetApiGroupName ( ) ;
214
218
215
- var fullNamespace = NamespaceFactory . CreateFull ( settings . ProjectName , settings . EndpointsLocation , apiGroupName ) ;
219
+ var endpointsLocation = LocationFactory . CreateWithApiGroupName ( apiGroupName , settings . EndpointsLocation ) ;
220
+ var contractsLocation = LocationFactory . CreateWithApiGroupName ( apiGroupName , settings . ContractsLocation ) ;
221
+
222
+ var fullNamespace = NamespaceFactory . Create ( settings . ProjectName , endpointsLocation ) ;
216
223
217
224
foreach ( var openApiOperation in openApiPath . Value . Operations )
218
225
{
@@ -225,7 +232,7 @@ public void GenerateEndpoints()
225
232
settings . ProjectName ,
226
233
apiGroupName ,
227
234
fullNamespace ,
228
- settings . ContractsLocation ,
235
+ contractsLocation ,
229
236
openApiPath . Value ,
230
237
openApiOperation . Key ,
231
238
openApiOperation . Value ,
@@ -246,7 +253,7 @@ public void GenerateEndpoints()
246
253
var contentWriter = new ContentWriter ( logger ) ;
247
254
contentWriter . Write (
248
255
settings . ProjectPath ,
249
- FileInfoFactory . Create ( settings . ProjectPath , settings . EndpointsLocation , apiGroupName , $ "{ endpointParameters . EndpointName } .cs") ,
256
+ FileInfoFactory . Create ( settings . ProjectPath , endpointsLocation , $ "{ endpointParameters . EndpointName } .cs") ,
250
257
ContentWriterArea . Src ,
251
258
content ) ;
252
259
}
@@ -259,7 +266,10 @@ public void GenerateEndpointResultInterfaces()
259
266
{
260
267
var apiGroupName = openApiPath . GetApiGroupName ( ) ;
261
268
262
- var fullNamespace = NamespaceFactory . CreateFull ( settings . ProjectName , settings . EndpointsLocation , apiGroupName , ContentGeneratorConstants . Interfaces ) ;
269
+ var endpointsLocation = LocationFactory . CreateWithApiGroupName ( apiGroupName , settings . EndpointsLocation ) ;
270
+ var contractsLocation = LocationFactory . CreateWithApiGroupName ( apiGroupName , settings . ContractsLocation ) ;
271
+
272
+ var fullNamespace = NamespaceFactory . Create ( settings . ProjectName , endpointsLocation ) + $ ".{ ContentGeneratorConstants . Interfaces } ";
263
273
264
274
foreach ( var openApiOperation in openApiPath . Value . Operations )
265
275
{
@@ -272,7 +282,7 @@ public void GenerateEndpointResultInterfaces()
272
282
settings . ProjectName ,
273
283
apiGroupName ,
274
284
fullNamespace ,
275
- settings . ContractsLocation ,
285
+ contractsLocation ,
276
286
openApiPath . Value ,
277
287
openApiOperation . Value ,
278
288
settings . UsePartialClassForContracts ) ;
@@ -289,7 +299,7 @@ public void GenerateEndpointResultInterfaces()
289
299
var contentWriter = new ContentWriter ( logger ) ;
290
300
contentWriter . Write (
291
301
settings . ProjectPath ,
292
- FileInfoFactory . Create ( settings . ProjectPath , settings . EndpointsLocation , apiGroupName , ContentGeneratorConstants . Interfaces , $ "{ endpointResultInterfaceParameters . InterfaceName } .cs") ,
302
+ FileInfoFactory . Create ( settings . ProjectPath , endpointsLocation , ContentGeneratorConstants . Interfaces , $ "{ endpointResultInterfaceParameters . InterfaceName } .cs") ,
293
303
ContentWriterArea . Src ,
294
304
content ) ;
295
305
}
@@ -302,7 +312,10 @@ public void GenerateEndpointResults()
302
312
{
303
313
var apiGroupName = openApiPath . GetApiGroupName ( ) ;
304
314
305
- var fullNamespace = NamespaceFactory . CreateFull ( settings . ProjectName , settings . EndpointsLocation , apiGroupName ) ;
315
+ var endpointsLocation = LocationFactory . CreateWithApiGroupName ( apiGroupName , settings . EndpointsLocation ) ;
316
+ var contractsLocation = LocationFactory . CreateWithApiGroupName ( apiGroupName , settings . ContractsLocation ) ;
317
+
318
+ var fullNamespace = NamespaceFactory . Create ( settings . ProjectName , endpointsLocation ) ;
306
319
307
320
foreach ( var openApiOperation in openApiPath . Value . Operations )
308
321
{
@@ -315,7 +328,7 @@ public void GenerateEndpointResults()
315
328
settings . ProjectName ,
316
329
apiGroupName ,
317
330
fullNamespace ,
318
- settings . ContractsLocation ,
331
+ contractsLocation ,
319
332
openApiPath . Value ,
320
333
openApiOperation . Value ,
321
334
settings . UsePartialClassForContracts ) ;
@@ -332,7 +345,7 @@ public void GenerateEndpointResults()
332
345
var contentWriter = new ContentWriter ( logger ) ;
333
346
contentWriter . Write (
334
347
settings . ProjectPath ,
335
- FileInfoFactory . Create ( settings . ProjectPath , settings . EndpointsLocation , apiGroupName , $ "{ endpointResultParameters . EndpointResultName } .cs") ,
348
+ FileInfoFactory . Create ( settings . ProjectPath , endpointsLocation , $ "{ endpointResultParameters . EndpointResultName } .cs") ,
336
349
ContentWriterArea . Src ,
337
350
content ) ;
338
351
}
@@ -384,13 +397,16 @@ public void MaintainGlobalUsings(
384
397
385
398
if ( operationSchemaMappings . Any ( apiOperation => apiOperation . Model . IsShared ) )
386
399
{
387
- requiredUsings . Add ( NamespaceFactory . CreateFull ( settings . ProjectName , settings . ContractsLocation ) ) ;
400
+ requiredUsings . Add ( NamespaceFactory . Create ( settings . ProjectName , LocationFactory . CreateWithoutTemplateForApiGroupName ( settings . ContractsLocation ) ) ) ;
388
401
}
389
402
390
403
var apiGroupNames = openApiDocument . GetApiGroupNames ( ) ;
391
404
foreach ( var openApiPath in openApiDocument . Paths )
392
405
{
393
406
var apiGroupName = openApiPath . GetApiGroupName ( ) ;
407
+
408
+ var contractsLocation = LocationFactory . CreateWithApiGroupName ( apiGroupName , settings . ContractsLocation ) ;
409
+
394
410
foreach ( var openApiOperation in openApiPath . Value . Operations )
395
411
{
396
412
if ( openApiOperation . Value . Deprecated && ! settings . IncludeDeprecatedOperations )
@@ -404,7 +420,7 @@ public void MaintainGlobalUsings(
404
420
continue ;
405
421
}
406
422
407
- var requiredUsing = NamespaceFactory . CreateFull ( settings . ProjectName , settings . ContractsLocation , apiGroupName ) ;
423
+ var requiredUsing = LocationFactory . Create ( settings . ProjectName , contractsLocation ) ;
408
424
if ( ! requiredUsings . Contains ( requiredUsing , StringComparer . CurrentCulture ) )
409
425
{
410
426
requiredUsings . Add ( requiredUsing ) ;
@@ -420,6 +436,8 @@ public void MaintainGlobalUsings(
420
436
421
437
var apiOperationModels = GetDistinctApiOperationModels ( apiOperations ) ;
422
438
439
+ var contractsLocation = LocationFactory . CreateWithApiGroupName ( apiGroupName , settings . ContractsLocation ) ;
440
+
423
441
foreach ( var apiOperationModel in apiOperationModels )
424
442
{
425
443
if ( apiOperationModel . IsEnum ||
@@ -433,15 +451,15 @@ public void MaintainGlobalUsings(
433
451
continue ;
434
452
}
435
453
436
- var requiredUsing = NamespaceFactory . CreateFull ( settings . ProjectName , settings . ContractsLocation , apiGroupName ) ;
454
+ var requiredUsing = LocationFactory . Create ( settings . ProjectName , contractsLocation ) ;
437
455
if ( ! requiredUsings . Contains ( requiredUsing , StringComparer . CurrentCulture ) )
438
456
{
439
457
requiredUsings . Add ( requiredUsing ) ;
440
458
}
441
459
}
442
460
}
443
461
444
- requiredUsings . AddRange ( apiGroupNames . Select ( x => NamespaceFactory . CreateFull ( settings . ProjectName , settings . EndpointsLocation , x , ContentGeneratorConstants . Interfaces ) ) ) ;
462
+ requiredUsings . AddRange ( apiGroupNames . Select ( x => LocationFactory . Create ( settings . ProjectName , LocationFactory . CreateWithApiGroupName ( x , settings . EndpointsLocation ) , ContentGeneratorConstants . Interfaces ) ) ) ;
445
463
446
464
GlobalUsingsHelper . CreateOrUpdate (
447
465
logger ,
@@ -455,7 +473,9 @@ private void GenerateEnumerationType(
455
473
string enumerationName ,
456
474
OpenApiSchema openApiSchemaEnumeration )
457
475
{
458
- var fullNamespace = NamespaceFactory . CreateFull ( settings . ProjectName , settings . ContractsLocation ) ;
476
+ var contractsLocation = LocationFactory . CreateWithoutTemplateForApiGroupName ( settings . ContractsLocation ) ;
477
+
478
+ var fullNamespace = NamespaceFactory . Create ( settings . ProjectName , contractsLocation ) ;
459
479
460
480
var enumParameters = ContentGeneratorServerClientEnumParametersFactory . Create (
461
481
codeGeneratorContentHeader ,
@@ -473,7 +493,7 @@ private void GenerateEnumerationType(
473
493
var contentWriter = new ContentWriter ( logger ) ;
474
494
contentWriter . Write (
475
495
settings . ProjectPath ,
476
- FileInfoFactory . Create ( settings . ProjectPath , settings . ContractsLocation , ContentGeneratorConstants . SpecialFolderEnumerationTypes , $ "{ enumerationName } .cs") ,
496
+ FileInfoFactory . Create ( settings . ProjectPath , contractsLocation , ContentGeneratorConstants . SpecialFolderEnumerationTypes , $ "{ enumerationName } .cs") ,
477
497
ContentWriterArea . Src ,
478
498
content ) ;
479
499
}
@@ -484,9 +504,11 @@ private void GenerateModel(
484
504
string apiGroupName ,
485
505
bool isSharedContract )
486
506
{
487
- var fullNamespace = isSharedContract
488
- ? NamespaceFactory . CreateFull ( settings . ProjectName , settings . ContractsLocation )
489
- : NamespaceFactory . CreateFull ( settings . ProjectName , settings . ContractsLocation , apiGroupName ) ;
507
+ var contractsLocation = isSharedContract
508
+ ? LocationFactory . CreateWithoutTemplateForApiGroupName ( settings . ContractsLocation )
509
+ : LocationFactory . CreateWithApiGroupName ( apiGroupName , settings . ContractsLocation ) ;
510
+
511
+ var fullNamespace = NamespaceFactory . Create ( settings . ProjectName , contractsLocation ) ;
490
512
491
513
var parameters = ContentGeneratorServerClientModelParametersFactory . CreateForClass (
492
514
codeGeneratorContentHeader ,
@@ -507,8 +529,8 @@ private void GenerateModel(
507
529
contentWriter . Write (
508
530
settings . ProjectPath ,
509
531
isSharedContract
510
- ? FileInfoFactory . Create ( settings . ProjectPath , settings . ContractsLocation , ContentGeneratorConstants . SpecialFolderSharedModels , $ "{ modelName } .cs")
511
- : FileInfoFactory . Create ( settings . ProjectPath , settings . ContractsLocation , apiGroupName , $ "{ modelName } .cs") ,
532
+ ? FileInfoFactory . Create ( settings . ProjectPath , contractsLocation , ContentGeneratorConstants . SpecialFolderSharedModels , $ "{ modelName } .cs")
533
+ : FileInfoFactory . Create ( settings . ProjectPath , contractsLocation , $ "{ modelName } .cs") ,
512
534
ContentWriterArea . Src ,
513
535
content ) ;
514
536
}
@@ -521,7 +543,9 @@ private void GenerateCustomErrorResponseModel()
521
543
return ;
522
544
}
523
545
524
- var fullNamespace = NamespaceFactory . CreateFull ( settings . ProjectName , settings . ContractsLocation ) ;
546
+ var contractsLocation = LocationFactory . CreateWithoutTemplateForApiGroupName ( settings . ContractsLocation ) ;
547
+
548
+ var fullNamespace = NamespaceFactory . Create ( settings . ProjectName , contractsLocation ) ;
525
549
526
550
var parameters = ContentGeneratorServerClientModelParametersFactory . CreateForCustomErrorResponseModel (
527
551
codeGeneratorContentHeader ,
@@ -539,7 +563,7 @@ private void GenerateCustomErrorResponseModel()
539
563
var contentWriter = new ContentWriter ( logger ) ;
540
564
contentWriter . Write (
541
565
settings . ProjectPath ,
542
- FileInfoFactory . Create ( settings . ProjectPath , settings . ContractsLocation , ContentGeneratorConstants . SpecialFolderSharedModels , $ "{ customErrorResponseModel . Name . EnsureFirstCharacterToUpper ( ) } .cs") ,
566
+ FileInfoFactory . Create ( settings . ProjectPath , contractsLocation , ContentGeneratorConstants . SpecialFolderSharedModels , $ "{ customErrorResponseModel . Name . EnsureFirstCharacterToUpper ( ) } .cs") ,
543
567
ContentWriterArea . Src ,
544
568
content ) ;
545
569
}
0 commit comments