Skip to content

How to customize operationId for a PUT and a PATCH rpc #5506

@saltbo

Description

@saltbo

📚 Documentation

(A clear and concise description of what the issue is.)

I have a rpc method like below, it supports both PUT and PATCH calls. I want to customize the operationId, like below. but the result is there is a repeated operateId in the generated apidocs.swagger.json.

How do I define these two operateIds separately?

  // Update updates a function.
  rpc Update(UpdateFunctionRequest) returns (Function) {
    option (google.api.http) = {
      put: "/api/v1/functions/{id}"
      body: "function"
      additional_bindings: {
        patch: "/api/v1/functions/{id}"
        body: "*"
      }
    };
    option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {operation_id: "updateFunction"};
  }

Image

PS: Duplicate ids will cause failure in client generation

Errors: 
	-attribute paths.'/api/v1/functions/{id}'(patch).operationId is repeated
	at org.openapitools.codegen.config.CodegenConfigurator.toContext(CodegenConfigurator.java:620)
	at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:647)
	at org.openapitools.codegen.cmd.Generate.execute(Generate.java:479)
	at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
	at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions