Skip to content

Commit

Permalink
Merge pull request #167 from seamapi/fix-acs-credentials-list
Browse files Browse the repository at this point in the history
Fix acs/credentials/list
  • Loading branch information
kainpets authored Jun 7, 2024
2 parents 22dcf80 + b82d0c5 commit 81d41e8
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/openapi/flatten-obj-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ type AllOfSchema = any
type ObjSchema = any
type PrimitiveSchema = any
type PropertySchema = any
type ArraySchema = any

import lodash from "lodash"

Expand All @@ -15,6 +16,9 @@ export const flattenObjSchema = (
| {
oneOf: Array<ObjSchema>
}
| {
allOf: Array<ObjSchema>
}
): ObjSchema => {
if ("type" in s && s.type === "object") return s

Expand All @@ -40,6 +44,11 @@ export const flattenObjSchema = (
}
return super_obj as ObjSchema
}

if ("allOf" in s) {
return deepFlattenAllOfSchema(s) as ObjSchema
}

throw new Error(`Unknown schema type "${s.type}"`)
}

Expand All @@ -58,7 +67,7 @@ export const deepFlattenAllOfSchema = (

const properties: Record<string, PropertySchema[]> = {}
const required = new Set<string>()
const primitives: PrimitiveSchema[] = []
const primitives: (PrimitiveSchema | ArraySchema)[] = []

for (let subschema of s.allOf) {
if ("allOf" in subschema) {
Expand All @@ -69,8 +78,11 @@ export const deepFlattenAllOfSchema = (
}

if ("oneOf" in subschema) {
console.error("oneOf not currently supported when flattening allOf")
continue
subschema = flattenObjSchema(
subschema as {
oneOf: Array<ObjSchema>
}
)
}

if ("$ref" in subschema) {
Expand Down

0 comments on commit 81d41e8

Please sign in to comment.