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:
@@ -357,7 +357,7 @@ class OasSchemaHelper {
|
|||||||
.replace("DTO", "")
|
.replace("DTO", "")
|
||||||
.replace(this.schemaRefPrefix, "")
|
.replace(this.schemaRefPrefix, "")
|
||||||
.replace(
|
.replace(
|
||||||
/(?<!(AdminProduct|CreateProduct|StoreShippingOption|AdminShippingOption))Type$/,
|
/(?<!(AdminProduct|CreateProduct|StoreShippingOption|AdminShippingOption|CreateShippingOption))Type$/,
|
||||||
""
|
""
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,46 +37,6 @@ class SchemaFactory {
|
|||||||
BigNumberValue: {
|
BigNumberValue: {
|
||||||
type: "number",
|
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: {
|
File: {
|
||||||
type: "object",
|
type: "object",
|
||||||
description: "A File to upload.",
|
description: "A File to upload.",
|
||||||
@@ -114,22 +74,34 @@ class SchemaFactory {
|
|||||||
title: "fields",
|
title: "fields",
|
||||||
description:
|
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.",
|
"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: {
|
offset: {
|
||||||
type: "number",
|
type: "number",
|
||||||
title: "offset",
|
title: "offset",
|
||||||
description: "The number of items to skip when retrieving a list.",
|
description: "The number of items to skip when retrieving a list.",
|
||||||
|
externalDocs: {
|
||||||
|
url: "#pagination",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
limit: {
|
limit: {
|
||||||
type: "number",
|
type: "number",
|
||||||
title: "limit",
|
title: "limit",
|
||||||
description: "Limit the number of items returned in the list.",
|
description: "Limit the number of items returned in the list.",
|
||||||
|
externalDocs: {
|
||||||
|
url: "#pagination",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
order: {
|
order: {
|
||||||
type: "string",
|
type: "string",
|
||||||
title: "order",
|
title: "order",
|
||||||
description:
|
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 `-`.",
|
"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",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2055,8 +2055,49 @@ class OasKindGenerator extends FunctionKindGenerator {
|
|||||||
!Object.hasOwn(oldSchemaObj!.properties!, propertyKey)
|
!Object.hasOwn(oldSchemaObj!.properties!, propertyKey)
|
||||||
)
|
)
|
||||||
.forEach((newPropertyKey) => {
|
.forEach((newPropertyKey) => {
|
||||||
oldSchemaObj!.properties![newPropertyKey] =
|
const tryToUpdateSchema = (
|
||||||
newSchemaObj!.properties![newPropertyKey]
|
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 (
|
} else if (
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"$schema": "http://json.schemastore.org/tsconfig",
|
"$schema": "http://json.schemastore.org/tsconfig",
|
||||||
"extends": [
|
"extends": [
|
||||||
"../../../../packages/framework/framework/tsconfig.json"
|
"../../../../packages/core/framework/tsconfig.json"
|
||||||
],
|
],
|
||||||
"include": ["../../../../packages/framework/framework/src"],
|
"include": ["../../../../packages/core/framework/src"],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"../../../../packages/framework/framework/dist",
|
"../../../../packages/core/framework/dist",
|
||||||
"../../../../packages/framework/framework/node_modules"
|
"../../../../packages/core/framework/node_modules"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user