Skip to content

Support metadata parameters in body models and use methodParameterSegments for accessor paths#3848

Open
JialinHuang803 wants to merge 1 commit intoAzure:mainfrom
JialinHuang803:fix/override-group-parameters
Open

Support metadata parameters in body models and use methodParameterSegments for accessor paths#3848
JialinHuang803 wants to merge 1 commit intoAzure:mainfrom
JialinHuang803:fix/override-group-parameters

Conversation

@JialinHuang803
Copy link
Member

@JialinHuang803 JialinHuang803 commented Mar 17, 2026

Problem

Two issues in the Modular emitter prevented correct handling of body models containing metadata properties (@header, @query, @path):

  1. emitModels.ts: The isMetadata() filter unconditionally removed all metadata properties from model interfaces. When a body model contains @header or @query properties, these were stripped from the generated interface — making it impossible for users to pass those values.

  2. operationHelpers.ts: Parameter accessor paths were built using bare param.name instead of walking TCGC's methodParameterSegments. This produced incorrect code when parameters are nested inside body models or grouped via @@override.

As a result, the @@override decorator's group parameters feature (issue #3540) is also resolved, since grouping @query/@header params into a model is a specific case of metadata properties in a body model.

Fix

emitModels.ts

  • Conditionally keep metadata properties for input models (users need to pass these values)
  • Filter metadata for output/exception models (deserialized separately via response headers)
  • Add ARM resource model workaround: skip inherited @path name property (handled by ARM infrastructure)

operationHelpers.ts

  • Add getMethodParamExpr() to build property accessor expressions from methodParameterSegments
  • Refactor getOptional, getRequired, getPathParamExpr, buildHeaderParameter to use the new accessor logic
  • Handle required vs optional method params correctly (no spurious options?. prefix on required body params)

Tests

  • Unskipped "Should handle parameter grouping when using @@override" unit test
  • Added 4 new bodyMetadataExtraction unit tests (required/optional x header/path in body models)
  • All 23 targeted unit tests passing

Fixes #3540

- 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>
@JialinHuang803 JialinHuang803 force-pushed the fix/override-group-parameters branch from cab2711 to 904fae6 Compare March 17, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[modular] @override group is not supported yet.

1 participant