@@ -18,6 +18,14 @@ export class Run extends Command {
1818 default : 'local' ,
1919 required : false ,
2020 } ) ,
21+ swagger : flags . boolean ( {
22+ char : 's' , // shorter flag version
23+ description : 'enable or disable swagger interface support' , // help description for flag
24+ hidden : false , // hide from help
25+ default : true , // default value if flag not passed (can be a function that returns a string or undefined)
26+ required : false , // make flag required (this is not common and you should probably use an argument instead)
27+ allowNo : true ,
28+ } ) ,
2129 readonly : flags . boolean ( {
2230 char : 'r' , // shorter flag version
2331 description : 'set api to readonly (true) or writeable (false)' , // help description for flag
@@ -44,6 +52,7 @@ export class Run extends Command {
4452 const server = express ( ) ;
4553 const defaultConfig = new AppConfig ( ) ;
4654 defaultConfig . readOnly = flags . readonly ;
55+ defaultConfig . enableSwagger = flags . swagger ;
4756 defaultConfig . jsonFile = args . file ;
4857 if ( args . file && flags . env ) {
4958 const promise = startServer (
@@ -55,28 +64,42 @@ export class Run extends Command {
5564 await promise ;
5665 this . log ( ) ;
5766 this . log ( ) ;
58- cli . table (
59- [
60- {
61- text : `${ chalk . blueBright ( 'Swagger UI' ) } ` ,
62- link : 'http://localhost:3000/ui' ,
63- } ,
64- {
65- text : `${ chalk . blueBright ( 'GraphiQL' ) } ` ,
66- link : 'http://localhost:3000/graphql' ,
67- } ,
68- {
69- text : `${ chalk . blueBright ( 'Swagger Specification' ) } ` ,
70- link : 'http://localhost:3000/api-spec' ,
71- } ,
72- {
73- text : `${ chalk . blueBright ( 'API Routes' ) } ` ,
74- link : 'http://localhost:3000/api/{routes}' ,
75- } ,
76- ] ,
77- { text : { minWidth : 30 } , link : { minWidth : 20 } } ,
78- { 'no-header' : true }
79- ) ;
67+
68+ if ( flags . swagger ) {
69+ cli . table (
70+ [
71+ {
72+ text : `${ chalk . blueBright ( 'Swagger UI' ) } ` ,
73+ link : 'http://localhost:3000/ui' ,
74+ } ,
75+ {
76+ text : `${ chalk . blueBright ( 'GraphiQL' ) } ` ,
77+ link : 'http://localhost:3000/graphql' ,
78+ } ,
79+ {
80+ text : `${ chalk . blueBright ( 'Swagger Specification' ) } ` ,
81+ link : 'http://localhost:3000/api-spec' ,
82+ } ,
83+ {
84+ text : `${ chalk . blueBright ( 'API Routes' ) } ` ,
85+ link : 'http://localhost:3000/api/{routes}' ,
86+ } ,
87+ ] ,
88+ { text : { minWidth : 30 } , link : { minWidth : 20 } } ,
89+ { 'no-header' : true }
90+ ) ;
91+ } else {
92+ cli . table (
93+ [
94+ {
95+ text : `${ chalk . blueBright ( 'API Routes' ) } ` ,
96+ link : 'http://localhost:3000/api/{routes}' ,
97+ } ,
98+ ] ,
99+ { text : { minWidth : 30 } , link : { minWidth : 20 } } ,
100+ { 'no-header' : true }
101+ ) ;
102+ }
80103 this . log ( ) ;
81104 this . log ( ) ;
82105 }
0 commit comments