docs-util: fixes for OAS docs generator + framework typedoc config (#9603)

* fix order replaced in OAS response + framework tsdoc config

* fix for some types
This commit is contained in:
Shahed Nasser
2024-10-16 12:17:28 +03:00
committed by GitHub
parent 714b9e6c98
commit 2b77bd85a6
4 changed files with 60 additions and 47 deletions

View File

@@ -357,7 +357,7 @@ class OasSchemaHelper {
.replace("DTO", "")
.replace(this.schemaRefPrefix, "")
.replace(
/(?<!(AdminProduct|CreateProduct|StoreShippingOption|AdminShippingOption))Type$/,
/(?<!(AdminProduct|CreateProduct|StoreShippingOption|AdminShippingOption|CreateShippingOption))Type$/,
""
)
}

View File

@@ -37,46 +37,6 @@ class SchemaFactory {
BigNumberValue: {
type: "number",
},
expand: {
type: "string",
title: "expand",
description:
"Comma-separated relations that should be expanded in the returned data.",
},
fields: {
type: "string",
title: "fields",
description:
"Comma-separated fields that should be included in the returned data. if a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. without prefix it will replace the entire default fields.",
externalDocs: {
url: "#select-fields-and-relations",
},
},
offset: {
type: "number",
title: "offset",
description: "The number of items to skip when retrieving a list.",
externalDocs: {
url: "#pagination",
},
},
limit: {
type: "number",
title: "limit",
description: "Limit the number of items returned in the list.",
externalDocs: {
url: "#pagination",
},
},
order: {
type: "string",
title: "order",
description:
"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.",
externalDocs: {
url: "#pagination",
},
},
File: {
type: "object",
description: "A File to upload.",
@@ -114,22 +74,34 @@ class SchemaFactory {
title: "fields",
description:
"Comma-separated fields that should be included in the returned data. If a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default fields. Without prefix it will replace the entire default fields.",
externalDocs: {
url: "#select-fields-and-relations",
},
},
offset: {
type: "number",
title: "offset",
description: "The number of items to skip when retrieving a list.",
externalDocs: {
url: "#pagination",
},
},
limit: {
type: "number",
title: "limit",
description: "Limit the number of items returned in the list.",
externalDocs: {
url: "#pagination",
},
},
order: {
type: "string",
title: "order",
description:
"The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.",
externalDocs: {
url: "#pagination",
},
},
}

View File

@@ -2055,8 +2055,49 @@ class OasKindGenerator extends FunctionKindGenerator {
!Object.hasOwn(oldSchemaObj!.properties!, propertyKey)
)
.forEach((newPropertyKey) => {
oldSchemaObj!.properties![newPropertyKey] =
newSchemaObj!.properties![newPropertyKey]
const tryToUpdateSchema = (
schema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject
) => {
let updatedSchema = schema
const newPropertySchemaName = this.oasSchemaHelper.isRefObject(
schema
)
? schema.$ref
: "x-schemaName" in schema
? (schema["x-schemaName"] as string)
: undefined
if (newPropertySchemaName) {
const schemaToUpdate = this.oasSchemaHelper.getSchemaByName(
newPropertySchemaName,
true,
true
)
if (schemaToUpdate) {
updatedSchema =
this.updateSchema({
oldSchema: schemaToUpdate.schema,
newSchema: schema,
level: maybeIncrementLevel(level, "object"),
}) || newProperty
}
}
return updatedSchema
}
let newProperty = newSchemaObj!.properties![newPropertyKey]
if (
!this.oasSchemaHelper.isRefObject(newProperty) &&
newProperty.type === "array"
) {
newProperty.items = tryToUpdateSchema(newProperty.items)
} else {
newProperty = tryToUpdateSchema(newProperty)
}
oldSchemaObj!.properties![newPropertyKey] = newProperty
})
}
} else if (

View File

@@ -1,11 +1,11 @@
{
"$schema": "http://json.schemastore.org/tsconfig",
"extends": [
"../../../../packages/framework/framework/tsconfig.json"
"../../../../packages/core/framework/tsconfig.json"
],
"include": ["../../../../packages/framework/framework/src"],
"include": ["../../../../packages/core/framework/src"],
"exclude": [
"../../../../packages/framework/framework/dist",
"../../../../packages/framework/framework/node_modules"
"../../../../packages/core/framework/dist",
"../../../../packages/core/framework/node_modules"
]
}