File tree 3 files changed +11
-19
lines changed 3 files changed +11
-19
lines changed Original file line number Diff line number Diff line change @@ -5,15 +5,15 @@ Convert swagger json api to js (with types fo typescript)
5
5
## Install
6
6
7
7
``` sh
8
- npm install -g swagger-to-js
8
+ npm install swagger-to-js
9
9
# or
10
- yarn global add swagger-to-js
10
+ yarn add swagger-to-js
11
11
```
12
12
13
13
## Usage CLI
14
14
15
15
``` sh
16
- swagger-to-js [options]
16
+ yarn swagger-to-js [options]
17
17
18
18
Options:
19
19
--file < path> Path swagger JSON file with api
Original file line number Diff line number Diff line change 28
28
"swagger-to-js" : " ./src/run.js"
29
29
},
30
30
"dependencies" : {
31
- "@babel/parser" : " ^7.9.6" ,
32
- "commander" : " ^5.1.0" ,
33
- "prettier" : " ^2.0.5"
31
+ "commander" : " ^5.1.0"
34
32
},
35
33
"devDependencies" : {
36
34
"eslint" : " ^6.8.0" ,
37
35
"eslint-plugin-prettier" : " ^3.1.3" ,
38
- "jest" : " ^25.5.3"
36
+ "jest" : " ^25.5.3" ,
37
+ "prettier" : " ^2.0.5"
39
38
},
40
39
"swagger-to-js" : {
41
40
"file" : " ./src/mocks/mock-v1.json"
Original file line number Diff line number Diff line change 1
- const prettier = require ( "prettier" ) ;
2
1
const { readFileSync } = require ( "fs" ) ;
3
2
const path = require ( "path" ) ;
4
3
@@ -25,14 +24,8 @@ function swaggerToJs(apiJson, config = {}) {
25
24
const pathRequestCode = path . resolve ( path . dirname ( __filename ) , "request.js" ) ;
26
25
const requestCode = readFileSync ( pathRequestCode ) ;
27
26
28
- const code = prettier . format ( `${ requestCode } \n\n${ paths . code } ` , {
29
- ...prettierOptions ,
30
- parser : "babel" ,
31
- } ) ;
32
- const types = prettier . format ( `${ definitions } \n\n${ paths . types } ` , {
33
- ...prettierOptions ,
34
- parser : "typescript" ,
35
- } ) ;
27
+ const code = `${ requestCode } \n\n${ paths . code } ` ;
28
+ const types = `${ definitions } \n\n${ paths . types } ` ;
36
29
37
30
console . timeEnd ( "✨ swaggerapi" ) ;
38
31
@@ -121,9 +114,9 @@ function printPathCode(scope, config) {
121
114
const addedParamsString = addedParams ? `, ${ addedParams } ` : "" ;
122
115
123
116
return `export function ${ name } (${ params } ) {
124
- ${ deprecatedWarning }
125
- return request("${ method } ", \`${ url } \`${ addedParamsString } )(${ params } );
126
- }\n\n`;
117
+ ${ deprecatedWarning }
118
+ return request("${ method } ", \`${ url } \`${ addedParamsString } )(${ params } );
119
+ }\n\n` ;
127
120
}
128
121
129
122
function printPathCodeAddedParams ( scope ) {
You can’t perform that action at this time.
0 commit comments