Skip to content

Commit 81d41e8

Browse files
authored
Merge pull request #167 from seamapi/fix-acs-credentials-list
Fix acs/credentials/list
2 parents 22dcf80 + b82d0c5 commit 81d41e8

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/openapi/flatten-obj-schema.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ type AllOfSchema = any
44
type ObjSchema = any
55
type PrimitiveSchema = any
66
type PropertySchema = any
7+
type ArraySchema = any
78

89
import 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

Comments
 (0)