internal/mcp/protocol: spell "Id" idiomatically

Enhance the generator so that it recognizes initialisms like "Id" and
writes them in all caps, as is idiomatic for Go.

Also, fix the import path of jsonschema in the generated code.

Change-Id: Ib12e9fbd543d360035d5e324f0aefca584ac7c85
Reviewed-on: https://go-review.googlesource.com/c/tools/+/670916
Auto-Submit: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Jonathan Amsterdam 2025-05-08 07:09:48 -04:00 • committed by Gopher Robot
commit 5bcbf820f2

View file

@ -135,7 +135,7 @@ func (c *canceller) Preempt(ctx context.Context, req *jsonrpc2.Request) (result
if err := json.Unmarshal(req.Params, &params); err != nil {
return nil, err
}
id, err := jsonrpc2.MakeID(params.RequestId)
id, err := jsonrpc2.MakeID(params.RequestID)
if err != nil {
return nil, err
}
@ -156,7 +156,7 @@ func call(ctx context.Context, conn *jsonrpc2.Connection, method string, params,
// Notify the peer of cancellation.
err := conn.Notify(xcontext.Detach(ctx), "notifications/cancelled", &protocol.CancelledParams{
Reason: ctx.Err().Error(),
RequestId: call.ID().Raw(),
RequestID: call.ID().Raw(),
})
return errors.Join(ctx.Err(), err)
case err != nil: