Skip to content

Commit a5fb4d9

Browse files
Fix service validation tag metadata (#7509)
fix #5933
1 parent 2f445f7 commit a5fb4d9

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
3+
changeKind: fix
4+
packages:
5+
- "@typespec/openapi"
6+
---
7+
8+
Fix `@tagMetadata` decorator emitting error when incorrectly not finding `@service` decorator

packages/openapi/src/decorators.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
$service,
32
compilerAssert,
43
DecoratorContext,
54
getDoc,
@@ -282,7 +281,13 @@ export const tagMetadataDecorator: TagMetadataDecorator = (
282281
tagMetadata: TagMetadata,
283282
) => {
284283
// Check if the namespace is a service namespace
285-
if (!entity.decorators.some((decorator) => decorator.decorator === $service)) {
284+
if (
285+
!entity.decorators.some(
286+
(decorator) =>
287+
decorator.definition?.name === "@service" &&
288+
decorator.definition?.namespace.name === "TypeSpec",
289+
)
290+
) {
286291
reportDiagnostic(context.program, {
287292
code: "tag-metadata-target-service",
288293
format: {

0 commit comments

Comments
 (0)