File tree Expand file tree Collapse file tree 4 files changed +20
-27
lines changed Expand file tree Collapse file tree 4 files changed +20
-27
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env node
2
- var argv = require ( 'yargs' )
3
- . usage ( 'Usage: $0 -i [path] -o [path]' )
4
- . demandOption ( [ 'i' , 'o' ] )
5
- . argv ;
2
+ var argv = require ( 'yargs' ) . argv ;
3
+ var build = require ( '../lib' ) ;
4
+ var graphql = require ( 'graphql' ) ;
5
+
6
+ if ( argv . help ) {
7
+ console . log ( '\nUsage: swagger2graphql --swagger=/path/to/schema.json' ) ;
8
+ }
9
+
10
+ if ( ! argv . swagger ) {
11
+ console . log ( '\nPlease provide path to swagger schema. \n--help for usage example' ) ;
12
+ }
13
+
14
+ build ( argv . swagger ) . then ( schema => {
15
+ console . log ( graphql . printSchema ( schema ) ) ;
16
+ } ) ;
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " swagger-to-graphql" ,
3
- "version" : " 1.0.6 " ,
3
+ "version" : " 1.1.0 " ,
4
4
"author" : " Roman Krivtsov" ,
5
5
"bin" : " ./bin/swagger2graphql" ,
6
6
"dependencies" : {
Original file line number Diff line number Diff line change @@ -45,6 +45,9 @@ const resolver = (endpoint) =>
45
45
const req = endpoint . request ( args , {
46
46
baseUrl : opts . GQLProxyBaseUrl
47
47
} ) ;
48
+ if ( opts . BearerToken ) {
49
+ req . headers . Authorization = opts . BearerToken ;
50
+ }
48
51
const res = await rp ( req ) ;
49
52
return JSON . parse ( res ) ;
50
53
} ;
@@ -69,7 +72,7 @@ const build = async (swaggerPath) => {
69
72
const swaggerSchema = await loadSchema ( swaggerPath ) ;
70
73
const endpoints = getAllEndPoints ( swaggerSchema ) ;
71
74
const schema = schemaFromEndpoints ( endpoints ) ;
72
- console . log ( printSchema ( schema ) ) ;
75
+ return schema ;
73
76
} ;
74
77
75
78
export default build ;
You can’t perform that action at this time.
0 commit comments