File tree Expand file tree Collapse file tree 3 files changed +21
-8
lines changed Expand file tree Collapse file tree 3 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ export type { OpenAPIConfig } from './core/OpenAPI';
15
15
{{ /if }}
16
16
{{ #if @root.exportModels }}
17
17
{{ #if models }}
18
-
19
18
{{ #each models }}
20
19
{{ #if @root.useUnionTypes }}
21
20
export type { {{{ name }}} {{ #if @root.postfixModels }} as {{{ name }}}{{{ @root.postfixModels }}} {{ /if }} } from './models/{{{ name }}} ';
@@ -29,6 +28,7 @@ export type { {{{name}}}{{#if @root.postfixModels}} as {{{name}}}{{{@root.postfi
29
28
{{ /each }}
30
29
{{ /if }}
31
30
{{ /if }}
31
+
32
32
{{ #if @root.exportSchemas }}
33
33
{{ #if models }}
34
34
@@ -41,7 +41,7 @@ export { ${{{name}}} } from './schemas/${{{name}}}';
41
41
{{ #if services }}
42
42
43
43
{{ #each services }}
44
- export { {{{ name }}}{{{ @root.postfixServices }}} } from './services /{{{ name }}}{{{ @root.postfixServices }}} ';
44
+ export { actionCreators as {{{ name }}}{{{ @root.postfixServices }}} Actions } from './store /{{{ name }}}{{{ @root.postfixServices }}} ';
45
45
{{ /each }}
46
46
{{ /if }}
47
47
{{ /if }}
Original file line number Diff line number Diff line change 1
1
import type { Model } from '../client/interfaces/Model' ;
2
2
3
3
export const sortModelsByName = ( models : Model [ ] ) : Model [ ] => {
4
- return models . sort ( ( a , b ) => {
5
- const nameA = a . name . toLowerCase ( ) ;
6
- const nameB = b . name . toLowerCase ( ) ;
7
- return nameA . localeCompare ( nameB , 'en' ) ;
8
- } ) ;
4
+ const seen = new Set ( ) ;
5
+
6
+ return models
7
+ . filter ( model => {
8
+ const key = model . name + '|' + model . export ;
9
+ if ( seen . has ( key ) ) {
10
+ return false ;
11
+ }
12
+ seen . add ( key ) ;
13
+ return true ;
14
+ } )
15
+ . sort ( ( a , b ) => {
16
+ const nameA = a . name . toLowerCase ( ) ;
17
+ const nameB = b . name . toLowerCase ( ) ;
18
+ return nameA . localeCompare ( nameB , 'en' ) ;
19
+ } ) ;
9
20
} ;
Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ export const writeClientIndex = async (
36
36
postfixModels : string ,
37
37
clientName ?: string
38
38
) : Promise < void > => {
39
+ const models = sortModelsByName ( client . models ) ;
40
+
39
41
const templateResult = templates . index ( {
40
42
exportCore,
41
43
exportServices,
@@ -47,7 +49,7 @@ export const writeClientIndex = async (
47
49
clientName,
48
50
server : client . server ,
49
51
version : client . version ,
50
- models : sortModelsByName ( client . models ) ,
52
+ models : models ,
51
53
services : sortServicesByName ( client . services ) ,
52
54
exportClient : isDefined ( clientName ) ,
53
55
} ) ;
You can’t perform that action at this time.
0 commit comments