Support metadata parameters in body models and use methodParameterSegments for accessor paths#3848
Merged
JialinHuang803 merged 11 commits intoAzure:mainfrom Apr 1, 2026
Conversation
- Keep @header/@query/@path metadata properties in model interfaces for input models while filtering them for output/exception models - Use TCGC methodParameterSegments to build correct property accessor paths for grouped/nested parameters (getMethodParamExpr) - Refactor getOptional, getRequired, getPathParamExpr, buildHeaderParameter to use the new accessor logic - Add ARM resource model workaround for inherited @path name property - Add unit tests for override group parameters and body metadata extraction - Update generated smoke test code to reflect metadata property additions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
cab2711 to
904fae6
Compare
99eccef to
e12fd76
Compare
qiaozha
reviewed
Mar 31, 2026
qiaozha
reviewed
Mar 31, 2026
| @@ -0,0 +1,497 @@ | |||
| # Should extract header and query from bodyRoot model containing header and query metadata | |||
Member
There was a problem hiding this comment.
wonder if you could add some test cases where the property has been moved to client via @clientLocation parameter.
Member
Author
There was a problem hiding this comment.
This case is not supported yet and we couldn't get sufficient information from TCGC. There is no spector test case for it as well. I think we can put it as low priority since there is no real case from services.
qiaozha
approved these changes
Apr 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two issues in the Modular emitter prevented correct handling of body models containing metadata properties (
@header,@query,@path):emitModels.ts: TheisMetadata()filter unconditionally removed all metadata properties from model interfaces. When a body model contains@headeror@queryproperties, these were stripped from the generated interface — making it impossible for users to pass those values.operationHelpers.ts: Parameter accessor paths were built using bareparam.nameinstead of walking TCGC'smethodParameterSegments. This produced incorrect code when parameters are nested inside body models or grouped via@@override.As a result, the
@@overridedecorator's group parameters feature (issue #3540) is also resolved, since grouping@query/@headerparams into a model is a specific case of metadata properties in a body model.Fix
emitModels.ts
@path nameproperty (handled by ARM infrastructure)isArmResourceModel()helper to detect ARM resource base types by walking ancestor chainoperationHelpers.ts
getMethodParamExpr()to build property accessor expressions frommethodParameterSegmentsgetParamAccessor()as a unified entry point for resolving parameter accessor paths (client-level, method-level with segments, or fallback)getOptional,getRequired,getPathParamExpr,buildHeaderParameter,getCollectionFormatForParamto use the newparamAccessorstring instead of reconstructing paths fromoptionalParamName+param.nameoptions?.prefix on required body params)options?.paraminstead ofoptions["param"]Tests
@@override" unit testbodyMetadataExtractionunit test scenarios:@header+@queryin@bodyRootmodel@pathin body model@header+@queryin@bodyRootmodel@pathin body model@header+@querymetadataFixes #3540