File tree 3 files changed +25
-1
lines changed
3 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ export const generateInterface = ({
43
43
}
44
44
45
45
if (
46
- ! generalJSTypesWithArray . includes ( scalar . value ) &&
46
+ scalar . type === 'object' &&
47
47
! context ?. output . override ?. useTypeOverInterfaces
48
48
) {
49
49
model += `export interface ${ name } ${ scalar . value } \n` ;
Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ import { combineSchemas } from './combine';
6
6
import { getKey } from './keys' ;
7
7
import { getRefInfo } from './ref' ;
8
8
9
+ interface SchemaWithConst extends SchemaObject {
10
+ const : string ;
11
+ }
12
+
9
13
/**
10
14
* Return the output type from an object
11
15
*
@@ -185,6 +189,19 @@ export const getObject = ({
185
189
} ;
186
190
}
187
191
192
+ const itemWithConst = item as SchemaWithConst ;
193
+ if ( itemWithConst . const ) {
194
+ return {
195
+ value : `'${ itemWithConst . const } '` + nullable ,
196
+ imports : [ ] ,
197
+ schemas : [ ] ,
198
+ isEnum : false ,
199
+ type : 'string' ,
200
+ isRef : false ,
201
+ hasReadonlyProps : item . readOnly || false ,
202
+ } ;
203
+ }
204
+
188
205
return {
189
206
value :
190
207
( item . type === 'object' ? '{ [key: string]: any }' : 'unknown' ) +
Original file line number Diff line number Diff line change @@ -26,5 +26,12 @@ components:
26
26
type : string
27
27
type : array
28
28
title : Example tuple
29
+ example_const :
30
+ const : this_is_a_const
31
+ example_enum :
32
+ type : string
33
+ enum :
34
+ - enum1
35
+ - enum2
29
36
title : Test
30
37
type : object
You can’t perform that action at this time.
0 commit comments