File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"host" : {
3
3
"url" : " http://apis.host"
4
+ },
5
+ "mock" : {
6
+ "url" : " http://mock.local:3020"
4
7
}
5
8
}
Original file line number Diff line number Diff line change
1
+ var _ = require ( 'lodash' ) ;
2
+ var request = require ( 'request' ) ;
3
+
4
+ exports . swagger = true ;
5
+ exports . login = true ;
6
+
7
+ /*
8
+ * This will completely change 100%, and all files
9
+ * uploaded to apis.host will be removed! It's just
10
+ * a placeholder to kinda have something that works.
11
+ */
12
+
13
+ exports . run = function ( config , info ) {
14
+ console . log ( 'Uploading Swagger file...' ) ;
15
+
16
+ request . post ( config . mock . url + '/upload' , {
17
+ 'form' : {
18
+ 'swagger' : JSON . stringify ( info . swagger ) ,
19
+ } ,
20
+ json : true
21
+ } , function ( err , res , data ) {
22
+ var samples = [ ] ;
23
+ _ . each ( info . swagger . paths , function ( types , path ) {
24
+ _ . each ( types , function ( endpoint , type ) {
25
+ if ( [ 'get' , 'post' ] . indexOf ( type . toLowerCase ( ) ) >= 0 ) {
26
+ samples . push ( [ type , path ] ) ;
27
+ }
28
+ } ) ;
29
+ } ) ;
30
+
31
+ console . log ( "Success!" . green . bold + " You now have an API you can test against:" ) ;
32
+ console . log ( "" ) ;
33
+ console . log ( " " + data . url ) ;
34
+ console . log ( "" ) ;
35
+ if ( samples . length ) {
36
+ console . log ( "Here's some example URLs you can try:" ) ;
37
+ console . log ( "" ) ;
38
+ _ . each ( samples , function ( s ) {
39
+ console . log ( ( " [" + s [ 0 ] + "] " + data . url + ( info . swagger . basePath || "" ) + s [ 1 ] ) . grey ) ;
40
+ } ) ;
41
+ }
42
+ } ) ;
43
+ } ;
You can’t perform that action at this time.
0 commit comments