3
3
using System . Linq ;
4
4
using System . Net ;
5
5
using Atc . Rest . ApiGenerator . Models ;
6
+ using Microsoft . CodeAnalysis . CSharp ;
7
+ using Microsoft . CodeAnalysis . CSharp . Syntax ;
6
8
using Microsoft . OpenApi . Models ;
7
9
8
10
namespace Atc . Rest . ApiGenerator . Factories
9
11
{
10
12
public static class ProjectApiFactory
11
13
{
12
- public static string [ ] CreateUsingListForEndpoint (
14
+ public static UsingDirectiveSyntax [ ] CreateProjectUsingListForEndpoint (
13
15
ApiProjectOptions apiProjectOptions ,
14
16
string focusOnSegmentName ,
17
+ bool hasSharedResponseContract )
18
+ {
19
+ var result = new List < UsingDirectiveSyntax > ( ) ;
20
+
21
+ if ( hasSharedResponseContract )
22
+ {
23
+ result . Add ( SyntaxFactory . UsingDirective ( SyntaxFactory . ParseName ( $ "{ apiProjectOptions . ProjectName } .{ NameConstants . Contracts } ") ) ) ;
24
+ }
25
+
26
+ result . Add ( SyntaxFactory . UsingDirective ( SyntaxFactory . ParseName ( $ "{ apiProjectOptions . ProjectName } .{ NameConstants . Contracts } .{ focusOnSegmentName . EnsureFirstCharacterToUpper ( ) } ") ) ) ;
27
+
28
+ return result . ToArray ( ) ;
29
+ }
30
+
31
+ public static string [ ] CreateGeneralUsingListForEndpoint (
32
+ ApiProjectOptions apiProjectOptions ,
15
33
List < OpenApiOperation > apiOperations ,
16
- bool includeRestResults ,
17
- bool hasSharedModel )
34
+ bool includeRestResults )
18
35
{
19
36
if ( apiOperations == null )
20
37
{
@@ -34,13 +51,6 @@ public static string[] CreateUsingListForEndpoint(
34
51
list . Add ( "Atc.Rest.Results" ) ;
35
52
}
36
53
37
- if ( hasSharedModel )
38
- {
39
- list . Add ( $ "{ apiProjectOptions . ProjectName } .{ NameConstants . Contracts } ") ;
40
- }
41
-
42
- list . Add ( $ "{ apiProjectOptions . ProjectName } .{ NameConstants . Contracts } .{ focusOnSegmentName . EnsureFirstCharacterToUpper ( ) } ") ;
43
-
44
54
list . Add ( "Microsoft.AspNetCore.Http" ) ;
45
55
list . Add ( "Microsoft.AspNetCore.Mvc" ) ;
46
56
0 commit comments