Skip to content

Add OmitMetadata, StripMetadata and pass metadata properties through in MergePatch #7551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

timotheeguerin
Copy link
Member

Progress for #7279

Copy link
Contributor

github-actions bot commented Jun 4, 2025

All changed packages have been documented.

  • @typespec/compiler
  • @typespec/http
Show changes

@typespec/http - fix ✏️

MergePatch templates now allow models with metadata properties to be used as input. Those properties will be ignored(passed through as it is)

@typespec/http - fix ✏️

Added new templates: ,> - OmitMetadata: Omit metadata properties recursively,> - StripMetadata: Strip metadata annotations recursively

@typespec/compiler - fix ✏️

Relax is-model constraint to allow unnamed models to be used.

@azure-sdk
Copy link
Collaborator

azure-sdk commented Jun 4, 2025

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@timotheeguerin timotheeguerin marked this pull request as ready for review June 6, 2025 16:01
Copy link
Contributor

@markcowl markcowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a couple of questions

* ```
*/
@Private.omitMetadata(T, NameTemplate)
model OmitMetadata<T extends Reflection.Model, NameTemplate extends valueof string = ""> {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we should have a filtering mechanism here, where the choices are, at least 'requestMetadata' 'responseMetadata' and 'all'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although, I think 'all' is the right default, so maybe we can leave this until additional flexibility is asked for

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah just not sure what exactly we should allow to filter. I think it for example make sense to filter per type as well "query"

@@ -67,6 +87,8 @@ export type TypeSpecHttpPrivateDecorators = {
httpFile: HttpFileDecorator;
httpPart: HttpPartDecorator;
applyMergePatch: ApplyMergePatchDecorator;
omitMetadata: OmitMetadataDecorator;
stripMetadata: StripMetadataDecorator;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, not sure about 'stripMetadata' I wonder if we should be more explicit, as in 'RemoveMetadataProperties' and 'RemoveMetadataDecorators'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that it would also be nice to have a PickMetadataProperties or the like that returns only the metadata properties, but this is not as important as the other two.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that one I think is a bit more tricky with nested metadata. Does it flatten it or keep the structure and then what does that mean for the envelope does it need to add @bodyIgnore on it?

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.

3 participants