-
Notifications
You must be signed in to change notification settings - Fork 245
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
how to interpret body in bodyRoot #4815
Comments
Can we have a linter rule to prevent the usage of body in bodyRoot? I wonder if there's a real case that customer has to write their typespec this way? In the above case, the Azure operation template has been changed from |
The azure specs shouldn't use @Body here it has no value and just pass start request |
@qiaozha , do you know the reason for them to declare this way? Why wouldn't it work just using
|
My guess is they want to override the body description, I can double confirm with the service team. But if service team should not use |
@allenjzhang @timotheeguerin Just curious any reason we don't recommand to use it in this way? Personally I like the way to explicitly declare The reason we declare this way is we'd like to change the optionality for body parameter, the body parameter is optional for Back to the question the interpretion is clear for me, with the following case it means the body parameter is
But if we remove the
|
Offline confirmed with above comment, the idea of bodyRoot is just a replacement of body but the former one is allowed to add other query/path/header parameters. So any nesting like bodyRoot with body doesn't make sense if we are not in templates. I'd like to confirm the followings:
|
Per discussion, sample template for the case in question here |
@timotheeguerin What does the |
Playground Link
In this tsp
is the body parameter Test or an anonymous model with a property named body whose type is Test?

the openapi3 emitter result shows the former
but the type graph shows the later?

it's a real case https://github.com/Azure/azure-rest-api-specs/blob/ca4b71ab0e3bb7e4c44b44bf4d84d9c51f7b8264/specification/workloads/Workloads.SAPVirtualInstance.Management/SAPCentralServerInstance.tsp#L61, and seems quite common as azure operation template uses bodyRoot here
https://github.com/Azure/typespec-azure/blob/main/packages/typespec-azure-resource-manager/lib/operations.tsp#L502
According to #2868 (comment) it feels like the former is correct?
The text was updated successfully, but these errors were encountered: