File tree Expand file tree Collapse file tree 3 files changed +25
-6
lines changed
Expand file tree Collapse file tree 3 files changed +25
-6
lines changed Original file line number Diff line number Diff line change 11using Inventory_Backend_NET . Startup ;
2+ using Inventory_Backend_NET . Startup . Constant ;
23using Inventory_Backend_NET . TestOnlyEndpoint ;
34
45namespace Inventory_Backend_NET ;
@@ -20,12 +21,13 @@ public static void Main(string[] args)
2021
2122
2223 var app = builder . Build ( ) ;
23- app . MigrateDatabases ( ) ;
24+ if ( ! app . Environment . IsEnvironment ( Env . ApiSpecGen ) )
25+ app . MigrateDatabases ( ) ;
2426
2527 var containsSeederKeyword = app . HandleSeedingCommandFromCli ( args : args ) ;
2628 if ( containsSeederKeyword ) return ;
2729
28- if ( app . Environment . IsEnvironment ( " Local" ) || app . Environment . IsEnvironment ( " E2E" ) )
30+ if ( app . Environment . IsEnvironment ( Env . Local ) || app . Environment . IsEnvironment ( Env . E2E ) )
2931 {
3032 app . UseSwaggerUI ( ) ;
3133 }
Original file line number Diff line number Diff line change 1+ namespace Inventory_Backend_NET . Startup . Constant ;
2+
3+ internal static class Env
4+ {
5+ internal const string Local = "Local" ;
6+
7+ internal const string E2E = "E2E" ;
8+
9+ /// <summary>
10+ /// Ignore DB Connection when generating OpenAPI Spec
11+ /// </summary>
12+ internal const string ApiSpecGen = "OpenAPI-Spec-Gen" ;
13+ }
Original file line number Diff line number Diff line change 44using Inventory_Backend_NET . Fitur . Barang . _Dependency ;
55using Inventory_Backend_NET . Fitur . Logging ;
66using Inventory_Backend_NET . Fitur . Pengajuan . _Dependency ;
7+ using Inventory_Backend_NET . Startup . Constant ;
78using Inventory_Backend_NET . Startup . Service ;
89using Microsoft . AspNetCore . Authorization ;
910using Microsoft . AspNetCore . Mvc . Authorization ;
@@ -42,11 +43,14 @@ public static WebApplicationBuilder PrepareDependencyInjectionServices(this WebA
4243 options . Filters . Add ( new AuthorizeFilter ( policy ) ) ; // 👈 Global AuthGuard
4344 } ) ;
4445
45- string connectionString = builder
46- . Configuration
47- . GetConnectionString ( MyConstants . AppSettingsKey . InventoryDbConnectionString ) ! ;
46+ if ( ! builder . Environment . IsEnvironment ( Env . ApiSpecGen ) )
47+ {
48+ string connectionString = builder
49+ . Configuration
50+ . GetConnectionString ( MyConstants . AppSettingsKey . InventoryDbConnectionString ) ! ;
4851
49- builder . Services . PrepareMyDbContextWithInterceptor ( connectionString ) ;
52+ builder . Services . PrepareMyDbContextWithInterceptor ( connectionString ) ;
53+ }
5054
5155 return builder ;
5256 }
You can’t perform that action at this time.
0 commit comments