chore(oas): clean up oas (#9354)

* clean up generated oas

* fix issues in docs-util

* more fixes

* align max level

* validation fix

* add missing summaries

* fix validation

* fix exchanges route
This commit is contained in:
Shahed Nasser
2024-10-02 10:27:02 +03:00
committed by GitHub
parent 13a3c1bd77
commit 1e144e9c08
83 changed files with 2709 additions and 640 deletions
@@ -1391,31 +1391,33 @@ class OasKindGenerator extends FunctionKindGenerator {
case itemType.isUnion():
// if it's a union of literal types,
// consider it an enum
const allLiteral = (itemType as ts.UnionType).types.every((unionType) =>
const cleanedUpTypes = this.typesHelper.cleanUpTypes(
(itemType as ts.UnionType).types
)
const allLiteral = cleanedUpTypes.every((unionType) =>
unionType.isLiteral()
)
if (allLiteral) {
return {
type: "string",
description,
enum: (itemType as ts.UnionType).types.map(
enum: cleanedUpTypes.map(
(unionType) => (unionType as ts.LiteralType).value
),
}
}
const oneOfItems = this.typesHelper
.cleanUpTypes((itemType as ts.UnionType).types)
.map((unionType) =>
this.typeToSchema({
itemType: unionType,
level: maybeIncrementLevel(level, "oneOf"),
title,
descriptionOptions,
saveSchema,
...rest,
})
)
const oneOfItems = cleanedUpTypes.map((unionType) =>
this.typeToSchema({
itemType: unionType,
level: maybeIncrementLevel(level, "oneOf"),
title,
descriptionOptions,
saveSchema,
...rest,
})
)
if (oneOfItems.length === 1) {
return oneOfItems[0]
@@ -1967,7 +1969,7 @@ class OasKindGenerator extends FunctionKindGenerator {
if (!oldSchemaObj && newSchemaObj) {
return newSchemaObj
} else if (!newSchemaObj || !Object.keys(newSchemaObj)) {
} else if (!newSchemaObj || !Object.keys(newSchemaObj).length) {
return undefined
}