Skip to content

rpc-operation-request-body

Full name
@azure-tools/typespec-azure-core/rpc-operation-request-body

Validates that RpcOperation request bodies are used correctly. Operations using HTTP verbs that do not support a body (like GET or DELETE) should not define one.

GET operation with a request body:

@get
op getWidget is RpcOperation<
{
@body body: Widget;
},
Widget
>;

DELETE operation with a request body:

@delete
op deleteWidget is RpcOperation<
{
@body body: Widget;
},
Widget
>;

GET operation with no body:

@get
op getWidget is RpcOperation<{}, Widget>;

DELETE operation with no body:

@delete
op deleteWidget is RpcOperation<{}, Widget>;

GET/DELETE with query parameters using @bodyIgnore:

@get
op get is RpcOperation<
{
@bodyIgnore options: {
@query foo: string;
};
},
{}
>;

POST operation with a body:

@post
op createWidget is RpcOperation<
{
@body body: Widget;
},
Widget
>;