@@ -4,6 +4,7 @@ type AllOfSchema = any
44type ObjSchema = any
55type PrimitiveSchema = any
66type PropertySchema = any
7+ type ArraySchema = any
78
89import lodash from "lodash"
910
@@ -15,6 +16,9 @@ export const flattenObjSchema = (
1516 | {
1617 oneOf : Array < ObjSchema >
1718 }
19+ | {
20+ allOf : Array < ObjSchema >
21+ }
1822) : ObjSchema => {
1923 if ( "type" in s && s . type === "object" ) return s
2024
@@ -40,6 +44,11 @@ export const flattenObjSchema = (
4044 }
4145 return super_obj as ObjSchema
4246 }
47+
48+ if ( "allOf" in s ) {
49+ return deepFlattenAllOfSchema ( s ) as ObjSchema
50+ }
51+
4352 throw new Error ( `Unknown schema type "${ s . type } "` )
4453}
4554
@@ -58,7 +67,7 @@ export const deepFlattenAllOfSchema = (
5867
5968 const properties : Record < string , PropertySchema [ ] > = { }
6069 const required = new Set < string > ( )
61- const primitives : PrimitiveSchema [ ] = [ ]
70+ const primitives : ( PrimitiveSchema | ArraySchema ) [ ] = [ ]
6271
6372 for ( let subschema of s . allOf ) {
6473 if ( "allOf" in subschema ) {
@@ -69,8 +78,11 @@ export const deepFlattenAllOfSchema = (
6978 }
7079
7180 if ( "oneOf" in subschema ) {
72- console . error ( "oneOf not currently supported when flattening allOf" )
73- continue
81+ subschema = flattenObjSchema (
82+ subschema as {
83+ oneOf : Array < ObjSchema >
84+ }
85+ )
7486 }
7587
7688 if ( "$ref" in subschema ) {
0 commit comments