@@ -41,7 +41,7 @@ describe('nx-dotnet e2e', () => {
4141 const testLib = uniq ( 'lib' ) ;
4242
4343 await runNxCommandAsync (
44- `generate @nx-dotnet/core:app ${ testApp } --language="C#" --template="webapi"` ,
44+ `generate @nx-dotnet/core:app ${ testApp } --language="C#" --template="webapi" --skipSwaggerLib ` ,
4545 ) ;
4646
4747 await runNxCommandAsync (
@@ -73,7 +73,7 @@ describe('nx-dotnet e2e', () => {
7373 ) ;
7474
7575 await runNxCommandAsync (
76- `generate @nx-dotnet/core:app ${ testApp } --language="C#" --template="webapi"` ,
76+ `generate @nx-dotnet/core:app ${ testApp } --language="C#" --template="webapi" --skipSwaggerLib ` ,
7777 ) ;
7878
7979 await runNxCommandAsync (
@@ -93,26 +93,29 @@ describe('nx-dotnet e2e', () => {
9393 it ( 'should obey dry-run' , async ( ) => {
9494 const app = uniq ( 'app' ) ;
9595 await runNxCommandAsync (
96- `generate @nx-dotnet/core:app ${ app } --language="C#" --template="webapi" --dry-run` ,
96+ `generate @nx-dotnet/core:app ${ app } --language="C#" --template="webapi" --skipSwaggerLib -- dry-run` ,
9797 ) ;
9898
9999 expect ( ( ) => checkFilesExist ( `apps/${ app } ` ) ) . toThrow ( ) ;
100100 } ) ;
101101
102- it ( 'should generate an app' , async ( ) => {
102+ it ( 'should generate an app without swagger library ' , async ( ) => {
103103 const app = uniq ( 'app' ) ;
104104 await runNxCommandAsync (
105- `generate @nx-dotnet/core:app ${ app } --language="C#" --template="webapi"` ,
105+ `generate @nx-dotnet/core:app ${ app } --language="C#" --template="webapi" --skip-swagger-lib ` ,
106106 ) ;
107107
108108 expect ( ( ) => checkFilesExist ( `apps/${ app } ` ) ) . not . toThrow ( ) ;
109+ expect ( ( ) =>
110+ checkFilesExist ( `libs/generated/${ app } -swaggger/project.json` ) ,
111+ ) . toThrow ( ) ;
109112 } ) ;
110113
111114 it ( 'should build and test an app' , async ( ) => {
112115 const app = uniq ( 'app' ) ;
113116 const testProj = `${ app } -test` ;
114117 await runNxCommandAsync (
115- `generate @nx-dotnet/core:app ${ app } --language="C#" --template="webapi"` ,
118+ `generate @nx-dotnet/core:app ${ app } --language="C#" --template="webapi" --skip-swagger-lib ` ,
116119 ) ;
117120
118121 await runNxCommandAsync ( `build ${ app } ` ) ;
@@ -126,7 +129,7 @@ describe('nx-dotnet e2e', () => {
126129 const app = uniq ( 'app' ) ;
127130 const lib = uniq ( 'lib' ) ;
128131 await runNxCommandAsync (
129- `generate @nx-dotnet/core:app ${ app } --language="C#" --template="webapi"` ,
132+ `generate @nx-dotnet/core:app ${ app } --language="C#" --template="webapi" --skip-swagger-lib ` ,
130133 ) ;
131134 await runNxCommandAsync (
132135 `generate @nx-dotnet/core:lib ${ lib } --language="C#" --template="classlib"` ,
@@ -145,7 +148,7 @@ describe('nx-dotnet e2e', () => {
145148 it ( 'should update output paths' , async ( ) => {
146149 const app = uniq ( 'app' ) ;
147150 await runNxCommandAsync (
148- `generate @nx-dotnet/core:app ${ app } --language="C#" --template="webapi"` ,
151+ `generate @nx-dotnet/core:app ${ app } --language="C#" --template="webapi" --skip-swagger-lib ` ,
149152 ) ;
150153 const configFilePath = findProjectFileInPathSync (
151154 join ( e2eDir , 'apps' , app ) ,
@@ -161,9 +164,10 @@ describe('nx-dotnet e2e', () => {
161164 it ( 'should lint' , async ( ) => {
162165 const app = uniq ( 'app' ) ;
163166 await runNxCommandAsync (
164- `generate @nx-dotnet/core:app ${ app } --language="C#" --template="webapi" ` ,
167+ `generate @nx-dotnet/core:app ${ app } --template webapi -- language="C#" --skip-swagger-lib ` ,
165168 ) ;
166- const promise = runNxCommandAsync ( `lint ${ app } ` ) . then ( ( x ) => x . stderr ) ;
169+ console . log ( 'LINT TEST PROJECT GENERATED' , app ) ;
170+ const promise = runNxCommandAsync ( `lint ${ app } ` ) ;
167171 await expect ( promise ) . rejects . toThrow (
168172 expect . objectContaining ( {
169173 message : expect . stringContaining ( 'WHITESPACE' ) ,
@@ -176,7 +180,7 @@ describe('nx-dotnet e2e', () => {
176180 it ( 'should add a reference to the target project' , async ( ) => {
177181 const app = uniq ( 'app' ) ;
178182 await runNxCommandAsync (
179- `generate @nx-dotnet/core:app ${ app } --language="C#" --template="webapi" --test-template="none"` ,
183+ `generate @nx-dotnet/core:app ${ app } --language="C#" --template="webapi" --skip-swagger-lib -- test-template="none"` ,
180184 ) ;
181185 await runNxCommandAsync (
182186 `generate @nx-dotnet/core:test ${ app } --language="C#" --template="nunit"` ,
@@ -200,7 +204,7 @@ describe('nx-dotnet e2e', () => {
200204 it ( 'should create test project using suffix' , async ( ) => {
201205 const app = uniq ( 'app' ) ;
202206 await runNxCommandAsync (
203- `generate @nx-dotnet/core:app ${ app } --language="C#" --template="webapi" --test-template="none"` ,
207+ `generate @nx-dotnet/core:app ${ app } --language="C#" --template="webapi" --skip-swagger-lib -- test-template="none"` ,
204208 ) ;
205209 await runNxCommandAsync (
206210 `generate @nx-dotnet/core:test ${ app } --language="C#" --template="nunit" --suffix="integration-tests"` ,
@@ -222,7 +226,7 @@ describe('nx-dotnet e2e', () => {
222226 it ( 'should obey dry-run' , async ( ) => {
223227 const lib = uniq ( 'lib' ) ;
224228 await runNxCommandAsync (
225- `generate @nx-dotnet/core:lib ${ lib } --language="C#" --template="webapi" --dry-run` ,
229+ `generate @nx-dotnet/core:lib ${ lib } --language="C#" --template="webapi" --skip-swagger-lib -- dry-run` ,
226230 ) ;
227231
228232 expect ( ( ) => checkFilesExist ( `libs/${ lib } ` ) ) . toThrow ( ) ;
@@ -231,7 +235,7 @@ describe('nx-dotnet e2e', () => {
231235 it ( 'should generate an lib' , async ( ) => {
232236 const lib = uniq ( 'lib' ) ;
233237 await runNxCommandAsync (
234- `generate @nx-dotnet/core:lib ${ lib } --language="C#" --template="webapi "` ,
238+ `generate @nx-dotnet/core:lib ${ lib } --language="C#" --template="classlib "` ,
235239 ) ;
236240
237241 expect ( ( ) => checkFilesExist ( `libs/${ lib } ` ) ) . not . toThrow ( ) ;
@@ -284,7 +288,7 @@ describe('nx-dotnet e2e', () => {
284288 it ( "shouldn't create a solution by default if not specified" , async ( ) => {
285289 const app = uniq ( 'app' ) ;
286290 await runNxCommandAsync (
287- `generate @nx-dotnet/core:app ${ app } --language="C#" --template="webapi"` ,
291+ `generate @nx-dotnet/core:app ${ app } --language="C#" --skip-swagger-lib -- template="webapi"` ,
288292 ) ;
289293
290294 expect ( ( ) => checkFilesExist ( `apps/${ app } ` ) ) . not . toThrow ( ) ;
@@ -294,7 +298,7 @@ describe('nx-dotnet e2e', () => {
294298 it ( 'should create a default solution file if specified as true' , async ( ) => {
295299 const app = uniq ( 'app' ) ;
296300 await runNxCommandAsync (
297- `generate @nx-dotnet/core:app ${ app } --language="C#" --template="webapi" --solutionFile` ,
301+ `generate @nx-dotnet/core:app ${ app } --language="C#" --template="webapi" --skip-swagger-lib -- solutionFile` ,
298302 ) ;
299303
300304 expect ( ( ) => checkFilesExist ( `apps/${ app } ` ) ) . not . toThrow ( ) ;
@@ -315,12 +319,12 @@ describe('nx-dotnet e2e', () => {
315319 it ( 'should add successive projects to default solution file' , async ( ) => {
316320 const app1 = uniq ( 'app' ) ;
317321 await runNxCommandAsync (
318- `generate @nx-dotnet/core:app ${ app1 } --language="C#" --template="webapi" --solutionFile` ,
322+ `generate @nx-dotnet/core:app ${ app1 } --language="C#" --skip-swagger-lib -- template="webapi" --solutionFile` ,
319323 ) ;
320324
321325 const app2 = uniq ( 'app2' ) ;
322326 await runNxCommandAsync (
323- `generate @nx-dotnet/core:app ${ app2 } --language="C#" --template="webapi" --solutionFile` ,
327+ `generate @nx-dotnet/core:app ${ app2 } --language="C#" --skip-swagger-lib -- template="webapi" --solutionFile` ,
324328 ) ;
325329
326330 const slnFile = readFile ( 'proj.nx-dotnet.sln' ) ;
@@ -333,7 +337,7 @@ describe('nx-dotnet e2e', () => {
333337 it ( 'should add test project to same solution as app project' , async ( ) => {
334338 const app = uniq ( 'app' ) ;
335339 await runNxCommandAsync (
336- `generate @nx-dotnet/core:app ${ app } --language="C#" --template="webapi" --test-template="xunit" --solutionFile` ,
340+ `generate @nx-dotnet/core:app ${ app } --language="C#" --template="webapi" --skip-swagger-lib -- test-template="xunit" --solutionFile` ,
337341 ) ;
338342
339343 const slnFile = readFile ( 'proj.nx-dotnet.sln' ) ;
@@ -399,7 +403,7 @@ describe('nx-dotnet e2e', () => {
399403 const appProject = uniq ( 'app' ) ;
400404 const testProject = `${ appProject } -test` ;
401405 runNxCommand (
402- `generate @nx-dotnet/core:app ${ appProject } --language="C#" --template="webapi" --test-runner xunit` ,
406+ `generate @nx-dotnet/core:app ${ appProject } --language="C#" --template="webapi" --skip-swagger-lib -- test-runner xunit` ,
403407 ) ;
404408
405409 expect ( ( ) => runNxCommand ( `test ${ testProject } ` ) ) . not . toThrow ( ) ;
@@ -428,7 +432,7 @@ public class UnitTest1
428432 const appProject = uniq ( 'app' ) ;
429433 const testProject = `${ appProject } -test` ;
430434 runNxCommand (
431- `generate @nx-dotnet/core:app ${ appProject } --language="C#" --template="webapi" --test-runner xunit` ,
435+ `generate @nx-dotnet/core:app ${ appProject } --language="C#" --template="webapi" --skip-swagger-lib -- test-runner xunit` ,
432436 ) ;
433437 const p = runCommandUntil (
434438 `test ${ testProject } --watch` ,
@@ -441,6 +445,24 @@ public class UnitTest1
441445 await expect ( p ) . resolves . not . toThrow ( ) ;
442446 } ) ;
443447 } ) ;
448+
449+ describe ( 'swagger integration' , ( ) => {
450+ it ( 'should generate swagger project for webapi' , async ( ) => {
451+ const api = uniq ( 'api' ) ;
452+ await runNxCommandAsync (
453+ `generate @nx-dotnet/core:app ${ api } --language="C#" --template="webapi"` ,
454+ ) ;
455+
456+ expect ( ( ) => checkFilesExist ( `apps/${ api } ` ) ) . not . toThrow ( ) ;
457+ expect ( ( ) =>
458+ checkFilesExist ( `libs/generated/${ api } -swagger` ) ,
459+ ) . not . toThrow ( ) ;
460+ expect ( ( ) => runNxCommand ( `swagger ${ api } ` ) ) . not . toThrow ( ) ;
461+ expect ( ( ) =>
462+ checkFilesExist ( `libs/generated/${ api } -swagger/swagger.json` ) ,
463+ ) . not . toThrow ( ) ;
464+ } ) ;
465+ } ) ;
444466} ) ;
445467
446468function initializeGitRepo ( cwd : string ) {
0 commit comments