Skip to content

fix(@typespec/openapi): Report invalid-extension-key error on the offending property name, not the decorator argument#10772

Closed
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-tagmetadata-custom-property-error
Closed

fix(@typespec/openapi): Report invalid-extension-key error on the offending property name, not the decorator argument#10772
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-tagmetadata-custom-property-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 22, 2026

When using @tagMetadata with a custom property missing the x- prefix, the invalid-extension-key diagnostic was reported at the wrong location — pointing to the tag name argument instead of the invalid property.

@service
@tagMetadata("ab", #{ custom: "Abc"})  // error was on "ab", should be on `custom`
namespace Test;

Changes

  • helpers.tscheckNoAdditionalProperties now accepts an optional ObjectLiteralNode and resolves the specific ObjectLiteralPropertyNode by name, using its id identifier node as the diagnostic target. For nested model properties, the inner ObjectLiteralNode is threaded through recursive calls. validateAdditionalInfoModel gains a corresponding optional node parameter.

  • decorators.tstagMetadataDecorator was incorrectly using getArgumentTarget(0) (the tag name string) for all tagMetadata validations; fixed to getArgumentTarget(1) and now passes the resolved ObjectLiteralNode for precise targeting. Same improvement applied to $info.

  • Tests — Added two position-sensitive tests using extractSquiggles that assert the diagnostic lands exactly on the invalid property name identifier, both at the root level and within nested objects (e.g., externalDocs). Added PlainTester to the test host for position-sensitive tests that need full control over the compiled source.

Copilot AI and others added 2 commits May 22, 2026 14:26
…in tagMetadata

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
…ve tests

Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/7d85b014-4b8c-4414-a8ac-386bc72e5a02

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix tagMetadata custom property placement error fix(@typespec/openapi): Report invalid-extension-key error on the offending property name, not the decorator argument May 22, 2026
Copilot AI requested a review from timotheeguerin May 22, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tagMetadata custom property without x report error on wrong location

2 participants