File tree 3 files changed +13
-1
lines changed 3 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ also use the Node API (below).
73
73
| ` --namespace [name] ` | ` -n ` | ` OpenAPI2 ` | How should the output be namespaced? (namespacing is enforced as there’s a high chance of collision) |
74
74
| ` --swagger [version] ` | ` -s ` | ` 2 ` | Which Swagger version to use. Currently only supports ` 2 ` . |
75
75
| ` --camelcase ` | ` -c ` | ` false ` | Convert ` snake_case ` properties to ` camelCase ` ? |
76
+ | ` --export ` | ` -e ` | ` false ` | Exports the namespace |
76
77
77
78
### Node
78
79
@@ -107,6 +108,7 @@ in handy.
107
108
| ` namespace ` | ` string ` | ` OpenAPI2 ` | How should the output be namespaced? (namespacing is enforced as there’s a high chance of collision) |
108
109
| ` swagger ` | ` number ` | ` 2 ` | Which Swagger version to use. Currently only supports ` 2 ` . |
109
110
| ` camelcase ` | ` boolean ` | ` false ` | Convert ` snake_case ` properties to ` camelCase ` |
111
+ | ` export ` | ` boolean ` | ` false ` | Exports the namespace |
110
112
111
113
[ glob ] : https://www.npmjs.com/package/glob
112
114
[ js-yaml ] : https://www.npmjs.com/package/js-yaml
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ Options
19
19
--output, -o specify output file
20
20
--camelcase, -c convert snake_case properties to camelCase (default: off)
21
21
--swagger, -s specify Swagger version (default: 2)
22
+ --export, -e exports the namespace (default: false)
22
23
` ,
23
24
{
24
25
flags : {
@@ -39,6 +40,11 @@ Options
39
40
type : 'number' ,
40
41
alias : 's' ,
41
42
} ,
43
+ export : {
44
+ type : 'boolean' ,
45
+ default : false ,
46
+ alias : 'e' ,
47
+ } ,
42
48
} ,
43
49
}
44
50
) ;
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export interface Swagger2 {
23
23
export interface Swagger2Options {
24
24
camelcase ?: boolean ;
25
25
namespace ?: string ;
26
+ export ?: boolean ;
26
27
}
27
28
28
29
// Primitives only!
@@ -43,9 +44,12 @@ function camelCase(name: string): string {
43
44
function parse ( spec : Swagger2 , options : Swagger2Options = { } ) : string {
44
45
const namespace = options . namespace || 'OpenAPI2' ;
45
46
const shouldCamelCase = options . camelcase || false ;
47
+ const shouldExport = options . export || false ;
46
48
47
49
const queue : [ string , Swagger2Definition ] [ ] = [ ] ;
48
- const output : string [ ] = [ `namespace ${ namespace } {` ] ;
50
+
51
+ const output : string [ ] = shouldExport ? [ 'export ' ] : [ ] ;
52
+ output . push ( `namespace ${ namespace } {` ) ;
49
53
50
54
const { definitions } = spec ;
51
55
You can’t perform that action at this time.
0 commit comments