Skip to content

Commit

Permalink
Validate @useAuth is unique on node (#2958)
Browse files Browse the repository at this point in the history
fix #2787 

having multiple has no effect, the latest value will override the
previous ones so there is no reason to use `@useAuth` twice on the same
node

---------

Co-authored-by: Brian Terlson <brian.terlson@microsoft.com>
  • Loading branch information
timotheeguerin and bterlson authored Feb 28, 2024
1 parent f884772 commit c9c1f3e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions packages/http/src/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c9c1f3e

Please sign in to comment.