microsoft / microsoft/typespec
[Bug]: HTTP should be explicit about incorrect usage of body/bodyRoot (linter, error, or else)
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
### Describe the bug
HTTP do not warn, refuse, or have linter rules about recursively using `body` or `bodyRoot`. It was discussed today with @markcowl and @timotheeguerin that this is not a valid pattern, therefore it's suggested that we refuse it.
This may happen unexpectidely when people are using template. Some template of Azure-core for instance include `bodyRoot`, and any usage of `body` would fall in this situation, and silently do nothing and be confusing for emitters.
It feels to me that HTTP should be explicit about its behavior, and this is not the case today.
### Reproduction
```typescript
@route("bodyRootWithBody")
op bodyRootWithBody(
@bodyRoot _: {
@body body: bytes;
},
): void;
@route("bodyWithBody")
op bodyWithBody(
@body _: {
@body body: bytes;
},
): void;
```
### Checklist
- [x] Follow our [Code of Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md)
- [x] Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- [x] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/Microsoft/typespec/discussions).
- [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
Contributor guide
Assessment
This issue has not been assessed yet.