Support metadata parameters in body models and use methodParameterSegments for accessor paths#3848
Open
JialinHuang803 wants to merge 1 commit intoAzure:mainfrom
Open
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
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)operationHelpers.ts
getMethodParamExpr()to build property accessor expressions frommethodParameterSegmentsgetOptional,getRequired,getPathParamExpr,buildHeaderParameterto use the new accessor logicoptions?.prefix on required body params)Tests
@@override" unit testbodyMetadataExtractionunit tests (required/optional x header/path in body models)Fixes #3540