microsoft / microsoft/typespec

Define clone/transform template heuristics

Open
#7,572 0 comments 0 reactions 0 assignees View on GitHub
compiler:core design:needed triaged:core
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

Right now we have a few templates that have the purpose of transforming types in various ways. We are however not consistent on their behavior
- recursiveness
- handling of model extends
- naming of the transformed type

For example [Playground](https://cadlplayground.z22.web.core.windows.net/?c=aW1wb3J0ICJAdHlwZXNwZWMvaHR0cCI7DQoNCnVzaW5nIEh0dHDFD21vZGVsIFBhcmVudCB7DQogIGE6IHN0cmluZzsgLy8gV2hlcmUgZGlkIEkgZ28%2FDQp9yjZGb28gZXh0ZW5kc81CYslCzS9UZXPHIS8vIEZsYXR0ZW5lZMdzQ3JlYXRlPEZvbywgIntuYW1lfcYTIj47xzNKdXN0IGRyb3BwxjZiOiBNZXJnZVBhdGNoVXBk0EDKHcVEfQ0K&e=%40typespec%2Fopenapi3&options=%7B%7D)
- `Create` will flatten base models properties
- `MergePatch` will just drop the base model reference without anything(Sounds just like a bug)
- `OmitMetadata/StripMetadata` has the same bug as above (not sure what approach yet we should take hence this issue)

Leaning towards:
- If template is acting recursively it should keep everything
- If template is limited to the type itself then flattening should probably happen `Pick`, `Omit`

Do we need a naming convention for a template that transform recursively vs not. Should recurisve template given an option to apply once

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.