diff --git a/.chronus/changes/validate-useauth-unique-2024-1-27-17-26-52.md b/.chronus/changes/validate-useauth-unique-2024-1-27-17-26-52.md new file mode 100644 index 0000000000..c76ad570bf --- /dev/null +++ b/.chronus/changes/validate-useauth-unique-2024-1-27-17-26-52.md @@ -0,0 +1,8 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: feature +packages: + - "@typespec/http" +--- + +Validate that only one `@useAuth` decorator is applied to a type. diff --git a/packages/http/src/decorators.ts b/packages/http/src/decorators.ts index 54e37b8892..758f843dc2 100644 --- a/packages/http/src/decorators.ts +++ b/packages/http/src/decorators.ts @@ -436,6 +436,7 @@ export function $useAuth( entity: Namespace | Interface | Operation, authConfig: Model | Union | Tuple ) { + validateDecoratorUniqueOnNode(context, entity, $useAuth); const [auth, diagnostics] = extractAuthentication(context.program, authConfig); if (diagnostics.length > 0) context.program.reportDiagnostics(diagnostics); if (auth !== undefined) {