@@ -14,7 +14,7 @@ import type {TupleType} from '../type/classes/TupleType';
1414import type { TypeExportContext } from '../system/TypeExportContext' ;
1515import type * as schema from '../schema' ;
1616import type {
17- JsonSchemaNode ,
17+ JsonSchemaNode ,
1818 JsonSchemaGenericKeywords ,
1919 JsonSchemaAny ,
2020 JsonSchemaArray ,
@@ -25,7 +25,7 @@ import type {
2525 JsonSchemaObject ,
2626 JsonSchemaRef ,
2727 JsonSchemaOr ,
28- JsonSchemaNull
28+ JsonSchemaNull ,
2929} from './types' ;
3030
3131/**
@@ -35,13 +35,13 @@ import type {
3535function getBaseJsonSchema ( type : AbstractType < any > , ctx ?: TypeExportContext ) : JsonSchemaGenericKeywords {
3636 const typeSchema = type . getSchema ( ) ;
3737 const jsonSchema : JsonSchemaGenericKeywords = { } ;
38-
38+
3939 if ( typeSchema . title ) jsonSchema . title = typeSchema . title ;
4040 if ( typeSchema . description ) jsonSchema . description = typeSchema . description ;
4141 if ( typeSchema . examples ) {
4242 jsonSchema . examples = typeSchema . examples . map ( ( example : schema . TExample ) => example . value ) ;
4343 }
44-
44+
4545 return jsonSchema ;
4646}
4747
@@ -51,7 +51,7 @@ function getBaseJsonSchema(type: AbstractType<any>, ctx?: TypeExportContext): Js
5151 */
5252export function typeToJsonSchema ( type : AbstractType < any > , ctx ?: TypeExportContext ) : JsonSchemaNode {
5353 const typeName = type . getTypeName ( ) ;
54-
54+
5555 switch ( typeName ) {
5656 case 'any' :
5757 return anyToJsonSchema ( type as AnyType , ctx ) ;
@@ -90,10 +90,10 @@ function anyToJsonSchema(type: AnyType, ctx?: TypeExportContext): JsonSchemaAny
9090 const result : JsonSchemaAny = {
9191 type : [ 'string' , 'number' , 'boolean' , 'null' , 'array' , 'object' ] as const ,
9292 } ;
93-
93+
9494 // Add base properties
9595 Object . assign ( result , baseSchema ) ;
96-
96+
9797 return result ;
9898}
9999
@@ -104,13 +104,13 @@ function arrayToJsonSchema(type: ArrayType<any>, ctx?: TypeExportContext): JsonS
104104 type : 'array' ,
105105 items : typeToJsonSchema ( ( type as any ) . type , ctx ) ,
106106 } ;
107-
107+
108108 // Add base properties
109109 Object . assign ( result , baseSchema ) ;
110-
110+
111111 if ( schema . min !== undefined ) result . minItems = schema . min ;
112112 if ( schema . max !== undefined ) result . maxItems = schema . max ;
113-
113+
114114 return result ;
115115}
116116
@@ -119,10 +119,10 @@ function binaryToJsonSchema(type: BinaryType<any>, ctx?: TypeExportContext): Jso
119119 const result : JsonSchemaBinary = {
120120 type : 'binary' as any ,
121121 } ;
122-
122+
123123 // Add base properties
124124 Object . assign ( result , baseSchema ) ;
125-
125+
126126 return result ;
127127}
128128
@@ -131,18 +131,18 @@ function booleanToJsonSchema(type: BooleanType, ctx?: TypeExportContext): JsonSc
131131 const result : JsonSchemaBoolean = {
132132 type : 'boolean' ,
133133 } ;
134-
134+
135135 // Add base properties
136136 Object . assign ( result , baseSchema ) ;
137-
137+
138138 return result ;
139139}
140140
141141function constToJsonSchema ( type : ConstType < any > , ctx ?: TypeExportContext ) : JsonSchemaNode {
142142 const schema = type . getSchema ( ) ;
143143 const baseSchema = getBaseJsonSchema ( type , ctx ) ;
144144 const value = schema . value ;
145-
145+
146146 if ( typeof value === 'string' ) {
147147 const result : JsonSchemaString = {
148148 type : 'string' ,
@@ -195,7 +195,7 @@ function constToJsonSchema(type: ConstType<any>, ctx?: TypeExportContext): JsonS
195195 Object . assign ( result , baseSchema ) ;
196196 return result ;
197197 }
198-
198+
199199 return baseSchema ;
200200}
201201
@@ -207,10 +207,10 @@ function mapToJsonSchema(type: MapType<any>, ctx?: TypeExportContext): JsonSchem
207207 '.*' : typeToJsonSchema ( ( type as any ) . type , ctx ) ,
208208 } ,
209209 } ;
210-
210+
211211 // Add base properties
212212 Object . assign ( result , baseSchema ) ;
213-
213+
214214 return result ;
215215}
216216
@@ -220,21 +220,21 @@ function numberToJsonSchema(type: NumberType, ctx?: TypeExportContext): JsonSche
220220 const result : JsonSchemaNumber = {
221221 type : 'number' ,
222222 } ;
223-
224- // Check if it's an integer format
223+
224+ // Check if it's an integer format
225225 const ints = new Set ( [ 'i8' , 'i16' , 'i32' , 'u8' , 'u16' , 'u32' ] ) ;
226226 if ( schema . format && ints . has ( schema . format ) ) {
227227 result . type = 'integer' ;
228228 }
229-
229+
230230 // Add base properties
231231 Object . assign ( result , baseSchema ) ;
232-
232+
233233 if ( schema . gt !== undefined ) result . exclusiveMinimum = schema . gt ;
234234 if ( schema . gte !== undefined ) result . minimum = schema . gte ;
235235 if ( schema . lt !== undefined ) result . exclusiveMaximum = schema . lt ;
236236 if ( schema . lte !== undefined ) result . maximum = schema . lte ;
237-
237+
238238 return result ;
239239}
240240
@@ -245,22 +245,22 @@ function objectToJsonSchema(type: ObjectType<any>, ctx?: TypeExportContext): Jso
245245 type : 'object' ,
246246 properties : { } ,
247247 } ;
248-
248+
249249 const required = [ ] ;
250250 const fields = ( type as any ) . fields ;
251251 for ( const field of fields ) {
252252 result . properties ! [ field . key ] = typeToJsonSchema ( field . value , ctx ) ;
253- if ( ! ( field . constructor . name . includes ( 'Optional' ) ) ) {
253+ if ( ! field . constructor . name . includes ( 'Optional' ) ) {
254254 required . push ( field . key ) ;
255255 }
256256 }
257-
257+
258258 if ( required . length ) result . required = required ;
259259 if ( schema . unknownFields === false ) result . additionalProperties = false ;
260-
260+
261261 // Add base properties
262262 Object . assign ( result , baseSchema ) ;
263-
263+
264264 return result ;
265265}
266266
@@ -270,27 +270,27 @@ function orToJsonSchema(type: OrType<any>, ctx?: TypeExportContext): JsonSchemaO
270270 const result : JsonSchemaOr = {
271271 anyOf : types . map ( ( t : any ) => typeToJsonSchema ( t , ctx ) ) ,
272272 } ;
273-
273+
274274 // Add base properties
275275 Object . assign ( result , baseSchema ) ;
276-
276+
277277 return result ;
278278}
279279
280280function refToJsonSchema ( type : RefType < any > , ctx ?: TypeExportContext ) : JsonSchemaRef {
281281 const schema = type . getSchema ( ) ;
282282 const baseSchema = getBaseJsonSchema ( type , ctx ) ;
283283 const ref = schema . ref ;
284-
284+
285285 if ( ctx ) ctx . mentionRef ( ref ) ;
286-
286+
287287 const result : JsonSchemaRef = {
288288 $ref : `#/$defs/${ ref } ` ,
289289 } ;
290-
290+
291291 // Add base properties
292292 Object . assign ( result , baseSchema ) ;
293-
293+
294294 return result ;
295295}
296296
@@ -300,10 +300,10 @@ function stringToJsonSchema(type: StringType, ctx?: TypeExportContext): JsonSche
300300 const result : JsonSchemaString = {
301301 type : 'string' ,
302302 } ;
303-
303+
304304 if ( schema . min !== undefined ) result . minLength = schema . min ;
305305 if ( schema . max !== undefined ) result . maxLength = schema . max ;
306-
306+
307307 // Add format to JSON Schema if specified
308308 if ( schema . format ) {
309309 if ( schema . format === 'ascii' ) {
@@ -316,10 +316,10 @@ function stringToJsonSchema(type: StringType, ctx?: TypeExportContext): JsonSche
316316 // Backward compatibility: if ascii=true, add pattern
317317 result . pattern = '^[\\x00-\\x7F]*$' ;
318318 }
319-
319+
320320 // Add base properties
321321 Object . assign ( result , baseSchema ) ;
322-
322+
323323 return result ;
324324}
325325
@@ -331,9 +331,9 @@ function tupleToJsonSchema(type: TupleType<any>, ctx?: TypeExportContext): JsonS
331331 items : false ,
332332 prefixItems : types . map ( ( t : any ) => typeToJsonSchema ( t , ctx ) ) ,
333333 } ;
334-
334+
335335 // Add base properties
336336 Object . assign ( result , baseSchema ) ;
337-
337+
338338 return result ;
339- }
339+ }
0 commit comments