sudorandom / protoc-gen-connect-openapi

Plugin for generating OpenAPIv3 from protobufs matching the Connect RPC interface
MIT License
103 stars 7 forks source link

generate openapi spec according to the idempotency level #44

Closed castlemilk closed 1 week ago

castlemilk commented 2 weeks ago

from https://connectrpc.com/docs/protocol#summary we see that with the idempotency setting we can inform connect-go of the supported idempotency of an operation, would be cool if we could set the appropriate method of an operation if the idempotency is set to NO_SIDE_EFFECTS for example.

Currently this would be worked around by doing

service PetService {
  rpc ListPets(ListPetRequest) returns (ListPetResponse) {
    option idempotency_level = NO_SIDE_EFFECTS;
    option (google.api.http) = {
      get: "/pets.v1.PetService/ListPets"
    };
    ...
  }
}

But this requires manually managing the path which is managed by connect-go based off package name and service name, so it's somewhat fragile

sudorandom commented 2 weeks ago

@castlemilk Have you seen the allow-get option? This would make a GET path for all methods that have idempotency_level = NO_SIDE_EFFECTS set. There are other details that are different with ConnectRPC GET requests, the biggest being the request being sent in query params.