@@ -14,7 +14,7 @@ import (
1414 "github.com/thoas/go-funk"
1515)
1616
17- const maxJSONTypeSchemaDepth = 4
17+ const DefaultMaxJSONTypeSchemaDepth = 4
1818
1919type structTransformer struct {
2020 table * schema.Table
@@ -29,6 +29,8 @@ type structTransformer struct {
2929 pkFieldsFound []string
3030 pkComponentFields []string
3131 pkComponentFieldsFound []string
32+
33+ maxJSONTypeSchemaDepth int
3234}
3335
3436func isFieldStruct (reflectType reflect.Type ) bool {
@@ -196,6 +198,7 @@ func TransformWithStruct(st any, opts ...StructTransformerOption) schema.Transfo
196198 typeTransformer : DefaultTypeTransformer ,
197199 resolverTransformer : DefaultResolverTransformer ,
198200 ignoreInTestsTransformer : DefaultIgnoreInTestsTransformer ,
201+ maxJSONTypeSchemaDepth : DefaultMaxJSONTypeSchemaDepth ,
199202 }
200203 for _ , opt := range opts {
201204 opt (t )
@@ -294,7 +297,7 @@ func (t *structTransformer) fieldToJSONSchema(field reflect.StructField, depth i
294297 continue
295298 }
296299 // Avoid infinite recursion
297- if columnType == types .ExtensionTypes .JSON && depth < maxJSONTypeSchemaDepth {
300+ if columnType == types .ExtensionTypes .JSON && depth < t . maxJSONTypeSchemaDepth {
298301 fieldsMap [name ] = t .fieldToJSONSchema (structField , depth + 1 )
299302 continue
300303 }
0 commit comments