Skip to content

Commit

Permalink
Validate @useAuth is unique on node (microsoft#2958)
Browse files Browse the repository at this point in the history
fix microsoft#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 <[email protected]>
  • Loading branch information
2 people authored and markcowl committed Mar 8, 2024
1 parent ef13f8f commit bd50004
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 bd50004

Please sign in to comment.