File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed
packages/core/src/generators Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change 1
1
import { describe , expect , it } from 'vitest' ;
2
- import { ContextSpecs , GeneratorSchema } from '../types' ;
2
+ import type { ContextSpecs , GeneratorSchema } from '../types' ;
3
3
import { generateInterface } from './interface' ;
4
- import { SchemaObject as SchemaObject31 } from 'openapi3-ts/oas31' ;
5
- import { SchemaObject as SchemaObject30 } from 'openapi3-ts/oas30' ;
4
+ import type { SchemaObject as SchemaObject31 } from 'openapi3-ts/oas31' ;
5
+ import type { SchemaObject as SchemaObject30 } from 'openapi3-ts/oas30' ;
6
6
7
7
describe ( 'generateInterface' , ( ) => {
8
8
const context : ContextSpecs = {
@@ -26,6 +26,10 @@ describe('generateInterface', () => {
26
26
type : 'integer' ,
27
27
const : 1 ,
28
28
} ,
29
+ isError : {
30
+ type : 'boolean' ,
31
+ const : false ,
32
+ } ,
29
33
} ,
30
34
required : [ 'message' , 'code' ] ,
31
35
} ;
@@ -42,6 +46,7 @@ describe('generateInterface', () => {
42
46
model : `export const TestSchemaValue = {
43
47
message: 'Invalid data',
44
48
code: 1,
49
+ isError: false,
45
50
} as const;
46
51
export type TestSchema = typeof TestSchemaValue;
47
52
` ,
Original file line number Diff line number Diff line change 1
- import { SchemaObject } from 'openapi3-ts/oas30' ;
1
+ import type { SchemaObject } from 'openapi3-ts/oas30' ;
2
2
import { getScalar } from '../getters' ;
3
- import { ContextSpecs } from '../types' ;
3
+ import type { ContextSpecs } from '../types' ;
4
4
import { jsDoc } from '../utils' ;
5
5
6
6
/**
@@ -51,7 +51,9 @@ export const generateInterface = ({
51
51
Object . values ( schema . properties ) . length > 0 &&
52
52
Object . values ( schema . properties ) . every ( ( item ) => 'const' in item )
53
53
) {
54
- const mappedScalarValue = scalar . value . replaceAll ( ';' , ',' ) ;
54
+ const mappedScalarValue = scalar . value
55
+ . replaceAll ( ';' , ',' )
56
+ . replaceAll ( '?:' , ':' ) ;
55
57
56
58
model += `export const ${ name } Value = ${ mappedScalarValue } as const;\nexport type ${ name } = typeof ${ name } Value;\n` ;
57
59
} else {
You can’t perform that action at this time.
0 commit comments