docs-util: fix workflows not picked for some routes + generate OAS (#13342)
* generated oas * fixes and improvements
This commit is contained in:
@@ -364,7 +364,7 @@ class OasSchemaHelper {
|
||||
.replace("DTO", "")
|
||||
.replace(this.schemaRefPrefix, "")
|
||||
.replace(
|
||||
/(?<!(AdminProduct|CreateProduct|UpdateProduct|StoreShippingOption|AdminShippingOption|CreateShippingOption|BaseProduct|StoreProduct))Type$/,
|
||||
/(?<!(AdminProduct|CreateProduct|UpdateProduct|StoreShippingOption|AdminShippingOption|CreateShippingOption|BaseProduct|StoreProduct|AdminCreateShippingOption|AdminUpdateShippingOption))Type$/,
|
||||
""
|
||||
)
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ class DefaultKindGenerator<T extends ts.Node = ts.Node> {
|
||||
* @returns {boolean} Whether this generator can be used with the specified node.
|
||||
*/
|
||||
isAllowed(node: ts.Node): node is T {
|
||||
return this.allowedKinds.includes(node.kind)
|
||||
return !this.isIgnored(node) && this.allowedKinds.includes(node.kind)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -638,6 +638,18 @@ class DefaultKindGenerator<T extends ts.Node = ts.Node> {
|
||||
featureFlagTag,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a node is ignored.
|
||||
*
|
||||
* @param node - The node to check.
|
||||
* @returns Whether the node is ignored.
|
||||
*/
|
||||
isIgnored(node: ts.Node): boolean {
|
||||
return ts
|
||||
.getJSDocTags(node)
|
||||
.some((tag) => tag.tagName.getText() === "ignore")
|
||||
}
|
||||
}
|
||||
|
||||
export default DefaultKindGenerator
|
||||
|
||||
@@ -203,6 +203,10 @@ class OasKindGenerator extends FunctionKindGenerator {
|
||||
return false
|
||||
}
|
||||
|
||||
if (this.isIgnored(functionNode)) {
|
||||
return false
|
||||
}
|
||||
|
||||
const hasCorrectRequestType = this.REQUEST_TYPE_NAMES.some(
|
||||
(name) => functionNode.parameters[0].type?.getText().startsWith(name)
|
||||
)
|
||||
@@ -2653,9 +2657,16 @@ class OasKindGenerator extends FunctionKindGenerator {
|
||||
if (
|
||||
fnText.includes(`${workflowName}(`) ||
|
||||
fnText.includes(`${workflowName} (`) ||
|
||||
fnText.includes(`${workflowName}.`)
|
||||
fnText.includes(`${workflowName}.`) ||
|
||||
fnText.includes(`we.run(${workflowName}`) ||
|
||||
fnText.includes(`we.run (${workflowName}`) ||
|
||||
fnText.includes(`we.run(
|
||||
${workflowName}
|
||||
)`)
|
||||
) {
|
||||
workflow = workflowName
|
||||
// workaround for API routes that execute a workflow
|
||||
// by its ID. Not very smart but will do for now.
|
||||
workflow = workflowName.replace(/Id$/, "")
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user