File tree Expand file tree Collapse file tree 9 files changed +61
-9
lines changed Expand file tree Collapse file tree 9 files changed +61
-9
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " openapi-typescript-codegen" ,
3
- "version" : " 0.7.0-beta-2 " ,
3
+ "version" : " 0.7.0-beta-3 " ,
4
4
"description" : " Library that generates Typescript clients based on the OpenAPI specification." ,
5
5
"author" : " Ferdi Koomen" ,
6
6
"homepage" : " https://github.com/ferdikoomen/openapi-typescript-codegen" ,
Original file line number Diff line number Diff line change @@ -9,6 +9,12 @@ import type { {{{this}}} } from './{{{this}}}';
9
9
10
10
{{ #equals export ' interface' }}
11
11
{{> exportInterface }}
12
+ {{ else equals export 'one-of'}}
13
+ {{> exportComposition }}
14
+ {{ else equals export 'any-of'}}
15
+ {{> exportComposition }}
16
+ {{ else equals export 'all-of'}}
17
+ {{> exportComposition }}
12
18
{{ else equals export 'enum'}}
13
19
{{> exportEnum }}
14
20
{{ else }}
Original file line number Diff line number Diff line change
1
+ {{ #if description }}
2
+ /**
3
+ * {{{ description }}}
4
+ */
5
+ {{ /if }}
6
+ export type {{{ name }}} = {{> type parent =name }} ;
7
+ {{ #if enums }}
8
+ {{ #unless @root.useUnionTypes }}
9
+
10
+ export namespace {{{ name }}} {
11
+
12
+ {{ #each enums }}
13
+ {{ #if description }}
14
+ /**
15
+ * {{{ description }}}
16
+ */
17
+ {{ /if }}
18
+ export enum {{{ name }}} {
19
+ {{ #each enum }}
20
+ {{{ name }}} = {{{ value }}} ,
21
+ {{ /each }}
22
+ }
23
+
24
+ {{ /each }}
25
+
26
+ }
27
+ {{ /unless }}
28
+ {{ /if }}
Original file line number Diff line number Diff line change 6
6
* {{{ description }}}
7
7
*/
8
8
{{ /if }}
9
+ {{ #if ../parent }}
10
+ {{> isReadOnly }}{{{ name }}}{{> isRequired }} : {{> type parent =../parent }} ,
11
+ {{ else }}
9
12
{{> isReadOnly }}{{{ name }}}{{> isRequired }} : {{> type }} ,
13
+ {{ /if }}
10
14
{{ /each }}
11
15
}{{> isNullable }}
12
16
{{ ~else ~}}
Original file line number Diff line number Diff line change
1
+ {{ ~#if parent ~}}
2
+ ({{ #each properties }} {{> type parent =../parent }} {{ #unless @last }} & {{ /unless }}{{ /each }} ){{> isNullable }}
3
+ {{ ~else ~}}
1
4
({{ #each properties }} {{> type }} {{ #unless @last }} & {{ /unless }}{{ /each }} ){{> isNullable }}
5
+ {{ ~/if ~}}
Original file line number Diff line number Diff line change
1
+ {{ ~#if parent ~}}
2
+ ({{ #each properties }} {{> type parent =../parent }} {{ #unless @last }} | {{ /unless }}{{ /each }} ){{> isNullable }}
3
+ {{ ~else ~}}
1
4
({{ #each properties }} {{> type }} {{ #unless @last }} | {{ /unless }}{{ /each }} ){{> isNullable }}
5
+ {{ ~/if ~}}
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ import templateExportSchema from '../templates/exportSchema.hbs';
39
39
import templateExportService from '../templates/exportService.hbs' ;
40
40
import templateIndex from '../templates/index.hbs' ;
41
41
import partialBase from '../templates/partials/base.hbs' ;
42
+ import partialExportComposition from '../templates/partials/exportComposition.hbs' ;
42
43
import partialExportEnum from '../templates/partials/exportEnum.hbs' ;
43
44
import partialExportInterface from '../templates/partials/exportInterface.hbs' ;
44
45
import partialExportType from '../templates/partials/exportType.hbs' ;
@@ -109,6 +110,7 @@ export function registerHandlebarTemplates(): Templates {
109
110
// Partials for the generations of the models, services, etc.
110
111
Handlebars . registerPartial ( 'exportEnum' , Handlebars . template ( partialExportEnum ) ) ;
111
112
Handlebars . registerPartial ( 'exportInterface' , Handlebars . template ( partialExportInterface ) ) ;
113
+ Handlebars . registerPartial ( 'exportComposition' , Handlebars . template ( partialExportComposition ) ) ;
112
114
Handlebars . registerPartial ( 'exportType' , Handlebars . template ( partialExportType ) ) ;
113
115
Handlebars . registerPartial ( 'header' , Handlebars . template ( partialHeader ) ) ;
114
116
Handlebars . registerPartial ( 'isNullable' , Handlebars . template ( partialIsNullable ) ) ;
Original file line number Diff line number Diff line change @@ -619,7 +619,8 @@ import type { ModelWithString } from './ModelWithString';
619
619
export type ModelThatExtends = (ModelWithString & {
620
620
propExtendsA?: string,
621
621
propExtendsB?: ModelWithString,
622
- });"
622
+ });
623
+ "
623
624
`;
624
625
625
626
exports[`v2 should generate: ./test/generated/v2/models/ModelThatExtendsExtends.ts 1`] = `
@@ -636,7 +637,8 @@ import type { ModelWithString } from './ModelWithString';
636
637
export type ModelThatExtendsExtends = (ModelWithString & ModelThatExtends & {
637
638
propExtendsC?: string,
638
639
propExtendsD?: ModelWithString,
639
- });"
640
+ });
641
+ "
640
642
`;
641
643
642
644
exports[`v2 should generate: ./test/generated/v2/models/ModelWithArray.ts 1`] = `
@@ -2992,7 +2994,8 @@ import type { ModelWithString } from './ModelWithString';
2992
2994
export type ModelThatExtends = (ModelWithString & {
2993
2995
propExtendsA?: string,
2994
2996
propExtendsB?: ModelWithString,
2995
- });"
2997
+ });
2998
+ "
2996
2999
`;
2997
3000
2998
3001
exports[`v3 should generate: ./test/generated/v3/models/ModelThatExtendsExtends.ts 1`] = `
@@ -3009,7 +3012,8 @@ import type { ModelWithString } from './ModelWithString';
3009
3012
export type ModelThatExtendsExtends = (ModelWithString & ModelThatExtends & {
3010
3013
propExtendsC?: string,
3011
3014
propExtendsD?: ModelWithString,
3012
- });"
3015
+ });
3016
+ "
3013
3017
`;
3014
3018
3015
3019
exports[`v3 should generate: ./test/generated/v3/models/ModelWithArray.ts 1`] = `
Original file line number Diff line number Diff line change @@ -7,8 +7,8 @@ async function generateV2() {
7
7
input : './test/spec/v2.json' ,
8
8
output : './test/generated/v2/' ,
9
9
httpClient : OpenAPI . HttpClient . FETCH ,
10
- useOptions : true ,
11
- useUnionTypes : true ,
10
+ useOptions : false ,
11
+ useUnionTypes : false ,
12
12
exportCore : true ,
13
13
exportSchemas : true ,
14
14
exportModels : true ,
@@ -21,8 +21,8 @@ async function generateV3() {
21
21
input : './test/spec/v3.json' ,
22
22
output : './test/generated/v3/' ,
23
23
httpClient : OpenAPI . HttpClient . FETCH ,
24
- useOptions : true ,
25
- useUnionTypes : true ,
24
+ useOptions : false ,
25
+ useUnionTypes : false ,
26
26
exportCore : true ,
27
27
exportSchemas : true ,
28
28
exportModels : true ,
You can’t perform that action at this time.
0 commit comments