File tree Expand file tree Collapse file tree 3 files changed +13
-1
lines changed Expand file tree Collapse file tree 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).
7373| ` --namespace [name] ` | ` -n ` | ` OpenAPI2 ` | How should the output be namespaced? (namespacing is enforced as there’s a high chance of collision) |
7474| ` --swagger [version] ` | ` -s ` | ` 2 ` | Which Swagger version to use. Currently only supports ` 2 ` . |
7575| ` --camelcase ` | ` -c ` | ` false ` | Convert ` snake_case ` properties to ` camelCase ` ? |
76+ | ` --export ` | ` -e ` | ` false ` | Exports the namespace |
7677
7778### Node
7879
@@ -107,6 +108,7 @@ in handy.
107108| ` namespace ` | ` string ` | ` OpenAPI2 ` | How should the output be namespaced? (namespacing is enforced as there’s a high chance of collision) |
108109| ` swagger ` | ` number ` | ` 2 ` | Which Swagger version to use. Currently only supports ` 2 ` . |
109110| ` camelcase ` | ` boolean ` | ` false ` | Convert ` snake_case ` properties to ` camelCase ` |
111+ | ` export ` | ` boolean ` | ` false ` | Exports the namespace |
110112
111113[ glob ] : https://www.npmjs.com/package/glob
112114[ js-yaml ] : https://www.npmjs.com/package/js-yaml
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ Options
1919 --output, -o specify output file
2020 --camelcase, -c convert snake_case properties to camelCase (default: off)
2121 --swagger, -s specify Swagger version (default: 2)
22+ --export, -e exports the namespace (default: false)
2223` ,
2324 {
2425 flags : {
@@ -39,6 +40,11 @@ Options
3940 type : 'number' ,
4041 alias : 's' ,
4142 } ,
43+ export : {
44+ type : 'boolean' ,
45+ default : false ,
46+ alias : 'e' ,
47+ } ,
4248 } ,
4349 }
4450) ;
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export interface Swagger2 {
2323export interface Swagger2Options {
2424 camelcase ?: boolean ;
2525 namespace ?: string ;
26+ export ?: boolean ;
2627}
2728
2829// Primitives only!
@@ -43,9 +44,12 @@ function camelCase(name: string): string {
4344function parse ( spec : Swagger2 , options : Swagger2Options = { } ) : string {
4445 const namespace = options . namespace || 'OpenAPI2' ;
4546 const shouldCamelCase = options . camelcase || false ;
47+ const shouldExport = options . export || false ;
4648
4749 const queue : [ string , Swagger2Definition ] [ ] = [ ] ;
48- const output : string [ ] = [ `namespace ${ namespace } {` ] ;
50+
51+ const output : string [ ] = shouldExport ? [ 'export ' ] : [ ] ;
52+ output . push ( `namespace ${ namespace } {` ) ;
4953
5054 const { definitions } = spec ;
5155
You can’t perform that action at this time.
0 commit comments