Skip to content

Commit

Permalink
Properly exclude operation templates when scanning for routes
Browse files Browse the repository at this point in the history
  • Loading branch information
daviwil committed Jun 8, 2022
1 parent 18178c9 commit a1388d5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@cadl-lang/rest",
"comment": "Properly exclude operation templates when scanning for routes",
"type": "patch"
}
],
"packageName": "@cadl-lang/rest"
}
7 changes: 6 additions & 1 deletion packages/rest/src/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ function buildRoutes(
}

// Skip templated operations
if (op.templateArguments && op.templateArguments.length > 0) {
if (isUninstantiatedTemplateOperation(op)) {
continue;
}

Expand Down Expand Up @@ -482,6 +482,11 @@ function isUninstantiatedTemplateInterface(maybeInterface: Type): boolean {
);
}

function isUninstantiatedTemplateOperation(maybeOperation: Type): boolean {
// Any operation statement with template parameters is inherently uninstantiated
return maybeOperation.kind === "Operation" && maybeOperation.node.templateParameters.length > 0;
}

export function getAllRoutes(
program: Program,
options?: RouteOptions
Expand Down

0 comments on commit a1388d5

Please sign in to comment.