1
- import type { AbstractType } from '../type/classes/AbstractType ' ;
1
+ import type { AbsType } from '../type/classes/AbsType ' ;
2
2
import type { AnyType } from '../type/classes/AnyType' ;
3
- import type { ArrayType } from '../type/classes/ArrayType ' ;
4
- import type { BinaryType } from '../type/classes/BinaryType ' ;
5
- import type { BooleanType } from '../type/classes/BooleanType ' ;
6
- import type { ConstType } from '../type/classes/ConstType ' ;
3
+ import type { ArrType } from '../type/classes/ArrType ' ;
4
+ import type { BinType } from '../type/classes/BinType ' ;
5
+ import type { BoolType } from '../type/classes/BoolType ' ;
6
+ import type { ConType } from '../type/classes/ConType ' ;
7
7
import type { MapType } from '../type/classes/MapType' ;
8
- import type { NumberType } from '../type/classes/NumberType ' ;
9
- import type { ObjectType } from '../type/classes/ObjectType ' ;
8
+ import type { NumType } from '../type/classes/NumType ' ;
9
+ import type { ObjType } from '../type/classes/ObjType ' ;
10
10
import type { OrType } from '../type/classes/OrType' ;
11
11
import type { RefType } from '../type/classes/RefType' ;
12
- import type { StringType } from '../type/classes/StringType ' ;
13
- import type { TupleType } from '../type/classes/TupleType ' ;
12
+ import type { StrType } from '../type/classes/StrType ' ;
13
+ import type { TupType } from '../type/classes/TupType ' ;
14
14
import type { TypeExportContext } from '../system/TypeExportContext' ;
15
15
import type * as schema from '../schema' ;
16
16
import type {
@@ -30,9 +30,9 @@ import type {
30
30
31
31
/**
32
32
* Extracts the base JSON Schema properties that are common to all types.
33
- * This replaces the logic from AbstractType .toJsonSchema().
33
+ * This replaces the logic from AbsType .toJsonSchema().
34
34
*/
35
- function getBaseJsonSchema ( type : AbstractType < any > , ctx ?: TypeExportContext ) : JsonSchemaGenericKeywords {
35
+ function getBaseJsonSchema ( type : AbsType < any > , ctx ?: TypeExportContext ) : JsonSchemaGenericKeywords {
36
36
const typeSchema = type . getSchema ( ) ;
37
37
const jsonSchema : JsonSchemaGenericKeywords = { } ;
38
38
@@ -49,34 +49,34 @@ function getBaseJsonSchema(type: AbstractType<any>, ctx?: TypeExportContext): Js
49
49
* Main router function that converts a type to JSON Schema using a switch statement.
50
50
* This replaces the individual toJsonSchema() methods on each type class.
51
51
*/
52
- export function typeToJsonSchema ( type : AbstractType < any > , ctx ?: TypeExportContext ) : JsonSchemaNode {
52
+ export function typeToJsonSchema ( type : AbsType < any > , ctx ?: TypeExportContext ) : JsonSchemaNode {
53
53
const typeName = type . getTypeName ( ) ;
54
54
55
55
switch ( typeName ) {
56
56
case 'any' :
57
57
return anyToJsonSchema ( type as AnyType , ctx ) ;
58
58
case 'arr' :
59
- return arrayToJsonSchema ( type as ArrayType < any > , ctx ) ;
59
+ return arrayToJsonSchema ( type as ArrType < any > , ctx ) ;
60
60
case 'bin' :
61
- return binaryToJsonSchema ( type as BinaryType < any > , ctx ) ;
61
+ return binaryToJsonSchema ( type as BinType < any > , ctx ) ;
62
62
case 'bool' :
63
- return booleanToJsonSchema ( type as BooleanType , ctx ) ;
64
- case 'const ' :
65
- return constToJsonSchema ( type as ConstType < any > , ctx ) ;
63
+ return booleanToJsonSchema ( type as BoolType , ctx ) ;
64
+ case 'con ' :
65
+ return constToJsonSchema ( type as ConType < any > , ctx ) ;
66
66
case 'map' :
67
67
return mapToJsonSchema ( type as MapType < any > , ctx ) ;
68
68
case 'num' :
69
- return numberToJsonSchema ( type as NumberType , ctx ) ;
69
+ return numberToJsonSchema ( type as NumType , ctx ) ;
70
70
case 'obj' :
71
- return objectToJsonSchema ( type as ObjectType < any > , ctx ) ;
71
+ return objectToJsonSchema ( type as ObjType < any > , ctx ) ;
72
72
case 'or' :
73
73
return orToJsonSchema ( type as OrType < any > , ctx ) ;
74
74
case 'ref' :
75
75
return refToJsonSchema ( type as RefType < any > , ctx ) ;
76
76
case 'str' :
77
- return stringToJsonSchema ( type as StringType , ctx ) ;
77
+ return stringToJsonSchema ( type as StrType , ctx ) ;
78
78
case 'tup' :
79
- return tupleToJsonSchema ( type as TupleType < any > , ctx ) ;
79
+ return tupleToJsonSchema ( type as TupType < any > , ctx ) ;
80
80
default :
81
81
// Fallback to base implementation for unknown types
82
82
return getBaseJsonSchema ( type , ctx ) ;
@@ -97,7 +97,7 @@ function anyToJsonSchema(type: AnyType, ctx?: TypeExportContext): JsonSchemaAny
97
97
return result ;
98
98
}
99
99
100
- function arrayToJsonSchema ( type : ArrayType < any > , ctx ?: TypeExportContext ) : JsonSchemaArray {
100
+ function arrayToJsonSchema ( type : ArrType < any > , ctx ?: TypeExportContext ) : JsonSchemaArray {
101
101
const schema = type . getSchema ( ) ;
102
102
const baseSchema = getBaseJsonSchema ( type , ctx ) ;
103
103
const result : JsonSchemaArray = {
@@ -114,7 +114,7 @@ function arrayToJsonSchema(type: ArrayType<any>, ctx?: TypeExportContext): JsonS
114
114
return result ;
115
115
}
116
116
117
- function binaryToJsonSchema ( type : BinaryType < any > , ctx ?: TypeExportContext ) : JsonSchemaBinary {
117
+ function binaryToJsonSchema ( type : BinType < any > , ctx ?: TypeExportContext ) : JsonSchemaBinary {
118
118
const baseSchema = getBaseJsonSchema ( type , ctx ) ;
119
119
const result : JsonSchemaBinary = {
120
120
type : 'binary' as any ,
@@ -126,7 +126,7 @@ function binaryToJsonSchema(type: BinaryType<any>, ctx?: TypeExportContext): Jso
126
126
return result ;
127
127
}
128
128
129
- function booleanToJsonSchema ( type : BooleanType , ctx ?: TypeExportContext ) : JsonSchemaBoolean {
129
+ function booleanToJsonSchema ( type : BoolType , ctx ?: TypeExportContext ) : JsonSchemaBoolean {
130
130
const baseSchema = getBaseJsonSchema ( type , ctx ) ;
131
131
const result : JsonSchemaBoolean = {
132
132
type : 'boolean' ,
@@ -138,7 +138,7 @@ function booleanToJsonSchema(type: BooleanType, ctx?: TypeExportContext): JsonSc
138
138
return result ;
139
139
}
140
140
141
- function constToJsonSchema ( type : ConstType < any > , ctx ?: TypeExportContext ) : JsonSchemaNode {
141
+ function constToJsonSchema ( type : ConType < any > , ctx ?: TypeExportContext ) : JsonSchemaNode {
142
142
const schema = type . getSchema ( ) ;
143
143
const baseSchema = getBaseJsonSchema ( type , ctx ) ;
144
144
const value = schema . value ;
@@ -204,7 +204,7 @@ function mapToJsonSchema(type: MapType<any>, ctx?: TypeExportContext): JsonSchem
204
204
const result : JsonSchemaObject = {
205
205
type : 'object' ,
206
206
patternProperties : {
207
- '.*' : typeToJsonSchema ( ( type as any ) . type , ctx ) ,
207
+ '.*' : typeToJsonSchema ( ( type as any ) . valueType , ctx ) ,
208
208
} ,
209
209
} ;
210
210
@@ -214,7 +214,7 @@ function mapToJsonSchema(type: MapType<any>, ctx?: TypeExportContext): JsonSchem
214
214
return result ;
215
215
}
216
216
217
- function numberToJsonSchema ( type : NumberType , ctx ?: TypeExportContext ) : JsonSchemaNumber {
217
+ function numberToJsonSchema ( type : NumType , ctx ?: TypeExportContext ) : JsonSchemaNumber {
218
218
const schema = type . getSchema ( ) ;
219
219
const baseSchema = getBaseJsonSchema ( type , ctx ) ;
220
220
const result : JsonSchemaNumber = {
@@ -238,7 +238,7 @@ function numberToJsonSchema(type: NumberType, ctx?: TypeExportContext): JsonSche
238
238
return result ;
239
239
}
240
240
241
- function objectToJsonSchema ( type : ObjectType < any > , ctx ?: TypeExportContext ) : JsonSchemaObject {
241
+ function objectToJsonSchema ( type : ObjType < any > , ctx ?: TypeExportContext ) : JsonSchemaObject {
242
242
const schema = type . getSchema ( ) ;
243
243
const baseSchema = getBaseJsonSchema ( type , ctx ) ;
244
244
const result : JsonSchemaObject = {
@@ -294,7 +294,7 @@ function refToJsonSchema(type: RefType<any>, ctx?: TypeExportContext): JsonSchem
294
294
return result ;
295
295
}
296
296
297
- function stringToJsonSchema ( type : StringType , ctx ?: TypeExportContext ) : JsonSchemaString {
297
+ function stringToJsonSchema ( type : StrType , ctx ?: TypeExportContext ) : JsonSchemaString {
298
298
const schema = type . getSchema ( ) ;
299
299
const baseSchema = getBaseJsonSchema ( type , ctx ) ;
300
300
const result : JsonSchemaString = {
@@ -323,7 +323,7 @@ function stringToJsonSchema(type: StringType, ctx?: TypeExportContext): JsonSche
323
323
return result ;
324
324
}
325
325
326
- function tupleToJsonSchema ( type : TupleType < any > , ctx ?: TypeExportContext ) : JsonSchemaArray {
326
+ function tupleToJsonSchema ( type : TupType < any > , ctx ?: TypeExportContext ) : JsonSchemaArray {
327
327
const baseSchema = getBaseJsonSchema ( type , ctx ) ;
328
328
const types = ( type as any ) . types ;
329
329
const result : JsonSchemaArray = {
0 commit comments