@@ -33,7 +33,7 @@ function normalize(value: unknown): unknown {
3333 if ( anyOf . length !== schema . anyOf . length ) {
3434 const { anyOf : _ , ...rest } = schema
3535 if ( anyOf . length === 1 && isRecord ( anyOf [ 0 ] ) ) return normalize ( { ...anyOf [ 0 ] , ...rest } )
36- return order ( { ...rest , anyOf } )
36+ return { ...rest , anyOf }
3737 }
3838 }
3939
@@ -43,10 +43,10 @@ function normalize(value: unknown): unknown {
4343 }
4444
4545 if ( schema . type === "integer" && schema . maximum === undefined ) {
46- return order ( { ...schema , maximum : Number . MAX_SAFE_INTEGER } )
46+ return { ...schema , maximum : Number . MAX_SAFE_INTEGER }
4747 }
4848
49- return order ( schema )
49+ return schema
5050}
5151
5252function restoreModelRefs ( value : unknown , key ?: string ) : unknown {
@@ -55,44 +55,9 @@ function restoreModelRefs(value: unknown, key?: string): unknown {
5555
5656 const schema = Object . fromEntries ( Object . entries ( value ) . map ( ( [ name , item ] ) => [ name , restoreModelRefs ( item , name ) ] ) )
5757 if ( ( key === "model" || key === "small_model" ) && schema . type === "string" ) {
58- return order ( { ...schema , $ref : MODEL_REF } )
58+ return { ...schema , $ref : MODEL_REF }
5959 }
60- return order ( schema )
61- }
62-
63- function order ( schema : JsonSchema ) {
64- const result : JsonSchema = { }
65- for ( const key of [
66- "$schema" ,
67- "$ref" ,
68- "type" ,
69- "const" ,
70- "enum" ,
71- "anyOf" ,
72- "properties" ,
73- "required" ,
74- "propertyNames" ,
75- "additionalProperties" ,
76- "items" ,
77- "prefixItems" ,
78- "$defs" ,
79- "minimum" ,
80- "exclusiveMinimum" ,
81- "maximum" ,
82- "exclusiveMaximum" ,
83- "pattern" ,
84- "description" ,
85- "default" ,
86- "examples" ,
87- "allowComments" ,
88- "allowTrailingCommas" ,
89- ] ) {
90- if ( key in schema ) result [ key ] = schema [ key ]
91- }
92- for ( const [ key , value ] of Object . entries ( schema ) ) {
93- if ( ! ( key in result ) ) result [ key ] = value
94- }
95- return result
60+ return schema
9661}
9762
9863function isRecord ( value : unknown ) : value is JsonSchema {
0 commit comments