Repository: grpc-ecosystem/grpc-gateway Branch: main Commit: f3f1b599a6e0 Files: 549 Total size: 5.8 MB Directory structure: gitextract_hqbjs28v/ ├── .bazelci/ │ └── presubmit.yml ├── .bazelrc ├── .bazelversion ├── .devcontainer/ │ └── devcontainer.json ├── .git-blame-ignore-revs ├── .github/ │ ├── Dockerfile │ ├── ISSUE_TEMPLATE/ │ │ ├── bug.md │ │ ├── documentation.md │ │ └── feature.md │ ├── ISSUE_TEMPLATE.md │ ├── PULL_REQUEST_TEMPLATE.md │ ├── README_GITHUB.md │ ├── dependabot.yml │ ├── stale.yml │ └── workflows/ │ ├── ci.yml │ ├── devcontainer.yml │ ├── release.yml │ └── renovate.yml ├── .gitignore ├── .goreleaser.yml ├── ADOPTERS.md ├── BUILD.bazel ├── CONTRIBUTING.md ├── LICENSE ├── MODULE.bazel ├── Makefile ├── README.md ├── WORKSPACE ├── bin/ │ └── .gitignore ├── buf.gen.yaml ├── buf.yaml ├── docs/ │ ├── .gitignore │ ├── Gemfile │ ├── _config.yml │ ├── _layouts/ │ │ └── default.html │ ├── docs/ │ │ ├── contributing/ │ │ │ ├── 2020_season_of_docs.md │ │ │ ├── getting_started.md │ │ │ └── index.md │ │ ├── development/ │ │ │ ├── grpc-gateway_v2_migration_guide.md │ │ │ ├── index.md │ │ │ └── installation_for_cygwin.md │ │ ├── faq.md │ │ ├── mapping/ │ │ │ ├── binary_file_uploads.md │ │ │ ├── custom_marshalers.md │ │ │ ├── customizing_openapi_output.md │ │ │ ├── customizing_your_gateway.md │ │ │ ├── examples.md │ │ │ ├── grpc_api_configuration.md │ │ │ ├── httpbody_messages.md │ │ │ ├── index.md │ │ │ ├── patch_feature.md │ │ │ └── using_ref_with_responses.md │ │ ├── operations/ │ │ │ ├── annotated_context.md │ │ │ ├── aws_gateway_integration.md │ │ │ ├── health_check.md │ │ │ ├── index.md │ │ │ ├── inject_router.md │ │ │ ├── logging.md │ │ │ └── tracing.md │ │ ├── overview/ │ │ │ ├── background.md │ │ │ ├── index.md │ │ │ └── usage.md │ │ ├── related_projects.md │ │ ├── tutorials/ │ │ │ ├── adding_annotations.md │ │ │ ├── creating_main.go.md │ │ │ ├── generating_stubs/ │ │ │ │ ├── index.md │ │ │ │ ├── using_buf.md │ │ │ │ └── using_protoc.md │ │ │ ├── index.md │ │ │ ├── introduction.md │ │ │ ├── learn_more.md │ │ │ └── simple_hello_world.md │ │ └── using_custom_query_parser.md │ ├── index.md │ └── run.sh ├── examples/ │ └── internal/ │ ├── README.md │ ├── browser/ │ │ ├── .gitignore │ │ ├── README.md │ │ ├── a_bit_of_everything_service.spec.js │ │ ├── bin/ │ │ │ └── .gitignore │ │ ├── bower.json │ │ ├── echo_service.spec.js │ │ ├── gulpfile.js │ │ ├── index.html │ │ ├── package.json │ │ ├── spec/ │ │ │ └── support/ │ │ │ └── jasmine-browser.json │ │ └── webpack.config.js │ ├── clients/ │ │ ├── abe/ │ │ │ ├── .gitignore │ │ │ ├── .swagger-codegen/ │ │ │ │ └── VERSION │ │ │ ├── .swagger-codegen-ignore │ │ │ ├── BUILD.bazel │ │ │ ├── api/ │ │ │ │ └── swagger.yaml │ │ │ ├── api_a_bit_of_everything.go │ │ │ ├── api_camel_case_service_name.go │ │ │ ├── api_echo_rpc.go │ │ │ ├── api_snake_enum_service.go │ │ │ ├── client.go │ │ │ ├── configuration.go │ │ │ ├── enum_helper.go │ │ │ ├── model_a_bit_of_everything.go │ │ │ ├── model_a_bit_of_everything_1.go │ │ │ ├── model_a_bit_of_everything_2.go │ │ │ ├── model_a_bit_of_everything_3.go │ │ │ ├── model_a_bit_of_everything_4.go │ │ │ ├── model_a_bit_of_everything_5.go │ │ │ ├── model_a_bit_of_everything_6.go │ │ │ ├── model_a_bit_of_everything_7.go │ │ │ ├── model_a_bit_of_everything_8.go │ │ │ ├── model_a_bit_of_everything_nested.go │ │ │ ├── model_a_bit_of_everything_service_deep_path_echo_body.go │ │ │ ├── model_a_bit_of_everything_service_deep_path_echo_body_single_nested.go │ │ │ ├── model_a_bit_of_everything_service_post_with_empty_body_body.go │ │ │ ├── model_a_bit_of_everything_service_update_body.go │ │ │ ├── model_a_bit_of_everything_service_update_v2_body.go │ │ │ ├── model_book.go │ │ │ ├── model_examplepb_a_bit_of_everything.go │ │ │ ├── model_examplepb_a_bit_of_everything_repeated.go │ │ │ ├── model_examplepb_a_bit_of_everything_service_update_body.go │ │ │ ├── model_examplepb_bar.go │ │ │ ├── model_examplepb_body.go │ │ │ ├── model_examplepb_book.go │ │ │ ├── model_examplepb_check_status_response.go │ │ │ ├── model_examplepb_error_object.go │ │ │ ├── model_examplepb_error_response.go │ │ │ ├── model_examplepb_numeric_enum.go │ │ │ ├── model_examplepb_required_message_type_request.go │ │ │ ├── model_examplepb_snake_case_0_enum.go │ │ │ ├── model_examplepb_snake_case_enum.go │ │ │ ├── model_examplepb_snake_enum_response.go │ │ │ ├── model_google_rpc_status.go │ │ │ ├── model_message_path_enum_nested_path_enum.go │ │ │ ├── model_nested_deep_enum.go │ │ │ ├── model_oneofenum_example_enum.go │ │ │ ├── model_pathenum_path_enum.go │ │ │ ├── model_pathenum_snake_case_for_import.go │ │ │ ├── model_proto_examplepb_foo.go │ │ │ ├── model_protobuf_any.go │ │ │ ├── model_sub_string_message.go │ │ │ ├── model_the_book_to_update_.go │ │ │ ├── model_the_book_to_update__1.go │ │ │ ├── model_the_book_to_update_the_books_name_field_is_used_to_identify_the_book_to_be_updated_format_publisherspublisherbooksbook.go │ │ │ ├── model_update_v2_request_request_for_update_includes_the_message_and_the_update_mask.go │ │ │ ├── model_update_v2_request_request_for_update_includes_the_message_and_the_update_mask_1.go │ │ │ ├── model_v1exampledeep_pathsingle_nested_name_single_nested.go │ │ │ └── response.go │ │ ├── echo/ │ │ │ ├── .gitignore │ │ │ ├── .swagger-codegen/ │ │ │ │ └── VERSION │ │ │ ├── .swagger-codegen-ignore │ │ │ ├── BUILD.bazel │ │ │ ├── api/ │ │ │ │ └── swagger.yaml │ │ │ ├── api_echo_service.go │ │ │ ├── client.go │ │ │ ├── configuration.go │ │ │ ├── model_examplepb_dynamic_message.go │ │ │ ├── model_examplepb_dynamic_message_update.go │ │ │ ├── model_examplepb_embedded.go │ │ │ ├── model_examplepb_nested_message.go │ │ │ ├── model_examplepb_simple_message.go │ │ │ ├── model_examplepb_status_check_request.go │ │ │ ├── model_examplepb_status_check_response.go │ │ │ ├── model_google_rpc_status.go │ │ │ ├── model_proto_sub2_status.go │ │ │ ├── model_proto_sub_status.go │ │ │ ├── model_protobuf_any.go │ │ │ ├── model_protobuf_null_value.go │ │ │ └── response.go │ │ ├── generateunboundmethods/ │ │ │ ├── .gitignore │ │ │ ├── .swagger-codegen/ │ │ │ │ └── VERSION │ │ │ ├── .swagger-codegen-ignore │ │ │ ├── BUILD.bazel │ │ │ ├── api/ │ │ │ │ └── swagger.yaml │ │ │ ├── api_generate_unbound_methods_echo_service.go │ │ │ ├── client.go │ │ │ ├── configuration.go │ │ │ ├── docs/ │ │ │ │ ├── ExamplepbGenerateUnboundMethodsSimpleMessage.md │ │ │ │ ├── GenerateUnboundMethodsEchoServiceApi.md │ │ │ │ ├── ProtobufAny.md │ │ │ │ └── RuntimeError.md │ │ │ ├── model_examplepb_generate_unbound_methods_simple_message.go │ │ │ ├── model_protobuf_any.go │ │ │ ├── model_rpc_status.go │ │ │ ├── model_runtime_error.go │ │ │ └── response.go │ │ ├── responsebody/ │ │ │ ├── .gitignore │ │ │ ├── .swagger-codegen/ │ │ │ │ └── VERSION │ │ │ ├── .swagger-codegen-ignore │ │ │ ├── BUILD.bazel │ │ │ ├── api/ │ │ │ │ └── swagger.yaml │ │ │ ├── api_response_body_service.go │ │ │ ├── client.go │ │ │ ├── configuration.go │ │ │ ├── docs/ │ │ │ │ ├── ExamplepbRepeatedResponseBodyOut.md │ │ │ │ ├── ExamplepbRepeatedResponseBodyOutResponse.md │ │ │ │ ├── ExamplepbRepeatedResponseStrings.md │ │ │ │ ├── ExamplepbResponseBodyMessage.md │ │ │ │ ├── ExamplepbResponseBodyMessageResponse.md │ │ │ │ ├── ExamplepbResponseBodyOut.md │ │ │ │ ├── ExamplepbResponseBodyOutResponse.md │ │ │ │ ├── ExamplepbResponseBodyReq.md │ │ │ │ ├── ExamplepbResponseBodyValue.md │ │ │ │ ├── GoogleRpcStatus.md │ │ │ │ ├── ProtobufAny.md │ │ │ │ ├── ResponseBodyServiceApi.md │ │ │ │ ├── ResponseResponseType.md │ │ │ │ ├── RpcStatus.md │ │ │ │ ├── RuntimeError.md │ │ │ │ └── StreamResultOfExamplepbResponseBodyOut.md │ │ │ ├── model_examplepb_repeated_response_body_out.go │ │ │ ├── model_examplepb_repeated_response_body_out_response.go │ │ │ ├── model_examplepb_repeated_response_strings.go │ │ │ ├── model_examplepb_response_body_out.go │ │ │ ├── model_examplepb_response_body_out_response.go │ │ │ ├── model_examplepb_response_body_value.go │ │ │ ├── model_google_rpc_status.go │ │ │ ├── model_protobuf_any.go │ │ │ ├── model_response_response_type.go │ │ │ ├── model_stream_result_of_examplepb_response_body_out.go │ │ │ └── response.go │ │ ├── staticcheck.conf │ │ └── unannotatedecho/ │ │ ├── .gitignore │ │ ├── .swagger-codegen/ │ │ │ └── VERSION │ │ ├── .swagger-codegen-ignore │ │ ├── BUILD.bazel │ │ ├── api/ │ │ │ └── swagger.yaml │ │ ├── api_unannotated_echo_service.go │ │ ├── client.go │ │ ├── configuration.go │ │ ├── model_examplepb_numeric_enum.go │ │ ├── model_examplepb_unannotated_embedded.go │ │ ├── model_examplepb_unannotated_nested_message.go │ │ ├── model_examplepb_unannotated_simple_message.go │ │ ├── model_protobuf_any.go │ │ ├── model_rpc_status.go │ │ └── response.go │ ├── cmd/ │ │ ├── example-gateway-server/ │ │ │ ├── BUILD.bazel │ │ │ └── main.go │ │ └── example-grpc-server/ │ │ ├── BUILD.bazel │ │ └── main.go │ ├── gateway/ │ │ ├── BUILD.bazel │ │ ├── doc.go │ │ ├── gateway.go │ │ ├── handlers.go │ │ └── main.go │ ├── helloworld/ │ │ ├── BUILD.bazel │ │ ├── helloworld.pb.go │ │ ├── helloworld.pb.gw.go │ │ ├── helloworld.proto │ │ ├── helloworld.swagger.json │ │ └── helloworld_grpc.pb.go │ ├── integration/ │ │ ├── BUILD.bazel │ │ ├── client_test.go │ │ ├── integration_test.go │ │ └── main_test.go │ ├── proto/ │ │ ├── examplepb/ │ │ │ ├── BUILD.bazel │ │ │ ├── a_bit_of_everything.pb.go │ │ │ ├── a_bit_of_everything.pb.gw.go │ │ │ ├── a_bit_of_everything.proto │ │ │ ├── a_bit_of_everything.swagger.json │ │ │ ├── a_bit_of_everything_grpc.pb.go │ │ │ ├── camel_case_service.pb.go │ │ │ ├── camel_case_service.pb.gw.go │ │ │ ├── camel_case_service.proto │ │ │ ├── camel_case_service.swagger.json │ │ │ ├── camel_case_service_grpc.pb.go │ │ │ ├── echo_service.pb.go │ │ │ ├── echo_service.pb.gw.go │ │ │ ├── echo_service.proto │ │ │ ├── echo_service.swagger.json │ │ │ ├── echo_service_grpc.pb.go │ │ │ ├── enum_with_single_value.buf.gen.yaml │ │ │ ├── enum_with_single_value.pb.go │ │ │ ├── enum_with_single_value.pb.gw.go │ │ │ ├── enum_with_single_value.proto │ │ │ ├── enum_with_single_value.swagger.json │ │ │ ├── enum_with_single_value_grpc.pb.go │ │ │ ├── excess_body.pb.go │ │ │ ├── excess_body.pb.gw.go │ │ │ ├── excess_body.proto │ │ │ ├── excess_body.swagger.json │ │ │ ├── excess_body_grpc.pb.go │ │ │ ├── flow_combination.pb.go │ │ │ ├── flow_combination.pb.gw.go │ │ │ ├── flow_combination.proto │ │ │ ├── flow_combination.swagger.json │ │ │ ├── flow_combination_grpc.pb.go │ │ │ ├── generate_unbound_methods.buf.gen.yaml │ │ │ ├── generate_unbound_methods.pb.go │ │ │ ├── generate_unbound_methods.pb.gw.go │ │ │ ├── generate_unbound_methods.proto │ │ │ ├── generate_unbound_methods.swagger.json │ │ │ ├── generate_unbound_methods_grpc.pb.go │ │ │ ├── generated_input.proto │ │ │ ├── generated_input.swagger.json │ │ │ ├── ignore_comment.buf.gen.yaml │ │ │ ├── ignore_comment.pb.go │ │ │ ├── ignore_comment.pb.gw.go │ │ │ ├── ignore_comment.proto │ │ │ ├── ignore_comment.swagger.json │ │ │ ├── ignore_comment_grpc.pb.go │ │ │ ├── non_standard_names.pb.go │ │ │ ├── non_standard_names.pb.gw.go │ │ │ ├── non_standard_names.proto │ │ │ ├── non_standard_names.swagger.json │ │ │ ├── non_standard_names_grpc.pb.go │ │ │ ├── opaque.buf.gen.yaml │ │ │ ├── opaque.pb.go │ │ │ ├── opaque.pb.gw.go │ │ │ ├── opaque.proto │ │ │ ├── opaque.swagger.json │ │ │ ├── opaque_grpc.pb.go │ │ │ ├── openapi_merge.buf.gen.yaml │ │ │ ├── openapi_merge.swagger.json │ │ │ ├── openapi_merge_a.pb.go │ │ │ ├── openapi_merge_a.pb.gw.go │ │ │ ├── openapi_merge_a.proto │ │ │ ├── openapi_merge_a.swagger.json │ │ │ ├── openapi_merge_a_grpc.pb.go │ │ │ ├── openapi_merge_b.pb.go │ │ │ ├── openapi_merge_b.pb.gw.go │ │ │ ├── openapi_merge_b.proto │ │ │ ├── openapi_merge_b.swagger.json │ │ │ ├── openapi_merge_b_grpc.pb.go │ │ │ ├── proto3_field_semantics.buf.gen.yaml │ │ │ ├── proto3_field_semantics.pb.go │ │ │ ├── proto3_field_semantics.pb.gw.go │ │ │ ├── proto3_field_semantics.proto │ │ │ ├── proto3_field_semantics.swagger.json │ │ │ ├── proto3_field_semantics_grpc.pb.go │ │ │ ├── remove_internal_comment.buf.gen.yaml │ │ │ ├── remove_internal_comment.pb.go │ │ │ ├── remove_internal_comment.pb.gw.go │ │ │ ├── remove_internal_comment.proto │ │ │ ├── remove_internal_comment.swagger.json │ │ │ ├── remove_internal_comment_grpc.pb.go │ │ │ ├── response_body_service.pb.go │ │ │ ├── response_body_service.pb.gw.go │ │ │ ├── response_body_service.proto │ │ │ ├── response_body_service.swagger.json │ │ │ ├── response_body_service_grpc.pb.go │ │ │ ├── standalone_echo_service.buf.gen.yaml │ │ │ ├── standalone_echo_service.yaml │ │ │ ├── stream.pb.go │ │ │ ├── stream.pb.gw.go │ │ │ ├── stream.proto │ │ │ ├── stream.swagger.json │ │ │ ├── stream_grpc.pb.go │ │ │ ├── unannotated_echo_service.buf.gen.yaml │ │ │ ├── unannotated_echo_service.pb.go │ │ │ ├── unannotated_echo_service.pb.gw.go │ │ │ ├── unannotated_echo_service.proto │ │ │ ├── unannotated_echo_service.swagger.json │ │ │ ├── unannotated_echo_service.swagger.yaml │ │ │ ├── unannotated_echo_service.yaml │ │ │ ├── unannotated_echo_service_grpc.pb.go │ │ │ ├── use_go_template.buf.gen.yaml │ │ │ ├── use_go_template.pb.go │ │ │ ├── use_go_template.pb.gw.go │ │ │ ├── use_go_template.proto │ │ │ ├── use_go_template.swagger.json │ │ │ ├── use_go_template_grpc.pb.go │ │ │ ├── visibility_rule_echo_service.pb.go │ │ │ ├── visibility_rule_echo_service.pb.gw.go │ │ │ ├── visibility_rule_echo_service.proto │ │ │ ├── visibility_rule_echo_service_grpc.pb.go │ │ │ ├── visibility_rule_enums_as_ints_echo_service.buf.gen.yaml │ │ │ ├── visibility_rule_enums_as_ints_echo_service.swagger.json │ │ │ ├── visibility_rule_internal_echo_service.buf.gen.yaml │ │ │ ├── visibility_rule_internal_echo_service.swagger.json │ │ │ ├── visibility_rule_none_echo_service.buf.gen.yaml │ │ │ ├── visibility_rule_none_echo_service.swagger.json │ │ │ ├── visibility_rule_preview_and_internal_echo_service.buf.gen.yaml │ │ │ ├── visibility_rule_preview_and_internal_echo_service.swagger.json │ │ │ ├── visibility_rule_preview_echo_service.buf.gen.yaml │ │ │ ├── visibility_rule_preview_echo_service.swagger.json │ │ │ ├── wrappers.pb.go │ │ │ ├── wrappers.pb.gw.go │ │ │ ├── wrappers.proto │ │ │ ├── wrappers.swagger.json │ │ │ └── wrappers_grpc.pb.go │ │ ├── oneofenum/ │ │ │ ├── BUILD.bazel │ │ │ ├── oneof_enum.pb.go │ │ │ ├── oneof_enum.proto │ │ │ └── oneof_enum.swagger.json │ │ ├── pathenum/ │ │ │ ├── BUILD.bazel │ │ │ ├── path_enum.pb.go │ │ │ ├── path_enum.proto │ │ │ └── path_enum.swagger.json │ │ ├── standalone/ │ │ │ ├── BUILD.bazel │ │ │ └── unannotated_echo_service.pb.gw.go │ │ ├── sub/ │ │ │ ├── BUILD.bazel │ │ │ ├── camel_case_message.pb.go │ │ │ ├── camel_case_message.proto │ │ │ ├── camel_case_message.swagger.json │ │ │ ├── message.pb.go │ │ │ ├── message.proto │ │ │ └── message.swagger.json │ │ └── sub2/ │ │ ├── BUILD.bazel │ │ ├── message.pb.go │ │ ├── message.proto │ │ └── message.swagger.json │ └── server/ │ ├── BUILD.bazel │ ├── a_bit_of_everything.go │ ├── echo.go │ ├── excess_body.go │ ├── fieldmask_helper.go │ ├── flow_combination.go │ ├── main.go │ ├── non_standard_names.go │ ├── responsebody.go │ └── unannotatedecho.go ├── go.mod ├── go.sum ├── internal/ │ ├── casing/ │ │ ├── BUILD.bazel │ │ ├── LICENSE.md │ │ ├── README.md │ │ ├── camel.go │ │ └── camel_test.go │ ├── codegenerator/ │ │ ├── BUILD.bazel │ │ ├── doc.go │ │ ├── parse_req.go │ │ ├── parse_req_test.go │ │ └── supported_features.go │ ├── descriptor/ │ │ ├── BUILD.bazel │ │ ├── apiconfig/ │ │ │ ├── BUILD.bazel │ │ │ ├── apiconfig.pb.go │ │ │ ├── apiconfig.proto │ │ │ └── apiconfig.swagger.json │ │ ├── grpc_api_configuration.go │ │ ├── grpc_api_configuration_test.go │ │ ├── openapi_configuration.go │ │ ├── openapi_configuration_test.go │ │ ├── openapiconfig/ │ │ │ ├── BUILD.bazel │ │ │ ├── openapiconfig.pb.go │ │ │ ├── openapiconfig.proto │ │ │ └── openapiconfig.swagger.json │ │ ├── registry.go │ │ ├── registry_test.go │ │ ├── services.go │ │ ├── services_test.go │ │ ├── types.go │ │ └── types_test.go │ ├── generator/ │ │ ├── BUILD.bazel │ │ └── generator.go │ └── httprule/ │ ├── BUILD.bazel │ ├── compile.go │ ├── compile_test.go │ ├── fuzz.go │ ├── parse.go │ ├── parse_test.go │ ├── types.go │ └── types_test.go ├── non_module_deps.bzl ├── protoc-gen-grpc-gateway/ │ ├── BUILD.bazel │ ├── internal/ │ │ └── gengateway/ │ │ ├── BUILD.bazel │ │ ├── doc.go │ │ ├── generator.go │ │ ├── generator_test.go │ │ ├── template.go │ │ └── template_test.go │ └── main.go ├── protoc-gen-openapiv2/ │ ├── BUILD.bazel │ ├── defs.bzl │ ├── internal/ │ │ └── genopenapi/ │ │ ├── BUILD.bazel │ │ ├── cycle_test.go │ │ ├── doc.go │ │ ├── format.go │ │ ├── format_test.go │ │ ├── generator.go │ │ ├── generator_test.go │ │ ├── helpers.go │ │ ├── helpers_go111_old.go │ │ ├── helpers_test.go │ │ ├── naming.go │ │ ├── naming_test.go │ │ ├── template.go │ │ ├── template_fuzz_test.go │ │ ├── template_test.go │ │ ├── testdata/ │ │ │ └── generator/ │ │ │ ├── path_item_object.prototext │ │ │ ├── path_item_object.swagger.yaml │ │ │ ├── x_go_type.prototext │ │ │ └── x_go_type.swagger.yaml │ │ ├── types.go │ │ └── types_test.go │ ├── main.go │ ├── main_test.go │ └── options/ │ ├── BUILD.bazel │ ├── annotations.pb.go │ ├── annotations.proto │ ├── annotations_protoopaque.pb.go │ ├── buf.gen.yaml │ ├── openapiv2.pb.go │ ├── openapiv2.proto │ └── openapiv2_protoopaque.pb.go ├── renovate.json ├── repositories.bzl ├── runtime/ │ ├── BUILD.bazel │ ├── context.go │ ├── context_test.go │ ├── convert.go │ ├── convert_test.go │ ├── doc.go │ ├── errors.go │ ├── errors_test.go │ ├── fieldmask.go │ ├── fieldmask_test.go │ ├── handler.go │ ├── handler_test.go │ ├── internal/ │ │ └── examplepb/ │ │ ├── BUILD.bazel │ │ ├── example.pb.go │ │ ├── example.proto │ │ ├── example.swagger.json │ │ ├── non_standard_names.pb.go │ │ ├── non_standard_names.proto │ │ ├── non_standard_names.swagger.json │ │ ├── non_standard_names_grpc.pb.go │ │ ├── proto2.pb.go │ │ ├── proto2.proto │ │ ├── proto2.swagger.json │ │ ├── proto3.pb.go │ │ ├── proto3.proto │ │ └── proto3.swagger.json │ ├── marshal_httpbodyproto.go │ ├── marshal_httpbodyproto_test.go │ ├── marshal_json.go │ ├── marshal_json_test.go │ ├── marshal_jsonpb.go │ ├── marshal_jsonpb_test.go │ ├── marshal_proto.go │ ├── marshal_proto_test.go │ ├── marshaler.go │ ├── marshaler_registry.go │ ├── marshaler_registry_test.go │ ├── mux.go │ ├── mux_internal_test.go │ ├── mux_test.go │ ├── pattern.go │ ├── pattern_test.go │ ├── proto2_convert.go │ ├── query.go │ ├── query_fuzz_test.go │ └── query_test.go └── utilities/ ├── BUILD.bazel ├── doc.go ├── pattern.go ├── readerfactory.go ├── string_array_flag.go ├── string_array_flag_test.go ├── trie.go └── trie_test.go ================================================ FILE CONTENTS ================================================ ================================================ FILE: .bazelci/presubmit.yml ================================================ --- platforms: ubuntu1804: build_flags: - "--build_tag_filters=-nolinux" build_targets: - "//..." test_flags: - "--features=race" - "--test_tag_filters=-nolinux" test_targets: - "//..." macos: build_flags: - "--build_tag_filters=-nomacos" build_targets: - "//..." test_flags: - "--features=race" - "--test_tag_filters=-nomacos" test_targets: - "//..." ================================================ FILE: .bazelrc ================================================ build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 build --test_output=errors ================================================ FILE: .bazelversion ================================================ 9.0.1 ================================================ FILE: .devcontainer/devcontainer.json ================================================ // For format details, see https://aka.ms/devcontainer.json. { "name": "Go", "build": { "dockerfile": "../.github/Dockerfile" }, "features": { "ghcr.io/devcontainers/features/common-utils:2": {}, "ghcr.io/devcontainers/features/node:1": {}, "ghcr.io/devcontainers/features/go:1": {} }, "customizations": { "vscode": { "editor.formatOnSave": true, "go.toolsManagement.checkForUpdates": "local", "go.useLanguageServer": true, "go.gopath": "/go", "go.goroot": "/usr/local/go", "bazel.buildifierExecutable": "/go/bin/buildifier", "bazel.buildifierFixOnFormat": true, "bazel.enableCodeLens": true, "extensions": ["golang.Go", "bazelbuild.vscode-bazel"] } } } ================================================ FILE: .git-blame-ignore-revs ================================================ # .git-blame-ignore-revs # Formatted all protobuf files bc0110188a8ef8e232050c3d9b347198dc83536a ================================================ FILE: .github/Dockerfile ================================================ FROM golang:1.26.1 RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \ wget \ unzip \ openjdk-25-jre \ bzip2 \ patch && \ apt-get clean -y && \ rm -rf /var/lib/apt/lists/* # Install swagger-codegen ENV SWAGGER_CODEGEN_VERSION=2.4.8 RUN wget https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/${SWAGGER_CODEGEN_VERSION}/swagger-codegen-cli-${SWAGGER_CODEGEN_VERSION}.jar \ -O /usr/local/bin/swagger-codegen-cli.jar && \ echo '#!/bin/bash\njava -jar /usr/local/bin/swagger-codegen-cli.jar "$@"' > /usr/local/bin/swagger-codegen && \ chmod +x /usr/local/bin/swagger-codegen # Install Bazelisk as bazel to manage Bazel RUN go install github.com/bazelbuild/bazelisk@latest && \ mv $(which bazelisk) /usr/local/bin/bazel # Install buildifier for bazel formatting RUN go install github.com/bazelbuild/buildtools/buildifier@latest ================================================ FILE: .github/ISSUE_TEMPLATE/bug.md ================================================ --- name: 🐛 Bug Report about: Submit a bug report to help us improve --- ## 🐛 Bug Report (A clear and concise description of what the bug is.) ## To Reproduce (Write your steps here:) 1. Step 1... 1. Step 2... 1. Step 3... ## Expected behavior (Write what you thought would happen.) ## Actual Behavior (Write what happened. Add screenshots, if applicable.) ## Your Environment (Environment name, version and operating system.) ================================================ FILE: .github/ISSUE_TEMPLATE/documentation.md ================================================ --- name: 📚 Documentation about: Report an issue related to documentation --- ## 📚 Documentation (A clear and concise description of what the issue is.) ================================================ FILE: .github/ISSUE_TEMPLATE/feature.md ================================================ --- name: 🚀 Feature about: Submit a proposal/request for a new feature --- ## 🚀 Feature (A clear and concise description of what the feature is.) ================================================ FILE: .github/ISSUE_TEMPLATE.md ================================================ # The gRPC-Gateway project is maintained by volunteers in their spare time. Please follow these troubleshooting steps before submitting an issue. - [ ] Check if your issue has already been reported (https://github.com/grpc-ecosystem/grpc-gateway/issues). - [ ] Update your protoc to the [latest version](https://github.com/google/protobuf/releases). - [ ] Update your copy of the `grpc-gateway` library to the latest version from github: ```sh go get github.com/grpc-ecosystem/grpc-gateway/v2@latest ``` - [ ] Delete the `protoc-gen-grpc-gateway` and `protoc-gen-openapiv2` binary from your `PATH`, and reinstall the latest versions: ```sh go get github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway go get github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 ``` ## I still have a problem! Please consider reaching out for help on a chat forum, such as [Gophers Slack](https://invite.slack.golangbridge.org/) (channel #grpc-gateway). It's much easier to help with common debugging steps in a chat, and some of the maintainers are reading the channel regularly. If you submit an issue which is clearly an environment setup problem, or it's obvious you haven't tried seeking help somewhere else first, we may close your issue. ## I still have a problem! Please follow these steps to submit a bug report: ### Bug reports: Fill in the following sections with explanations of what's gone wrong. ### Steps you follow to reproduce the error: ```html ``` Your steps here. ### What did you expect to happen instead: ```html ``` Your answer here. ### What's your theory on why it isn't working: ```html ``` Your theory here. ================================================ FILE: .github/PULL_REQUEST_TEMPLATE.md ================================================ #### References to other Issues or PRs #### Have you read the [Contributing Guidelines](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/CONTRIBUTING.md)? #### Brief description of what is fixed or changed #### Other comments ================================================ FILE: .github/README_GITHUB.md ================================================ ### What's up with the Dockerfile? The `Dockerfile` in this folder is used as the build environment when regenerating the files (see CONTRIBUTING.md). The canonical repository for this Dockerfile is `ghcr.io/grpc-ecosystem/grpc-gateway/build-env`. ================================================ FILE: .github/dependabot.yml ================================================ # To get started with Dependabot version updates, you'll need to specify which # package ecosystems to update and where the package manifests are located. # Please see the documentation for all configuration options: # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates version: 2 updates: - package-ecosystem: "bundler" # See documentation for possible values directory: "/docs" # Location of package manifests schedule: interval: "daily" - package-ecosystem: "github-actions" directory: "/" schedule: interval: daily ================================================ FILE: .github/stale.yml ================================================ # Number of days of inactivity before an issue becomes stale daysUntilStale: 60 # Number of days of inactivity before a stale issue is closed daysUntilClose: 7 # Issues with these labels will never be considered stale exemptLabels: - help wanted - enhancement - security # Label to use when marking an issue as stale staleLabel: wontfix # Comment to post when marking an issue as stale. Set to `false` to disable markComment: > This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. # Comment to post when closing a stale issue. Set to `false` to disable closeComment: false ================================================ FILE: .github/workflows/ci.yml ================================================ on: - pull_request permissions: contents: read name: CI jobs: build: strategy: matrix: go-version: [oldstable, stable] os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6 with: go-version: ${{ matrix.go-version }} - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - run: go build ./... test: runs-on: ubuntu-latest steps: - uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6 with: go-version: 1.26 check-latest: true - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - run: go test ./... node_test: runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 with: node-version: 24 - uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6 with: go-version: 1.26 check-latest: true - run: > cd examples/internal/browser && npm install gulp-cli && npm install && ./node_modules/.bin/gulp generate: container: image: ghcr.io/grpc-ecosystem/grpc-gateway/build-env:latest runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 # Required with newer versions of Git # https://github.com/actions/checkout/issues/766 - run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - run: make install - run: make clean - run: make generate - run: go mod tidy - run: git diff --exit-code bazel: container: image: ghcr.io/grpc-ecosystem/grpc-gateway/build-env:latest runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5 with: path: /home/vscode/.cache/_grpc_gateway_bazel key: v1-bazel-cache-${{ hashFiles('repositories.bzl') }} restore-keys: v1-bazel-cache- # Required with newer versions of Git # https://github.com/actions/checkout/issues/766 - run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - name: Configure bazel run: | # put .bazelrc in $HOME so that it's read before project's .bazelrc cat > /home/vscode/.bazelrc << EOF startup --output_base=/home/vscode/.cache/_grpc_gateway_bazel build --@io_bazel_rules_go//go/config:race # Workaround https://github.com/bazelbuild/bazel/issues/3645 # See https://docs.bazel.build/versions/0.23.0/command-line-reference.html build --local_ram_resources=7168 # Github runners have 7G of memory build --local_cpu_resources=2 # Github runners have 2 vCPU EOF - name: Check that Bazel BUILD files are up-to-date run: bazel run //:gazelle && git diff --exit-code - name: Check that repositories.bzl is up-to-date run: | bazel run //:gazelle -- update-repos -from_file=go.mod -to_macro=repositories.bzl%go_repositories && git diff --exit-code - name: Check formatting of Bazel BUILD files run: bazel run //:buildifier && git diff --exit-code - name: Run tests with Bazel run: bazel test //... gorelease: runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6 with: go-version: 1.26 check-latest: true - run: go run golang.org/x/exp/cmd/gorelease@latest -base=v2.28.0 proto_lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6 with: go-version: 1.26 check-latest: true - run: make install - run: PATH=$PATH:~/go/bin buf build - run: PATH=$PATH:~/go/bin buf lint - run: PATH=$PATH:~/go/bin buf format -w && git diff --exit-code - run: PATH=$PATH:~/go/bin buf breaking --path protoc-gen-openapiv2/ --against 'https://github.com/grpc-ecosystem/grpc-gateway.git#branch=main' lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6 with: go-version: 1.26 check-latest: true - uses: dominikh/staticcheck-action@9716614d4101e79b4340dd97b10e54d68234e431 # v1.4.1 with: install-go: false fuzz: runs-on: ubuntu-latest steps: - name: Build Fuzzers id: build uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master with: oss-fuzz-project-name: "grpc-gateway" dry-run: false language: go - name: Run Fuzzers uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master with: oss-fuzz-project-name: "grpc-gateway" fuzz-seconds: 600 dry-run: false language: go - name: Upload Crash uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7 if: failure() && steps.build.outcome == 'success' with: name: artifacts path: ./out/artifacts ================================================ FILE: .github/workflows/devcontainer.yml ================================================ on: push: paths: - .devcontainer/devcontainer.json - .github/workflows/devcontainer.yml - .github/Dockerfile permissions: contents: read packages: write name: devcontainer jobs: rebuild: runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - name: Login to GitHub Container Registry uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Rebuild dev container image uses: devcontainers/ci@8bf61b26e9c3a98f69cb6ce2f88d24ff59b785c6 # v0.3 with: imageName: ghcr.io/grpc-ecosystem/grpc-gateway/build-env cacheFrom: ghcr.io/grpc-ecosystem/grpc-gateway/build-env push: filter refFilterForPush: refs/heads/main ================================================ FILE: .github/workflows/release.yml ================================================ on: push: tags: - v2.[0-9]+.[0-9]+ # For testing the workflow before pushing a tag # This will run goreleaser with --snapshot and test the # SLSA generator. workflow_dispatch: permissions: contents: read name: release jobs: goreleaser: outputs: hashes: ${{ steps.hash.outputs.hashes }} runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 with: fetch-depth: 0 - uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6 with: check-latest: true - name: Generate goreleaser args id: args run: | set -euo pipefail args='release --clean' if [[ "$GITHUB_REF" != refs/tags/* ]]; then args+=' --snapshot' fi echo "args=$args" >> $GITHUB_OUTPUT - uses: goreleaser/goreleaser-action@ec59f474b9834571250b370d4735c50f8e2d1e29 # v7 id: run-goreleaser with: args: ${{ steps.args.outputs.args }} distribution: goreleaser # or 'goreleaser-pro' version: "~> v2" # or 'latest', 'nightly', semver env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Generate subject id: hash env: ARTIFACTS: "${{ steps.run-goreleaser.outputs.artifacts }}" run: | set -euo pipefail checksum_file=$(echo "$ARTIFACTS" | jq -r '.[] | select (.type=="Checksum") | .path') echo "hashes=$(cat $checksum_file | base64 -w0)" >> $GITHUB_OUTPUT provenance: needs: [goreleaser] permissions: actions: read # To read the workflow path. id-token: write # To sign the provenance. contents: write # To add assets to a release. uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.1.0 with: compile-generator: true # Workaround for https://github.com/slsa-framework/slsa-github-generator/issues/1163 base64-subjects: "${{ needs.goreleaser.outputs.hashes }}" upload-assets: ${{ github.event_name == 'push' }} # upload to a new release when pushing via tag ================================================ FILE: .github/workflows/renovate.yml ================================================ on: push: branches: - renovate/* permissions: contents: read name: renovate jobs: update_repositoriesbzl: container: image: ghcr.io/grpc-ecosystem/grpc-gateway/build-env:latest runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 with: fetch-depth: 0 token: ${{ secrets.GH_PUSH_TOKEN }} - uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5 with: path: /home/vscode/.cache/_grpc_gateway_bazel key: v1-bazel-cache-${{ hashFiles('repositories.bzl') }} restore-keys: v1-bazel-cache- - name: Configure bazel run: | # put .bazelrc in $HOME so that it's read before project's .bazelrc cat > /home/vscode/.bazelrc << EOF startup --output_base /home/vscode/.cache/_grpc_gateway_bazel build --@io_bazel_rules_go//go/config:race # Workaround https://github.com/bazelbuild/bazel/issues/3645 # See https://docs.bazel.build/versions/0.23.0/command-line-reference.html build --local_ram_resources=7168 # Github runners have 7G of memory build --local_cpu_resources=2 # Github runners have 2 vCPU EOF - run: bazel run //:gazelle -- update-repos -from_file=go.mod -to_macro=repositories.bzl%go_repositories # Required with newer versions of Git # https://github.com/actions/checkout/issues/766 - run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - run: | git add . if output=$(git status --porcelain) && [ ! -z "$output" ]; then git config user.name "Renovate Bot" git config user.email "bot@renovateapp.com" git commit --amend --no-edit git push --force-with-lease origin ${{ github.ref_name }} fi regenerate: container: image: ghcr.io/grpc-ecosystem/grpc-gateway/build-env:latest runs-on: ubuntu-latest needs: # Run after update_repositoriesbzl to avoid # git conflicts - update_repositoriesbzl steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 with: fetch-depth: 0 token: ${{ secrets.GH_PUSH_TOKEN }} # Required with newer versions of Git # https://github.com/actions/checkout/issues/766 - run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - run: make install - run: make clean - run: make generate - run: go mod tidy - run: | git add . if output=$(git status --porcelain) && [ ! -z "$output" ]; then git config user.name "Renovate Bot" git config user.email "bot@renovateapp.com" git commit --amend --no-edit git push --force-with-lease origin ${{ github.ref_name }} fi ================================================ FILE: .gitignore ================================================ _output/ .idea # Bazel. bazel-bin bazel-genfiles bazel-grpc-gateway bazel-out bazel-testlogs # Go vendor directory vendor # Generated travis files .travis.yml ================================================ FILE: .goreleaser.yml ================================================ version: 2 builds: - main: ./protoc-gen-grpc-gateway/main.go id: protoc-gen-grpc-gateway binary: protoc-gen-grpc-gateway env: - CGO_ENABLED=0 goos: - linux - darwin - windows goarch: - amd64 - arm64 - main: ./protoc-gen-openapiv2/main.go id: protoc-gen-openapiv2 binary: protoc-gen-openapiv2 env: - CGO_ENABLED=0 goos: - linux - darwin - windows goarch: - amd64 - arm64 archives: - name_template: '{{ .Binary }}-{{ .Tag }}-{{ .Os }}-{{if eq .Arch "amd64"}}x86_64{{else}}{{ .Arch }}{{end}}' format: binary source: enabled: true name_template: '{{ .ProjectName }}-{{ .Tag }}' dist: _output ================================================ FILE: ADOPTERS.md ================================================ # Adopters This is a list of organizations that have spoken publicly about their adoption or production users that have added themselves (in alphabetical order): - [Ad Hoc](http://adhocteam.us/) uses the gRPC-Gateway to serve millions of API requests per day. - [Chef](https://www.chef.io/) uses the gRPC-Gateway to provide the user-facing API of [Chef Automate](https://automate.chef.io/). Furthermore, the generated OpenAPI data serves as the basis for its [API documentation](https://automate.chef.io/docs/api/). The code is Open Source, [see `github.com/chef/automate`](https://github.com/chef/automate). - [Cho Tot](https://careers.chotot.com/about-us/) utilizes gRPC Gateway to seamlessly integrate HTTP and gRPC services, enabling efficient communication for both legacy and modern systems. - [Conduit](https://github.com/ConduitIO/conduit), a data streaming tool written in Go, uses the gRPC-Gateway since its very beginning to provide an HTTP API in addition to its gRPC API. This makes it easier to integrate with Conduit, and the generated OpenAPI data is used in the documentation. - [PITS Global Data Recovery Services](https://www.pitsdatarecovery.net/) uses the gRPC-Gateway to generate efficient reverse-proxy servers for internal needs. - [Scaleway](https://www.scaleway.com/en/) uses the gRPC-Gateway since 2018 to serve millions of API requests per day [1]. - [SpiceDB](https://github.com/authzed/spicedb) uses the gRPC-Gateway to handle requests for security-critical permissions checks in environments where gRPC is unavailable. If you have adopted the gRPC-Gateway and would like to be included in this list, feel free to submit a PR. [1]: [The odyssey of an HTTP request in Scaleway](https://www.youtube.com/watch?v=eLxD-zIUraE&feature=youtu.be&t=480). ================================================ FILE: BUILD.bazel ================================================ load("@bazel_gazelle//:def.bzl", "gazelle") load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier") load("@io_bazel_rules_go//proto:compiler.bzl", "go_proto_compiler") load("@io_bazel_rules_go//proto/wkt:well_known_types.bzl", "PROTO_RUNTIME_DEPS", "WELL_KNOWN_TYPES_APIV2") exports_files(["LICENSE"]) buildifier( name = "buildifier", ) buildifier( name = "buildifier_check", mode = "check", ) # gazelle:exclude _output # gazelle:prefix github.com/grpc-ecosystem/grpc-gateway/v2 # gazelle:go_proto_compilers //:go_apiv2 # gazelle:go_grpc_compilers //:go_apiv2, //:go_grpc # gazelle:go_naming_convention import_alias # gazelle:resolve proto proto google/api/annotations.proto @googleapis//google/api:annotations_proto # gazelle:resolve proto go google/api/annotations.proto @org_golang_google_genproto_googleapis_api//annotations # gazelle:resolve proto proto google/api/http.proto @googleapis//google/api:http_proto # gazelle:resolve proto go google/api/http.proto @org_golang_google_genproto_googleapis_api//annotations # gazelle:resolve proto proto google/api/field_behavior.proto @googleapis//google/api:field_behavior_proto # gazelle:resolve proto go google/api/field_behavior.proto @org_golang_google_genproto_googleapis_api//annotations # gazelle:resolve proto proto google/api/httpbody.proto @googleapis//google/api:httpbody_proto # gazelle:resolve proto go google/api/httpbody.proto @org_golang_google_genproto_googleapis_api//httpbody # gazelle:resolve proto proto google/api/visibility.proto @googleapis//google/api:visibility_proto # gazelle:resolve proto go google/api/visibility.proto @org_golang_google_genproto_googleapis_api//visibility # gazelle:resolve proto proto google/rpc/status.proto @googleapis//google/rpc:status_proto # gazelle:resolve proto go google/rpc/status.proto @org_golang_google_genproto_googleapis_rpc//status gazelle(name = "gazelle") package_group( name = "generators", packages = [ "//protoc-gen-grpc-gateway/...", "//protoc-gen-openapiv2/...", ], ) go_proto_compiler( name = "go_apiv2", options = [ "paths=source_relative", ], plugin = "@org_golang_google_protobuf//cmd/protoc-gen-go", suffix = ".pb.go", visibility = ["//visibility:public"], deps = PROTO_RUNTIME_DEPS + WELL_KNOWN_TYPES_APIV2, ) go_proto_compiler( name = "go_apiv2_opaque", options = [ "paths=source_relative", "default_api_level=API_OPAQUE", ], plugin = "@org_golang_google_protobuf//cmd/protoc-gen-go", suffix = ".pb.go", visibility = ["//visibility:public"], deps = PROTO_RUNTIME_DEPS + WELL_KNOWN_TYPES_APIV2, ) go_proto_compiler( name = "go_grpc", options = [ "paths=source_relative", "require_unimplemented_servers=false", ], plugin = "@org_golang_google_grpc_cmd_protoc_gen_go_grpc//:protoc-gen-go-grpc", suffix = "_grpc.pb.go", visibility = ["//visibility:public"], deps = PROTO_RUNTIME_DEPS + [ "@org_golang_google_grpc//:go_default_library", "@org_golang_google_grpc//codes:go_default_library", "@org_golang_google_grpc//status:go_default_library", ], ) ================================================ FILE: CONTRIBUTING.md ================================================ # How to contribute ## Code reviews All submissions, including submissions by project members, require review. ## I want to regenerate the files after making changes ### Using Docker It should be as simple as this (run from the root of the repository): ```bash docker run -v $(pwd):/grpc-gateway -w /grpc-gateway --rm ghcr.io/grpc-ecosystem/grpc-gateway/build-env:latest \ /bin/bash -c 'make install && \ make clean && \ make generate' docker run -itv $(pwd):/grpc-gateway -w /grpc-gateway --entrypoint /bin/bash --rm \ ghcr.io/grpc-ecosystem/grpc-gateway/build-env:latest -c '\ bazel run :gazelle -- update-repos -from_file=go.mod -to_macro=repositories.bzl%go_repositories && \ bazel run :gazelle && \ bazel run :buildifier' ``` You may need to authenticate with GitHub to pull `ghcr.io/grpc-ecosystem/grpc-gateway/build-env`. You can do this by following the steps on the [GitHub Package docs](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#authenticating-to-the-container-registry). ### Using Visual Studio Code dev containers This repo contains a `devcontainer.json` configuration that sets up the build environment in a container using [VS Code dev containers](https://code.visualstudio.com/docs/remote/containers). If you're using the dev container, you can run the commands directly in your terminal: ```sh $ make install && make clean && make generate ``` ```sh $ bazel run :gazelle -- update-repos -from_file=go.mod -to_macro=repositories.bzl%go_repositories && \ bazel run :gazelle && \ bazel run :buildifier ``` Note that the above-listed docker commands will not work in the dev container, since volume mounts from nested docker container is not possible. If this has resulted in some file changes in the repo, please ensure you check those in with your merge request. ## Making a release To make a release, follow these steps: 1. Decide on a release version. The `gorelease` job can recommend whether the new release should be a patch or minor release. 1. Tag the release on `main`. 1. The release can be created using the command line, or also through GitHub's [releases UI](https://github.com/grpc-ecosystem/grpc-gateway/releases/new). 1. If you create a release using the web UI you can publish it as a draft and have it reviewed by another maintainer. 1. Update the release description. Try to include some of the highlights of this release, ideally with links to the PRs and crediting the contributors. 1. Update the gorelease job in .github/ci.yaml to point to the new release version. 1. Sit back and pat yourself on the back for a job well done :clap:. ================================================ FILE: LICENSE ================================================ Copyright (c) 2015, Gengo, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Gengo, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: MODULE.bazel ================================================ module( name = "grpc_ecosystem_grpc_gateway", # TODO: Change this to the actual version on each release. # This can wait until we publish this project on the Bazel registry. version = "0.0.0", ) # Bazel Central Registry modules. bazel_dep(name = "bazel_features", version = "1.43.0") bazel_dep(name = "rules_license", version = "1.0.0") bazel_dep(name = "rules_python", version = "1.9.0") bazel_dep(name = "rules_proto", version = "7.1.0") bazel_dep(name = "rules_go", version = "0.60.0", repo_name = "io_bazel_rules_go") bazel_dep(name = "rules_shell", version = "0.6.1") bazel_dep(name = "gazelle", version = "0.47.0", repo_name = "bazel_gazelle") bazel_dep(name = "bazel_skylib", version = "1.9.0") bazel_dep(name = "protobuf", version = "34.0.bcr.1", repo_name = "com_google_protobuf") bazel_dep(name = "googleapis", version = "0.0.0-20260223-edfe7983") # This is required as a transitive dependency and not directly needed by this module. # We have this version pinned to solve for differences in the MODULE.bazel.lock file # when running CI. bazel_dep(name = "rules_rust", version = "0.69.0") go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk") go_sdk.download(version = "1.26.0") go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps") go_deps.from_file(go_mod = ":go.mod") # These dependencies are required by `.proto` files but are not captured in `go.mod`, # so they have to explicitly be made known to Gazelle. go_deps.module( path = "google.golang.org/grpc/cmd/protoc-gen-go-grpc", sum = "h1:F29+wU6Ee6qgu9TddPgooOdaqsxTMunOoj8KA5yuS5A=", version = "v1.5.1", ) go_deps.module( path = "github.com/golang/protobuf", sum = "h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=", version = "v1.5.4", ) go_deps.module( path = "github.com/bazelbuild/buildtools/v7", sum = "h1:BRlRwQ/4rd608QvjsM9HSzBLLM1nXyzHaDzdkBAyDKk=", version = "v7.3.1", ) go_deps.module( path = "golang.org/x/tools", sum = "h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=", version = "v0.21.1-0.20240508182429-e35e4ccd0d2d", ) use_repo( go_deps, "com_github_antihax_optional", "com_github_bazelbuild_buildtools_v7", "com_github_golang_protobuf", "com_github_google_go_cmp", "com_github_rogpeppe_fastuuid", "in_yaml_go_yaml_v3", "org_golang_google_genproto_googleapis_api", "org_golang_google_genproto_googleapis_rpc", "org_golang_google_grpc", "org_golang_google_grpc_cmd_protoc_gen_go_grpc", "org_golang_google_protobuf", "org_golang_x_oauth2", "org_golang_x_text", "org_golang_x_tools", ) non_module_deps = use_extension(":non_module_deps.bzl", "non_module_deps") use_repo( non_module_deps, "com_github_bazelbuild_buildtools", ) ================================================ FILE: Makefile ================================================ # This is a Makefile which maintains files automatically generated but to be # shipped together with other files. # You don't have to rebuild these targets by yourself unless you develop # gRPC-Gateway itself. EXAMPLE_CLIENT_DIR=examples/internal/clients ECHO_EXAMPLE_SPEC=examples/internal/proto/examplepb/echo_service.swagger.json ECHO_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/echo/client.go \ $(EXAMPLE_CLIENT_DIR)/echo/response.go \ $(EXAMPLE_CLIENT_DIR)/echo/configuration.go \ $(EXAMPLE_CLIENT_DIR)/echo/api_echo_service.go \ $(EXAMPLE_CLIENT_DIR)/echo/model_examplepb_simple_message.go \ $(EXAMPLE_CLIENT_DIR)/echo/model_examplepb_embedded.go ABE_EXAMPLE_SPEC=examples/internal/proto/examplepb/a_bit_of_everything.swagger.json ABE_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/abe/model_a_bit_of_everything_nested.go \ $(EXAMPLE_CLIENT_DIR)/abe/api_a_bit_of_everything_service.go \ $(EXAMPLE_CLIENT_DIR)/abe/client.go \ $(EXAMPLE_CLIENT_DIR)/abe/api_camel_case_service_name.go \ $(EXAMPLE_CLIENT_DIR)/abe/configuration.go \ $(EXAMPLE_CLIENT_DIR)/abe/api_echo_rpc.go \ $(EXAMPLE_CLIENT_DIR)/abe/model_examplepb_a_bit_of_everything.go \ $(EXAMPLE_CLIENT_DIR)/abe/model_examplepb_a_bit_of_everything_repeated.go \ $(EXAMPLE_CLIENT_DIR)/abe/model_examplepb_body.go \ $(EXAMPLE_CLIENT_DIR)/abe/model_examplepb_numeric_enum.go \ $(EXAMPLE_CLIENT_DIR)/abe/model_examplepb_update_v2_request.go \ $(EXAMPLE_CLIENT_DIR)/abe/model_message_path_enum_nested_path_enum.go \ $(EXAMPLE_CLIENT_DIR)/abe/model_nested_deep_enum.go \ $(EXAMPLE_CLIENT_DIR)/abe/model_pathenum_path_enum.go \ $(EXAMPLE_CLIENT_DIR)/abe/model_protobuf_field_mask.go \ $(EXAMPLE_CLIENT_DIR)/abe/response.go UNANNOTATED_ECHO_EXAMPLE_SPEC=examples/internal/proto/examplepb/unannotated_echo_service.swagger.json UNANNOTATED_ECHO_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/unannotatedecho/client.go \ $(EXAMPLE_CLIENT_DIR)/unannotatedecho/response.go \ $(EXAMPLE_CLIENT_DIR)/unannotatedecho/configuration.go \ $(EXAMPLE_CLIENT_DIR)/unannotatedecho/model_examplepb_unannotated_simple_message.go \ $(EXAMPLE_CLIENT_DIR)/unannotatedecho/api_unannotated_echo_service.go RESPONSE_BODY_EXAMPLE_SPEC=examples/internal/proto/examplepb/response_body_service.swagger.json RESPONSE_BODY_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/responsebody/client.go \ $(EXAMPLE_CLIENT_DIR)/responsebody/response.go \ $(EXAMPLE_CLIENT_DIR)/responsebody/configuration.go \ $(EXAMPLE_CLIENT_DIR)/responsebody/model_examplepb_repeated_response_body_out.go \ $(EXAMPLE_CLIENT_DIR)/responsebody/model_examplepb_repeated_response_body_out_response.go \ $(EXAMPLE_CLIENT_DIR)/responsebody/model_examplepb_repeated_response_strings.go \ $(EXAMPLE_CLIENT_DIR)/responsebody/model_examplepb_response_body_out.go \ $(EXAMPLE_CLIENT_DIR)/responsebody/model_examplepb_response_body_out_response.go \ $(EXAMPLE_CLIENT_DIR)/responsebody/model_response_response_type.go \ $(EXAMPLE_CLIENT_DIR)/responsebody/api_response_body_service.go GENERATE_UNBOUND_METHODS_EXAMPLE_SPEC=examples/internal/proto/examplepb/generate_unbound_methods.swagger.json GENERATE_UNBOUND_METHODS_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/generateunboundmethods/client.go \ $(EXAMPLE_CLIENT_DIR)/generateunboundmethods/response.go \ $(EXAMPLE_CLIENT_DIR)/generateunboundmethods/configuration.go \ $(EXAMPLE_CLIENT_DIR)/generateunboundmethods/model_examplepb_generate_unbound_methods_simple_message.go \ $(EXAMPLE_CLIENT_DIR)/generateunboundmethods/api_generate_unbound_methods.go EXAMPLE_CLIENT_SRCS=$(ECHO_EXAMPLE_SRCS) $(ABE_EXAMPLE_SRCS) $(UNANNOTATED_ECHO_EXAMPLE_SRCS) $(RESPONSE_BODY_EXAMPLE_SRCS) $(GENERATE_UNBOUND_METHODS_EXAMPLE_SRCS) SWAGGER_CODEGEN=swagger-codegen $(ECHO_EXAMPLE_SRCS): $(ECHO_EXAMPLE_SPEC) $(SWAGGER_CODEGEN) generate -i $(ECHO_EXAMPLE_SPEC) \ -l go -o examples/internal/clients/echo --additional-properties packageName=echo @rm -f $(EXAMPLE_CLIENT_DIR)/echo/README.md \ $(EXAMPLE_CLIENT_DIR)/echo/git_push.sh $(ABE_EXAMPLE_SRCS): $(ABE_EXAMPLE_SPEC) $(SWAGGER_CODEGEN) generate -i $(ABE_EXAMPLE_SPEC) \ -l go -o examples/internal/clients/abe --additional-properties packageName=abe @rm -f $(EXAMPLE_CLIENT_DIR)/abe/README.md \ $(EXAMPLE_CLIENT_DIR)/abe/git_push.sh $(UNANNOTATED_ECHO_EXAMPLE_SRCS): $(UNANNOTATED_ECHO_EXAMPLE_SPEC) $(SWAGGER_CODEGEN) generate -i $(UNANNOTATED_ECHO_EXAMPLE_SPEC) \ -l go -o examples/internal/clients/unannotatedecho --additional-properties packageName=unannotatedecho @rm -f $(EXAMPLE_CLIENT_DIR)/unannotatedecho/README.md \ $(EXAMPLE_CLIENT_DIR)/unannotatedecho/git_push.sh $(RESPONSE_BODY_EXAMPLE_SRCS): $(RESPONSE_BODY_EXAMPLE_SPEC) $(SWAGGER_CODEGEN) generate -i $(RESPONSE_BODY_EXAMPLE_SPEC) \ -l go -o examples/internal/clients/responsebody --additional-properties packageName=responsebody @rm -f $(EXAMPLE_CLIENT_DIR)/responsebody/README.md \ $(EXAMPLE_CLIENT_DIR)/responsebody/git_push.sh $(GENERATE_UNBOUND_METHODS_EXAMPLE_SRCS): $(GENERATE_UNBOUND_METHODS_EXAMPLE_SPEC) $(SWAGGER_CODEGEN) generate -i $(GENERATE_UNBOUND_METHODS_EXAMPLE_SPEC) \ -l go -o examples/internal/clients/generateunboundmethods --additional-properties packageName=generateunboundmethods @rm -f $(EXAMPLE_CLIENT_DIR)/generateunboundmethods/README.md \ $(EXAMPLE_CLIENT_DIR)/generateunboundmethods/git_push.sh install: go install github.com/bufbuild/buf/cmd/buf@v1.45.0 go install \ ./protoc-gen-openapiv2 \ ./protoc-gen-grpc-gateway proto: # These generation steps are run in order so that later steps can # overwrite files produced by previous steps, if necessary. buf generate # Remove generated gateway in runtime tests, causes import cycle rm ./runtime/internal/examplepb/non_standard_names.pb.gw.go # Remove generated_input.proto files, bazel genrule relies on these # *not* being generated (to avoid conflicts). rm ./examples/internal/proto/examplepb/generated_input.pb.go rm ./examples/internal/proto/examplepb/generated_input_grpc.pb.go rm ./examples/internal/proto/examplepb/generated_input.pb.gw.go # Remove swagger files for openapiv2 definitions, they're unused rm ./protoc-gen-openapiv2/options/annotations.swagger.json rm ./protoc-gen-openapiv2/options/openapiv2.swagger.json buf generate \ --template ./examples/internal/proto/examplepb/openapi_merge.buf.gen.yaml \ --path ./examples/internal/proto/examplepb/openapi_merge_a.proto \ --path ./examples/internal/proto/examplepb/openapi_merge_b.proto buf generate \ --template ./examples/internal/proto/examplepb/standalone_echo_service.buf.gen.yaml \ --path examples/internal/proto/examplepb/unannotated_echo_service.proto mv examples/internal/proto/examplepb/unannotated_echo_service.pb.gw.go examples/internal/proto/standalone/ buf generate \ --template ./examples/internal/proto/examplepb/unannotated_echo_service.buf.gen.yaml \ --path examples/internal/proto/examplepb/unannotated_echo_service.proto buf generate \ --template ./examples/internal/proto/examplepb/generate_unbound_methods.buf.gen.yaml \ --path examples/internal/proto/examplepb/generate_unbound_methods.proto buf generate \ --template ./examples/internal/proto/examplepb/use_go_template.buf.gen.yaml \ --path examples/internal/proto/examplepb/use_go_template.proto buf generate \ --template ./examples/internal/proto/examplepb/ignore_comment.buf.gen.yaml \ --path examples/internal/proto/examplepb/ignore_comment.proto buf generate \ --template ./examples/internal/proto/examplepb/remove_internal_comment.buf.gen.yaml \ --path examples/internal/proto/examplepb/remove_internal_comment.proto buf generate \ --template ./examples/internal/proto/examplepb/visibility_rule_preview_echo_service.buf.gen.yaml \ --path examples/internal/proto/examplepb/visibility_rule_echo_service.proto mv examples/internal/proto/examplepb/visibility_rule_echo_service.swagger.json examples/internal/proto/examplepb/visibility_rule_preview_echo_service.swagger.json buf generate \ --template ./examples/internal/proto/examplepb/visibility_rule_internal_echo_service.buf.gen.yaml \ --path examples/internal/proto/examplepb/visibility_rule_echo_service.proto mv examples/internal/proto/examplepb/visibility_rule_echo_service.swagger.json examples/internal/proto/examplepb/visibility_rule_internal_echo_service.swagger.json buf generate \ --template ./examples/internal/proto/examplepb/visibility_rule_none_echo_service.buf.gen.yaml \ --path examples/internal/proto/examplepb/visibility_rule_echo_service.proto mv examples/internal/proto/examplepb/visibility_rule_echo_service.swagger.json examples/internal/proto/examplepb/visibility_rule_none_echo_service.swagger.json buf generate \ --template ./examples/internal/proto/examplepb/visibility_rule_preview_and_internal_echo_service.buf.gen.yaml \ --path examples/internal/proto/examplepb/visibility_rule_echo_service.proto mv examples/internal/proto/examplepb/visibility_rule_echo_service.swagger.json examples/internal/proto/examplepb/visibility_rule_preview_and_internal_echo_service.swagger.json buf generate \ --template ./examples/internal/proto/examplepb/visibility_rule_enums_as_ints_echo_service.buf.gen.yaml \ --path examples/internal/proto/examplepb/visibility_rule_echo_service.proto mv examples/internal/proto/examplepb/visibility_rule_echo_service.swagger.json examples/internal/proto/examplepb/visibility_rule_enums_as_ints_echo_service.swagger.json buf generate \ --template examples/internal/proto/examplepb/enum_with_single_value.buf.gen.yaml \ --path examples/internal/proto/examplepb/enum_with_single_value.proto buf generate \ --template ./examples/internal/proto/examplepb/proto3_field_semantics.buf.gen.yaml \ --path examples/internal/proto/examplepb/proto3_field_semantics.proto buf generate \ --template ./protoc-gen-openapiv2/options/buf.gen.yaml \ --path ./protoc-gen-openapiv2/options/annotations.proto \ --path ./protoc-gen-openapiv2/options/openapiv2.proto buf generate \ --template ./examples/internal/proto/examplepb/opaque.buf.gen.yaml \ --path examples/internal/proto/examplepb/opaque.proto generate: proto $(ECHO_EXAMPLE_SRCS) $(ABE_EXAMPLE_SRCS) $(UNANNOTATED_ECHO_EXAMPLE_SRCS) $(RESPONSE_BODY_EXAMPLE_SRCS) $(GENERATE_UNBOUND_METHODS_EXAMPLE_SRCS) test: proto go test -short -race ./... go test -race ./examples/internal/integration -args -network=unix -endpoint=test.sock clean: find . -type f -name '*.pb.go' -delete find . -type f -name '*.swagger.json' -delete find . -type f -name '*.pb.gw.go' -delete rm -f $(EXAMPLE_CLIENT_SRCS) .PHONY: generate test clean proto install ================================================ FILE: README.md ================================================

gRPC-Gateway

gRPC to JSON proxy generator following the gRPC HTTP spec

## About The gRPC-Gateway is a plugin of the Google protocol buffers compiler [protoc](https://github.com/protocolbuffers/protobuf). It reads protobuf service definitions and generates a reverse-proxy server which translates a RESTful HTTP API into gRPC. This server is generated according to the [`google.api.http`](https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L46) annotations in your service definitions. This helps you provide your APIs in both gRPC and RESTful style at the same time.
## Docs You can read our docs at: - https://grpc-ecosystem.github.io/grpc-gateway/ ## Testimonials > We use the gRPC-Gateway to serve millions of API requests per day, > and have been since 2018 and through all of that, > we have never had any issues with it. > > _- William Mill, [Ad Hoc](http://adhocteam.us/)_ ## Background gRPC is great -- it generates API clients and server stubs in many programming languages, it is fast, easy-to-use, bandwidth-efficient and its design is combat-proven by Google. However, you might still want to provide a traditional RESTful JSON API as well. Reasons can range from maintaining backward-compatibility, supporting languages or clients that are not well supported by gRPC, to simply maintaining the aesthetics and tooling involved with a RESTful JSON architecture. This project aims to provide that HTTP+JSON interface to your gRPC service. A small amount of configuration in your service to attach HTTP semantics is all that's needed to generate a reverse-proxy with this library. ## Installation ### Compile from source The following instructions assume you are using [Go Modules](https://go.dev/wiki/Modules) for dependency management. Use a [tool dependency](https://go.dev/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module) to track the versions of the following executable packages: ```go // +build tools package tools import ( _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway" _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2" _ "google.golang.org/grpc/cmd/protoc-gen-go-grpc" _ "google.golang.org/protobuf/cmd/protoc-gen-go" ) ``` Run `go mod tidy` to resolve the versions. Install by running ```sh go install \ github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \ github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \ google.golang.org/protobuf/cmd/protoc-gen-go \ google.golang.org/grpc/cmd/protoc-gen-go-grpc ``` This will place four binaries in your `$GOBIN`; - `protoc-gen-grpc-gateway` - `protoc-gen-openapiv2` - `protoc-gen-go` - `protoc-gen-go-grpc` Make sure that your `$GOBIN` is in your `$PATH`. ### **Using the `tool` Directive in Go 1.24** Starting from Go 1.24, the `tool` directive in `go.mod` provides a structured way to track and manage executable dependencies. This replaces the previous workaround of using a separate `tools.go` file with blank imports. #### **Tracking Tools in `go.mod`** Instead of manually importing tool dependencies in a Go source file, you can now use the `tool` directive in `go.mod` to declare the tools your project depends on. For example: ```go module tools go 1.24 tool ( github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 google.golang.org/grpc/cmd/protoc-gen-go-grpc google.golang.org/protobuf/cmd/protoc-gen-go ) ``` #### **Managing Tool Dependencies** To add tools to your module, use the `-tool` flag with `go get`: ```sh go get -tool github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway go get -tool github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 go get -tool google.golang.org/protobuf/cmd/protoc-gen-go go get -tool google.golang.org/grpc/cmd/protoc-gen-go-grpc ``` This automatically updates `go.mod`, adding the tools under the `tool` directive along with `require` statements to ensure version tracking. ### Install Tools Once the tool dependencies are properly recorded in the `go.mod` file, simply execute the following command in the root directory of your project: ```sh go install tool ``` This will place four binaries in your `$GOBIN`; - `protoc-gen-grpc-gateway` - `protoc-gen-openapiv2` - `protoc-gen-go` - `protoc-gen-go-grpc` Make sure that your `$GOBIN` is in your `$PATH`. ### Download the binaries You may alternatively download the binaries from the [GitHub releases page](https://github.com/grpc-ecosystem/grpc-gateway/releases/latest). We generate [SLSA3 signatures](slsa.dev) using the OpenSSF's [slsa-framework/slsa-github-generator](https://github.com/slsa-framework/slsa-github-generator) during the release process. To verify a release binary: 1. Install the verification tool from [slsa-framework/slsa-verifier#installation](https://github.com/slsa-framework/slsa-verifier#installation). 2. Download the provenance file `attestation.intoto.jsonl` from the [GitHub releases page](https://github.com/grpc-ecosystem/grpc-gateway/releases/latest). 3. Run the verifier: ```shell slsa-verifier -artifact-path -provenance attestation.intoto.jsonl -source github.com/grpc-ecosystem/grpc-gateway -tag ``` Alternatively, see the section on remotely managed plugin versions below. ## Usage ### 1.Define your [gRPC](https://grpc.io/docs/) service using protocol buffers `your_service.proto`: ```protobuf syntax = "proto3"; package your.service.v1; option go_package = "github.com/yourorg/yourprotos/gen/go/your/service/v1"; message StringMessage { string value = 1; } service YourService { rpc Echo(StringMessage) returns (StringMessage) {} } ``` ### 2. Generate gRPC stubs This step generates the gRPC stubs that you can use to implement the service and consume from clients: Here's an example `buf.gen.yaml` you can use to generate the stubs with [buf](https://github.com/bufbuild/buf): ```yaml version: v2 plugins: - local: protoc-gen-go out: gen/go opt: - paths=source_relative - local: protoc-gen-go-grpc out: gen/go opt: - paths=source_relative ``` With this file in place, you can generate your files using `buf generate`. > For a complete example of using `buf generate` to generate protobuf stubs, see > [the boilerplate repo](https://github.com/johanbrandhorst/grpc-gateway-boilerplate). > For more information on generating the stubs with buf, see > [the official documentation](https://docs.buf.build/generate-usage). If you are using `protoc` to generate stubs, here's an example of what a command might look like: ```sh protoc -I . \ --go_out ./gen/go/ --go_opt paths=source_relative \ --go-grpc_out ./gen/go/ --go-grpc_opt paths=source_relative \ your/service/v1/your_service.proto ``` ### 3. Implement your service in gRPC as usual. ### 4. Generate reverse-proxy using `protoc-gen-grpc-gateway` At this point, you have 3 options: - no further modifications, use the default mapping to HTTP semantics (method, path, etc.) - this will work on any `.proto` file, but will not allow setting HTTP paths, request parameters or similar - additional `.proto` modifications to use a custom mapping - relies on parameters in the `.proto` file to set custom HTTP mappings - no `.proto` modifications, but use an external configuration file - relies on an external configuration file to set custom HTTP mappings - mostly useful when the source proto file isn't under your control #### 1. Using the default mapping This requires no additional modification to the `.proto` file but does require enabling a specific option when executing the plugin. The `generate_unbound_methods` should be enabled. Here's what a `buf.gen.yaml` file might look like with this option enabled: ```yaml version: v2 plugins: - local: protoc-gen-go out: gen/go opt: - paths=source_relative - local: protoc-gen-go-grpc out: gen/go opt: - paths=source_relative - local: protoc-gen-grpc-gateway out: gen/go opt: - paths=source_relative - generate_unbound_methods=true ``` With `protoc` (just the grpc-gateway stubs): ```sh protoc -I . --grpc-gateway_out ./gen/go \ --grpc-gateway_opt paths=source_relative \ --grpc-gateway_opt generate_unbound_methods=true \ your/service/v1/your_service.proto ``` #### 2. With custom annotations Add a [`google.api.http`](https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L46) annotation to your .proto file `your_service.proto`: ```diff syntax = "proto3"; package your.service.v1; option go_package = "github.com/yourorg/yourprotos/gen/go/your/service/v1"; + +import "google/api/annotations.proto"; + message StringMessage { string value = 1; } service YourService { - rpc Echo(StringMessage) returns (StringMessage) {} + rpc Echo(StringMessage) returns (StringMessage) { + option (google.api.http) = { + post: "/v1/example/echo" + body: "*" + }; + } } ``` > You will need to provide the required third party protobuf files to the protobuf compiler. > If you are using [buf](https://github.com/bufbuild/buf), this dependency can > be added to the `deps` array in your `buf.yaml` under the name > `buf.build/googleapis/googleapis`: > > ```yaml > version: v2 > name: buf.build/yourorg/myprotos > deps: > - buf.build/googleapis/googleapis > ``` > > Always run `buf dep update` after adding a dependency to your `buf.yaml`. See [a_bit_of_everything.proto](examples/internal/proto/examplepb/a_bit_of_everything.proto) for examples of more annotations you can add to customize gateway behavior and generated OpenAPI output. Here's what a `buf.gen.yaml` file might look like: ```yaml version: v2 plugins: - local: protoc-gen-go out: gen/go opt: - paths=source_relative - local: protoc-gen-go-grpc out: gen/go opt: - paths=source_relative - local: protoc-gen-grpc-gateway out: gen/go opt: - paths=source_relative ``` If you are using `protoc` to generate stubs, you need to ensure the required dependencies are available to the compiler at compile time. These can be found by manually cloning and copying the relevant files from the [googleapis repository](https://github.com/googleapis/googleapis), and providing them to `protoc` when running. The files you will need are: ``` google/api/annotations.proto google/api/field_behavior.proto google/api/http.proto google/api/httpbody.proto ``` Here's what a `protoc` execution might look like: ```sh protoc -I . --grpc-gateway_out ./gen/go \ --grpc-gateway_opt paths=source_relative \ your/service/v1/your_service.proto ``` #### 3. External configuration If you do not want to (or cannot) modify the proto file for use with gRPC-Gateway you can alternatively use an external [gRPC Service Configuration](https://cloud.google.com/endpoints/docs/grpc/grpc-service-config) file. [Check our documentation](https://grpc-ecosystem.github.io/grpc-gateway/docs/mapping/grpc_api_configuration/) for more information. This is best combined with the `standalone=true` option to generate a file that can live in its own package, separate from the files generated by the source protobuf file. Here's what a `buf.gen.yaml` file might look like with this option enabled: ```yaml version: v2 plugins: - local: protoc-gen-go out: gen/go opt: - paths=source_relative - local: protoc-gen-go-grpc out: gen/go opt: - paths=source_relative - local: protoc-gen-grpc-gateway out: gen/go opt: - paths=source_relative - grpc_api_configuration=path/to/config.yaml - standalone=true ``` With `protoc` (just the grpc-gateway stubs): ```sh protoc -I . --grpc-gateway_out ./gen/go \ --grpc-gateway_opt paths=source_relative \ --grpc-gateway_opt grpc_api_configuration=path/to/config.yaml \ --grpc-gateway_opt standalone=true \ your/service/v1/your_service.proto ``` ### 5. Write an entrypoint for the HTTP reverse-proxy server ```go package main import ( "context" "flag" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/grpclog" gw "github.com/yourorg/yourrepo/proto/gen/go/your/service/v1/your_service" // Update ) var ( // command-line options: // gRPC server endpoint grpcServerEndpoint = flag.String("grpc-server-endpoint", "localhost:9090", "gRPC server endpoint") ) func run() error { ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() // Register gRPC server endpoint // Note: Make sure the gRPC server is running properly and accessible mux := runtime.NewServeMux() opts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())} err := gw.RegisterYourServiceHandlerFromEndpoint(ctx, mux, *grpcServerEndpoint, opts) if err != nil { return err } // Start HTTP server (and proxy calls to gRPC server endpoint) return http.ListenAndServe(":8081", mux) } func main() { flag.Parse() if err := run(); err != nil { grpclog.Fatal(err) } } ``` ### 6. (Optional) Generate OpenAPI definitions using `protoc-gen-openapiv2` Here's what a `buf.gen.yaml` file might look like: ```yaml version: v2 plugins: - local: protoc-gen-go out: gen/go opt: - paths=source_relative - local: protoc-gen-go-grpc out: gen/go opt: - paths=source_relative - local: protoc-gen-grpc-gateway out: gen/go opt: - paths=source_relative - generate_unbound_methods=true - local: protoc-gen-openapiv2 out: gen/go ``` To use the custom protobuf annotations supported by `protoc-gen-openapiv2`, we need another dependency added to our protobuf generation step. If you are using `buf`, you can add the `buf.build/grpc-ecosystem/grpc-gateway` dependency to your `deps` array: ```yaml version: v2 name: buf.build/yourorg/myprotos deps: - buf.build/googleapis/googleapis - buf.build/grpc-ecosystem/grpc-gateway ``` With `protoc` (just the swagger file): ```sh protoc -I . --openapiv2_out ./gen/openapiv2 \ your/service/v1/your_service.proto ``` If you are using `protoc` to generate stubs, you will need to copy the protobuf files from the `protoc-gen-openapiv2/options` directory of this repository, and providing them to `protoc` when running. Note that this plugin also supports generating OpenAPI definitions for unannotated methods; use the `generate_unbound_methods` option to enable this. It is possible with the HTTP mapping for a gRPC service method to create duplicate mappings with the only difference being constraints on the path parameter. `/v1/{name=projects/*}` and `/v1/{name=organizations/*}` both become `/v1/{name}`. When this occurs the plugin will rename the path parameter with a "\_1" (or "\_2" etc) suffix to differentiate the different operations. So in the above example, the 2nd path would become `/v1/{name_1=organizations/*}`. This can also cause OpenAPI clients to URL encode the "/" that is part of the path parameter as that is what OpenAPI defines in the specification. To allow gRPC gateway to accept the URL encoded slash and still route the request, use the UnescapingModeAllCharacters or UnescapingModeLegacy (which is the default currently though may change in future versions). See [Customizing Your Gateway](https://grpc-ecosystem.github.io/grpc-gateway/docs/mapping/customizing_your_gateway/) for more information. ## Usage with remote plugins As an alternative to all of the above, you can use `buf` with [remote plugins](https://buf.build/docs/bsr/remote-plugins/usage) to manage plugin versions and generation. An example `buf.gen.yaml` using remote plugin generation looks like this: ```yaml version: v2 plugins: - remote: buf.build/protocolbuffers/go:v1.31.0 out: gen/go opt: - paths=source_relative - remote: buf.build/grpc/go:v1.3.0 out: gen/go opt: - paths=source_relative - remote: buf.build/grpc-ecosystem/gateway:v2.16.2 out: gen/go opt: - paths=source_relative - remote: buf.build/grpc-ecosystem/openapiv2:v2.16.2 out: gen/openapiv2 ``` This requires no local installation of any plugins. Be careful to use the same version of the generator as the runtime library, i.e. if using `v2.16.2`, run ```shell $ go get github.com/grpc-ecosystem/grpc-gateway/v2@v2.16.2 ``` To get the same version of the runtime in your `go.mod`. Note that usage of remote plugins is incompatible with usage of external configuration files like [grpc_api_configuration](https://grpc-ecosystem.github.io/grpc-gateway/docs/mapping/grpc_api_configuration/#using-an-external-configuration-file). ## Video intro This GopherCon UK 2019 presentation from our maintainer [@JohanBrandhorst](https://github.com/johanbrandhorst) provides a good intro to using the gRPC-Gateway. It uses the following boilerplate repo as a base: https://github.com/johanbrandhorst/grpc-gateway-boilerplate.
## Parameters and flags When using `buf` to generate stubs, flags and parameters are passed through the `opt` field in your `buf.gen.yaml` file, for example: ```yaml version: v2 plugins: - local: protoc-gen-grpc-gateway out: gen/go opt: - paths=source_relative - grpc_api_configuration=path/to/config.yaml - standalone=true ``` During code generation with `protoc`, flags to gRPC-Gateway tools must be passed through `protoc` using one of 2 patterns: - as part of the `--_out` `protoc` parameter: `--_out=:` ```sh --grpc-gateway_out=repeated_path_param_separator=ssv:. --openapiv2_out=repeated_path_param_separator=ssv:. ``` - using additional `--_opt` parameters: `--_opt=[,]*` ```sh --grpc-gateway_opt repeated_path_param_separator=ssv --openapiv2_opt repeated_path_param_separator=ssv ``` ## More examples More examples are available under the `examples` directory. - `proto/examplepb/echo_service.proto`, `proto/examplepb/a_bit_of_everything.proto`, `proto/examplepb/unannotated_echo_service.proto`: service definition - `proto/examplepb/echo_service.pb.go`, `proto/examplepb/a_bit_of_everything.pb.go`, `proto/examplepb/unannotated_echo_service.pb.go`: [generated] stub of the service - `proto/examplepb/echo_service.pb.gw.go`, `proto/examplepb/a_bit_of_everything.pb.gw.go`, `proto/examplepb/uannotated_echo_service.pb.gw.go`: [generated] reverse proxy for the service - `proto/examplepb/unannotated_echo_service.yaml`: gRPC API Configuration for `unannotated_echo_service.proto` - `server/main.go`: service implementation - `main.go`: entrypoint of the generated reverse proxy To use the same port for custom HTTP handlers (e.g. serving `swagger.json`), gRPC-Gateway, and a gRPC server, see [this example by CoreOS](https://github.com/philips/grpc-gateway-example/blob/master/cmd/serve.go) (and its accompanying [blog post](https://web.archive.org/web/20201112010739/https://coreos.com/blog/grpc-protobufs-swagger.html)). [This example by neiro.ai](https://github.com/mynalabsai/grpc_gateway_media_example) (and its accompanying [blog post](https://medium.com/neiro-ai/grpc-gateway-for-media-api-by-neiro-9033caab12c8)) shows how mediafiles using `multipart/form-data` can be integrated into rpc messages using a middleware. ## Features ### Supported - Generating JSON API handlers. - Method parameters in the request body. - Method parameters in the request path. - Method parameters in the query string. - Enum fields in the path parameter (including repeated enum fields). - Mapping streaming APIs to newline-delimited JSON streams. - Mapping HTTP headers with `Grpc-Metadata-` prefix to gRPC metadata (prefixed with `grpcgateway-`) - Optionally emitting API definitions for [OpenAPI (Swagger) v2](https://swagger.io/docs/specification/2-0/basic-structure/). - Setting [gRPC timeouts](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests) through inbound HTTP `Grpc-Timeout` header. - Partial support for [gRPC API Configuration](https://cloud.google.com/endpoints/docs/grpc/grpc-service-config) files as an alternative to annotation. - Automatically translating PATCH requests into Field Mask gRPC requests. See [the docs](https://grpc-ecosystem.github.io/grpc-gateway/docs/mapping/patch_feature/) for more information. - [Protobuf Editions](https://protobuf.dev/editions/overview/) support (edition 2023). - Go [Opaque API](https://go.dev/blog/protobuf-opaque) support. ### No plan to support But patches are welcome. - Method parameters in HTTP headers. - Handling trailer metadata. - Encoding request/response body in XML. - True bi-directional streaming. ## Mapping gRPC to HTTP - [How gRPC error codes map to HTTP status codes in the response](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/runtime/errors.go#L15). - HTTP request source IP is added as `X-Forwarded-For` gRPC request header. - HTTP request host is added as `X-Forwarded-Host` gRPC request header. - HTTP `Authorization` header is added as `authorization` gRPC request header. - Remaining Permanent HTTP header keys (as specified by the IANA [here](http://www.iana.org/assignments/message-headers/message-headers.xhtml)) are prefixed with `grpcgateway-` and added with their values to gRPC request header. - HTTP headers that start with 'Grpc-Metadata-' are mapped to gRPC metadata (prefixed with `grpcgateway-`). - While configurable, the default {un,}marshaling uses [protojson](https://pkg.go.dev/google.golang.org/protobuf/encoding/protojson). - The path template used to map gRPC service methods to HTTP endpoints supports the [google.api.http](https://github.com/googleapis/googleapis/blob/master/google/api/http.proto) path template syntax. For example, `/api/v1/{name=projects/*/topics/*}` or `/prefix/{path=organizations/**}`. ## Contribution See [CONTRIBUTING.md](http://github.com/grpc-ecosystem/grpc-gateway/blob/main/CONTRIBUTING.md). ## License gRPC-Gateway is licensed under the BSD 3-Clause License. See [LICENSE](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE) for more details. ================================================ FILE: WORKSPACE ================================================ workspace(name = "grpc_ecosystem_grpc_gateway") load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "bazel_features", sha256 = "c26b4e69cf02fea24511a108d158188b9d8174426311aac59ce803a78d107648", strip_prefix = "bazel_features-1.43.0", url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.43.0/bazel_features-v1.43.0.tar.gz", ) load("@bazel_features//:deps.bzl", "bazel_features_deps") bazel_features_deps() http_archive( name = "rules_python", sha256 = "098ba13578e796c00c853a2161f382647f32eb9a77099e1c88bc5299333d0d6e", strip_prefix = "rules_python-1.9.0", url = "https://github.com/bazelbuild/rules_python/releases/download/1.9.0/rules_python-1.9.0.tar.gz", ) load("@rules_python//python:repositories.bzl", "py_repositories") py_repositories() http_archive( name = "com_google_googletest", sha256 = "40d4ec942217dcc84a9ebe2a68584ada7d4a33a8ee958755763278ea1c5e18ff", strip_prefix = "googletest-1.17.0", urls = ["https://github.com/google/googletest/archive/v1.17.0.zip"], ) # Define before rules_proto, otherwise we receive the version of com_google_protobuf from there http_archive( name = "com_google_protobuf", sha256 = "a83103b7ed3afaeedee9a212c8f65825444f58144f5e075b73c83f2b4ff27b62", strip_prefix = "protobuf-34.1", urls = ["https://github.com/protocolbuffers/protobuf/archive/v34.1.tar.gz"], ) http_archive( name = "googleapis", sha256 = "1ec16c560b6fb94413dedd3f5abca88b72a9047ddec3225e0e654d122f64dd71", strip_prefix = "googleapis-cba8415718590712af80d0fd90a5f016a2607b25", urls = [ "https://github.com/googleapis/googleapis/archive/cba8415718590712af80d0fd90a5f016a2607b25.zip", ], ) load("@googleapis//:repository_rules.bzl", "switched_rules_by_language") switched_rules_by_language( name = "com_google_googleapis_imports", ) http_archive( name = "bazel_skylib", sha256 = "3b5b49006181f5f8ff626ef8ddceaa95e9bb8ad294f7b5d7b11ea9f7ddaf8c59", urls = [ "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.9.0/bazel-skylib-1.9.0.tar.gz", "https://github.com/bazelbuild/bazel-skylib/releases/download/1.9.0/bazel-skylib-1.9.0.tar.gz", ], ) load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") bazel_skylib_workspace() http_archive( name = "rules_proto", sha256 = "14a225870ab4e91869652cfd69ef2028277fc1dc4910d65d353b62d6e0ae21f4", strip_prefix = "rules_proto-7.1.0", urls = [ "https://github.com/bazelbuild/rules_proto/archive/refs/tags/7.1.0.tar.gz", ], ) load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies") rules_proto_dependencies() load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains") rules_proto_toolchains() http_archive( name = "io_bazel_rules_go", sha256 = "86d3dc8f59d253524f933aaf2f3c05896cb0b605fc35b460c0b4b039996124c6", urls = [ "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.60.0/rules_go-v0.60.0.zip", "https://github.com/bazelbuild/rules_go/releases/download/v0.60.0/rules_go-v0.60.0.zip", ], ) load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") go_rules_dependencies() go_register_toolchains(version = "1.26.0") http_archive( name = "bazel_gazelle", sha256 = "675114d8b433d0a9f54d81171833be96ebc4113115664b791e6f204d58e93446", urls = [ "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.47.0/bazel-gazelle-v0.47.0.tar.gz", "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.47.0/bazel-gazelle-v0.47.0.tar.gz", ], ) load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") # Use gazelle to declare Go dependencies in Bazel. # gazelle:repository_macro repositories.bzl%go_repositories load("//:repositories.bzl", "go_repositories") go_repositories() # This must be invoked after our explicit dependencies # See https://github.com/bazelbuild/bazel-gazelle/issues/1115. gazelle_dependencies() load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") protobuf_deps() http_archive( name = "rules_shell", sha256 = "e17f72732618a6536559b3015dbe190ef592f7b9ba81969ff4bca766c451b3a5", strip_prefix = "rules_shell-0.7.0", url = "https://github.com/bazelbuild/rules_shell/releases/download/v0.7.0/rules_shell-v0.7.0.tar.gz", ) load("@rules_shell//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains") rules_shell_dependencies() rules_shell_toolchains() http_archive( name = "com_github_bazelbuild_buildtools", sha256 = "f3b800e9f6ca60bdef3709440f393348f7c18a29f30814288a7326285c80aab9", strip_prefix = "buildtools-8.5.1", urls = ["https://github.com/bazelbuild/buildtools/archive/v8.5.1.tar.gz"], ) load("@com_github_bazelbuild_buildtools//buildifier:deps.bzl", "buildifier_dependencies") buildifier_dependencies() ================================================ FILE: bin/.gitignore ================================================ /protoc-gen-go /protoc-gen-go-grpc /protoc-gen-grpc-gateway /protoc-gen-openapiv2 ================================================ FILE: buf.gen.yaml ================================================ version: v2 plugins: - remote: buf.build/protocolbuffers/go:v1.35.1 out: . opt: - paths=source_relative - remote: buf.build/grpc/go:v1.5.1 out: . opt: - paths=source_relative - require_unimplemented_servers=false - local: protoc-gen-grpc-gateway out: . opt: - paths=source_relative - allow_repeated_fields_in_body=true - local: protoc-gen-openapiv2 out: . opt: - allow_repeated_fields_in_body=true ================================================ FILE: buf.yaml ================================================ version: v1 name: buf.build/grpc-ecosystem/grpc-gateway deps: - buf.build/googleapis/googleapis breaking: use: - FILE lint: use: - DEFAULT ignore_only: DIRECTORY_SAME_PACKAGE: - examples/internal/proto/examplepb/a_bit_of_everything.proto - examples/internal/proto/examplepb/camel_case_service.proto - examples/internal/proto/examplepb/echo_service.proto - examples/internal/proto/examplepb/enum_with_single_value.proto - examples/internal/proto/examplepb/flow_combination.proto - examples/internal/proto/examplepb/generate_unbound_methods.proto - examples/internal/proto/examplepb/generated_input.proto - examples/internal/proto/examplepb/excess_body.proto - examples/internal/proto/examplepb/non_standard_names.proto - examples/internal/proto/examplepb/opaque.proto - examples/internal/proto/examplepb/openapi_merge_a.proto - examples/internal/proto/examplepb/openapi_merge_b.proto - examples/internal/proto/examplepb/proto3_field_semantics.proto - examples/internal/proto/examplepb/response_body_service.proto - examples/internal/proto/examplepb/stream.proto - examples/internal/proto/examplepb/unannotated_echo_service.proto - examples/internal/proto/examplepb/visibility_rule_echo_service.proto - examples/internal/proto/examplepb/use_go_template.proto - examples/internal/proto/examplepb/ignore_comment.proto - examples/internal/proto/examplepb/remove_internal_comment.proto - examples/internal/proto/examplepb/wrappers.proto ENUM_PASCAL_CASE: - examples/internal/proto/sub/camel_case_message.proto ENUM_VALUE_PREFIX: - examples/internal/proto/examplepb/a_bit_of_everything.proto - examples/internal/proto/examplepb/response_body_service.proto - examples/internal/proto/pathenum/path_enum.proto - protoc-gen-openapiv2/options/openapiv2.proto - runtime/internal/examplepb/example.proto - runtime/internal/examplepb/proto3.proto ENUM_ZERO_VALUE_SUFFIX: - examples/internal/proto/examplepb/a_bit_of_everything.proto - examples/internal/proto/examplepb/response_body_service.proto - examples/internal/proto/pathenum/path_enum.proto - protoc-gen-openapiv2/options/openapiv2.proto - runtime/internal/examplepb/example.proto - runtime/internal/examplepb/proto3.proto FIELD_LOWER_SNAKE_CASE: - examples/internal/helloworld/helloworld.proto - examples/internal/proto/examplepb/a_bit_of_everything.proto - examples/internal/proto/examplepb/non_standard_names.proto - runtime/internal/examplepb/example.proto - runtime/internal/examplepb/non_standard_names.proto MESSAGE_PASCAL_CASE: - examples/internal/proto/sub/camel_case_message.proto PACKAGE_DIRECTORY_MATCH: - examples/internal/helloworld/helloworld.proto - examples/internal/proto/examplepb/a_bit_of_everything.proto - examples/internal/proto/examplepb/camel_case_service.proto - examples/internal/proto/examplepb/echo_service.proto - examples/internal/proto/examplepb/enum_with_single_value.proto - examples/internal/proto/examplepb/flow_combination.proto - examples/internal/proto/examplepb/generate_unbound_methods.proto - examples/internal/proto/examplepb/generated_input.proto - examples/internal/proto/examplepb/excess_body.proto - examples/internal/proto/examplepb/non_standard_names.proto - examples/internal/proto/examplepb/opaque.proto - examples/internal/proto/examplepb/openapi_merge_a.proto - examples/internal/proto/examplepb/openapi_merge_b.proto - examples/internal/proto/examplepb/proto3_field_semantics.proto - examples/internal/proto/examplepb/response_body_service.proto - examples/internal/proto/examplepb/stream.proto - examples/internal/proto/examplepb/unannotated_echo_service.proto - examples/internal/proto/examplepb/visibility_rule_echo_service.proto - examples/internal/proto/examplepb/use_go_template.proto - examples/internal/proto/examplepb/ignore_comment.proto - examples/internal/proto/examplepb/remove_internal_comment.proto - examples/internal/proto/examplepb/wrappers.proto - examples/internal/proto/oneofenum/oneof_enum.proto - examples/internal/proto/pathenum/path_enum.proto - examples/internal/proto/sub/camel_case_message.proto - examples/internal/proto/sub/message.proto - examples/internal/proto/sub2/message.proto - internal/descriptor/apiconfig/apiconfig.proto - internal/descriptor/openapiconfig/openapiconfig.proto - protoc-gen-openapiv2/options/annotations.proto - protoc-gen-openapiv2/options/openapiv2.proto - runtime/internal/examplepb/example.proto - runtime/internal/examplepb/non_standard_names.proto - runtime/internal/examplepb/proto2.proto - runtime/internal/examplepb/proto3.proto PACKAGE_SAME_GO_PACKAGE: - examples/internal/proto/examplepb/a_bit_of_everything.proto - examples/internal/proto/examplepb/camel_case_service.proto - examples/internal/proto/examplepb/echo_service.proto - examples/internal/proto/examplepb/enum_with_single_value.proto - examples/internal/proto/examplepb/flow_combination.proto - examples/internal/proto/examplepb/generate_unbound_methods.proto - examples/internal/proto/examplepb/generated_input.proto - examples/internal/proto/examplepb/excess_body.proto - examples/internal/proto/examplepb/non_standard_names.proto - examples/internal/proto/examplepb/opaque.proto - examples/internal/proto/examplepb/proto3_field_semantics.proto - examples/internal/proto/examplepb/response_body_service.proto - examples/internal/proto/examplepb/stream.proto - examples/internal/proto/examplepb/unannotated_echo_service.proto - examples/internal/proto/examplepb/visibility_rule_echo_service.proto - examples/internal/proto/examplepb/use_go_template.proto - examples/internal/proto/examplepb/ignore_comment.proto - examples/internal/proto/examplepb/remove_internal_comment.proto - examples/internal/proto/examplepb/wrappers.proto - runtime/internal/examplepb/example.proto - runtime/internal/examplepb/non_standard_names.proto - runtime/internal/examplepb/proto2.proto - runtime/internal/examplepb/proto3.proto PACKAGE_VERSION_SUFFIX: - examples/internal/helloworld/helloworld.proto - examples/internal/proto/examplepb/a_bit_of_everything.proto - examples/internal/proto/examplepb/camel_case_service.proto - examples/internal/proto/examplepb/echo_service.proto - examples/internal/proto/examplepb/enum_with_single_value.proto - examples/internal/proto/examplepb/flow_combination.proto - examples/internal/proto/examplepb/generate_unbound_methods.proto - examples/internal/proto/examplepb/generated_input.proto - examples/internal/proto/examplepb/excess_body.proto - examples/internal/proto/examplepb/non_standard_names.proto - examples/internal/proto/examplepb/opaque.proto - examples/internal/proto/examplepb/openapi_merge_a.proto - examples/internal/proto/examplepb/openapi_merge_b.proto - examples/internal/proto/examplepb/proto3_field_semantics.proto - examples/internal/proto/examplepb/response_body_service.proto - examples/internal/proto/examplepb/stream.proto - examples/internal/proto/examplepb/unannotated_echo_service.proto - examples/internal/proto/examplepb/visibility_rule_echo_service.proto - examples/internal/proto/examplepb/use_go_template.proto - examples/internal/proto/examplepb/ignore_comment.proto - examples/internal/proto/examplepb/remove_internal_comment.proto - examples/internal/proto/examplepb/wrappers.proto - examples/internal/proto/oneofenum/oneof_enum.proto - examples/internal/proto/pathenum/path_enum.proto - examples/internal/proto/sub/camel_case_message.proto - examples/internal/proto/sub/message.proto - examples/internal/proto/sub2/message.proto - internal/descriptor/apiconfig/apiconfig.proto - internal/descriptor/openapiconfig/openapiconfig.proto - protoc-gen-openapiv2/options/annotations.proto - protoc-gen-openapiv2/options/openapiv2.proto - runtime/internal/examplepb/example.proto - runtime/internal/examplepb/non_standard_names.proto - runtime/internal/examplepb/proto2.proto - runtime/internal/examplepb/proto3.proto RPC_PASCAL_CASE: - examples/internal/proto/examplepb/camel_case_service.proto RPC_REQUEST_RESPONSE_UNIQUE: - examples/internal/proto/examplepb/a_bit_of_everything.proto - examples/internal/proto/examplepb/echo_service.proto - examples/internal/proto/examplepb/flow_combination.proto - examples/internal/proto/examplepb/generate_unbound_methods.proto - examples/internal/proto/examplepb/generated_input.proto - examples/internal/proto/examplepb/excess_body.proto - examples/internal/proto/examplepb/openapi_merge_a.proto - examples/internal/proto/examplepb/openapi_merge_b.proto - examples/internal/proto/examplepb/response_body_service.proto - examples/internal/proto/examplepb/stream.proto - examples/internal/proto/examplepb/unannotated_echo_service.proto - examples/internal/proto/examplepb/visibility_rule_echo_service.proto - examples/internal/proto/examplepb/wrappers.proto RPC_REQUEST_STANDARD_NAME: - examples/internal/helloworld/helloworld.proto - examples/internal/proto/examplepb/a_bit_of_everything.proto - examples/internal/proto/examplepb/echo_service.proto - examples/internal/proto/examplepb/flow_combination.proto - examples/internal/proto/examplepb/generate_unbound_methods.proto - examples/internal/proto/examplepb/generated_input.proto - examples/internal/proto/examplepb/excess_body.proto - examples/internal/proto/examplepb/non_standard_names.proto - examples/internal/proto/examplepb/openapi_merge_a.proto - examples/internal/proto/examplepb/openapi_merge_b.proto - examples/internal/proto/examplepb/response_body_service.proto - examples/internal/proto/examplepb/stream.proto - examples/internal/proto/examplepb/unannotated_echo_service.proto - examples/internal/proto/examplepb/visibility_rule_echo_service.proto - examples/internal/proto/examplepb/wrappers.proto - runtime/internal/examplepb/non_standard_names.proto RPC_RESPONSE_STANDARD_NAME: - examples/internal/helloworld/helloworld.proto - examples/internal/proto/examplepb/a_bit_of_everything.proto - examples/internal/proto/examplepb/echo_service.proto - examples/internal/proto/examplepb/flow_combination.proto - examples/internal/proto/examplepb/generate_unbound_methods.proto - examples/internal/proto/examplepb/generated_input.proto - examples/internal/proto/examplepb/excess_body.proto - examples/internal/proto/examplepb/non_standard_names.proto - examples/internal/proto/examplepb/openapi_merge_a.proto - examples/internal/proto/examplepb/openapi_merge_b.proto - examples/internal/proto/examplepb/response_body_service.proto - examples/internal/proto/examplepb/stream.proto - examples/internal/proto/examplepb/unannotated_echo_service.proto - examples/internal/proto/examplepb/visibility_rule_echo_service.proto - examples/internal/proto/examplepb/use_go_template.proto - examples/internal/proto/examplepb/ignore_comment.proto - examples/internal/proto/examplepb/remove_internal_comment.proto - examples/internal/proto/examplepb/wrappers.proto - runtime/internal/examplepb/non_standard_names.proto SERVICE_PASCAL_CASE: - examples/internal/proto/examplepb/a_bit_of_everything.proto - examples/internal/proto/examplepb/camel_case_service.proto SERVICE_SUFFIX: - examples/internal/helloworld/helloworld.proto - examples/internal/proto/examplepb/a_bit_of_everything.proto - examples/internal/proto/examplepb/camel_case_service.proto - examples/internal/proto/examplepb/flow_combination.proto - examples/internal/proto/examplepb/openapi_merge_a.proto - examples/internal/proto/examplepb/openapi_merge_b.proto allow_comment_ignores: true # Note: the build configuration goes last in this # files so we can append excludes at push time. build: excludes: - bazel-grpc-gateway ================================================ FILE: docs/.gitignore ================================================ *.gem .bundle .ruby-version .jekyll-cache .sass-cache _site ================================================ FILE: docs/Gemfile ================================================ source "https://rubygems.org" gem "just-the-docs" group :jekyll_plugins do gem "github-pages" # GitHub Pages gem "jekyll-optional-front-matter" # GitHub Pages gem "jekyll-default-layout" # GitHub Pages gem "jekyll-titles-from-headings" # GitHub Pages gem "jekyll-readme-index" # GitHub Pages gem "jekyll-relative-links" # GitHub Pages gem 'jekyll-include-cache' # GitHub Pages end ================================================ FILE: docs/_config.yml ================================================ # Site settings # These are used to personalize your new site. If you look in the HTML files, # you will see them accessed via {{ site.title }}, {{ site.github_repo }}, and so on. # You can create any custom variable you would like, and they will be accessible # in the templates via {{ site.myvariable }}. title: gRPC-Gateway description: gRPC-Gateway Documentation Website baseurl: "/grpc-gateway" # the subpath of your site, e.g. /blog url: "https://grpc-ecosystem.github.io" # the base hostname & protocol for your site, e.g. http://example.com repository: grpc-ecosystem/grpc-gateway remote_theme: pmarsceill/just-the-docs@v0.6.2 permalink: pretty exclude: ["run.sh"] # Set a path/url to a logo that will be displayed instead of the title #logo: "/assets/images/grpc-gateway.png" # Enable or disable the site search # Supports true (default) or false search_enabled: true search: # Split pages into sections that can be searched individually # Supports 1 - 6, default: 2 heading_level: 2 # Maximum amount of previews per search result # Default: 3 previews: 2 # Maximum amount of words to display before a matched word in the preview # Default: 5 preview_words_before: 3 # Maximum amount of words to display after a matched word in the preview # Default: 10 preview_words_after: 3 # Set the search token separator # Default: /[\s\-/]+/ # Example: enable support for hyphenated search words tokenizer_separator: /[\s/]+/ # Display the relative url in search results # Supports true (default) or false rel_url: true # Enable or disable the search button that appears in the bottom right corner of every page # Supports true or false (default) button: false # Enable or disable heading anchors heading_anchors: true # Aux links for the upper right navigation aux_links: "gRPC-Gateway on GitHub": - "https://github.com/grpc-ecosystem/grpc-gateway" # Makes Aux links open in a new tab. Default is false aux_links_new_tab: false # Sort order for navigation links # nav_sort: case_insensitive # default, equivalent to nil nav_sort: case_sensitive # Capital letters sorted before lowercase # Footer content # appears at the bottom of every page's main content # Back to top link back_to_top: true back_to_top_text: "Back to top" footer_content: 'Copyright © the gRPC-Gateway Authors. Distributed by a BSD 3-Clause License.' # Footer last edited timestamp last_edit_timestamp: true # show or hide edit time - page must have `last_modified_date` defined in the frontmatter last_edit_time_format: "%b %e %Y at %I:%M %p" # uses ruby's time format: https://ruby-doc.org/stdlib-2.7.0/libdoc/time/rdoc/Time.html # Footer "Edit this page on GitHub" link text gh_edit_link: true # show or hide edit this page link gh_edit_link_text: "Edit this page on GitHub" gh_edit_repository: "https://github.com/grpc-ecosystem/grpc-gateway" # the github URL for your repo gh_edit_branch: "main" # the branch that your docs is served from gh_edit_source: docs # the source that your files originate from gh_edit_view_mode: "tree" # "tree" or "edit" if you want the user to jump into the editor immediately # Color scheme currently only supports "dark", "light"/nil (default), or a custom scheme that you define color_scheme: nil # Disqus Comments # disqus: # Leave shortname blank to disable comments site-wide. # Enable comments for any post by adding `comments: true` to that post's YAML Front Matter. # shortname: # Google Analytics Tracking # e.g, UA-1234567-89 # ga_tracking: # ga_tracking_anonymize_ip: true # Use GDPR compliant Google Analytics settings (true/nil by default) plugins: - jekyll-seo-tag - jekyll-include-cache kramdown: syntax_highlighter_opts: block: line_numbers: false compress_html: clippings: all comments: all endings: all startings: [] blanklines: false profile: false # ignore: # envs: all ================================================ FILE: docs/_layouts/default.html ================================================ --- layout: table_wrappers --- {% include head.html %} Link Search Menu Expand Document
{% if site.search_enabled != false %} {% endif %} {% if site.aux_links %} {% endif %}
{% unless page.url == "/" %} {% if page.parent %} {% endif %} {% endunless %}
{% if site.heading_anchors != false %} {% include vendor/anchor_headings.html html=content beforeHeading="true" anchorBody="" anchorClass="anchor-heading" anchorAttrs="aria-labelledby=\"%html_id%\"" %} {% else %} {{ content }} {% endif %} {% if page.has_children == true and page.has_toc != false %}

Table of contents

    {%- assign children_list = pages_list | where: "parent", page.title | where: "grand_parent", page.parent -%} {% for child in children_list %}
  • {{ child.title }}{% if child.summary %} - {{ child.summary }}{% endif %}
  • {% endfor %}
{% endif %} {% if site.footer_content != nil or site.last_edit_timestamp or site.gh_edit_link %}
{% if site.back_to_top %}

{{ site.back_to_top_text }}

{% endif %} {% if site.footer_content != nil %}

{{ site.footer_content }}

{% endif %} {% if site.last_edit_timestamp or site.gh_edit_link %}
{% if site.last_edit_timestamp and site.last_edit_time_format and page.last_modified_date %}

Page last modified: {{ page.last_modified_date | date: site.last_edit_time_format }}.

{% endif %} {% if site.gh_edit_link and site.gh_edit_link_text and site.gh_edit_repository and site.gh_edit_branch and site.gh_edit_view_mode %}

{{ site.gh_edit_link_text }}

{% endif %}
{% endif %} {% if site.disqus.shortname %} {% include comments.html %} {% endif %}
{% endif %}
{% if site.search_enabled != false %} {% if site.search.button %} {% endif %}
{% endif %}
================================================ FILE: docs/docs/contributing/2020_season_of_docs.md ================================================ --- layout: default title: Google Season of Docs nav_order: 1 parent: Contributing --- # 2020 Season of Docs
The gRPC-Gateway participated in the 2020 [Google Season of Docs](https://g.co/seasonofdocs). The project was completed by [@iamrajiv](https://github.com/iamrajiv). A summary of the project work can be found in the [project report](https://github.com/iamrajiv/GSoD-2020/blob/master/GSoD_2020_Project_Report.md). ================================================ FILE: docs/docs/contributing/getting_started.md ================================================ --- layout: default title: Getting started nav_order: 0 parent: Contributing --- # How to contribute See [CONTRIBUTING.md](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/CONTRIBUTING.md). ================================================ FILE: docs/docs/contributing/index.md ================================================ --- layout: default title: Contributing nav_order: 5 has_children: true --- ================================================ FILE: docs/docs/development/grpc-gateway_v2_migration_guide.md ================================================ --- layout: default title: gRPC-Gateway v2 migration guide nav_order: 0 parent: Development --- # gRPC-Gateway v2 migration guide This guide is supposed to help users of the gateway migrate from v1 to v2. See [the original issue](https://github.com/grpc-ecosystem/grpc-gateway/issues/1223) for detailed information on all changes that were made specifically to v2. The following behavioural defaults have been changed: ## protoc-gen-swagger has been renamed protoc-gen-openapiv2 See [the original issue](https://github.com/grpc-ecosystem/grpc-gateway/issues/675) for more information. Apart from the new name, the only real difference to users will be a slightly different proto annotation: ```protobuf import "protoc-gen-openapiv2/options/annotations.proto"; ``` instead of ```protobuf import "protoc-gen-swagger/options/annotations.proto"; ``` and ```protobuf option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { ``` instead of ```protobuf option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = { ``` The Bazel rule has been renamed `protoc_gen_openapiv2`. ## The example field in the OpenAPI annotations is now a string This was a `google.protobuf.Any` type, but it was only used for the JSON representation, and it was breaking some tools and it was generally unclear to the user how it works. It is now a string instead. The value is copied verbatim to the output OpenAPI file. Remember to escape any quotes in the strings. For example, if you had an example that looked like this: ```protobuf example: { value: '{ "uuid": "0cf361e1-4b44-483d-a159-54dabdf7e814" }' } ``` It would now look like this: ```protobuf example: "{\"uuid\": \"0cf361e1-4b44-483d-a159-54dabdf7e814\"}" ``` See [a_bit_of_everything.proto](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/examples/internal/proto/examplepb/a_bit_of_everything.proto) in the example protos for more examples. ## We now use the camelCase JSON names by default See [the original issue](https://github.com/grpc-ecosystem/grpc-gateway/issues/375) and [original pull request](https://github.com/grpc-ecosystem/grpc-gateway/pull/540) for more information. If you want to revert to the old behaviour, configure a custom marshaler with `UseProtoNames: true`: ```go mux := runtime.NewServeMux( runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.HTTPBodyMarshaler{ Marshaler: &runtime.JSONPb{ MarshalOptions: protojson.MarshalOptions{ UseProtoNames: true, EmitUnpopulated: true, }, UnmarshalOptions: protojson.UnmarshalOptions{ DiscardUnknown: true, }, }, }), ) ``` To change the OpenAPI generator behaviour to match, set `json_names_for_fields=false` when generating: ```sh --openapiv2_out=json_names_for_fields=false:./gen/openapiv2 path/to/my/proto/v1/myproto.proto ``` If using the Bazel rule, set `json_names_for_fields=False`. ## We now emit default values for all fields See [the original issue](https://github.com/grpc-ecosystem/grpc-gateway/issues/233) for more information. If you want to revert to the old behaviour, configure a custom marshaler with `EmitUnpopulated: false`: ```go mux := runtime.NewServeMux( runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.HTTPBodyMarshaler{ Marshaler: &runtime.JSONPb{ MarshalOptions: protojson.MarshalOptions{ EmitUnpopulated: false, }, UnmarshalOptions: protojson.UnmarshalOptions{ DiscardUnknown: true, }, }, }), ) ``` ## We now support google.api.HttpBody message types by default The `runtime.SetHTTPBodyMarshaler` function has disappeared, and is now enabled by default. If you for some reason don't want `HttpBody` messages to be respected, you can disable it by overwriting the default marshaler with one which does not wrap `runtime.JSONPb` in `runtime.HTTPBodyMarshaler`: ```go mux := runtime.NewServeMux( runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.JSONPb{ MarshalOptions: protojson.MarshalOptions{ EmitUnpopulated: true, }, UnmarshalOptions: protojson.UnmarshalOptions{ DiscardUnknown: true, }, }), ) ``` ## runtime.DisallowUnknownFields has been removed All marshalling settings are now inherited from the configured marshaler. If you wish to disallow unknown fields, configure a custom marshaler: ```go mux := runtime.NewServeMux( runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.HTTPBodyMarshaler{ Marshaler: &runtime.JSONPb{ MarshalOptions: protojson.MarshalOptions{ EmitUnpopulated: true, }, UnmarshalOptions: protojson.UnmarshalOptions{ DiscardUnknown: false, }, }, }), ) ``` ## WithLastMatchWins and allow_colon_final_segments=true is now default behaviour If you were previously specifying these, please remove them, as this is now the default behaviour. See [the original issue](https://github.com/grpc-ecosystem/grpc-gateway/issues/224) for more information. There is no workaround for this, as we considered it a correct interpretation of the spec. If this breaks your application, carefully consider the order in which you define your services. ## Error handling configuration has been overhauled `runtime.HTTPError`, `runtime.OtherErrorHandler`, `runtime.GlobalHTTPErrorHandler`, `runtime.WithProtoErrorHandler` are all gone. Error handling is rewritten around the use of gRPCs Status types. If you wish to configure how the gateway handles errors, please use `runtime.WithErrorHandler` and `runtime.WithStreamErrorHandler`. To handle routing errors (similar to the removed `runtime.OtherErrorHandler`) please use `runtime.WithRoutingErrorHandler`. ## Default query parameter parsing behaviour change The default behaviour for query parameter parsing has changed to return an `InvalidArgument` (`400 Bad Request`) error when more than one of the same matching query parameters is parsed. Previously, it would log but not return an error, using the first query parameter that matched and ignoring any others. See [the original issue](https://github.com/grpc-ecosystem/grpc-gateway/issues/2632) for more information. ================================================ FILE: docs/docs/development/index.md ================================================ --- layout: default title: Development nav_order: 4 has_children: true --- ================================================ FILE: docs/docs/development/installation_for_cygwin.md ================================================ --- layout: default title: Installation for Cygwin nav_order: 1 parent: Development --- # Installation for Cygwin
## Installation First, you need to install the [Go language](https://golang.org/dl/). Please install the latest version, not the one that is listed here. wget -N https://storage.googleapis.com/golang/go1.8.1.windows-amd64.msi msiexec /i go1.8.1.windows-amd64.msi /passive /promptrestart Then you need to install [ProtocolBuffers 3.0.0-beta-3](https://github.com/google/protobuf/releases) or later. Use the Windows release as no native Cygwin `protoc` with version 3 is available yet. wget -N https://github.com/google/protobuf/releases/download/v3.2.0/protoc-3.2.0-win32.zip` 7z x protoc-3.2.0-win32.zip -o/usr/local/ Then you need to set up your Go workspace. Create the workspace dir. mkdir /home/user/go mkdir /home/user/go/bin mkdir /home/user/go/pkg mkdir /home/user/go/src From an elevated cmd.exe prompt set the GOPATH variable in Windows and add the `$GOPATH/bin` directory to your path using `reg add` instead of `setx` because [setx can truncate your PATH variable to 1024 characters](https://encrypted.google.com/search?hl=en&q=setx%20truncates%20PATH%201024#safe=off&hl=en&q=setx+truncated+PATH+1024). setx GOPATH c:\path\to\your\cygwin\home\user\go /M set pathkey="HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment" for /F "usebackq skip=2 tokens=2*" %A IN (`reg query %pathkey% /v Path`) do (reg add %pathkey% /f /v Path /t REG_SZ /d "%B;c:\path\to\your\cygwin\home\user\go\bin") Then `go get -u -v` the following packages: go get -u -v github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway go get -u -v github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 go get -u -v google.golang.org/protobuf/cmd/protoc-gen-go go get -u -v google.golang.org/grpc/cmd/protoc-gen-go-grpc This will probably fail with a similar output to this: github.com/grpc-ecosystem/grpc-gateway (download) # cd .; git clone https://github.com/grpc-ecosystem/grpc-gateway C:\path\to\your\cygwin\home\user\go\src\github.com\grpc-ecosystem\grpc-gateway Cloning into 'C:\path\to\your\cygwin\home\user\go\src\github.com\grpc-ecosystem\grpc-gateway'... fatal: Invalid path '/home/user/go/C:\path\to\your\cygwin\home\user\go\src\github.com\grpc-ecosystem\grpc-gateway': No such file or directory package github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway: exit status 128 To fix this you need to run the `go get -u -v` commands and look for all lines starting with `# cd .;`. Copy and paste these lines into your shell and change the clone destination directories. git clone https://github.com/grpc-ecosystem/grpc-gateway $(cygpath -u $GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway git clone https://github.com/golang/protobuf $(cygpath -u $GOPATH)/src/github.com/golang/protobuf git clone https://github.com/google/go-genproto $(cygpath -u $GOPATH)/src/google.golang.org/genproto Once the clone operations are finished the `go get -u -v` commands shouldn't give you an error anymore. ## Usage Follow the [instructions](https://github.com/grpc-ecosystem/grpc-gateway#usage) in the [README](https://github.com/grpc-ecosystem/grpc-gateway#readme). Adjust steps 3, 5 and 7 like this. `protoc` expects native Windows paths. protoc -I. -I$(cygpath -w /usr/local/include) -I${GOPATH}/src --go_out=. --go-grpc_out=. ./path/to/your_service.proto protoc -I. -I$(cygpath -w /usr/local/include) -I${GOPATH}/src ./path/to/your_service.proto protoc -I. -I$(cygpath -w /usr/local/include) -I${GOPATH}/src ./path/to/your_service.proto Then `cd` into the directory where your entry-point `main.go` file is located and run: go get -v This will fail in this same way as it did during the installation. Look for all lines starting with `# cd .;`. Copy and paste these lines into your shell and change the clone destination directories. git clone https://go.googlesource.com/net $(cygpath -u $GOPATH)/src/golang.org/x/net git clone https://go.googlesource.com/text $(cygpath -u $GOPATH)/src/golang.org/x/text git clone https://github.com/grpc/grpc-go $(cygpath -u $GOPATH)/src/google.golang.org/grpc Once the clone operations are finished the `go get -v` commands shouldn't give you an error anymore. Then run: go install This will compile and install your gRPC-Gateway service into `$GOPATH/bin`. ================================================ FILE: docs/docs/faq.md ================================================ --- layout: default title: FAQ nav_order: 7 --- # FAQ ## How can I write the annotations which gRPC-Gateway requires? The gRPC-Gateway follows the spec of [`google.api.HttpRule`](https://github.com/googleapis/googleapis/blob/master/google/api/http.proto), so first check out the documentation if it is feasible in the spec. For situations where annotating the proto file is not an option please reference the documentation on [gRPC API Configuration](https://grpc-ecosystem.github.io/grpc-gateway/docs/mapping/grpc_api_configuration/) See also [a past discussion](https://groups.google.com/d/msg/grpc-io/Xqx80hG0D44/VNCDHjeE6pUJ) in the grpc-io mailing list. ## I want to support a certain style of HTTP request but the code generated by gRPC-Gateway does not. How can I support this style? See the question above at first. The gRPC-Gateway is intended to cover 80% of use cases without forcing you to write comprehensive but complicated annotations. So the gateway itself does not always cover all the use cases you have by design. In other words, the gateway automates typical boring boilerplate mapping between gRPC and HTTP/1 communication, but it does not do arbitrarily complex custom mappings for you. On the other hand, you can still add whatever you want as a middleware which wraps [`runtime.ServeMux`](https://pkg.go.dev/github.com/grpc-ecosystem/grpc-gateway/runtime?tab=doc#ServeMux). Since `runtime.ServeMux` is just a standard [`http.Handler`](http://golang.org/pkg/http#Handler), you can easily write a custom wrapper of `runtime.ServeMux`, leveraged with existing third-party libraries in Go (e.g. [gateway main.go program](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/examples/internal/gateway/main.go)). ## My gRPC server is written in (Scala or C++ or Ruby or Haskell etc). Is there a (Scala or C++ or Ruby or Haskell etc) version of gRPC-Gateway? As of now, No. But it should not be a big issue because the reverse-proxy which gRPC-Gateway generates usually works as an independent process and communicates with your gRPC server over TCP or a Unix domain sockets (Unix systems only). ## Why are the models in the OpenAPI specification prefixed with the last part of the proto package name? The reason to generate the prefixes is that we don't have a guaranteed unique namespace. If two packages produce different `Foo` messages then we will have trouble. ## Why not strip the prefix? When a message is added which happens to conflict with another message (e.g. by importing a message with the same name from a different package) it will break code that is very far away from the code that changed. This is in an effort to adhere to the [principle of least astonishment](https://en.wikipedia.org/wiki/Principle_of_least_astonishment). ## What is the difference between the gRPC-Gateway and grpc-httpjson-transcoding? The gRPC-Gateway is a generator that generates a Go implementation of a JSON/HTTP-gRPC reverse proxy based on annotations in your proto file, while the [grpc-httpjson-transcoding](https://github.com/grpc-ecosystem/grpc-httpjson-transcoding) library doesn't require the generation step, it uses protobuf descriptors as config. It can be used as a component of an existing proxy. Google Cloud Endpoints and the gRPC-JSON transcoder filter in Envoy are using this. **Behavior differences:** - By default, gRPC-Gateway does not escape path parameters in the same way. [This can be configured.](mapping/customizing_your_gateway.md#Controlling-path-parameter-unescaping) ## What is the difference between the gRPC-Gateway and gRPC-web? ### Usage In the gRPC-Gateway, we generate a reverse-proxy from the proto file annotations. In the front-end, we call directly through REST APIs. We can generate an OpenAPI v2 specification that may further be used to generate the frontend client from using `protoc-gen-openapiv2`. In gRPC-web, the client code is generated directly from the proto files and can be used in the frontend. ### Performance The gRPC-Gateway parses JSON to the protobuf binary format before sending it to the gRPC server. It then has to parse the reply back from the protobuf binary format to JSON again The parsing overhead has a negative impact on performance. In gRPC-web, the message is sent in the protobuf binary format already, so there is no additional parsing cost on the proxy side. ### Maintenance With the gRPC-Gateway, if your proto file changes, we have to regenerate the gateway reverse proxy code. If you are using the HTTP/JSON interface you probably have to change the front-end too, which means making changes in two places. In gRPC-web, regenerating the files from the proto file will automatically update the front-end client. ================================================ FILE: docs/docs/mapping/binary_file_uploads.md ================================================ --- layout: default title: Binary file uploads nav_order: 2 parent: Mapping --- # Binary file uploads If you need to do a binary file upload, e.g. via; ```sh curl -X POST -F "attachment=@/tmp/somefile.txt" http://localhost:9090/v1/files ``` then your request will contain the binary data directly and there is no way to model this using gRPC. What you can do instead is to add a custom route directly on the `mux` instance. ## Custom route on a mux instance Here we'll setup a handler (`handleBinaryFileUpload`) for `POST` requests: ```go // Create a mux instance mux := runtime.NewServeMux() // Attachment upload from http/s handled manually mux.HandlePath("POST", "/v1/files", handleBinaryFileUpload) ``` And then in your handler you can do something like: ```go func handleBinaryFileUpload(w http.ResponseWriter, r *http.Request, params map[string]string) { err := r.ParseForm() if err != nil { http.Error(w, fmt.Sprintf("failed to parse form: %s", err.Error()), http.StatusBadRequest) return } f, header, err := r.FormFile("attachment") if err != nil { http.Error(w, fmt.Sprintf("failed to get file 'attachment': %s", err.Error()), http.StatusBadRequest) return } defer f.Close() // // Now do something with the io.Reader in `f`, i.e. read it into a buffer or stream it to a gRPC client side stream. // Also `header` will contain the filename, size etc of the original file. // } ``` ================================================ FILE: docs/docs/mapping/custom_marshalers.md ================================================ --- layout: default title: Custom marshalers nav_order: 6 parent: Mapping --- # Custom marshalers [`Marshaler`](https://pkg.go.dev/github.com/grpc-ecosystem/grpc-gateway/runtime?tab=doc#Marshaler) implementations can implement optional additional methods to customize their behaviour beyond the methods required by the core interface. ## Stream delimiters By default, a streamed response delimits each response body with a single newline (`"\n"`). You can change this delimiter by having your marshaler implement [`Delimited`](https://pkg.go.dev/github.com/grpc-ecosystem/grpc-gateway/runtime#Delimited). For example, to separate each entry with a pipe (`"|"`) instead: ```go type YourMarshaler struct { // ... } // ... func (*YourMarshaler) Delimiter() []byte { return []byte("|") } ``` ## Stream content type By default, a streamed response emits a `Content-Type` header that is the same for a unary response, from the `ContentType()` method of the [`Marshaler`](https://pkg.go.dev/github.com/grpc-ecosystem/grpc-gateway/runtime?tab=doc#Marshaler) interface. If you require the server to declare a distinct content type for stream responses versus unary responses, the marshaler must implement [`StreamContentType`](https://pkg.go.dev/github.com/grpc-ecosystem/grpc-gateway/runtime#StreamContentType). This provides the MIME type when specifically responding to a streaming response. For example, by default the [`JSONPb`](https://pkg.go.dev/github.com/grpc-ecosystem/grpc-gateway/runtime#JSONPb) marshaler results in `application/json` for its `Content-Type` response header, irrespective of unary versus streaming. This can be changed for streaming endpoints by wrapping the marshaler with a custom marshaler that implements [`StreamContentType`](https://pkg.go.dev/github.com/grpc-ecosystem/grpc-gateway/runtime#StreamContentType) to return the [NDJSON](https://github.com/ndjson/ndjson-spec) MIME type for streaming response endpoints: ```go type CustomJSONPb struct { runtime.JSONPb } func (*CustomJSONPb) Delimiter() []byte { // Strictly speaking this is already the default delimiter for JSONPb, but // providing it here for completeness with an NDJSON marshaler all in one // place. return []byte("\n") } func (*CustomJSONPb) StreamContentType(interface{}) string { return "application/x-ndjson" } ``` ================================================ FILE: docs/docs/mapping/customizing_openapi_output.md ================================================ --- layout: default title: Customizing OpenAPI Output nav_order: 4 parent: Mapping --- {% raw %} # Customizing OpenAPI Output ## In proto comments You can provide comments directly in your Protocol Buffer definitions and they will be translated into comments in the generated OpenAPI definitions: ```protobuf message MyMessage { // This comment will end up directly in your Open API definition string uuid = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "The UUID field."}]; } ``` You can disable this behavior and exclude all protobuf comments from OpenAPI output via the `ignore_comments` option. ## Using proto options You can define options on your Protocol Buffer services, operations, messages, enums and field definitions to customize your Open API output. For instance, to customize the [OpenAPI Schema Object](https://swagger.io/specification/v2/#schemaObject) for messages and fields: ```protobuf import "protoc-gen-openapiv2/options/annotations.proto"; message ABitOfEverything { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { json_schema: { title: "A bit of everything" description: "Intentionally complicated message type to cover many features of Protobuf." required: ["uuid", "int64_value", "double_value"] } external_docs: { url: "https://github.com/grpc-ecosystem/grpc-gateway"; description: "Find out more about ABitOfEverything"; } example: "{\"uuid\": \"0cf361e1-4b44-483d-a159-54dabdf7e814\"}" extensions: { key: "x-irreversible"; value { bool_value: true; } } }; string uuid = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "The UUID field."}]; } ``` Enums can be customized like messages: ```protobuf // NumericEnum is one or zero. enum NumericEnum { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_enum) = { description: "NumericEnum is one or zero." title: "NumericEnum" extensions: { key: "x-a-bit-of-everything-foo" value { string_value: "bar" } } external_docs: { url: "https://github.com/grpc-ecosystem/grpc-gateway" description: "Find out more about ABitOfEverything" } example: "\"ZERO\"" }; // ZERO means 0 ZERO = 0; // ONE means 1 ONE = 1; } ``` Operations can also be customized: ```protobuf service ABitOfEverythingService { rpc Delete(grpc.gateway.examples.internal.proto.sub2.IdMessage) returns (google.protobuf.Empty) { option (google.api.http) = { delete: "/v1/example/a_bit_of_everything/{uuid}" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { security: { security_requirement: { key: "ApiKeyAuth"; value: {} } security_requirement: { key: "OAuth2"; value: { scope: "read"; scope: "write"; } } } extensions: { key: "x-irreversible"; value { bool_value: true; } } }; } } ``` [Swagger Extensions](https://swagger.io/docs/specification/2-0/swagger-extensions/) can be added as key-value pairs to the options. Keys must begin with `x-` and values can be of any type listed [here](https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#value). For example: ``` extensions: { key: "x-amazon-apigateway-authorizer"; value { struct_value { fields { key: "type"; value { string_value: "token"; } } fields { key: "authorizerResultTtlInSeconds"; value { number_value: 60; } } } } } ``` Please see this [a_bit_of_everything.proto](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/examples/internal/proto/examplepb/a_bit_of_everything.proto) for examples of the options being used. ## Using google.api.field_behavior Google provides a [field option](https://github.com/googleapis/googleapis/blob/master/google/api/field_behavior.proto) for defining the behavior of fields that is also supported: ```protobuf import "google/api/field_behavior.proto"; message MyMessage { string a_required_field = 1 [(google.api.field_behavior) = REQUIRED]; } ``` The following options are used in the Open API output: - `REQUIRED` - marks a field as required - `OUTPUT_ONLY` - marks a field as readonly Google defines a couple of other options - `OPTIONAL`, `IMMUTABLE`, `INPUT_ONLY` - that are not currently used. `OPTIONAL` support is currently under discussion in [this issue](https://github.com/grpc-ecosystem/grpc-gateway/issues/669). For `IMMUTABLE` and `INPUT_ONLY` fields, there is an [open issue](https://github.com/OAI/OpenAPI-Specification/issues/1497) in the Open API specification for adding functionality for write-once or immutable fields to the spec. ## Using go templates in proto file comments Use [Go templates](https://golang.org/pkg/text/template/) in your proto file comments to allow more advanced documentation such as: - Documentation about fields in the proto objects. - Import the content of external files (such as [Markdown](https://en.wikipedia.org/wiki/Markdown)). ### How to use it By default this function is turned off, so if you want to use it you have to add the `use_go_templates` option: ```sh --openapiv2_out . --openapiv2_opt use_go_templates=true ``` or: ```sh --openapiv2_out=use_go_templates=true:. ``` #### Example script Example of a bash script with the `use_go_templates` flag set to true: ```sh $ protoc -I. \ --go_out . --go-grpc_out . \ --grpc-gateway_out . \ --openapiv2_out . \ --openapiv2_opt use_go_templates=true \ path/to/my/proto/v1/myproto.proto ``` #### Example proto file Example of a proto file with Go templates. This proto file imports documentation from another file, `tables.md`: ```protobuf service LoginService { // Login // // {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service. // It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}". // // {{import "tables.md"}} rpc Login (LoginRequest) returns (LoginReply) { option (google.api.http) = { post: "/v1/example/login" body: "*" }; } } message LoginRequest { // The entered username string username = 1; // The entered password string password = 2; } message LoginReply { // Whether you have access or not bool access = 1; } ``` The content of `tables.md`: ```markdown ## {{.RequestType.Name}} | Field ID | Name | Type | Description | | ----------- | --------- | --------------------------------------------------------- | ---------------------------- | {{range .RequestType.Fields}} | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} ## {{.ResponseType.Name}} | Field ID | Name | Type | Description | | ----------- | --------- | ---------------------------------------------------------- | ---------------------------- | {{range .ResponseType.Fields}} | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} ``` ### OpenAPI output #### SwaggerUI This is how the OpenAPI file would be rendered in [Swagger UI](https://swagger.io/tools/swagger-ui/). ![Screenshot OpenAPI file in SwaggerUI](../../assets/images/gotemplates/swaggerui.png) #### Postman This is how the OpenAPI file would be rendered in [Postman](https://www.getpostman.com/). ![Screenshot OpenAPI file in Postman](../../assets/images/gotemplates/postman.png) For a more detailed example of a proto file that has Go, templates enabled, [see the examples](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/examples/internal/proto/examplepb/use_go_template.proto). ### Using custom values Custom values can be specified in the [Go templates](https://golang.org/pkg/text/template/) that generate your proto file comments. A use case might be to interpolate different external documentation URLs when rendering documentation for different environments. #### How to use it The `use_go_templates` option has to be enabled as a prerequisite. Provide customized values in the format of `go_template_args=my_key=my_value`. `{{arg "my_key"}}` will be replaced with `my_value` in the Go template. Specify the `go_template_args` option multiple times if needed. ```sh --openapiv2_out . --openapiv2_opt use_go_templates=true --openapiv2_opt go_template_args=my_key1=my_value1 --openapiv2_opt go_template_args=my_key2=my_value2 ... ``` #### Example script Example of a bash script with the `use_go_templates` flag set to true and custom template values set: ```sh $ protoc -I. \ --go_out . --go-grpc_out . \ --grpc-gateway_out . \ --openapiv2_out . \ --openapiv2_opt use_go_templates=true \ --openapiv2_opt go_template_args=environment=test1 \ --openapiv2_opt go_template_args=environment_label=Test1 \ path/to/my/proto/v1/myproto.proto ``` #### Example proto file Example of a proto file with Go templates and custom values: ```protobuf service LoginService { // Login (Environment: {{arg "environment_label"}}) // // {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service. // It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}". // This only works in the {{arg "environment"}} domain. // rpc Login (LoginRequest) returns (LoginReply) { option (google.api.http) = { post: "/v1/example/login" body: "*" }; } } ``` ## Other plugin options A comprehensive list of OpenAPI plugin options can be found [here](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/protoc-gen-openapiv2/main.go). Options can be passed via `protoc` CLI: ```sh --openapiv2_out . --openapiv2_opt bar=baz,color=red ``` Or, with `buf` in `buf.gen.yaml`: ```yaml - name: openapiv2 out: foo opt: bar=baz,color=red ``` ### Merging output If your protobuf definitions are spread across multiple files, the OpenAPI plugin will create a file for each `.proto` input. This may make sense for Go bindings, since they still share a package space, but fragmenting OpenAPI specifications across multiple files changes the schema itself. To merge disparate `.proto` inputs into a single OpenAPI file, use the `allow_merge` and `merge_file_name` options. `opt: allow_merge=true,merge_file_name=foo` will result in a single `foo.swagger.json`. Note that you may need to set the [generation strategy](https://docs.buf.build/configuration/v1/buf-gen-yaml/#strategy) to `all` when merging many files: ```yaml - name: openapiv2 out: foo strategy: all opt: allow_merge=true,merge_file_name=foo ``` ### Enums as integers To generate enums as integers instead of strings, use `enums_as_ints`. `opt: enums_as_ints=true` will result in: ```json { "name": "enumValue", "description": " - Example enums", "in": "query", "required": false, "type": "int", "enum": [ 0, 1 ], "default": 0 }, ``` ### Omitting the default value of enums If you define enum types with non default value such as declaring 0 value with UNKNOWN and want to omit the default value from generated swagger file, use `omit_enum_default_value`. This option also applies if enums_as_ints option is enalbled to generate enums as integer. `opt: omit_enum_default_value=true` will result in: Input Example: ``` enum enumValue { UNKNOWN = 0; FOO = 1; } ``` Output json: ```json { "name": "enumValue", "description": " - Example enums", "in": "query", "required": false, "type": "string", "enum": [ "FOO" ] }, ``` ### Hiding fields, methods, services and enum values If you require internal or unreleased fields and APIs to be hidden from your API documentation, [`google.api.VisibilityRule`](https://github.com/googleapis/googleapis/blob/9916192ab15e3507e41ba2c5165182fec06120d0/google/api/visibility.proto#L89) annotations can be added to customize where they are generated. Combined with the option `visibility_restriction_selectors`, overlapping rules will appear in the OpenAPI output. `visibility_restriction_selectors` can be declared multiple times as an option to include multiple visibility restrictions in the output. e.g. if you are using `buf`: ```yaml version: v1 plugins: - name: openapiv2 out: . opt: - visibility_restriction_selectors=PREVIEW - visibility_restriction_selectors=INTERNAL ``` or with `protoc` ```sh protoc --openapiv2_out=. --openapiv2_opt=visibility_restriction_selectors=PREVIEW --openapiv2_opt=visibility_restriction_selectors=INTERNAL ./path/to/file.proto ``` Elements without `google.api.VisibilityRule` annotations will appear as usual in the generated output. These restrictions and selectors are completely arbitrary and you can define whatever values or hierarchies you want. In this example we use `INTERNAL` and `PREVIEW`, but `INTERNAL`, `ALPHA`, `BETA`, `RELEASED`, or anything else could be used if you wish. Note: Annotations are only supported on Services, Methods, Fields and Enum Values. `opt: visibility_restriction_selectors=PREVIEW` will result in: Input Example: ```protobuf service Echo { rpc EchoInternal(VisibilityRuleSimpleMessage) returns (VisibilityRuleSimpleMessage) { option (google.api.method_visibility).restriction = "INTERNAL"; option (google.api.http) = { get: "/v1/example/echo_internal" }; } rpc EchoInternalAndPreview(VisibilityRuleSimpleMessage) returns (VisibilityRuleSimpleMessage) { option (google.api.method_visibility).restriction = "INTERNAL,PREVIEW"; option (google.api.http) = { get: "/v1/example/echo_internal_and_preview" }; } } message VisibilityRuleSimpleMessage { enum VisibilityEnum { UNSPECIFIED = 0; VISIBLE = 1; INTERNAL = 2 [(google.api.value_visibility).restriction = "INTERNAL"]; PREVIEW = 3 [(google.api.value_visibility).restriction = "INTERNAL,PREVIEW"]; } string internal_field = 1 [(google.api.field_visibility).restriction = "INTERNAL"]; string preview_field = 2 [(google.api.field_visibility).restriction = "INTERNAL,PREVIEW"]; VisibilityEnum an_enum = 3; } ``` Output json: ```json { "paths": { "/v1/example/echo_internal_and_preview": { "get": { "summary": "EchoInternalAndPreview is a internal and preview API that should be visible in the OpenAPI spec.", "operationId": "VisibilityRuleEchoService_EchoInternalAndPreview", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbVisibilityRuleSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "previewField", "in": "query", "required": false, "type": "string" }, { "name": "anEnum", "in": "query", "required": false, "type": "string", "enum": [ "UNSPECIFIED", "VISIBLE", "PREVIEW" ], "default": "UNSPECIFIED" } ], "tags": [ "VisibilityRuleEchoService" ] } } } } ``` For a more in depth example see [visibility_rule_echo_service.proto](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/examples/internal/proto/examplepb/visibility_rule_echo_service.proto) and the following output files for different values of `visibility_restriction_selectors`: - [`visibility_restriction_selectors=PREVIEW`](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/examples/internal/proto/examplepb/visibility_rule_preview_echo_service.swagger.json) - [`visibility_restriction_selectors=INTERNAL`](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/examples/internal/proto/examplepb/visibility_rule_internal_echo_service.swagger.json) - [`visibility_restriction_selectors=INTERNAL,visibility_restriction_selectors=PREVIEW`](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/examples/internal/proto/examplepb/visibility_rule_preview_and_internal_echo_service.swagger.json) - [Not set](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/examples/internal/proto/examplepb/visibility_rule_none_echo_service.swagger.json) ### Path parameters When defining HTTP bindings with path parameters that contain multiple path segments, as suggested by the [Google AIPs](https://google.aip.dev/), the path parameter names are numbered to avoid generating duplicate paths in the OpenAPI file. For example, consider: ```protobuf service LibraryService { rpc GetShelf(GetShelfRequest) returns (Shelf) { option (google.api.http) = { get: "/v1/{name=shelves/*}" }; } rpc GetBook(GetBookRequest) returns (Book) { option (google.api.http) = { get: "/v1/{name=shelves/*/books/*}" }; } } message GetShelfRequest { string name = 1; } message GetBookRequest { string name = 1; } ``` This will generate the following paths: - `/v1/{name}` - `/v1/{name_1}` To override the path parameter names, annotate the field used as path parameter: ```protobuf message GetShelfRequest { string name = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {field_configuration: {path_param_name: "shelfName"}}]; } message GetBookRequest { string name = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {field_configuration: {path_param_name: "bookName"}}]; } ``` This will instead generate the following paths: - `/v1/{shelfName}` - `/v1/{bookName}` Note that path parameters in OpenAPI does not support values with `/`, as discussed in [Support for path parameters which can contain slashes #892](https://github.com/OAI/OpenAPI-Specification/issues/892), so tools as Swagger UI will URL encode any `/` provided as parameter value. A possible workaround for this is to write a custom post processor for your OAS file to replace any path parameter with `/` into multiple parameters. #### Expand path parameters containing sub-path segments Alternative to the above, you can enable the `expand_slashed_path_patterns` compiler option to expand path parameters containing sub-path segments into the URI. For example, consider: ```protobuf rpc GetBook(GetBookRequest) returns (Book) { option (google.api.http) = { get: "/v1/{name=publishers/*/books/*}" }; } ``` Where the `GetBook` has a path parameter `name` with a pattern `publishers/*/books/*`. When you enable the `expand_slashed_path_patterns=true` option the path pattern is expanded into the URI and each wildcard in the pattern is transformed into new path parameter. The generated schema for previous protobuf is: ```JSON { "/v1/publishers/{publisher}/books/{book}": { "get": { "parameters": [ { "name": "publisher", "in": "path", "required": true, "type": "string", }, { "name": "book", "in": "path", "required": true, "type": "string", } ] } } } ``` The URI is now pretty descriptive and there are two path parameters `publisher` and `book` instead of one `name`. The name of the new parameters is derived from the path segment before the wildcard in the pattern. Caveats: - the fact that the original `name` parameter is missing might complicate the usage of the API if you intend to pass in the `name` parameters from the resources, - when the `expand_slashed_path_patterns` compiler flag is enabled, the [`path_param_name`](#path-parameters) field annotation is ignored. ### Output format By default the output format is JSON, but it is possible to configure it using the `output_format` option. Allowed values are: `json`, `yaml`. The output format will also change the extension of the output files. For example, if using `buf`: ```yaml - name: openapiv2 out: pkg opt: output_format=yaml ``` Input example: ```protobuf syntax = "proto3"; package helloproto.v1; option go_package = "helloproto/v1;helloproto"; import "google/api/annotations.proto"; service EchoService { rpc Hello(HelloReq) returns (HelloResp) { option (google.api.http) = { get: "/api/hello" }; } } message HelloReq { string name = 1; } message HelloResp { string message = 1; } ``` Output: ```yaml swagger: "2.0" info: title: helloproto/v1/example.proto version: version not set tags: - name: EchoService consumes: - application/json produces: - application/json paths: /api/hello: get: operationId: EchoService_Hello responses: "200": description: A successful response. schema: $ref: '#/definitions/v1HelloResp' default: description: An unexpected error response. schema: $ref: '#/definitions/rpcStatus' parameters: - name: name in: query required: false type: string tags: - EchoService definitions: protobufAny: type: object properties: '@type': type: string additionalProperties: {} rpcStatus: type: object properties: code: type: integer format: int32 message: type: string details: type: array items: $ref: '#/definitions/protobufAny' v1HelloResp: type: object properties: message: type: string ``` ### Disable service tag generation By default service tags are generated for backend services, but it is possible to disable it using the `disable_service_tags` option. Allowed values are: `true`, `false`. For example, if you are using `buf`: ```yaml version: v1 plugins: - name: openapiv2 out: . opt: - disable_service_tags=true ``` or with `protoc` ```sh protoc --openapiv2_out=. --openapiv2_opt=disable_service_tags=true ./path/to/file.proto ``` Input example: ```protobuf syntax = "proto3"; package helloproto.v1; option go_package = "helloproto/v1;helloproto"; import "google/api/annotations.proto"; service EchoService { rpc Hello(HelloReq) returns (HelloResp) { option (google.api.http) = { get: "/api/hello" }; } } message HelloReq { string name = 1; } message HelloResp { string message = 1; } ``` Output (tags object are not generated): ```yaml swagger: "2.0" info: title: helloproto/v1/example.proto version: version not set consumes: - application/json produces: - application/json paths: /api/hello: get: operationId: EchoService_Hello ``` ### Disable default responses By default a 200 OK response is rendered for each service operation. But it is possible to disable this and explicitly define your service's responses, using the `disable_default_responses` option. Allowed values are: `true`, `false`. **Note**: This does not alter the behavior of the gateway itself and should be coupled with a `ForwardResponseWriter` when altering status codes, see [Controlling HTTP Response Codes](https://grpc-ecosystem.github.io/grpc-gateway/docs/mapping/customizing_your_gateway/#controlling-http-response-status-codes). For example, if you are using `buf`: ```yaml version: v1 plugins: - name: openapiv2 out: . opt: - disable_default_responses=true ``` or with `protoc` ```sh protoc --openapiv2_out=. --openapiv2_opt=disable_default_responses=true ./path/to/file.proto ``` Input example: ```protobuf syntax = "proto3"; package helloproto.v1; import "google/api/annotations.proto"; import "protoc-gen-openapiv2/options/annotations.proto"; option go_package = "helloproto/v1;helloproto"; service EchoService { rpc Hello(HelloReq) returns (HelloResp) { option (google.api.http) = {get: "/api/hello"}; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { responses: { key: "201", value: { description: "Created"; schema: { json_schema: {ref: ".helloproto.v1.HelloResp"} } } }; }; } } message HelloReq { string name = 1; } message HelloResp { string message = 1; } ``` Output (default response not generated): ```yaml swagger: "2.0" info: title: helloproto/v1/hello.proto version: version not set consumes: - application/json produces: - application/json paths: /api/hello: get: operationId: EchoService_Hello responses: "201": description: Created schema: $ref: "#/definitions/v1HelloResp" parameters: - name: name in: query required: false type: string definitions: v1HelloResp: type: object properties: message: type: string ``` ### Omit array item type when $ref is a sibling By default, when generating OpenAPI schemas for array items that reference other definitions, both `type: object` and `$ref` properties are included. However, some strict OpenAPI validators enforce the `no-$ref-siblings` rule, which prohibits having `$ref` alongside other properties at the same level. To comply with this strict validation, you can use the `omit_array_item_type_when_ref_sibling` option. When enabled, this option omits the `type: object` property from array items when a `$ref` is present, since `$ref` already implies the type. Allowed values are: `true`, `false`. **Note**: This option only affects the generated OpenAPI specification and does not alter the behavior of the gateway itself. For example, if you are using `buf`: ```yaml version: v1 plugins: - name: openapiv2 out: . opt: - omit_array_item_type_when_ref_sibling=true ``` or with `protoc` ```sh protoc --openapiv2_out=. --openapiv2_opt=omit_array_item_type_when_ref_sibling=true ./path/to/file.proto ``` Input example: ```protobuf syntax = "proto3"; package example.v1; import "google/api/annotations.proto"; option go_package = "example/v1;example"; service ExampleService { rpc GetItems(GetItemsRequest) returns (GetItemsResponse) { option (google.api.http) = {get: "/api/items"}; } } message GetItemsRequest {} message GetItemsResponse { repeated Item items = 1; } message Item { string id = 1; string name = 2; } ``` Output without the option (default behavior): ```yaml definitions: v1GetItemsResponse: type: object properties: items: type: array items: type: object # This can violate strict no-$ref-siblings rule $ref: "#/definitions/v1Item" v1Item: type: object properties: id: type: string name: type: string ``` Output with `omit_array_item_type_when_ref_sibling=true`: ```yaml definitions: v1GetItemsResponse: type: object properties: items: type: array items: $ref: "#/definitions/v1Item" # type: object is omitted v1Item: type: object properties: id: type: string name: type: string ``` ### Custom HTTP Header Request Parameters By default the parameters for each operation are generated from the protocol buffer definition however you can extend the parameters to include extra HTTP headers if required. **NOTE**: These annotations do not alter the behaviour of the gateway and must be coupled with custom header parsing behaviour in the application. Also be aware that adding header parameters can alter the forwards and backwards compatibility of the schema. You must also set a type for your header which can be one of `STRING`, `INTEGER`, `NUMBER` or `BOOLEAN`. ```protobuf syntax = "proto3"; package helloproto.v1; import "google/api/annotations.proto"; import "protoc-gen-openapiv2/options/annotations.proto"; option go_package = "helloproto/v1;helloproto"; service EchoService { rpc Hello(HelloReq) returns (HelloResp) { option (google.api.http) = {get: "/api/hello"}; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { parameters: { headers: { name: "X-Foo"; description: "Foo Header"; type: STRING, required: true; }; headers: { name: "X-Bar"; description: "Bar Header"; type: NUMBER, }; }; }; } } message HelloReq { string name = 1; } message HelloResp { string message = 1; } ``` Output: ```yaml swagger: "2.0" info: title: helloproto/v1/hello.proto version: version not set consumes: - application/json produces: - application/json paths: /api/hello: get: operationId: Hello responses: "200": description: A successful response. schema: $ref: "#/definitions/helloproto.v1.HelloResp" parameters: - name: name in: query required: false type: string - name: X-Foo description: Foo Header in: header required: true type: string - name: X-Bar description: Bar Header in: header required: false type: number definitions: helloproto.v1.HelloResp: type: object properties: message: type: string ``` ### Ignore comments If you want to exclude all protobuf comments (such as `// buf:lint:ignore`) from OpenAPI output, use the `ignore_comments` option. Allowed values are: `true`, `false`. **Note**: `ignore_comments` and `use_go_templates` are mutually exclusive and cannot be enabled at the same time. If you are using `buf`: ```yaml version: v1 plugins: - name: openapiv2 out: . opt: - ignore_comments=true ``` or with `protoc`: ```sh protoc --openapiv2_out=. --openapiv2_opt=ignore_comments=true ./path/to/file.proto ``` ### Removing internal comments If you want to remove internal comments from the from OpenAPI output (such as `TODO` and `FIXME` directives) you can use the `remove_internal_comments` option. If set to `true`, this will remove all comment text located between `(--` and `--)` as per [AIP 192: Internal comments](https://google.aip.dev/192#internal-comments). ### Preserve RPC Path Order By default, generated Swagger files emit paths found in proto files in alphabetical order. If you would like to preserve the order of emitted paths to mirror the path order found in proto files, you can use the `preserve_rpc_order` option. If set to `true`, this option will ensure path ordering is preserved for Swagger files with both json and yaml formats. This option will also ensure path ordering is preserved in the following scenarios: 1. When using additional bindings, paths will preserve their ordering within an RPC. 2. When using multiple services, paths will preserve their ordering between RPCs in the whole protobuf file. 3. When merging protobuf files, paths will preserve their ordering depending on the order of files specified on the command line. `preserve_rpc_order` can be passed via the `protoc` CLI: ```sh protoc --openapiv2_out=. --openapiv2_opt=preserve_rpc_order=true ./path/to/file.proto ``` Or, with `buf` in `buf.gen.yaml`: ```yaml version: v1 plugins: - name: openapiv2 out: . opt: - preserve_rpc_order=true ``` ### Enable RPC deprecation With `enable_rpc_deprecation` option you can deprecate openapi method using standard method's option. Allowed values are: `true`, `false`. For example, if you are using `buf`: ```yaml version: v1 plugins: - name: openapiv2 out: . opt: - enable_rpc_deprecation=true ``` or with `protoc` ```sh protoc --openapiv2_out=. --openapiv2_opt=enable_rpc_deprecation=true ./path/to/file.proto ``` Input example: ```protobuf syntax = "proto3"; package helloproto.v1; import "google/api/annotations.proto"; option go_package = "helloproto/v1;helloproto"; service EchoService { rpc Hello(HelloReq) returns (HelloResp) { option deprecated = true; option (google.api.http) = {get: "/api/hello"}; } } message HelloReq { string name = 1; } message HelloResp { string message = 1; } ``` Output: ```yaml swagger: "2.0" info: title: helloproto/v1/example.proto version: version not set tags: - name: EchoService consumes: - application/json produces: - application/json paths: /api/hello: get: operationId: EchoService_Hello responses: "200": description: A successful response. schema: $ref: '#/definitions/v1HelloResp' default: description: An unexpected error response. schema: $ref: '#/definitions/rpcStatus' parameters: - name: name in: query required: false type: string tags: - EchoService deprecated: true definitions: protobufAny: type: object properties: '@type': type: string additionalProperties: {} rpcStatus: type: object properties: code: type: integer format: int32 message: type: string details: type: array items: type: object $ref: '#/definitions/protobufAny' v1HelloResp: type: object properties: message: type: string ``` ### Deprecating parameters With the `enable_field_deprecation` option, OpenAPI parameters will be marked as deprecated based on the protobuf `deprecated` field option. Allowed values are: `true`, `false`. For example, if you are using `buf`: ```yaml version: v1 plugins: - name: openapiv2 out: . opt: - enable_field_deprecation=true ``` or with `protoc` ```sh protoc --openapiv2_out=. --openapiv2_opt=enable_field_deprecation=true ./path/to/file.proto ``` Input example: ```protobuf message SearchRequest { string legacy_filter = 1 [deprecated = true]; string query = 2; } ``` Output (excerpt): ```yaml paths: /v1/search: get: parameters: - name: legacy_filter in: query required: false type: string deprecated: true - name: query in: query required: false type: string ``` If you prefer to leave the protobuf definition active, you can use the `field_configuration.deprecated` annotation on the `openapiv2_field` option instead: ```protobuf message SearchRequest { string legacy_filter = 1 [ (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Legacy filter syntax. Prefer the new 'query' field." field_configuration: { deprecated: true } } ]; string query = 2; } ``` This keeps the protobuf field untouched but still emits a deprecated parameter in the generated spec: ```yaml paths: /v1/search: get: parameters: - name: legacy_filter in: query required: false type: string description: Legacy filter syntax. Prefer the new 'query' field. deprecated: true - name: query in: query required: false type: string ``` If you set both the protobuf `deprecated = true` option and `field_configuration.deprecated`, the OpenAPI parameter is marked as deprecated regardless of the `enable_field_deprecation` option. {% endraw %} ================================================ FILE: docs/docs/mapping/customizing_your_gateway.md ================================================ --- layout: default title: Customizing your gateway nav_order: 5 parent: Mapping --- # Customizing your gateway ## Message serialization ### Custom serializer You might want to serialize request/response messages in MessagePack instead of JSON, for example: 1. Write a custom implementation of [`Marshaler`](https://pkg.go.dev/github.com/grpc-ecosystem/grpc-gateway/runtime?tab=doc#Marshaler). See [Custom marshalers](custom_marshalers.md) for some additional customization options. 2. Register your marshaler with [`WithMarshalerOption`](https://pkg.go.dev/github.com/grpc-ecosystem/grpc-gateway/runtime?tab=doc#WithMarshalerOption). e.g. ```go var m your.MsgPackMarshaler mux := runtime.NewServeMux( runtime.WithMarshalerOption("application/x-msgpack", m), ) ``` You can see [the default implementation for JSON](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/runtime/marshal_jsonpb.go) for reference. ### Using proto names in JSON The protocol buffer compiler generates camelCase JSON tags that are used by default. If you want to use the exact case used in the proto files, set `UseProtoNames: true`: ```go mux := runtime.NewServeMux( runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.JSONPb{ MarshalOptions: protojson.MarshalOptions{ UseProtoNames: true, }, UnmarshalOptions: protojson.UnmarshalOptions{ DiscardUnknown: true, }, }), ) ``` ### Pretty-print JSON responses when queried with ?pretty You can have Elasticsearch-style `?pretty` support in your gateway's endpoints as follows: 1. Wrap the ServeMux using a stdlib [`http.HandlerFunc`](https://golang.org/pkg/net/http/#HandlerFunc) that translates the provided query parameter into a custom `Accept` header. 2. Register a pretty-printing marshaler for that MIME code. For example: ```go mux := runtime.NewServeMux( runtime.WithMarshalerOption("application/json+pretty", &runtime.JSONPb{ MarshalOptions: protojson.MarshalOptions{ Indent: " ", Multiline: true, // Optional, implied by presence of "Indent". }, UnmarshalOptions: protojson.UnmarshalOptions{ DiscardUnknown: true, }, }), ) prettier := func(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // checking Values as map[string][]string also catches ?pretty and ?pretty= // r.URL.Query().Get("pretty") would not. if _, ok := r.URL.Query()["pretty"]; ok { r.Header.Set("Accept", "application/json+pretty") } h.ServeHTTP(w, r) }) } http.ListenAndServe(":8080", prettier(mux)) ``` Now, either when passing the header `Accept: application/json+pretty` or appending `?pretty` to your HTTP endpoints, the response will be pretty-printed. Note that this will conflict with any methods having input messages with fields named `pretty`; also, this example code does not remove the query parameter `pretty` from further processing. ## Customize unmarshaling per Content-Type Having different unmarshaling options per Content-Type is as easy as configuring a custom marshaler: ```go mux := runtime.NewServeMux( runtime.WithMarshalerOption("application/json+strict", &runtime.JSONPb{ UnmarshalOptions: &protojson.UnmarshalOptions{ DiscardUnknown: false, // explicit "false", &protojson.UnmarshalOptions{} would have the same effect }, }), ) ``` Note: The incoming `Authorization` HTTP header can not be removed or overwritten. It will always be forwarded in the gRPC metadata under the `authorization` key. However, values can be appended. ## Mapping from HTTP request headers to gRPC client metadata You might not like [the default mapping rule](https://pkg.go.dev/github.com/grpc-ecosystem/grpc-gateway/runtime?tab=doc#DefaultHeaderMatcher) and might want to pass through all the HTTP headers, for example: 1. Write a [`HeaderMatcherFunc`](https://pkg.go.dev/github.com/grpc-ecosystem/grpc-gateway/runtime?tab=doc#HeaderMatcherFunc). 2. Register the function with [`WithIncomingHeaderMatcher`](https://pkg.go.dev/github.com/grpc-ecosystem/grpc-gateway/runtime?tab=doc#WithIncomingHeaderMatcher) e.g. ```go func CustomMatcher(key string) (string, bool) { switch key { case "X-Custom-Header1": return key, true case "X-Custom-Header2": return "custom-header2", true default: return key, false } } mux := runtime.NewServeMux( runtime.WithIncomingHeaderMatcher(CustomMatcher), ) ``` To keep the [default mapping rule](https://pkg.go.dev/github.com/grpc-ecosystem/grpc-gateway/runtime?tab=doc#DefaultHeaderMatcher) alongside with your own rules write: ```go func CustomMatcher(key string) (string, bool) { switch key { case "X-User-Id": return key, true default: return runtime.DefaultHeaderMatcher(key) } } ``` It will work with both: ```sh $ curl --header "x-user-id: 100d9f38-2777-4ee2-ac3b-b3a108f81a30" ... ``` and ```sh $ curl --header "X-USER-ID: 100d9f38-2777-4ee2-ac3b-b3a108f81a30" ... ``` To access this header on gRPC server side use: ```go userID := "" if md, ok := metadata.FromIncomingContext(ctx); ok { if uID, ok := md["x-user-id"]; ok { userID = strings.Join(uID, ",") } } ``` ## Mapping from gRPC server metadata to HTTP response headers Use [`WithOutgoingHeaderMatcher`](https://pkg.go.dev/github.com/grpc-ecosystem/grpc-gateway/runtime?tab=doc#WithOutgoingHeaderMatcher). See [gRPC metadata docs](https://github.com/grpc/grpc-go/blob/master/Documentation/grpc-metadata.md) for more info on sending / receiving gRPC metadata, for example: ```go if appendCustomHeader { grpc.SendHeader(ctx, metadata.New(map[string]string{ "x-custom-header1": "value", })) } ``` ## Mutate response messages or set response headers ### Set HTTP headers You might want to return a subset of response fields as HTTP response headers; You might want to simply set an application-specific token in a header. Or you might want to mutate the response messages to be returned. 1. Write a filter function. ```go func myFilter(ctx context.Context, w http.ResponseWriter, resp proto.Message) error { t, ok := resp.(*externalpb.Tokenizer) if ok { w.Header().Set("X-My-Tracking-Token", t.Token) t.Token = "" } return nil } ``` 2. Register the filter with [`WithForwardResponseOption`](https://pkg.go.dev/github.com/grpc-ecosystem/grpc-gateway/runtime?tab=doc#WithForwardResponseOption) e.g. ```go mux := runtime.NewServeMux( runtime.WithForwardResponseOption(myFilter), ) ``` ### Controlling HTTP response status codes To have the most control over the HTTP response status codes, you can use custom metadata. While handling the rpc, set the intended status code: ```go _ = grpc.SetHeader(ctx, metadata.Pairs("x-http-code", "401")) ``` Now, before sending the HTTP response, we need to check for this metadata pair and explicitly set the status code for the response if found. To do so, create a function and hook it into the gRPC-Gateway as a Forward Response Option. The function looks like this: ```go func httpResponseModifier(ctx context.Context, w http.ResponseWriter, p proto.Message) error { md, ok := runtime.ServerMetadataFromContext(ctx) if !ok { return nil } // set http status code if vals := md.HeaderMD.Get("x-http-code"); len(vals) > 0 { code, err := strconv.Atoi(vals[0]) if err != nil { return err } // delete the headers to not expose any grpc-metadata in http response delete(md.HeaderMD, "x-http-code") delete(w.Header(), "Grpc-Metadata-X-Http-Code") w.WriteHeader(code) } return nil } ``` And it gets hooked into the gRPC-Gateway with: ```go gwMux := runtime.NewServeMux( runtime.WithForwardResponseOption(httpResponseModifier), ) ``` Additional responses can be added to the Protocol Buffer definitions to match the new status codes: ```protobuf service Greeter { rpc SayHello (HelloRequest) returns (HelloReply) { option (google.api.http) = { post: "/v1/example/echo" body: "*" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { responses: { key: "201" value: { description: "A successful response." schema: { json_schema: { ref: ".mypackage.HelloReply" } } } } }; } rpc SayGoodbye (GoodbyeRequest) returns (google.protobuf.Empty) { option (google.api.http) = { delete: "/v1/example/echo/{id}" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { responses: { key: "204" value: { description: "A successful response." schema: {} } } }; } } ``` ### Fully Overriding Custom HTTP Responses To fully override custom HTTP responses, you can use both a Forward Response Option and a Custom Marshaler. For example with proto response message as: ```proto message CreateUserResponse { string name = 1; } ``` The default HTTP response: ```json5 HTTP 200 OK Content-Type: application/json {"name":"John Doe"} ``` But you want to return a `201 Created` status code along with a custom response structure: ```json5 HTTP 201 Created Content-Type: application/json {"success":true,"data":{"name":"John Doe"}} ``` First, set up the gRPC-Gateway with the custom options: ```go mux := runtime.NewServeMux( runtime.WithForwardResponseOption(setStatus), runtime.WithForwardResponseRewriter(responseEnvelope), ) ``` Define the `setStatus` function to handle specific response types: ```go func setStatus(ctx context.Context, w http.ResponseWriter, m protoreflect.ProtoMessage) error { switch v := m.(type) { case *pb.CreateUserResponse: w.WriteHeader(http.StatusCreated) } // keep default behavior return nil } ``` Define the `responseEnvelope` function to rewrite the response to a different type/shape: ```go func responseEnvelope(_ context.Context, response proto.Message) (interface{}, error) { switch v := response.(type) { case *pb.CreateUserResponse: // wrap the response in a custom structure return map[string]any{ "success": true, "data": response, }, nil } return response, nil } ``` In this setup: - The `setStatus` function intercepts the response and uses its type to send `201 Created` only when it sees `*pb.CreateUserResponse`. - The `responseEnvelope` function ensures that specific types of responses are wrapped in a custom structure before being sent to the client. ❗ **NOTE:** Using `WithForwardResponseRewriter` is partially incompatible with OpenAPI annotations. Because response rewriting happens at runtime, it is not possible to represent that in `protoc-gen-openapiv2` output. ## Error handler To override error handling for a `*runtime.ServeMux`, use the `runtime.WithErrorHandler` option. This will configure all unary error responses to pass through this error handler. ## Stream Error Handler The error handler described in the previous section applies only to RPC methods that have a unary response. When the method has a streaming response, gRPC-Gateway handles that by emitting a newline-separated stream of "chunks". Each chunk is an envelope that can contain either a response message or an error. Only the last chunk will include an error, and only when the RPC handler ends abnormally (i.e. with an error code). Because of the way the errors are included in the response body, the other error handler signature is insufficient. So for server streams, you must install a _different_ error handler: ```go mux := runtime.NewServeMux( runtime.WithStreamErrorHandler(handleStreamError), ) ``` The signature of the handler is much more rigid because we need to know the structure of the error payload to properly encode the "chunk" schema into an OpenAPI spec. So the function must return a `*runtime.StreamError`. The handler can choose to omit some fields and can filter/transform the original error, such as stripping stack traces from error messages. Here's an example custom handler: ```go // handleStreamError overrides default behavior for computing an error // message for a server stream. // // It uses a default "502 Bad Gateway" HTTP code, only emits "safe" // messages and does not set the details field (so it will // be omitted from the resulting JSON object that is sent to client). func handleStreamError(ctx context.Context, err error) *status.Status { code := codes.Internal msg := "unexpected error" if s, ok := status.FromError(err); ok { code = s.Code() // default message, based on the gRPC status msg = s.Message() // see if error details include "safe" message to send // to external callers for _, msg := range s.Details() { if safe, ok := msg.(*SafeMessage); ok { msg = safe.Text break } } } return status.Errorf(code, msg) } ``` If no custom handler is provided, the default stream error handler will include any gRPC error attributes (code, message, detail messages), if the error being reported includes them. If the error does not have these attributes, a gRPC code of `Unknown` (2) is reported. ## Controlling path parameter unescaping By default, gRPC-Gateway unescapes the entire URL path string attempting to route a request. This causes routing errors when the path parameter contains an illegal character such as `/`. To replicate the behavior described in [google.api.http](https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L224), use [runtime.WithUnescapingMode()](https://pkg.go.dev/github.com/grpc-ecosystem/grpc-gateway/runtime?tab=doc#WithUnescapingMode) to configure the unescaping behavior, as in the example below: ```go mux := runtime.NewServeMux( runtime.WithUnescapingMode(runtime.UnescapingModeAllExceptReserved), ) ``` For multi-segment parameters (e.g. `{id=**}`) [RFC 6570](https://tools.ietf.org/html/rfc6570) Reserved Expansion characters are left escaped and the gRPC API will need to unescape them. To replicate the default V2 escaping behavior but also allow passing pct-encoded `/` characters, the ServeMux can be configured as in the example below: ```go mux := runtime.NewServeMux( runtime.WithUnescapingMode(runtime.UnescapingModeAllCharacters), ) ``` ## Routing Error handler To override the error behavior when `*runtime.ServeMux` was not able to serve the request due to routing issues, use the `runtime.WithRoutingErrorHandler` option. This will configure all HTTP routing errors to pass through this error handler. The default behavior is to map HTTP error codes to gRPC errors. HTTP statuses and their mappings to gRPC statuses: - HTTP `404 Not Found` -> gRPC `5 NOT_FOUND` - HTTP `405 Method Not Allowed` -> gRPC `12 UNIMPLEMENTED` - HTTP `400 Bad Request` -> gRPC `3 INVALID_ARGUMENT` This method is not used outside of the initial routing. ### Customizing Routing Errors If you want to retain HTTP `405 Method Not Allowed` instead of allowing it to be converted to the equivalent of the gRPC `12 UNIMPLEMENTED`, which is HTTP `501 Not Implemented` you can use the following example: ```go func handleRoutingError(ctx context.Context, mux *runtime.ServeMux, marshaler runtime.Marshaler, w http.ResponseWriter, r *http.Request, httpStatus int) { if httpStatus != http.StatusMethodNotAllowed { runtime.DefaultRoutingErrorHandler(ctx, mux, marshaler, w, r, httpStatus) return } // Use HTTPStatusError to customize the DefaultHTTPErrorHandler status code err := &runtime.HTTPStatusError{ HTTPStatus: httpStatus, Err: status.Error(codes.Unimplemented, http.StatusText(httpStatus)), } runtime.DefaultHTTPErrorHandler(ctx, mux, marshaler, w, r, err) } ``` To use this routing error handler, construct the mux as follows: ```go mux := runtime.NewServeMux( runtime.WithRoutingErrorHandler(handleRoutingError), ) ``` ## Disabling X-HTTP-Method-Override By default, the gRPC-Gateway allows clients to send a `POST` request with an `X-HTTP-Method-Override` header to override the HTTP method. For example, a `POST` request with `X-HTTP-Method-Override: GET` will be routed as if it were a `GET` request. This is part of the path length fallback behavior, which allows HTML forms (which only support `GET` and `POST`) to call other methods. This can lead to HTTP method confusion when your gateway sits behind a Web Application Firewall (WAF) or reverse proxy that enforces method-based access controls. For example, if a WAF is configured to only allow `POST` requests to a particular endpoint, a client could send a `POST` with `X-HTTP-Method-Override: DELETE` and the gateway would route the request to the `DELETE` handler, bypassing the WAF's intended restrictions. The WAF sees a `POST` request, but the gateway processes it as a `DELETE`. To disable the `X-HTTP-Method-Override` header handling, use the `WithDisableHTTPMethodOverride` option: ```go mux := runtime.NewServeMux( runtime.WithDisableHTTPMethodOverride(), ) ``` This disables only the method override header. The path length fallback (routing a `POST` with `Content-Type: application/x-www-form-urlencoded` to a matching `GET` handler) remains available unless separately disabled with `WithDisablePathLengthFallback`. ================================================ FILE: docs/docs/mapping/examples.md ================================================ --- layout: default title: Examples nav_order: 0 parent: Mapping --- # Examples Examples are available under `examples/internal` directory. - [`proto/examplepb/echo_service.proto`](https://github.com/grpc-ecosystem/grpc-gateway/tree/main/examples/internal/proto/examplepb/echo_service.proto), [`proto/examplepb/a_bit_of_everything.proto`](https://github.com/grpc-ecosystem/grpc-gateway/tree/main/examples/internal/proto/examplepb/a_bit_of_everything.proto), [`proto/examplepb/unannotated_echo_service.proto`](https://github.com/grpc-ecosystem/grpc-gateway/tree/main/examples/internal/proto/examplepb/unannotated_echo_service.proto): protobuf service definitions. - [`proto/examplepb/echo_service.pb.go`](https://github.com/grpc-ecosystem/grpc-gateway/tree/main/examples/internal/proto/examplepb/echo_service.pb.go), [`proto/examplepb/a_bit_of_everything.pb.go`](https://github.com/grpc-ecosystem/grpc-gateway/tree/main/examples/internal/proto/examplepb/a_bit_of_everything.pb.go), [`proto/examplepb/unannotated_echo_service.pb.go`](https://github.com/grpc-ecosystem/grpc-gateway/tree/main/examples/internal/proto/examplepb/unannotated_echo_service.pb.go): generated Go service stubs and types. - [`proto/examplepb/echo_service.pb.gw.go`](https://github.com/grpc-ecosystem/grpc-gateway/tree/main/examples/internal/proto/examplepb/echo_service.pb.gw.go), [`proto/examplepb/a_bit_of_everything.pb.gw.go`](https://github.com/grpc-ecosystem/grpc-gateway/tree/main/examples/internal/proto/examplepb/a_bit_of_everything.pb.gw.go), [`proto/examplepb/unannotated_echo_service.pb.gw.go`](https://github.com/grpc-ecosystem/grpc-gateway/tree/main/examples/internal/proto/examplepb/unannotated_echo_service.pb.gw.go): generated gRPC-Gateway clients. - [`proto/examplepb/unannotated_echo_service.yaml`](https://github.com/grpc-ecosystem/grpc-gateway/tree/main/examples/internal/proto/examplepb/unannotated_echo_service.yaml): gRPC API Configuration for `unannotated_echo_service.proto`. - [`server/main.go`](https://github.com/grpc-ecosystem/grpc-gateway/tree/main/examples/internal/server/main.go): service implementation. - [`main.go`](https://github.com/grpc-ecosystem/grpc-gateway/tree/main/examples/internal/gateway/main.go): entrypoint of the generated reverse proxy. To use the same port for custom HTTP handlers (e.g. serving `swagger.json`), gRPC-Gateway, and a gRPC server, see [this code example by CoreOS](https://github.com/philips/grpc-gateway-example/blob/master/cmd/serve.go) (and its accompanying [blog post](https://coreos.com/blog/grpc-protobufs-swagger.html)). ================================================ FILE: docs/docs/mapping/grpc_api_configuration.md ================================================ --- layout: default title: gRPC API Configuration nav_order: 3 parent: Mapping --- # gRPC API Configuration In some situations annotating the proto file of service is not an option. For example, you might not have control over the proto file, or you might want to expose the same gRPC API multiple times in completely different ways. gRPC-Gateway supports 2 ways of dealing with these situations: - [gRPC API Configuration](#grpc-api-configuration) - [`generate_unbound_methods`](#generate_unbound_methods) - [Using an external configuration file](#using-an-external-configuration-file) - [Usage of gRPC API Configuration YAML files](#usage-of-grpc-api-configuration-yaml-files) ## `generate_unbound_methods` Providing this parameter to the `protoc` plugin will make it produce the HTTP mapping even for methods without any `HttpRule` annotation. This is similar to how [Cloud Endpoints behaves](https://cloud.google.com/endpoints/docs/grpc/transcoding#where_to_configure_transcoding) and uses the way [gRPC itself](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md) maps to HTTP/2: - HTTP method is `POST` - URI path is built from the service's name and method: `//` (e.g.: `/my.package.EchoService/Echo`) - HTTP body is the serialized protobuf message. NOTE: the same option is also supported by the `gen-openapiv2` plugin. ## Using an external configuration file Google Cloud Platform offers a way to do this for services hosted with them called ["gRPC API Configuration"](https://cloud.google.com/endpoints/docs/grpc/grpc-service-config). It can be used to define the behavior of a gRPC API service without modifications to the service itself in the form of [YAML](https://en.wikipedia.org/wiki/YAML) configuration files. gRPC-Gateway generators implement the [HTTP rules part](https://cloud.google.com/endpoints/docs/grpc-service-config/reference/rpc/google.api#httprule) of this specification. This allows you to take a completely unannotated service proto file, add a YAML file describing its HTTP endpoints and use them together like an annotated proto file with the gRPC-Gateway generators. OpenAPI options may also be configured via ["OpenAPI Configuration"](https://github.com/grpc-ecosystem/grpc-gateway/tree/main/internal/descriptor/openapiconfig/openapiconfig.proto) in the form of YAML configuration files. ### Usage of gRPC API Configuration YAML files The following is equivalent to the basic [`README.md`](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/README.md#usage) example but without direct annotation for gRPC-Gateway in the proto file. Only some steps require minor changes to use a gRPC API Configuration YAML file instead: 1. Define your service in gRPC as usual your_service.proto: ```protobuf syntax = "proto3"; package your.service.v1; option go_package = "github.com/yourorg/yourprotos/gen/go/your/service/v1"; message StringMessage { string value = 1; } service YourService { rpc Echo(StringMessage) returns (StringMessage) {} } ``` 2. Instead of annotating the proto file in this step leave it untouched and create a `your_service.yaml` with the following content: ```yaml type: google.api.Service config_version: 3 http: rules: - selector: your.service.v1.YourService.Echo post: /v1/example/echo body: "*" ``` Use a [linter](http://www.yamllint.com/) to validate your YAML. 3. Generate gRPC stub as before ```sh protoc -I . \ --go_out ./gen/go/ \ --go_opt paths=source_relative \ --go-grpc_out ./gen/go/ \ --go-grpc_opt paths=source_relative \ your/service/v1/your_service.proto ``` It will generate a stub file with path `./gen/go/your/service/v1/your_service.pb.go`. 4. Implement your service in gRPC as usual 5. Generate the reverse-proxy. Here we have to pass the path to the `your_service.yaml` in addition to the proto file: ```sh protoc -I . \ --grpc-gateway_out ./gen/go \ --grpc-gateway_opt paths=source_relative \ --grpc-gateway_opt grpc_api_configuration=path/to/your_service.yaml \ your/service/v1/your_service.proto ``` This will generate a reverse proxy `gen/go/your/service/v1/your_service.pb.gw.go` that is identical to the one produced for the annotated proto. In situations where you only need the reverse-proxy you can use the `standalone=true` option when generating the code. This will ensure the `types` used within `your_service.pb.gw.go` reference the external source appropriately. ``` protoc -I . \ --grpc-gateway_out ./gen/go \ --grpc-gateway_opt paths=source_relative \ --grpc-gateway_opt standalone=true \ --grpc-gateway_opt grpc_api_configuration=path/to/your_service.yaml \ your/service/v1/your_service.proto ``` 6. Generate the optional your_service.swagger.json ```sh protoc -I . --openapiv2_out ./gen/go \ --openapiv2_opt grpc_api_configuration=path/to/your_service.yaml \ your/service/v1/your_service.proto ``` or using an OpenAPI configuration file ```sh protoc -I . --openapiv2_out ./gen/go \ --openapiv2_opt grpc_api_configuration=path/to/your_service.yaml \ --openapiv2_opt openapi_configuration=path/to/your_service_swagger.yaml \ your/service/v1/your_service.proto ``` For an example of an OpenAPI configuration file, see [unannotated_echo_service.swagger.yaml](https://github.com/grpc-ecosystem/grpc-gateway/tree/main/examples/internal/proto/examplepb/unannotated_echo_service.swagger.yaml), which adds OpenAPI options to [unannotated_echo_service.proto](https://github.com/grpc-ecosystem/grpc-gateway/tree/main/examples/internal/proto/examplepb/unannotated_echo_service.proto). ```sh protoc -I . --openapiv2_out ./gen/go \ --openapiv2_opt grpc_api_configuration=path/to/your_service.yaml \ your/service/v1/your_service.proto ``` All other steps work as before. If you want you can remove the `googleapis` include path in step 3 and 4 as the unannotated proto no longer requires them. ================================================ FILE: docs/docs/mapping/httpbody_messages.md ================================================ --- layout: default title: HttpBody Messages nav_order: 1 parent: Mapping --- # HttpBody Messages The [HTTPBody](https://github.com/googleapis/googleapis/blob/master/google/api/httpbody.proto) messages allow a response message to be specified with custom data content and a custom content-type header. The values included in the HTTPBody response will be used verbatim in the returned message from the gateway. Make sure you format your response carefully! ## Example Usage 1. Define your service in gRPC with an httpbody response message ```protobuf import "google/api/httpbody.proto"; import "google/api/annotations.proto"; import "google/protobuf/empty.proto"; service HttpBodyExampleService { rpc HelloWorld(google.protobuf.Empty) returns (google.api.HttpBody) { option (google.api.http) = { get: "/helloworld" }; } rpc Download(google.protobuf.Empty) returns (stream google.api.HttpBody) { option (google.api.http) = { get: "/download" }; } } ``` 3. Generate gRPC and reverse-proxy stubs and implement your service. ## Example service implementation ```go func (*HttpBodyExampleService) Helloworld(ctx context.Context, in *empty.Empty) (*httpbody.HttpBody, error) { return &httpbody.HttpBody{ ContentType: "text/html", Data: []byte("Hello World"), }, nil } func (HttpBodyExampleService) Download(_ *empty.Empty, stream HttpBodyExampleService_DownloadServer) error { msgs := []*httpbody.HttpBody{ { ContentType: "text/html", Data: []byte("Hello 1"), }, { ContentType: "text/html", Data: []byte("Hello 2"), }, } for _, msg := range msgs { if err := stream.Send(msg); err != nil { return err } } return nil } ``` ================================================ FILE: docs/docs/mapping/index.md ================================================ --- layout: default title: Mapping nav_order: 2 has_children: true --- ================================================ FILE: docs/docs/mapping/patch_feature.md ================================================ --- layout: default title: Patch feature nav_order: 2 parent: Mapping --- # Patch feature The HTTP PATCH method allows a resource to be partially updated. If a binding is mapped to patch and the request message has exactly one FieldMask message in it, additional code is rendered for the gateway handler that will populate the FieldMask based on the request body. FieldMask is treated as a regular field by the gateway if the request method is not PATCH, or if the HttpRule body is `"*"` There are two scenarios: - The FieldMask is hidden from the REST request as per the [Google API design guide](https://cloud.google.com/apis/design/standard_methods#update) (as in the first additional binding in the [UpdateV2](https://github.com/grpc-ecosystem/grpc-gateway/blob/370d869f65d1ffb3d07187fb0db238eca2371ce3/examples/internal/proto/examplepb/a_bit_of_everything.proto#L428-L431) example). In this case, the FieldMask is updated from the request body and set in the gRPC request message. - By default this feature is enabled, if you need to disable it, you can use the plugin option `allow_patch_feature=false`. - Note: The same option is supported by the `protoc-gen-openapiv2` plugin. - The FieldMask is exposed to the REST request (as in the second additional binding in the [UpdateV2](https://github.com/grpc-ecosystem/grpc-gateway/blob/370d869f65d1ffb3d07187fb0db238eca2371ce3/examples/internal/proto/examplepb/a_bit_of_everything.proto#L432-L435) example). For this case, the field mask is left untouched by the gateway. ## Example Usage 1. Create a PATCH request. The PATCH request needs to include the message and the update mask. ```protobuf // UpdateV2Request request for update includes the message and the update mask message UpdateV2Request { ABitOfEverything abe = 1; google.protobuf.FieldMask update_mask = 2; } ``` 2. Define your service in gRPC If you want to use PATCH with fieldmask hidden from REST request only include the request message in the body. ```protobuf rpc UpdateV2(UpdateV2Request) returns (google.protobuf.Empty) { option (google.api.http) = { put: "/v2/example/a_bit_of_everything/{abe.uuid}" body: "abe" additional_bindings { patch: "/v2/example/a_bit_of_everything/{abe.uuid}" body: "abe" } }; } ``` If you want to use PATCH with fieldmask exposed to the REST request then include the entire request message. ```protobuf rpc UpdateV2(UpdateV2Request) returns (google.protobuf.Empty) { option (google.api.http) = { patch: "/v2a/example/a_bit_of_everything/{abe.uuid}" body: "*" }; } ``` 3. Generate gRPC and reverse-proxy stubs and implement your service. ## cURL examples In the example below, we will partially update our ABitOfEverything resource by passing only the field we want to change. Since we are using the endpoint with field mask hidden we only need to pass the field we want to change ("string_value") and it will keep everything else in our resource the same. ```sh $ curl \ --data '{"stringValue": "strprefix/foo"}' \ -X PATCH \ http://address:port/v2/example/a_bit_of_everything/1 ``` If we know what fields we want to update then we can use PATCH with field mask approach. For this, we need to pass the resource and the update_mask. Below only the "single_nested" will get updated because that is what we specify in the field_mask. ```sh $ curl \ --data '{"abe":{"singleNested":{"amount":457},"stringValue":"some value that will not get updated because not in the field mask"},"updateMask":"singleNested"}}' \ -X PATCH \ http://address:port/v2a/example/a_bit_of_everything/1 ``` ================================================ FILE: docs/docs/mapping/using_ref_with_responses.md ================================================ # Using arbitrary messages in response description Assuming a protobuf file of the structure ```protobuf syntax = "proto3"; package example.service.v1; import "protoc-gen-openapiv2/options/annotations.proto"; service GenericService { rpc GenericRPC(GenericRPCRequest) returns (GenericRPCResponse); } message GenericRPCRequest { string id = 1; } message GenericRPCResponse { string result = 1; } ``` If you want your OpenAPI document to include a custom response for all RPCs defined in this protobuf file, you can add the following: ```protobuf option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { responses: { key: "400" value: { description: "Returned when the request is malformed." schema: { json_schema: {ref: ".example.service.v1.GenericResponse"} // Must match the fully qualified name of the message } } } }; message GenericResponse { repeated string resources = 1; repeated string errors = 2; } ``` When generating, you will see the following response included in your OpenAPI document: ```json "400": { "description": "Returned when the request is malformed.", "schema": { "$ref": "#/definitions/v1GenericResponse" } }, ``` The annotation can also be specified per-rpc. ================================================ FILE: docs/docs/operations/annotated_context.md ================================================ --- layout: default title: Extracting the HTTP path pattern for a request nav_order: 4 parent: Operations --- # Extracting the HTTP path pattern for a request It is often interesting to know what [HTTP path pattern](https://github.com/googleapis/googleapis/blob/869d32e2f0af2748ab530646053b23a2b80d9ca5/google/api/http.proto#L61-L87) was matched for a specific request, for example for metrics. This article explains how to extract the HTTP path pattern from the request context. ## Get HTTP Path pattern 1. Define the HTTP path in the proto annotation. For example: ```proto syntax = "proto3"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; package grpc.gateway.examples.internal.proto.examplepb; import "google/api/annotations.proto"; service LoginService { rpc Login (LoginRequest) returns (LoginReply) { option (google.api.http) = { post: "/v1/example/login" body: "*" }; } } message LoginRequest {} message LoginReply {} ``` 2. At runtime, get the HTTP path pattern from the annotated context, for example using the `WithMetadata` function. You can pass data to your backend by adding them to the gRPC metadata or push them to a metrics server. ```go mux := runtime.NewServeMux( runtime.WithMetadata(func(ctx context.Context, r *http.Request) metadata.MD { md := make(map[string]string) if method, ok := runtime.RPCMethod(ctx); ok { md["method"] = method // /grpc.gateway.examples.internal.proto.examplepb.LoginService/Login } if pattern, ok := runtime.HTTPPathPattern(ctx); ok { md["pattern"] = pattern // /v1/example/login } return metadata.New(md) }), ) ``` ================================================ FILE: docs/docs/operations/aws_gateway_integration.md ================================================ --- layout: default title: AWS gateway integration nav_order: 3 parent: Operations --- # AWS gateway integration ## Import OpenAPI documentation into AWS API Gateway The AWS API Gateway service allows importing of an OpenAPI specification to create a REST API. The process is very straightforward and can be found [here](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-import-api.html). Here are some tips to consider when importing the documentation: 1. Remove any circular dependencies (these aren't supported by the parser). 2. Remove security-related annotations (These annotations aren't well supported by the parser). 3. Max length of fields are reviewed by the parser but the errors aren't self-explanatory. Review the [specification](https://swagger.io/specification/v2/) to verify that the requirements are met. 4. API gateway errors aren't great, but you can use this [page](https://apidevtools.org/swagger-parser/online/) for structure validation. ================================================ FILE: docs/docs/operations/health_check.md ================================================ --- layout: default title: Health check nav_order: 1 parent: Operations --- # Health check ## With the [gRPC Health Checking Protocol](https://github.com/grpc/grpc/blob/master/doc/health-checking.md) To use the gRPC health checking protocol you must add the two health checking methods, `Watch` and `Check`. ## Registering the health server 1. Add `google.golang.org/grpc/health/grpc_health_v1` to your imports 2. Register the health server with `grpc_health_v1.RegisterHealthServer(grpcServer, yourService)` ## Adding the health check methods 1. Check method ```go func (s *serviceServer) Check(ctx context.Context, in *health.HealthCheckRequest) (*health.HealthCheckResponse, error) { return &health.HealthCheckResponse{Status: health.HealthCheckResponse_SERVING}, nil } ``` 2. Watch method ```go func (s *serviceServer) Watch(in *health.HealthCheckRequest, _ health.Health_WatchServer) error { // Example of how to register both methods but only implement the Check method. return status.Error(codes.Unimplemented, "unimplemented") } ``` 3. You can test the functionality with [GRPC health probe](https://github.com/grpc-ecosystem/grpc-health-probe). ## Adding `/healthz` endpoint to runtime.ServeMux To automatically register a `/healthz` endpoint in your `ServeMux` you can use the `ServeMuxOption` `WithHealthzEndpoint` which takes in a connection to your registered gRPC server. This endpoint will forward a request to the `Check` method described above to really check the health of the whole system, not only the gateway itself. If your server doesn't implement the health checking protocol each request to `/healthz` will result in the following: ```json {"code":12,"message":"unknown service grpc.health.v1.Health","details":[]} ``` If you've implemented multiple services in your server you can target specific services with the `?service=` query parameter. This will then be added to the `health.HealthCheckRequest` in the `Service` property. With that you can write your own logic to handle that in the health checking methods. Analogously, to register an `{/endpoint/path}` endpoint in your `ServeMux` with a user-defined endpoint path, you can use the `ServeMuxOption` `WithHealthEndpointAt`, which accepts a connection to your registered gRPC server together with a custom `endpointPath string` parameter. ================================================ FILE: docs/docs/operations/index.md ================================================ --- layout: default title: Operations nav_order: 3 has_children: true --- ================================================ FILE: docs/docs/operations/inject_router.md ================================================ --- layout: default title: Adding custom routes to the mux nav_order: 0 parent: Operations --- # Adding custom routes to the mux The gRPC-Gateway allows you to add custom routes to the serve mux, for example, if you want to support a use case that isn't supported by the gRPC-Gateway, like file uploads. ## Example ```go package main import ( "context" "net/http" pb "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/helloworld" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" ) func main() { ctx := context.TODO() mux := runtime.NewServeMux() // Register generated routes to mux err := pb.RegisterGreeterHandlerServer(ctx, mux, &GreeterServer{}) if err != nil { panic(err) } // Register custom route for GET /hello/{name} err = mux.HandlePath("GET", "/hello/{name}", func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) { w.Write([]byte("hello " + pathParams["name"])) }) if err != nil { panic(err) } http.ListenAndServe(":8080", mux) } // GreeterServer is the server API for Greeter service. type GreeterServer struct { } // SayHello implement to say hello func (h *GreeterServer) SayHello(ctx context.Context, req *pb.HelloRequest) (*pb.HelloReply, error) { return &pb.HelloReply{ Message: "hello " + req.Name, }, nil } ``` ================================================ FILE: docs/docs/operations/logging.md ================================================ --- layout: default title: Logging the request body pattern for a request nav_order: 5 parent: Operations --- # Logging the request body pattern for a request If you want to log the request body of incoming requests, you will need to buffer the body before it reaches the gateway. To log the request body, you can use a middleware `http.Handler` to buffer the request body before it's consumed. 1. Create a `http.Handler` middleware. The `logRequestBody` example middleware logs the request body when the response status code is not 200. ```go type logResponseWriter struct { http.ResponseWriter statusCode int } func (rsp *logResponseWriter) WriteHeader(code int) { rsp.statusCode = code rsp.ResponseWriter.WriteHeader(code) } // Unwrap returns the original http.ResponseWriter. This is necessary // to expose Flush() and Push() on the underlying response writer. func (rsp *logResponseWriter) Unwrap() http.ResponseWriter { return rsp.ResponseWriter } func newLogResponseWriter(w http.ResponseWriter) *logResponseWriter { return &logResponseWriter{w, http.StatusOK} } // logRequestBody logs the request body when the response status code is not 200. func logRequestBody(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { lw := newLogResponseWriter(w) // Note that buffering the entire request body could consume a lot of memory. body, err := io.ReadAll(r.Body) if err != nil { http.Error(w, fmt.Sprintf("failed to read body: %v", err), http.StatusBadRequest) return } clonedR := r.Clone(r.Context()) clonedR.Body = io.NopCloser(bytes.NewReader(body)) h.ServeHTTP(lw, clonedR) if lw.statusCode != http.StatusOK { grpclog.Errorf("http error %+v request body %+v", lw.statusCode, string(body)) } }) } ``` 2. Wrap the gateway serve mux with the `logRequestBody` middleware: ```go mux := runtime.NewServeMux() // Register generated gateway handlers s := &http.Server{ Handler: logRequestBody(mux), } ``` ================================================ FILE: docs/docs/operations/tracing.md ================================================ --- layout: default title: Tracing nav_order: 2 parent: Operations --- # Tracing ## With [OpenCensus.io](https://opencensus.io/) and [AWS X-ray](https://aws.amazon.com/xray/) ### Adding tracing using AWS-Xray as the exporter This example uses the AWS-Xray exporter with a global trace setting. Note that AWS X-ray exporter does not handle any metrics only tracing. 1. Add the following imports ```go xray "contrib.go.opencensus.io/exporter/aws" "go.opencensus.io/plugin/ocgrpc" "go.opencensus.io/plugin/ochttp" "go.opencensus.io/trace" ``` 2. Register the AWS X-ray exporter for the GRPC server ```go xrayExporter, err := xray.NewExporter( xray.WithVersion("latest"), // Add your AWS region. xray.WithRegion("ap-southeast-1"), ) if err != nil { // Handle any error. } // Do not forget to call Flush() before the application terminates. defer xrayExporter.Flush() // Register the trace exporter. trace.RegisterExporter(xrayExporter) ``` 3. Add a global tracing configuration ```go // Always trace in this example. // In production this can be set to a trace.ProbabilitySampler. trace.ApplyConfig(trace.Config{DefaultSampler: trace.AlwaysSample()}) ``` 4. Add `ocgrpc.ClientHandler` for tracing the gRPC client calls ```go conn, err := grpc.NewClient( // Other options goes here. // Add ocgrpc.ClientHandler for tracing the grpc client calls. grpc.WithStatsHandler(&ocgrpc.ClientHandler{}), ) ``` 5. Wrap the gateway mux with the OpenCensus HTTP handler ```go gwmux := runtime.NewServeMux() openCensusHandler := &ochttp.Handler{ Handler: gwmux, } gwServer := &http.Server{ Addr: "0.0.0.0:10000", Handler: openCensusHandler, }), } ``` ### Without a global configuration In this example we have added the [gRPC Health Checking Protocol](https://github.com/grpc/grpc/blob/master/doc/health-checking.md) and we do not wish to trace any health checks. 1. Follow step `1`, `2` and `4` from the previous section. 2. Since we are not using a global configuration we can decide what paths we want to trace. ```go gwmux := runtime.NewServeMux() openCensusHandler := &ochttp.Handler{ Handler: gwmux, GetStartOptions: func(r *http.Request) trace.StartOptions { startOptions := trace.StartOptions{} if strings.HasPrefix(r.URL.Path, "/api") { // This example will always trace anything starting with /api. startOptions.Sampler = trace.AlwaysSample() } return startOptions }, } ``` 4. No global configuration means we have to use the [per span sampler](https://opencensus.io/tracing/sampling/#per-span-sampler). #### A method we want to trace ```go func (s *service) Name(ctx context.Context, req *pb.Request) (*pb.Response, error) { // Here we add the span ourselves. ctx, span := trace.StartSpan(ctx, "name.to.use.in.trace", trace. // Select a sampler that fits your implementation. WithSampler(trace.AlwaysSample())) defer span.End() /// Other stuff goes here. } ``` #### A method we do not wish to trace ```go func (s *service) Check(ctx context.Context, in *health.HealthCheckRequest) (*health.HealthCheckResponse, error) { // Note no span here. return &health.HealthCheckResponse{Status: health.HealthCheckResponse_SERVING}, nil } ``` ## OpenTracing Support If your project uses [OpenTracing](https://github.com/opentracing/opentracing-go) and you'd like spans to propagate through the gateway, you can add some middleware which parses the incoming HTTP headers to create a new span correctly. ```go import ( "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/ext" ) var grpcGatewayTag = opentracing.Tag{Key: string(ext.Component), Value: "grpc-gateway"} func tracingWrapper(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { parentSpanContext, err := opentracing.GlobalTracer().Extract( opentracing.HTTPHeaders, opentracing.HTTPHeadersCarrier(r.Header)) if err == nil || err == opentracing.ErrSpanContextNotFound { serverSpan := opentracing.GlobalTracer().StartSpan( "ServeHTTP", // this is magical, it attaches the new span to the parent parentSpanContext, and creates an unparented one if empty. ext.RPCServerOption(parentSpanContext), grpcGatewayTag, ) r = r.WithContext(opentracing.ContextWithSpan(r.Context(), serverSpan)) defer serverSpan.Finish() } h.ServeHTTP(w, r) }) } // Then just wrap the mux returned by runtime.NewServeMux() like this if err := http.ListenAndServe(":8080", tracingWrapper(mux)); err != nil { log.Fatalf("failed to start gateway server on 8080: %v", err) } ``` Finally, don't forget to add a tracing interceptor when registering the services. E.g. ```go import ( "google.golang.org/grpc" "github.com/grpc-ecosystem/go-grpc-middleware/tracing/opentracing" ) opts := []grpc.DialOption{ grpc.WithUnaryInterceptor( grpc_opentracing.UnaryClientInterceptor( grpc_opentracing.WithTracer(opentracing.GlobalTracer()), ), ), } if err := pb.RegisterMyServiceHandlerFromEndpoint(ctx, mux, serviceEndpoint, opts); err != nil { log.Fatalf("could not register HTTP service: %v", err) } ``` ## OpenTelemetry If your project uses [OpenTelemetry](https://opentelemetry.io/) and you would like spans to propagate through the gateway, you can refer to the [OpenTelemetry gRPC-Gateway Boilerplate](https://github.com/iamrajiv/opentelemetry-grpc-gateway-boilerplate) project. This repository provides a sample project that showcases the integration of OpenTelemetry with gRPC-Gateway to set up an OpenTelemetry-enabled gRPC-Gateway REST server. The project includes a simple `SayHello` method implemented on the gRPC server that returns a greeting message to the client. ================================================ FILE: docs/docs/overview/background.md ================================================ --- layout: default title: Background nav_order: 0 parent: Overview --- # Background gRPC is great -- it generates API clients and server stubs in many programming languages, it is fast, easy-to-use, bandwidth-efficient and its design is combat-proven by Google. However, you might still want to provide a traditional RESTful API as well. Reasons can range from maintaining backwards-compatibility, supporting languages or clients not well supported by gRPC to simply maintaining the aesthetics and tooling involved with a RESTful architecture. This project aims to provide that HTTP+JSON interface to your gRPC service. A small amount of configuration in your service to attach HTTP semantics is all that's needed to generate a reverse-proxy with this library. ================================================ FILE: docs/docs/overview/index.md ================================================ --- layout: default title: Overview nav_order: 1 has_children: true --- ================================================ FILE: docs/docs/overview/usage.md ================================================ --- layout: default title: How do I use this? nav_order: 1 parent: Overview --- # How do I use this? Follow the [instructions](https://github.com/grpc-ecosystem/grpc-gateway#usage) in the [README](https://github.com/grpc-ecosystem/grpc-gateway#readme). ================================================ FILE: docs/docs/related_projects.md ================================================ --- layout: default title: Related projects nav_order: 8 --- # Related projects - [grpc-dynamic-gateway](https://github.com/konsumer/grpc-dynamic-gateway) A dynamically configured alternative to the grpc-gateway written in Node. - [rest2grpc](https://www.npmjs.com/package/rest2grpc) A statically configured alternative to the grpc-gateway written in Node. - The Envoy proxy [gRPC-JSON transcoder](https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/grpc_json_transcoder_filter) An Envoy proxy filter that translates incoming JSON requests to gRPC and back. - Google Cloud Platform [HTTP/JSON gRPC transcoding](https://cloud.google.com/endpoints/docs/grpc/transcoding) A GCP product that behaves like the grpc-gateway. - gRPC gateway project generator [gen-grpc-gateway-api](https://github.com/akoserwal/gen-grpc-gateway-api) A shell script that can be used to generate a Go project that utilizes the gRPC-gateway and protobuf to expose a simple API. Tutorial guide: [Automate gRPC-Gateway project generation in Go with gen-grpc-gateway-api](https://akoserwal.medium.com/automate-grpc-gateway-project-generation-in-golang-with-gen-grpc-gateway-api-015759f1e51b) - [grpc-starter transcoding](https://danielliu1123.github.io/grpc-starter/docs/extensions/grpc-http-transcoding/) A Java implementation of grpc-gateway based on Spring Boot. - [grpc-rest-api-example](https://github.com/bullet-tooth/grpc-rest-api-example) An example repo showcasing how to use gRPC-Gateway with a Java Maven multi-module project. ================================================ FILE: docs/docs/tutorials/adding_annotations.md ================================================ --- layout: default title: Adding gRPC-Gateway annotations to an existing proto file nav_order: 4 parent: Tutorials --- # Adding gRPC-Gateway annotations to an existing proto file Now that we've got a working Go gRPC server, we need to add the gRPC-Gateway annotations. The annotations define how gRPC services map to the JSON request and response. When using protocol buffers, each RPC must define the HTTP method and path using the `google.api.http` annotation. So we will need to add the `google/api/http.proto` import to the proto file. We also need to add the HTTP->gRPC mapping we want. In this case, we're mapping `POST /v1/example/echo` to our `SayHello` RPC. ```protobuf syntax = "proto3"; package helloworld; import "google/api/annotations.proto"; // Here is the overall greeting service definition where we define all our endpoints service Greeter { // Sends a greeting rpc SayHello (HelloRequest) returns (HelloReply) { option (google.api.http) = { post: "/v1/example/echo" body: "*" }; } } // The request message containing the user's name message HelloRequest { string name = 1; } // The response message containing the greetings message HelloReply { string message = 1; } ``` See [a_bit_of_everything.proto](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/examples/internal/proto/examplepb/a_bit_of_everything.proto) for examples of more annotations you can add to customize gateway behavior. ## Generating the gRPC-Gateway stubs Now that we've got the gRPC-Gateway annotations added to the proto file, we need to use the gRPC-Gateway generator to generate the stubs. ### Using buf We'll need to add the gRPC-Gateway generator to the generation configuration: ```yaml version: v1 plugins: - plugin: go out: proto opt: paths=source_relative - plugin: go-grpc out: proto opt: paths=source_relative,require_unimplemented_servers=false - plugin: grpc-gateway out: proto opt: paths=source_relative ``` We'll also need to add the `googleapis` dependency to our `buf.yaml` file: ```yaml version: v1 name: buf.build/myuser/myrepo deps: - buf.build/googleapis/googleapis ``` Then we need to run `buf mod update` to select a version of the dependency to use. And that's it! Now if you run: ```sh $ buf generate ``` It should produce a `*.gw.pb.go` file. ### Using `protoc` Before we can generate the stubs with `protoc`, we need to copy some dependencies into our proto file structure. Copy a subset of the `googleapis` from the [official repository](https://github.com/googleapis/googleapis) to your local proto file structure. It should look like this afterwards: ``` proto ├── google │ └── api │ ├── annotations.proto │ └── http.proto └── helloworld └── hello_world.proto ``` Now we need to add the gRPC-Gateway generator to the `protoc` invocation: ```sh $ protoc -I ./proto \ --go_out ./proto --go_opt paths=source_relative \ --go-grpc_out ./proto --go-grpc_opt paths=source_relative \ --grpc-gateway_out ./proto --grpc-gateway_opt paths=source_relative \ ./proto/helloworld/hello_world.proto ``` This should generate a `*.gw.pb.go` file. We also need to add and serve the gRPC-Gateway mux in our `main.go` file. ```go package main import ( "context" "log" "net" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" helloworldpb "github.com/myuser/myrepo/proto/helloworld" ) type server struct{ helloworldpb.UnimplementedGreeterServer } func NewServer() *server { return &server{} } func (s *server) SayHello(ctx context.Context, in *helloworldpb.HelloRequest) (*helloworldpb.HelloReply, error) { return &helloworldpb.HelloReply{Message: in.Name + " world"}, nil } func main() { // Create a listener on TCP port lis, err := net.Listen("tcp", ":8080") if err != nil { log.Fatalln("Failed to listen:", err) } // Create a gRPC server object s := grpc.NewServer() // Attach the Greeter service to the server helloworldpb.RegisterGreeterServer(s, &server{}) // Serve gRPC server log.Println("Serving gRPC on 0.0.0.0:8080") go func() { log.Fatalln(s.Serve(lis)) }() // Create a client connection to the gRPC server we just started // This is where the gRPC-Gateway proxies the requests conn, err := grpc.NewClient( "0.0.0.0:8080", grpc.WithTransportCredentials(insecure.NewCredentials()), ) if err != nil { log.Fatalln("Failed to dial server:", err) } gwmux := runtime.NewServeMux() // Register Greeter err = helloworldpb.RegisterGreeterHandler(context.Background(), gwmux, conn) if err != nil { log.Fatalln("Failed to register gateway:", err) } gwServer := &http.Server{ Addr: ":8090", Handler: gwmux, } log.Println("Serving gRPC-Gateway on http://0.0.0.0:8090") log.Fatalln(gwServer.ListenAndServe()) } ``` For more examples, please refer to [our boilerplate repository](https://github.com/johanbrandhorst/grpc-gateway-boilerplate). ## Testing the gRPC-Gateway Now we can start the server: ```sh $ go run main.go ``` Then we use cURL to send HTTP requests: ```sh $ curl -X POST -k http://localhost:8090/v1/example/echo -d '{"name": " hello"}' ``` ``` {"message":"hello world"} ``` Hopefully, that gives a bit of understanding of how to use the gRPC-Gateway. Full source code of hello world program can be found here [helloworld-grpc-gateway](https://github.com/iamrajiv/helloworld-grpc-gateway). [Next](learn_more.md){: .btn .btn-primary .fs-5 .mb-4 .mb-md-0 .mr-2 } ================================================ FILE: docs/docs/tutorials/creating_main.go.md ================================================ --- layout: default title: Creating main.go nav_order: 3 parent: Tutorials --- # Creating main.go Before creating `main.go` file we are assuming that the user has created a `go.mod` with the name `github.com/myuser/myrepo`, if not please refer to [Creating go.mod file](introduction.md#creating-gomod-file). The import here is using the path to the generated files in `proto/helloworld` relative to the root of the repository. ```go package main import ( "context" "log" "net" "google.golang.org/grpc" helloworldpb "github.com/myuser/myrepo/proto/helloworld" ) type server struct{ helloworldpb.UnimplementedGreeterServer } func NewServer() *server { return &server{} } func (s *server) SayHello(ctx context.Context, in *helloworldpb.HelloRequest) (*helloworldpb.HelloReply, error) { return &helloworldpb.HelloReply{Message: in.Name + " world"}, nil } func main() { // Create a listener on TCP port lis, err := net.Listen("tcp", ":8080") if err != nil { log.Fatalln("Failed to listen:", err) } // Create a gRPC server object s := grpc.NewServer() // Attach the Greeter service to the server helloworldpb.RegisterGreeterServer(s, &server{}) // Serve gRPC Server log.Println("Serving gRPC on 0.0.0.0:8080") log.Fatal(s.Serve(lis)) } ``` ## Read More For more refer to gRPC docs [https://grpc.io/docs/languages/go/](https://grpc.io/docs/languages/go/). [Next](adding_annotations.md){: .btn .btn-primary .fs-5 .mb-4 .mb-md-0 .mr-2 } ================================================ FILE: docs/docs/tutorials/generating_stubs/index.md ================================================ --- layout: default title: Generating stubs parent: Tutorials nav_order: 2 has_children: true --- For generating the stubs, we have two alternatives: `protoc` and `buf`. `protoc` is the more classic generation experience that is used widely in the industry, but it has a pretty steep learning curve. `buf` is a newer tool that is built with user experience and speed in mind. It also offers linting and breaking change detection, something `protoc` doesn't offer. We offer instructions for both here. ================================================ FILE: docs/docs/tutorials/generating_stubs/using_buf.md ================================================ --- layout: default title: Generating stubs using buf nav_order: 0 parent: Generating stubs grand_parent: Tutorials --- # Generating stubs using buf [Buf](https://github.com/bufbuild/buf) is a tool that provides various protobuf utilities such as linting, breaking change detection and generation. Please find installation instructions on [https://docs.buf.build/installation/](https://docs.buf.build/installation/). It is configured through a `buf.yaml` file that should be checked in to the root of your Protobuf file hierarchy. Buf will automatically read this file if present. Configuration can also be provided via the command-line flag `--config`, which accepts a path to a `.json` or `.yaml` file, or direct JSON or YAML data. As opposed to `protoc`, where all `.proto` files are manually specified on the command-line, buf operates by recursively discovering all `.proto` files under configuration and building them. The following is an example of a valid configuration, and you would put it in the root of your Protobuf file hierarchy, e.g. in `proto/buf.yaml` relative to the root of your repository. ```yaml version: v1 name: buf.build/myuser/myrepo ``` To generate type and gRPC stubs for Go, create the file `buf.gen.yaml`: ```yaml version: v1 plugins: - plugin: go out: proto opt: paths=source_relative - plugin: go-grpc out: proto opt: paths=source_relative ``` We use the `go` and `go-grpc` plugins to generate Go types and gRPC service definitions. We're outputting the generated files relative to the `proto` folder, and we're using the `paths=source_relative` option, which means that the generated files will appear in the same directory as the source `.proto` file. Then run ```sh $ buf generate ``` This will have generated a `*.pb.go` and a `*_grpc.pb.go` file for each protobuf package in our `proto` file hierarchy. [Next](../creating_main.go.md){: .btn .btn-primary .fs-5 .mb-4 .mb-md-0 .mr-2 } ================================================ FILE: docs/docs/tutorials/generating_stubs/using_protoc.md ================================================ --- layout: default title: Generating stubs using protoc nav_order: 1 parent: Generating stubs grand_parent: Tutorials --- # Generating stubs using protoc Here's an example of what a `protoc` command might look like to generate Go stubs, assuming that you're at the root of your repository and you have your proto files in a directory called `proto`: ```sh $ protoc -I ./proto \ --go_out ./proto --go_opt paths=source_relative \ --go-grpc_out ./proto --go-grpc_opt paths=source_relative \ ./proto/helloworld/hello_world.proto ``` We use the `go` and `go-grpc` plugins to generate Go types and gRPC service definitions. We're outputting the generated files relative to the `proto` folder, and we're using the `paths=source_relative` option, which means that the generated files will appear in the same directory as the source `.proto` file. This will have generated a `*.pb.go` and a `*_grpc.pb.go` file for `proto/helloworld/hello_world.proto`. [Next](../creating_main.go.md){: .btn .btn-primary .fs-5 .mb-4 .mb-md-0 .mr-2 } ================================================ FILE: docs/docs/tutorials/index.md ================================================ --- layout: default title: Tutorials nav_order: 6 has_children: true --- ================================================ FILE: docs/docs/tutorials/introduction.md ================================================ --- layout: default title: Introduction to the gRPC-Gateway nav_order: 0 parent: Tutorials --- # Introduction to the gRPC-Gateway We all know that gRPC is not a tool for everything. There are cases where we still want to provide a traditional HTTP/JSON API. The reasons can range from maintaining backward-compatibility to supporting programming languages or clients not well supported by gRPC. But writing another service just to expose an HTTP/JSON API is quite a time consuming and tedious task. So is there any way to code just once, but provide APIs in both gRPC and HTTP/JSON at the same time? The answer is Yes. The gRPC-Gateway is a plugin of the Google protocol buffers compiler [protoc](https://github.com/protocolbuffers/protobuf). It reads protobuf service definitions and generates a reverse-proxy server which translates a RESTful HTTP API into gRPC. This server is generated according to the [`google.api.http`](https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L46) annotations in your service definitions. This helps you provide your APIs in both gRPC and HTTP/JSON format at the same time.
## Prerequisites Before we start coding, we have to install some tools. We will be using a Go gRPC server in the examples, so please install Go first from [https://golang.org/dl/](https://golang.org/dl/). After installing Go, use `go install` to download and build the following binaries: ```sh $ go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest $ go install google.golang.org/protobuf/cmd/protoc-gen-go@latest $ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest ``` This installs the `protoc` generator plugins we need to generate the stubs. Make sure to add `$GOPATH/bin` to your `$PATH` so that executables installed via `go get` are available on your `$PATH`. We will be working in a new module for this tutorial, so go ahead and create that in a folder of your choosing now: ### Creating go.mod file Start your module using the [go mod init command](https://golang.org/cmd/go/#hdr-Initialize_new_module_in_current_directory) to create a go.mod file. Run the `go mod init` command, giving it the path of the module your code will be in. Here, use github.com/myuser/myrepo for the module path -- in production code, this would be the URL from which your module can be downloaded. ```sh $ go mod init github.com/myuser/myrepo go: creating new go.mod: module github.com/myuser/myrepo ``` The `go mod init` command creates a go.mod file that identifies your code as a module that might be used from other code. The file you just created includes only the name of your module and the Go version your code supports. But as you add dependencies -- meaning packages from other modules -- the go.mod file will list the specific module versions to use. This keeps builds reproducible and gives you direct control over which module versions to use. [Next](simple_hello_world.md){: .btn .btn-primary .fs-5 .mb-4 .mb-md-0 .mr-2 } ================================================ FILE: docs/docs/tutorials/learn_more.md ================================================ --- layout: default title: Learn More nav_order: 5 parent: Tutorials --- # Learn More ## How it works When the HTTP request arrives at the gRPC-Gateway, it parses the JSON data into a protobuf message. It then makes a normal Go gRPC client request using the parsed protobuf message. The Go gRPC client encodes the protobuf structure into the protobuf binary format and sends it to the gRPC server. The gRPC Server handles the request and returns the response in the protobuf binary format. The Go gRPC client parses it into a protobuf message and returns it to the gRPC-Gateway, which encodes the protobuf message to JSON and returns it to the original client. ## google.api.http Read more about `google.api.http` in [the source file documentation](https://github.com/googleapis/googleapis/blob/master/google/api/http.proto). ## HTTP and gRPC Transcoding Read more about HTTP and gRPC Transcoding on [AIP 127](https://google.aip.dev/127). ================================================ FILE: docs/docs/tutorials/simple_hello_world.md ================================================ --- layout: default title: Creating a simple hello world with gRPC nav_order: 1 parent: Tutorials --- # Creating a simple hello world with gRPC To understand the gRPC-Gateway we are going to first make a hello world gRPC service. ## Defining your gRPC service using protocol buffers Before we create a gRPC service, we should create a proto file to define what we need, here we create a file named `hello_world.proto` in the directory `proto/helloworld/hello_world.proto`. The gRPC service is defined using [Google Protocol Buffers](https://developers.google.com/protocol-buffers). To learn more about how to define a service in a `.proto` file see their [Basics tutorial](https://grpc.io/docs/languages/go/basics/). For now, all you need to know is that both the server and the client stub have a `SayHello()` RPC method that takes a `HelloRequest` parameter from the client and returns a `HelloReply` from the server, and that the method is defined like this: ```protobuf syntax = "proto3"; package helloworld; // The greeting service definition service Greeter { // Sends a greeting rpc SayHello (HelloRequest) returns (HelloReply) {} } // The request message containing the user's name message HelloRequest { string name = 1; } // The response message containing the greetings message HelloReply { string message = 1; } ``` [Next](generating_stubs/index.md){: .btn .btn-primary .fs-5 .mb-4 .mb-md-0 .mr-2 } ================================================ FILE: docs/docs/using_custom_query_parser.md ================================================ # Custom Query Parameter Parsing in gRPC-Gateway The gRPC-Gateway allows you to customize the way query parameters are parsed and mapped to your gRPC request messages. This can be particularly useful when dealing with nested fields or complex query parameter mappings that are not directly supported by the default behavior. ## Example: Custom Query Parameter Parser for Nested Fields Suppose you have a gRPC service definition where you want to map query parameters to a nested message field. Here is how you can achieve this using a custom query parameter parser. ## Protobuf Definition: ```protobuf syntax = "proto3"; import "google/api/annotations.proto"; package your.service.v1; message PageOptions { int32 limit = 1; int32 page = 2; } message ListStuffRequest { string stuff_uuid = 1; PageOptions pagination = 2; } message ListStuffResponse { repeated string stuff = 1; } service MyService { rpc ListStuff(ListStuffRequest) returns (ListStuffResponse) { option (google.api.http) = { get: "/path/to/{stuff_uuid}/stuff" }; } } ``` ## The Problem The ListStuffRequest message contains a nested PageOptions message that represents pagination options for the list operation. By default, creating a ServerMux in gRPC-Gateway will be able to parse query parameters for the `stuff_uuid` and other basic fields (that are not your own custom message). Given that `PageOptions` is a custom message, and therefore will lead to a nested RequestMessage (the root message), it can only parse query parameters for the `PageOptions` message if they are in the format `url?pagination.limit=x`. If your endpoint constraints require query parameters to be in the format `url?limit=x`, without specifying the full qualified path in the url, you will need to implement a custom parser to map these parameters correctly into the nested PageOptions message. ## Custom Query Parameter Parser Create a custom [QueryParameterParser](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/runtime/query.go#L30) to handle the nested PageOptions message. ```go package customparser import ( "net/url" "strconv" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/protobuf/proto" your_service_v1 "path/to/your/service/v1" ) // CustomQueryParameterParser parses query parameters into the appropriate gRPC message fields. type CustomQueryParameterParser struct{} // Parse parses query parameters and populates the appropriate fields in the gRPC request message. func (p *CustomQueryParameterParser) Parse(target proto.Message, values url.Values, filter *utilities.DoubleArray) error { switch req := target.(type) { // Different messages/requests can have different parsers, of course case *your_service_v1.ListStuffRequest: return populateListStuffParams(values, req) } return (runtime.DefaultQueryParser{}).Parse(target, values, filter) } // populateListStuffParams populates the ListStuffRequest with query parameters. func populateListStuffParams(values url.Values, r *your_service_v1.ListStuffRequest) error { pageOptions := &your_service_v1.PageOptions{} if limit := values.Get("limit"); limit != "" { if parsedLimit, err := strconv.Atoi(limit); err == nil { pageOptions.Limit = int32(parsedLimit) } } if page := values.Get("page"); page != "" { if parsedPage, err := strconv.Atoi(page); err == nil { pageOptions.Page = int32(parsedPage) } } r.Pagination = pageOptions return nil } ``` ## Integrate Your Custom Query Parameter Parser in gRPC-Gateway Setup All you need to do now is update the gRPC-Gateway setup, particularly wherever you are [defining the mux server](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/runtime/mux.go#L293), to [use the custom query parameter parser](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/runtime/mux.go#L110). ```go package main import ( "context" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "google.golang.org/grpc/metadata" "google.golang.org/protobuf/encoding/protojson" "your_module/path/customparser" ) // create a new ServeMux with custom parser and other runtime options as needed func createGRPCGatewayMux() *runtime.ServeMux { // whatever custom code you may need before you create the mux... return runtime.NewServeMux( // Custom query parameter parser runtime.SetQueryParameterParser(&customparser.CustomQueryParameterParser{}), // other runtime options you may need... ) } ``` ================================================ FILE: docs/index.md ================================================ --- layout: default title: gRPC-Gateway nav_order: 0 description: "Documentation site for the gRPC-Gateway" permalink: / --- # gRPC-Gateway {: .fs-9 } gRPC-Gateway is a plugin of [protoc](https://github.com/protocolbuffers/protobuf). It reads a [gRPC](https://grpc.io/) service definition and generates a reverse-proxy server which translates a RESTful JSON API into gRPC. This server is generated according to [custom options](https://cloud.google.com/service-infrastructure/docs/service-management/reference/rpc/google.api#http) in your gRPC definition. {: .fs-6 .fw-300 } [Get started](#getting-started){: .btn .btn-primary .fs-5 .mb-4 .mb-md-0 .mr-2 } [View it on GitHub](https://github.com/grpc-ecosystem/grpc-gateway){: .btn .fs-5 .mb-4 .mb-md-0 } --- ## Getting started gRPC-Gateway helps you to provide your APIs in both gRPC and RESTful style at the same time.
To learn more about gRPC-Gateway check out the documentation. ## Contribution See [CONTRIBUTING.md](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/CONTRIBUTING.md). ## License gRPC-Gateway is licensed under the BSD 3-Clause License. See [LICENSE](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE) for more details. ### Thank you to the contributors of gRPC-Gateway
    {% for contributor in site.github.contributors %}
  • {{ contributor.login }}
  • {% endfor %}
================================================ FILE: docs/run.sh ================================================ #! /bin/bash set -e JEKYLL_VERSION=4 BUNDLE_DIR="/tmp/grpc-gateway-bundle" if [ ! -d "${BUNDLE_DIR}" ]; then mkdir "${BUNDLE_DIR}" # Run this to update the Gemsfile.lock docker run --rm \ --volume="${PWD}:/srv/jekyll" \ -e "JEKYLL_UID=$(id -u)" \ -e "JEKYLL_GID=$(id -g)" \ --volume="/tmp/grpc-gateway-bundle:/usr/local/bundle" \ -it "jekyll/builder:${JEKYLL_VERSION}" \ bundle update fi if [[ ${JEKYLL_GITHUB_TOKEN} == "" ]]; then echo "Please set \$JEKYLL_GITHUB_TOKEN before running" exit 1 fi docker run --rm \ --volume="${PWD}:/srv/jekyll" \ -p 35729:35729 -p 4000:4000 \ -e "JEKYLL_UID=$(id -u)" \ -e "JEKYLL_GID=$(id -g)" \ -e "JEKYLL_GITHUB_TOKEN=${JEKYLL_GITHUB_TOKEN}" \ --volume="/tmp/grpc-gateway-bundle:/usr/local/bundle" \ -it "jekyll/builder:${JEKYLL_VERSION}" \ jekyll serve ================================================ FILE: examples/internal/README.md ================================================ # One way to run the example ```bash # Handle dependencies $ dep init ``` Follow the guides from this [README.md](./browser/README.md) to run the server and gateway. ```bash # Make sure you are in the correct directory: # $GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/v2/examples $ cd examples/internal/browser $ pwd # Install gulp $ npm install -g gulp-cli $ npm install $ gulp # Run $ gulp bower $ gulp backends ``` Then you can use curl or a browser to test: ```bash # List all apis $ curl http://localhost:8080/openapiv2/echo_service.swagger.json # Visit the apis $ curl -XPOST http://localhost:8080/v1/example/echo/foo {"id":"foo"} $ curl http://localhost:8080/v1/example/echo/foo/123 {"id":"foo","num":"123"} ``` So you have visited the apis by HTTP successfully. You can also try other apis. ================================================ FILE: examples/internal/browser/.gitignore ================================================ /bower_components /node_modules ================================================ FILE: examples/internal/browser/README.md ================================================ # Browser example This directory contains an example use of gRPC-Gateway with web browsers. The following commands automatically runs integration tests with phantomjs. ```shell-session $ npm install -g gulp-cli $ npm install $ gulp ``` ## Other examples ### Very simple example Run ```shell-session $ gulp bower $ gulp backends ``` then, open `index.html`. ### Integration test with your browser Run ```shell-session $ gulp serve ``` then, open `http://localhost:8000` with your browser. ================================================ FILE: examples/internal/browser/a_bit_of_everything_service.spec.js ================================================ 'use strict'; var SwaggerClient = require('swagger-client'); describe('ABitOfEverythingService', function () { var client; beforeEach(function (done) { new SwaggerClient({ url: "http://localhost:8080/openapiv2/a_bit_of_everything.swagger.json", usePromise: true, }).then(function (c) { client = c; }).catch(function (err) { done.fail(err); }).then(done); }); describe('Create', function () { var created; var expected = { floatValue: 1.5, doubleValue: 2.5, int64Value: "4294967296", uint64Value: "9223372036854775807", int32Value: -2147483648, fixed64Value: "9223372036854775807", fixed32Value: 4294967295, boolValue: true, stringValue: "strprefix/foo", uint32Value: 4294967295, sfixed32Value: 2147483647, sfixed64Value: "-4611686018427387904", sint32Value: 2147483647, sint64Value: "4611686018427387903", nonConventionalNameValue: "camelCase", enumValue: "ONE", pathEnumValue: "DEF", nestedPathEnumValue: "JKL", enumValueAnnotation: "ONE", requiredStringViaFieldBehaviorAnnotation: "foo", required_field_schema_json_name_custom: "bar", required_field_behavior_json_name_custom: "baz", requiredStringField1: "field1", requiredStringField2: "field2", uuid: "", singleNested: null, nested: [], bytesValue: "", repeatedStringValue: [], mapValue: {}, mappedStringValue: {}, mappedNestedValue: {}, timestampValue: "2006-01-02T15:04:05Z", repeatedEnumValue: [], repeatedEnumAnnotation: [], repeatedStringAnnotation: [], repeatedNestedAnnotation: [], nestedAnnotation: null, int64OverrideType: "0", outputOnlyStringViaFieldBehaviorAnnotation: "", }; beforeEach(function (done) { // Skipping Create endpoint - it has issues with map serialization in URL parameters done(); }); // Skipping - GET-style Create endpoint renders map objects as [object Object] instead of proper nested format xit('should assign id', function () { expect(created.uuid).not.toBe(""); }); // Skipping - GET-style Create endpoint renders map objects as [object Object] instead of proper nested format xit('should echo the request back', function () { delete created.uuid; expect(created).toEqual(expected); }); }); describe('CreateBody', function () { var created; var expected = { floatValue: 1.5, doubleValue: 2.5, int64Value: "4294967296", uint64Value: "9223372036854775807", int32Value: -2147483648, fixed64Value: "9223372036854775807", fixed32Value: 4294967295, boolValue: true, stringValue: "strprefix/foo", uint32Value: 4294967295, sfixed32Value: 2147483647, sfixed64Value: "-4611686018427387904", sint32Value: 2147483647, sint64Value: "4611686018427387903", nonConventionalNameValue: "camelCase", enumValue: "ONE", pathEnumValue: "DEF", nestedPathEnumValue: "JKL", nested: [ { name: "bar", amount: 10 }, { name: "baz", amount: 20 }, ], repeatedStringValue: ["a", "b", "c"], oneofString: "x", mapValue: { a: "ONE", b: 2 }, mappedStringValue: { a: "x", b: "y" }, mappedNestedValue: { a: { name: "x", amount: 1 }, b: { name: "y", amount: 2 }, }, enumValueAnnotation: "ONE", requiredStringViaFieldBehaviorAnnotation: "foo", productId: [], optionalStringField: "", requiredStringField1: "", requiredStringField2: "", required_field_behavior_json_name_custom: "", required_field_schema_json_name_custom: "", trailingOnly: "", trailingOnlyDot: "", trailingBoth: "", trailingMultiline: "", uuids: [], singleNested: null, nested: [], bytesValue: "", repeatedStringValue: [], mapValue: {}, mappedStringValue: {}, mappedNestedValue: {}, timestampValue: "2006-01-02T15:04:05Z", repeatedEnumValue: [], repeatedEnumAnnotation: [], repeatedStringAnnotation: [], repeatedNestedAnnotation: [], nestedAnnotation: null, int64OverrideType: "0", outputOnlyStringViaFieldBehaviorAnnotation: "", }; beforeEach(function (done) { client.ABitOfEverything.ABitOfEverythingService_CreateBody({ body: expected, }).then(function (resp) { created = resp.obj; }).catch(function (err) { done.fail(err); }).then(done); }); it('should assign id', function () { expect(created.uuid).not.toBe(""); }); it('should echo the request back', function () { delete created.uuid; expect(created).toEqual(expected); }); }); describe('lookup', function () { var created; var expected = { boolValue: true, stringValue: "strprefix/foo", }; beforeEach(function (done) { client.ABitOfEverything.ABitOfEverythingService_CreateBody({ body: expected, }).then(function (resp) { created = resp.obj; }).catch(function (err) { fail(err); }).finally(done); }); it('should look up an object by uuid', function (done) { client.ABitOfEverything.ABitOfEverythingService_Lookup({ uuid: created.uuid }).then(function (resp) { expect(resp.obj).toEqual(created); }).catch(function (err) { fail(err.errObj); }).finally(done); }); it('should fail if no such object', function (done) { client.ABitOfEverything.ABitOfEverythingService_Lookup({ uuid: 'not_exist', }).then(function (resp) { fail('expected failure but succeeded'); }).catch(function (err) { expect(err.status).toBe(404); }).finally(done); }); }); describe('Delete', function () { var created; var expected = { boolValue: true, stringValue: "strprefix/foo", }; beforeEach(function (done) { client.ABitOfEverything.ABitOfEverythingService_CreateBody({ body: expected, }).then(function (resp) { created = resp.obj; }).catch(function (err) { fail(err); }).finally(done); }); it('should delete an object by id', function (done) { client.ABitOfEverything.ABitOfEverythingService_Delete({ uuid: created.uuid }).then(function (resp) { expect(resp.obj).toEqual({}); }).catch(function (err) { fail(err.errObj); }).then(function () { return client.ABitOfEverything.ABitOfEverythingService_Lookup({ uuid: created.uuid }); }).then(function (resp) { fail('expected failure but succeeded'); }).catch(function (err) { expect(err.status).toBe(404); }).finally(done); }); }); describe('GetRepeatedQuery', function () { var repeated; var expected = { pathRepeatedFloatValue: [1.5, -1.5], pathRepeatedDoubleValue: [2.5, -2.5], pathRepeatedInt64Value: ["4294967296", "-4294967296"], pathRepeatedUint64Value: ["0", "9223372036854775807"], pathRepeatedInt32Value: [2147483647, -2147483648], pathRepeatedFixed64Value: ["0", "9223372036854775807"], pathRepeatedFixed32Value: [0, 4294967295], pathRepeatedBoolValue: [true, false], pathRepeatedStringValue: ["foo", "bar"], pathRepeatedBytesValue: ["AA==", "_w=="], pathRepeatedUint32Value: [4294967295, 0], pathRepeatedEnumValue: ["ONE", "ONE"], pathRepeatedSfixed32Value: [-2147483648, 2147483647], pathRepeatedSfixed64Value: ["-4294967296", "4294967296"], pathRepeatedSint32Value: [2147483646, -2147483647], pathRepeatedSint64Value: ["4611686018427387903", "-4611686018427387904"] }; beforeEach(function (done) { client.ABitOfEverything.ABitOfEverythingService_GetRepeatedQuery(expected).then(function (resp) { repeated = resp.obj; }).catch(function (err) { done.fail(err); }).then(done); }); it('should echo the request back', function () { // API will echo a non URL safe encoding expected.pathRepeatedBytesValue = ["AA==", "/w=="]; expect(repeated).toEqual(expected); }); }); }); ================================================ FILE: examples/internal/browser/bin/.gitignore ================================================ /* !/.gitignore ================================================ FILE: examples/internal/browser/bower.json ================================================ { "name": "grpc-gateway-example-browser", "description": "Example use of gRPC-Gateway from browser", "main": "index.js", "authors": [ "Yuki Yugui Sonoda " ], "license": "SEE LICENSE IN LICENSE file", "homepage": "https://github.com/grpc-ecosystem/grpc-gateway", "private": true, "dependencies": { "swagger-js": "~> 2.1" }, "ignore": [ "**/.*", "node_modules", "bower_components", "test", "tests" ] } ================================================ FILE: examples/internal/browser/echo_service.spec.js ================================================ 'use strict'; var SwaggerClient = require('swagger-client'); describe('EchoService', function () { var client; beforeEach(function (done) { new SwaggerClient({ url: "http://localhost:8080/openapiv2/echo_service.swagger.json", usePromise: true, }).then(function (c) { client = c; done(); }); }); describe('Echo', function () { it('should echo the request back', function (done) { var expected = { id: "foo", num: "0", status: null, resourceId: '', nId: null }; client.EchoService.EchoService_Echo( expected, { responseContentType: "application/json" } ).then(function (resp) { expect(resp.obj).toEqual(expected); }).catch(function (err) { done.fail(err); }).then(done); }); }); describe('EchoBody', function () { it('should echo the request back', function (done) { var expected = { id: "foo", num: "0", status: null, resourceId: '', nId: null }; client.EchoService.EchoService_EchoBody( { body: expected }, { responseContentType: "application/json" } ).then(function (resp) { expect(resp.obj).toEqual(expected); }).catch(function (err) { done.fail(err); }).then(done); }); }); }); ================================================ FILE: examples/internal/browser/gulpfile.js ================================================ "use strict"; const { exec, spawn } = require('child_process'); const util = require('util'); const path = require('path'); const fs = require('fs'); const http = require('http'); const execPromise = util.promisify(exec); // Module paths for the example builds const SERVER_MODULE = 'github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/cmd/example-grpc-server'; const GATEWAY_MODULE = 'github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/cmd/example-gateway-server'; let serverProcess = null; let gatewayProcess = null; // Validate module path to ensure it's safe function validateModulePath(modulePath) { // Module path should only contain alphanumeric, hyphens, underscores, dots, and slashes if (!/^[a-zA-Z0-9\-_.\/]+$/.test(modulePath)) { throw new Error(`Invalid module path: ${modulePath}`); } } function cleanupProcesses() { if (serverProcess) { serverProcess.kill(); serverProcess = null; } if (gatewayProcess) { gatewayProcess.kill(); gatewayProcess = null; } } process.on('exit', cleanupProcesses); process.on('SIGINT', () => { cleanupProcesses(); process.exit(); }); async function buildServer() { console.log('Building example server...'); validateModulePath(SERVER_MODULE); try { const { stdout, stderr } = await execPromise( `go build -o bin/example-server ${SERVER_MODULE}` ); // Only log if there's actual output (Go builds are usually silent on success) if (stdout) console.log(stdout); if (stderr) console.error(stderr); console.log('Server built successfully'); } catch (error) { console.error('Failed to build server:', error.message); throw error; } } async function buildGateway() { console.log('Building gateway...'); validateModulePath(GATEWAY_MODULE); try { const { stdout, stderr } = await execPromise( `go build -o bin/example-gw ${GATEWAY_MODULE}` ); // Only log if there's actual output (Go builds are usually silent on success) if (stdout) console.log(stdout); if (stderr) console.error(stderr); console.log('Gateway built successfully'); } catch (error) { console.error('Failed to build gateway:', error.message); throw error; } } async function build() { await buildServer(); await buildGateway(); console.log('All builds completed successfully'); } async function startServer() { await buildServer(); return new Promise((resolve, reject) => { const serverPath = path.join(__dirname, 'bin', 'example-server'); console.log(`Starting server: ${serverPath}`); serverProcess = spawn(serverPath, [], { stdio: ['ignore', 'pipe', 'pipe'], cwd: __dirname }); serverProcess.stdout.on('data', (data) => { console.log(`[Server]: ${data.toString().trim()}`); }); serverProcess.stderr.on('data', (data) => { console.error(`[Server Error]: ${data.toString().trim()}`); }); serverProcess.on('error', (error) => { console.error(`Failed to start server: ${error.message}`); reject(error); }); serverProcess.on('exit', (code, signal) => { console.log(`Server exited with code ${code} and signal ${signal}`); }); // Give server time to start setTimeout(resolve, 2000); }); } async function startGateway() { await buildGateway(); return new Promise((resolve, reject) => { const gatewayPath = path.join(__dirname, 'bin', 'example-gw'); const openApiDir = path.join(__dirname, '..', 'proto', 'examplepb'); console.log(`Starting gateway: ${gatewayPath} with openapi_dir: ${openApiDir}`); gatewayProcess = spawn(gatewayPath, [ '--openapi_dir', openApiDir ], { stdio: ['ignore', 'pipe', 'pipe'], cwd: __dirname }); gatewayProcess.stdout.on('data', (data) => { console.log(`[Gateway]: ${data.toString().trim()}`); }); gatewayProcess.stderr.on('data', (data) => { console.error(`[Gateway Error]: ${data.toString().trim()}`); }); gatewayProcess.on('error', (error) => { console.error(`Failed to start gateway: ${error.message}`); reject(error); }); gatewayProcess.on('exit', (code, signal) => { console.log(`Gateway exited with code ${code} and signal ${signal}`); }); // Give gateway time to start setTimeout(resolve, 2000); }); } async function bundleSpecs() { console.log('Bundling test specs with webpack...'); const specFiles = [ path.join(__dirname, 'a_bit_of_everything_service.spec.js'), path.join(__dirname, 'echo_service.spec.js') ]; try { const { stdout, stderr } = await execPromise( `npx webpack --config webpack.config.js --entry ${specFiles.join(' --entry ')} --output-path ${path.join(__dirname, 'bin')} --output-filename spec.js`, { cwd: __dirname } ); if (stdout) console.log(stdout); if (stderr && !stderr.includes('webpack')) console.error(stderr); console.log('Specs bundled successfully'); } catch (error) { console.error('Failed to bundle specs:', error.message); throw error; } } // Generate HTML content for Jasmine test runner function generateJasmineHTML(jasmineCore, jasmineHtml, includeResultsCapture = false) { const resultsScript = includeResultsCapture ? 'window.jasmineResults = result;' : ''; return ` Jasmine Spec Runner `; } // Load Jasmine library files function loadJasmineFiles() { const jasmineCorePath = require.resolve('jasmine-core/lib/jasmine-core/jasmine.js'); const jasmineHtmlPath = require.resolve('jasmine-core/lib/jasmine-core/jasmine-html.js'); return { jasmineCore: fs.readFileSync(jasmineCorePath, 'utf8'), jasmineHtml: fs.readFileSync(jasmineHtmlPath, 'utf8') }; } // Create HTTP server that serves test page and spec bundle function createTestServer(htmlContent, specBundle) { return http.createServer((req, res) => { if (req.url === '/spec.js') { res.writeHead(200, { 'Content-Type': 'application/javascript' }); res.end(specBundle); } else { res.writeHead(200, { 'Content-Type': 'text/html' }); res.end(htmlContent); } }); } async function runTests() { const { chromium } = require('playwright'); let server = null; let browser = null; try { // Start the backends console.log('Starting server and gateway...'); await startServer(); await startGateway(); // Bundle the specs await bundleSpecs(); // Set up test server console.log('Setting up test server...'); // Load Jasmine and the bundled specs const { jasmineCore, jasmineHtml } = loadJasmineFiles(); const specBundle = fs.readFileSync(path.join(__dirname, 'bin', 'spec.js'), 'utf8'); // Create HTML page content with results capture const htmlContent = generateJasmineHTML(jasmineCore, jasmineHtml, true); // Create HTTP server server = createTestServer(htmlContent, specBundle); // Start server on port 8000 await new Promise((resolve) => { server.listen(8000, () => { console.log('Test server listening on http://localhost:8000'); resolve(); }); }); // Run tests in Playwright console.log('Launching browser...'); browser = await chromium.launch({ headless: true }); const context = await browser.newContext(); const page = await context.newPage(); console.log('Setting page timeout...'); page.setDefaultTimeout(120000); // Set default timeout to 120 seconds // Capture console output page.on('console', msg => { const text = msg.text(); console.log('[Browser]:', text); }); // Capture page errors page.on('pageerror', error => { console.error('[Page Error]:', error.message); }); console.log('Navigating to test page...'); // Navigate to the test server await page.goto('http://localhost:8000'); console.log('Waiting for tests to complete...'); // Wait for tests to complete await page.waitForFunction(() => window.jasmineResults !== undefined, { timeout: 120000 }); // Get results const results = await page.evaluate(() => window.jasmineResults); await browser.close(); browser = null; console.log(`\nTest Results: ${results.overallStatus}`); console.log(`Total specs: ${results.totalCount || 'N/A'}`); console.log(`Failed specs: ${results.failedExpectations?.length || 0}`); if (results.overallStatus !== 'passed') { throw new Error('Tests failed'); } console.log('Tests completed successfully'); } catch (error) { console.error('Tests failed:', error.message); throw error; } finally { // Cleanup if (browser) { await browser.close(); } if (server) { server.close(); } cleanupProcesses(); } } async function serve() { try { // Start the backends console.log('Starting server and gateway...'); await startServer(); await startGateway(); // Bundle the specs await bundleSpecs(); // Start a development server console.log('Starting development server on http://localhost:8000...'); // Load Jasmine files const { jasmineCore, jasmineHtml } = loadJasmineFiles(); // Create server that dynamically loads spec bundle on each request (for development) const server = http.createServer((req, res) => { if (req.url === '/spec.js') { const specBundle = fs.readFileSync(path.join(__dirname, 'bin', 'spec.js'), 'utf8'); res.writeHead(200, { 'Content-Type': 'application/javascript' }); res.end(specBundle); return; } // Generate HTML without results capture for development const htmlContent = generateJasmineHTML(jasmineCore, jasmineHtml, false); res.writeHead(200, { 'Content-Type': 'text/html' }); res.end(htmlContent); }); server.listen(8000, () => { console.log('Development server running at http://localhost:8000'); console.log('Backend server running at http://localhost:9090'); console.log('Gateway running at http://localhost:8080'); console.log('Press Ctrl+C to stop'); }); // Keep the process running indefinitely until terminated by user await new Promise(() => {}); } catch (error) { console.error('Serve task failed:', error.message); throw error; } finally { cleanupProcesses(); } } exports.build = build; exports.buildServer = buildServer; exports.buildGateway = buildGateway; exports.test = runTests; exports.serve = serve; exports.default = runTests; ================================================ FILE: examples/internal/browser/index.html ================================================
================================================ FILE: examples/internal/browser/package.json ================================================ { "name": "grpc-gateway-example", "version": "1.0.0", "description": "Example use of gRPC-Gateway from browser", "scripts": { "test": "gulp", "postinstall": "playwright install chromium" }, "author": "", "license": "SEE LICENSE", "devDependencies": { "gulp": "^5.0.0", "jasmine-core": "^5.5.0", "playwright": "^1.49.1", "swagger-client": "^2.1.32", "webpack": "^5.97.1", "webpack-cli": "^6.0.1" }, "dependencies": { "gulp-cli": "^3.1.0" } } ================================================ FILE: examples/internal/browser/spec/support/jasmine-browser.json ================================================ { "srcDir": ".", "srcFiles": [], "specDir": "bin", "specFiles": [ "spec.js" ], "helpers": [], "env": { "stopSpecOnExpectationFailure": false, "stopOnSpecFailure": false, "random": false }, "browser": { "name": "headlessChrome" } } ================================================ FILE: examples/internal/browser/webpack.config.js ================================================ const path = require('path'); module.exports = { mode: 'development', devtool: 'source-map' }; ================================================ FILE: examples/internal/clients/abe/.gitignore ================================================ /docs ================================================ FILE: examples/internal/clients/abe/.swagger-codegen/VERSION ================================================ 2.4.8 ================================================ FILE: examples/internal/clients/abe/.swagger-codegen-ignore ================================================ .gitignore ================================================ FILE: examples/internal/clients/abe/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library") package(default_visibility = ["//visibility:public"]) go_library( name = "abe", srcs = [ "api_a_bit_of_everything.go", "api_camel_case_service_name.go", "api_echo_rpc.go", "api_snake_enum_service.go", "client.go", "configuration.go", "enum_helper.go", "model_a_bit_of_everything.go", "model_a_bit_of_everything_1.go", "model_a_bit_of_everything_2.go", "model_a_bit_of_everything_3.go", "model_a_bit_of_everything_4.go", "model_a_bit_of_everything_5.go", "model_a_bit_of_everything_6.go", "model_a_bit_of_everything_7.go", "model_a_bit_of_everything_8.go", "model_a_bit_of_everything_nested.go", "model_a_bit_of_everything_service_deep_path_echo_body.go", "model_a_bit_of_everything_service_deep_path_echo_body_single_nested.go", "model_a_bit_of_everything_service_post_with_empty_body_body.go", "model_a_bit_of_everything_service_update_body.go", "model_a_bit_of_everything_service_update_v2_body.go", "model_book.go", "model_examplepb_a_bit_of_everything.go", "model_examplepb_a_bit_of_everything_repeated.go", "model_examplepb_a_bit_of_everything_service_update_body.go", "model_examplepb_bar.go", "model_examplepb_body.go", "model_examplepb_book.go", "model_examplepb_check_status_response.go", "model_examplepb_error_object.go", "model_examplepb_error_response.go", "model_examplepb_numeric_enum.go", "model_examplepb_required_message_type_request.go", "model_examplepb_snake_case_0_enum.go", "model_examplepb_snake_case_enum.go", "model_examplepb_snake_enum_response.go", "model_google_rpc_status.go", "model_message_path_enum_nested_path_enum.go", "model_nested_deep_enum.go", "model_oneofenum_example_enum.go", "model_pathenum_path_enum.go", "model_pathenum_snake_case_for_import.go", "model_proto_examplepb_foo.go", "model_protobuf_any.go", "model_sub_string_message.go", "model_the_book_to_update_.go", "model_the_book_to_update__1.go", "model_the_book_to_update_the_books_name_field_is_used_to_identify_the_book_to_be_updated_format_publisherspublisherbooksbook.go", "model_update_v2_request_request_for_update_includes_the_message_and_the_update_mask.go", "model_update_v2_request_request_for_update_includes_the_message_and_the_update_mask_1.go", "model_v1exampledeep_pathsingle_nested_name_single_nested.go", "response.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/clients/abe", deps = [ "//examples/internal/proto/examplepb", "//examples/internal/proto/pathenum", "//runtime", "@com_github_antihax_optional//:optional", "@org_golang_x_oauth2//:oauth2", ], ) alias( name = "go_default_library", actual = ":abe", visibility = ["//examples:__subpackages__"], ) ================================================ FILE: examples/internal/clients/abe/api/swagger.yaml ================================================ --- swagger: "2.0" info: version: "1.0" title: "A Bit of Everything" contact: name: "gRPC-Gateway project" url: "https://github.com/grpc-ecosystem/grpc-gateway" email: "none@example.com" license: name: "BSD 3-Clause License" url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE" x-something-something: "yadda" tags: - name: "echo rpc" description: "Echo Rpc description" x-traitTag: true - name: "ABitOfEverything" description: "ABitOfEverythingService description -- which should not be used in\ \ place of the documentation comment!" externalDocs: description: "Find out more about EchoService" url: "https://github.com/grpc-ecosystem/grpc-gateway" - name: "camelCaseServiceName" - name: "AnotherServiceWithNoBindings" - name: "SnakeEnumService" schemes: - "http" - "https" - "wss" consumes: - "application/json" - "application/x-foo-mime" produces: - "application/json" - "application/x-foo-mime" security: - ApiKeyAuth: [] BasicAuth: [] - ApiKeyAuth: [] OAuth2: - "read" - "write" paths: /v1/example/a_bit_of_everything: post: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_CreateBody" parameters: - in: "body" name: "body" description: "Intentionally complicated message type to cover many features\ \ of Protobuf." required: true schema: $ref: "#/definitions/examplepbABitOfEverything" x-exportParamName: "Body" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbABitOfEverything" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/a_bit_of_everything/custom/{optionalStringValue}: get: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_Custom2" parameters: - name: "optionalStringValue" in: "path" required: true type: "string" x-exportParamName: "OptionalStringValue" - name: "singleNested.name" in: "query" description: "name is nested field." required: false type: "string" x-exportParamName: "SingleNestedName" x-optionalDataType: "String" - name: "singleNested.amount" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "SingleNestedAmount" x-optionalDataType: "Int64" - name: "singleNested.ok" in: "query" description: "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE:\ \ TRUE is true." required: false type: "string" default: "FALSE" enum: - "FALSE" - "TRUE" x-exportParamName: "SingleNestedOk" x-optionalDataType: "String" - name: "uuid" in: "query" required: true type: "string" pattern: "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}" format: "uuid" x-internal: true x-exportParamName: "Uuid" - name: "floatValue" in: "query" description: "Float value field" required: true type: "number" default: 0.2 format: "float" x-exportParamName: "FloatValue" - name: "doubleValue" in: "query" required: true type: "number" format: "double" x-exportParamName: "DoubleValue" - name: "int64Value" in: "query" required: true type: "string" format: "int64" x-exportParamName: "Int64Value" - name: "uint64Value" in: "query" required: false type: "string" format: "uint64" x-exportParamName: "Uint64Value" x-optionalDataType: "String" - name: "int32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Int32Value" x-optionalDataType: "Int32" - name: "fixed64Value" in: "query" required: false type: "string" format: "uint64" x-exportParamName: "Fixed64Value" x-optionalDataType: "String" - name: "fixed32Value" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Fixed32Value" x-optionalDataType: "Int64" - name: "boolValue" in: "query" required: false type: "boolean" x-exportParamName: "BoolValue" x-optionalDataType: "Bool" - name: "stringValue" in: "query" required: false type: "string" x-exportParamName: "StringValue" x-optionalDataType: "String" - name: "bytesValue" in: "query" required: false type: "string" format: "byte" x-exportParamName: "BytesValue" x-optionalDataType: "String" - name: "uint32Value" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Uint32Value" x-optionalDataType: "Int64" - name: "enumValue" in: "query" description: " - ZERO: ZERO means 0\n - ONE: ONE means 1" required: false type: "string" default: "ZERO" enum: - "ZERO" - "ONE" x-exportParamName: "EnumValue" x-optionalDataType: "String" - name: "pathEnumValue" in: "query" required: false type: "string" default: "ABC" enum: - "ABC" - "DEF" x-exportParamName: "PathEnumValue" x-optionalDataType: "String" - name: "nestedPathEnumValue" in: "query" required: false type: "string" default: "GHI" enum: - "GHI" - "JKL" x-exportParamName: "NestedPathEnumValue" x-optionalDataType: "String" - name: "sfixed32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Sfixed32Value" x-optionalDataType: "Int32" - name: "sfixed64Value" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Sfixed64Value" x-optionalDataType: "String" - name: "sint32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Sint32Value" x-optionalDataType: "Int32" - name: "sint64Value" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Sint64Value" x-optionalDataType: "String" - name: "repeatedStringValue" in: "query" required: false type: "array" items: type: "string" collectionFormat: "multi" x-exportParamName: "RepeatedStringValue" - name: "oneofEmpty" in: "query" required: false type: "object" x-exportParamName: "OneofEmpty" - name: "oneofString" in: "query" required: false type: "string" x-exportParamName: "OneofString" x-optionalDataType: "String" - name: "mapValue" in: "query" description: "map of numeric enum" required: false x-exportParamName: "MapValue" - name: "mappedStringValue" in: "query" description: "Map of string title\n\nMap of string description." required: false type: "string" x-exportParamName: "MappedStringValue" x-optionalDataType: "String" - name: "mappedNestedValue" in: "query" required: false x-exportParamName: "MappedNestedValue" - name: "nonConventionalNameValue" in: "query" required: false type: "string" x-exportParamName: "NonConventionalNameValue" x-optionalDataType: "String" - name: "timestampValue" in: "query" required: false type: "string" format: "date-time" x-exportParamName: "TimestampValue" x-optionalDataType: "Time" - name: "repeatedEnumValue" in: "query" description: "repeated enum value. it is comma-separated in query\n\n - ZERO:\ \ ZERO means 0\n - ONE: ONE means 1" required: false type: "array" items: type: "string" enum: - "ZERO" - "ONE" collectionFormat: "multi" x-exportParamName: "RepeatedEnumValue" - name: "repeatedEnumAnnotation" in: "query" description: "Repeated numeric enum title\n\nRepeated numeric enum description.\n\ \n - ZERO: ZERO means 0\n - ONE: ONE means 1" required: false type: "array" items: type: "string" enum: - "ZERO" - "ONE" collectionFormat: "multi" x-exportParamName: "RepeatedEnumAnnotation" - name: "enumValueAnnotation" in: "query" description: "Numeric enum title\n\nNumeric enum description.\n\n - ZERO:\ \ ZERO means 0\n - ONE: ONE means 1" required: false type: "string" default: "ZERO" enum: - "ZERO" - "ONE" x-exportParamName: "EnumValueAnnotation" x-optionalDataType: "String" - name: "repeatedStringAnnotation" in: "query" description: "Repeated string title\n\nRepeated string description." required: false type: "array" items: type: "string" collectionFormat: "multi" x-exportParamName: "RepeatedStringAnnotation" - name: "nestedAnnotation.name" in: "query" description: "name is nested field." required: false type: "string" x-exportParamName: "NestedAnnotationName" x-optionalDataType: "String" - name: "nestedAnnotation.amount" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "NestedAnnotationAmount" x-optionalDataType: "Int64" - name: "nestedAnnotation.ok" in: "query" description: "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE:\ \ TRUE is true." required: false type: "string" default: "FALSE" enum: - "FALSE" - "TRUE" x-exportParamName: "NestedAnnotationOk" x-optionalDataType: "String" - name: "int64OverrideType" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Int64OverrideType" x-optionalDataType: "Int64" - name: "requiredStringViaFieldBehaviorAnnotation" in: "query" description: "mark a field as required in Open API definition" required: true type: "string" x-exportParamName: "RequiredStringViaFieldBehaviorAnnotation" - name: "outputOnlyStringViaFieldBehaviorAnnotation" in: "query" description: "mark a field as readonly in Open API definition" required: false type: "string" x-exportParamName: "OutputOnlyStringViaFieldBehaviorAnnotation" x-optionalDataType: "String" - name: "productId" in: "query" description: "Test openapiv2 generation of repeated fields\n\nOnly digits\ \ are allowed." required: false type: "array" items: type: "string" minLength: 1 maxLength: 19 pattern: "^[0-9]+$" collectionFormat: "multi" x-exportParamName: "ProductId" - name: "optionalStringField" in: "query" description: "Test openapiv2 generation of required fields with annotation\ \ and jsonschema to reproduce" required: false type: "string" x-exportParamName: "OptionalStringField" x-optionalDataType: "String" - name: "requiredStringField1" in: "query" required: true type: "string" x-exportParamName: "RequiredStringField1" - name: "requiredStringField2" in: "query" required: true type: "string" x-exportParamName: "RequiredStringField2" - name: "required_field_behavior_json_name_custom" in: "query" description: "Test openapiv2 handling of required json_name fields" required: true type: "string" x-exportParamName: "RequiredFieldBehaviorJsonNameCustom" - name: "required_field_schema_json_name_custom" in: "query" required: true type: "string" x-exportParamName: "RequiredFieldSchemaJsonNameCustom" - name: "trailingOnly" in: "query" description: "Trailing only" required: false type: "string" x-exportParamName: "TrailingOnly" x-optionalDataType: "String" - name: "trailingOnlyDot" in: "query" description: "Trailing only dot." required: false type: "string" x-exportParamName: "TrailingOnlyDot" x-optionalDataType: "String" - name: "trailingBoth" in: "query" description: "Leading both\n\nTrailing both." required: false type: "string" x-exportParamName: "TrailingBoth" x-optionalDataType: "String" - name: "trailingMultiline" in: "query" description: "Leading multiline\n\nThis is an example of a multi-line comment.\n\ \nTrailing multiline." required: false type: "string" x-exportParamName: "TrailingMultiline" x-optionalDataType: "String" - name: "uuids" in: "query" description: "Specify a custom format of repeated field items" required: false type: "array" items: type: "string" format: "uuid" collectionFormat: "multi" x-exportParamName: "Uuids" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbABitOfEverything" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/a_bit_of_everything/echo/{value}: get: tags: - "echo rpc" summary: "Summary: Echo rpc" description: "Description Echo" operationId: "ABitOfEverythingService_Echo" parameters: - name: "value" in: "path" required: true type: "string" x-exportParamName: "Value" responses: 200: description: "A successful response." examples: application/json: value: "the input value" schema: $ref: "#/definitions/subStringMessage" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "integer" format: "integer" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" 503: description: "Returned when the resource is temporarily unavailable." schema: {} x-number: 100 default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" externalDocs: description: "Find out more Echo" url: "https://github.com/grpc-ecosystem/grpc-gateway" /v1/example/a_bit_of_everything/params/get/nested_enum/{singleNested.ok}: get: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_CheckNestedEnumGetQueryParams" parameters: - name: "singleNested.ok" in: "path" description: "DeepEnum description." required: true type: "string" enum: - "FALSE" - "TRUE" x-exportParamName: "SingleNestedOk" - name: "singleNested.name" in: "query" description: "name is nested field." required: false type: "string" x-exportParamName: "SingleNestedName" x-optionalDataType: "String" - name: "singleNested.amount" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "SingleNestedAmount" x-optionalDataType: "Int64" - name: "uuid" in: "query" required: true type: "string" pattern: "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}" format: "uuid" x-internal: true x-exportParamName: "Uuid" - name: "floatValue" in: "query" description: "Float value field" required: true type: "number" default: 0.2 format: "float" x-exportParamName: "FloatValue" - name: "doubleValue" in: "query" required: true type: "number" format: "double" x-exportParamName: "DoubleValue" - name: "int64Value" in: "query" required: true type: "string" format: "int64" x-exportParamName: "Int64Value" - name: "uint64Value" in: "query" required: false type: "string" format: "uint64" x-exportParamName: "Uint64Value" x-optionalDataType: "String" - name: "int32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Int32Value" x-optionalDataType: "Int32" - name: "fixed64Value" in: "query" required: false type: "string" format: "uint64" x-exportParamName: "Fixed64Value" x-optionalDataType: "String" - name: "fixed32Value" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Fixed32Value" x-optionalDataType: "Int64" - name: "boolValue" in: "query" required: false type: "boolean" x-exportParamName: "BoolValue" x-optionalDataType: "Bool" - name: "stringValue" in: "query" required: false type: "string" x-exportParamName: "StringValue" x-optionalDataType: "String" - name: "bytesValue" in: "query" required: false type: "string" format: "byte" x-exportParamName: "BytesValue" x-optionalDataType: "String" - name: "uint32Value" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Uint32Value" x-optionalDataType: "Int64" - name: "enumValue" in: "query" description: " - ZERO: ZERO means 0\n - ONE: ONE means 1" required: false type: "string" default: "ZERO" enum: - "ZERO" - "ONE" x-exportParamName: "EnumValue" x-optionalDataType: "String" - name: "pathEnumValue" in: "query" required: false type: "string" default: "ABC" enum: - "ABC" - "DEF" x-exportParamName: "PathEnumValue" x-optionalDataType: "String" - name: "nestedPathEnumValue" in: "query" required: false type: "string" default: "GHI" enum: - "GHI" - "JKL" x-exportParamName: "NestedPathEnumValue" x-optionalDataType: "String" - name: "sfixed32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Sfixed32Value" x-optionalDataType: "Int32" - name: "sfixed64Value" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Sfixed64Value" x-optionalDataType: "String" - name: "sint32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Sint32Value" x-optionalDataType: "Int32" - name: "sint64Value" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Sint64Value" x-optionalDataType: "String" - name: "repeatedStringValue" in: "query" required: false type: "array" items: type: "string" collectionFormat: "multi" x-exportParamName: "RepeatedStringValue" - name: "oneofEmpty" in: "query" required: false type: "object" x-exportParamName: "OneofEmpty" - name: "oneofString" in: "query" required: false type: "string" x-exportParamName: "OneofString" x-optionalDataType: "String" - name: "mapValue" in: "query" description: "map of numeric enum" required: false x-exportParamName: "MapValue" - name: "mappedStringValue" in: "query" description: "Map of string title\n\nMap of string description." required: false type: "string" x-exportParamName: "MappedStringValue" x-optionalDataType: "String" - name: "mappedNestedValue" in: "query" required: false x-exportParamName: "MappedNestedValue" - name: "nonConventionalNameValue" in: "query" required: false type: "string" x-exportParamName: "NonConventionalNameValue" x-optionalDataType: "String" - name: "timestampValue" in: "query" required: false type: "string" format: "date-time" x-exportParamName: "TimestampValue" x-optionalDataType: "Time" - name: "repeatedEnumValue" in: "query" description: "repeated enum value. it is comma-separated in query\n\n - ZERO:\ \ ZERO means 0\n - ONE: ONE means 1" required: false type: "array" items: type: "string" enum: - "ZERO" - "ONE" collectionFormat: "multi" x-exportParamName: "RepeatedEnumValue" - name: "repeatedEnumAnnotation" in: "query" description: "Repeated numeric enum title\n\nRepeated numeric enum description.\n\ \n - ZERO: ZERO means 0\n - ONE: ONE means 1" required: false type: "array" items: type: "string" enum: - "ZERO" - "ONE" collectionFormat: "multi" x-exportParamName: "RepeatedEnumAnnotation" - name: "enumValueAnnotation" in: "query" description: "Numeric enum title\n\nNumeric enum description.\n\n - ZERO:\ \ ZERO means 0\n - ONE: ONE means 1" required: false type: "string" default: "ZERO" enum: - "ZERO" - "ONE" x-exportParamName: "EnumValueAnnotation" x-optionalDataType: "String" - name: "repeatedStringAnnotation" in: "query" description: "Repeated string title\n\nRepeated string description." required: false type: "array" items: type: "string" collectionFormat: "multi" x-exportParamName: "RepeatedStringAnnotation" - name: "nestedAnnotation.name" in: "query" description: "name is nested field." required: false type: "string" x-exportParamName: "NestedAnnotationName" x-optionalDataType: "String" - name: "nestedAnnotation.amount" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "NestedAnnotationAmount" x-optionalDataType: "Int64" - name: "int64OverrideType" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Int64OverrideType" x-optionalDataType: "Int64" - name: "requiredStringViaFieldBehaviorAnnotation" in: "query" description: "mark a field as required in Open API definition" required: true type: "string" x-exportParamName: "RequiredStringViaFieldBehaviorAnnotation" - name: "outputOnlyStringViaFieldBehaviorAnnotation" in: "query" description: "mark a field as readonly in Open API definition" required: false type: "string" x-exportParamName: "OutputOnlyStringViaFieldBehaviorAnnotation" x-optionalDataType: "String" - name: "optionalStringValue" in: "query" required: false type: "string" x-exportParamName: "OptionalStringValue" x-optionalDataType: "String" - name: "productId" in: "query" description: "Test openapiv2 generation of repeated fields\n\nOnly digits\ \ are allowed." required: false type: "array" items: type: "string" minLength: 1 maxLength: 19 pattern: "^[0-9]+$" collectionFormat: "multi" x-exportParamName: "ProductId" - name: "optionalStringField" in: "query" description: "Test openapiv2 generation of required fields with annotation\ \ and jsonschema to reproduce" required: false type: "string" x-exportParamName: "OptionalStringField" x-optionalDataType: "String" - name: "requiredStringField1" in: "query" required: true type: "string" x-exportParamName: "RequiredStringField1" - name: "requiredStringField2" in: "query" required: true type: "string" x-exportParamName: "RequiredStringField2" - name: "required_field_behavior_json_name_custom" in: "query" description: "Test openapiv2 handling of required json_name fields" required: true type: "string" x-exportParamName: "RequiredFieldBehaviorJsonNameCustom" - name: "required_field_schema_json_name_custom" in: "query" required: true type: "string" x-exportParamName: "RequiredFieldSchemaJsonNameCustom" - name: "trailingOnly" in: "query" description: "Trailing only" required: false type: "string" x-exportParamName: "TrailingOnly" x-optionalDataType: "String" - name: "trailingOnlyDot" in: "query" description: "Trailing only dot." required: false type: "string" x-exportParamName: "TrailingOnlyDot" x-optionalDataType: "String" - name: "trailingBoth" in: "query" description: "Leading both\n\nTrailing both." required: false type: "string" x-exportParamName: "TrailingBoth" x-optionalDataType: "String" - name: "trailingMultiline" in: "query" description: "Leading multiline\n\nThis is an example of a multi-line comment.\n\ \nTrailing multiline." required: false type: "string" x-exportParamName: "TrailingMultiline" x-optionalDataType: "String" - name: "uuids" in: "query" description: "Specify a custom format of repeated field items" required: false type: "array" items: type: "string" format: "uuid" collectionFormat: "multi" x-exportParamName: "Uuids" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbABitOfEverything" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/a_bit_of_everything/params/get/{singleNested.name}: get: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_CheckGetQueryParams" parameters: - name: "singleNested.name" in: "path" description: "name is nested field." required: true type: "string" x-exportParamName: "SingleNestedName" - name: "singleNested.amount" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "SingleNestedAmount" x-optionalDataType: "Int64" - name: "singleNested.ok" in: "query" description: "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE:\ \ TRUE is true." required: false type: "string" default: "FALSE" enum: - "FALSE" - "TRUE" x-exportParamName: "SingleNestedOk" x-optionalDataType: "String" - name: "uuid" in: "query" required: true type: "string" pattern: "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}" format: "uuid" x-internal: true x-exportParamName: "Uuid" - name: "floatValue" in: "query" description: "Float value field" required: true type: "number" default: 0.2 format: "float" x-exportParamName: "FloatValue" - name: "doubleValue" in: "query" required: true type: "number" format: "double" x-exportParamName: "DoubleValue" - name: "int64Value" in: "query" required: true type: "string" format: "int64" x-exportParamName: "Int64Value" - name: "uint64Value" in: "query" required: false type: "string" format: "uint64" x-exportParamName: "Uint64Value" x-optionalDataType: "String" - name: "int32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Int32Value" x-optionalDataType: "Int32" - name: "fixed64Value" in: "query" required: false type: "string" format: "uint64" x-exportParamName: "Fixed64Value" x-optionalDataType: "String" - name: "fixed32Value" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Fixed32Value" x-optionalDataType: "Int64" - name: "boolValue" in: "query" required: false type: "boolean" x-exportParamName: "BoolValue" x-optionalDataType: "Bool" - name: "stringValue" in: "query" required: false type: "string" x-exportParamName: "StringValue" x-optionalDataType: "String" - name: "bytesValue" in: "query" required: false type: "string" format: "byte" x-exportParamName: "BytesValue" x-optionalDataType: "String" - name: "uint32Value" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Uint32Value" x-optionalDataType: "Int64" - name: "enumValue" in: "query" description: " - ZERO: ZERO means 0\n - ONE: ONE means 1" required: false type: "string" default: "ZERO" enum: - "ZERO" - "ONE" x-exportParamName: "EnumValue" x-optionalDataType: "String" - name: "pathEnumValue" in: "query" required: false type: "string" default: "ABC" enum: - "ABC" - "DEF" x-exportParamName: "PathEnumValue" x-optionalDataType: "String" - name: "nestedPathEnumValue" in: "query" required: false type: "string" default: "GHI" enum: - "GHI" - "JKL" x-exportParamName: "NestedPathEnumValue" x-optionalDataType: "String" - name: "sfixed32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Sfixed32Value" x-optionalDataType: "Int32" - name: "sfixed64Value" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Sfixed64Value" x-optionalDataType: "String" - name: "sint32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Sint32Value" x-optionalDataType: "Int32" - name: "sint64Value" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Sint64Value" x-optionalDataType: "String" - name: "repeatedStringValue" in: "query" required: false type: "array" items: type: "string" collectionFormat: "multi" x-exportParamName: "RepeatedStringValue" - name: "oneofEmpty" in: "query" required: false type: "object" x-exportParamName: "OneofEmpty" - name: "oneofString" in: "query" required: false type: "string" x-exportParamName: "OneofString" x-optionalDataType: "String" - name: "mapValue" in: "query" description: "map of numeric enum" required: false x-exportParamName: "MapValue" - name: "mappedStringValue" in: "query" description: "Map of string title\n\nMap of string description." required: false type: "string" x-exportParamName: "MappedStringValue" x-optionalDataType: "String" - name: "mappedNestedValue" in: "query" required: false x-exportParamName: "MappedNestedValue" - name: "nonConventionalNameValue" in: "query" required: false type: "string" x-exportParamName: "NonConventionalNameValue" x-optionalDataType: "String" - name: "timestampValue" in: "query" required: false type: "string" format: "date-time" x-exportParamName: "TimestampValue" x-optionalDataType: "Time" - name: "repeatedEnumValue" in: "query" description: "repeated enum value. it is comma-separated in query\n\n - ZERO:\ \ ZERO means 0\n - ONE: ONE means 1" required: false type: "array" items: type: "string" enum: - "ZERO" - "ONE" collectionFormat: "multi" x-exportParamName: "RepeatedEnumValue" - name: "repeatedEnumAnnotation" in: "query" description: "Repeated numeric enum title\n\nRepeated numeric enum description.\n\ \n - ZERO: ZERO means 0\n - ONE: ONE means 1" required: false type: "array" items: type: "string" enum: - "ZERO" - "ONE" collectionFormat: "multi" x-exportParamName: "RepeatedEnumAnnotation" - name: "enumValueAnnotation" in: "query" description: "Numeric enum title\n\nNumeric enum description.\n\n - ZERO:\ \ ZERO means 0\n - ONE: ONE means 1" required: false type: "string" default: "ZERO" enum: - "ZERO" - "ONE" x-exportParamName: "EnumValueAnnotation" x-optionalDataType: "String" - name: "repeatedStringAnnotation" in: "query" description: "Repeated string title\n\nRepeated string description." required: false type: "array" items: type: "string" collectionFormat: "multi" x-exportParamName: "RepeatedStringAnnotation" - name: "nestedAnnotation.amount" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "NestedAnnotationAmount" x-optionalDataType: "Int64" - name: "nestedAnnotation.ok" in: "query" description: "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE:\ \ TRUE is true." required: false type: "string" default: "FALSE" enum: - "FALSE" - "TRUE" x-exportParamName: "NestedAnnotationOk" x-optionalDataType: "String" - name: "int64OverrideType" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Int64OverrideType" x-optionalDataType: "Int64" - name: "requiredStringViaFieldBehaviorAnnotation" in: "query" description: "mark a field as required in Open API definition" required: true type: "string" x-exportParamName: "RequiredStringViaFieldBehaviorAnnotation" - name: "outputOnlyStringViaFieldBehaviorAnnotation" in: "query" description: "mark a field as readonly in Open API definition" required: false type: "string" x-exportParamName: "OutputOnlyStringViaFieldBehaviorAnnotation" x-optionalDataType: "String" - name: "optionalStringValue" in: "query" required: false type: "string" x-exportParamName: "OptionalStringValue" x-optionalDataType: "String" - name: "productId" in: "query" description: "Test openapiv2 generation of repeated fields\n\nOnly digits\ \ are allowed." required: false type: "array" items: type: "string" minLength: 1 maxLength: 19 pattern: "^[0-9]+$" collectionFormat: "multi" x-exportParamName: "ProductId" - name: "optionalStringField" in: "query" description: "Test openapiv2 generation of required fields with annotation\ \ and jsonschema to reproduce" required: false type: "string" x-exportParamName: "OptionalStringField" x-optionalDataType: "String" - name: "requiredStringField1" in: "query" required: true type: "string" x-exportParamName: "RequiredStringField1" - name: "requiredStringField2" in: "query" required: true type: "string" x-exportParamName: "RequiredStringField2" - name: "required_field_behavior_json_name_custom" in: "query" description: "Test openapiv2 handling of required json_name fields" required: true type: "string" x-exportParamName: "RequiredFieldBehaviorJsonNameCustom" - name: "required_field_schema_json_name_custom" in: "query" required: true type: "string" x-exportParamName: "RequiredFieldSchemaJsonNameCustom" - name: "trailingOnly" in: "query" description: "Trailing only" required: false type: "string" x-exportParamName: "TrailingOnly" x-optionalDataType: "String" - name: "trailingOnlyDot" in: "query" description: "Trailing only dot." required: false type: "string" x-exportParamName: "TrailingOnlyDot" x-optionalDataType: "String" - name: "trailingBoth" in: "query" description: "Leading both\n\nTrailing both." required: false type: "string" x-exportParamName: "TrailingBoth" x-optionalDataType: "String" - name: "trailingMultiline" in: "query" description: "Leading multiline\n\nThis is an example of a multi-line comment.\n\ \nTrailing multiline." required: false type: "string" x-exportParamName: "TrailingMultiline" x-optionalDataType: "String" - name: "uuids" in: "query" description: "Specify a custom format of repeated field items" required: false type: "array" items: type: "string" format: "uuid" collectionFormat: "multi" x-exportParamName: "Uuids" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbABitOfEverything" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/a_bit_of_everything/params/post/{stringValue}: post: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_CheckPostQueryParams" parameters: - name: "stringValue" in: "path" required: true type: "string" x-exportParamName: "StringValue" - in: "body" name: "singleNested" required: true schema: $ref: "#/definitions/ABitOfEverythingNested" x-exportParamName: "SingleNested" - name: "uuid" in: "query" required: true type: "string" pattern: "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}" format: "uuid" x-internal: true x-exportParamName: "Uuid" - name: "floatValue" in: "query" description: "Float value field" required: true type: "number" default: 0.2 format: "float" x-exportParamName: "FloatValue" - name: "doubleValue" in: "query" required: true type: "number" format: "double" x-exportParamName: "DoubleValue" - name: "int64Value" in: "query" required: true type: "string" format: "int64" x-exportParamName: "Int64Value" - name: "uint64Value" in: "query" required: false type: "string" format: "uint64" x-exportParamName: "Uint64Value" x-optionalDataType: "String" - name: "int32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Int32Value" x-optionalDataType: "Int32" - name: "fixed64Value" in: "query" required: false type: "string" format: "uint64" x-exportParamName: "Fixed64Value" x-optionalDataType: "String" - name: "fixed32Value" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Fixed32Value" x-optionalDataType: "Int64" - name: "boolValue" in: "query" required: false type: "boolean" x-exportParamName: "BoolValue" x-optionalDataType: "Bool" - name: "bytesValue" in: "query" required: false type: "string" format: "byte" x-exportParamName: "BytesValue" x-optionalDataType: "String" - name: "uint32Value" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Uint32Value" x-optionalDataType: "Int64" - name: "enumValue" in: "query" description: " - ZERO: ZERO means 0\n - ONE: ONE means 1" required: false type: "string" default: "ZERO" enum: - "ZERO" - "ONE" x-exportParamName: "EnumValue" x-optionalDataType: "String" - name: "pathEnumValue" in: "query" required: false type: "string" default: "ABC" enum: - "ABC" - "DEF" x-exportParamName: "PathEnumValue" x-optionalDataType: "String" - name: "nestedPathEnumValue" in: "query" required: false type: "string" default: "GHI" enum: - "GHI" - "JKL" x-exportParamName: "NestedPathEnumValue" x-optionalDataType: "String" - name: "sfixed32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Sfixed32Value" x-optionalDataType: "Int32" - name: "sfixed64Value" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Sfixed64Value" x-optionalDataType: "String" - name: "sint32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Sint32Value" x-optionalDataType: "Int32" - name: "sint64Value" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Sint64Value" x-optionalDataType: "String" - name: "repeatedStringValue" in: "query" required: false type: "array" items: type: "string" collectionFormat: "multi" x-exportParamName: "RepeatedStringValue" - name: "oneofEmpty" in: "query" required: false type: "object" x-exportParamName: "OneofEmpty" - name: "oneofString" in: "query" required: false type: "string" x-exportParamName: "OneofString" x-optionalDataType: "String" - name: "mapValue" in: "query" description: "map of numeric enum" required: false x-exportParamName: "MapValue" - name: "mappedStringValue" in: "query" description: "Map of string title\n\nMap of string description." required: false type: "string" x-exportParamName: "MappedStringValue" x-optionalDataType: "String" - name: "mappedNestedValue" in: "query" required: false x-exportParamName: "MappedNestedValue" - name: "nonConventionalNameValue" in: "query" required: false type: "string" x-exportParamName: "NonConventionalNameValue" x-optionalDataType: "String" - name: "timestampValue" in: "query" required: false type: "string" format: "date-time" x-exportParamName: "TimestampValue" x-optionalDataType: "Time" - name: "repeatedEnumValue" in: "query" description: "repeated enum value. it is comma-separated in query\n\n - ZERO:\ \ ZERO means 0\n - ONE: ONE means 1" required: false type: "array" items: type: "string" enum: - "ZERO" - "ONE" collectionFormat: "multi" x-exportParamName: "RepeatedEnumValue" - name: "repeatedEnumAnnotation" in: "query" description: "Repeated numeric enum title\n\nRepeated numeric enum description.\n\ \n - ZERO: ZERO means 0\n - ONE: ONE means 1" required: false type: "array" items: type: "string" enum: - "ZERO" - "ONE" collectionFormat: "multi" x-exportParamName: "RepeatedEnumAnnotation" - name: "enumValueAnnotation" in: "query" description: "Numeric enum title\n\nNumeric enum description.\n\n - ZERO:\ \ ZERO means 0\n - ONE: ONE means 1" required: false type: "string" default: "ZERO" enum: - "ZERO" - "ONE" x-exportParamName: "EnumValueAnnotation" x-optionalDataType: "String" - name: "repeatedStringAnnotation" in: "query" description: "Repeated string title\n\nRepeated string description." required: false type: "array" items: type: "string" collectionFormat: "multi" x-exportParamName: "RepeatedStringAnnotation" - name: "nestedAnnotation.name" in: "query" description: "name is nested field." required: false type: "string" x-exportParamName: "NestedAnnotationName" x-optionalDataType: "String" - name: "nestedAnnotation.amount" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "NestedAnnotationAmount" x-optionalDataType: "Int64" - name: "nestedAnnotation.ok" in: "query" description: "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE:\ \ TRUE is true." required: false type: "string" default: "FALSE" enum: - "FALSE" - "TRUE" x-exportParamName: "NestedAnnotationOk" x-optionalDataType: "String" - name: "int64OverrideType" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Int64OverrideType" x-optionalDataType: "Int64" - name: "requiredStringViaFieldBehaviorAnnotation" in: "query" description: "mark a field as required in Open API definition" required: true type: "string" x-exportParamName: "RequiredStringViaFieldBehaviorAnnotation" - name: "outputOnlyStringViaFieldBehaviorAnnotation" in: "query" description: "mark a field as readonly in Open API definition" required: false type: "string" x-exportParamName: "OutputOnlyStringViaFieldBehaviorAnnotation" x-optionalDataType: "String" - name: "optionalStringValue" in: "query" required: false type: "string" x-exportParamName: "OptionalStringValue" x-optionalDataType: "String" - name: "productId" in: "query" description: "Test openapiv2 generation of repeated fields\n\nOnly digits\ \ are allowed." required: false type: "array" items: type: "string" minLength: 1 maxLength: 19 pattern: "^[0-9]+$" collectionFormat: "multi" x-exportParamName: "ProductId" - name: "optionalStringField" in: "query" description: "Test openapiv2 generation of required fields with annotation\ \ and jsonschema to reproduce" required: false type: "string" x-exportParamName: "OptionalStringField" x-optionalDataType: "String" - name: "requiredStringField1" in: "query" required: true type: "string" x-exportParamName: "RequiredStringField1" - name: "requiredStringField2" in: "query" required: true type: "string" x-exportParamName: "RequiredStringField2" - name: "required_field_behavior_json_name_custom" in: "query" description: "Test openapiv2 handling of required json_name fields" required: true type: "string" x-exportParamName: "RequiredFieldBehaviorJsonNameCustom" - name: "required_field_schema_json_name_custom" in: "query" required: true type: "string" x-exportParamName: "RequiredFieldSchemaJsonNameCustom" - name: "trailingOnly" in: "query" description: "Trailing only" required: false type: "string" x-exportParamName: "TrailingOnly" x-optionalDataType: "String" - name: "trailingOnlyDot" in: "query" description: "Trailing only dot." required: false type: "string" x-exportParamName: "TrailingOnlyDot" x-optionalDataType: "String" - name: "trailingBoth" in: "query" description: "Leading both\n\nTrailing both." required: false type: "string" x-exportParamName: "TrailingBoth" x-optionalDataType: "String" - name: "trailingMultiline" in: "query" description: "Leading multiline\n\nThis is an example of a multi-line comment.\n\ \nTrailing multiline." required: false type: "string" x-exportParamName: "TrailingMultiline" x-optionalDataType: "String" - name: "uuids" in: "query" description: "Specify a custom format of repeated field items" required: false type: "array" items: type: "string" format: "uuid" collectionFormat: "multi" x-exportParamName: "Uuids" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbABitOfEverything" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/a_bit_of_everything/query/{uuidName}: get: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_GetQuery" parameters: - name: "uuidName" in: "path" required: true type: "string" format: "uuid" x-internal: true x-exportParamName: "UuidName" - name: "singleNested.name" in: "query" description: "name is nested field." required: false type: "string" x-exportParamName: "SingleNestedName" x-optionalDataType: "String" - name: "singleNested.amount" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "SingleNestedAmount" x-optionalDataType: "Int64" - name: "singleNested.ok" in: "query" description: "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE:\ \ TRUE is true." required: false type: "string" default: "FALSE" enum: - "FALSE" - "TRUE" x-exportParamName: "SingleNestedOk" x-optionalDataType: "String" - name: "floatValue" in: "query" description: "Float value field" required: true type: "number" default: 0.2 format: "float" x-exportParamName: "FloatValue" - name: "doubleValue" in: "query" required: true type: "number" format: "double" x-exportParamName: "DoubleValue" - name: "int64Value" in: "query" required: true type: "string" format: "int64" x-exportParamName: "Int64Value" - name: "uint64Value" in: "query" required: false type: "string" format: "uint64" x-exportParamName: "Uint64Value" x-optionalDataType: "String" - name: "int32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Int32Value" x-optionalDataType: "Int32" - name: "fixed64Value" in: "query" required: false type: "string" format: "uint64" x-exportParamName: "Fixed64Value" x-optionalDataType: "String" - name: "fixed32Value" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Fixed32Value" x-optionalDataType: "Int64" - name: "boolValue" in: "query" required: false type: "boolean" x-exportParamName: "BoolValue" x-optionalDataType: "Bool" - name: "stringValue" in: "query" required: false type: "string" x-exportParamName: "StringValue" x-optionalDataType: "String" - name: "bytesValue" in: "query" required: false type: "string" format: "byte" x-exportParamName: "BytesValue" x-optionalDataType: "String" - name: "uint32Value" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Uint32Value" x-optionalDataType: "Int64" - name: "enumValue" in: "query" description: " - ZERO: ZERO means 0\n - ONE: ONE means 1" required: false type: "string" default: "ZERO" enum: - "ZERO" - "ONE" x-exportParamName: "EnumValue" x-optionalDataType: "String" - name: "pathEnumValue" in: "query" required: false type: "string" default: "ABC" enum: - "ABC" - "DEF" x-exportParamName: "PathEnumValue" x-optionalDataType: "String" - name: "nestedPathEnumValue" in: "query" required: false type: "string" default: "GHI" enum: - "GHI" - "JKL" x-exportParamName: "NestedPathEnumValue" x-optionalDataType: "String" - name: "sfixed32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Sfixed32Value" x-optionalDataType: "Int32" - name: "sfixed64Value" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Sfixed64Value" x-optionalDataType: "String" - name: "sint32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Sint32Value" x-optionalDataType: "Int32" - name: "sint64Value" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Sint64Value" x-optionalDataType: "String" - name: "repeatedStringValue" in: "query" required: false type: "array" items: type: "string" collectionFormat: "multi" x-exportParamName: "RepeatedStringValue" - name: "oneofEmpty" in: "query" required: false type: "object" x-exportParamName: "OneofEmpty" - name: "oneofString" in: "query" required: false type: "string" x-exportParamName: "OneofString" x-optionalDataType: "String" - name: "mapValue" in: "query" description: "map of numeric enum" required: false x-exportParamName: "MapValue" - name: "mappedStringValue" in: "query" description: "Map of string title\n\nMap of string description." required: false type: "string" x-exportParamName: "MappedStringValue" x-optionalDataType: "String" - name: "mappedNestedValue" in: "query" required: false x-exportParamName: "MappedNestedValue" - name: "nonConventionalNameValue" in: "query" required: false type: "string" x-exportParamName: "NonConventionalNameValue" x-optionalDataType: "String" - name: "timestampValue" in: "query" required: false type: "string" format: "date-time" x-exportParamName: "TimestampValue" x-optionalDataType: "Time" - name: "repeatedEnumValue" in: "query" description: "repeated enum value. it is comma-separated in query\n\n - ZERO:\ \ ZERO means 0\n - ONE: ONE means 1" required: false type: "array" items: type: "string" enum: - "ZERO" - "ONE" collectionFormat: "multi" x-exportParamName: "RepeatedEnumValue" - name: "repeatedEnumAnnotation" in: "query" description: "Repeated numeric enum title\n\nRepeated numeric enum description.\n\ \n - ZERO: ZERO means 0\n - ONE: ONE means 1" required: false type: "array" items: type: "string" enum: - "ZERO" - "ONE" collectionFormat: "multi" x-exportParamName: "RepeatedEnumAnnotation" - name: "enumValueAnnotation" in: "query" description: "Numeric enum title\n\nNumeric enum description.\n\n - ZERO:\ \ ZERO means 0\n - ONE: ONE means 1" required: false type: "string" default: "ZERO" enum: - "ZERO" - "ONE" x-exportParamName: "EnumValueAnnotation" x-optionalDataType: "String" - name: "repeatedStringAnnotation" in: "query" description: "Repeated string title\n\nRepeated string description." required: false type: "array" items: type: "string" collectionFormat: "multi" x-exportParamName: "RepeatedStringAnnotation" - name: "nestedAnnotation.name" in: "query" description: "name is nested field." required: false type: "string" x-exportParamName: "NestedAnnotationName" x-optionalDataType: "String" - name: "nestedAnnotation.amount" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "NestedAnnotationAmount" x-optionalDataType: "Int64" - name: "nestedAnnotation.ok" in: "query" description: "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE:\ \ TRUE is true." required: false type: "string" default: "FALSE" enum: - "FALSE" - "TRUE" x-exportParamName: "NestedAnnotationOk" x-optionalDataType: "String" - name: "int64OverrideType" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Int64OverrideType" x-optionalDataType: "Int64" - name: "requiredStringViaFieldBehaviorAnnotation" in: "query" description: "mark a field as required in Open API definition" required: true type: "string" x-exportParamName: "RequiredStringViaFieldBehaviorAnnotation" - name: "outputOnlyStringViaFieldBehaviorAnnotation" in: "query" description: "mark a field as readonly in Open API definition" required: false type: "string" x-exportParamName: "OutputOnlyStringViaFieldBehaviorAnnotation" x-optionalDataType: "String" - name: "optionalStringValue" in: "query" required: false type: "string" x-exportParamName: "OptionalStringValue" x-optionalDataType: "String" - name: "productId" in: "query" description: "Test openapiv2 generation of repeated fields\n\nOnly digits\ \ are allowed." required: false type: "array" items: type: "string" minLength: 1 maxLength: 19 pattern: "^[0-9]+$" collectionFormat: "multi" x-exportParamName: "ProductId" - name: "optionalStringField" in: "query" description: "Test openapiv2 generation of required fields with annotation\ \ and jsonschema to reproduce" required: false type: "string" x-exportParamName: "OptionalStringField" x-optionalDataType: "String" - name: "requiredStringField1" in: "query" required: true type: "string" x-exportParamName: "RequiredStringField1" - name: "requiredStringField2" in: "query" required: true type: "string" x-exportParamName: "RequiredStringField2" - name: "required_field_behavior_json_name_custom" in: "query" description: "Test openapiv2 handling of required json_name fields" required: true type: "string" x-exportParamName: "RequiredFieldBehaviorJsonNameCustom" - name: "required_field_schema_json_name_custom" in: "query" required: true type: "string" x-exportParamName: "RequiredFieldSchemaJsonNameCustom" - name: "trailingOnly" in: "query" description: "Trailing only" required: false type: "string" x-exportParamName: "TrailingOnly" x-optionalDataType: "String" - name: "trailingOnlyDot" in: "query" description: "Trailing only dot." required: false type: "string" x-exportParamName: "TrailingOnlyDot" x-optionalDataType: "String" - name: "trailingBoth" in: "query" description: "Leading both\n\nTrailing both." required: false type: "string" x-exportParamName: "TrailingBoth" x-optionalDataType: "String" - name: "trailingMultiline" in: "query" description: "Leading multiline\n\nThis is an example of a multi-line comment.\n\ \nTrailing multiline." required: false type: "string" x-exportParamName: "TrailingMultiline" x-optionalDataType: "String" - name: "uuids" in: "query" description: "Specify a custom format of repeated field items" required: false type: "array" items: type: "string" format: "uuid" collectionFormat: "multi" x-exportParamName: "Uuids" responses: 200: description: "A successful response." schema: type: "object" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" security: [] externalDocs: description: "Find out more about GetQuery" url: "https://github.com/grpc-ecosystem/grpc-gateway" deprecated: true ? /v1/example/a_bit_of_everything/{floatValue}/{doubleValue}/{int64Value}/separator/{uint64Value}/{int32Value}/{fixed64Value}/{fixed32Value}/{boolValue}/{stringValue}/{uint32Value}/{sfixed32Value}/{sfixed64Value}/{sint32Value}/{sint64Value}/{nonConventionalNameValue}/{enumValue}/{pathEnumValue}/{nestedPathEnumValue}/{enumValueAnnotation} : post: tags: - "ABitOfEverything" summary: "Create a new ABitOfEverything" description: "This API creates a new ABitOfEverything" operationId: "ABitOfEverythingService_Create" parameters: - name: "floatValue" in: "path" description: "Float value field" required: true type: "number" default: 0.2 format: "float" x-exportParamName: "FloatValue" - name: "doubleValue" in: "path" required: true type: "number" format: "double" x-exportParamName: "DoubleValue" - name: "int64Value" in: "path" required: true type: "string" format: "int64" x-exportParamName: "Int64Value" - name: "uint64Value" in: "path" required: true type: "string" format: "uint64" x-exportParamName: "Uint64Value" - name: "int32Value" in: "path" required: true type: "integer" format: "int32" x-exportParamName: "Int32Value" - name: "fixed64Value" in: "path" required: true type: "string" format: "uint64" x-exportParamName: "Fixed64Value" - name: "fixed32Value" in: "path" required: true type: "integer" format: "int64" x-exportParamName: "Fixed32Value" - name: "boolValue" in: "path" required: true type: "boolean" x-exportParamName: "BoolValue" - name: "stringValue" in: "path" required: true type: "string" pattern: "strprefix/[^/]+" x-exportParamName: "StringValue" - name: "uint32Value" in: "path" required: true type: "integer" format: "int64" x-exportParamName: "Uint32Value" - name: "sfixed32Value" in: "path" required: true type: "integer" format: "int32" x-exportParamName: "Sfixed32Value" - name: "sfixed64Value" in: "path" required: true type: "string" format: "int64" x-exportParamName: "Sfixed64Value" - name: "sint32Value" in: "path" required: true type: "integer" format: "int32" x-exportParamName: "Sint32Value" - name: "sint64Value" in: "path" required: true type: "string" format: "int64" x-exportParamName: "Sint64Value" - name: "nonConventionalNameValue" in: "path" required: true type: "string" x-exportParamName: "NonConventionalNameValue" - name: "enumValue" in: "path" required: true type: "string" enum: - "ZERO" - "ONE" x-exportParamName: "EnumValue" - name: "pathEnumValue" in: "path" required: true type: "string" enum: - "ABC" - "DEF" x-exportParamName: "PathEnumValue" - name: "nestedPathEnumValue" in: "path" required: true type: "string" enum: - "GHI" - "JKL" x-exportParamName: "NestedPathEnumValue" - name: "enumValueAnnotation" in: "path" description: "Numeric enum description." required: true type: "string" enum: - "ZERO" - "ONE" x-exportParamName: "EnumValueAnnotation" - name: "singleNested.name" in: "query" description: "name is nested field." required: false type: "string" x-exportParamName: "SingleNestedName" x-optionalDataType: "String" - name: "singleNested.amount" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "SingleNestedAmount" x-optionalDataType: "Int64" - name: "singleNested.ok" in: "query" description: "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE:\ \ TRUE is true." required: false type: "string" default: "FALSE" enum: - "FALSE" - "TRUE" x-exportParamName: "SingleNestedOk" x-optionalDataType: "String" - name: "uuid" in: "query" required: true type: "string" pattern: "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}" format: "uuid" x-internal: true x-exportParamName: "Uuid" - name: "bytesValue" in: "query" required: false type: "string" format: "byte" x-exportParamName: "BytesValue" x-optionalDataType: "String" - name: "repeatedStringValue" in: "query" required: false type: "array" items: type: "string" collectionFormat: "multi" x-exportParamName: "RepeatedStringValue" - name: "oneofEmpty" in: "query" required: false type: "object" x-exportParamName: "OneofEmpty" - name: "oneofString" in: "query" required: false type: "string" x-exportParamName: "OneofString" x-optionalDataType: "String" - name: "mapValue" in: "query" description: "map of numeric enum" required: false x-exportParamName: "MapValue" - name: "mappedStringValue" in: "query" description: "Map of string title\n\nMap of string description." required: false type: "string" x-exportParamName: "MappedStringValue" x-optionalDataType: "String" - name: "mappedNestedValue" in: "query" required: false x-exportParamName: "MappedNestedValue" - name: "timestampValue" in: "query" required: false type: "string" format: "date-time" x-exportParamName: "TimestampValue" x-optionalDataType: "Time" - name: "repeatedEnumValue" in: "query" description: "repeated enum value. it is comma-separated in query\n\n - ZERO:\ \ ZERO means 0\n - ONE: ONE means 1" required: false type: "array" items: type: "string" enum: - "ZERO" - "ONE" collectionFormat: "multi" x-exportParamName: "RepeatedEnumValue" - name: "repeatedEnumAnnotation" in: "query" description: "Repeated numeric enum title\n\nRepeated numeric enum description.\n\ \n - ZERO: ZERO means 0\n - ONE: ONE means 1" required: false type: "array" items: type: "string" enum: - "ZERO" - "ONE" collectionFormat: "multi" x-exportParamName: "RepeatedEnumAnnotation" - name: "repeatedStringAnnotation" in: "query" description: "Repeated string title\n\nRepeated string description." required: false type: "array" items: type: "string" collectionFormat: "multi" x-exportParamName: "RepeatedStringAnnotation" - name: "nestedAnnotation.name" in: "query" description: "name is nested field." required: false type: "string" x-exportParamName: "NestedAnnotationName" x-optionalDataType: "String" - name: "nestedAnnotation.amount" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "NestedAnnotationAmount" x-optionalDataType: "Int64" - name: "nestedAnnotation.ok" in: "query" description: "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE:\ \ TRUE is true." required: false type: "string" default: "FALSE" enum: - "FALSE" - "TRUE" x-exportParamName: "NestedAnnotationOk" x-optionalDataType: "String" - name: "int64OverrideType" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Int64OverrideType" x-optionalDataType: "Int64" - name: "requiredStringViaFieldBehaviorAnnotation" in: "query" description: "mark a field as required in Open API definition" required: true type: "string" x-exportParamName: "RequiredStringViaFieldBehaviorAnnotation" - name: "outputOnlyStringViaFieldBehaviorAnnotation" in: "query" description: "mark a field as readonly in Open API definition" required: false type: "string" x-exportParamName: "OutputOnlyStringViaFieldBehaviorAnnotation" x-optionalDataType: "String" - name: "optionalStringValue" in: "query" required: false type: "string" x-exportParamName: "OptionalStringValue" x-optionalDataType: "String" - name: "productId" in: "query" description: "Test openapiv2 generation of repeated fields\n\nOnly digits\ \ are allowed." required: false type: "array" items: type: "string" minLength: 1 maxLength: 19 pattern: "^[0-9]+$" collectionFormat: "multi" x-exportParamName: "ProductId" - name: "optionalStringField" in: "query" description: "Test openapiv2 generation of required fields with annotation\ \ and jsonschema to reproduce" required: false type: "string" x-exportParamName: "OptionalStringField" x-optionalDataType: "String" - name: "requiredStringField1" in: "query" required: true type: "string" x-exportParamName: "RequiredStringField1" - name: "requiredStringField2" in: "query" required: true type: "string" x-exportParamName: "RequiredStringField2" - name: "required_field_behavior_json_name_custom" in: "query" description: "Test openapiv2 handling of required json_name fields" required: true type: "string" x-exportParamName: "RequiredFieldBehaviorJsonNameCustom" - name: "required_field_schema_json_name_custom" in: "query" required: true type: "string" x-exportParamName: "RequiredFieldSchemaJsonNameCustom" - name: "trailingOnly" in: "query" description: "Trailing only" required: false type: "string" x-exportParamName: "TrailingOnly" x-optionalDataType: "String" - name: "trailingOnlyDot" in: "query" description: "Trailing only dot." required: false type: "string" x-exportParamName: "TrailingOnlyDot" x-optionalDataType: "String" - name: "trailingBoth" in: "query" description: "Leading both\n\nTrailing both." required: false type: "string" x-exportParamName: "TrailingBoth" x-optionalDataType: "String" - name: "trailingMultiline" in: "query" description: "Leading multiline\n\nThis is an example of a multi-line comment.\n\ \nTrailing multiline." required: false type: "string" x-exportParamName: "TrailingMultiline" x-optionalDataType: "String" - name: "uuids" in: "query" description: "Specify a custom format of repeated field items" required: false type: "array" items: type: "string" format: "uuid" collectionFormat: "multi" x-exportParamName: "Uuids" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbABitOfEverything" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/a_bit_of_everything/{uuidName}: head: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_Exists" parameters: - name: "uuidName" in: "path" required: true type: "string" format: "uuid" x-internal: true x-exportParamName: "UuidName" - name: "singleNested.name" in: "query" description: "name is nested field." required: false type: "string" x-exportParamName: "SingleNestedName" x-optionalDataType: "String" - name: "singleNested.amount" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "SingleNestedAmount" x-optionalDataType: "Int64" - name: "singleNested.ok" in: "query" description: "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE:\ \ TRUE is true." required: false type: "string" default: "FALSE" enum: - "FALSE" - "TRUE" x-exportParamName: "SingleNestedOk" x-optionalDataType: "String" - name: "floatValue" in: "query" description: "Float value field" required: true type: "number" default: 0.2 format: "float" x-exportParamName: "FloatValue" - name: "doubleValue" in: "query" required: true type: "number" format: "double" x-exportParamName: "DoubleValue" - name: "int64Value" in: "query" required: true type: "string" format: "int64" x-exportParamName: "Int64Value" - name: "uint64Value" in: "query" required: false type: "string" format: "uint64" x-exportParamName: "Uint64Value" x-optionalDataType: "String" - name: "int32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Int32Value" x-optionalDataType: "Int32" - name: "fixed64Value" in: "query" required: false type: "string" format: "uint64" x-exportParamName: "Fixed64Value" x-optionalDataType: "String" - name: "fixed32Value" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Fixed32Value" x-optionalDataType: "Int64" - name: "boolValue" in: "query" required: false type: "boolean" x-exportParamName: "BoolValue" x-optionalDataType: "Bool" - name: "stringValue" in: "query" required: false type: "string" x-exportParamName: "StringValue" x-optionalDataType: "String" - name: "bytesValue" in: "query" required: false type: "string" format: "byte" x-exportParamName: "BytesValue" x-optionalDataType: "String" - name: "uint32Value" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Uint32Value" x-optionalDataType: "Int64" - name: "enumValue" in: "query" description: " - ZERO: ZERO means 0\n - ONE: ONE means 1" required: false type: "string" default: "ZERO" enum: - "ZERO" - "ONE" x-exportParamName: "EnumValue" x-optionalDataType: "String" - name: "pathEnumValue" in: "query" required: false type: "string" default: "ABC" enum: - "ABC" - "DEF" x-exportParamName: "PathEnumValue" x-optionalDataType: "String" - name: "nestedPathEnumValue" in: "query" required: false type: "string" default: "GHI" enum: - "GHI" - "JKL" x-exportParamName: "NestedPathEnumValue" x-optionalDataType: "String" - name: "sfixed32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Sfixed32Value" x-optionalDataType: "Int32" - name: "sfixed64Value" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Sfixed64Value" x-optionalDataType: "String" - name: "sint32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Sint32Value" x-optionalDataType: "Int32" - name: "sint64Value" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Sint64Value" x-optionalDataType: "String" - name: "repeatedStringValue" in: "query" required: false type: "array" items: type: "string" collectionFormat: "multi" x-exportParamName: "RepeatedStringValue" - name: "oneofEmpty" in: "query" required: false type: "object" x-exportParamName: "OneofEmpty" - name: "oneofString" in: "query" required: false type: "string" x-exportParamName: "OneofString" x-optionalDataType: "String" - name: "mapValue" in: "query" description: "map of numeric enum" required: false x-exportParamName: "MapValue" - name: "mappedStringValue" in: "query" description: "Map of string title\n\nMap of string description." required: false type: "string" x-exportParamName: "MappedStringValue" x-optionalDataType: "String" - name: "mappedNestedValue" in: "query" required: false x-exportParamName: "MappedNestedValue" - name: "nonConventionalNameValue" in: "query" required: false type: "string" x-exportParamName: "NonConventionalNameValue" x-optionalDataType: "String" - name: "timestampValue" in: "query" required: false type: "string" format: "date-time" x-exportParamName: "TimestampValue" x-optionalDataType: "Time" - name: "repeatedEnumValue" in: "query" description: "repeated enum value. it is comma-separated in query\n\n - ZERO:\ \ ZERO means 0\n - ONE: ONE means 1" required: false type: "array" items: type: "string" enum: - "ZERO" - "ONE" collectionFormat: "multi" x-exportParamName: "RepeatedEnumValue" - name: "repeatedEnumAnnotation" in: "query" description: "Repeated numeric enum title\n\nRepeated numeric enum description.\n\ \n - ZERO: ZERO means 0\n - ONE: ONE means 1" required: false type: "array" items: type: "string" enum: - "ZERO" - "ONE" collectionFormat: "multi" x-exportParamName: "RepeatedEnumAnnotation" - name: "enumValueAnnotation" in: "query" description: "Numeric enum title\n\nNumeric enum description.\n\n - ZERO:\ \ ZERO means 0\n - ONE: ONE means 1" required: false type: "string" default: "ZERO" enum: - "ZERO" - "ONE" x-exportParamName: "EnumValueAnnotation" x-optionalDataType: "String" - name: "repeatedStringAnnotation" in: "query" description: "Repeated string title\n\nRepeated string description." required: false type: "array" items: type: "string" collectionFormat: "multi" x-exportParamName: "RepeatedStringAnnotation" - name: "nestedAnnotation.name" in: "query" description: "name is nested field." required: false type: "string" x-exportParamName: "NestedAnnotationName" x-optionalDataType: "String" - name: "nestedAnnotation.amount" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "NestedAnnotationAmount" x-optionalDataType: "Int64" - name: "nestedAnnotation.ok" in: "query" description: "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE:\ \ TRUE is true." required: false type: "string" default: "FALSE" enum: - "FALSE" - "TRUE" x-exportParamName: "NestedAnnotationOk" x-optionalDataType: "String" - name: "int64OverrideType" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Int64OverrideType" x-optionalDataType: "Int64" - name: "requiredStringViaFieldBehaviorAnnotation" in: "query" description: "mark a field as required in Open API definition" required: true type: "string" x-exportParamName: "RequiredStringViaFieldBehaviorAnnotation" - name: "outputOnlyStringViaFieldBehaviorAnnotation" in: "query" description: "mark a field as readonly in Open API definition" required: false type: "string" x-exportParamName: "OutputOnlyStringViaFieldBehaviorAnnotation" x-optionalDataType: "String" - name: "optionalStringValue" in: "query" required: false type: "string" x-exportParamName: "OptionalStringValue" x-optionalDataType: "String" - name: "productId" in: "query" description: "Test openapiv2 generation of repeated fields\n\nOnly digits\ \ are allowed." required: false type: "array" items: type: "string" minLength: 1 maxLength: 19 pattern: "^[0-9]+$" collectionFormat: "multi" x-exportParamName: "ProductId" - name: "optionalStringField" in: "query" description: "Test openapiv2 generation of required fields with annotation\ \ and jsonschema to reproduce" required: false type: "string" x-exportParamName: "OptionalStringField" x-optionalDataType: "String" - name: "requiredStringField1" in: "query" required: true type: "string" x-exportParamName: "RequiredStringField1" - name: "requiredStringField2" in: "query" required: true type: "string" x-exportParamName: "RequiredStringField2" - name: "required_field_behavior_json_name_custom" in: "query" description: "Test openapiv2 handling of required json_name fields" required: true type: "string" x-exportParamName: "RequiredFieldBehaviorJsonNameCustom" - name: "required_field_schema_json_name_custom" in: "query" required: true type: "string" x-exportParamName: "RequiredFieldSchemaJsonNameCustom" - name: "trailingOnly" in: "query" description: "Trailing only" required: false type: "string" x-exportParamName: "TrailingOnly" x-optionalDataType: "String" - name: "trailingOnlyDot" in: "query" description: "Trailing only dot." required: false type: "string" x-exportParamName: "TrailingOnlyDot" x-optionalDataType: "String" - name: "trailingBoth" in: "query" description: "Leading both\n\nTrailing both." required: false type: "string" x-exportParamName: "TrailingBoth" x-optionalDataType: "String" - name: "trailingMultiline" in: "query" description: "Leading multiline\n\nThis is an example of a multi-line comment.\n\ \nTrailing multiline." required: false type: "string" x-exportParamName: "TrailingMultiline" x-optionalDataType: "String" - name: "uuids" in: "query" description: "Specify a custom format of repeated field items" required: false type: "array" items: type: "string" format: "uuid" collectionFormat: "multi" x-exportParamName: "Uuids" responses: 200: description: "A successful response." schema: type: "object" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" put: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_Update" parameters: - name: "uuidName" in: "path" required: true type: "string" format: "uuid" x-internal: true x-exportParamName: "UuidName" - in: "body" name: "body" required: true schema: $ref: "#/definitions/examplepbABitOfEverythingServiceUpdateBody" x-exportParamName: "Body" responses: 200: description: "A successful response." schema: type: "object" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" options: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_CustomOptionsRequest" parameters: - name: "uuidName" in: "path" required: true type: "string" format: "uuid" x-internal: true x-exportParamName: "UuidName" - name: "singleNested.name" in: "query" description: "name is nested field." required: false type: "string" x-exportParamName: "SingleNestedName" x-optionalDataType: "String" - name: "singleNested.amount" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "SingleNestedAmount" x-optionalDataType: "Int64" - name: "singleNested.ok" in: "query" description: "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE:\ \ TRUE is true." required: false type: "string" default: "FALSE" enum: - "FALSE" - "TRUE" x-exportParamName: "SingleNestedOk" x-optionalDataType: "String" - name: "floatValue" in: "query" description: "Float value field" required: true type: "number" default: 0.2 format: "float" x-exportParamName: "FloatValue" - name: "doubleValue" in: "query" required: true type: "number" format: "double" x-exportParamName: "DoubleValue" - name: "int64Value" in: "query" required: true type: "string" format: "int64" x-exportParamName: "Int64Value" - name: "uint64Value" in: "query" required: false type: "string" format: "uint64" x-exportParamName: "Uint64Value" x-optionalDataType: "String" - name: "int32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Int32Value" x-optionalDataType: "Int32" - name: "fixed64Value" in: "query" required: false type: "string" format: "uint64" x-exportParamName: "Fixed64Value" x-optionalDataType: "String" - name: "fixed32Value" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Fixed32Value" x-optionalDataType: "Int64" - name: "boolValue" in: "query" required: false type: "boolean" x-exportParamName: "BoolValue" x-optionalDataType: "Bool" - name: "stringValue" in: "query" required: false type: "string" x-exportParamName: "StringValue" x-optionalDataType: "String" - name: "bytesValue" in: "query" required: false type: "string" format: "byte" x-exportParamName: "BytesValue" x-optionalDataType: "String" - name: "uint32Value" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Uint32Value" x-optionalDataType: "Int64" - name: "enumValue" in: "query" description: " - ZERO: ZERO means 0\n - ONE: ONE means 1" required: false type: "string" default: "ZERO" enum: - "ZERO" - "ONE" x-exportParamName: "EnumValue" x-optionalDataType: "String" - name: "pathEnumValue" in: "query" required: false type: "string" default: "ABC" enum: - "ABC" - "DEF" x-exportParamName: "PathEnumValue" x-optionalDataType: "String" - name: "nestedPathEnumValue" in: "query" required: false type: "string" default: "GHI" enum: - "GHI" - "JKL" x-exportParamName: "NestedPathEnumValue" x-optionalDataType: "String" - name: "sfixed32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Sfixed32Value" x-optionalDataType: "Int32" - name: "sfixed64Value" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Sfixed64Value" x-optionalDataType: "String" - name: "sint32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Sint32Value" x-optionalDataType: "Int32" - name: "sint64Value" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Sint64Value" x-optionalDataType: "String" - name: "repeatedStringValue" in: "query" required: false type: "array" items: type: "string" collectionFormat: "multi" x-exportParamName: "RepeatedStringValue" - name: "oneofEmpty" in: "query" required: false type: "object" x-exportParamName: "OneofEmpty" - name: "oneofString" in: "query" required: false type: "string" x-exportParamName: "OneofString" x-optionalDataType: "String" - name: "mapValue" in: "query" description: "map of numeric enum" required: false x-exportParamName: "MapValue" - name: "mappedStringValue" in: "query" description: "Map of string title\n\nMap of string description." required: false type: "string" x-exportParamName: "MappedStringValue" x-optionalDataType: "String" - name: "mappedNestedValue" in: "query" required: false x-exportParamName: "MappedNestedValue" - name: "nonConventionalNameValue" in: "query" required: false type: "string" x-exportParamName: "NonConventionalNameValue" x-optionalDataType: "String" - name: "timestampValue" in: "query" required: false type: "string" format: "date-time" x-exportParamName: "TimestampValue" x-optionalDataType: "Time" - name: "repeatedEnumValue" in: "query" description: "repeated enum value. it is comma-separated in query\n\n - ZERO:\ \ ZERO means 0\n - ONE: ONE means 1" required: false type: "array" items: type: "string" enum: - "ZERO" - "ONE" collectionFormat: "multi" x-exportParamName: "RepeatedEnumValue" - name: "repeatedEnumAnnotation" in: "query" description: "Repeated numeric enum title\n\nRepeated numeric enum description.\n\ \n - ZERO: ZERO means 0\n - ONE: ONE means 1" required: false type: "array" items: type: "string" enum: - "ZERO" - "ONE" collectionFormat: "multi" x-exportParamName: "RepeatedEnumAnnotation" - name: "enumValueAnnotation" in: "query" description: "Numeric enum title\n\nNumeric enum description.\n\n - ZERO:\ \ ZERO means 0\n - ONE: ONE means 1" required: false type: "string" default: "ZERO" enum: - "ZERO" - "ONE" x-exportParamName: "EnumValueAnnotation" x-optionalDataType: "String" - name: "repeatedStringAnnotation" in: "query" description: "Repeated string title\n\nRepeated string description." required: false type: "array" items: type: "string" collectionFormat: "multi" x-exportParamName: "RepeatedStringAnnotation" - name: "nestedAnnotation.name" in: "query" description: "name is nested field." required: false type: "string" x-exportParamName: "NestedAnnotationName" x-optionalDataType: "String" - name: "nestedAnnotation.amount" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "NestedAnnotationAmount" x-optionalDataType: "Int64" - name: "nestedAnnotation.ok" in: "query" description: "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE:\ \ TRUE is true." required: false type: "string" default: "FALSE" enum: - "FALSE" - "TRUE" x-exportParamName: "NestedAnnotationOk" x-optionalDataType: "String" - name: "int64OverrideType" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Int64OverrideType" x-optionalDataType: "Int64" - name: "requiredStringViaFieldBehaviorAnnotation" in: "query" description: "mark a field as required in Open API definition" required: true type: "string" x-exportParamName: "RequiredStringViaFieldBehaviorAnnotation" - name: "outputOnlyStringViaFieldBehaviorAnnotation" in: "query" description: "mark a field as readonly in Open API definition" required: false type: "string" x-exportParamName: "OutputOnlyStringViaFieldBehaviorAnnotation" x-optionalDataType: "String" - name: "optionalStringValue" in: "query" required: false type: "string" x-exportParamName: "OptionalStringValue" x-optionalDataType: "String" - name: "productId" in: "query" description: "Test openapiv2 generation of repeated fields\n\nOnly digits\ \ are allowed." required: false type: "array" items: type: "string" minLength: 1 maxLength: 19 pattern: "^[0-9]+$" collectionFormat: "multi" x-exportParamName: "ProductId" - name: "optionalStringField" in: "query" description: "Test openapiv2 generation of required fields with annotation\ \ and jsonschema to reproduce" required: false type: "string" x-exportParamName: "OptionalStringField" x-optionalDataType: "String" - name: "requiredStringField1" in: "query" required: true type: "string" x-exportParamName: "RequiredStringField1" - name: "requiredStringField2" in: "query" required: true type: "string" x-exportParamName: "RequiredStringField2" - name: "required_field_behavior_json_name_custom" in: "query" description: "Test openapiv2 handling of required json_name fields" required: true type: "string" x-exportParamName: "RequiredFieldBehaviorJsonNameCustom" - name: "required_field_schema_json_name_custom" in: "query" required: true type: "string" x-exportParamName: "RequiredFieldSchemaJsonNameCustom" - name: "trailingOnly" in: "query" description: "Trailing only" required: false type: "string" x-exportParamName: "TrailingOnly" x-optionalDataType: "String" - name: "trailingOnlyDot" in: "query" description: "Trailing only dot." required: false type: "string" x-exportParamName: "TrailingOnlyDot" x-optionalDataType: "String" - name: "trailingBoth" in: "query" description: "Leading both\n\nTrailing both." required: false type: "string" x-exportParamName: "TrailingBoth" x-optionalDataType: "String" - name: "trailingMultiline" in: "query" description: "Leading multiline\n\nThis is an example of a multi-line comment.\n\ \nTrailing multiline." required: false type: "string" x-exportParamName: "TrailingMultiline" x-optionalDataType: "String" - name: "uuids" in: "query" description: "Specify a custom format of repeated field items" required: false type: "array" items: type: "string" format: "uuid" collectionFormat: "multi" x-exportParamName: "Uuids" responses: 200: description: "A successful response." schema: type: "object" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/a_bit_of_everything/{uuidName}:custom: post: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_Custom" parameters: - name: "uuidName" in: "path" required: true type: "string" format: "uuid" x-internal: true x-exportParamName: "UuidName" - name: "singleNested.name" in: "query" description: "name is nested field." required: false type: "string" x-exportParamName: "SingleNestedName" x-optionalDataType: "String" - name: "singleNested.amount" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "SingleNestedAmount" x-optionalDataType: "Int64" - name: "singleNested.ok" in: "query" description: "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE:\ \ TRUE is true." required: false type: "string" default: "FALSE" enum: - "FALSE" - "TRUE" x-exportParamName: "SingleNestedOk" x-optionalDataType: "String" - name: "floatValue" in: "query" description: "Float value field" required: true type: "number" default: 0.2 format: "float" x-exportParamName: "FloatValue" - name: "doubleValue" in: "query" required: true type: "number" format: "double" x-exportParamName: "DoubleValue" - name: "int64Value" in: "query" required: true type: "string" format: "int64" x-exportParamName: "Int64Value" - name: "uint64Value" in: "query" required: false type: "string" format: "uint64" x-exportParamName: "Uint64Value" x-optionalDataType: "String" - name: "int32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Int32Value" x-optionalDataType: "Int32" - name: "fixed64Value" in: "query" required: false type: "string" format: "uint64" x-exportParamName: "Fixed64Value" x-optionalDataType: "String" - name: "fixed32Value" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Fixed32Value" x-optionalDataType: "Int64" - name: "boolValue" in: "query" required: false type: "boolean" x-exportParamName: "BoolValue" x-optionalDataType: "Bool" - name: "stringValue" in: "query" required: false type: "string" x-exportParamName: "StringValue" x-optionalDataType: "String" - name: "bytesValue" in: "query" required: false type: "string" format: "byte" x-exportParamName: "BytesValue" x-optionalDataType: "String" - name: "uint32Value" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Uint32Value" x-optionalDataType: "Int64" - name: "enumValue" in: "query" description: " - ZERO: ZERO means 0\n - ONE: ONE means 1" required: false type: "string" default: "ZERO" enum: - "ZERO" - "ONE" x-exportParamName: "EnumValue" x-optionalDataType: "String" - name: "pathEnumValue" in: "query" required: false type: "string" default: "ABC" enum: - "ABC" - "DEF" x-exportParamName: "PathEnumValue" x-optionalDataType: "String" - name: "nestedPathEnumValue" in: "query" required: false type: "string" default: "GHI" enum: - "GHI" - "JKL" x-exportParamName: "NestedPathEnumValue" x-optionalDataType: "String" - name: "sfixed32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Sfixed32Value" x-optionalDataType: "Int32" - name: "sfixed64Value" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Sfixed64Value" x-optionalDataType: "String" - name: "sint32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Sint32Value" x-optionalDataType: "Int32" - name: "sint64Value" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Sint64Value" x-optionalDataType: "String" - name: "repeatedStringValue" in: "query" required: false type: "array" items: type: "string" collectionFormat: "multi" x-exportParamName: "RepeatedStringValue" - name: "oneofEmpty" in: "query" required: false type: "object" x-exportParamName: "OneofEmpty" - name: "oneofString" in: "query" required: false type: "string" x-exportParamName: "OneofString" x-optionalDataType: "String" - name: "mapValue" in: "query" description: "map of numeric enum" required: false x-exportParamName: "MapValue" - name: "mappedStringValue" in: "query" description: "Map of string title\n\nMap of string description." required: false type: "string" x-exportParamName: "MappedStringValue" x-optionalDataType: "String" - name: "mappedNestedValue" in: "query" required: false x-exportParamName: "MappedNestedValue" - name: "nonConventionalNameValue" in: "query" required: false type: "string" x-exportParamName: "NonConventionalNameValue" x-optionalDataType: "String" - name: "timestampValue" in: "query" required: false type: "string" format: "date-time" x-exportParamName: "TimestampValue" x-optionalDataType: "Time" - name: "repeatedEnumValue" in: "query" description: "repeated enum value. it is comma-separated in query\n\n - ZERO:\ \ ZERO means 0\n - ONE: ONE means 1" required: false type: "array" items: type: "string" enum: - "ZERO" - "ONE" collectionFormat: "multi" x-exportParamName: "RepeatedEnumValue" - name: "repeatedEnumAnnotation" in: "query" description: "Repeated numeric enum title\n\nRepeated numeric enum description.\n\ \n - ZERO: ZERO means 0\n - ONE: ONE means 1" required: false type: "array" items: type: "string" enum: - "ZERO" - "ONE" collectionFormat: "multi" x-exportParamName: "RepeatedEnumAnnotation" - name: "enumValueAnnotation" in: "query" description: "Numeric enum title\n\nNumeric enum description.\n\n - ZERO:\ \ ZERO means 0\n - ONE: ONE means 1" required: false type: "string" default: "ZERO" enum: - "ZERO" - "ONE" x-exportParamName: "EnumValueAnnotation" x-optionalDataType: "String" - name: "repeatedStringAnnotation" in: "query" description: "Repeated string title\n\nRepeated string description." required: false type: "array" items: type: "string" collectionFormat: "multi" x-exportParamName: "RepeatedStringAnnotation" - name: "nestedAnnotation.name" in: "query" description: "name is nested field." required: false type: "string" x-exportParamName: "NestedAnnotationName" x-optionalDataType: "String" - name: "nestedAnnotation.amount" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "NestedAnnotationAmount" x-optionalDataType: "Int64" - name: "nestedAnnotation.ok" in: "query" description: "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE:\ \ TRUE is true." required: false type: "string" default: "FALSE" enum: - "FALSE" - "TRUE" x-exportParamName: "NestedAnnotationOk" x-optionalDataType: "String" - name: "int64OverrideType" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Int64OverrideType" x-optionalDataType: "Int64" - name: "requiredStringViaFieldBehaviorAnnotation" in: "query" description: "mark a field as required in Open API definition" required: true type: "string" x-exportParamName: "RequiredStringViaFieldBehaviorAnnotation" - name: "outputOnlyStringViaFieldBehaviorAnnotation" in: "query" description: "mark a field as readonly in Open API definition" required: false type: "string" x-exportParamName: "OutputOnlyStringViaFieldBehaviorAnnotation" x-optionalDataType: "String" - name: "optionalStringValue" in: "query" required: false type: "string" x-exportParamName: "OptionalStringValue" x-optionalDataType: "String" - name: "productId" in: "query" description: "Test openapiv2 generation of repeated fields\n\nOnly digits\ \ are allowed." required: false type: "array" items: type: "string" minLength: 1 maxLength: 19 pattern: "^[0-9]+$" collectionFormat: "multi" x-exportParamName: "ProductId" - name: "optionalStringField" in: "query" description: "Test openapiv2 generation of required fields with annotation\ \ and jsonschema to reproduce" required: false type: "string" x-exportParamName: "OptionalStringField" x-optionalDataType: "String" - name: "requiredStringField1" in: "query" required: true type: "string" x-exportParamName: "RequiredStringField1" - name: "requiredStringField2" in: "query" required: true type: "string" x-exportParamName: "RequiredStringField2" - name: "required_field_behavior_json_name_custom" in: "query" description: "Test openapiv2 handling of required json_name fields" required: true type: "string" x-exportParamName: "RequiredFieldBehaviorJsonNameCustom" - name: "required_field_schema_json_name_custom" in: "query" required: true type: "string" x-exportParamName: "RequiredFieldSchemaJsonNameCustom" - name: "trailingOnly" in: "query" description: "Trailing only" required: false type: "string" x-exportParamName: "TrailingOnly" x-optionalDataType: "String" - name: "trailingOnlyDot" in: "query" description: "Trailing only dot." required: false type: "string" x-exportParamName: "TrailingOnlyDot" x-optionalDataType: "String" - name: "trailingBoth" in: "query" description: "Leading both\n\nTrailing both." required: false type: "string" x-exportParamName: "TrailingBoth" x-optionalDataType: "String" - name: "trailingMultiline" in: "query" description: "Leading multiline\n\nThis is an example of a multi-line comment.\n\ \nTrailing multiline." required: false type: "string" x-exportParamName: "TrailingMultiline" x-optionalDataType: "String" - name: "uuids" in: "query" description: "Specify a custom format of repeated field items" required: false type: "array" items: type: "string" format: "uuid" collectionFormat: "multi" x-exportParamName: "Uuids" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbABitOfEverything" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/a_bit_of_everything/{uuidName}:custom:custom: post: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_DoubleColon" parameters: - name: "uuidName" in: "path" required: true type: "string" format: "uuid" x-internal: true x-exportParamName: "UuidName" - name: "singleNested.name" in: "query" description: "name is nested field." required: false type: "string" x-exportParamName: "SingleNestedName" x-optionalDataType: "String" - name: "singleNested.amount" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "SingleNestedAmount" x-optionalDataType: "Int64" - name: "singleNested.ok" in: "query" description: "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE:\ \ TRUE is true." required: false type: "string" default: "FALSE" enum: - "FALSE" - "TRUE" x-exportParamName: "SingleNestedOk" x-optionalDataType: "String" - name: "floatValue" in: "query" description: "Float value field" required: true type: "number" default: 0.2 format: "float" x-exportParamName: "FloatValue" - name: "doubleValue" in: "query" required: true type: "number" format: "double" x-exportParamName: "DoubleValue" - name: "int64Value" in: "query" required: true type: "string" format: "int64" x-exportParamName: "Int64Value" - name: "uint64Value" in: "query" required: false type: "string" format: "uint64" x-exportParamName: "Uint64Value" x-optionalDataType: "String" - name: "int32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Int32Value" x-optionalDataType: "Int32" - name: "fixed64Value" in: "query" required: false type: "string" format: "uint64" x-exportParamName: "Fixed64Value" x-optionalDataType: "String" - name: "fixed32Value" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Fixed32Value" x-optionalDataType: "Int64" - name: "boolValue" in: "query" required: false type: "boolean" x-exportParamName: "BoolValue" x-optionalDataType: "Bool" - name: "stringValue" in: "query" required: false type: "string" x-exportParamName: "StringValue" x-optionalDataType: "String" - name: "bytesValue" in: "query" required: false type: "string" format: "byte" x-exportParamName: "BytesValue" x-optionalDataType: "String" - name: "uint32Value" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Uint32Value" x-optionalDataType: "Int64" - name: "enumValue" in: "query" description: " - ZERO: ZERO means 0\n - ONE: ONE means 1" required: false type: "string" default: "ZERO" enum: - "ZERO" - "ONE" x-exportParamName: "EnumValue" x-optionalDataType: "String" - name: "pathEnumValue" in: "query" required: false type: "string" default: "ABC" enum: - "ABC" - "DEF" x-exportParamName: "PathEnumValue" x-optionalDataType: "String" - name: "nestedPathEnumValue" in: "query" required: false type: "string" default: "GHI" enum: - "GHI" - "JKL" x-exportParamName: "NestedPathEnumValue" x-optionalDataType: "String" - name: "sfixed32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Sfixed32Value" x-optionalDataType: "Int32" - name: "sfixed64Value" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Sfixed64Value" x-optionalDataType: "String" - name: "sint32Value" in: "query" required: false type: "integer" format: "int32" x-exportParamName: "Sint32Value" x-optionalDataType: "Int32" - name: "sint64Value" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Sint64Value" x-optionalDataType: "String" - name: "repeatedStringValue" in: "query" required: false type: "array" items: type: "string" collectionFormat: "multi" x-exportParamName: "RepeatedStringValue" - name: "oneofEmpty" in: "query" required: false type: "object" x-exportParamName: "OneofEmpty" - name: "oneofString" in: "query" required: false type: "string" x-exportParamName: "OneofString" x-optionalDataType: "String" - name: "mapValue" in: "query" description: "map of numeric enum" required: false x-exportParamName: "MapValue" - name: "mappedStringValue" in: "query" description: "Map of string title\n\nMap of string description." required: false type: "string" x-exportParamName: "MappedStringValue" x-optionalDataType: "String" - name: "mappedNestedValue" in: "query" required: false x-exportParamName: "MappedNestedValue" - name: "nonConventionalNameValue" in: "query" required: false type: "string" x-exportParamName: "NonConventionalNameValue" x-optionalDataType: "String" - name: "timestampValue" in: "query" required: false type: "string" format: "date-time" x-exportParamName: "TimestampValue" x-optionalDataType: "Time" - name: "repeatedEnumValue" in: "query" description: "repeated enum value. it is comma-separated in query\n\n - ZERO:\ \ ZERO means 0\n - ONE: ONE means 1" required: false type: "array" items: type: "string" enum: - "ZERO" - "ONE" collectionFormat: "multi" x-exportParamName: "RepeatedEnumValue" - name: "repeatedEnumAnnotation" in: "query" description: "Repeated numeric enum title\n\nRepeated numeric enum description.\n\ \n - ZERO: ZERO means 0\n - ONE: ONE means 1" required: false type: "array" items: type: "string" enum: - "ZERO" - "ONE" collectionFormat: "multi" x-exportParamName: "RepeatedEnumAnnotation" - name: "enumValueAnnotation" in: "query" description: "Numeric enum title\n\nNumeric enum description.\n\n - ZERO:\ \ ZERO means 0\n - ONE: ONE means 1" required: false type: "string" default: "ZERO" enum: - "ZERO" - "ONE" x-exportParamName: "EnumValueAnnotation" x-optionalDataType: "String" - name: "repeatedStringAnnotation" in: "query" description: "Repeated string title\n\nRepeated string description." required: false type: "array" items: type: "string" collectionFormat: "multi" x-exportParamName: "RepeatedStringAnnotation" - name: "nestedAnnotation.name" in: "query" description: "name is nested field." required: false type: "string" x-exportParamName: "NestedAnnotationName" x-optionalDataType: "String" - name: "nestedAnnotation.amount" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "NestedAnnotationAmount" x-optionalDataType: "Int64" - name: "nestedAnnotation.ok" in: "query" description: "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE:\ \ TRUE is true." required: false type: "string" default: "FALSE" enum: - "FALSE" - "TRUE" x-exportParamName: "NestedAnnotationOk" x-optionalDataType: "String" - name: "int64OverrideType" in: "query" required: false type: "integer" format: "int64" x-exportParamName: "Int64OverrideType" x-optionalDataType: "Int64" - name: "requiredStringViaFieldBehaviorAnnotation" in: "query" description: "mark a field as required in Open API definition" required: true type: "string" x-exportParamName: "RequiredStringViaFieldBehaviorAnnotation" - name: "outputOnlyStringViaFieldBehaviorAnnotation" in: "query" description: "mark a field as readonly in Open API definition" required: false type: "string" x-exportParamName: "OutputOnlyStringViaFieldBehaviorAnnotation" x-optionalDataType: "String" - name: "optionalStringValue" in: "query" required: false type: "string" x-exportParamName: "OptionalStringValue" x-optionalDataType: "String" - name: "productId" in: "query" description: "Test openapiv2 generation of repeated fields\n\nOnly digits\ \ are allowed." required: false type: "array" items: type: "string" minLength: 1 maxLength: 19 pattern: "^[0-9]+$" collectionFormat: "multi" x-exportParamName: "ProductId" - name: "optionalStringField" in: "query" description: "Test openapiv2 generation of required fields with annotation\ \ and jsonschema to reproduce" required: false type: "string" x-exportParamName: "OptionalStringField" x-optionalDataType: "String" - name: "requiredStringField1" in: "query" required: true type: "string" x-exportParamName: "RequiredStringField1" - name: "requiredStringField2" in: "query" required: true type: "string" x-exportParamName: "RequiredStringField2" - name: "required_field_behavior_json_name_custom" in: "query" description: "Test openapiv2 handling of required json_name fields" required: true type: "string" x-exportParamName: "RequiredFieldBehaviorJsonNameCustom" - name: "required_field_schema_json_name_custom" in: "query" required: true type: "string" x-exportParamName: "RequiredFieldSchemaJsonNameCustom" - name: "trailingOnly" in: "query" description: "Trailing only" required: false type: "string" x-exportParamName: "TrailingOnly" x-optionalDataType: "String" - name: "trailingOnlyDot" in: "query" description: "Trailing only dot." required: false type: "string" x-exportParamName: "TrailingOnlyDot" x-optionalDataType: "String" - name: "trailingBoth" in: "query" description: "Leading both\n\nTrailing both." required: false type: "string" x-exportParamName: "TrailingBoth" x-optionalDataType: "String" - name: "trailingMultiline" in: "query" description: "Leading multiline\n\nThis is an example of a multi-line comment.\n\ \nTrailing multiline." required: false type: "string" x-exportParamName: "TrailingMultiline" x-optionalDataType: "String" - name: "uuids" in: "query" description: "Specify a custom format of repeated field items" required: false type: "array" items: type: "string" format: "uuid" collectionFormat: "multi" x-exportParamName: "Uuids" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbABitOfEverything" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/a_bit_of_everything/{uuid}: get: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_Lookup" parameters: - name: "uuid" in: "path" required: true type: "string" x-exportParamName: "Uuid" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbABitOfEverything" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" delete: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_Delete" parameters: - name: "uuid" in: "path" required: true type: "string" x-exportParamName: "Uuid" responses: 200: description: "A successful response." schema: type: "object" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" security: - ApiKeyAuth: [] OAuth2: - "read" - "write" x-irreversible: true ? /v1/example/a_bit_of_everything_repeated/{pathRepeatedFloatValue}/{pathRepeatedDoubleValue}/{pathRepeatedInt64Value}/{pathRepeatedUint64Value}/{pathRepeatedInt32Value}/{pathRepeatedFixed64Value}/{pathRepeatedFixed32Value}/{pathRepeatedBoolValue}/{pathRepeatedStringValue}/{pathRepeatedBytesValue}/{pathRepeatedUint32Value}/{pathRepeatedEnumValue}/{pathRepeatedSfixed32Value}/{pathRepeatedSfixed64Value}/{pathRepeatedSint32Value}/{pathRepeatedSint64Value} : get: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_GetRepeatedQuery" parameters: - name: "pathRepeatedFloatValue" in: "path" description: "repeated values. they are comma-separated in path" required: true type: "array" items: type: "number" format: "float" collectionFormat: "csv" minItems: 1 x-exportParamName: "PathRepeatedFloatValue" - name: "pathRepeatedDoubleValue" in: "path" required: true type: "array" items: type: "number" format: "double" collectionFormat: "csv" minItems: 1 x-exportParamName: "PathRepeatedDoubleValue" - name: "pathRepeatedInt64Value" in: "path" required: true type: "array" items: type: "string" format: "int64" collectionFormat: "csv" minItems: 1 x-exportParamName: "PathRepeatedInt64Value" - name: "pathRepeatedUint64Value" in: "path" required: true type: "array" items: type: "string" format: "uint64" collectionFormat: "csv" minItems: 1 x-exportParamName: "PathRepeatedUint64Value" - name: "pathRepeatedInt32Value" in: "path" required: true type: "array" items: type: "integer" format: "int32" collectionFormat: "csv" minItems: 1 x-exportParamName: "PathRepeatedInt32Value" - name: "pathRepeatedFixed64Value" in: "path" required: true type: "array" items: type: "string" format: "uint64" collectionFormat: "csv" minItems: 1 x-exportParamName: "PathRepeatedFixed64Value" - name: "pathRepeatedFixed32Value" in: "path" required: true type: "array" items: type: "integer" format: "int64" collectionFormat: "csv" minItems: 1 x-exportParamName: "PathRepeatedFixed32Value" - name: "pathRepeatedBoolValue" in: "path" required: true type: "array" items: type: "boolean" collectionFormat: "csv" minItems: 1 x-exportParamName: "PathRepeatedBoolValue" - name: "pathRepeatedStringValue" in: "path" required: true type: "array" items: type: "string" collectionFormat: "csv" minItems: 1 x-exportParamName: "PathRepeatedStringValue" - name: "pathRepeatedBytesValue" in: "path" required: true type: "array" items: type: "string" format: "byte" pattern: "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" collectionFormat: "csv" minItems: 1 x-exportParamName: "PathRepeatedBytesValue" - name: "pathRepeatedUint32Value" in: "path" required: true type: "array" items: type: "integer" format: "int64" collectionFormat: "csv" minItems: 1 x-exportParamName: "PathRepeatedUint32Value" - name: "pathRepeatedEnumValue" in: "path" required: true type: "array" items: type: "string" enum: - "ZERO" - "ONE" collectionFormat: "csv" minItems: 1 x-exportParamName: "PathRepeatedEnumValue" - name: "pathRepeatedSfixed32Value" in: "path" required: true type: "array" items: type: "integer" format: "int32" collectionFormat: "csv" minItems: 1 x-exportParamName: "PathRepeatedSfixed32Value" - name: "pathRepeatedSfixed64Value" in: "path" required: true type: "array" items: type: "string" format: "int64" collectionFormat: "csv" minItems: 1 x-exportParamName: "PathRepeatedSfixed64Value" - name: "pathRepeatedSint32Value" in: "path" required: true type: "array" items: type: "integer" format: "int32" collectionFormat: "csv" minItems: 1 x-exportParamName: "PathRepeatedSint32Value" - name: "pathRepeatedSint64Value" in: "path" required: true type: "array" items: type: "string" format: "int64" collectionFormat: "csv" minItems: 1 x-exportParamName: "PathRepeatedSint64Value" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbABitOfEverythingRepeated" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/checkStatus: get: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_CheckStatus" parameters: [] responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbCheckStatusResponse" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/deep_path/{singleNested.name}: post: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_DeepPathEcho" parameters: - name: "singleNested.name" in: "path" description: "name is nested field." required: true type: "string" x-exportParamName: "SingleNestedName" - in: "body" name: "body" required: true schema: $ref: "#/definitions/ABitOfEverythingServiceDeepPathEchoBody" x-exportParamName: "Body" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbABitOfEverything" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/oneofenum: post: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_PostOneofEnum" parameters: - in: "body" name: "exampleEnum" required: true schema: $ref: "#/definitions/oneofenumExampleEnum" x-exportParamName: "ExampleEnum" responses: 200: description: "A successful response." schema: type: "object" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/requiredmessagetype: post: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_PostRequiredMessageType" parameters: - in: "body" name: "body" required: true schema: $ref: "#/definitions/examplepbRequiredMessageTypeRequest" x-exportParamName: "Body" responses: 200: description: "A successful response." schema: type: "object" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/snake/{who}/{what}/{where}: get: tags: - "SnakeEnumService" operationId: "SnakeEnumService_SnakeEnum" parameters: - name: "who" in: "path" required: true type: "string" enum: - "value_e" - "value_f" x-exportParamName: "Who" - name: "what" in: "path" required: true type: "string" enum: - "value_c" - "value_d" x-exportParamName: "What" - name: "where" in: "path" required: true type: "string" enum: - "value_x" - "value_y" x-exportParamName: "Where" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbSnakeEnumResponse" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/{book.name}: patch: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_UpdateBook" parameters: - name: "book.name" in: "path" description: "The resource name of the book.\n\nFormat: `publishers/{publisher}/books/{book}`\n\ \nExample: `publishers/1257894000000000000/books/my-book`" required: true type: "string" pattern: "publishers/[^/]+/books/[^/]+" x-exportParamName: "BookName" - in: "body" name: "book" description: "The book to update.\n\nThe book's `name` field is used to identify\ \ the book to be updated.\nFormat: publishers/{publisher}/books/{book}" required: true schema: $ref: "The book to update." x-exportParamName: "Book" - name: "allowMissing" in: "query" description: "If set to true, and the book is not found, a new book will be\ \ created.\nIn this situation, `update_mask` is ignored." required: false type: "boolean" x-exportParamName: "AllowMissing" x-optionalDataType: "Bool" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbBook" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/{parent}/books: post: tags: - "ABitOfEverything" summary: "Create a book." operationId: "ABitOfEverythingService_CreateBook" parameters: - name: "parent" in: "path" description: "The publisher in which to create the book.\n\nFormat: `publishers/{publisher}`\n\ \nExample: `publishers/1257894000000000000`" required: true type: "string" pattern: "publishers/[^/]+" x-exportParamName: "Parent" - in: "body" name: "book" description: "The book to create." required: true schema: $ref: "#/definitions/examplepbBook" x-exportParamName: "Book" - name: "bookId" in: "query" description: "The ID to use for the book.\n\nThis must start with an alphanumeric\ \ character." required: false type: "string" x-exportParamName: "BookId" x-optionalDataType: "String" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbBook" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v2/example/a_bit_of_everything/{uuidName}: put: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_UpdateV2" parameters: - name: "uuidName" in: "path" required: true type: "string" format: "uuid" x-internal: true x-exportParamName: "UuidName" - in: "body" name: "abe" description: "A bit of everything\n\nIntentionally complicated message type\ \ to cover many features of Protobuf." required: true schema: $ref: "#/definitions/A bit of everything" x-exportParamName: "Abe" - name: "updateMask" in: "query" description: "The paths to update." required: false type: "string" x-exportParamName: "UpdateMask" x-optionalDataType: "String" responses: 200: description: "A successful response." schema: type: "object" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" patch: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_UpdateV22" parameters: - name: "uuidName" in: "path" required: true type: "string" format: "uuid" x-internal: true x-exportParamName: "UuidName" - in: "body" name: "abe" description: "A bit of everything\n\nIntentionally complicated message type\ \ to cover many features of Protobuf." required: true schema: $ref: "#/definitions/A bit of everything_1" x-exportParamName: "Abe" responses: 200: description: "A successful response." schema: type: "object" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v2/example/echo: get: tags: - "echo rpc" summary: "Summary: Echo rpc" description: "Description Echo" operationId: "ABitOfEverythingService_Echo3" parameters: - name: "value" in: "query" required: false type: "string" x-exportParamName: "Value" x-optionalDataType: "String" responses: 200: description: "A successful response." examples: application/json: value: "the input value" schema: $ref: "#/definitions/subStringMessage" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "integer" format: "integer" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" 503: description: "Returned when the resource is temporarily unavailable." schema: {} x-number: 100 default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" externalDocs: description: "Find out more Echo" url: "https://github.com/grpc-ecosystem/grpc-gateway" post: tags: - "echo rpc" summary: "Summary: Echo rpc" description: "Description Echo" operationId: "ABitOfEverythingService_Echo2" parameters: - in: "body" name: "value" required: true schema: type: "string" x-exportParamName: "Value" responses: 200: description: "A successful response." examples: application/json: value: "the input value" schema: $ref: "#/definitions/subStringMessage" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "integer" format: "integer" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" 503: description: "Returned when the resource is temporarily unavailable." schema: {} x-number: 100 default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" externalDocs: description: "Find out more Echo" url: "https://github.com/grpc-ecosystem/grpc-gateway" /v2/example/empty: get: tags: - "camelCaseServiceName" operationId: "camelCaseServiceName_Empty" parameters: [] responses: 200: description: "A successful response." schema: type: "object" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v2/example/errorwithdetails: get: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_ErrorWithDetails" parameters: [] responses: 200: description: "A successful response." schema: type: "object" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v2/example/overwriterequestcontenttype: post: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_OverwriteRequestContentType" consumes: - "application/x-bar-mime" parameters: - in: "body" name: "body" required: true schema: $ref: "#/definitions/examplepbBody" x-exportParamName: "Body" responses: 200: description: "A successful response." schema: type: "object" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v2/example/overwriteresponsecontenttype: get: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_OverwriteResponseContentType" produces: - "application/text" parameters: [] responses: 200: description: "A successful response." schema: type: "string" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v2/example/postwithemptybody/{name}: post: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_PostWithEmptyBody" parameters: - name: "name" in: "path" required: true type: "string" x-exportParamName: "Name" - in: "body" name: "body" required: true schema: $ref: "#/definitions/ABitOfEverythingServicePostWithEmptyBodyBody" x-exportParamName: "Body" responses: 200: description: "A successful response." schema: type: "object" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v2/example/timeout: get: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_Timeout" parameters: [] responses: 200: description: "A successful response." schema: type: "object" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v2/example/withbody/{id}: post: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_GetMessageWithBody" parameters: - name: "id" in: "path" required: true type: "string" x-exportParamName: "Id" - in: "body" name: "data" required: true schema: $ref: "#/definitions/examplepbBody" x-exportParamName: "Data" responses: 200: description: "A successful response." schema: type: "object" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v2/{value}:check: get: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_CheckExternalPathEnum" parameters: - name: "value" in: "path" required: true type: "string" enum: - "ABC" - "DEF" x-exportParamName: "Value" responses: 200: description: "A successful response." schema: type: "object" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v2a/example/a_bit_of_everything/{uuidName}: patch: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_UpdateV23" parameters: - name: "uuidName" in: "path" required: true type: "string" format: "uuid" x-internal: true x-exportParamName: "UuidName" - in: "body" name: "body" required: true schema: $ref: "#/definitions/ABitOfEverythingServiceUpdateV2Body" x-exportParamName: "Body" responses: 200: description: "A successful response." schema: type: "object" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v3/{value}:check: get: tags: - "ABitOfEverything" operationId: "ABitOfEverythingService_CheckExternalNestedPathEnum" parameters: - name: "value" in: "path" required: true type: "string" enum: - "GHI" - "JKL" x-exportParamName: "Value" responses: 200: description: "A successful response." schema: type: "object" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" 418: description: "I'm a teapot." schema: $ref: "#/definitions/examplepbNumericEnum" 500: description: "Server error" schema: $ref: "#/definitions/examplepbErrorResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" securityDefinitions: ApiKeyAuth: type: "apiKey" name: "X-API-Key" in: "header" x-amazon-apigateway-authorizer: authorizerResultTtlInSeconds: 60 type: "token" x-amazon-apigateway-authtype: "oauth2" BasicAuth: type: "basic" OAuth2: type: "oauth2" authorizationUrl: "https://example.com/oauth/authorize" tokenUrl: "https://example.com/oauth/token" flow: "accessCode" scopes: admin: "Grants read and write access to administrative information" read: "Grants read access" write: "Grants write access" definitions: ABitOfEverythingNested: type: "object" properties: name: type: "string" description: "name is nested field." amount: type: "integer" format: "int64" ok: description: "DeepEnum description." $ref: "#/definitions/NestedDeepEnum" description: "Nested is nested type." example: ok: "TRUE" ABitOfEverythingServiceDeepPathEchoBody: type: "object" required: - "doubleValue" - "floatValue" - "int64Value" - "requiredStringField1" - "requiredStringField2" - "requiredStringViaFieldBehaviorAnnotation" - "required_field_behavior_json_name_custom" - "required_field_schema_json_name_custom" - "uuid" properties: singleNested: $ref: "#/definitions/ABitOfEverythingServiceDeepPathEchoBody_singleNested" uuid: type: "string" format: "uuid" minLength: 1 pattern: "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}" x-internal: true nested: type: "array" items: $ref: "#/definitions/ABitOfEverythingNested" floatValue: type: "number" format: "float" description: "Float value field" default: 0.2 doubleValue: type: "number" format: "double" int64Value: type: "string" format: "int64" uint64Value: type: "string" format: "uint64" int32Value: type: "integer" format: "int32" fixed64Value: type: "string" format: "uint64" fixed32Value: type: "integer" format: "int64" boolValue: type: "boolean" stringValue: type: "string" bytesValue: type: "string" format: "byte" pattern: "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" uint32Value: type: "integer" format: "int64" enumValue: $ref: "#/definitions/examplepbNumericEnum" pathEnumValue: $ref: "#/definitions/pathenumPathEnum" nestedPathEnumValue: $ref: "#/definitions/MessagePathEnumNestedPathEnum" sfixed32Value: type: "integer" format: "int32" sfixed64Value: type: "string" format: "int64" sint32Value: type: "integer" format: "int32" sint64Value: type: "string" format: "int64" repeatedStringValue: type: "array" items: type: "string" oneofEmpty: type: "object" properties: {} oneofString: type: "string" mapValue: type: "object" title: "map of numeric enum" additionalProperties: $ref: "#/definitions/examplepbNumericEnum" mappedStringValue: type: "object" description: "Map of string description." title: "Map of string title" additionalProperties: type: "string" mappedNestedValue: type: "object" additionalProperties: $ref: "#/definitions/ABitOfEverythingNested" nonConventionalNameValue: type: "string" timestampValue: type: "string" format: "date-time" repeatedEnumValue: type: "array" title: "repeated enum value. it is comma-separated in query" items: $ref: "#/definitions/examplepbNumericEnum" repeatedEnumAnnotation: type: "array" description: "Repeated numeric enum description." title: "Repeated numeric enum title" items: $ref: "#/definitions/examplepbNumericEnum" enumValueAnnotation: description: "Numeric enum description." title: "Numeric enum title" $ref: "#/definitions/examplepbNumericEnum" repeatedStringAnnotation: type: "array" description: "Repeated string description." title: "Repeated string title" items: type: "string" repeatedNestedAnnotation: type: "array" description: "Repeated nested object description." title: "Repeated nested object title" items: $ref: "#/definitions/ABitOfEverythingNested" nestedAnnotation: description: "Nested object description." title: "Nested object title" $ref: "#/definitions/ABitOfEverythingNested" int64OverrideType: type: "integer" format: "int64" requiredStringViaFieldBehaviorAnnotation: type: "string" title: "mark a field as required in Open API definition" outputOnlyStringViaFieldBehaviorAnnotation: type: "string" title: "mark a field as readonly in Open API definition" readOnly: true optionalStringValue: type: "string" productId: type: "array" description: "Only digits are allowed." title: "Test openapiv2 generation of repeated fields" items: type: "string" minLength: 1 maxLength: 19 pattern: "^[0-9]+$" optionalStringField: type: "string" title: "Test openapiv2 generation of required fields with annotation and jsonschema\ \ to reproduce" requiredStringField1: type: "string" requiredStringField2: type: "string" required_field_behavior_json_name_custom: type: "string" title: "Test openapiv2 handling of required json_name fields" required_field_schema_json_name_custom: type: "string" trailingOnly: type: "string" title: "Trailing only" trailingOnlyDot: type: "string" description: "Trailing only dot." trailingBoth: type: "string" description: "Trailing both." title: "Leading both" trailingMultiline: type: "string" description: "This is an example of a multi-line comment.\n\nTrailing multiline." title: "Leading multiline" uuids: type: "array" title: "Specify a custom format of repeated field items" items: type: "string" format: "uuid" externalDocs: description: "Find out more about ABitOfEverything" url: "https://github.com/grpc-ecosystem/grpc-gateway" title: "A bit of everything" description: "Intentionally complicated message type to cover many features of\ \ Protobuf." example: int64_value: 12 double_value: 12.3 x-a-bit-of-everything-foo: "bar" ABitOfEverythingServicePostWithEmptyBodyBody: type: "object" ABitOfEverythingServiceUpdateV2Body: type: "object" properties: abe: $ref: "#/definitions/A bit of everything_2" updateMask: type: "string" description: "The paths to update." title: "UpdateV2Request request for update includes the message and the update\ \ mask" example: abe: "{\"int64_value\":12,\"double_value\":12.3}" updateMask: "updateMask" MessagePathEnumNestedPathEnum: type: "string" enum: - "GHI" - "JKL" default: "GHI" NestedDeepEnum: type: "string" description: "DeepEnum is one or zero.\n\n - FALSE: FALSE is false.\n - TRUE:\ \ TRUE is true." enum: - "FALSE" - "TRUE" default: "FALSE" examplepbABitOfEverything: type: "object" required: - "doubleValue" - "floatValue" - "int64Value" - "requiredStringField1" - "requiredStringField2" - "requiredStringViaFieldBehaviorAnnotation" - "required_field_behavior_json_name_custom" - "required_field_schema_json_name_custom" - "uuid" properties: singleNested: $ref: "#/definitions/ABitOfEverythingNested" uuid: type: "string" format: "uuid" minLength: 1 pattern: "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}" x-internal: true nested: type: "array" items: $ref: "#/definitions/ABitOfEverythingNested" floatValue: type: "number" format: "float" description: "Float value field" default: 0.2 doubleValue: type: "number" format: "double" int64Value: type: "string" format: "int64" uint64Value: type: "string" format: "uint64" int32Value: type: "integer" format: "int32" fixed64Value: type: "string" format: "uint64" fixed32Value: type: "integer" format: "int64" boolValue: type: "boolean" stringValue: type: "string" bytesValue: type: "string" format: "byte" pattern: "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" uint32Value: type: "integer" format: "int64" enumValue: $ref: "#/definitions/examplepbNumericEnum" pathEnumValue: $ref: "#/definitions/pathenumPathEnum" nestedPathEnumValue: $ref: "#/definitions/MessagePathEnumNestedPathEnum" sfixed32Value: type: "integer" format: "int32" sfixed64Value: type: "string" format: "int64" sint32Value: type: "integer" format: "int32" sint64Value: type: "string" format: "int64" repeatedStringValue: type: "array" items: type: "string" oneofEmpty: type: "object" properties: {} oneofString: type: "string" mapValue: type: "object" title: "map of numeric enum" additionalProperties: $ref: "#/definitions/examplepbNumericEnum" mappedStringValue: type: "object" description: "Map of string description." title: "Map of string title" additionalProperties: type: "string" mappedNestedValue: type: "object" additionalProperties: $ref: "#/definitions/ABitOfEverythingNested" nonConventionalNameValue: type: "string" timestampValue: type: "string" format: "date-time" repeatedEnumValue: type: "array" title: "repeated enum value. it is comma-separated in query" items: $ref: "#/definitions/examplepbNumericEnum" repeatedEnumAnnotation: type: "array" description: "Repeated numeric enum description." title: "Repeated numeric enum title" items: $ref: "#/definitions/examplepbNumericEnum" enumValueAnnotation: description: "Numeric enum description." title: "Numeric enum title" $ref: "#/definitions/examplepbNumericEnum" repeatedStringAnnotation: type: "array" description: "Repeated string description." title: "Repeated string title" items: type: "string" repeatedNestedAnnotation: type: "array" description: "Repeated nested object description." title: "Repeated nested object title" items: $ref: "#/definitions/ABitOfEverythingNested" nestedAnnotation: description: "Nested object description." title: "Nested object title" $ref: "#/definitions/ABitOfEverythingNested" int64OverrideType: type: "integer" format: "int64" requiredStringViaFieldBehaviorAnnotation: type: "string" title: "mark a field as required in Open API definition" outputOnlyStringViaFieldBehaviorAnnotation: type: "string" title: "mark a field as readonly in Open API definition" readOnly: true optionalStringValue: type: "string" productId: type: "array" description: "Only digits are allowed." title: "Test openapiv2 generation of repeated fields" items: type: "string" minLength: 1 maxLength: 19 pattern: "^[0-9]+$" optionalStringField: type: "string" title: "Test openapiv2 generation of required fields with annotation and jsonschema\ \ to reproduce" requiredStringField1: type: "string" requiredStringField2: type: "string" required_field_behavior_json_name_custom: type: "string" title: "Test openapiv2 handling of required json_name fields" required_field_schema_json_name_custom: type: "string" trailingOnly: type: "string" title: "Trailing only" trailingOnlyDot: type: "string" description: "Trailing only dot." trailingBoth: type: "string" description: "Trailing both." title: "Leading both" trailingMultiline: type: "string" description: "This is an example of a multi-line comment.\n\nTrailing multiline." title: "Leading multiline" uuids: type: "array" title: "Specify a custom format of repeated field items" items: type: "string" format: "uuid" externalDocs: description: "Find out more about ABitOfEverything" url: "https://github.com/grpc-ecosystem/grpc-gateway" title: "A bit of everything" description: "Intentionally complicated message type to cover many features of\ \ Protobuf." example: int64_value: 12 double_value: 12.3 x-a-bit-of-everything-foo: "bar" examplepbABitOfEverythingRepeated: type: "object" properties: pathRepeatedFloatValue: type: "array" title: "repeated values. they are comma-separated in path" items: type: "number" format: "float" pathRepeatedDoubleValue: type: "array" items: type: "number" format: "double" pathRepeatedInt64Value: type: "array" items: type: "string" format: "int64" pathRepeatedUint64Value: type: "array" items: type: "string" format: "uint64" pathRepeatedInt32Value: type: "array" items: type: "integer" format: "int32" pathRepeatedFixed64Value: type: "array" items: type: "string" format: "uint64" pathRepeatedFixed32Value: type: "array" items: type: "integer" format: "int64" pathRepeatedBoolValue: type: "array" items: type: "boolean" pathRepeatedStringValue: type: "array" items: type: "string" pathRepeatedBytesValue: type: "array" items: type: "string" format: "byte" pattern: "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" pathRepeatedUint32Value: type: "array" items: type: "integer" format: "int64" pathRepeatedEnumValue: type: "array" items: $ref: "#/definitions/examplepbNumericEnum" pathRepeatedSfixed32Value: type: "array" items: type: "integer" format: "int32" pathRepeatedSfixed64Value: type: "array" items: type: "string" format: "int64" pathRepeatedSint32Value: type: "array" items: type: "integer" format: "int32" pathRepeatedSint64Value: type: "array" items: type: "string" format: "int64" title: "ABitOfEverythingRepeated is used to validate repeated path parameter functionality" example: path_repeated_bool_value: - true - true - false - true path_repeated_int32_value: - 1 - 2 - 3 examplepbABitOfEverythingServiceUpdateBody: type: "object" required: - "doubleValue" - "floatValue" - "int64Value" - "requiredStringField1" - "requiredStringField2" - "requiredStringViaFieldBehaviorAnnotation" - "required_field_behavior_json_name_custom" - "required_field_schema_json_name_custom" properties: singleNested: $ref: "#/definitions/ABitOfEverythingNested" nested: type: "array" items: $ref: "#/definitions/ABitOfEverythingNested" floatValue: type: "number" format: "float" description: "Float value field" default: 0.2 doubleValue: type: "number" format: "double" int64Value: type: "string" format: "int64" uint64Value: type: "string" format: "uint64" int32Value: type: "integer" format: "int32" fixed64Value: type: "string" format: "uint64" fixed32Value: type: "integer" format: "int64" boolValue: type: "boolean" stringValue: type: "string" bytesValue: type: "string" format: "byte" pattern: "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" uint32Value: type: "integer" format: "int64" enumValue: $ref: "#/definitions/examplepbNumericEnum" pathEnumValue: $ref: "#/definitions/pathenumPathEnum" nestedPathEnumValue: $ref: "#/definitions/MessagePathEnumNestedPathEnum" sfixed32Value: type: "integer" format: "int32" sfixed64Value: type: "string" format: "int64" sint32Value: type: "integer" format: "int32" sint64Value: type: "string" format: "int64" repeatedStringValue: type: "array" items: type: "string" oneofEmpty: type: "object" properties: {} oneofString: type: "string" mapValue: type: "object" title: "map of numeric enum" additionalProperties: $ref: "#/definitions/examplepbNumericEnum" mappedStringValue: type: "object" description: "Map of string description." title: "Map of string title" additionalProperties: type: "string" mappedNestedValue: type: "object" additionalProperties: $ref: "#/definitions/ABitOfEverythingNested" nonConventionalNameValue: type: "string" timestampValue: type: "string" format: "date-time" repeatedEnumValue: type: "array" title: "repeated enum value. it is comma-separated in query" items: $ref: "#/definitions/examplepbNumericEnum" repeatedEnumAnnotation: type: "array" description: "Repeated numeric enum description." title: "Repeated numeric enum title" items: $ref: "#/definitions/examplepbNumericEnum" enumValueAnnotation: description: "Numeric enum description." title: "Numeric enum title" $ref: "#/definitions/examplepbNumericEnum" repeatedStringAnnotation: type: "array" description: "Repeated string description." title: "Repeated string title" items: type: "string" repeatedNestedAnnotation: type: "array" description: "Repeated nested object description." title: "Repeated nested object title" items: $ref: "#/definitions/ABitOfEverythingNested" nestedAnnotation: description: "Nested object description." title: "Nested object title" $ref: "#/definitions/ABitOfEverythingNested" int64OverrideType: type: "integer" format: "int64" requiredStringViaFieldBehaviorAnnotation: type: "string" title: "mark a field as required in Open API definition" outputOnlyStringViaFieldBehaviorAnnotation: type: "string" title: "mark a field as readonly in Open API definition" readOnly: true optionalStringValue: type: "string" productId: type: "array" description: "Only digits are allowed." title: "Test openapiv2 generation of repeated fields" items: type: "string" minLength: 1 maxLength: 19 pattern: "^[0-9]+$" optionalStringField: type: "string" title: "Test openapiv2 generation of required fields with annotation and jsonschema\ \ to reproduce" requiredStringField1: type: "string" requiredStringField2: type: "string" required_field_behavior_json_name_custom: type: "string" title: "Test openapiv2 handling of required json_name fields" required_field_schema_json_name_custom: type: "string" trailingOnly: type: "string" title: "Trailing only" trailingOnlyDot: type: "string" description: "Trailing only dot." trailingBoth: type: "string" description: "Trailing both." title: "Leading both" trailingMultiline: type: "string" description: "This is an example of a multi-line comment.\n\nTrailing multiline." title: "Leading multiline" uuids: type: "array" title: "Specify a custom format of repeated field items" items: type: "string" format: "uuid" externalDocs: description: "Find out more about ABitOfEverything" url: "https://github.com/grpc-ecosystem/grpc-gateway" title: "A bit of everything" description: "Intentionally complicated message type to cover many features of\ \ Protobuf." example: int64_value: 12 double_value: 12.3 x-a-bit-of-everything-foo: "bar" examplepbBar: type: "object" required: - "id" properties: id: type: "string" examplepbBody: type: "object" properties: name: type: "string" examplepbBook: type: "object" properties: name: type: "string" description: "The resource name of the book.\n\nFormat: `publishers/{publisher}/books/{book}`\n\ \nExample: `publishers/1257894000000000000/books/my-book`" id: type: "string" description: "Output only. The book's ID." readOnly: true createTime: type: "string" format: "date-time" description: "Output only. Creation time of the book." readOnly: true description: "An example resource type from AIP-123 used to test the behavior\ \ described in\nthe CreateBookRequest message.\n\nSee: https://google.aip.dev/123" example: createTime: "2000-01-23T04:56:07.000+00:00" name: "name" id: "id" examplepbCheckStatusResponse: type: "object" properties: status: $ref: "#/definitions/googleRpcStatus" example: status: code: 0 details: - '@type': "@type" - '@type': "@type" message: "message" examplepbErrorObject: type: "object" properties: code: type: "integer" format: "integer" description: "Response code" title: "code" message: type: "string" description: "Response message" title: "message" pattern: "^[a-zA-Z0-9]{1, 32}$" examplepbErrorResponse: type: "object" properties: correlationId: type: "string" format: "uuid" example: "2438ac3c-37eb-4902-adef-ed16b4431030" description: "Unique event identifier for server requests" title: "x-correlation-id" pattern: "^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$" error: $ref: "#/definitions/examplepbErrorObject" examplepbNumericEnum: type: "string" externalDocs: description: "Find out more about ABitOfEverything" url: "https://github.com/grpc-ecosystem/grpc-gateway" title: "NumericEnum" description: "NumericEnum is one or zero." example: "ZERO" enum: - "ZERO" - "ONE" default: "ZERO" x-a-bit-of-everything-foo: "bar" examplepbRequiredMessageTypeRequest: type: "object" required: - "foo" - "id" properties: id: type: "string" foo: $ref: "#/definitions/protoExamplepbFoo" title: "Required message type -> OpenAPI\nhttps://github.com/grpc-ecosystem/grpc-gateway/issues/2837" examplepbSnakeEnumResponse: type: "object" examplepbSnake_case_0_enum: type: "string" title: "Ignoring lint warnings as this enum type exist to validate proper functionality\n\ for projects that don't follow these lint rules.\nbuf:lint:ignore ENUM_PASCAL_CASE" description: "- value_e: buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE\n - value_f:\ \ buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE" enum: - "value_e" - "value_f" default: "value_e" examplepbSnake_case_enum: type: "string" title: "Ignoring lint warnings as this enum type exist to validate proper functionality\n\ for projects that don't follow these lint rules.\nbuf:lint:ignore ENUM_PASCAL_CASE" description: "- value_c: buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE\n - value_d:\ \ buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE" enum: - "value_c" - "value_d" default: "value_c" googleRpcStatus: type: "object" properties: code: type: "integer" format: "int32" description: "The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]." message: type: "string" description: "A developer-facing error message, which should be in English.\ \ Any\nuser-facing error message should be localized and sent in the\n[google.rpc.Status.details][google.rpc.Status.details]\ \ field, or localized by the client." details: type: "array" description: "A list of messages that carry the error details. There is a\ \ common set of\nmessage types for APIs to use." items: $ref: "#/definitions/protobufAny" description: "The `Status` type defines a logical error model that is suitable\ \ for\ndifferent programming environments, including REST APIs and RPC APIs.\ \ It is\nused by [gRPC](https://github.com/grpc). Each `Status` message contains\n\ three pieces of data: error code, error message, and error details.\n\nYou can\ \ find out more about this error model and how to work with it in the\n[API\ \ Design Guide](https://cloud.google.com/apis/design/errors)." example: code: 0 details: - '@type': "@type" - '@type': "@type" message: "message" oneofenumExampleEnum: type: "string" enum: - "EXAMPLE_ENUM_UNSPECIFIED" - "EXAMPLE_ENUM_FIRST" default: "EXAMPLE_ENUM_UNSPECIFIED" pathenumPathEnum: type: "string" enum: - "ABC" - "DEF" default: "ABC" pathenumSnake_case_for_import: type: "string" title: "Ignoring lint warnings as this enum type exist to validate proper functionality\n\ for projects that don't follow these lint rules.\nbuf:lint:ignore ENUM_PASCAL_CASE" description: "- value_x: buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE\n - value_y:\ \ buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE" enum: - "value_x" - "value_y" default: "value_x" protoExamplepbFoo: type: "object" required: - "bar" properties: bar: $ref: "#/definitions/examplepbBar" protobufAny: type: "object" properties: '@type': type: "string" description: "A URL/resource name that uniquely identifies the type of the\ \ serialized\nprotocol buffer message. This string must contain at least\n\ one \"/\" character. The last segment of the URL's path must represent\n\ the fully qualified name of the type (as in\n`path/google.protobuf.Duration`).\ \ The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\ \nIn practice, teams usually precompile into the binary all types that they\n\ expect it to use in the context of Any. However, for URLs which use the\n\ scheme `http`, `https`, or no scheme, one can optionally set up a type\n\ server that maps type URLs to message definitions as follows:\n\n* If no\ \ scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must\ \ yield a [google.protobuf.Type][]\n value in binary format, or produce\ \ an error.\n* Applications are allowed to cache lookup results based on\ \ the\n URL, or have them precompiled into a binary to avoid any\n lookup.\ \ Therefore, binary compatibility needs to be preserved\n on changes to\ \ types. (Use versioned type names to manage\n breaking changes.)\n\nNote:\ \ this functionality is not currently available in the official\nprotobuf\ \ release, and it is not used for type URLs beginning with\ntype.googleapis.com.\ \ As of May 2023, there are no widely used type server\nimplementations\ \ and no plans to implement one.\n\nSchemes other than `http`, `https` (or\ \ the empty scheme) might be\nused with implementation specific semantics." description: "`Any` contains an arbitrary serialized protocol buffer message along\ \ with a\nURL that describes the type of the serialized message.\n\nProtobuf\ \ library provides support to pack/unpack Any values in the form\nof utility\ \ functions or additional generated methods of the Any type.\n\nExample 1: Pack\ \ and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n\ \ ...\n if (any.UnpackTo(&foo)) {\n ...\n }\n\nExample 2: Pack\ \ and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n\ \ ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n\ \ }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n\ \ foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack\ \ and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n \ \ any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n\ \ ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := &pb.Foo{...}\n\ \ any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n\ \ ...\n foo := &pb.Foo{}\n if err := any.UnmarshalTo(foo); err !=\ \ nil {\n ...\n }\n\nThe pack methods provided by protobuf library\ \ will by default use\n'type.googleapis.com/full.type.name' as the type URL\ \ and the unpack\nmethods only use the fully qualified type name after the last\ \ '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\n\ name \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses\ \ the regular\nrepresentation of the deserialized, embedded message, with an\n\ additional field `@type` which contains the type URL. Example:\n\n package\ \ google.profile;\n message Person {\n string first_name = 1;\n \ \ string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\"\ ,\n \"firstName\": ,\n \"lastName\": \n }\n\nIf\ \ the embedded message type is well-known and has a custom JSON\nrepresentation,\ \ that representation will be embedded adding a field\n`value` which holds the\ \ custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\ \n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n\ \ \"value\": \"1.212s\"\n }" example: '@type': "@type" additionalProperties: {} subStringMessage: type: "object" properties: value: type: "string" The book to update.: type: "object" properties: id: type: "string" description: "Output only. The book's ID." readOnly: true createTime: type: "string" format: "date-time" description: "Output only. Creation time of the book." readOnly: true title: "The book to update." description: "The book's `name` field is used to identify the book to be updated.\n\ Format: publishers/{publisher}/books/{book}" A bit of everything: type: "object" required: - "doubleValue" - "floatValue" - "int64Value" - "requiredStringField1" - "requiredStringField2" - "requiredStringViaFieldBehaviorAnnotation" - "required_field_behavior_json_name_custom" - "required_field_schema_json_name_custom" properties: singleNested: $ref: "#/definitions/ABitOfEverythingNested" nested: type: "array" items: $ref: "#/definitions/ABitOfEverythingNested" floatValue: type: "number" format: "float" description: "Float value field" default: 0.2 doubleValue: type: "number" format: "double" int64Value: type: "string" format: "int64" uint64Value: type: "string" format: "uint64" int32Value: type: "integer" format: "int32" fixed64Value: type: "string" format: "uint64" fixed32Value: type: "integer" format: "int64" boolValue: type: "boolean" stringValue: type: "string" bytesValue: type: "string" format: "byte" pattern: "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" uint32Value: type: "integer" format: "int64" enumValue: $ref: "#/definitions/examplepbNumericEnum" pathEnumValue: $ref: "#/definitions/pathenumPathEnum" nestedPathEnumValue: $ref: "#/definitions/MessagePathEnumNestedPathEnum" sfixed32Value: type: "integer" format: "int32" sfixed64Value: type: "string" format: "int64" sint32Value: type: "integer" format: "int32" sint64Value: type: "string" format: "int64" repeatedStringValue: type: "array" items: type: "string" oneofEmpty: type: "object" properties: {} oneofString: type: "string" mapValue: type: "object" title: "map of numeric enum" additionalProperties: $ref: "#/definitions/examplepbNumericEnum" mappedStringValue: type: "object" description: "Map of string description." title: "Map of string title" additionalProperties: type: "string" mappedNestedValue: type: "object" additionalProperties: $ref: "#/definitions/ABitOfEverythingNested" nonConventionalNameValue: type: "string" timestampValue: type: "string" format: "date-time" repeatedEnumValue: type: "array" title: "repeated enum value. it is comma-separated in query" items: $ref: "#/definitions/examplepbNumericEnum" repeatedEnumAnnotation: type: "array" description: "Repeated numeric enum description." title: "Repeated numeric enum title" items: $ref: "#/definitions/examplepbNumericEnum" enumValueAnnotation: description: "Numeric enum description." title: "Numeric enum title" $ref: "#/definitions/examplepbNumericEnum" repeatedStringAnnotation: type: "array" description: "Repeated string description." title: "Repeated string title" items: type: "string" repeatedNestedAnnotation: type: "array" description: "Repeated nested object description." title: "Repeated nested object title" items: $ref: "#/definitions/ABitOfEverythingNested" nestedAnnotation: description: "Nested object description." title: "Nested object title" $ref: "#/definitions/ABitOfEverythingNested" int64OverrideType: type: "integer" format: "int64" requiredStringViaFieldBehaviorAnnotation: type: "string" title: "mark a field as required in Open API definition" outputOnlyStringViaFieldBehaviorAnnotation: type: "string" title: "mark a field as readonly in Open API definition" readOnly: true optionalStringValue: type: "string" productId: type: "array" description: "Only digits are allowed." title: "Test openapiv2 generation of repeated fields" items: type: "string" minLength: 1 maxLength: 19 pattern: "^[0-9]+$" optionalStringField: type: "string" title: "Test openapiv2 generation of required fields with annotation and jsonschema\ \ to reproduce" requiredStringField1: type: "string" requiredStringField2: type: "string" required_field_behavior_json_name_custom: type: "string" title: "Test openapiv2 handling of required json_name fields" required_field_schema_json_name_custom: type: "string" trailingOnly: type: "string" title: "Trailing only" trailingOnlyDot: type: "string" description: "Trailing only dot." trailingBoth: type: "string" description: "Trailing both." title: "Leading both" trailingMultiline: type: "string" description: "This is an example of a multi-line comment.\n\nTrailing multiline." title: "Leading multiline" uuids: type: "array" title: "Specify a custom format of repeated field items" items: type: "string" format: "uuid" externalDocs: description: "Find out more about ABitOfEverything" url: "https://github.com/grpc-ecosystem/grpc-gateway" title: "A bit of everything" description: "Intentionally complicated message type to cover many features of\ \ Protobuf." example: int64_value: 12 double_value: 12.3 x-a-bit-of-everything-foo: "bar" A bit of everything_1: type: "object" required: - "doubleValue" - "floatValue" - "int64Value" - "requiredStringField1" - "requiredStringField2" - "requiredStringViaFieldBehaviorAnnotation" - "required_field_behavior_json_name_custom" - "required_field_schema_json_name_custom" properties: singleNested: $ref: "#/definitions/ABitOfEverythingNested" nested: type: "array" items: $ref: "#/definitions/ABitOfEverythingNested" floatValue: type: "number" format: "float" description: "Float value field" default: 0.2 doubleValue: type: "number" format: "double" int64Value: type: "string" format: "int64" uint64Value: type: "string" format: "uint64" int32Value: type: "integer" format: "int32" fixed64Value: type: "string" format: "uint64" fixed32Value: type: "integer" format: "int64" boolValue: type: "boolean" stringValue: type: "string" bytesValue: type: "string" format: "byte" pattern: "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" uint32Value: type: "integer" format: "int64" enumValue: $ref: "#/definitions/examplepbNumericEnum" pathEnumValue: $ref: "#/definitions/pathenumPathEnum" nestedPathEnumValue: $ref: "#/definitions/MessagePathEnumNestedPathEnum" sfixed32Value: type: "integer" format: "int32" sfixed64Value: type: "string" format: "int64" sint32Value: type: "integer" format: "int32" sint64Value: type: "string" format: "int64" repeatedStringValue: type: "array" items: type: "string" oneofEmpty: type: "object" properties: {} oneofString: type: "string" mapValue: type: "object" title: "map of numeric enum" additionalProperties: $ref: "#/definitions/examplepbNumericEnum" mappedStringValue: type: "object" description: "Map of string description." title: "Map of string title" additionalProperties: type: "string" mappedNestedValue: type: "object" additionalProperties: $ref: "#/definitions/ABitOfEverythingNested" nonConventionalNameValue: type: "string" timestampValue: type: "string" format: "date-time" repeatedEnumValue: type: "array" title: "repeated enum value. it is comma-separated in query" items: $ref: "#/definitions/examplepbNumericEnum" repeatedEnumAnnotation: type: "array" description: "Repeated numeric enum description." title: "Repeated numeric enum title" items: $ref: "#/definitions/examplepbNumericEnum" enumValueAnnotation: description: "Numeric enum description." title: "Numeric enum title" $ref: "#/definitions/examplepbNumericEnum" repeatedStringAnnotation: type: "array" description: "Repeated string description." title: "Repeated string title" items: type: "string" repeatedNestedAnnotation: type: "array" description: "Repeated nested object description." title: "Repeated nested object title" items: $ref: "#/definitions/ABitOfEverythingNested" nestedAnnotation: description: "Nested object description." title: "Nested object title" $ref: "#/definitions/ABitOfEverythingNested" int64OverrideType: type: "integer" format: "int64" requiredStringViaFieldBehaviorAnnotation: type: "string" title: "mark a field as required in Open API definition" outputOnlyStringViaFieldBehaviorAnnotation: type: "string" title: "mark a field as readonly in Open API definition" readOnly: true optionalStringValue: type: "string" productId: type: "array" description: "Only digits are allowed." title: "Test openapiv2 generation of repeated fields" items: type: "string" minLength: 1 maxLength: 19 pattern: "^[0-9]+$" optionalStringField: type: "string" title: "Test openapiv2 generation of required fields with annotation and jsonschema\ \ to reproduce" requiredStringField1: type: "string" requiredStringField2: type: "string" required_field_behavior_json_name_custom: type: "string" title: "Test openapiv2 handling of required json_name fields" required_field_schema_json_name_custom: type: "string" trailingOnly: type: "string" title: "Trailing only" trailingOnlyDot: type: "string" description: "Trailing only dot." trailingBoth: type: "string" description: "Trailing both." title: "Leading both" trailingMultiline: type: "string" description: "This is an example of a multi-line comment.\n\nTrailing multiline." title: "Leading multiline" uuids: type: "array" title: "Specify a custom format of repeated field items" items: type: "string" format: "uuid" externalDocs: description: "Find out more about ABitOfEverything" url: "https://github.com/grpc-ecosystem/grpc-gateway" title: "A bit of everything" description: "Intentionally complicated message type to cover many features of\ \ Protobuf." example: int64_value: 12 double_value: 12.3 x-a-bit-of-everything-foo: "bar" ABitOfEverythingServiceDeepPathEchoBody_singleNested: properties: amount: type: "integer" format: "int64" ok: description: "DeepEnum description." $ref: "#/definitions/NestedDeepEnum" description: "Nested is nested type." example: "{\"ok\":\"TRUE\"}" A bit of everything_2: required: - "doubleValue" - "floatValue" - "int64Value" - "requiredStringField1" - "requiredStringField2" - "requiredStringViaFieldBehaviorAnnotation" - "required_field_behavior_json_name_custom" - "required_field_schema_json_name_custom" properties: singleNested: $ref: "#/definitions/ABitOfEverythingNested" nested: type: "array" items: $ref: "#/definitions/ABitOfEverythingNested" floatValue: type: "number" format: "float" description: "Float value field" default: 0.2 doubleValue: type: "number" format: "double" int64Value: type: "string" format: "int64" uint64Value: type: "string" format: "uint64" int32Value: type: "integer" format: "int32" fixed64Value: type: "string" format: "uint64" fixed32Value: type: "integer" format: "int64" boolValue: type: "boolean" stringValue: type: "string" bytesValue: type: "string" format: "byte" pattern: "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" uint32Value: type: "integer" format: "int64" enumValue: $ref: "#/definitions/examplepbNumericEnum" pathEnumValue: $ref: "#/definitions/pathenumPathEnum" nestedPathEnumValue: $ref: "#/definitions/MessagePathEnumNestedPathEnum" sfixed32Value: type: "integer" format: "int32" sfixed64Value: type: "string" format: "int64" sint32Value: type: "integer" format: "int32" sint64Value: type: "string" format: "int64" repeatedStringValue: type: "array" items: type: "string" oneofEmpty: type: "object" properties: {} oneofString: type: "string" mapValue: type: "object" title: "map of numeric enum" additionalProperties: $ref: "#/definitions/examplepbNumericEnum" mappedStringValue: type: "object" description: "Map of string description." title: "Map of string title" additionalProperties: type: "string" mappedNestedValue: type: "object" additionalProperties: $ref: "#/definitions/ABitOfEverythingNested" nonConventionalNameValue: type: "string" timestampValue: type: "string" format: "date-time" repeatedEnumValue: type: "array" title: "repeated enum value. it is comma-separated in query" items: $ref: "#/definitions/examplepbNumericEnum" repeatedEnumAnnotation: type: "array" description: "Repeated numeric enum description." title: "Repeated numeric enum title" items: $ref: "#/definitions/examplepbNumericEnum" enumValueAnnotation: description: "Numeric enum description." title: "Numeric enum title" $ref: "#/definitions/examplepbNumericEnum" repeatedStringAnnotation: type: "array" description: "Repeated string description." title: "Repeated string title" items: type: "string" repeatedNestedAnnotation: type: "array" description: "Repeated nested object description." title: "Repeated nested object title" items: $ref: "#/definitions/ABitOfEverythingNested" nestedAnnotation: description: "Nested object description." title: "Nested object title" $ref: "#/definitions/ABitOfEverythingNested" int64OverrideType: type: "integer" format: "int64" requiredStringViaFieldBehaviorAnnotation: type: "string" title: "mark a field as required in Open API definition" outputOnlyStringViaFieldBehaviorAnnotation: type: "string" title: "mark a field as readonly in Open API definition" readOnly: true optionalStringValue: type: "string" productId: type: "array" description: "Only digits are allowed." title: "Test openapiv2 generation of repeated fields" items: type: "string" minLength: 1 maxLength: 19 pattern: "^[0-9]+$" optionalStringField: type: "string" title: "Test openapiv2 generation of required fields with annotation and jsonschema\ \ to reproduce" requiredStringField1: type: "string" requiredStringField2: type: "string" required_field_behavior_json_name_custom: type: "string" title: "Test openapiv2 handling of required json_name fields" required_field_schema_json_name_custom: type: "string" trailingOnly: type: "string" title: "Trailing only" trailingOnlyDot: type: "string" description: "Trailing only dot." trailingBoth: type: "string" description: "Trailing both." title: "Leading both" trailingMultiline: type: "string" description: "This is an example of a multi-line comment.\n\nTrailing multiline." title: "Leading multiline" uuids: type: "array" title: "Specify a custom format of repeated field items" items: type: "string" format: "uuid" description: "Intentionally complicated message type to cover many features of\ \ Protobuf." example: "{\"int64_value\":12,\"double_value\":12.3}" externalDocs: description: "More about gRPC-Gateway" url: "https://github.com/grpc-ecosystem/grpc-gateway" x-grpc-gateway-baz-list: - "one" - true x-grpc-gateway-foo: "bar" ================================================ FILE: examples/internal/clients/abe/api_a_bit_of_everything.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "context" "io/ioutil" "net/http" "net/url" "strings" "fmt" "github.com/antihax/optional" ) // Linger please var ( _ context.Context ) type ABitOfEverythingApiService service /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param value @return interface{} */ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckExternalNestedPathEnum(ctx context.Context, value string) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue interface{} ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v3/{value}:check" localVarPath = strings.Replace(localVarPath, "{"+"value"+"}", fmt.Sprintf("%v", value), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param value @return interface{} */ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckExternalPathEnum(ctx context.Context, value string) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue interface{} ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v2/{value}:check" localVarPath = strings.Replace(localVarPath, "{"+"value"+"}", fmt.Sprintf("%v", value), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param singleNestedName name is nested field. * @param uuid * @param floatValue Float value field * @param doubleValue * @param int64Value * @param requiredStringViaFieldBehaviorAnnotation mark a field as required in Open API definition * @param requiredStringField1 * @param requiredStringField2 * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields * @param requiredFieldSchemaJsonNameCustom * @param optional nil or *ABitOfEverythingServiceCheckGetQueryParamsOpts - Optional Parameters: * @param "SingleNestedAmount" (optional.Int64) - * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. * @param "Uint64Value" (optional.String) - * @param "Int32Value" (optional.Int32) - * @param "Fixed64Value" (optional.String) - * @param "Fixed32Value" (optional.Int64) - * @param "BoolValue" (optional.Bool) - * @param "StringValue" (optional.String) - * @param "BytesValue" (optional.String) - * @param "Uint32Value" (optional.Int64) - * @param "EnumValue" (optional.String) - - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "PathEnumValue" (optional.String) - * @param "NestedPathEnumValue" (optional.String) - * @param "Sfixed32Value" (optional.Int32) - * @param "Sfixed64Value" (optional.String) - * @param "Sint32Value" (optional.Int32) - * @param "Sint64Value" (optional.String) - * @param "RepeatedStringValue" (optional.Interface of []string) - * @param "OneofEmpty" (optional.Interface of map[string]string) - * @param "OneofString" (optional.String) - * @param "MapValue" (optional.Interface of interface{}) - map of numeric enum * @param "MappedStringValue" (optional.String) - Map of string title Map of string description. * @param "MappedNestedValue" (optional.Interface of interface{}) - * @param "NonConventionalNameValue" (optional.String) - * @param "TimestampValue" (optional.Time) - * @param "RepeatedEnumValue" (optional.Interface of []string) - repeated enum value. it is comma-separated in query - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "RepeatedEnumAnnotation" (optional.Interface of []string) - Repeated numeric enum title Repeated numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "EnumValueAnnotation" (optional.String) - Numeric enum title Numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "RepeatedStringAnnotation" (optional.Interface of []string) - Repeated string title Repeated string description. * @param "NestedAnnotationAmount" (optional.Int64) - * @param "NestedAnnotationOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. * @param "Int64OverrideType" (optional.Int64) - * @param "OutputOnlyStringViaFieldBehaviorAnnotation" (optional.String) - mark a field as readonly in Open API definition * @param "OptionalStringValue" (optional.String) - * @param "ProductId" (optional.Interface of []string) - Test openapiv2 generation of repeated fields Only digits are allowed. * @param "OptionalStringField" (optional.String) - Test openapiv2 generation of required fields with annotation and jsonschema to reproduce * @param "TrailingOnly" (optional.String) - Trailing only * @param "TrailingOnlyDot" (optional.String) - Trailing only dot. * @param "TrailingBoth" (optional.String) - Leading both Trailing both. * @param "TrailingMultiline" (optional.String) - Leading multiline This is an example of a multi-line comment. Trailing multiline. * @param "Uuids" (optional.Interface of []string) - Specify a custom format of repeated field items @return ExamplepbABitOfEverything */ type ABitOfEverythingServiceCheckGetQueryParamsOpts struct { SingleNestedAmount optional.Int64 SingleNestedOk optional.String Uint64Value optional.String Int32Value optional.Int32 Fixed64Value optional.String Fixed32Value optional.Int64 BoolValue optional.Bool StringValue optional.String BytesValue optional.String Uint32Value optional.Int64 EnumValue optional.String PathEnumValue optional.String NestedPathEnumValue optional.String Sfixed32Value optional.Int32 Sfixed64Value optional.String Sint32Value optional.Int32 Sint64Value optional.String RepeatedStringValue optional.Interface OneofEmpty optional.Interface OneofString optional.String MapValue optional.Interface MappedStringValue optional.String MappedNestedValue optional.Interface NonConventionalNameValue optional.String TimestampValue optional.Time RepeatedEnumValue optional.Interface RepeatedEnumAnnotation optional.Interface EnumValueAnnotation optional.String RepeatedStringAnnotation optional.Interface NestedAnnotationAmount optional.Int64 NestedAnnotationOk optional.String Int64OverrideType optional.Int64 OutputOnlyStringViaFieldBehaviorAnnotation optional.String OptionalStringValue optional.String ProductId optional.Interface OptionalStringField optional.String TrailingOnly optional.String TrailingOnlyDot optional.String TrailingBoth optional.String TrailingMultiline optional.String Uuids optional.Interface } func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckGetQueryParams(ctx context.Context, singleNestedName string, uuid string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceCheckGetQueryParamsOpts) (ExamplepbABitOfEverything, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbABitOfEverything ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/params/get/{singleNested.name}" localVarPath = strings.Replace(localVarPath, "{"+"singleNested.name"+"}", fmt.Sprintf("%v", singleNestedName), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.SingleNestedAmount.IsSet() { localVarQueryParams.Add("singleNested.amount", parameterToString(localVarOptionals.SingleNestedAmount.Value(), "")) } if localVarOptionals != nil && localVarOptionals.SingleNestedOk.IsSet() { localVarQueryParams.Add("singleNested.ok", parameterToString(localVarOptionals.SingleNestedOk.Value(), "")) } localVarQueryParams.Add("uuid", parameterToString(uuid, "")) localVarQueryParams.Add("floatValue", parameterToString(floatValue, "")) localVarQueryParams.Add("doubleValue", parameterToString(doubleValue, "")) localVarQueryParams.Add("int64Value", parameterToString(int64Value, "")) if localVarOptionals != nil && localVarOptionals.Uint64Value.IsSet() { localVarQueryParams.Add("uint64Value", parameterToString(localVarOptionals.Uint64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Int32Value.IsSet() { localVarQueryParams.Add("int32Value", parameterToString(localVarOptionals.Int32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Fixed64Value.IsSet() { localVarQueryParams.Add("fixed64Value", parameterToString(localVarOptionals.Fixed64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Fixed32Value.IsSet() { localVarQueryParams.Add("fixed32Value", parameterToString(localVarOptionals.Fixed32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.BoolValue.IsSet() { localVarQueryParams.Add("boolValue", parameterToString(localVarOptionals.BoolValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StringValue.IsSet() { localVarQueryParams.Add("stringValue", parameterToString(localVarOptionals.StringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.BytesValue.IsSet() { localVarQueryParams.Add("bytesValue", parameterToString(localVarOptionals.BytesValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Uint32Value.IsSet() { localVarQueryParams.Add("uint32Value", parameterToString(localVarOptionals.Uint32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.EnumValue.IsSet() { localVarQueryParams.Add("enumValue", parameterToString(localVarOptionals.EnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.PathEnumValue.IsSet() { localVarQueryParams.Add("pathEnumValue", parameterToString(localVarOptionals.PathEnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedPathEnumValue.IsSet() { localVarQueryParams.Add("nestedPathEnumValue", parameterToString(localVarOptionals.NestedPathEnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sfixed32Value.IsSet() { localVarQueryParams.Add("sfixed32Value", parameterToString(localVarOptionals.Sfixed32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sfixed64Value.IsSet() { localVarQueryParams.Add("sfixed64Value", parameterToString(localVarOptionals.Sfixed64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sint32Value.IsSet() { localVarQueryParams.Add("sint32Value", parameterToString(localVarOptionals.Sint32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sint64Value.IsSet() { localVarQueryParams.Add("sint64Value", parameterToString(localVarOptionals.Sint64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedStringValue.IsSet() { localVarQueryParams.Add("repeatedStringValue", parameterToString(localVarOptionals.RepeatedStringValue.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.OneofEmpty.IsSet() { localVarQueryParams.Add("oneofEmpty", parameterToString(localVarOptionals.OneofEmpty.Value(), "")) } if localVarOptionals != nil && localVarOptionals.OneofString.IsSet() { localVarQueryParams.Add("oneofString", parameterToString(localVarOptionals.OneofString.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MapValue.IsSet() { localVarQueryParams.Add("mapValue", parameterToString(localVarOptionals.MapValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MappedStringValue.IsSet() { localVarQueryParams.Add("mappedStringValue", parameterToString(localVarOptionals.MappedStringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MappedNestedValue.IsSet() { localVarQueryParams.Add("mappedNestedValue", parameterToString(localVarOptionals.MappedNestedValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NonConventionalNameValue.IsSet() { localVarQueryParams.Add("nonConventionalNameValue", parameterToString(localVarOptionals.NonConventionalNameValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TimestampValue.IsSet() { localVarQueryParams.Add("timestampValue", parameterToString(localVarOptionals.TimestampValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedEnumValue.IsSet() { localVarQueryParams.Add("repeatedEnumValue", parameterToString(localVarOptionals.RepeatedEnumValue.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.RepeatedEnumAnnotation.IsSet() { localVarQueryParams.Add("repeatedEnumAnnotation", parameterToString(localVarOptionals.RepeatedEnumAnnotation.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.EnumValueAnnotation.IsSet() { localVarQueryParams.Add("enumValueAnnotation", parameterToString(localVarOptionals.EnumValueAnnotation.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedStringAnnotation.IsSet() { localVarQueryParams.Add("repeatedStringAnnotation", parameterToString(localVarOptionals.RepeatedStringAnnotation.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationAmount.IsSet() { localVarQueryParams.Add("nestedAnnotation.amount", parameterToString(localVarOptionals.NestedAnnotationAmount.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationOk.IsSet() { localVarQueryParams.Add("nestedAnnotation.ok", parameterToString(localVarOptionals.NestedAnnotationOk.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Int64OverrideType.IsSet() { localVarQueryParams.Add("int64OverrideType", parameterToString(localVarOptionals.Int64OverrideType.Value(), "")) } localVarQueryParams.Add("requiredStringViaFieldBehaviorAnnotation", parameterToString(requiredStringViaFieldBehaviorAnnotation, "")) if localVarOptionals != nil && localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.IsSet() { localVarQueryParams.Add("outputOnlyStringViaFieldBehaviorAnnotation", parameterToString(localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.Value(), "")) } if localVarOptionals != nil && localVarOptionals.OptionalStringValue.IsSet() { localVarQueryParams.Add("optionalStringValue", parameterToString(localVarOptionals.OptionalStringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ProductId.IsSet() { localVarQueryParams.Add("productId", parameterToString(localVarOptionals.ProductId.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.OptionalStringField.IsSet() { localVarQueryParams.Add("optionalStringField", parameterToString(localVarOptionals.OptionalStringField.Value(), "")) } localVarQueryParams.Add("requiredStringField1", parameterToString(requiredStringField1, "")) localVarQueryParams.Add("requiredStringField2", parameterToString(requiredStringField2, "")) localVarQueryParams.Add("required_field_behavior_json_name_custom", parameterToString(requiredFieldBehaviorJsonNameCustom, "")) localVarQueryParams.Add("required_field_schema_json_name_custom", parameterToString(requiredFieldSchemaJsonNameCustom, "")) if localVarOptionals != nil && localVarOptionals.TrailingOnly.IsSet() { localVarQueryParams.Add("trailingOnly", parameterToString(localVarOptionals.TrailingOnly.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingOnlyDot.IsSet() { localVarQueryParams.Add("trailingOnlyDot", parameterToString(localVarOptionals.TrailingOnlyDot.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingBoth.IsSet() { localVarQueryParams.Add("trailingBoth", parameterToString(localVarOptionals.TrailingBoth.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingMultiline.IsSet() { localVarQueryParams.Add("trailingMultiline", parameterToString(localVarOptionals.TrailingMultiline.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Uuids.IsSet() { localVarQueryParams.Add("uuids", parameterToString(localVarOptionals.Uuids.Value(), "multi")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbABitOfEverything err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param singleNestedOk DeepEnum description. * @param uuid * @param floatValue Float value field * @param doubleValue * @param int64Value * @param requiredStringViaFieldBehaviorAnnotation mark a field as required in Open API definition * @param requiredStringField1 * @param requiredStringField2 * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields * @param requiredFieldSchemaJsonNameCustom * @param optional nil or *ABitOfEverythingServiceCheckNestedEnumGetQueryParamsOpts - Optional Parameters: * @param "SingleNestedName" (optional.String) - name is nested field. * @param "SingleNestedAmount" (optional.Int64) - * @param "Uint64Value" (optional.String) - * @param "Int32Value" (optional.Int32) - * @param "Fixed64Value" (optional.String) - * @param "Fixed32Value" (optional.Int64) - * @param "BoolValue" (optional.Bool) - * @param "StringValue" (optional.String) - * @param "BytesValue" (optional.String) - * @param "Uint32Value" (optional.Int64) - * @param "EnumValue" (optional.String) - - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "PathEnumValue" (optional.String) - * @param "NestedPathEnumValue" (optional.String) - * @param "Sfixed32Value" (optional.Int32) - * @param "Sfixed64Value" (optional.String) - * @param "Sint32Value" (optional.Int32) - * @param "Sint64Value" (optional.String) - * @param "RepeatedStringValue" (optional.Interface of []string) - * @param "OneofEmpty" (optional.Interface of map[string]string) - * @param "OneofString" (optional.String) - * @param "MapValue" (optional.Interface of interface{}) - map of numeric enum * @param "MappedStringValue" (optional.String) - Map of string title Map of string description. * @param "MappedNestedValue" (optional.Interface of interface{}) - * @param "NonConventionalNameValue" (optional.String) - * @param "TimestampValue" (optional.Time) - * @param "RepeatedEnumValue" (optional.Interface of []string) - repeated enum value. it is comma-separated in query - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "RepeatedEnumAnnotation" (optional.Interface of []string) - Repeated numeric enum title Repeated numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "EnumValueAnnotation" (optional.String) - Numeric enum title Numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "RepeatedStringAnnotation" (optional.Interface of []string) - Repeated string title Repeated string description. * @param "NestedAnnotationName" (optional.String) - name is nested field. * @param "NestedAnnotationAmount" (optional.Int64) - * @param "Int64OverrideType" (optional.Int64) - * @param "OutputOnlyStringViaFieldBehaviorAnnotation" (optional.String) - mark a field as readonly in Open API definition * @param "OptionalStringValue" (optional.String) - * @param "ProductId" (optional.Interface of []string) - Test openapiv2 generation of repeated fields Only digits are allowed. * @param "OptionalStringField" (optional.String) - Test openapiv2 generation of required fields with annotation and jsonschema to reproduce * @param "TrailingOnly" (optional.String) - Trailing only * @param "TrailingOnlyDot" (optional.String) - Trailing only dot. * @param "TrailingBoth" (optional.String) - Leading both Trailing both. * @param "TrailingMultiline" (optional.String) - Leading multiline This is an example of a multi-line comment. Trailing multiline. * @param "Uuids" (optional.Interface of []string) - Specify a custom format of repeated field items @return ExamplepbABitOfEverything */ type ABitOfEverythingServiceCheckNestedEnumGetQueryParamsOpts struct { SingleNestedName optional.String SingleNestedAmount optional.Int64 Uint64Value optional.String Int32Value optional.Int32 Fixed64Value optional.String Fixed32Value optional.Int64 BoolValue optional.Bool StringValue optional.String BytesValue optional.String Uint32Value optional.Int64 EnumValue optional.String PathEnumValue optional.String NestedPathEnumValue optional.String Sfixed32Value optional.Int32 Sfixed64Value optional.String Sint32Value optional.Int32 Sint64Value optional.String RepeatedStringValue optional.Interface OneofEmpty optional.Interface OneofString optional.String MapValue optional.Interface MappedStringValue optional.String MappedNestedValue optional.Interface NonConventionalNameValue optional.String TimestampValue optional.Time RepeatedEnumValue optional.Interface RepeatedEnumAnnotation optional.Interface EnumValueAnnotation optional.String RepeatedStringAnnotation optional.Interface NestedAnnotationName optional.String NestedAnnotationAmount optional.Int64 Int64OverrideType optional.Int64 OutputOnlyStringViaFieldBehaviorAnnotation optional.String OptionalStringValue optional.String ProductId optional.Interface OptionalStringField optional.String TrailingOnly optional.String TrailingOnlyDot optional.String TrailingBoth optional.String TrailingMultiline optional.String Uuids optional.Interface } func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckNestedEnumGetQueryParams(ctx context.Context, singleNestedOk string, uuid string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceCheckNestedEnumGetQueryParamsOpts) (ExamplepbABitOfEverything, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbABitOfEverything ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/params/get/nested_enum/{singleNested.ok}" localVarPath = strings.Replace(localVarPath, "{"+"singleNested.ok"+"}", fmt.Sprintf("%v", singleNestedOk), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.SingleNestedName.IsSet() { localVarQueryParams.Add("singleNested.name", parameterToString(localVarOptionals.SingleNestedName.Value(), "")) } if localVarOptionals != nil && localVarOptionals.SingleNestedAmount.IsSet() { localVarQueryParams.Add("singleNested.amount", parameterToString(localVarOptionals.SingleNestedAmount.Value(), "")) } localVarQueryParams.Add("uuid", parameterToString(uuid, "")) localVarQueryParams.Add("floatValue", parameterToString(floatValue, "")) localVarQueryParams.Add("doubleValue", parameterToString(doubleValue, "")) localVarQueryParams.Add("int64Value", parameterToString(int64Value, "")) if localVarOptionals != nil && localVarOptionals.Uint64Value.IsSet() { localVarQueryParams.Add("uint64Value", parameterToString(localVarOptionals.Uint64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Int32Value.IsSet() { localVarQueryParams.Add("int32Value", parameterToString(localVarOptionals.Int32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Fixed64Value.IsSet() { localVarQueryParams.Add("fixed64Value", parameterToString(localVarOptionals.Fixed64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Fixed32Value.IsSet() { localVarQueryParams.Add("fixed32Value", parameterToString(localVarOptionals.Fixed32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.BoolValue.IsSet() { localVarQueryParams.Add("boolValue", parameterToString(localVarOptionals.BoolValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StringValue.IsSet() { localVarQueryParams.Add("stringValue", parameterToString(localVarOptionals.StringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.BytesValue.IsSet() { localVarQueryParams.Add("bytesValue", parameterToString(localVarOptionals.BytesValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Uint32Value.IsSet() { localVarQueryParams.Add("uint32Value", parameterToString(localVarOptionals.Uint32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.EnumValue.IsSet() { localVarQueryParams.Add("enumValue", parameterToString(localVarOptionals.EnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.PathEnumValue.IsSet() { localVarQueryParams.Add("pathEnumValue", parameterToString(localVarOptionals.PathEnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedPathEnumValue.IsSet() { localVarQueryParams.Add("nestedPathEnumValue", parameterToString(localVarOptionals.NestedPathEnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sfixed32Value.IsSet() { localVarQueryParams.Add("sfixed32Value", parameterToString(localVarOptionals.Sfixed32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sfixed64Value.IsSet() { localVarQueryParams.Add("sfixed64Value", parameterToString(localVarOptionals.Sfixed64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sint32Value.IsSet() { localVarQueryParams.Add("sint32Value", parameterToString(localVarOptionals.Sint32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sint64Value.IsSet() { localVarQueryParams.Add("sint64Value", parameterToString(localVarOptionals.Sint64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedStringValue.IsSet() { localVarQueryParams.Add("repeatedStringValue", parameterToString(localVarOptionals.RepeatedStringValue.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.OneofEmpty.IsSet() { localVarQueryParams.Add("oneofEmpty", parameterToString(localVarOptionals.OneofEmpty.Value(), "")) } if localVarOptionals != nil && localVarOptionals.OneofString.IsSet() { localVarQueryParams.Add("oneofString", parameterToString(localVarOptionals.OneofString.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MapValue.IsSet() { localVarQueryParams.Add("mapValue", parameterToString(localVarOptionals.MapValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MappedStringValue.IsSet() { localVarQueryParams.Add("mappedStringValue", parameterToString(localVarOptionals.MappedStringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MappedNestedValue.IsSet() { localVarQueryParams.Add("mappedNestedValue", parameterToString(localVarOptionals.MappedNestedValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NonConventionalNameValue.IsSet() { localVarQueryParams.Add("nonConventionalNameValue", parameterToString(localVarOptionals.NonConventionalNameValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TimestampValue.IsSet() { localVarQueryParams.Add("timestampValue", parameterToString(localVarOptionals.TimestampValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedEnumValue.IsSet() { localVarQueryParams.Add("repeatedEnumValue", parameterToString(localVarOptionals.RepeatedEnumValue.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.RepeatedEnumAnnotation.IsSet() { localVarQueryParams.Add("repeatedEnumAnnotation", parameterToString(localVarOptionals.RepeatedEnumAnnotation.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.EnumValueAnnotation.IsSet() { localVarQueryParams.Add("enumValueAnnotation", parameterToString(localVarOptionals.EnumValueAnnotation.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedStringAnnotation.IsSet() { localVarQueryParams.Add("repeatedStringAnnotation", parameterToString(localVarOptionals.RepeatedStringAnnotation.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationName.IsSet() { localVarQueryParams.Add("nestedAnnotation.name", parameterToString(localVarOptionals.NestedAnnotationName.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationAmount.IsSet() { localVarQueryParams.Add("nestedAnnotation.amount", parameterToString(localVarOptionals.NestedAnnotationAmount.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Int64OverrideType.IsSet() { localVarQueryParams.Add("int64OverrideType", parameterToString(localVarOptionals.Int64OverrideType.Value(), "")) } localVarQueryParams.Add("requiredStringViaFieldBehaviorAnnotation", parameterToString(requiredStringViaFieldBehaviorAnnotation, "")) if localVarOptionals != nil && localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.IsSet() { localVarQueryParams.Add("outputOnlyStringViaFieldBehaviorAnnotation", parameterToString(localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.Value(), "")) } if localVarOptionals != nil && localVarOptionals.OptionalStringValue.IsSet() { localVarQueryParams.Add("optionalStringValue", parameterToString(localVarOptionals.OptionalStringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ProductId.IsSet() { localVarQueryParams.Add("productId", parameterToString(localVarOptionals.ProductId.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.OptionalStringField.IsSet() { localVarQueryParams.Add("optionalStringField", parameterToString(localVarOptionals.OptionalStringField.Value(), "")) } localVarQueryParams.Add("requiredStringField1", parameterToString(requiredStringField1, "")) localVarQueryParams.Add("requiredStringField2", parameterToString(requiredStringField2, "")) localVarQueryParams.Add("required_field_behavior_json_name_custom", parameterToString(requiredFieldBehaviorJsonNameCustom, "")) localVarQueryParams.Add("required_field_schema_json_name_custom", parameterToString(requiredFieldSchemaJsonNameCustom, "")) if localVarOptionals != nil && localVarOptionals.TrailingOnly.IsSet() { localVarQueryParams.Add("trailingOnly", parameterToString(localVarOptionals.TrailingOnly.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingOnlyDot.IsSet() { localVarQueryParams.Add("trailingOnlyDot", parameterToString(localVarOptionals.TrailingOnlyDot.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingBoth.IsSet() { localVarQueryParams.Add("trailingBoth", parameterToString(localVarOptionals.TrailingBoth.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingMultiline.IsSet() { localVarQueryParams.Add("trailingMultiline", parameterToString(localVarOptionals.TrailingMultiline.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Uuids.IsSet() { localVarQueryParams.Add("uuids", parameterToString(localVarOptionals.Uuids.Value(), "multi")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbABitOfEverything err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param stringValue * @param singleNested * @param uuid * @param floatValue Float value field * @param doubleValue * @param int64Value * @param requiredStringViaFieldBehaviorAnnotation mark a field as required in Open API definition * @param requiredStringField1 * @param requiredStringField2 * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields * @param requiredFieldSchemaJsonNameCustom * @param optional nil or *ABitOfEverythingServiceCheckPostQueryParamsOpts - Optional Parameters: * @param "Uint64Value" (optional.String) - * @param "Int32Value" (optional.Int32) - * @param "Fixed64Value" (optional.String) - * @param "Fixed32Value" (optional.Int64) - * @param "BoolValue" (optional.Bool) - * @param "BytesValue" (optional.String) - * @param "Uint32Value" (optional.Int64) - * @param "EnumValue" (optional.String) - - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "PathEnumValue" (optional.String) - * @param "NestedPathEnumValue" (optional.String) - * @param "Sfixed32Value" (optional.Int32) - * @param "Sfixed64Value" (optional.String) - * @param "Sint32Value" (optional.Int32) - * @param "Sint64Value" (optional.String) - * @param "RepeatedStringValue" (optional.Interface of []string) - * @param "OneofEmpty" (optional.Interface of map[string]string) - * @param "OneofString" (optional.String) - * @param "MapValue" (optional.Interface of interface{}) - map of numeric enum * @param "MappedStringValue" (optional.String) - Map of string title Map of string description. * @param "MappedNestedValue" (optional.Interface of interface{}) - * @param "NonConventionalNameValue" (optional.String) - * @param "TimestampValue" (optional.Time) - * @param "RepeatedEnumValue" (optional.Interface of []string) - repeated enum value. it is comma-separated in query - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "RepeatedEnumAnnotation" (optional.Interface of []string) - Repeated numeric enum title Repeated numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "EnumValueAnnotation" (optional.String) - Numeric enum title Numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "RepeatedStringAnnotation" (optional.Interface of []string) - Repeated string title Repeated string description. * @param "NestedAnnotationName" (optional.String) - name is nested field. * @param "NestedAnnotationAmount" (optional.Int64) - * @param "NestedAnnotationOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. * @param "Int64OverrideType" (optional.Int64) - * @param "OutputOnlyStringViaFieldBehaviorAnnotation" (optional.String) - mark a field as readonly in Open API definition * @param "OptionalStringValue" (optional.String) - * @param "ProductId" (optional.Interface of []string) - Test openapiv2 generation of repeated fields Only digits are allowed. * @param "OptionalStringField" (optional.String) - Test openapiv2 generation of required fields with annotation and jsonschema to reproduce * @param "TrailingOnly" (optional.String) - Trailing only * @param "TrailingOnlyDot" (optional.String) - Trailing only dot. * @param "TrailingBoth" (optional.String) - Leading both Trailing both. * @param "TrailingMultiline" (optional.String) - Leading multiline This is an example of a multi-line comment. Trailing multiline. * @param "Uuids" (optional.Interface of []string) - Specify a custom format of repeated field items @return ExamplepbABitOfEverything */ type ABitOfEverythingServiceCheckPostQueryParamsOpts struct { Uint64Value optional.String Int32Value optional.Int32 Fixed64Value optional.String Fixed32Value optional.Int64 BoolValue optional.Bool BytesValue optional.String Uint32Value optional.Int64 EnumValue optional.String PathEnumValue optional.String NestedPathEnumValue optional.String Sfixed32Value optional.Int32 Sfixed64Value optional.String Sint32Value optional.Int32 Sint64Value optional.String RepeatedStringValue optional.Interface OneofEmpty optional.Interface OneofString optional.String MapValue optional.Interface MappedStringValue optional.String MappedNestedValue optional.Interface NonConventionalNameValue optional.String TimestampValue optional.Time RepeatedEnumValue optional.Interface RepeatedEnumAnnotation optional.Interface EnumValueAnnotation optional.String RepeatedStringAnnotation optional.Interface NestedAnnotationName optional.String NestedAnnotationAmount optional.Int64 NestedAnnotationOk optional.String Int64OverrideType optional.Int64 OutputOnlyStringViaFieldBehaviorAnnotation optional.String OptionalStringValue optional.String ProductId optional.Interface OptionalStringField optional.String TrailingOnly optional.String TrailingOnlyDot optional.String TrailingBoth optional.String TrailingMultiline optional.String Uuids optional.Interface } func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckPostQueryParams(ctx context.Context, stringValue string, singleNested ABitOfEverythingNested, uuid string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceCheckPostQueryParamsOpts) (ExamplepbABitOfEverything, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbABitOfEverything ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/params/post/{stringValue}" localVarPath = strings.Replace(localVarPath, "{"+"stringValue"+"}", fmt.Sprintf("%v", stringValue), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} localVarQueryParams.Add("uuid", parameterToString(uuid, "")) localVarQueryParams.Add("floatValue", parameterToString(floatValue, "")) localVarQueryParams.Add("doubleValue", parameterToString(doubleValue, "")) localVarQueryParams.Add("int64Value", parameterToString(int64Value, "")) if localVarOptionals != nil && localVarOptionals.Uint64Value.IsSet() { localVarQueryParams.Add("uint64Value", parameterToString(localVarOptionals.Uint64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Int32Value.IsSet() { localVarQueryParams.Add("int32Value", parameterToString(localVarOptionals.Int32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Fixed64Value.IsSet() { localVarQueryParams.Add("fixed64Value", parameterToString(localVarOptionals.Fixed64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Fixed32Value.IsSet() { localVarQueryParams.Add("fixed32Value", parameterToString(localVarOptionals.Fixed32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.BoolValue.IsSet() { localVarQueryParams.Add("boolValue", parameterToString(localVarOptionals.BoolValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.BytesValue.IsSet() { localVarQueryParams.Add("bytesValue", parameterToString(localVarOptionals.BytesValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Uint32Value.IsSet() { localVarQueryParams.Add("uint32Value", parameterToString(localVarOptionals.Uint32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.EnumValue.IsSet() { localVarQueryParams.Add("enumValue", parameterToString(localVarOptionals.EnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.PathEnumValue.IsSet() { localVarQueryParams.Add("pathEnumValue", parameterToString(localVarOptionals.PathEnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedPathEnumValue.IsSet() { localVarQueryParams.Add("nestedPathEnumValue", parameterToString(localVarOptionals.NestedPathEnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sfixed32Value.IsSet() { localVarQueryParams.Add("sfixed32Value", parameterToString(localVarOptionals.Sfixed32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sfixed64Value.IsSet() { localVarQueryParams.Add("sfixed64Value", parameterToString(localVarOptionals.Sfixed64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sint32Value.IsSet() { localVarQueryParams.Add("sint32Value", parameterToString(localVarOptionals.Sint32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sint64Value.IsSet() { localVarQueryParams.Add("sint64Value", parameterToString(localVarOptionals.Sint64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedStringValue.IsSet() { localVarQueryParams.Add("repeatedStringValue", parameterToString(localVarOptionals.RepeatedStringValue.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.OneofEmpty.IsSet() { localVarQueryParams.Add("oneofEmpty", parameterToString(localVarOptionals.OneofEmpty.Value(), "")) } if localVarOptionals != nil && localVarOptionals.OneofString.IsSet() { localVarQueryParams.Add("oneofString", parameterToString(localVarOptionals.OneofString.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MapValue.IsSet() { localVarQueryParams.Add("mapValue", parameterToString(localVarOptionals.MapValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MappedStringValue.IsSet() { localVarQueryParams.Add("mappedStringValue", parameterToString(localVarOptionals.MappedStringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MappedNestedValue.IsSet() { localVarQueryParams.Add("mappedNestedValue", parameterToString(localVarOptionals.MappedNestedValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NonConventionalNameValue.IsSet() { localVarQueryParams.Add("nonConventionalNameValue", parameterToString(localVarOptionals.NonConventionalNameValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TimestampValue.IsSet() { localVarQueryParams.Add("timestampValue", parameterToString(localVarOptionals.TimestampValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedEnumValue.IsSet() { localVarQueryParams.Add("repeatedEnumValue", parameterToString(localVarOptionals.RepeatedEnumValue.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.RepeatedEnumAnnotation.IsSet() { localVarQueryParams.Add("repeatedEnumAnnotation", parameterToString(localVarOptionals.RepeatedEnumAnnotation.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.EnumValueAnnotation.IsSet() { localVarQueryParams.Add("enumValueAnnotation", parameterToString(localVarOptionals.EnumValueAnnotation.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedStringAnnotation.IsSet() { localVarQueryParams.Add("repeatedStringAnnotation", parameterToString(localVarOptionals.RepeatedStringAnnotation.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationName.IsSet() { localVarQueryParams.Add("nestedAnnotation.name", parameterToString(localVarOptionals.NestedAnnotationName.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationAmount.IsSet() { localVarQueryParams.Add("nestedAnnotation.amount", parameterToString(localVarOptionals.NestedAnnotationAmount.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationOk.IsSet() { localVarQueryParams.Add("nestedAnnotation.ok", parameterToString(localVarOptionals.NestedAnnotationOk.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Int64OverrideType.IsSet() { localVarQueryParams.Add("int64OverrideType", parameterToString(localVarOptionals.Int64OverrideType.Value(), "")) } localVarQueryParams.Add("requiredStringViaFieldBehaviorAnnotation", parameterToString(requiredStringViaFieldBehaviorAnnotation, "")) if localVarOptionals != nil && localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.IsSet() { localVarQueryParams.Add("outputOnlyStringViaFieldBehaviorAnnotation", parameterToString(localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.Value(), "")) } if localVarOptionals != nil && localVarOptionals.OptionalStringValue.IsSet() { localVarQueryParams.Add("optionalStringValue", parameterToString(localVarOptionals.OptionalStringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ProductId.IsSet() { localVarQueryParams.Add("productId", parameterToString(localVarOptionals.ProductId.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.OptionalStringField.IsSet() { localVarQueryParams.Add("optionalStringField", parameterToString(localVarOptionals.OptionalStringField.Value(), "")) } localVarQueryParams.Add("requiredStringField1", parameterToString(requiredStringField1, "")) localVarQueryParams.Add("requiredStringField2", parameterToString(requiredStringField2, "")) localVarQueryParams.Add("required_field_behavior_json_name_custom", parameterToString(requiredFieldBehaviorJsonNameCustom, "")) localVarQueryParams.Add("required_field_schema_json_name_custom", parameterToString(requiredFieldSchemaJsonNameCustom, "")) if localVarOptionals != nil && localVarOptionals.TrailingOnly.IsSet() { localVarQueryParams.Add("trailingOnly", parameterToString(localVarOptionals.TrailingOnly.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingOnlyDot.IsSet() { localVarQueryParams.Add("trailingOnlyDot", parameterToString(localVarOptionals.TrailingOnlyDot.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingBoth.IsSet() { localVarQueryParams.Add("trailingBoth", parameterToString(localVarOptionals.TrailingBoth.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingMultiline.IsSet() { localVarQueryParams.Add("trailingMultiline", parameterToString(localVarOptionals.TrailingMultiline.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Uuids.IsSet() { localVarQueryParams.Add("uuids", parameterToString(localVarOptionals.Uuids.Value(), "multi")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &singleNested if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbABitOfEverything err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @return ExamplepbCheckStatusResponse */ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCheckStatus(ctx context.Context) (ExamplepbCheckStatusResponse, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbCheckStatusResponse ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/checkStatus" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbCheckStatusResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService Create a new ABitOfEverything This API creates a new ABitOfEverything * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param floatValue Float value field * @param doubleValue * @param int64Value * @param uint64Value * @param int32Value * @param fixed64Value * @param fixed32Value * @param boolValue * @param stringValue * @param uint32Value * @param sfixed32Value * @param sfixed64Value * @param sint32Value * @param sint64Value * @param nonConventionalNameValue * @param enumValue * @param pathEnumValue * @param nestedPathEnumValue * @param enumValueAnnotation Numeric enum description. * @param uuid * @param requiredStringViaFieldBehaviorAnnotation mark a field as required in Open API definition * @param requiredStringField1 * @param requiredStringField2 * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields * @param requiredFieldSchemaJsonNameCustom * @param optional nil or *ABitOfEverythingServiceCreateOpts - Optional Parameters: * @param "SingleNestedName" (optional.String) - name is nested field. * @param "SingleNestedAmount" (optional.Int64) - * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. * @param "BytesValue" (optional.String) - * @param "RepeatedStringValue" (optional.Interface of []string) - * @param "OneofEmpty" (optional.Interface of map[string]string) - * @param "OneofString" (optional.String) - * @param "MapValue" (optional.Interface of interface{}) - map of numeric enum * @param "MappedStringValue" (optional.String) - Map of string title Map of string description. * @param "MappedNestedValue" (optional.Interface of interface{}) - * @param "TimestampValue" (optional.Time) - * @param "RepeatedEnumValue" (optional.Interface of []string) - repeated enum value. it is comma-separated in query - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "RepeatedEnumAnnotation" (optional.Interface of []string) - Repeated numeric enum title Repeated numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "RepeatedStringAnnotation" (optional.Interface of []string) - Repeated string title Repeated string description. * @param "NestedAnnotationName" (optional.String) - name is nested field. * @param "NestedAnnotationAmount" (optional.Int64) - * @param "NestedAnnotationOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. * @param "Int64OverrideType" (optional.Int64) - * @param "OutputOnlyStringViaFieldBehaviorAnnotation" (optional.String) - mark a field as readonly in Open API definition * @param "OptionalStringValue" (optional.String) - * @param "ProductId" (optional.Interface of []string) - Test openapiv2 generation of repeated fields Only digits are allowed. * @param "OptionalStringField" (optional.String) - Test openapiv2 generation of required fields with annotation and jsonschema to reproduce * @param "TrailingOnly" (optional.String) - Trailing only * @param "TrailingOnlyDot" (optional.String) - Trailing only dot. * @param "TrailingBoth" (optional.String) - Leading both Trailing both. * @param "TrailingMultiline" (optional.String) - Leading multiline This is an example of a multi-line comment. Trailing multiline. * @param "Uuids" (optional.Interface of []string) - Specify a custom format of repeated field items @return ExamplepbABitOfEverything */ type ABitOfEverythingServiceCreateOpts struct { SingleNestedName optional.String SingleNestedAmount optional.Int64 SingleNestedOk optional.String BytesValue optional.String RepeatedStringValue optional.Interface OneofEmpty optional.Interface OneofString optional.String MapValue optional.Interface MappedStringValue optional.String MappedNestedValue optional.Interface TimestampValue optional.Time RepeatedEnumValue optional.Interface RepeatedEnumAnnotation optional.Interface RepeatedStringAnnotation optional.Interface NestedAnnotationName optional.String NestedAnnotationAmount optional.Int64 NestedAnnotationOk optional.String Int64OverrideType optional.Int64 OutputOnlyStringViaFieldBehaviorAnnotation optional.String OptionalStringValue optional.String ProductId optional.Interface OptionalStringField optional.String TrailingOnly optional.String TrailingOnlyDot optional.String TrailingBoth optional.String TrailingMultiline optional.String Uuids optional.Interface } func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCreate(ctx context.Context, floatValue float32, doubleValue float64, int64Value string, uint64Value string, int32Value int32, fixed64Value string, fixed32Value int64, boolValue bool, stringValue string, uint32Value int64, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, nonConventionalNameValue string, enumValue string, pathEnumValue string, nestedPathEnumValue string, enumValueAnnotation string, uuid string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceCreateOpts) (ExamplepbABitOfEverything, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbABitOfEverything ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/{floatValue}/{doubleValue}/{int64Value}/separator/{uint64Value}/{int32Value}/{fixed64Value}/{fixed32Value}/{boolValue}/{stringValue}/{uint32Value}/{sfixed32Value}/{sfixed64Value}/{sint32Value}/{sint64Value}/{nonConventionalNameValue}/{enumValue}/{pathEnumValue}/{nestedPathEnumValue}/{enumValueAnnotation}" localVarPath = strings.Replace(localVarPath, "{"+"floatValue"+"}", fmt.Sprintf("%v", floatValue), -1) localVarPath = strings.Replace(localVarPath, "{"+"doubleValue"+"}", fmt.Sprintf("%v", doubleValue), -1) localVarPath = strings.Replace(localVarPath, "{"+"int64Value"+"}", fmt.Sprintf("%v", int64Value), -1) localVarPath = strings.Replace(localVarPath, "{"+"uint64Value"+"}", fmt.Sprintf("%v", uint64Value), -1) localVarPath = strings.Replace(localVarPath, "{"+"int32Value"+"}", fmt.Sprintf("%v", int32Value), -1) localVarPath = strings.Replace(localVarPath, "{"+"fixed64Value"+"}", fmt.Sprintf("%v", fixed64Value), -1) localVarPath = strings.Replace(localVarPath, "{"+"fixed32Value"+"}", fmt.Sprintf("%v", fixed32Value), -1) localVarPath = strings.Replace(localVarPath, "{"+"boolValue"+"}", fmt.Sprintf("%v", boolValue), -1) localVarPath = strings.Replace(localVarPath, "{"+"stringValue"+"}", fmt.Sprintf("%v", stringValue), -1) localVarPath = strings.Replace(localVarPath, "{"+"uint32Value"+"}", fmt.Sprintf("%v", uint32Value), -1) localVarPath = strings.Replace(localVarPath, "{"+"sfixed32Value"+"}", fmt.Sprintf("%v", sfixed32Value), -1) localVarPath = strings.Replace(localVarPath, "{"+"sfixed64Value"+"}", fmt.Sprintf("%v", sfixed64Value), -1) localVarPath = strings.Replace(localVarPath, "{"+"sint32Value"+"}", fmt.Sprintf("%v", sint32Value), -1) localVarPath = strings.Replace(localVarPath, "{"+"sint64Value"+"}", fmt.Sprintf("%v", sint64Value), -1) localVarPath = strings.Replace(localVarPath, "{"+"nonConventionalNameValue"+"}", fmt.Sprintf("%v", nonConventionalNameValue), -1) localVarPath = strings.Replace(localVarPath, "{"+"enumValue"+"}", fmt.Sprintf("%v", enumValue), -1) localVarPath = strings.Replace(localVarPath, "{"+"pathEnumValue"+"}", fmt.Sprintf("%v", pathEnumValue), -1) localVarPath = strings.Replace(localVarPath, "{"+"nestedPathEnumValue"+"}", fmt.Sprintf("%v", nestedPathEnumValue), -1) localVarPath = strings.Replace(localVarPath, "{"+"enumValueAnnotation"+"}", fmt.Sprintf("%v", enumValueAnnotation), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.SingleNestedName.IsSet() { localVarQueryParams.Add("singleNested.name", parameterToString(localVarOptionals.SingleNestedName.Value(), "")) } if localVarOptionals != nil && localVarOptionals.SingleNestedAmount.IsSet() { localVarQueryParams.Add("singleNested.amount", parameterToString(localVarOptionals.SingleNestedAmount.Value(), "")) } if localVarOptionals != nil && localVarOptionals.SingleNestedOk.IsSet() { localVarQueryParams.Add("singleNested.ok", parameterToString(localVarOptionals.SingleNestedOk.Value(), "")) } localVarQueryParams.Add("uuid", parameterToString(uuid, "")) if localVarOptionals != nil && localVarOptionals.BytesValue.IsSet() { localVarQueryParams.Add("bytesValue", parameterToString(localVarOptionals.BytesValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedStringValue.IsSet() { localVarQueryParams.Add("repeatedStringValue", parameterToString(localVarOptionals.RepeatedStringValue.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.OneofEmpty.IsSet() { localVarQueryParams.Add("oneofEmpty", parameterToString(localVarOptionals.OneofEmpty.Value(), "")) } if localVarOptionals != nil && localVarOptionals.OneofString.IsSet() { localVarQueryParams.Add("oneofString", parameterToString(localVarOptionals.OneofString.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MapValue.IsSet() { localVarQueryParams.Add("mapValue", parameterToString(localVarOptionals.MapValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MappedStringValue.IsSet() { localVarQueryParams.Add("mappedStringValue", parameterToString(localVarOptionals.MappedStringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MappedNestedValue.IsSet() { localVarQueryParams.Add("mappedNestedValue", parameterToString(localVarOptionals.MappedNestedValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TimestampValue.IsSet() { localVarQueryParams.Add("timestampValue", parameterToString(localVarOptionals.TimestampValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedEnumValue.IsSet() { localVarQueryParams.Add("repeatedEnumValue", parameterToString(localVarOptionals.RepeatedEnumValue.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.RepeatedEnumAnnotation.IsSet() { localVarQueryParams.Add("repeatedEnumAnnotation", parameterToString(localVarOptionals.RepeatedEnumAnnotation.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.RepeatedStringAnnotation.IsSet() { localVarQueryParams.Add("repeatedStringAnnotation", parameterToString(localVarOptionals.RepeatedStringAnnotation.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationName.IsSet() { localVarQueryParams.Add("nestedAnnotation.name", parameterToString(localVarOptionals.NestedAnnotationName.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationAmount.IsSet() { localVarQueryParams.Add("nestedAnnotation.amount", parameterToString(localVarOptionals.NestedAnnotationAmount.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationOk.IsSet() { localVarQueryParams.Add("nestedAnnotation.ok", parameterToString(localVarOptionals.NestedAnnotationOk.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Int64OverrideType.IsSet() { localVarQueryParams.Add("int64OverrideType", parameterToString(localVarOptionals.Int64OverrideType.Value(), "")) } localVarQueryParams.Add("requiredStringViaFieldBehaviorAnnotation", parameterToString(requiredStringViaFieldBehaviorAnnotation, "")) if localVarOptionals != nil && localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.IsSet() { localVarQueryParams.Add("outputOnlyStringViaFieldBehaviorAnnotation", parameterToString(localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.Value(), "")) } if localVarOptionals != nil && localVarOptionals.OptionalStringValue.IsSet() { localVarQueryParams.Add("optionalStringValue", parameterToString(localVarOptionals.OptionalStringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ProductId.IsSet() { localVarQueryParams.Add("productId", parameterToString(localVarOptionals.ProductId.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.OptionalStringField.IsSet() { localVarQueryParams.Add("optionalStringField", parameterToString(localVarOptionals.OptionalStringField.Value(), "")) } localVarQueryParams.Add("requiredStringField1", parameterToString(requiredStringField1, "")) localVarQueryParams.Add("requiredStringField2", parameterToString(requiredStringField2, "")) localVarQueryParams.Add("required_field_behavior_json_name_custom", parameterToString(requiredFieldBehaviorJsonNameCustom, "")) localVarQueryParams.Add("required_field_schema_json_name_custom", parameterToString(requiredFieldSchemaJsonNameCustom, "")) if localVarOptionals != nil && localVarOptionals.TrailingOnly.IsSet() { localVarQueryParams.Add("trailingOnly", parameterToString(localVarOptionals.TrailingOnly.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingOnlyDot.IsSet() { localVarQueryParams.Add("trailingOnlyDot", parameterToString(localVarOptionals.TrailingOnlyDot.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingBoth.IsSet() { localVarQueryParams.Add("trailingBoth", parameterToString(localVarOptionals.TrailingBoth.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingMultiline.IsSet() { localVarQueryParams.Add("trailingMultiline", parameterToString(localVarOptionals.TrailingMultiline.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Uuids.IsSet() { localVarQueryParams.Add("uuids", parameterToString(localVarOptionals.Uuids.Value(), "multi")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbABitOfEverything err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param body Intentionally complicated message type to cover many features of Protobuf. @return ExamplepbABitOfEverything */ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCreateBody(ctx context.Context, body ExamplepbABitOfEverything) (ExamplepbABitOfEverything, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbABitOfEverything ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbABitOfEverything err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService Create a book. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param parent The publisher in which to create the book. Format: `publishers/{publisher}` Example: `publishers/1257894000000000000` * @param book The book to create. * @param optional nil or *ABitOfEverythingServiceCreateBookOpts - Optional Parameters: * @param "BookId" (optional.String) - The ID to use for the book. This must start with an alphanumeric character. @return ExamplepbBook */ type ABitOfEverythingServiceCreateBookOpts struct { BookId optional.String } func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCreateBook(ctx context.Context, parent string, book ExamplepbBook, localVarOptionals *ABitOfEverythingServiceCreateBookOpts) (ExamplepbBook, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbBook ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/{parent}/books" localVarPath = strings.Replace(localVarPath, "{"+"parent"+"}", fmt.Sprintf("%v", parent), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.BookId.IsSet() { localVarQueryParams.Add("bookId", parameterToString(localVarOptionals.BookId.Value(), "")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &book if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbBook err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuidName * @param floatValue Float value field * @param doubleValue * @param int64Value * @param requiredStringViaFieldBehaviorAnnotation mark a field as required in Open API definition * @param requiredStringField1 * @param requiredStringField2 * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields * @param requiredFieldSchemaJsonNameCustom * @param optional nil or *ABitOfEverythingServiceCustomOpts - Optional Parameters: * @param "SingleNestedName" (optional.String) - name is nested field. * @param "SingleNestedAmount" (optional.Int64) - * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. * @param "Uint64Value" (optional.String) - * @param "Int32Value" (optional.Int32) - * @param "Fixed64Value" (optional.String) - * @param "Fixed32Value" (optional.Int64) - * @param "BoolValue" (optional.Bool) - * @param "StringValue" (optional.String) - * @param "BytesValue" (optional.String) - * @param "Uint32Value" (optional.Int64) - * @param "EnumValue" (optional.String) - - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "PathEnumValue" (optional.String) - * @param "NestedPathEnumValue" (optional.String) - * @param "Sfixed32Value" (optional.Int32) - * @param "Sfixed64Value" (optional.String) - * @param "Sint32Value" (optional.Int32) - * @param "Sint64Value" (optional.String) - * @param "RepeatedStringValue" (optional.Interface of []string) - * @param "OneofEmpty" (optional.Interface of map[string]string) - * @param "OneofString" (optional.String) - * @param "MapValue" (optional.Interface of interface{}) - map of numeric enum * @param "MappedStringValue" (optional.String) - Map of string title Map of string description. * @param "MappedNestedValue" (optional.Interface of interface{}) - * @param "NonConventionalNameValue" (optional.String) - * @param "TimestampValue" (optional.Time) - * @param "RepeatedEnumValue" (optional.Interface of []string) - repeated enum value. it is comma-separated in query - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "RepeatedEnumAnnotation" (optional.Interface of []string) - Repeated numeric enum title Repeated numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "EnumValueAnnotation" (optional.String) - Numeric enum title Numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "RepeatedStringAnnotation" (optional.Interface of []string) - Repeated string title Repeated string description. * @param "NestedAnnotationName" (optional.String) - name is nested field. * @param "NestedAnnotationAmount" (optional.Int64) - * @param "NestedAnnotationOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. * @param "Int64OverrideType" (optional.Int64) - * @param "OutputOnlyStringViaFieldBehaviorAnnotation" (optional.String) - mark a field as readonly in Open API definition * @param "OptionalStringValue" (optional.String) - * @param "ProductId" (optional.Interface of []string) - Test openapiv2 generation of repeated fields Only digits are allowed. * @param "OptionalStringField" (optional.String) - Test openapiv2 generation of required fields with annotation and jsonschema to reproduce * @param "TrailingOnly" (optional.String) - Trailing only * @param "TrailingOnlyDot" (optional.String) - Trailing only dot. * @param "TrailingBoth" (optional.String) - Leading both Trailing both. * @param "TrailingMultiline" (optional.String) - Leading multiline This is an example of a multi-line comment. Trailing multiline. * @param "Uuids" (optional.Interface of []string) - Specify a custom format of repeated field items @return ExamplepbABitOfEverything */ type ABitOfEverythingServiceCustomOpts struct { SingleNestedName optional.String SingleNestedAmount optional.Int64 SingleNestedOk optional.String Uint64Value optional.String Int32Value optional.Int32 Fixed64Value optional.String Fixed32Value optional.Int64 BoolValue optional.Bool StringValue optional.String BytesValue optional.String Uint32Value optional.Int64 EnumValue optional.String PathEnumValue optional.String NestedPathEnumValue optional.String Sfixed32Value optional.Int32 Sfixed64Value optional.String Sint32Value optional.Int32 Sint64Value optional.String RepeatedStringValue optional.Interface OneofEmpty optional.Interface OneofString optional.String MapValue optional.Interface MappedStringValue optional.String MappedNestedValue optional.Interface NonConventionalNameValue optional.String TimestampValue optional.Time RepeatedEnumValue optional.Interface RepeatedEnumAnnotation optional.Interface EnumValueAnnotation optional.String RepeatedStringAnnotation optional.Interface NestedAnnotationName optional.String NestedAnnotationAmount optional.Int64 NestedAnnotationOk optional.String Int64OverrideType optional.Int64 OutputOnlyStringViaFieldBehaviorAnnotation optional.String OptionalStringValue optional.String ProductId optional.Interface OptionalStringField optional.String TrailingOnly optional.String TrailingOnlyDot optional.String TrailingBoth optional.String TrailingMultiline optional.String Uuids optional.Interface } func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCustom(ctx context.Context, uuidName string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceCustomOpts) (ExamplepbABitOfEverything, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbABitOfEverything ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/{uuidName}:custom" localVarPath = strings.Replace(localVarPath, "{"+"uuidName"+"}", fmt.Sprintf("%v", uuidName), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.SingleNestedName.IsSet() { localVarQueryParams.Add("singleNested.name", parameterToString(localVarOptionals.SingleNestedName.Value(), "")) } if localVarOptionals != nil && localVarOptionals.SingleNestedAmount.IsSet() { localVarQueryParams.Add("singleNested.amount", parameterToString(localVarOptionals.SingleNestedAmount.Value(), "")) } if localVarOptionals != nil && localVarOptionals.SingleNestedOk.IsSet() { localVarQueryParams.Add("singleNested.ok", parameterToString(localVarOptionals.SingleNestedOk.Value(), "")) } localVarQueryParams.Add("floatValue", parameterToString(floatValue, "")) localVarQueryParams.Add("doubleValue", parameterToString(doubleValue, "")) localVarQueryParams.Add("int64Value", parameterToString(int64Value, "")) if localVarOptionals != nil && localVarOptionals.Uint64Value.IsSet() { localVarQueryParams.Add("uint64Value", parameterToString(localVarOptionals.Uint64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Int32Value.IsSet() { localVarQueryParams.Add("int32Value", parameterToString(localVarOptionals.Int32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Fixed64Value.IsSet() { localVarQueryParams.Add("fixed64Value", parameterToString(localVarOptionals.Fixed64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Fixed32Value.IsSet() { localVarQueryParams.Add("fixed32Value", parameterToString(localVarOptionals.Fixed32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.BoolValue.IsSet() { localVarQueryParams.Add("boolValue", parameterToString(localVarOptionals.BoolValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StringValue.IsSet() { localVarQueryParams.Add("stringValue", parameterToString(localVarOptionals.StringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.BytesValue.IsSet() { localVarQueryParams.Add("bytesValue", parameterToString(localVarOptionals.BytesValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Uint32Value.IsSet() { localVarQueryParams.Add("uint32Value", parameterToString(localVarOptionals.Uint32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.EnumValue.IsSet() { localVarQueryParams.Add("enumValue", parameterToString(localVarOptionals.EnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.PathEnumValue.IsSet() { localVarQueryParams.Add("pathEnumValue", parameterToString(localVarOptionals.PathEnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedPathEnumValue.IsSet() { localVarQueryParams.Add("nestedPathEnumValue", parameterToString(localVarOptionals.NestedPathEnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sfixed32Value.IsSet() { localVarQueryParams.Add("sfixed32Value", parameterToString(localVarOptionals.Sfixed32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sfixed64Value.IsSet() { localVarQueryParams.Add("sfixed64Value", parameterToString(localVarOptionals.Sfixed64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sint32Value.IsSet() { localVarQueryParams.Add("sint32Value", parameterToString(localVarOptionals.Sint32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sint64Value.IsSet() { localVarQueryParams.Add("sint64Value", parameterToString(localVarOptionals.Sint64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedStringValue.IsSet() { localVarQueryParams.Add("repeatedStringValue", parameterToString(localVarOptionals.RepeatedStringValue.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.OneofEmpty.IsSet() { localVarQueryParams.Add("oneofEmpty", parameterToString(localVarOptionals.OneofEmpty.Value(), "")) } if localVarOptionals != nil && localVarOptionals.OneofString.IsSet() { localVarQueryParams.Add("oneofString", parameterToString(localVarOptionals.OneofString.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MapValue.IsSet() { localVarQueryParams.Add("mapValue", parameterToString(localVarOptionals.MapValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MappedStringValue.IsSet() { localVarQueryParams.Add("mappedStringValue", parameterToString(localVarOptionals.MappedStringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MappedNestedValue.IsSet() { localVarQueryParams.Add("mappedNestedValue", parameterToString(localVarOptionals.MappedNestedValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NonConventionalNameValue.IsSet() { localVarQueryParams.Add("nonConventionalNameValue", parameterToString(localVarOptionals.NonConventionalNameValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TimestampValue.IsSet() { localVarQueryParams.Add("timestampValue", parameterToString(localVarOptionals.TimestampValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedEnumValue.IsSet() { localVarQueryParams.Add("repeatedEnumValue", parameterToString(localVarOptionals.RepeatedEnumValue.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.RepeatedEnumAnnotation.IsSet() { localVarQueryParams.Add("repeatedEnumAnnotation", parameterToString(localVarOptionals.RepeatedEnumAnnotation.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.EnumValueAnnotation.IsSet() { localVarQueryParams.Add("enumValueAnnotation", parameterToString(localVarOptionals.EnumValueAnnotation.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedStringAnnotation.IsSet() { localVarQueryParams.Add("repeatedStringAnnotation", parameterToString(localVarOptionals.RepeatedStringAnnotation.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationName.IsSet() { localVarQueryParams.Add("nestedAnnotation.name", parameterToString(localVarOptionals.NestedAnnotationName.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationAmount.IsSet() { localVarQueryParams.Add("nestedAnnotation.amount", parameterToString(localVarOptionals.NestedAnnotationAmount.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationOk.IsSet() { localVarQueryParams.Add("nestedAnnotation.ok", parameterToString(localVarOptionals.NestedAnnotationOk.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Int64OverrideType.IsSet() { localVarQueryParams.Add("int64OverrideType", parameterToString(localVarOptionals.Int64OverrideType.Value(), "")) } localVarQueryParams.Add("requiredStringViaFieldBehaviorAnnotation", parameterToString(requiredStringViaFieldBehaviorAnnotation, "")) if localVarOptionals != nil && localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.IsSet() { localVarQueryParams.Add("outputOnlyStringViaFieldBehaviorAnnotation", parameterToString(localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.Value(), "")) } if localVarOptionals != nil && localVarOptionals.OptionalStringValue.IsSet() { localVarQueryParams.Add("optionalStringValue", parameterToString(localVarOptionals.OptionalStringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ProductId.IsSet() { localVarQueryParams.Add("productId", parameterToString(localVarOptionals.ProductId.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.OptionalStringField.IsSet() { localVarQueryParams.Add("optionalStringField", parameterToString(localVarOptionals.OptionalStringField.Value(), "")) } localVarQueryParams.Add("requiredStringField1", parameterToString(requiredStringField1, "")) localVarQueryParams.Add("requiredStringField2", parameterToString(requiredStringField2, "")) localVarQueryParams.Add("required_field_behavior_json_name_custom", parameterToString(requiredFieldBehaviorJsonNameCustom, "")) localVarQueryParams.Add("required_field_schema_json_name_custom", parameterToString(requiredFieldSchemaJsonNameCustom, "")) if localVarOptionals != nil && localVarOptionals.TrailingOnly.IsSet() { localVarQueryParams.Add("trailingOnly", parameterToString(localVarOptionals.TrailingOnly.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingOnlyDot.IsSet() { localVarQueryParams.Add("trailingOnlyDot", parameterToString(localVarOptionals.TrailingOnlyDot.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingBoth.IsSet() { localVarQueryParams.Add("trailingBoth", parameterToString(localVarOptionals.TrailingBoth.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingMultiline.IsSet() { localVarQueryParams.Add("trailingMultiline", parameterToString(localVarOptionals.TrailingMultiline.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Uuids.IsSet() { localVarQueryParams.Add("uuids", parameterToString(localVarOptionals.Uuids.Value(), "multi")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbABitOfEverything err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param optionalStringValue * @param uuid * @param floatValue Float value field * @param doubleValue * @param int64Value * @param requiredStringViaFieldBehaviorAnnotation mark a field as required in Open API definition * @param requiredStringField1 * @param requiredStringField2 * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields * @param requiredFieldSchemaJsonNameCustom * @param optional nil or *ABitOfEverythingServiceCustom2Opts - Optional Parameters: * @param "SingleNestedName" (optional.String) - name is nested field. * @param "SingleNestedAmount" (optional.Int64) - * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. * @param "Uint64Value" (optional.String) - * @param "Int32Value" (optional.Int32) - * @param "Fixed64Value" (optional.String) - * @param "Fixed32Value" (optional.Int64) - * @param "BoolValue" (optional.Bool) - * @param "StringValue" (optional.String) - * @param "BytesValue" (optional.String) - * @param "Uint32Value" (optional.Int64) - * @param "EnumValue" (optional.String) - - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "PathEnumValue" (optional.String) - * @param "NestedPathEnumValue" (optional.String) - * @param "Sfixed32Value" (optional.Int32) - * @param "Sfixed64Value" (optional.String) - * @param "Sint32Value" (optional.Int32) - * @param "Sint64Value" (optional.String) - * @param "RepeatedStringValue" (optional.Interface of []string) - * @param "OneofEmpty" (optional.Interface of map[string]string) - * @param "OneofString" (optional.String) - * @param "MapValue" (optional.Interface of interface{}) - map of numeric enum * @param "MappedStringValue" (optional.String) - Map of string title Map of string description. * @param "MappedNestedValue" (optional.Interface of interface{}) - * @param "NonConventionalNameValue" (optional.String) - * @param "TimestampValue" (optional.Time) - * @param "RepeatedEnumValue" (optional.Interface of []string) - repeated enum value. it is comma-separated in query - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "RepeatedEnumAnnotation" (optional.Interface of []string) - Repeated numeric enum title Repeated numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "EnumValueAnnotation" (optional.String) - Numeric enum title Numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "RepeatedStringAnnotation" (optional.Interface of []string) - Repeated string title Repeated string description. * @param "NestedAnnotationName" (optional.String) - name is nested field. * @param "NestedAnnotationAmount" (optional.Int64) - * @param "NestedAnnotationOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. * @param "Int64OverrideType" (optional.Int64) - * @param "OutputOnlyStringViaFieldBehaviorAnnotation" (optional.String) - mark a field as readonly in Open API definition * @param "ProductId" (optional.Interface of []string) - Test openapiv2 generation of repeated fields Only digits are allowed. * @param "OptionalStringField" (optional.String) - Test openapiv2 generation of required fields with annotation and jsonschema to reproduce * @param "TrailingOnly" (optional.String) - Trailing only * @param "TrailingOnlyDot" (optional.String) - Trailing only dot. * @param "TrailingBoth" (optional.String) - Leading both Trailing both. * @param "TrailingMultiline" (optional.String) - Leading multiline This is an example of a multi-line comment. Trailing multiline. * @param "Uuids" (optional.Interface of []string) - Specify a custom format of repeated field items @return ExamplepbABitOfEverything */ type ABitOfEverythingServiceCustom2Opts struct { SingleNestedName optional.String SingleNestedAmount optional.Int64 SingleNestedOk optional.String Uint64Value optional.String Int32Value optional.Int32 Fixed64Value optional.String Fixed32Value optional.Int64 BoolValue optional.Bool StringValue optional.String BytesValue optional.String Uint32Value optional.Int64 EnumValue optional.String PathEnumValue optional.String NestedPathEnumValue optional.String Sfixed32Value optional.Int32 Sfixed64Value optional.String Sint32Value optional.Int32 Sint64Value optional.String RepeatedStringValue optional.Interface OneofEmpty optional.Interface OneofString optional.String MapValue optional.Interface MappedStringValue optional.String MappedNestedValue optional.Interface NonConventionalNameValue optional.String TimestampValue optional.Time RepeatedEnumValue optional.Interface RepeatedEnumAnnotation optional.Interface EnumValueAnnotation optional.String RepeatedStringAnnotation optional.Interface NestedAnnotationName optional.String NestedAnnotationAmount optional.Int64 NestedAnnotationOk optional.String Int64OverrideType optional.Int64 OutputOnlyStringViaFieldBehaviorAnnotation optional.String ProductId optional.Interface OptionalStringField optional.String TrailingOnly optional.String TrailingOnlyDot optional.String TrailingBoth optional.String TrailingMultiline optional.String Uuids optional.Interface } func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCustom2(ctx context.Context, optionalStringValue string, uuid string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceCustom2Opts) (ExamplepbABitOfEverything, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbABitOfEverything ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/custom/{optionalStringValue}" localVarPath = strings.Replace(localVarPath, "{"+"optionalStringValue"+"}", fmt.Sprintf("%v", optionalStringValue), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.SingleNestedName.IsSet() { localVarQueryParams.Add("singleNested.name", parameterToString(localVarOptionals.SingleNestedName.Value(), "")) } if localVarOptionals != nil && localVarOptionals.SingleNestedAmount.IsSet() { localVarQueryParams.Add("singleNested.amount", parameterToString(localVarOptionals.SingleNestedAmount.Value(), "")) } if localVarOptionals != nil && localVarOptionals.SingleNestedOk.IsSet() { localVarQueryParams.Add("singleNested.ok", parameterToString(localVarOptionals.SingleNestedOk.Value(), "")) } localVarQueryParams.Add("uuid", parameterToString(uuid, "")) localVarQueryParams.Add("floatValue", parameterToString(floatValue, "")) localVarQueryParams.Add("doubleValue", parameterToString(doubleValue, "")) localVarQueryParams.Add("int64Value", parameterToString(int64Value, "")) if localVarOptionals != nil && localVarOptionals.Uint64Value.IsSet() { localVarQueryParams.Add("uint64Value", parameterToString(localVarOptionals.Uint64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Int32Value.IsSet() { localVarQueryParams.Add("int32Value", parameterToString(localVarOptionals.Int32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Fixed64Value.IsSet() { localVarQueryParams.Add("fixed64Value", parameterToString(localVarOptionals.Fixed64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Fixed32Value.IsSet() { localVarQueryParams.Add("fixed32Value", parameterToString(localVarOptionals.Fixed32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.BoolValue.IsSet() { localVarQueryParams.Add("boolValue", parameterToString(localVarOptionals.BoolValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StringValue.IsSet() { localVarQueryParams.Add("stringValue", parameterToString(localVarOptionals.StringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.BytesValue.IsSet() { localVarQueryParams.Add("bytesValue", parameterToString(localVarOptionals.BytesValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Uint32Value.IsSet() { localVarQueryParams.Add("uint32Value", parameterToString(localVarOptionals.Uint32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.EnumValue.IsSet() { localVarQueryParams.Add("enumValue", parameterToString(localVarOptionals.EnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.PathEnumValue.IsSet() { localVarQueryParams.Add("pathEnumValue", parameterToString(localVarOptionals.PathEnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedPathEnumValue.IsSet() { localVarQueryParams.Add("nestedPathEnumValue", parameterToString(localVarOptionals.NestedPathEnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sfixed32Value.IsSet() { localVarQueryParams.Add("sfixed32Value", parameterToString(localVarOptionals.Sfixed32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sfixed64Value.IsSet() { localVarQueryParams.Add("sfixed64Value", parameterToString(localVarOptionals.Sfixed64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sint32Value.IsSet() { localVarQueryParams.Add("sint32Value", parameterToString(localVarOptionals.Sint32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sint64Value.IsSet() { localVarQueryParams.Add("sint64Value", parameterToString(localVarOptionals.Sint64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedStringValue.IsSet() { localVarQueryParams.Add("repeatedStringValue", parameterToString(localVarOptionals.RepeatedStringValue.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.OneofEmpty.IsSet() { localVarQueryParams.Add("oneofEmpty", parameterToString(localVarOptionals.OneofEmpty.Value(), "")) } if localVarOptionals != nil && localVarOptionals.OneofString.IsSet() { localVarQueryParams.Add("oneofString", parameterToString(localVarOptionals.OneofString.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MapValue.IsSet() { localVarQueryParams.Add("mapValue", parameterToString(localVarOptionals.MapValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MappedStringValue.IsSet() { localVarQueryParams.Add("mappedStringValue", parameterToString(localVarOptionals.MappedStringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MappedNestedValue.IsSet() { localVarQueryParams.Add("mappedNestedValue", parameterToString(localVarOptionals.MappedNestedValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NonConventionalNameValue.IsSet() { localVarQueryParams.Add("nonConventionalNameValue", parameterToString(localVarOptionals.NonConventionalNameValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TimestampValue.IsSet() { localVarQueryParams.Add("timestampValue", parameterToString(localVarOptionals.TimestampValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedEnumValue.IsSet() { localVarQueryParams.Add("repeatedEnumValue", parameterToString(localVarOptionals.RepeatedEnumValue.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.RepeatedEnumAnnotation.IsSet() { localVarQueryParams.Add("repeatedEnumAnnotation", parameterToString(localVarOptionals.RepeatedEnumAnnotation.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.EnumValueAnnotation.IsSet() { localVarQueryParams.Add("enumValueAnnotation", parameterToString(localVarOptionals.EnumValueAnnotation.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedStringAnnotation.IsSet() { localVarQueryParams.Add("repeatedStringAnnotation", parameterToString(localVarOptionals.RepeatedStringAnnotation.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationName.IsSet() { localVarQueryParams.Add("nestedAnnotation.name", parameterToString(localVarOptionals.NestedAnnotationName.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationAmount.IsSet() { localVarQueryParams.Add("nestedAnnotation.amount", parameterToString(localVarOptionals.NestedAnnotationAmount.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationOk.IsSet() { localVarQueryParams.Add("nestedAnnotation.ok", parameterToString(localVarOptionals.NestedAnnotationOk.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Int64OverrideType.IsSet() { localVarQueryParams.Add("int64OverrideType", parameterToString(localVarOptionals.Int64OverrideType.Value(), "")) } localVarQueryParams.Add("requiredStringViaFieldBehaviorAnnotation", parameterToString(requiredStringViaFieldBehaviorAnnotation, "")) if localVarOptionals != nil && localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.IsSet() { localVarQueryParams.Add("outputOnlyStringViaFieldBehaviorAnnotation", parameterToString(localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ProductId.IsSet() { localVarQueryParams.Add("productId", parameterToString(localVarOptionals.ProductId.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.OptionalStringField.IsSet() { localVarQueryParams.Add("optionalStringField", parameterToString(localVarOptionals.OptionalStringField.Value(), "")) } localVarQueryParams.Add("requiredStringField1", parameterToString(requiredStringField1, "")) localVarQueryParams.Add("requiredStringField2", parameterToString(requiredStringField2, "")) localVarQueryParams.Add("required_field_behavior_json_name_custom", parameterToString(requiredFieldBehaviorJsonNameCustom, "")) localVarQueryParams.Add("required_field_schema_json_name_custom", parameterToString(requiredFieldSchemaJsonNameCustom, "")) if localVarOptionals != nil && localVarOptionals.TrailingOnly.IsSet() { localVarQueryParams.Add("trailingOnly", parameterToString(localVarOptionals.TrailingOnly.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingOnlyDot.IsSet() { localVarQueryParams.Add("trailingOnlyDot", parameterToString(localVarOptionals.TrailingOnlyDot.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingBoth.IsSet() { localVarQueryParams.Add("trailingBoth", parameterToString(localVarOptionals.TrailingBoth.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingMultiline.IsSet() { localVarQueryParams.Add("trailingMultiline", parameterToString(localVarOptionals.TrailingMultiline.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Uuids.IsSet() { localVarQueryParams.Add("uuids", parameterToString(localVarOptionals.Uuids.Value(), "multi")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbABitOfEverything err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuidName * @param floatValue Float value field * @param doubleValue * @param int64Value * @param requiredStringViaFieldBehaviorAnnotation mark a field as required in Open API definition * @param requiredStringField1 * @param requiredStringField2 * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields * @param requiredFieldSchemaJsonNameCustom * @param optional nil or *ABitOfEverythingServiceCustomOptionsRequestOpts - Optional Parameters: * @param "SingleNestedName" (optional.String) - name is nested field. * @param "SingleNestedAmount" (optional.Int64) - * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. * @param "Uint64Value" (optional.String) - * @param "Int32Value" (optional.Int32) - * @param "Fixed64Value" (optional.String) - * @param "Fixed32Value" (optional.Int64) - * @param "BoolValue" (optional.Bool) - * @param "StringValue" (optional.String) - * @param "BytesValue" (optional.String) - * @param "Uint32Value" (optional.Int64) - * @param "EnumValue" (optional.String) - - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "PathEnumValue" (optional.String) - * @param "NestedPathEnumValue" (optional.String) - * @param "Sfixed32Value" (optional.Int32) - * @param "Sfixed64Value" (optional.String) - * @param "Sint32Value" (optional.Int32) - * @param "Sint64Value" (optional.String) - * @param "RepeatedStringValue" (optional.Interface of []string) - * @param "OneofEmpty" (optional.Interface of map[string]string) - * @param "OneofString" (optional.String) - * @param "MapValue" (optional.Interface of interface{}) - map of numeric enum * @param "MappedStringValue" (optional.String) - Map of string title Map of string description. * @param "MappedNestedValue" (optional.Interface of interface{}) - * @param "NonConventionalNameValue" (optional.String) - * @param "TimestampValue" (optional.Time) - * @param "RepeatedEnumValue" (optional.Interface of []string) - repeated enum value. it is comma-separated in query - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "RepeatedEnumAnnotation" (optional.Interface of []string) - Repeated numeric enum title Repeated numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "EnumValueAnnotation" (optional.String) - Numeric enum title Numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "RepeatedStringAnnotation" (optional.Interface of []string) - Repeated string title Repeated string description. * @param "NestedAnnotationName" (optional.String) - name is nested field. * @param "NestedAnnotationAmount" (optional.Int64) - * @param "NestedAnnotationOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. * @param "Int64OverrideType" (optional.Int64) - * @param "OutputOnlyStringViaFieldBehaviorAnnotation" (optional.String) - mark a field as readonly in Open API definition * @param "OptionalStringValue" (optional.String) - * @param "ProductId" (optional.Interface of []string) - Test openapiv2 generation of repeated fields Only digits are allowed. * @param "OptionalStringField" (optional.String) - Test openapiv2 generation of required fields with annotation and jsonschema to reproduce * @param "TrailingOnly" (optional.String) - Trailing only * @param "TrailingOnlyDot" (optional.String) - Trailing only dot. * @param "TrailingBoth" (optional.String) - Leading both Trailing both. * @param "TrailingMultiline" (optional.String) - Leading multiline This is an example of a multi-line comment. Trailing multiline. * @param "Uuids" (optional.Interface of []string) - Specify a custom format of repeated field items @return interface{} */ type ABitOfEverythingServiceCustomOptionsRequestOpts struct { SingleNestedName optional.String SingleNestedAmount optional.Int64 SingleNestedOk optional.String Uint64Value optional.String Int32Value optional.Int32 Fixed64Value optional.String Fixed32Value optional.Int64 BoolValue optional.Bool StringValue optional.String BytesValue optional.String Uint32Value optional.Int64 EnumValue optional.String PathEnumValue optional.String NestedPathEnumValue optional.String Sfixed32Value optional.Int32 Sfixed64Value optional.String Sint32Value optional.Int32 Sint64Value optional.String RepeatedStringValue optional.Interface OneofEmpty optional.Interface OneofString optional.String MapValue optional.Interface MappedStringValue optional.String MappedNestedValue optional.Interface NonConventionalNameValue optional.String TimestampValue optional.Time RepeatedEnumValue optional.Interface RepeatedEnumAnnotation optional.Interface EnumValueAnnotation optional.String RepeatedStringAnnotation optional.Interface NestedAnnotationName optional.String NestedAnnotationAmount optional.Int64 NestedAnnotationOk optional.String Int64OverrideType optional.Int64 OutputOnlyStringViaFieldBehaviorAnnotation optional.String OptionalStringValue optional.String ProductId optional.Interface OptionalStringField optional.String TrailingOnly optional.String TrailingOnlyDot optional.String TrailingBoth optional.String TrailingMultiline optional.String Uuids optional.Interface } func (a *ABitOfEverythingApiService) ABitOfEverythingServiceCustomOptionsRequest(ctx context.Context, uuidName string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceCustomOptionsRequestOpts) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Options") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue interface{} ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/{uuidName}" localVarPath = strings.Replace(localVarPath, "{"+"uuidName"+"}", fmt.Sprintf("%v", uuidName), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.SingleNestedName.IsSet() { localVarQueryParams.Add("singleNested.name", parameterToString(localVarOptionals.SingleNestedName.Value(), "")) } if localVarOptionals != nil && localVarOptionals.SingleNestedAmount.IsSet() { localVarQueryParams.Add("singleNested.amount", parameterToString(localVarOptionals.SingleNestedAmount.Value(), "")) } if localVarOptionals != nil && localVarOptionals.SingleNestedOk.IsSet() { localVarQueryParams.Add("singleNested.ok", parameterToString(localVarOptionals.SingleNestedOk.Value(), "")) } localVarQueryParams.Add("floatValue", parameterToString(floatValue, "")) localVarQueryParams.Add("doubleValue", parameterToString(doubleValue, "")) localVarQueryParams.Add("int64Value", parameterToString(int64Value, "")) if localVarOptionals != nil && localVarOptionals.Uint64Value.IsSet() { localVarQueryParams.Add("uint64Value", parameterToString(localVarOptionals.Uint64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Int32Value.IsSet() { localVarQueryParams.Add("int32Value", parameterToString(localVarOptionals.Int32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Fixed64Value.IsSet() { localVarQueryParams.Add("fixed64Value", parameterToString(localVarOptionals.Fixed64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Fixed32Value.IsSet() { localVarQueryParams.Add("fixed32Value", parameterToString(localVarOptionals.Fixed32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.BoolValue.IsSet() { localVarQueryParams.Add("boolValue", parameterToString(localVarOptionals.BoolValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StringValue.IsSet() { localVarQueryParams.Add("stringValue", parameterToString(localVarOptionals.StringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.BytesValue.IsSet() { localVarQueryParams.Add("bytesValue", parameterToString(localVarOptionals.BytesValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Uint32Value.IsSet() { localVarQueryParams.Add("uint32Value", parameterToString(localVarOptionals.Uint32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.EnumValue.IsSet() { localVarQueryParams.Add("enumValue", parameterToString(localVarOptionals.EnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.PathEnumValue.IsSet() { localVarQueryParams.Add("pathEnumValue", parameterToString(localVarOptionals.PathEnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedPathEnumValue.IsSet() { localVarQueryParams.Add("nestedPathEnumValue", parameterToString(localVarOptionals.NestedPathEnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sfixed32Value.IsSet() { localVarQueryParams.Add("sfixed32Value", parameterToString(localVarOptionals.Sfixed32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sfixed64Value.IsSet() { localVarQueryParams.Add("sfixed64Value", parameterToString(localVarOptionals.Sfixed64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sint32Value.IsSet() { localVarQueryParams.Add("sint32Value", parameterToString(localVarOptionals.Sint32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sint64Value.IsSet() { localVarQueryParams.Add("sint64Value", parameterToString(localVarOptionals.Sint64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedStringValue.IsSet() { localVarQueryParams.Add("repeatedStringValue", parameterToString(localVarOptionals.RepeatedStringValue.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.OneofEmpty.IsSet() { localVarQueryParams.Add("oneofEmpty", parameterToString(localVarOptionals.OneofEmpty.Value(), "")) } if localVarOptionals != nil && localVarOptionals.OneofString.IsSet() { localVarQueryParams.Add("oneofString", parameterToString(localVarOptionals.OneofString.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MapValue.IsSet() { localVarQueryParams.Add("mapValue", parameterToString(localVarOptionals.MapValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MappedStringValue.IsSet() { localVarQueryParams.Add("mappedStringValue", parameterToString(localVarOptionals.MappedStringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MappedNestedValue.IsSet() { localVarQueryParams.Add("mappedNestedValue", parameterToString(localVarOptionals.MappedNestedValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NonConventionalNameValue.IsSet() { localVarQueryParams.Add("nonConventionalNameValue", parameterToString(localVarOptionals.NonConventionalNameValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TimestampValue.IsSet() { localVarQueryParams.Add("timestampValue", parameterToString(localVarOptionals.TimestampValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedEnumValue.IsSet() { localVarQueryParams.Add("repeatedEnumValue", parameterToString(localVarOptionals.RepeatedEnumValue.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.RepeatedEnumAnnotation.IsSet() { localVarQueryParams.Add("repeatedEnumAnnotation", parameterToString(localVarOptionals.RepeatedEnumAnnotation.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.EnumValueAnnotation.IsSet() { localVarQueryParams.Add("enumValueAnnotation", parameterToString(localVarOptionals.EnumValueAnnotation.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedStringAnnotation.IsSet() { localVarQueryParams.Add("repeatedStringAnnotation", parameterToString(localVarOptionals.RepeatedStringAnnotation.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationName.IsSet() { localVarQueryParams.Add("nestedAnnotation.name", parameterToString(localVarOptionals.NestedAnnotationName.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationAmount.IsSet() { localVarQueryParams.Add("nestedAnnotation.amount", parameterToString(localVarOptionals.NestedAnnotationAmount.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationOk.IsSet() { localVarQueryParams.Add("nestedAnnotation.ok", parameterToString(localVarOptionals.NestedAnnotationOk.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Int64OverrideType.IsSet() { localVarQueryParams.Add("int64OverrideType", parameterToString(localVarOptionals.Int64OverrideType.Value(), "")) } localVarQueryParams.Add("requiredStringViaFieldBehaviorAnnotation", parameterToString(requiredStringViaFieldBehaviorAnnotation, "")) if localVarOptionals != nil && localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.IsSet() { localVarQueryParams.Add("outputOnlyStringViaFieldBehaviorAnnotation", parameterToString(localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.Value(), "")) } if localVarOptionals != nil && localVarOptionals.OptionalStringValue.IsSet() { localVarQueryParams.Add("optionalStringValue", parameterToString(localVarOptionals.OptionalStringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ProductId.IsSet() { localVarQueryParams.Add("productId", parameterToString(localVarOptionals.ProductId.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.OptionalStringField.IsSet() { localVarQueryParams.Add("optionalStringField", parameterToString(localVarOptionals.OptionalStringField.Value(), "")) } localVarQueryParams.Add("requiredStringField1", parameterToString(requiredStringField1, "")) localVarQueryParams.Add("requiredStringField2", parameterToString(requiredStringField2, "")) localVarQueryParams.Add("required_field_behavior_json_name_custom", parameterToString(requiredFieldBehaviorJsonNameCustom, "")) localVarQueryParams.Add("required_field_schema_json_name_custom", parameterToString(requiredFieldSchemaJsonNameCustom, "")) if localVarOptionals != nil && localVarOptionals.TrailingOnly.IsSet() { localVarQueryParams.Add("trailingOnly", parameterToString(localVarOptionals.TrailingOnly.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingOnlyDot.IsSet() { localVarQueryParams.Add("trailingOnlyDot", parameterToString(localVarOptionals.TrailingOnlyDot.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingBoth.IsSet() { localVarQueryParams.Add("trailingBoth", parameterToString(localVarOptionals.TrailingBoth.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingMultiline.IsSet() { localVarQueryParams.Add("trailingMultiline", parameterToString(localVarOptionals.TrailingMultiline.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Uuids.IsSet() { localVarQueryParams.Add("uuids", parameterToString(localVarOptionals.Uuids.Value(), "multi")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param singleNestedName name is nested field. * @param body @return ExamplepbABitOfEverything */ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceDeepPathEcho(ctx context.Context, singleNestedName string, body ABitOfEverythingServiceDeepPathEchoBody) (ExamplepbABitOfEverything, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbABitOfEverything ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/deep_path/{singleNested.name}" localVarPath = strings.Replace(localVarPath, "{"+"singleNested.name"+"}", fmt.Sprintf("%v", singleNestedName), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbABitOfEverything err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuid @return interface{} */ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceDelete(ctx context.Context, uuid string) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Delete") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue interface{} ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/{uuid}" localVarPath = strings.Replace(localVarPath, "{"+"uuid"+"}", fmt.Sprintf("%v", uuid), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuidName * @param floatValue Float value field * @param doubleValue * @param int64Value * @param requiredStringViaFieldBehaviorAnnotation mark a field as required in Open API definition * @param requiredStringField1 * @param requiredStringField2 * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields * @param requiredFieldSchemaJsonNameCustom * @param optional nil or *ABitOfEverythingServiceDoubleColonOpts - Optional Parameters: * @param "SingleNestedName" (optional.String) - name is nested field. * @param "SingleNestedAmount" (optional.Int64) - * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. * @param "Uint64Value" (optional.String) - * @param "Int32Value" (optional.Int32) - * @param "Fixed64Value" (optional.String) - * @param "Fixed32Value" (optional.Int64) - * @param "BoolValue" (optional.Bool) - * @param "StringValue" (optional.String) - * @param "BytesValue" (optional.String) - * @param "Uint32Value" (optional.Int64) - * @param "EnumValue" (optional.String) - - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "PathEnumValue" (optional.String) - * @param "NestedPathEnumValue" (optional.String) - * @param "Sfixed32Value" (optional.Int32) - * @param "Sfixed64Value" (optional.String) - * @param "Sint32Value" (optional.Int32) - * @param "Sint64Value" (optional.String) - * @param "RepeatedStringValue" (optional.Interface of []string) - * @param "OneofEmpty" (optional.Interface of map[string]string) - * @param "OneofString" (optional.String) - * @param "MapValue" (optional.Interface of interface{}) - map of numeric enum * @param "MappedStringValue" (optional.String) - Map of string title Map of string description. * @param "MappedNestedValue" (optional.Interface of interface{}) - * @param "NonConventionalNameValue" (optional.String) - * @param "TimestampValue" (optional.Time) - * @param "RepeatedEnumValue" (optional.Interface of []string) - repeated enum value. it is comma-separated in query - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "RepeatedEnumAnnotation" (optional.Interface of []string) - Repeated numeric enum title Repeated numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "EnumValueAnnotation" (optional.String) - Numeric enum title Numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "RepeatedStringAnnotation" (optional.Interface of []string) - Repeated string title Repeated string description. * @param "NestedAnnotationName" (optional.String) - name is nested field. * @param "NestedAnnotationAmount" (optional.Int64) - * @param "NestedAnnotationOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. * @param "Int64OverrideType" (optional.Int64) - * @param "OutputOnlyStringViaFieldBehaviorAnnotation" (optional.String) - mark a field as readonly in Open API definition * @param "OptionalStringValue" (optional.String) - * @param "ProductId" (optional.Interface of []string) - Test openapiv2 generation of repeated fields Only digits are allowed. * @param "OptionalStringField" (optional.String) - Test openapiv2 generation of required fields with annotation and jsonschema to reproduce * @param "TrailingOnly" (optional.String) - Trailing only * @param "TrailingOnlyDot" (optional.String) - Trailing only dot. * @param "TrailingBoth" (optional.String) - Leading both Trailing both. * @param "TrailingMultiline" (optional.String) - Leading multiline This is an example of a multi-line comment. Trailing multiline. * @param "Uuids" (optional.Interface of []string) - Specify a custom format of repeated field items @return ExamplepbABitOfEverything */ type ABitOfEverythingServiceDoubleColonOpts struct { SingleNestedName optional.String SingleNestedAmount optional.Int64 SingleNestedOk optional.String Uint64Value optional.String Int32Value optional.Int32 Fixed64Value optional.String Fixed32Value optional.Int64 BoolValue optional.Bool StringValue optional.String BytesValue optional.String Uint32Value optional.Int64 EnumValue optional.String PathEnumValue optional.String NestedPathEnumValue optional.String Sfixed32Value optional.Int32 Sfixed64Value optional.String Sint32Value optional.Int32 Sint64Value optional.String RepeatedStringValue optional.Interface OneofEmpty optional.Interface OneofString optional.String MapValue optional.Interface MappedStringValue optional.String MappedNestedValue optional.Interface NonConventionalNameValue optional.String TimestampValue optional.Time RepeatedEnumValue optional.Interface RepeatedEnumAnnotation optional.Interface EnumValueAnnotation optional.String RepeatedStringAnnotation optional.Interface NestedAnnotationName optional.String NestedAnnotationAmount optional.Int64 NestedAnnotationOk optional.String Int64OverrideType optional.Int64 OutputOnlyStringViaFieldBehaviorAnnotation optional.String OptionalStringValue optional.String ProductId optional.Interface OptionalStringField optional.String TrailingOnly optional.String TrailingOnlyDot optional.String TrailingBoth optional.String TrailingMultiline optional.String Uuids optional.Interface } func (a *ABitOfEverythingApiService) ABitOfEverythingServiceDoubleColon(ctx context.Context, uuidName string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceDoubleColonOpts) (ExamplepbABitOfEverything, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbABitOfEverything ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/{uuidName}:custom:custom" localVarPath = strings.Replace(localVarPath, "{"+"uuidName"+"}", fmt.Sprintf("%v", uuidName), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.SingleNestedName.IsSet() { localVarQueryParams.Add("singleNested.name", parameterToString(localVarOptionals.SingleNestedName.Value(), "")) } if localVarOptionals != nil && localVarOptionals.SingleNestedAmount.IsSet() { localVarQueryParams.Add("singleNested.amount", parameterToString(localVarOptionals.SingleNestedAmount.Value(), "")) } if localVarOptionals != nil && localVarOptionals.SingleNestedOk.IsSet() { localVarQueryParams.Add("singleNested.ok", parameterToString(localVarOptionals.SingleNestedOk.Value(), "")) } localVarQueryParams.Add("floatValue", parameterToString(floatValue, "")) localVarQueryParams.Add("doubleValue", parameterToString(doubleValue, "")) localVarQueryParams.Add("int64Value", parameterToString(int64Value, "")) if localVarOptionals != nil && localVarOptionals.Uint64Value.IsSet() { localVarQueryParams.Add("uint64Value", parameterToString(localVarOptionals.Uint64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Int32Value.IsSet() { localVarQueryParams.Add("int32Value", parameterToString(localVarOptionals.Int32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Fixed64Value.IsSet() { localVarQueryParams.Add("fixed64Value", parameterToString(localVarOptionals.Fixed64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Fixed32Value.IsSet() { localVarQueryParams.Add("fixed32Value", parameterToString(localVarOptionals.Fixed32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.BoolValue.IsSet() { localVarQueryParams.Add("boolValue", parameterToString(localVarOptionals.BoolValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StringValue.IsSet() { localVarQueryParams.Add("stringValue", parameterToString(localVarOptionals.StringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.BytesValue.IsSet() { localVarQueryParams.Add("bytesValue", parameterToString(localVarOptionals.BytesValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Uint32Value.IsSet() { localVarQueryParams.Add("uint32Value", parameterToString(localVarOptionals.Uint32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.EnumValue.IsSet() { localVarQueryParams.Add("enumValue", parameterToString(localVarOptionals.EnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.PathEnumValue.IsSet() { localVarQueryParams.Add("pathEnumValue", parameterToString(localVarOptionals.PathEnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedPathEnumValue.IsSet() { localVarQueryParams.Add("nestedPathEnumValue", parameterToString(localVarOptionals.NestedPathEnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sfixed32Value.IsSet() { localVarQueryParams.Add("sfixed32Value", parameterToString(localVarOptionals.Sfixed32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sfixed64Value.IsSet() { localVarQueryParams.Add("sfixed64Value", parameterToString(localVarOptionals.Sfixed64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sint32Value.IsSet() { localVarQueryParams.Add("sint32Value", parameterToString(localVarOptionals.Sint32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sint64Value.IsSet() { localVarQueryParams.Add("sint64Value", parameterToString(localVarOptionals.Sint64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedStringValue.IsSet() { localVarQueryParams.Add("repeatedStringValue", parameterToString(localVarOptionals.RepeatedStringValue.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.OneofEmpty.IsSet() { localVarQueryParams.Add("oneofEmpty", parameterToString(localVarOptionals.OneofEmpty.Value(), "")) } if localVarOptionals != nil && localVarOptionals.OneofString.IsSet() { localVarQueryParams.Add("oneofString", parameterToString(localVarOptionals.OneofString.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MapValue.IsSet() { localVarQueryParams.Add("mapValue", parameterToString(localVarOptionals.MapValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MappedStringValue.IsSet() { localVarQueryParams.Add("mappedStringValue", parameterToString(localVarOptionals.MappedStringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MappedNestedValue.IsSet() { localVarQueryParams.Add("mappedNestedValue", parameterToString(localVarOptionals.MappedNestedValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NonConventionalNameValue.IsSet() { localVarQueryParams.Add("nonConventionalNameValue", parameterToString(localVarOptionals.NonConventionalNameValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TimestampValue.IsSet() { localVarQueryParams.Add("timestampValue", parameterToString(localVarOptionals.TimestampValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedEnumValue.IsSet() { localVarQueryParams.Add("repeatedEnumValue", parameterToString(localVarOptionals.RepeatedEnumValue.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.RepeatedEnumAnnotation.IsSet() { localVarQueryParams.Add("repeatedEnumAnnotation", parameterToString(localVarOptionals.RepeatedEnumAnnotation.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.EnumValueAnnotation.IsSet() { localVarQueryParams.Add("enumValueAnnotation", parameterToString(localVarOptionals.EnumValueAnnotation.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedStringAnnotation.IsSet() { localVarQueryParams.Add("repeatedStringAnnotation", parameterToString(localVarOptionals.RepeatedStringAnnotation.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationName.IsSet() { localVarQueryParams.Add("nestedAnnotation.name", parameterToString(localVarOptionals.NestedAnnotationName.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationAmount.IsSet() { localVarQueryParams.Add("nestedAnnotation.amount", parameterToString(localVarOptionals.NestedAnnotationAmount.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationOk.IsSet() { localVarQueryParams.Add("nestedAnnotation.ok", parameterToString(localVarOptionals.NestedAnnotationOk.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Int64OverrideType.IsSet() { localVarQueryParams.Add("int64OverrideType", parameterToString(localVarOptionals.Int64OverrideType.Value(), "")) } localVarQueryParams.Add("requiredStringViaFieldBehaviorAnnotation", parameterToString(requiredStringViaFieldBehaviorAnnotation, "")) if localVarOptionals != nil && localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.IsSet() { localVarQueryParams.Add("outputOnlyStringViaFieldBehaviorAnnotation", parameterToString(localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.Value(), "")) } if localVarOptionals != nil && localVarOptionals.OptionalStringValue.IsSet() { localVarQueryParams.Add("optionalStringValue", parameterToString(localVarOptionals.OptionalStringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ProductId.IsSet() { localVarQueryParams.Add("productId", parameterToString(localVarOptionals.ProductId.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.OptionalStringField.IsSet() { localVarQueryParams.Add("optionalStringField", parameterToString(localVarOptionals.OptionalStringField.Value(), "")) } localVarQueryParams.Add("requiredStringField1", parameterToString(requiredStringField1, "")) localVarQueryParams.Add("requiredStringField2", parameterToString(requiredStringField2, "")) localVarQueryParams.Add("required_field_behavior_json_name_custom", parameterToString(requiredFieldBehaviorJsonNameCustom, "")) localVarQueryParams.Add("required_field_schema_json_name_custom", parameterToString(requiredFieldSchemaJsonNameCustom, "")) if localVarOptionals != nil && localVarOptionals.TrailingOnly.IsSet() { localVarQueryParams.Add("trailingOnly", parameterToString(localVarOptionals.TrailingOnly.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingOnlyDot.IsSet() { localVarQueryParams.Add("trailingOnlyDot", parameterToString(localVarOptionals.TrailingOnlyDot.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingBoth.IsSet() { localVarQueryParams.Add("trailingBoth", parameterToString(localVarOptionals.TrailingBoth.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingMultiline.IsSet() { localVarQueryParams.Add("trailingMultiline", parameterToString(localVarOptionals.TrailingMultiline.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Uuids.IsSet() { localVarQueryParams.Add("uuids", parameterToString(localVarOptionals.Uuids.Value(), "multi")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbABitOfEverything err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @return interface{} */ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceErrorWithDetails(ctx context.Context) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue interface{} ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v2/example/errorwithdetails" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuidName * @param floatValue Float value field * @param doubleValue * @param int64Value * @param requiredStringViaFieldBehaviorAnnotation mark a field as required in Open API definition * @param requiredStringField1 * @param requiredStringField2 * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields * @param requiredFieldSchemaJsonNameCustom * @param optional nil or *ABitOfEverythingServiceExistsOpts - Optional Parameters: * @param "SingleNestedName" (optional.String) - name is nested field. * @param "SingleNestedAmount" (optional.Int64) - * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. * @param "Uint64Value" (optional.String) - * @param "Int32Value" (optional.Int32) - * @param "Fixed64Value" (optional.String) - * @param "Fixed32Value" (optional.Int64) - * @param "BoolValue" (optional.Bool) - * @param "StringValue" (optional.String) - * @param "BytesValue" (optional.String) - * @param "Uint32Value" (optional.Int64) - * @param "EnumValue" (optional.String) - - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "PathEnumValue" (optional.String) - * @param "NestedPathEnumValue" (optional.String) - * @param "Sfixed32Value" (optional.Int32) - * @param "Sfixed64Value" (optional.String) - * @param "Sint32Value" (optional.Int32) - * @param "Sint64Value" (optional.String) - * @param "RepeatedStringValue" (optional.Interface of []string) - * @param "OneofEmpty" (optional.Interface of map[string]string) - * @param "OneofString" (optional.String) - * @param "MapValue" (optional.Interface of interface{}) - map of numeric enum * @param "MappedStringValue" (optional.String) - Map of string title Map of string description. * @param "MappedNestedValue" (optional.Interface of interface{}) - * @param "NonConventionalNameValue" (optional.String) - * @param "TimestampValue" (optional.Time) - * @param "RepeatedEnumValue" (optional.Interface of []string) - repeated enum value. it is comma-separated in query - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "RepeatedEnumAnnotation" (optional.Interface of []string) - Repeated numeric enum title Repeated numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "EnumValueAnnotation" (optional.String) - Numeric enum title Numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "RepeatedStringAnnotation" (optional.Interface of []string) - Repeated string title Repeated string description. * @param "NestedAnnotationName" (optional.String) - name is nested field. * @param "NestedAnnotationAmount" (optional.Int64) - * @param "NestedAnnotationOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. * @param "Int64OverrideType" (optional.Int64) - * @param "OutputOnlyStringViaFieldBehaviorAnnotation" (optional.String) - mark a field as readonly in Open API definition * @param "OptionalStringValue" (optional.String) - * @param "ProductId" (optional.Interface of []string) - Test openapiv2 generation of repeated fields Only digits are allowed. * @param "OptionalStringField" (optional.String) - Test openapiv2 generation of required fields with annotation and jsonschema to reproduce * @param "TrailingOnly" (optional.String) - Trailing only * @param "TrailingOnlyDot" (optional.String) - Trailing only dot. * @param "TrailingBoth" (optional.String) - Leading both Trailing both. * @param "TrailingMultiline" (optional.String) - Leading multiline This is an example of a multi-line comment. Trailing multiline. * @param "Uuids" (optional.Interface of []string) - Specify a custom format of repeated field items @return interface{} */ type ABitOfEverythingServiceExistsOpts struct { SingleNestedName optional.String SingleNestedAmount optional.Int64 SingleNestedOk optional.String Uint64Value optional.String Int32Value optional.Int32 Fixed64Value optional.String Fixed32Value optional.Int64 BoolValue optional.Bool StringValue optional.String BytesValue optional.String Uint32Value optional.Int64 EnumValue optional.String PathEnumValue optional.String NestedPathEnumValue optional.String Sfixed32Value optional.Int32 Sfixed64Value optional.String Sint32Value optional.Int32 Sint64Value optional.String RepeatedStringValue optional.Interface OneofEmpty optional.Interface OneofString optional.String MapValue optional.Interface MappedStringValue optional.String MappedNestedValue optional.Interface NonConventionalNameValue optional.String TimestampValue optional.Time RepeatedEnumValue optional.Interface RepeatedEnumAnnotation optional.Interface EnumValueAnnotation optional.String RepeatedStringAnnotation optional.Interface NestedAnnotationName optional.String NestedAnnotationAmount optional.Int64 NestedAnnotationOk optional.String Int64OverrideType optional.Int64 OutputOnlyStringViaFieldBehaviorAnnotation optional.String OptionalStringValue optional.String ProductId optional.Interface OptionalStringField optional.String TrailingOnly optional.String TrailingOnlyDot optional.String TrailingBoth optional.String TrailingMultiline optional.String Uuids optional.Interface } func (a *ABitOfEverythingApiService) ABitOfEverythingServiceExists(ctx context.Context, uuidName string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceExistsOpts) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Head") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue interface{} ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/{uuidName}" localVarPath = strings.Replace(localVarPath, "{"+"uuidName"+"}", fmt.Sprintf("%v", uuidName), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.SingleNestedName.IsSet() { localVarQueryParams.Add("singleNested.name", parameterToString(localVarOptionals.SingleNestedName.Value(), "")) } if localVarOptionals != nil && localVarOptionals.SingleNestedAmount.IsSet() { localVarQueryParams.Add("singleNested.amount", parameterToString(localVarOptionals.SingleNestedAmount.Value(), "")) } if localVarOptionals != nil && localVarOptionals.SingleNestedOk.IsSet() { localVarQueryParams.Add("singleNested.ok", parameterToString(localVarOptionals.SingleNestedOk.Value(), "")) } localVarQueryParams.Add("floatValue", parameterToString(floatValue, "")) localVarQueryParams.Add("doubleValue", parameterToString(doubleValue, "")) localVarQueryParams.Add("int64Value", parameterToString(int64Value, "")) if localVarOptionals != nil && localVarOptionals.Uint64Value.IsSet() { localVarQueryParams.Add("uint64Value", parameterToString(localVarOptionals.Uint64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Int32Value.IsSet() { localVarQueryParams.Add("int32Value", parameterToString(localVarOptionals.Int32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Fixed64Value.IsSet() { localVarQueryParams.Add("fixed64Value", parameterToString(localVarOptionals.Fixed64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Fixed32Value.IsSet() { localVarQueryParams.Add("fixed32Value", parameterToString(localVarOptionals.Fixed32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.BoolValue.IsSet() { localVarQueryParams.Add("boolValue", parameterToString(localVarOptionals.BoolValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StringValue.IsSet() { localVarQueryParams.Add("stringValue", parameterToString(localVarOptionals.StringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.BytesValue.IsSet() { localVarQueryParams.Add("bytesValue", parameterToString(localVarOptionals.BytesValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Uint32Value.IsSet() { localVarQueryParams.Add("uint32Value", parameterToString(localVarOptionals.Uint32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.EnumValue.IsSet() { localVarQueryParams.Add("enumValue", parameterToString(localVarOptionals.EnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.PathEnumValue.IsSet() { localVarQueryParams.Add("pathEnumValue", parameterToString(localVarOptionals.PathEnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedPathEnumValue.IsSet() { localVarQueryParams.Add("nestedPathEnumValue", parameterToString(localVarOptionals.NestedPathEnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sfixed32Value.IsSet() { localVarQueryParams.Add("sfixed32Value", parameterToString(localVarOptionals.Sfixed32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sfixed64Value.IsSet() { localVarQueryParams.Add("sfixed64Value", parameterToString(localVarOptionals.Sfixed64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sint32Value.IsSet() { localVarQueryParams.Add("sint32Value", parameterToString(localVarOptionals.Sint32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sint64Value.IsSet() { localVarQueryParams.Add("sint64Value", parameterToString(localVarOptionals.Sint64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedStringValue.IsSet() { localVarQueryParams.Add("repeatedStringValue", parameterToString(localVarOptionals.RepeatedStringValue.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.OneofEmpty.IsSet() { localVarQueryParams.Add("oneofEmpty", parameterToString(localVarOptionals.OneofEmpty.Value(), "")) } if localVarOptionals != nil && localVarOptionals.OneofString.IsSet() { localVarQueryParams.Add("oneofString", parameterToString(localVarOptionals.OneofString.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MapValue.IsSet() { localVarQueryParams.Add("mapValue", parameterToString(localVarOptionals.MapValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MappedStringValue.IsSet() { localVarQueryParams.Add("mappedStringValue", parameterToString(localVarOptionals.MappedStringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MappedNestedValue.IsSet() { localVarQueryParams.Add("mappedNestedValue", parameterToString(localVarOptionals.MappedNestedValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NonConventionalNameValue.IsSet() { localVarQueryParams.Add("nonConventionalNameValue", parameterToString(localVarOptionals.NonConventionalNameValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TimestampValue.IsSet() { localVarQueryParams.Add("timestampValue", parameterToString(localVarOptionals.TimestampValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedEnumValue.IsSet() { localVarQueryParams.Add("repeatedEnumValue", parameterToString(localVarOptionals.RepeatedEnumValue.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.RepeatedEnumAnnotation.IsSet() { localVarQueryParams.Add("repeatedEnumAnnotation", parameterToString(localVarOptionals.RepeatedEnumAnnotation.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.EnumValueAnnotation.IsSet() { localVarQueryParams.Add("enumValueAnnotation", parameterToString(localVarOptionals.EnumValueAnnotation.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedStringAnnotation.IsSet() { localVarQueryParams.Add("repeatedStringAnnotation", parameterToString(localVarOptionals.RepeatedStringAnnotation.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationName.IsSet() { localVarQueryParams.Add("nestedAnnotation.name", parameterToString(localVarOptionals.NestedAnnotationName.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationAmount.IsSet() { localVarQueryParams.Add("nestedAnnotation.amount", parameterToString(localVarOptionals.NestedAnnotationAmount.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationOk.IsSet() { localVarQueryParams.Add("nestedAnnotation.ok", parameterToString(localVarOptionals.NestedAnnotationOk.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Int64OverrideType.IsSet() { localVarQueryParams.Add("int64OverrideType", parameterToString(localVarOptionals.Int64OverrideType.Value(), "")) } localVarQueryParams.Add("requiredStringViaFieldBehaviorAnnotation", parameterToString(requiredStringViaFieldBehaviorAnnotation, "")) if localVarOptionals != nil && localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.IsSet() { localVarQueryParams.Add("outputOnlyStringViaFieldBehaviorAnnotation", parameterToString(localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.Value(), "")) } if localVarOptionals != nil && localVarOptionals.OptionalStringValue.IsSet() { localVarQueryParams.Add("optionalStringValue", parameterToString(localVarOptionals.OptionalStringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ProductId.IsSet() { localVarQueryParams.Add("productId", parameterToString(localVarOptionals.ProductId.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.OptionalStringField.IsSet() { localVarQueryParams.Add("optionalStringField", parameterToString(localVarOptionals.OptionalStringField.Value(), "")) } localVarQueryParams.Add("requiredStringField1", parameterToString(requiredStringField1, "")) localVarQueryParams.Add("requiredStringField2", parameterToString(requiredStringField2, "")) localVarQueryParams.Add("required_field_behavior_json_name_custom", parameterToString(requiredFieldBehaviorJsonNameCustom, "")) localVarQueryParams.Add("required_field_schema_json_name_custom", parameterToString(requiredFieldSchemaJsonNameCustom, "")) if localVarOptionals != nil && localVarOptionals.TrailingOnly.IsSet() { localVarQueryParams.Add("trailingOnly", parameterToString(localVarOptionals.TrailingOnly.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingOnlyDot.IsSet() { localVarQueryParams.Add("trailingOnlyDot", parameterToString(localVarOptionals.TrailingOnlyDot.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingBoth.IsSet() { localVarQueryParams.Add("trailingBoth", parameterToString(localVarOptionals.TrailingBoth.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingMultiline.IsSet() { localVarQueryParams.Add("trailingMultiline", parameterToString(localVarOptionals.TrailingMultiline.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Uuids.IsSet() { localVarQueryParams.Add("uuids", parameterToString(localVarOptionals.Uuids.Value(), "multi")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param id * @param data @return interface{} */ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceGetMessageWithBody(ctx context.Context, id string, data ExamplepbBody) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue interface{} ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v2/example/withbody/{id}" localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &data if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuidName * @param floatValue Float value field * @param doubleValue * @param int64Value * @param requiredStringViaFieldBehaviorAnnotation mark a field as required in Open API definition * @param requiredStringField1 * @param requiredStringField2 * @param requiredFieldBehaviorJsonNameCustom Test openapiv2 handling of required json_name fields * @param requiredFieldSchemaJsonNameCustom * @param optional nil or *ABitOfEverythingServiceGetQueryOpts - Optional Parameters: * @param "SingleNestedName" (optional.String) - name is nested field. * @param "SingleNestedAmount" (optional.Int64) - * @param "SingleNestedOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. * @param "Uint64Value" (optional.String) - * @param "Int32Value" (optional.Int32) - * @param "Fixed64Value" (optional.String) - * @param "Fixed32Value" (optional.Int64) - * @param "BoolValue" (optional.Bool) - * @param "StringValue" (optional.String) - * @param "BytesValue" (optional.String) - * @param "Uint32Value" (optional.Int64) - * @param "EnumValue" (optional.String) - - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "PathEnumValue" (optional.String) - * @param "NestedPathEnumValue" (optional.String) - * @param "Sfixed32Value" (optional.Int32) - * @param "Sfixed64Value" (optional.String) - * @param "Sint32Value" (optional.Int32) - * @param "Sint64Value" (optional.String) - * @param "RepeatedStringValue" (optional.Interface of []string) - * @param "OneofEmpty" (optional.Interface of map[string]string) - * @param "OneofString" (optional.String) - * @param "MapValue" (optional.Interface of interface{}) - map of numeric enum * @param "MappedStringValue" (optional.String) - Map of string title Map of string description. * @param "MappedNestedValue" (optional.Interface of interface{}) - * @param "NonConventionalNameValue" (optional.String) - * @param "TimestampValue" (optional.Time) - * @param "RepeatedEnumValue" (optional.Interface of []string) - repeated enum value. it is comma-separated in query - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "RepeatedEnumAnnotation" (optional.Interface of []string) - Repeated numeric enum title Repeated numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "EnumValueAnnotation" (optional.String) - Numeric enum title Numeric enum description. - ZERO: ZERO means 0 - ONE: ONE means 1 * @param "RepeatedStringAnnotation" (optional.Interface of []string) - Repeated string title Repeated string description. * @param "NestedAnnotationName" (optional.String) - name is nested field. * @param "NestedAnnotationAmount" (optional.Int64) - * @param "NestedAnnotationOk" (optional.String) - DeepEnum description. - FALSE: FALSE is false. - TRUE: TRUE is true. * @param "Int64OverrideType" (optional.Int64) - * @param "OutputOnlyStringViaFieldBehaviorAnnotation" (optional.String) - mark a field as readonly in Open API definition * @param "OptionalStringValue" (optional.String) - * @param "ProductId" (optional.Interface of []string) - Test openapiv2 generation of repeated fields Only digits are allowed. * @param "OptionalStringField" (optional.String) - Test openapiv2 generation of required fields with annotation and jsonschema to reproduce * @param "TrailingOnly" (optional.String) - Trailing only * @param "TrailingOnlyDot" (optional.String) - Trailing only dot. * @param "TrailingBoth" (optional.String) - Leading both Trailing both. * @param "TrailingMultiline" (optional.String) - Leading multiline This is an example of a multi-line comment. Trailing multiline. * @param "Uuids" (optional.Interface of []string) - Specify a custom format of repeated field items @return interface{} */ type ABitOfEverythingServiceGetQueryOpts struct { SingleNestedName optional.String SingleNestedAmount optional.Int64 SingleNestedOk optional.String Uint64Value optional.String Int32Value optional.Int32 Fixed64Value optional.String Fixed32Value optional.Int64 BoolValue optional.Bool StringValue optional.String BytesValue optional.String Uint32Value optional.Int64 EnumValue optional.String PathEnumValue optional.String NestedPathEnumValue optional.String Sfixed32Value optional.Int32 Sfixed64Value optional.String Sint32Value optional.Int32 Sint64Value optional.String RepeatedStringValue optional.Interface OneofEmpty optional.Interface OneofString optional.String MapValue optional.Interface MappedStringValue optional.String MappedNestedValue optional.Interface NonConventionalNameValue optional.String TimestampValue optional.Time RepeatedEnumValue optional.Interface RepeatedEnumAnnotation optional.Interface EnumValueAnnotation optional.String RepeatedStringAnnotation optional.Interface NestedAnnotationName optional.String NestedAnnotationAmount optional.Int64 NestedAnnotationOk optional.String Int64OverrideType optional.Int64 OutputOnlyStringViaFieldBehaviorAnnotation optional.String OptionalStringValue optional.String ProductId optional.Interface OptionalStringField optional.String TrailingOnly optional.String TrailingOnlyDot optional.String TrailingBoth optional.String TrailingMultiline optional.String Uuids optional.Interface } func (a *ABitOfEverythingApiService) ABitOfEverythingServiceGetQuery(ctx context.Context, uuidName string, floatValue float32, doubleValue float64, int64Value string, requiredStringViaFieldBehaviorAnnotation string, requiredStringField1 string, requiredStringField2 string, requiredFieldBehaviorJsonNameCustom string, requiredFieldSchemaJsonNameCustom string, localVarOptionals *ABitOfEverythingServiceGetQueryOpts) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue interface{} ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/query/{uuidName}" localVarPath = strings.Replace(localVarPath, "{"+"uuidName"+"}", fmt.Sprintf("%v", uuidName), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.SingleNestedName.IsSet() { localVarQueryParams.Add("singleNested.name", parameterToString(localVarOptionals.SingleNestedName.Value(), "")) } if localVarOptionals != nil && localVarOptionals.SingleNestedAmount.IsSet() { localVarQueryParams.Add("singleNested.amount", parameterToString(localVarOptionals.SingleNestedAmount.Value(), "")) } if localVarOptionals != nil && localVarOptionals.SingleNestedOk.IsSet() { localVarQueryParams.Add("singleNested.ok", parameterToString(localVarOptionals.SingleNestedOk.Value(), "")) } localVarQueryParams.Add("floatValue", parameterToString(floatValue, "")) localVarQueryParams.Add("doubleValue", parameterToString(doubleValue, "")) localVarQueryParams.Add("int64Value", parameterToString(int64Value, "")) if localVarOptionals != nil && localVarOptionals.Uint64Value.IsSet() { localVarQueryParams.Add("uint64Value", parameterToString(localVarOptionals.Uint64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Int32Value.IsSet() { localVarQueryParams.Add("int32Value", parameterToString(localVarOptionals.Int32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Fixed64Value.IsSet() { localVarQueryParams.Add("fixed64Value", parameterToString(localVarOptionals.Fixed64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Fixed32Value.IsSet() { localVarQueryParams.Add("fixed32Value", parameterToString(localVarOptionals.Fixed32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.BoolValue.IsSet() { localVarQueryParams.Add("boolValue", parameterToString(localVarOptionals.BoolValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StringValue.IsSet() { localVarQueryParams.Add("stringValue", parameterToString(localVarOptionals.StringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.BytesValue.IsSet() { localVarQueryParams.Add("bytesValue", parameterToString(localVarOptionals.BytesValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Uint32Value.IsSet() { localVarQueryParams.Add("uint32Value", parameterToString(localVarOptionals.Uint32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.EnumValue.IsSet() { localVarQueryParams.Add("enumValue", parameterToString(localVarOptionals.EnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.PathEnumValue.IsSet() { localVarQueryParams.Add("pathEnumValue", parameterToString(localVarOptionals.PathEnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedPathEnumValue.IsSet() { localVarQueryParams.Add("nestedPathEnumValue", parameterToString(localVarOptionals.NestedPathEnumValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sfixed32Value.IsSet() { localVarQueryParams.Add("sfixed32Value", parameterToString(localVarOptionals.Sfixed32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sfixed64Value.IsSet() { localVarQueryParams.Add("sfixed64Value", parameterToString(localVarOptionals.Sfixed64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sint32Value.IsSet() { localVarQueryParams.Add("sint32Value", parameterToString(localVarOptionals.Sint32Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Sint64Value.IsSet() { localVarQueryParams.Add("sint64Value", parameterToString(localVarOptionals.Sint64Value.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedStringValue.IsSet() { localVarQueryParams.Add("repeatedStringValue", parameterToString(localVarOptionals.RepeatedStringValue.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.OneofEmpty.IsSet() { localVarQueryParams.Add("oneofEmpty", parameterToString(localVarOptionals.OneofEmpty.Value(), "")) } if localVarOptionals != nil && localVarOptionals.OneofString.IsSet() { localVarQueryParams.Add("oneofString", parameterToString(localVarOptionals.OneofString.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MapValue.IsSet() { localVarQueryParams.Add("mapValue", parameterToString(localVarOptionals.MapValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MappedStringValue.IsSet() { localVarQueryParams.Add("mappedStringValue", parameterToString(localVarOptionals.MappedStringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.MappedNestedValue.IsSet() { localVarQueryParams.Add("mappedNestedValue", parameterToString(localVarOptionals.MappedNestedValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NonConventionalNameValue.IsSet() { localVarQueryParams.Add("nonConventionalNameValue", parameterToString(localVarOptionals.NonConventionalNameValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TimestampValue.IsSet() { localVarQueryParams.Add("timestampValue", parameterToString(localVarOptionals.TimestampValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedEnumValue.IsSet() { localVarQueryParams.Add("repeatedEnumValue", parameterToString(localVarOptionals.RepeatedEnumValue.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.RepeatedEnumAnnotation.IsSet() { localVarQueryParams.Add("repeatedEnumAnnotation", parameterToString(localVarOptionals.RepeatedEnumAnnotation.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.EnumValueAnnotation.IsSet() { localVarQueryParams.Add("enumValueAnnotation", parameterToString(localVarOptionals.EnumValueAnnotation.Value(), "")) } if localVarOptionals != nil && localVarOptionals.RepeatedStringAnnotation.IsSet() { localVarQueryParams.Add("repeatedStringAnnotation", parameterToString(localVarOptionals.RepeatedStringAnnotation.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationName.IsSet() { localVarQueryParams.Add("nestedAnnotation.name", parameterToString(localVarOptionals.NestedAnnotationName.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationAmount.IsSet() { localVarQueryParams.Add("nestedAnnotation.amount", parameterToString(localVarOptionals.NestedAnnotationAmount.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NestedAnnotationOk.IsSet() { localVarQueryParams.Add("nestedAnnotation.ok", parameterToString(localVarOptionals.NestedAnnotationOk.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Int64OverrideType.IsSet() { localVarQueryParams.Add("int64OverrideType", parameterToString(localVarOptionals.Int64OverrideType.Value(), "")) } localVarQueryParams.Add("requiredStringViaFieldBehaviorAnnotation", parameterToString(requiredStringViaFieldBehaviorAnnotation, "")) if localVarOptionals != nil && localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.IsSet() { localVarQueryParams.Add("outputOnlyStringViaFieldBehaviorAnnotation", parameterToString(localVarOptionals.OutputOnlyStringViaFieldBehaviorAnnotation.Value(), "")) } if localVarOptionals != nil && localVarOptionals.OptionalStringValue.IsSet() { localVarQueryParams.Add("optionalStringValue", parameterToString(localVarOptionals.OptionalStringValue.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ProductId.IsSet() { localVarQueryParams.Add("productId", parameterToString(localVarOptionals.ProductId.Value(), "multi")) } if localVarOptionals != nil && localVarOptionals.OptionalStringField.IsSet() { localVarQueryParams.Add("optionalStringField", parameterToString(localVarOptionals.OptionalStringField.Value(), "")) } localVarQueryParams.Add("requiredStringField1", parameterToString(requiredStringField1, "")) localVarQueryParams.Add("requiredStringField2", parameterToString(requiredStringField2, "")) localVarQueryParams.Add("required_field_behavior_json_name_custom", parameterToString(requiredFieldBehaviorJsonNameCustom, "")) localVarQueryParams.Add("required_field_schema_json_name_custom", parameterToString(requiredFieldSchemaJsonNameCustom, "")) if localVarOptionals != nil && localVarOptionals.TrailingOnly.IsSet() { localVarQueryParams.Add("trailingOnly", parameterToString(localVarOptionals.TrailingOnly.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingOnlyDot.IsSet() { localVarQueryParams.Add("trailingOnlyDot", parameterToString(localVarOptionals.TrailingOnlyDot.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingBoth.IsSet() { localVarQueryParams.Add("trailingBoth", parameterToString(localVarOptionals.TrailingBoth.Value(), "")) } if localVarOptionals != nil && localVarOptionals.TrailingMultiline.IsSet() { localVarQueryParams.Add("trailingMultiline", parameterToString(localVarOptionals.TrailingMultiline.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Uuids.IsSet() { localVarQueryParams.Add("uuids", parameterToString(localVarOptionals.Uuids.Value(), "multi")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param pathRepeatedFloatValue repeated values. they are comma-separated in path * @param pathRepeatedDoubleValue * @param pathRepeatedInt64Value * @param pathRepeatedUint64Value * @param pathRepeatedInt32Value * @param pathRepeatedFixed64Value * @param pathRepeatedFixed32Value * @param pathRepeatedBoolValue * @param pathRepeatedStringValue * @param pathRepeatedBytesValue * @param pathRepeatedUint32Value * @param pathRepeatedEnumValue * @param pathRepeatedSfixed32Value * @param pathRepeatedSfixed64Value * @param pathRepeatedSint32Value * @param pathRepeatedSint64Value @return ExamplepbABitOfEverythingRepeated */ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceGetRepeatedQuery(ctx context.Context, pathRepeatedFloatValue []float32, pathRepeatedDoubleValue []float64, pathRepeatedInt64Value []string, pathRepeatedUint64Value []string, pathRepeatedInt32Value []int32, pathRepeatedFixed64Value []string, pathRepeatedFixed32Value []int64, pathRepeatedBoolValue []bool, pathRepeatedStringValue []string, pathRepeatedBytesValue []string, pathRepeatedUint32Value []int64, pathRepeatedEnumValue []string, pathRepeatedSfixed32Value []int32, pathRepeatedSfixed64Value []string, pathRepeatedSint32Value []int32, pathRepeatedSint64Value []string) (ExamplepbABitOfEverythingRepeated, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbABitOfEverythingRepeated ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything_repeated/{pathRepeatedFloatValue}/{pathRepeatedDoubleValue}/{pathRepeatedInt64Value}/{pathRepeatedUint64Value}/{pathRepeatedInt32Value}/{pathRepeatedFixed64Value}/{pathRepeatedFixed32Value}/{pathRepeatedBoolValue}/{pathRepeatedStringValue}/{pathRepeatedBytesValue}/{pathRepeatedUint32Value}/{pathRepeatedEnumValue}/{pathRepeatedSfixed32Value}/{pathRepeatedSfixed64Value}/{pathRepeatedSint32Value}/{pathRepeatedSint64Value}" localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedFloatValue"+"}", fmt.Sprintf("%v", pathRepeatedFloatValue), -1) localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedDoubleValue"+"}", fmt.Sprintf("%v", pathRepeatedDoubleValue), -1) localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedInt64Value"+"}", fmt.Sprintf("%v", pathRepeatedInt64Value), -1) localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedUint64Value"+"}", fmt.Sprintf("%v", pathRepeatedUint64Value), -1) localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedInt32Value"+"}", fmt.Sprintf("%v", pathRepeatedInt32Value), -1) localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedFixed64Value"+"}", fmt.Sprintf("%v", pathRepeatedFixed64Value), -1) localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedFixed32Value"+"}", fmt.Sprintf("%v", pathRepeatedFixed32Value), -1) localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedBoolValue"+"}", fmt.Sprintf("%v", pathRepeatedBoolValue), -1) localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedStringValue"+"}", fmt.Sprintf("%v", pathRepeatedStringValue), -1) localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedBytesValue"+"}", fmt.Sprintf("%v", pathRepeatedBytesValue), -1) localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedUint32Value"+"}", fmt.Sprintf("%v", pathRepeatedUint32Value), -1) localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedEnumValue"+"}", fmt.Sprintf("%v", pathRepeatedEnumValue), -1) localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedSfixed32Value"+"}", fmt.Sprintf("%v", pathRepeatedSfixed32Value), -1) localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedSfixed64Value"+"}", fmt.Sprintf("%v", pathRepeatedSfixed64Value), -1) localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedSint32Value"+"}", fmt.Sprintf("%v", pathRepeatedSint32Value), -1) localVarPath = strings.Replace(localVarPath, "{"+"pathRepeatedSint64Value"+"}", fmt.Sprintf("%v", pathRepeatedSint64Value), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if len(pathRepeatedFloatValue) < 1 { return localVarReturnValue, nil, reportError("pathRepeatedFloatValue must have at least 1 elements") } if len(pathRepeatedDoubleValue) < 1 { return localVarReturnValue, nil, reportError("pathRepeatedDoubleValue must have at least 1 elements") } if len(pathRepeatedInt64Value) < 1 { return localVarReturnValue, nil, reportError("pathRepeatedInt64Value must have at least 1 elements") } if len(pathRepeatedUint64Value) < 1 { return localVarReturnValue, nil, reportError("pathRepeatedUint64Value must have at least 1 elements") } if len(pathRepeatedInt32Value) < 1 { return localVarReturnValue, nil, reportError("pathRepeatedInt32Value must have at least 1 elements") } if len(pathRepeatedFixed64Value) < 1 { return localVarReturnValue, nil, reportError("pathRepeatedFixed64Value must have at least 1 elements") } if len(pathRepeatedFixed32Value) < 1 { return localVarReturnValue, nil, reportError("pathRepeatedFixed32Value must have at least 1 elements") } if len(pathRepeatedBoolValue) < 1 { return localVarReturnValue, nil, reportError("pathRepeatedBoolValue must have at least 1 elements") } if len(pathRepeatedStringValue) < 1 { return localVarReturnValue, nil, reportError("pathRepeatedStringValue must have at least 1 elements") } if len(pathRepeatedBytesValue) < 1 { return localVarReturnValue, nil, reportError("pathRepeatedBytesValue must have at least 1 elements") } if len(pathRepeatedUint32Value) < 1 { return localVarReturnValue, nil, reportError("pathRepeatedUint32Value must have at least 1 elements") } if len(pathRepeatedEnumValue) < 1 { return localVarReturnValue, nil, reportError("pathRepeatedEnumValue must have at least 1 elements") } if len(pathRepeatedSfixed32Value) < 1 { return localVarReturnValue, nil, reportError("pathRepeatedSfixed32Value must have at least 1 elements") } if len(pathRepeatedSfixed64Value) < 1 { return localVarReturnValue, nil, reportError("pathRepeatedSfixed64Value must have at least 1 elements") } if len(pathRepeatedSint32Value) < 1 { return localVarReturnValue, nil, reportError("pathRepeatedSint32Value must have at least 1 elements") } if len(pathRepeatedSint64Value) < 1 { return localVarReturnValue, nil, reportError("pathRepeatedSint64Value must have at least 1 elements") } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbABitOfEverythingRepeated err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuid @return ExamplepbABitOfEverything */ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceLookup(ctx context.Context, uuid string) (ExamplepbABitOfEverything, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbABitOfEverything ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/{uuid}" localVarPath = strings.Replace(localVarPath, "{"+"uuid"+"}", fmt.Sprintf("%v", uuid), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbABitOfEverything err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param body @return interface{} */ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceOverwriteRequestContentType(ctx context.Context, body ExamplepbBody) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue interface{} ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v2/example/overwriterequestcontenttype" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/x-bar-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @return string */ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceOverwriteResponseContentType(ctx context.Context) (string, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue string ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v2/example/overwriteresponsecontenttype" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/text"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param exampleEnum @return interface{} */ func (a *ABitOfEverythingApiService) ABitOfEverythingServicePostOneofEnum(ctx context.Context, exampleEnum OneofenumExampleEnum) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue interface{} ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/oneofenum" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &exampleEnum if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param body @return interface{} */ func (a *ABitOfEverythingApiService) ABitOfEverythingServicePostRequiredMessageType(ctx context.Context, body ExamplepbRequiredMessageTypeRequest) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue interface{} ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/requiredmessagetype" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param name * @param body @return interface{} */ func (a *ABitOfEverythingApiService) ABitOfEverythingServicePostWithEmptyBody(ctx context.Context, name string, body ABitOfEverythingServicePostWithEmptyBodyBody) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue interface{} ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v2/example/postwithemptybody/{name}" localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", fmt.Sprintf("%v", name), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @return interface{} */ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceTimeout(ctx context.Context) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue interface{} ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v2/example/timeout" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuidName * @param body @return interface{} */ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceUpdate(ctx context.Context, uuidName string, body ExamplepbABitOfEverythingServiceUpdateBody) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Put") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue interface{} ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/{uuidName}" localVarPath = strings.Replace(localVarPath, "{"+"uuidName"+"}", fmt.Sprintf("%v", uuidName), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param bookName The resource name of the book. Format: `publishers/{publisher}/books/{book}` Example: `publishers/1257894000000000000/books/my-book` * @param book The book to update. The book's `name` field is used to identify the book to be updated. Format: publishers/{publisher}/books/{book} * @param optional nil or *ABitOfEverythingServiceUpdateBookOpts - Optional Parameters: * @param "AllowMissing" (optional.Bool) - If set to true, and the book is not found, a new book will be created. In this situation, `update_mask` is ignored. @return ExamplepbBook */ type ABitOfEverythingServiceUpdateBookOpts struct { AllowMissing optional.Bool } func (a *ABitOfEverythingApiService) ABitOfEverythingServiceUpdateBook(ctx context.Context, bookName string, book TheBookToUpdate_, localVarOptionals *ABitOfEverythingServiceUpdateBookOpts) (ExamplepbBook, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Patch") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbBook ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/{book.name}" localVarPath = strings.Replace(localVarPath, "{"+"book.name"+"}", fmt.Sprintf("%v", bookName), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.AllowMissing.IsSet() { localVarQueryParams.Add("allowMissing", parameterToString(localVarOptionals.AllowMissing.Value(), "")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &book if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbBook err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuidName * @param abe A bit of everything Intentionally complicated message type to cover many features of Protobuf. * @param optional nil or *ABitOfEverythingServiceUpdateV2Opts - Optional Parameters: * @param "UpdateMask" (optional.String) - The paths to update. @return interface{} */ type ABitOfEverythingServiceUpdateV2Opts struct { UpdateMask optional.String } func (a *ABitOfEverythingApiService) ABitOfEverythingServiceUpdateV2(ctx context.Context, uuidName string, abe ABitOfEverything, localVarOptionals *ABitOfEverythingServiceUpdateV2Opts) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Put") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue interface{} ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v2/example/a_bit_of_everything/{uuidName}" localVarPath = strings.Replace(localVarPath, "{"+"uuidName"+"}", fmt.Sprintf("%v", uuidName), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.UpdateMask.IsSet() { localVarQueryParams.Add("updateMask", parameterToString(localVarOptionals.UpdateMask.Value(), "")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &abe if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuidName * @param abe A bit of everything Intentionally complicated message type to cover many features of Protobuf. @return interface{} */ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceUpdateV22(ctx context.Context, uuidName string, abe ABitOfEverything1) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Patch") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue interface{} ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v2/example/a_bit_of_everything/{uuidName}" localVarPath = strings.Replace(localVarPath, "{"+"uuidName"+"}", fmt.Sprintf("%v", uuidName), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &abe if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ABitOfEverythingApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param uuidName * @param body @return interface{} */ func (a *ABitOfEverythingApiService) ABitOfEverythingServiceUpdateV23(ctx context.Context, uuidName string, body ABitOfEverythingServiceUpdateV2Body) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Patch") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue interface{} ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v2a/example/a_bit_of_everything/{uuidName}" localVarPath = strings.Replace(localVarPath, "{"+"uuidName"+"}", fmt.Sprintf("%v", uuidName), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } ================================================ FILE: examples/internal/clients/abe/api_camel_case_service_name.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "context" "io/ioutil" "net/http" "net/url" "strings" ) // Linger please var ( _ context.Context ) type CamelCaseServiceNameApiService service /* CamelCaseServiceNameApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @return interface{} */ func (a *CamelCaseServiceNameApiService) CamelCaseServiceNameEmpty(ctx context.Context) (interface{}, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue interface{} ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v2/example/empty" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } ================================================ FILE: examples/internal/clients/abe/api_echo_rpc.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "context" "io/ioutil" "net/http" "net/url" "strings" "fmt" "github.com/antihax/optional" ) // Linger please var ( _ context.Context ) type EchoRpcApiService service /* EchoRpcApiService Summary: Echo rpc Description Echo * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param value @return SubStringMessage */ func (a *EchoRpcApiService) ABitOfEverythingServiceEcho(ctx context.Context, value string) (SubStringMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue SubStringMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/echo/{value}" localVarPath = strings.Replace(localVarPath, "{"+"value"+"}", fmt.Sprintf("%v", value), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v SubStringMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v int32 err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 503 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* EchoRpcApiService Summary: Echo rpc Description Echo * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param value @return SubStringMessage */ func (a *EchoRpcApiService) ABitOfEverythingServiceEcho2(ctx context.Context, value string) (SubStringMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue SubStringMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v2/example/echo" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &value if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v SubStringMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v int32 err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 503 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* EchoRpcApiService Summary: Echo rpc Description Echo * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param optional nil or *ABitOfEverythingServiceEcho3Opts - Optional Parameters: * @param "Value" (optional.String) - @return SubStringMessage */ type ABitOfEverythingServiceEcho3Opts struct { Value optional.String } func (a *EchoRpcApiService) ABitOfEverythingServiceEcho3(ctx context.Context, localVarOptionals *ABitOfEverythingServiceEcho3Opts) (SubStringMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue SubStringMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v2/example/echo" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.Value.IsSet() { localVarQueryParams.Add("value", parameterToString(localVarOptionals.Value.Value(), "")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v SubStringMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v int32 err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 503 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } ================================================ FILE: examples/internal/clients/abe/api_snake_enum_service.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "context" "io/ioutil" "net/http" "net/url" "strings" "fmt" ) // Linger please var ( _ context.Context ) type SnakeEnumServiceApiService service /* SnakeEnumServiceApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param who * @param what * @param where @return ExamplepbSnakeEnumResponse */ func (a *SnakeEnumServiceApiService) SnakeEnumServiceSnakeEnum(ctx context.Context, who string, what string, where string) (ExamplepbSnakeEnumResponse, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbSnakeEnumResponse ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/snake/{who}/{what}/{where}" localVarPath = strings.Replace(localVarPath, "{"+"who"+"}", fmt.Sprintf("%v", who), -1) localVarPath = strings.Replace(localVarPath, "{"+"what"+"}", fmt.Sprintf("%v", what), -1) localVarPath = strings.Replace(localVarPath, "{"+"where"+"}", fmt.Sprintf("%v", where), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbSnakeEnumResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 418 { var v ExamplepbNumericEnum err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 500 { var v ExamplepbErrorResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } ================================================ FILE: examples/internal/clients/abe/client.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "bytes" "context" "encoding/json" "encoding/xml" "errors" "fmt" "io" "mime/multipart" "net/http" "net/url" "os" "path/filepath" "reflect" "regexp" "strconv" "strings" "time" "unicode/utf8" "golang.org/x/oauth2" ) var ( jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") ) // APIClient manages communication with the A Bit of Everything API v1.0 // In most cases there should be only one, shared, APIClient. type APIClient struct { cfg *Configuration common service // Reuse a single struct instead of allocating one for each service on the heap. // API Services ABitOfEverythingApi *ABitOfEverythingApiService CamelCaseServiceNameApi *CamelCaseServiceNameApiService EchoRpcApi *EchoRpcApiService SnakeEnumServiceApi *SnakeEnumServiceApiService } type service struct { client *APIClient } // NewAPIClient creates a new API client. Requires a userAgent string describing your application. // optionally a custom http.Client to allow for advanced features such as caching. func NewAPIClient(cfg *Configuration) *APIClient { if cfg.HTTPClient == nil { cfg.HTTPClient = http.DefaultClient } c := &APIClient{} c.cfg = cfg c.common.client = c // API Services c.ABitOfEverythingApi = (*ABitOfEverythingApiService)(&c.common) c.CamelCaseServiceNameApi = (*CamelCaseServiceNameApiService)(&c.common) c.EchoRpcApi = (*EchoRpcApiService)(&c.common) c.SnakeEnumServiceApi = (*SnakeEnumServiceApiService)(&c.common) return c } func atoi(in string) (int, error) { return strconv.Atoi(in) } // selectHeaderContentType select a content type from the available list. func selectHeaderContentType(contentTypes []string) string { if len(contentTypes) == 0 { return "" } if contains(contentTypes, "application/json") { return "application/json" } return contentTypes[0] // use the first content type specified in 'consumes' } // selectHeaderAccept join all accept types and return func selectHeaderAccept(accepts []string) string { if len(accepts) == 0 { return "" } if contains(accepts, "application/json") { return "application/json" } return strings.Join(accepts, ",") } // contains is a case insenstive match, finding needle in a haystack func contains(haystack []string, needle string) bool { for _, a := range haystack { if strings.ToLower(a) == strings.ToLower(needle) { return true } } return false } // Verify optional parameters are of the correct type. func typeCheckParameter(obj interface{}, expected string, name string) error { // Make sure there is an object. if obj == nil { return nil } // Check the type is as expected. if reflect.TypeOf(obj).String() != expected { return fmt.Errorf("Expected %s to be of type %s but received %s.", name, expected, reflect.TypeOf(obj).String()) } return nil } // parameterToString convert interface{} parameters to string, using a delimiter if format is provided. func parameterToString(obj interface{}, collectionFormat string) string { var delimiter string switch collectionFormat { case "pipes": delimiter = "|" case "ssv": delimiter = " " case "tsv": delimiter = "\t" case "csv": delimiter = "," } if reflect.TypeOf(obj).Kind() == reflect.Slice { return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]") } return fmt.Sprintf("%v", obj) } // callAPI do the request. func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { return c.cfg.HTTPClient.Do(request) } // Change base path to allow switching to mocks func (c *APIClient) ChangeBasePath(path string) { c.cfg.BasePath = path } // prepareRequest build the request func (c *APIClient) prepareRequest( ctx context.Context, path string, method string, postBody interface{}, headerParams map[string]string, queryParams url.Values, formParams url.Values, fileName string, fileBytes []byte) (localVarRequest *http.Request, err error) { var body *bytes.Buffer // Detect postBody type and post. if postBody != nil { contentType := headerParams["Content-Type"] if contentType == "" { contentType = detectContentType(postBody) headerParams["Content-Type"] = contentType } body, err = setBody(postBody, contentType) if err != nil { return nil, err } } // add form parameters and file if available. if len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") { if body != nil { return nil, errors.New("Cannot specify postBody and multipart form at the same time.") } body = &bytes.Buffer{} w := multipart.NewWriter(body) for k, v := range formParams { for _, iv := range v { if strings.HasPrefix(k, "@") { // file err = addFile(w, k[1:], iv) if err != nil { return nil, err } } else { // form value w.WriteField(k, iv) } } } if len(fileBytes) > 0 && fileName != "" { w.Boundary() //_, fileNm := filepath.Split(fileName) part, err := w.CreateFormFile("file", filepath.Base(fileName)) if err != nil { return nil, err } _, err = part.Write(fileBytes) if err != nil { return nil, err } // Set the Boundary in the Content-Type headerParams["Content-Type"] = w.FormDataContentType() } // Set Content-Length headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) w.Close() } // Setup path and query parameters url, err := url.Parse(path) if err != nil { return nil, err } // Adding Query Param query := url.Query() for k, v := range queryParams { for _, iv := range v { query.Add(k, iv) } } // Encode the parameters. url.RawQuery = query.Encode() // Generate a new request if body != nil { localVarRequest, err = http.NewRequest(method, url.String(), body) } else { localVarRequest, err = http.NewRequest(method, url.String(), nil) } if err != nil { return nil, err } // add header parameters, if any if len(headerParams) > 0 { headers := http.Header{} for h, v := range headerParams { headers.Set(h, v) } localVarRequest.Header = headers } // Override request host, if applicable if c.cfg.Host != "" { localVarRequest.Host = c.cfg.Host } // Add the user agent to the request. localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) if ctx != nil { // add context to the request localVarRequest = localVarRequest.WithContext(ctx) // Walk through any authentication. // OAuth2 authentication if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok { // We were able to grab an oauth2 token from the context var latestToken *oauth2.Token if latestToken, err = tok.Token(); err != nil { return nil, err } latestToken.SetAuthHeader(localVarRequest) } // Basic HTTP Authentication if auth, ok := ctx.Value(ContextBasicAuth).(BasicAuth); ok { localVarRequest.SetBasicAuth(auth.UserName, auth.Password) } // AccessToken Authentication if auth, ok := ctx.Value(ContextAccessToken).(string); ok { localVarRequest.Header.Add("Authorization", "Bearer "+auth) } } for header, value := range c.cfg.DefaultHeader { localVarRequest.Header.Add(header, value) } return localVarRequest, nil } func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { if strings.Contains(contentType, "application/xml") { if err = xml.Unmarshal(b, v); err != nil { return err } return nil } else if strings.Contains(contentType, "application/json") { if err = json.Unmarshal(b, v); err != nil { return err } return nil } return errors.New("undefined response type") } // Add a file to the multipart request func addFile(w *multipart.Writer, fieldName, path string) error { file, err := os.Open(path) if err != nil { return err } defer file.Close() part, err := w.CreateFormFile(fieldName, filepath.Base(path)) if err != nil { return err } _, err = io.Copy(part, file) return err } // Prevent trying to import "fmt" func reportError(format string, a ...interface{}) error { return fmt.Errorf(format, a...) } // Set request body from an interface{} func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { if bodyBuf == nil { bodyBuf = &bytes.Buffer{} } if reader, ok := body.(io.Reader); ok { _, err = bodyBuf.ReadFrom(reader) } else if b, ok := body.([]byte); ok { _, err = bodyBuf.Write(b) } else if s, ok := body.(string); ok { _, err = bodyBuf.WriteString(s) } else if s, ok := body.(*string); ok { _, err = bodyBuf.WriteString(*s) } else if jsonCheck.MatchString(contentType) { err = json.NewEncoder(bodyBuf).Encode(body) } else if xmlCheck.MatchString(contentType) { xml.NewEncoder(bodyBuf).Encode(body) } if err != nil { return nil, err } if bodyBuf.Len() == 0 { err = fmt.Errorf("Invalid body type %s\n", contentType) return nil, err } return bodyBuf, nil } // detectContentType method is used to figure out `Request.Body` content type for request header func detectContentType(body interface{}) string { contentType := "text/plain; charset=utf-8" kind := reflect.TypeOf(body).Kind() switch kind { case reflect.Struct, reflect.Map, reflect.Ptr: contentType = "application/json; charset=utf-8" case reflect.String: contentType = "text/plain; charset=utf-8" default: if b, ok := body.([]byte); ok { contentType = http.DetectContentType(b) } else if kind == reflect.Slice { contentType = "application/json; charset=utf-8" } } return contentType } // Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go type cacheControl map[string]string func parseCacheControl(headers http.Header) cacheControl { cc := cacheControl{} ccHeader := headers.Get("Cache-Control") for _, part := range strings.Split(ccHeader, ",") { part = strings.Trim(part, " ") if part == "" { continue } if strings.ContainsRune(part, '=') { keyval := strings.Split(part, "=") cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") } else { cc[part] = "" } } return cc } // CacheExpires helper function to determine remaining time before repeating a request. func CacheExpires(r *http.Response) time.Time { // Figure out when the cache expires. var expires time.Time now, err := time.Parse(time.RFC1123, r.Header.Get("date")) if err != nil { return time.Now() } respCacheControl := parseCacheControl(r.Header) if maxAge, ok := respCacheControl["max-age"]; ok { lifetime, err := time.ParseDuration(maxAge + "s") if err != nil { expires = now } expires = now.Add(lifetime) } else { expiresHeader := r.Header.Get("Expires") if expiresHeader != "" { expires, err = time.Parse(time.RFC1123, expiresHeader) if err != nil { expires = now } } } return expires } func strlen(s string) int { return utf8.RuneCountInString(s) } // GenericSwaggerError Provides access to the body, error and model on returned errors. type GenericSwaggerError struct { body []byte error string model interface{} } // Error returns non-empty string if there was an error. func (e GenericSwaggerError) Error() string { return e.error } // Body returns the raw bytes of the response func (e GenericSwaggerError) Body() []byte { return e.body } // Model returns the unpacked model of the error func (e GenericSwaggerError) Model() interface{} { return e.model } ================================================ FILE: examples/internal/clients/abe/configuration.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "net/http" ) // contextKeys are used to identify the type of value in the context. // Since these are string, it is possible to get a short description of the // context key for logging and debugging using key.String(). type contextKey string func (c contextKey) String() string { return "auth " + string(c) } var ( // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. ContextOAuth2 = contextKey("token") // ContextBasicAuth takes BasicAuth as authentication for the request. ContextBasicAuth = contextKey("basic") // ContextAccessToken takes a string oauth2 access token as authentication for the request. ContextAccessToken = contextKey("accesstoken") // ContextAPIKey takes an APIKey as authentication for the request ContextAPIKey = contextKey("apikey") ) // BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth type BasicAuth struct { UserName string `json:"userName,omitempty"` Password string `json:"password,omitempty"` } // APIKey provides API key based authentication to a request passed via context using ContextAPIKey type APIKey struct { Key string Prefix string } type Configuration struct { BasePath string `json:"basePath,omitempty"` Host string `json:"host,omitempty"` Scheme string `json:"scheme,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"` UserAgent string `json:"userAgent,omitempty"` HTTPClient *http.Client } func NewConfiguration() *Configuration { cfg := &Configuration{ BasePath: "http://localhost", DefaultHeader: make(map[string]string), UserAgent: "Swagger-Codegen/1.0.0/go", } return cfg } func (c *Configuration) AddDefaultHeader(key string, value string) { c.DefaultHeader[key] = value } ================================================ FILE: examples/internal/clients/abe/enum_helper.go ================================================ package abe import ( pbexamplepb "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb" pbpathenum "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/pathenum" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" ) // String returns a string representation of "NumericEnum" func (e ExamplepbNumericEnum) String() string { return pbexamplepb.NumericEnum_ONE.String() } // UnmarshalJSON does a no-op unmarshal to ExamplepbNumericEnum. // It just validates that the input is sane. func (e ExamplepbNumericEnum) UnmarshalJSON(b []byte) error { return unmarshalJSONEnum(b, pbexamplepb.NumericEnum_value) } // String returns a string representation of "MessagePathEnum" func (e MessagePathEnumNestedPathEnum) String() string { return pbpathenum.MessagePathEnum_JKL.String() } // UnmarshalJSON does a no-op unmarshal to MessagePathEnumNestedPathEnum. // It just validates that the input is sane. func (e MessagePathEnumNestedPathEnum) UnmarshalJSON(b []byte) error { return unmarshalJSONEnum(b, pbpathenum.MessagePathEnum_NestedPathEnum_value) } // String returns a string representation of "PathEnum" func (e PathenumPathEnum) String() string { return pbpathenum.PathEnum_DEF.String() } // UnmarshalJSON does a no-op unmarshal to PathenumPathEnum. // It just validates that the input is sane. func (e PathenumPathEnum) UnmarshalJSON(b []byte) error { return unmarshalJSONEnum(b, pbpathenum.PathEnum_value) } func unmarshalJSONEnum(b []byte, enumValMap map[string]int32) error { val := string(b[1 : len(b)-1]) _, err := runtime.Enum(val, enumValMap) return err } ================================================ FILE: examples/internal/clients/abe/model_a_bit_of_everything.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "time" ) // Intentionally complicated message type to cover many features of Protobuf. type ABitOfEverything struct { SingleNested *ABitOfEverythingNested `json:"singleNested,omitempty"` Nested []ABitOfEverythingNested `json:"nested,omitempty"` // Float value field FloatValue float32 `json:"floatValue"` DoubleValue float64 `json:"doubleValue"` Int64Value string `json:"int64Value"` Uint64Value string `json:"uint64Value,omitempty"` Int32Value int32 `json:"int32Value,omitempty"` Fixed64Value string `json:"fixed64Value,omitempty"` Fixed32Value int64 `json:"fixed32Value,omitempty"` BoolValue bool `json:"boolValue,omitempty"` StringValue string `json:"stringValue,omitempty"` BytesValue string `json:"bytesValue,omitempty"` Uint32Value int64 `json:"uint32Value,omitempty"` EnumValue *ExamplepbNumericEnum `json:"enumValue,omitempty"` PathEnumValue *PathenumPathEnum `json:"pathEnumValue,omitempty"` NestedPathEnumValue *MessagePathEnumNestedPathEnum `json:"nestedPathEnumValue,omitempty"` Sfixed32Value int32 `json:"sfixed32Value,omitempty"` Sfixed64Value string `json:"sfixed64Value,omitempty"` Sint32Value int32 `json:"sint32Value,omitempty"` Sint64Value string `json:"sint64Value,omitempty"` RepeatedStringValue []string `json:"repeatedStringValue,omitempty"` OneofEmpty *interface{} `json:"oneofEmpty,omitempty"` OneofString string `json:"oneofString,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"` // Map of string description. MappedStringValue map[string]string `json:"mappedStringValue,omitempty"` MappedNestedValue map[string]ABitOfEverythingNested `json:"mappedNestedValue,omitempty"` NonConventionalNameValue string `json:"nonConventionalNameValue,omitempty"` TimestampValue time.Time `json:"timestampValue,omitempty"` RepeatedEnumValue []ExamplepbNumericEnum `json:"repeatedEnumValue,omitempty"` // Repeated numeric enum description. RepeatedEnumAnnotation []ExamplepbNumericEnum `json:"repeatedEnumAnnotation,omitempty"` // Numeric enum description. EnumValueAnnotation *ExamplepbNumericEnum `json:"enumValueAnnotation,omitempty"` // Repeated string description. RepeatedStringAnnotation []string `json:"repeatedStringAnnotation,omitempty"` // Repeated nested object description. RepeatedNestedAnnotation []ABitOfEverythingNested `json:"repeatedNestedAnnotation,omitempty"` // Nested object description. NestedAnnotation *ABitOfEverythingNested `json:"nestedAnnotation,omitempty"` Int64OverrideType int64 `json:"int64OverrideType,omitempty"` RequiredStringViaFieldBehaviorAnnotation string `json:"requiredStringViaFieldBehaviorAnnotation"` OutputOnlyStringViaFieldBehaviorAnnotation string `json:"outputOnlyStringViaFieldBehaviorAnnotation,omitempty"` OptionalStringValue string `json:"optionalStringValue,omitempty"` // Only digits are allowed. ProductId []string `json:"productId,omitempty"` OptionalStringField string `json:"optionalStringField,omitempty"` RequiredStringField1 string `json:"requiredStringField1"` RequiredStringField2 string `json:"requiredStringField2"` RequiredFieldBehaviorJsonNameCustom string `json:"required_field_behavior_json_name_custom"` RequiredFieldSchemaJsonNameCustom string `json:"required_field_schema_json_name_custom"` TrailingOnly string `json:"trailingOnly,omitempty"` // Trailing only dot. TrailingOnlyDot string `json:"trailingOnlyDot,omitempty"` // Trailing both. TrailingBoth string `json:"trailingBoth,omitempty"` // This is an example of a multi-line comment. Trailing multiline. TrailingMultiline string `json:"trailingMultiline,omitempty"` Uuids []string `json:"uuids,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_a_bit_of_everything_1.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "time" ) // Intentionally complicated message type to cover many features of Protobuf. type ABitOfEverything1 struct { SingleNested *ABitOfEverythingNested `json:"singleNested,omitempty"` Nested []ABitOfEverythingNested `json:"nested,omitempty"` // Float value field FloatValue float32 `json:"floatValue"` DoubleValue float64 `json:"doubleValue"` Int64Value string `json:"int64Value"` Uint64Value string `json:"uint64Value,omitempty"` Int32Value int32 `json:"int32Value,omitempty"` Fixed64Value string `json:"fixed64Value,omitempty"` Fixed32Value int64 `json:"fixed32Value,omitempty"` BoolValue bool `json:"boolValue,omitempty"` StringValue string `json:"stringValue,omitempty"` BytesValue string `json:"bytesValue,omitempty"` Uint32Value int64 `json:"uint32Value,omitempty"` EnumValue *ExamplepbNumericEnum `json:"enumValue,omitempty"` PathEnumValue *PathenumPathEnum `json:"pathEnumValue,omitempty"` NestedPathEnumValue *MessagePathEnumNestedPathEnum `json:"nestedPathEnumValue,omitempty"` Sfixed32Value int32 `json:"sfixed32Value,omitempty"` Sfixed64Value string `json:"sfixed64Value,omitempty"` Sint32Value int32 `json:"sint32Value,omitempty"` Sint64Value string `json:"sint64Value,omitempty"` RepeatedStringValue []string `json:"repeatedStringValue,omitempty"` OneofEmpty *interface{} `json:"oneofEmpty,omitempty"` OneofString string `json:"oneofString,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"` // Map of string description. MappedStringValue map[string]string `json:"mappedStringValue,omitempty"` MappedNestedValue map[string]ABitOfEverythingNested `json:"mappedNestedValue,omitempty"` NonConventionalNameValue string `json:"nonConventionalNameValue,omitempty"` TimestampValue time.Time `json:"timestampValue,omitempty"` RepeatedEnumValue []ExamplepbNumericEnum `json:"repeatedEnumValue,omitempty"` // Repeated numeric enum description. RepeatedEnumAnnotation []ExamplepbNumericEnum `json:"repeatedEnumAnnotation,omitempty"` // Numeric enum description. EnumValueAnnotation *ExamplepbNumericEnum `json:"enumValueAnnotation,omitempty"` // Repeated string description. RepeatedStringAnnotation []string `json:"repeatedStringAnnotation,omitempty"` // Repeated nested object description. RepeatedNestedAnnotation []ABitOfEverythingNested `json:"repeatedNestedAnnotation,omitempty"` // Nested object description. NestedAnnotation *ABitOfEverythingNested `json:"nestedAnnotation,omitempty"` Int64OverrideType int64 `json:"int64OverrideType,omitempty"` RequiredStringViaFieldBehaviorAnnotation string `json:"requiredStringViaFieldBehaviorAnnotation"` OutputOnlyStringViaFieldBehaviorAnnotation string `json:"outputOnlyStringViaFieldBehaviorAnnotation,omitempty"` OptionalStringValue string `json:"optionalStringValue,omitempty"` // Only digits are allowed. ProductId []string `json:"productId,omitempty"` OptionalStringField string `json:"optionalStringField,omitempty"` RequiredStringField1 string `json:"requiredStringField1"` RequiredStringField2 string `json:"requiredStringField2"` RequiredFieldBehaviorJsonNameCustom string `json:"required_field_behavior_json_name_custom"` RequiredFieldSchemaJsonNameCustom string `json:"required_field_schema_json_name_custom"` TrailingOnly string `json:"trailingOnly,omitempty"` // Trailing only dot. TrailingOnlyDot string `json:"trailingOnlyDot,omitempty"` // Trailing both. TrailingBoth string `json:"trailingBoth,omitempty"` // This is an example of a multi-line comment. Trailing multiline. TrailingMultiline string `json:"trailingMultiline,omitempty"` Uuids []string `json:"uuids,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_a_bit_of_everything_2.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "time" ) // Intentionally complicated message type to cover many features of Protobuf. type ABitOfEverything2 struct { SingleNested *ABitOfEverythingNested `json:"singleNested,omitempty"` Nested []ABitOfEverythingNested `json:"nested,omitempty"` // Float value field FloatValue float32 `json:"floatValue"` DoubleValue float64 `json:"doubleValue"` Int64Value string `json:"int64Value"` Uint64Value string `json:"uint64Value,omitempty"` Int32Value int32 `json:"int32Value,omitempty"` Fixed64Value string `json:"fixed64Value,omitempty"` Fixed32Value int64 `json:"fixed32Value,omitempty"` BoolValue bool `json:"boolValue,omitempty"` StringValue string `json:"stringValue,omitempty"` BytesValue string `json:"bytesValue,omitempty"` Uint32Value int64 `json:"uint32Value,omitempty"` EnumValue *ExamplepbNumericEnum `json:"enumValue,omitempty"` PathEnumValue *PathenumPathEnum `json:"pathEnumValue,omitempty"` NestedPathEnumValue *MessagePathEnumNestedPathEnum `json:"nestedPathEnumValue,omitempty"` Sfixed32Value int32 `json:"sfixed32Value,omitempty"` Sfixed64Value string `json:"sfixed64Value,omitempty"` Sint32Value int32 `json:"sint32Value,omitempty"` Sint64Value string `json:"sint64Value,omitempty"` RepeatedStringValue []string `json:"repeatedStringValue,omitempty"` OneofEmpty *interface{} `json:"oneofEmpty,omitempty"` OneofString string `json:"oneofString,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"` // Map of string description. MappedStringValue map[string]string `json:"mappedStringValue,omitempty"` MappedNestedValue map[string]ABitOfEverythingNested `json:"mappedNestedValue,omitempty"` NonConventionalNameValue string `json:"nonConventionalNameValue,omitempty"` TimestampValue time.Time `json:"timestampValue,omitempty"` RepeatedEnumValue []ExamplepbNumericEnum `json:"repeatedEnumValue,omitempty"` // Repeated numeric enum description. RepeatedEnumAnnotation []ExamplepbNumericEnum `json:"repeatedEnumAnnotation,omitempty"` // Numeric enum description. EnumValueAnnotation *ExamplepbNumericEnum `json:"enumValueAnnotation,omitempty"` // Repeated string description. RepeatedStringAnnotation []string `json:"repeatedStringAnnotation,omitempty"` // Repeated nested object description. RepeatedNestedAnnotation []ABitOfEverythingNested `json:"repeatedNestedAnnotation,omitempty"` // Nested object description. NestedAnnotation *ABitOfEverythingNested `json:"nestedAnnotation,omitempty"` Int64OverrideType int64 `json:"int64OverrideType,omitempty"` RequiredStringViaFieldBehaviorAnnotation string `json:"requiredStringViaFieldBehaviorAnnotation"` OutputOnlyStringViaFieldBehaviorAnnotation string `json:"outputOnlyStringViaFieldBehaviorAnnotation,omitempty"` OptionalStringValue string `json:"optionalStringValue,omitempty"` // Only digits are allowed. ProductId []string `json:"productId,omitempty"` OptionalStringField string `json:"optionalStringField,omitempty"` RequiredStringField1 string `json:"requiredStringField1"` RequiredStringField2 string `json:"requiredStringField2"` RequiredFieldBehaviorJsonNameCustom string `json:"required_field_behavior_json_name_custom"` RequiredFieldSchemaJsonNameCustom string `json:"required_field_schema_json_name_custom"` TrailingOnly string `json:"trailingOnly,omitempty"` // Trailing only dot. TrailingOnlyDot string `json:"trailingOnlyDot,omitempty"` // Trailing both. TrailingBoth string `json:"trailingBoth,omitempty"` // This is an example of a multi-line comment. Trailing multiline. TrailingMultiline string `json:"trailingMultiline,omitempty"` Uuids []string `json:"uuids,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_a_bit_of_everything_3.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "time" ) // Intentionally complicated message type to cover many features of Protobuf. type ABitOfEverything3 struct { SingleNested *ABitOfEverythingNested `json:"singleNested,omitempty"` Nested []ABitOfEverythingNested `json:"nested,omitempty"` // Float value field FloatValue float32 `json:"floatValue"` DoubleValue float64 `json:"doubleValue"` Int64Value string `json:"int64Value"` Uint64Value string `json:"uint64Value,omitempty"` Int32Value int32 `json:"int32Value,omitempty"` Fixed64Value string `json:"fixed64Value,omitempty"` Fixed32Value int64 `json:"fixed32Value,omitempty"` BoolValue bool `json:"boolValue,omitempty"` StringValue string `json:"stringValue,omitempty"` BytesValue string `json:"bytesValue,omitempty"` Uint32Value int64 `json:"uint32Value,omitempty"` EnumValue *ExamplepbNumericEnum `json:"enumValue,omitempty"` PathEnumValue *PathenumPathEnum `json:"pathEnumValue,omitempty"` NestedPathEnumValue *MessagePathEnumNestedPathEnum `json:"nestedPathEnumValue,omitempty"` Sfixed32Value int32 `json:"sfixed32Value,omitempty"` Sfixed64Value string `json:"sfixed64Value,omitempty"` Sint32Value int32 `json:"sint32Value,omitempty"` Sint64Value string `json:"sint64Value,omitempty"` RepeatedStringValue []string `json:"repeatedStringValue,omitempty"` OneofEmpty *interface{} `json:"oneofEmpty,omitempty"` OneofString string `json:"oneofString,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"` MappedStringValue map[string]string `json:"mappedStringValue,omitempty"` MappedNestedValue map[string]ABitOfEverythingNested `json:"mappedNestedValue,omitempty"` NonConventionalNameValue string `json:"nonConventionalNameValue,omitempty"` TimestampValue time.Time `json:"timestampValue,omitempty"` RepeatedEnumValue []ExamplepbNumericEnum `json:"repeatedEnumValue,omitempty"` // Repeated numeric enum description. RepeatedEnumAnnotation []ExamplepbNumericEnum `json:"repeatedEnumAnnotation,omitempty"` // Numeric enum description. EnumValueAnnotation *ExamplepbNumericEnum `json:"enumValueAnnotation,omitempty"` // Repeated string description. RepeatedStringAnnotation []string `json:"repeatedStringAnnotation,omitempty"` // Repeated nested object description. RepeatedNestedAnnotation []ABitOfEverythingNested `json:"repeatedNestedAnnotation,omitempty"` // Nested object description. NestedAnnotation *ABitOfEverythingNested `json:"nestedAnnotation,omitempty"` Int64OverrideType int64 `json:"int64OverrideType,omitempty"` RequiredStringViaFieldBehaviorAnnotation string `json:"requiredStringViaFieldBehaviorAnnotation"` OutputOnlyStringViaFieldBehaviorAnnotation string `json:"outputOnlyStringViaFieldBehaviorAnnotation,omitempty"` OptionalStringValue string `json:"optionalStringValue,omitempty"` // Only digits are allowed. ProductId []string `json:"productId,omitempty"` OptionalStringField string `json:"optionalStringField,omitempty"` RequiredStringField1 string `json:"requiredStringField1"` RequiredStringField2 string `json:"requiredStringField2"` RequiredFieldBehaviorJsonNameCustom string `json:"required_field_behavior_json_name_custom"` RequiredFieldSchemaJsonNameCustom string `json:"required_field_schema_json_name_custom"` TrailingOnly string `json:"trailingOnly,omitempty"` // Trailing only dot. TrailingOnlyDot string `json:"trailingOnlyDot,omitempty"` // Trailing both. TrailingBoth string `json:"trailingBoth,omitempty"` // This is an example of a multi-line comment. Trailing multiline. TrailingMultiline string `json:"trailingMultiline,omitempty"` Uuids []string `json:"uuids,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_a_bit_of_everything_4.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "time" ) // Intentionally complicated message type to cover many features of Protobuf. type ABitOfEverything4 struct { SingleNested *ABitOfEverythingNested `json:"singleNested,omitempty"` Nested []ABitOfEverythingNested `json:"nested,omitempty"` // Float value field FloatValue float32 `json:"floatValue,omitempty"` DoubleValue float64 `json:"doubleValue,omitempty"` Int64Value string `json:"int64Value,omitempty"` Uint64Value string `json:"uint64Value,omitempty"` Int32Value int32 `json:"int32Value,omitempty"` Fixed64Value string `json:"fixed64Value,omitempty"` Fixed32Value int64 `json:"fixed32Value,omitempty"` BoolValue bool `json:"boolValue,omitempty"` StringValue string `json:"stringValue,omitempty"` BytesValue string `json:"bytesValue,omitempty"` Uint32Value int64 `json:"uint32Value,omitempty"` EnumValue *ExamplepbNumericEnum `json:"enumValue,omitempty"` PathEnumValue *PathenumPathEnum `json:"pathEnumValue,omitempty"` NestedPathEnumValue *MessagePathEnumNestedPathEnum `json:"nestedPathEnumValue,omitempty"` Sfixed32Value int32 `json:"sfixed32Value,omitempty"` Sfixed64Value string `json:"sfixed64Value,omitempty"` Sint32Value int32 `json:"sint32Value,omitempty"` Sint64Value string `json:"sint64Value,omitempty"` RepeatedStringValue []string `json:"repeatedStringValue,omitempty"` OneofEmpty *interface{} `json:"oneofEmpty,omitempty"` OneofString string `json:"oneofString,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"` MappedStringValue map[string]string `json:"mappedStringValue,omitempty"` MappedNestedValue map[string]ABitOfEverythingNested `json:"mappedNestedValue,omitempty"` NonConventionalNameValue string `json:"nonConventionalNameValue,omitempty"` TimestampValue time.Time `json:"timestampValue,omitempty"` RepeatedEnumValue []ExamplepbNumericEnum `json:"repeatedEnumValue,omitempty"` // Repeated numeric enum description. RepeatedEnumAnnotation []ExamplepbNumericEnum `json:"repeatedEnumAnnotation,omitempty"` // Numeric enum description. EnumValueAnnotation *ExamplepbNumericEnum `json:"enumValueAnnotation,omitempty"` // Repeated string description. RepeatedStringAnnotation []string `json:"repeatedStringAnnotation,omitempty"` // Repeated nested object description. RepeatedNestedAnnotation []ABitOfEverythingNested `json:"repeatedNestedAnnotation,omitempty"` // Nested object description. NestedAnnotation *ABitOfEverythingNested `json:"nestedAnnotation,omitempty"` Int64OverrideType int64 `json:"int64OverrideType,omitempty"` RequiredStringViaFieldBehaviorAnnotation string `json:"requiredStringViaFieldBehaviorAnnotation,omitempty"` OutputOnlyStringViaFieldBehaviorAnnotation string `json:"outputOnlyStringViaFieldBehaviorAnnotation,omitempty"` OptionalStringValue string `json:"optionalStringValue,omitempty"` // Only digits are allowed. ProductId []string `json:"productId,omitempty"` OptionalStringField string `json:"optionalStringField,omitempty"` RequiredStringField1 string `json:"requiredStringField1,omitempty"` RequiredStringField2 string `json:"requiredStringField2,omitempty"` RequiredFieldBehaviorJsonNameCustom string `json:"required_field_behavior_json_name_custom,omitempty"` RequiredFieldSchemaJsonNameCustom string `json:"required_field_schema_json_name_custom,omitempty"` TrailingOnly string `json:"trailingOnly,omitempty"` // Trailing only dot. TrailingOnlyDot string `json:"trailingOnlyDot,omitempty"` // Trailing both. TrailingBoth string `json:"trailingBoth,omitempty"` // This is an example of a multi-line comment. Trailing multiline. TrailingMultiline string `json:"trailingMultiline,omitempty"` Uuids []string `json:"uuids,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_a_bit_of_everything_5.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "time" ) // Intentionally complicated message type to cover many features of Protobuf. type ABitOfEverything5 struct { SingleNested *ABitOfEverythingNested `json:"singleNested,omitempty"` Nested []ABitOfEverythingNested `json:"nested,omitempty"` // Float value field FloatValue float32 `json:"floatValue"` DoubleValue float64 `json:"doubleValue"` Int64Value string `json:"int64Value"` Uint64Value string `json:"uint64Value,omitempty"` Int32Value int32 `json:"int32Value,omitempty"` Fixed64Value string `json:"fixed64Value,omitempty"` Fixed32Value int64 `json:"fixed32Value,omitempty"` BoolValue bool `json:"boolValue,omitempty"` StringValue string `json:"stringValue,omitempty"` BytesValue string `json:"bytesValue,omitempty"` Uint32Value int64 `json:"uint32Value,omitempty"` EnumValue *ExamplepbNumericEnum `json:"enumValue,omitempty"` PathEnumValue *PathenumPathEnum `json:"pathEnumValue,omitempty"` NestedPathEnumValue *MessagePathEnumNestedPathEnum `json:"nestedPathEnumValue,omitempty"` Sfixed32Value int32 `json:"sfixed32Value,omitempty"` Sfixed64Value string `json:"sfixed64Value,omitempty"` Sint32Value int32 `json:"sint32Value,omitempty"` Sint64Value string `json:"sint64Value,omitempty"` RepeatedStringValue []string `json:"repeatedStringValue,omitempty"` OneofEmpty *interface{} `json:"oneofEmpty,omitempty"` OneofString string `json:"oneofString,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"` MappedStringValue map[string]string `json:"mappedStringValue,omitempty"` MappedNestedValue map[string]ABitOfEverythingNested `json:"mappedNestedValue,omitempty"` NonConventionalNameValue string `json:"nonConventionalNameValue,omitempty"` TimestampValue time.Time `json:"timestampValue,omitempty"` RepeatedEnumValue []ExamplepbNumericEnum `json:"repeatedEnumValue,omitempty"` // Repeated numeric enum description. RepeatedEnumAnnotation []ExamplepbNumericEnum `json:"repeatedEnumAnnotation,omitempty"` EnumValueAnnotation *ExamplepbNumericEnum `json:"enumValueAnnotation,omitempty"` // Repeated string description. RepeatedStringAnnotation []string `json:"repeatedStringAnnotation,omitempty"` // Repeated nested object description. RepeatedNestedAnnotation []ABitOfEverythingNested `json:"repeatedNestedAnnotation,omitempty"` NestedAnnotation *ABitOfEverythingNested `json:"nestedAnnotation,omitempty"` Int64OverrideType int64 `json:"int64OverrideType,omitempty"` RequiredStringViaFieldBehaviorAnnotation string `json:"requiredStringViaFieldBehaviorAnnotation"` OutputOnlyStringViaFieldBehaviorAnnotation string `json:"outputOnlyStringViaFieldBehaviorAnnotation,omitempty"` OptionalStringValue string `json:"optionalStringValue,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_a_bit_of_everything_6.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "time" ) // Intentionally complicated message type to cover many features of Protobuf. type ABitOfEverything6 struct { SingleNested *ABitOfEverythingNested `json:"singleNested,omitempty"` Nested []ABitOfEverythingNested `json:"nested,omitempty"` // Float value field FloatValue float32 `json:"floatValue"` DoubleValue float64 `json:"doubleValue"` Int64Value string `json:"int64Value"` Uint64Value string `json:"uint64Value,omitempty"` Int32Value int32 `json:"int32Value,omitempty"` Fixed64Value string `json:"fixed64Value,omitempty"` Fixed32Value int64 `json:"fixed32Value,omitempty"` BoolValue bool `json:"boolValue,omitempty"` StringValue string `json:"stringValue,omitempty"` BytesValue string `json:"bytesValue,omitempty"` Uint32Value int64 `json:"uint32Value,omitempty"` EnumValue *ExamplepbNumericEnum `json:"enumValue,omitempty"` PathEnumValue *PathenumPathEnum `json:"pathEnumValue,omitempty"` NestedPathEnumValue *MessagePathEnumNestedPathEnum `json:"nestedPathEnumValue,omitempty"` Sfixed32Value int32 `json:"sfixed32Value,omitempty"` Sfixed64Value string `json:"sfixed64Value,omitempty"` Sint32Value int32 `json:"sint32Value,omitempty"` Sint64Value string `json:"sint64Value,omitempty"` RepeatedStringValue []string `json:"repeatedStringValue,omitempty"` OneofEmpty *interface{} `json:"oneofEmpty,omitempty"` OneofString string `json:"oneofString,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"` MappedStringValue map[string]string `json:"mappedStringValue,omitempty"` MappedNestedValue map[string]ABitOfEverythingNested `json:"mappedNestedValue,omitempty"` NonConventionalNameValue string `json:"nonConventionalNameValue,omitempty"` TimestampValue time.Time `json:"timestampValue,omitempty"` RepeatedEnumValue []ExamplepbNumericEnum `json:"repeatedEnumValue,omitempty"` // Repeated numeric enum description. RepeatedEnumAnnotation []ExamplepbNumericEnum `json:"repeatedEnumAnnotation,omitempty"` EnumValueAnnotation *ExamplepbNumericEnum `json:"enumValueAnnotation,omitempty"` // Repeated string description. RepeatedStringAnnotation []string `json:"repeatedStringAnnotation,omitempty"` // Repeated nested object description. RepeatedNestedAnnotation []ABitOfEverythingNested `json:"repeatedNestedAnnotation,omitempty"` NestedAnnotation *ABitOfEverythingNested `json:"nestedAnnotation,omitempty"` Int64OverrideType int64 `json:"int64OverrideType,omitempty"` RequiredStringViaFieldBehaviorAnnotation string `json:"requiredStringViaFieldBehaviorAnnotation"` OutputOnlyStringViaFieldBehaviorAnnotation string `json:"outputOnlyStringViaFieldBehaviorAnnotation,omitempty"` OptionalStringValue string `json:"optionalStringValue,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_a_bit_of_everything_7.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "time" ) // Intentionally complicated message type to cover many features of Protobuf. type ABitOfEverything7 struct { SingleNested *ABitOfEverythingNested `json:"singleNested,omitempty"` Nested []ABitOfEverythingNested `json:"nested,omitempty"` // Float value field FloatValue float32 `json:"floatValue"` DoubleValue float64 `json:"doubleValue"` Int64Value string `json:"int64Value"` Uint64Value string `json:"uint64Value,omitempty"` Int32Value int32 `json:"int32Value,omitempty"` Fixed64Value string `json:"fixed64Value,omitempty"` Fixed32Value int64 `json:"fixed32Value,omitempty"` BoolValue bool `json:"boolValue,omitempty"` StringValue string `json:"stringValue,omitempty"` BytesValue string `json:"bytesValue,omitempty"` Uint32Value int64 `json:"uint32Value,omitempty"` EnumValue *ExamplepbNumericEnum `json:"enumValue,omitempty"` PathEnumValue *PathenumPathEnum `json:"pathEnumValue,omitempty"` NestedPathEnumValue *MessagePathEnumNestedPathEnum `json:"nestedPathEnumValue,omitempty"` Sfixed32Value int32 `json:"sfixed32Value,omitempty"` Sfixed64Value string `json:"sfixed64Value,omitempty"` Sint32Value int32 `json:"sint32Value,omitempty"` Sint64Value string `json:"sint64Value,omitempty"` RepeatedStringValue []string `json:"repeatedStringValue,omitempty"` OneofEmpty *interface{} `json:"oneofEmpty,omitempty"` OneofString string `json:"oneofString,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"` MappedStringValue map[string]string `json:"mappedStringValue,omitempty"` MappedNestedValue map[string]ABitOfEverythingNested `json:"mappedNestedValue,omitempty"` NonConventionalNameValue string `json:"nonConventionalNameValue,omitempty"` TimestampValue time.Time `json:"timestampValue,omitempty"` RepeatedEnumValue []ExamplepbNumericEnum `json:"repeatedEnumValue,omitempty"` // Repeated numeric enum description. RepeatedEnumAnnotation []ExamplepbNumericEnum `json:"repeatedEnumAnnotation,omitempty"` EnumValueAnnotation *ExamplepbNumericEnum `json:"enumValueAnnotation,omitempty"` // Repeated string description. RepeatedStringAnnotation []string `json:"repeatedStringAnnotation,omitempty"` // Repeated nested object description. RepeatedNestedAnnotation []ABitOfEverythingNested `json:"repeatedNestedAnnotation,omitempty"` NestedAnnotation *ABitOfEverythingNested `json:"nestedAnnotation,omitempty"` Int64OverrideType int64 `json:"int64OverrideType,omitempty"` RequiredStringViaFieldBehaviorAnnotation string `json:"requiredStringViaFieldBehaviorAnnotation"` OutputOnlyStringViaFieldBehaviorAnnotation string `json:"outputOnlyStringViaFieldBehaviorAnnotation,omitempty"` OptionalStringValue string `json:"optionalStringValue,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_a_bit_of_everything_8.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "time" ) // Intentionally complicated message type to cover many features of Protobuf. type ABitOfEverything8 struct { SingleNested *ABitOfEverythingNested `json:"singleNested,omitempty"` Nested []ABitOfEverythingNested `json:"nested,omitempty"` // Float value field FloatValue float32 `json:"floatValue"` DoubleValue float64 `json:"doubleValue"` Int64Value string `json:"int64Value"` Uint64Value string `json:"uint64Value,omitempty"` Int32Value int32 `json:"int32Value,omitempty"` Fixed64Value string `json:"fixed64Value,omitempty"` Fixed32Value int64 `json:"fixed32Value,omitempty"` BoolValue bool `json:"boolValue,omitempty"` StringValue string `json:"stringValue,omitempty"` BytesValue string `json:"bytesValue,omitempty"` Uint32Value int64 `json:"uint32Value,omitempty"` EnumValue *ExamplepbNumericEnum `json:"enumValue,omitempty"` PathEnumValue *PathenumPathEnum `json:"pathEnumValue,omitempty"` NestedPathEnumValue *MessagePathEnumNestedPathEnum `json:"nestedPathEnumValue,omitempty"` Sfixed32Value int32 `json:"sfixed32Value,omitempty"` Sfixed64Value string `json:"sfixed64Value,omitempty"` Sint32Value int32 `json:"sint32Value,omitempty"` Sint64Value string `json:"sint64Value,omitempty"` RepeatedStringValue []string `json:"repeatedStringValue,omitempty"` OneofEmpty *interface{} `json:"oneofEmpty,omitempty"` OneofString string `json:"oneofString,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"` MappedStringValue map[string]string `json:"mappedStringValue,omitempty"` MappedNestedValue map[string]ABitOfEverythingNested `json:"mappedNestedValue,omitempty"` NonConventionalNameValue string `json:"nonConventionalNameValue,omitempty"` TimestampValue time.Time `json:"timestampValue,omitempty"` RepeatedEnumValue []ExamplepbNumericEnum `json:"repeatedEnumValue,omitempty"` // Repeated numeric enum description. RepeatedEnumAnnotation []ExamplepbNumericEnum `json:"repeatedEnumAnnotation,omitempty"` EnumValueAnnotation *ExamplepbNumericEnum `json:"enumValueAnnotation,omitempty"` // Repeated string description. RepeatedStringAnnotation []string `json:"repeatedStringAnnotation,omitempty"` // Repeated nested object description. RepeatedNestedAnnotation []ABitOfEverythingNested `json:"repeatedNestedAnnotation,omitempty"` NestedAnnotation *ABitOfEverythingNested `json:"nestedAnnotation,omitempty"` Int64OverrideType int64 `json:"int64OverrideType,omitempty"` RequiredStringViaFieldBehaviorAnnotation string `json:"requiredStringViaFieldBehaviorAnnotation"` OutputOnlyStringViaFieldBehaviorAnnotation string `json:"outputOnlyStringViaFieldBehaviorAnnotation,omitempty"` OptionalStringValue string `json:"optionalStringValue,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_a_bit_of_everything_nested.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe // Nested is nested type. type ABitOfEverythingNested struct { // name is nested field. Name string `json:"name,omitempty"` Amount int64 `json:"amount,omitempty"` // DeepEnum description. Ok *NestedDeepEnum `json:"ok,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_a_bit_of_everything_service_deep_path_echo_body.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "time" ) // Intentionally complicated message type to cover many features of Protobuf. type ABitOfEverythingServiceDeepPathEchoBody struct { SingleNested *ABitOfEverythingServiceDeepPathEchoBodySingleNested `json:"singleNested,omitempty"` Uuid string `json:"uuid"` Nested []ABitOfEverythingNested `json:"nested,omitempty"` // Float value field FloatValue float32 `json:"floatValue"` DoubleValue float64 `json:"doubleValue"` Int64Value string `json:"int64Value"` Uint64Value string `json:"uint64Value,omitempty"` Int32Value int32 `json:"int32Value,omitempty"` Fixed64Value string `json:"fixed64Value,omitempty"` Fixed32Value int64 `json:"fixed32Value,omitempty"` BoolValue bool `json:"boolValue,omitempty"` StringValue string `json:"stringValue,omitempty"` BytesValue string `json:"bytesValue,omitempty"` Uint32Value int64 `json:"uint32Value,omitempty"` EnumValue *ExamplepbNumericEnum `json:"enumValue,omitempty"` PathEnumValue *PathenumPathEnum `json:"pathEnumValue,omitempty"` NestedPathEnumValue *MessagePathEnumNestedPathEnum `json:"nestedPathEnumValue,omitempty"` Sfixed32Value int32 `json:"sfixed32Value,omitempty"` Sfixed64Value string `json:"sfixed64Value,omitempty"` Sint32Value int32 `json:"sint32Value,omitempty"` Sint64Value string `json:"sint64Value,omitempty"` RepeatedStringValue []string `json:"repeatedStringValue,omitempty"` OneofEmpty *interface{} `json:"oneofEmpty,omitempty"` OneofString string `json:"oneofString,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"` // Map of string description. MappedStringValue map[string]string `json:"mappedStringValue,omitempty"` MappedNestedValue map[string]ABitOfEverythingNested `json:"mappedNestedValue,omitempty"` NonConventionalNameValue string `json:"nonConventionalNameValue,omitempty"` TimestampValue time.Time `json:"timestampValue,omitempty"` RepeatedEnumValue []ExamplepbNumericEnum `json:"repeatedEnumValue,omitempty"` // Repeated numeric enum description. RepeatedEnumAnnotation []ExamplepbNumericEnum `json:"repeatedEnumAnnotation,omitempty"` // Numeric enum description. EnumValueAnnotation *ExamplepbNumericEnum `json:"enumValueAnnotation,omitempty"` // Repeated string description. RepeatedStringAnnotation []string `json:"repeatedStringAnnotation,omitempty"` // Repeated nested object description. RepeatedNestedAnnotation []ABitOfEverythingNested `json:"repeatedNestedAnnotation,omitempty"` // Nested object description. NestedAnnotation *ABitOfEverythingNested `json:"nestedAnnotation,omitempty"` Int64OverrideType int64 `json:"int64OverrideType,omitempty"` RequiredStringViaFieldBehaviorAnnotation string `json:"requiredStringViaFieldBehaviorAnnotation"` OutputOnlyStringViaFieldBehaviorAnnotation string `json:"outputOnlyStringViaFieldBehaviorAnnotation,omitempty"` OptionalStringValue string `json:"optionalStringValue,omitempty"` // Only digits are allowed. ProductId []string `json:"productId,omitempty"` OptionalStringField string `json:"optionalStringField,omitempty"` RequiredStringField1 string `json:"requiredStringField1"` RequiredStringField2 string `json:"requiredStringField2"` RequiredFieldBehaviorJsonNameCustom string `json:"required_field_behavior_json_name_custom"` RequiredFieldSchemaJsonNameCustom string `json:"required_field_schema_json_name_custom"` TrailingOnly string `json:"trailingOnly,omitempty"` // Trailing only dot. TrailingOnlyDot string `json:"trailingOnlyDot,omitempty"` // Trailing both. TrailingBoth string `json:"trailingBoth,omitempty"` // This is an example of a multi-line comment. Trailing multiline. TrailingMultiline string `json:"trailingMultiline,omitempty"` Uuids []string `json:"uuids,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_a_bit_of_everything_service_deep_path_echo_body_single_nested.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe // Nested is nested type. type ABitOfEverythingServiceDeepPathEchoBodySingleNested struct { Amount int64 `json:"amount,omitempty"` // DeepEnum description. Ok *NestedDeepEnum `json:"ok,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_a_bit_of_everything_service_post_with_empty_body_body.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe type ABitOfEverythingServicePostWithEmptyBodyBody struct { } ================================================ FILE: examples/internal/clients/abe/model_a_bit_of_everything_service_update_body.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "time" ) // Intentionally complicated message type to cover many features of Protobuf. type ABitOfEverythingServiceUpdateBody struct { SingleNested *ABitOfEverythingNested `json:"singleNested,omitempty"` Nested []ABitOfEverythingNested `json:"nested,omitempty"` // Float value field FloatValue float32 `json:"floatValue"` DoubleValue float64 `json:"doubleValue"` Int64Value string `json:"int64Value"` Uint64Value string `json:"uint64Value,omitempty"` Int32Value int32 `json:"int32Value,omitempty"` Fixed64Value string `json:"fixed64Value,omitempty"` Fixed32Value int64 `json:"fixed32Value,omitempty"` BoolValue bool `json:"boolValue,omitempty"` StringValue string `json:"stringValue,omitempty"` BytesValue string `json:"bytesValue,omitempty"` Uint32Value int64 `json:"uint32Value,omitempty"` EnumValue *ExamplepbNumericEnum `json:"enumValue,omitempty"` PathEnumValue *PathenumPathEnum `json:"pathEnumValue,omitempty"` NestedPathEnumValue *MessagePathEnumNestedPathEnum `json:"nestedPathEnumValue,omitempty"` Sfixed32Value int32 `json:"sfixed32Value,omitempty"` Sfixed64Value string `json:"sfixed64Value,omitempty"` Sint32Value int32 `json:"sint32Value,omitempty"` Sint64Value string `json:"sint64Value,omitempty"` RepeatedStringValue []string `json:"repeatedStringValue,omitempty"` OneofEmpty *interface{} `json:"oneofEmpty,omitempty"` OneofString string `json:"oneofString,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"` MappedStringValue map[string]string `json:"mappedStringValue,omitempty"` MappedNestedValue map[string]ABitOfEverythingNested `json:"mappedNestedValue,omitempty"` NonConventionalNameValue string `json:"nonConventionalNameValue,omitempty"` TimestampValue time.Time `json:"timestampValue,omitempty"` RepeatedEnumValue []ExamplepbNumericEnum `json:"repeatedEnumValue,omitempty"` // Repeated numeric enum description. RepeatedEnumAnnotation []ExamplepbNumericEnum `json:"repeatedEnumAnnotation,omitempty"` // Numeric enum description. EnumValueAnnotation *ExamplepbNumericEnum `json:"enumValueAnnotation,omitempty"` // Repeated string description. RepeatedStringAnnotation []string `json:"repeatedStringAnnotation,omitempty"` // Repeated nested object description. RepeatedNestedAnnotation []ABitOfEverythingNested `json:"repeatedNestedAnnotation,omitempty"` // Nested object description. NestedAnnotation *ABitOfEverythingNested `json:"nestedAnnotation,omitempty"` Int64OverrideType int64 `json:"int64OverrideType,omitempty"` RequiredStringViaFieldBehaviorAnnotation string `json:"requiredStringViaFieldBehaviorAnnotation"` OutputOnlyStringViaFieldBehaviorAnnotation string `json:"outputOnlyStringViaFieldBehaviorAnnotation,omitempty"` OptionalStringValue string `json:"optionalStringValue,omitempty"` // Only digits are allowed. ProductId []string `json:"productId,omitempty"` OptionalStringField string `json:"optionalStringField,omitempty"` RequiredStringField1 string `json:"requiredStringField1"` RequiredStringField2 string `json:"requiredStringField2"` RequiredFieldBehaviorJsonNameCustom string `json:"required_field_behavior_json_name_custom"` RequiredFieldSchemaJsonNameCustom string `json:"required_field_schema_json_name_custom"` TrailingOnly string `json:"trailingOnly,omitempty"` // Trailing only dot. TrailingOnlyDot string `json:"trailingOnlyDot,omitempty"` // Trailing both. TrailingBoth string `json:"trailingBoth,omitempty"` // This is an example of a multi-line comment. Trailing multiline. TrailingMultiline string `json:"trailingMultiline,omitempty"` Uuids []string `json:"uuids,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_a_bit_of_everything_service_update_v2_body.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe type ABitOfEverythingServiceUpdateV2Body struct { Abe *ABitOfEverything2 `json:"abe,omitempty"` // The paths to update. UpdateMask string `json:"updateMask,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_book.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "time" ) // An example resource type from AIP-123 used to test the behavior described in the CreateBookRequest message. See: https://google.aip.dev/123 type Book struct { // Output only. The book's ID. Id string `json:"id,omitempty"` // Output only. Creation time of the book. CreateTime time.Time `json:"createTime,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_examplepb_a_bit_of_everything.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "time" ) // Intentionally complicated message type to cover many features of Protobuf. type ExamplepbABitOfEverything struct { SingleNested *ABitOfEverythingNested `json:"singleNested,omitempty"` Uuid string `json:"uuid"` Nested []ABitOfEverythingNested `json:"nested,omitempty"` // Float value field FloatValue float32 `json:"floatValue"` DoubleValue float64 `json:"doubleValue"` Int64Value string `json:"int64Value"` Uint64Value string `json:"uint64Value,omitempty"` Int32Value int32 `json:"int32Value,omitempty"` Fixed64Value string `json:"fixed64Value,omitempty"` Fixed32Value int64 `json:"fixed32Value,omitempty"` BoolValue bool `json:"boolValue,omitempty"` StringValue string `json:"stringValue,omitempty"` BytesValue string `json:"bytesValue,omitempty"` Uint32Value int64 `json:"uint32Value,omitempty"` EnumValue *ExamplepbNumericEnum `json:"enumValue,omitempty"` PathEnumValue *PathenumPathEnum `json:"pathEnumValue,omitempty"` NestedPathEnumValue *MessagePathEnumNestedPathEnum `json:"nestedPathEnumValue,omitempty"` Sfixed32Value int32 `json:"sfixed32Value,omitempty"` Sfixed64Value string `json:"sfixed64Value,omitempty"` Sint32Value int32 `json:"sint32Value,omitempty"` Sint64Value string `json:"sint64Value,omitempty"` RepeatedStringValue []string `json:"repeatedStringValue,omitempty"` OneofEmpty *interface{} `json:"oneofEmpty,omitempty"` OneofString string `json:"oneofString,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"` // Map of string description. MappedStringValue map[string]string `json:"mappedStringValue,omitempty"` MappedNestedValue map[string]ABitOfEverythingNested `json:"mappedNestedValue,omitempty"` NonConventionalNameValue string `json:"nonConventionalNameValue,omitempty"` TimestampValue time.Time `json:"timestampValue,omitempty"` RepeatedEnumValue []ExamplepbNumericEnum `json:"repeatedEnumValue,omitempty"` // Repeated numeric enum description. RepeatedEnumAnnotation []ExamplepbNumericEnum `json:"repeatedEnumAnnotation,omitempty"` // Numeric enum description. EnumValueAnnotation *ExamplepbNumericEnum `json:"enumValueAnnotation,omitempty"` // Repeated string description. RepeatedStringAnnotation []string `json:"repeatedStringAnnotation,omitempty"` // Repeated nested object description. RepeatedNestedAnnotation []ABitOfEverythingNested `json:"repeatedNestedAnnotation,omitempty"` // Nested object description. NestedAnnotation *ABitOfEverythingNested `json:"nestedAnnotation,omitempty"` Int64OverrideType int64 `json:"int64OverrideType,omitempty"` RequiredStringViaFieldBehaviorAnnotation string `json:"requiredStringViaFieldBehaviorAnnotation"` OutputOnlyStringViaFieldBehaviorAnnotation string `json:"outputOnlyStringViaFieldBehaviorAnnotation,omitempty"` OptionalStringValue string `json:"optionalStringValue,omitempty"` // Only digits are allowed. ProductId []string `json:"productId,omitempty"` OptionalStringField string `json:"optionalStringField,omitempty"` RequiredStringField1 string `json:"requiredStringField1"` RequiredStringField2 string `json:"requiredStringField2"` RequiredFieldBehaviorJsonNameCustom string `json:"required_field_behavior_json_name_custom"` RequiredFieldSchemaJsonNameCustom string `json:"required_field_schema_json_name_custom"` TrailingOnly string `json:"trailingOnly,omitempty"` // Trailing only dot. TrailingOnlyDot string `json:"trailingOnlyDot,omitempty"` // Trailing both. TrailingBoth string `json:"trailingBoth,omitempty"` // This is an example of a multi-line comment. Trailing multiline. TrailingMultiline string `json:"trailingMultiline,omitempty"` Uuids []string `json:"uuids,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_examplepb_a_bit_of_everything_repeated.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe type ExamplepbABitOfEverythingRepeated struct { PathRepeatedFloatValue []float32 `json:"pathRepeatedFloatValue,omitempty"` PathRepeatedDoubleValue []float64 `json:"pathRepeatedDoubleValue,omitempty"` PathRepeatedInt64Value []string `json:"pathRepeatedInt64Value,omitempty"` PathRepeatedUint64Value []string `json:"pathRepeatedUint64Value,omitempty"` PathRepeatedInt32Value []int32 `json:"pathRepeatedInt32Value,omitempty"` PathRepeatedFixed64Value []string `json:"pathRepeatedFixed64Value,omitempty"` PathRepeatedFixed32Value []int64 `json:"pathRepeatedFixed32Value,omitempty"` PathRepeatedBoolValue []bool `json:"pathRepeatedBoolValue,omitempty"` PathRepeatedStringValue []string `json:"pathRepeatedStringValue,omitempty"` PathRepeatedBytesValue []string `json:"pathRepeatedBytesValue,omitempty"` PathRepeatedUint32Value []int64 `json:"pathRepeatedUint32Value,omitempty"` PathRepeatedEnumValue []ExamplepbNumericEnum `json:"pathRepeatedEnumValue,omitempty"` PathRepeatedSfixed32Value []int32 `json:"pathRepeatedSfixed32Value,omitempty"` PathRepeatedSfixed64Value []string `json:"pathRepeatedSfixed64Value,omitempty"` PathRepeatedSint32Value []int32 `json:"pathRepeatedSint32Value,omitempty"` PathRepeatedSint64Value []string `json:"pathRepeatedSint64Value,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_examplepb_a_bit_of_everything_service_update_body.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "time" ) // Intentionally complicated message type to cover many features of Protobuf. type ExamplepbABitOfEverythingServiceUpdateBody struct { SingleNested *ABitOfEverythingNested `json:"singleNested,omitempty"` Nested []ABitOfEverythingNested `json:"nested,omitempty"` // Float value field FloatValue float32 `json:"floatValue"` DoubleValue float64 `json:"doubleValue"` Int64Value string `json:"int64Value"` Uint64Value string `json:"uint64Value,omitempty"` Int32Value int32 `json:"int32Value,omitempty"` Fixed64Value string `json:"fixed64Value,omitempty"` Fixed32Value int64 `json:"fixed32Value,omitempty"` BoolValue bool `json:"boolValue,omitempty"` StringValue string `json:"stringValue,omitempty"` BytesValue string `json:"bytesValue,omitempty"` Uint32Value int64 `json:"uint32Value,omitempty"` EnumValue *ExamplepbNumericEnum `json:"enumValue,omitempty"` PathEnumValue *PathenumPathEnum `json:"pathEnumValue,omitempty"` NestedPathEnumValue *MessagePathEnumNestedPathEnum `json:"nestedPathEnumValue,omitempty"` Sfixed32Value int32 `json:"sfixed32Value,omitempty"` Sfixed64Value string `json:"sfixed64Value,omitempty"` Sint32Value int32 `json:"sint32Value,omitempty"` Sint64Value string `json:"sint64Value,omitempty"` RepeatedStringValue []string `json:"repeatedStringValue,omitempty"` OneofEmpty *interface{} `json:"oneofEmpty,omitempty"` OneofString string `json:"oneofString,omitempty"` MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"` // Map of string description. MappedStringValue map[string]string `json:"mappedStringValue,omitempty"` MappedNestedValue map[string]ABitOfEverythingNested `json:"mappedNestedValue,omitempty"` NonConventionalNameValue string `json:"nonConventionalNameValue,omitempty"` TimestampValue time.Time `json:"timestampValue,omitempty"` RepeatedEnumValue []ExamplepbNumericEnum `json:"repeatedEnumValue,omitempty"` // Repeated numeric enum description. RepeatedEnumAnnotation []ExamplepbNumericEnum `json:"repeatedEnumAnnotation,omitempty"` // Numeric enum description. EnumValueAnnotation *ExamplepbNumericEnum `json:"enumValueAnnotation,omitempty"` // Repeated string description. RepeatedStringAnnotation []string `json:"repeatedStringAnnotation,omitempty"` // Repeated nested object description. RepeatedNestedAnnotation []ABitOfEverythingNested `json:"repeatedNestedAnnotation,omitempty"` // Nested object description. NestedAnnotation *ABitOfEverythingNested `json:"nestedAnnotation,omitempty"` Int64OverrideType int64 `json:"int64OverrideType,omitempty"` RequiredStringViaFieldBehaviorAnnotation string `json:"requiredStringViaFieldBehaviorAnnotation"` OutputOnlyStringViaFieldBehaviorAnnotation string `json:"outputOnlyStringViaFieldBehaviorAnnotation,omitempty"` OptionalStringValue string `json:"optionalStringValue,omitempty"` // Only digits are allowed. ProductId []string `json:"productId,omitempty"` OptionalStringField string `json:"optionalStringField,omitempty"` RequiredStringField1 string `json:"requiredStringField1"` RequiredStringField2 string `json:"requiredStringField2"` RequiredFieldBehaviorJsonNameCustom string `json:"required_field_behavior_json_name_custom"` RequiredFieldSchemaJsonNameCustom string `json:"required_field_schema_json_name_custom"` TrailingOnly string `json:"trailingOnly,omitempty"` // Trailing only dot. TrailingOnlyDot string `json:"trailingOnlyDot,omitempty"` // Trailing both. TrailingBoth string `json:"trailingBoth,omitempty"` // This is an example of a multi-line comment. Trailing multiline. TrailingMultiline string `json:"trailingMultiline,omitempty"` Uuids []string `json:"uuids,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_examplepb_bar.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe type ExamplepbBar struct { Id string `json:"id"` } ================================================ FILE: examples/internal/clients/abe/model_examplepb_body.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe type ExamplepbBody struct { Name string `json:"name,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_examplepb_book.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "time" ) // An example resource type from AIP-123 used to test the behavior described in the CreateBookRequest message. See: https://google.aip.dev/123 type ExamplepbBook struct { // The resource name of the book. Format: `publishers/{publisher}/books/{book}` Example: `publishers/1257894000000000000/books/my-book` Name string `json:"name,omitempty"` // Output only. The book's ID. Id string `json:"id,omitempty"` // Output only. Creation time of the book. CreateTime time.Time `json:"createTime,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_examplepb_check_status_response.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe type ExamplepbCheckStatusResponse struct { Status *GoogleRpcStatus `json:"status,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_examplepb_error_object.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe type ExamplepbErrorObject struct { // Response code Code int32 `json:"code,omitempty"` // Response message Message string `json:"message,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_examplepb_error_response.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe type ExamplepbErrorResponse struct { // Unique event identifier for server requests CorrelationId string `json:"correlationId,omitempty"` Error_ *ExamplepbErrorObject `json:"error,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_examplepb_numeric_enum.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe // ExamplepbNumericEnum : NumericEnum is one or zero. type ExamplepbNumericEnum string // List of examplepbNumericEnum const ( ZERO_ExamplepbNumericEnum ExamplepbNumericEnum = "ZERO" ONE_ExamplepbNumericEnum ExamplepbNumericEnum = "ONE" ) ================================================ FILE: examples/internal/clients/abe/model_examplepb_required_message_type_request.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe type ExamplepbRequiredMessageTypeRequest struct { Id string `json:"id"` Foo *ProtoExamplepbFoo `json:"foo"` } ================================================ FILE: examples/internal/clients/abe/model_examplepb_snake_case_0_enum.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe // ExamplepbSnakeCase0Enum : - value_e: buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE - value_f: buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE type ExamplepbSnakeCase0Enum string // List of examplepbSnake_case_0_enum const ( E_ExamplepbSnakeCase0Enum ExamplepbSnakeCase0Enum = "value_e" F_ExamplepbSnakeCase0Enum ExamplepbSnakeCase0Enum = "value_f" ) ================================================ FILE: examples/internal/clients/abe/model_examplepb_snake_case_enum.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe // ExamplepbSnakeCaseEnum : - value_c: buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE - value_d: buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE type ExamplepbSnakeCaseEnum string // List of examplepbSnake_case_enum const ( C_ExamplepbSnakeCaseEnum ExamplepbSnakeCaseEnum = "value_c" D_ExamplepbSnakeCaseEnum ExamplepbSnakeCaseEnum = "value_d" ) ================================================ FILE: examples/internal/clients/abe/model_examplepb_snake_enum_response.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe type ExamplepbSnakeEnumResponse struct { } ================================================ FILE: examples/internal/clients/abe/model_google_rpc_status.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe // The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). type GoogleRpcStatus struct { // The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. Code int32 `json:"code,omitempty"` // A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. Message string `json:"message,omitempty"` // A list of messages that carry the error details. There is a common set of message types for APIs to use. Details []ProtobufAny `json:"details,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_message_path_enum_nested_path_enum.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe type MessagePathEnumNestedPathEnum string // List of MessagePathEnumNestedPathEnum const ( GHI_MessagePathEnumNestedPathEnum MessagePathEnumNestedPathEnum = "GHI" JKL_MessagePathEnumNestedPathEnum MessagePathEnumNestedPathEnum = "JKL" ) ================================================ FILE: examples/internal/clients/abe/model_nested_deep_enum.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe // NestedDeepEnum : DeepEnum is one or zero. - FALSE: FALSE is false. - TRUE: TRUE is true. type NestedDeepEnum string // List of NestedDeepEnum const ( FALSE_NestedDeepEnum NestedDeepEnum = "FALSE" TRUE_NestedDeepEnum NestedDeepEnum = "TRUE" ) ================================================ FILE: examples/internal/clients/abe/model_oneofenum_example_enum.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe type OneofenumExampleEnum string // List of oneofenumExampleEnum const ( UNSPECIFIED_OneofenumExampleEnum OneofenumExampleEnum = "EXAMPLE_ENUM_UNSPECIFIED" FIRST_OneofenumExampleEnum OneofenumExampleEnum = "EXAMPLE_ENUM_FIRST" ) ================================================ FILE: examples/internal/clients/abe/model_pathenum_path_enum.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe type PathenumPathEnum string // List of pathenumPathEnum const ( ABC_PathenumPathEnum PathenumPathEnum = "ABC" DEF_PathenumPathEnum PathenumPathEnum = "DEF" ) ================================================ FILE: examples/internal/clients/abe/model_pathenum_snake_case_for_import.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe // PathenumSnakeCaseForImport : - value_x: buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE - value_y: buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE type PathenumSnakeCaseForImport string // List of pathenumSnake_case_for_import const ( X_PathenumSnakeCaseForImport PathenumSnakeCaseForImport = "value_x" Y_PathenumSnakeCaseForImport PathenumSnakeCaseForImport = "value_y" ) ================================================ FILE: examples/internal/clients/abe/model_proto_examplepb_foo.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe type ProtoExamplepbFoo struct { Bar *ExamplepbBar `json:"bar"` } ================================================ FILE: examples/internal/clients/abe/model_protobuf_any.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe // `Any` contains an arbitrary serialized protocol buffer message along with a URL that describes the type of the serialized message. Protobuf library provides support to pack/unpack Any values in the form of utility functions or additional generated methods of the Any type. Example 1: Pack and unpack a message in C++. Foo foo = ...; Any any; any.PackFrom(foo); ... if (any.UnpackTo(&foo)) { ... } Example 2: Pack and unpack a message in Java. Foo foo = ...; Any any = Any.pack(foo); ... if (any.is(Foo.class)) { foo = any.unpack(Foo.class); } // or ... if (any.isSameTypeAs(Foo.getDefaultInstance())) { foo = any.unpack(Foo.getDefaultInstance()); } Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() any.Pack(foo) ... if any.Is(Foo.DESCRIPTOR): any.Unpack(foo) ... Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) if err != nil { ... } ... foo := &pb.Foo{} if err := any.UnmarshalTo(foo); err != nil { ... } The pack methods provided by protobuf library will by default use 'type.googleapis.com/full.type.name' as the type URL and the unpack methods only use the fully qualified type name after the last '/' in the type URL, for example \"foo.bar.com/x/y.z\" will yield type name \"y.z\". JSON ==== The JSON representation of an `Any` value uses the regular representation of the deserialized, embedded message, with an additional field `@type` which contains the type URL. Example: package google.profile; message Person { string first_name = 1; string last_name = 2; } { \"@type\": \"type.googleapis.com/google.profile.Person\", \"firstName\": , \"lastName\": } If the embedded message type is well-known and has a custom JSON representation, that representation will be embedded adding a field `value` which holds the custom JSON in addition to the `@type` field. Example (for message [google.protobuf.Duration][]): { \"@type\": \"type.googleapis.com/google.protobuf.Duration\", \"value\": \"1.212s\" } type ProtobufAny struct { // A URL/resource name that uniquely identifies the type of the serialized protocol buffer message. This string must contain at least one \"/\" character. The last segment of the URL's path must represent the fully qualified name of the type (as in `path/google.protobuf.Duration`). The name should be in a canonical form (e.g., leading \".\" is not accepted). In practice, teams usually precompile into the binary all types that they expect it to use in the context of Any. However, for URLs which use the scheme `http`, `https`, or no scheme, one can optionally set up a type server that maps type URLs to message definitions as follows: * If no scheme is provided, `https` is assumed. * An HTTP GET on the URL must yield a [google.protobuf.Type][] value in binary format, or produce an error. * Applications are allowed to cache lookup results based on the URL, or have them precompiled into a binary to avoid any lookup. Therefore, binary compatibility needs to be preserved on changes to types. (Use versioned type names to manage breaking changes.) Note: this functionality is not currently available in the official protobuf release, and it is not used for type URLs beginning with type.googleapis.com. As of May 2023, there are no widely used type server implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) might be used with implementation specific semantics. Type_ string `json:"@type,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_sub_string_message.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe type SubStringMessage struct { Value string `json:"value,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_the_book_to_update_.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "time" ) // The book's `name` field is used to identify the book to be updated. Format: publishers/{publisher}/books/{book} type TheBookToUpdate_ struct { // Output only. The book's ID. Id string `json:"id,omitempty"` // Output only. Creation time of the book. CreateTime time.Time `json:"createTime,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_the_book_to_update__1.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "time" ) // The book's `name` field is used to identify the book to be updated. Format: publishers/{publisher}/books/{book} type TheBookToUpdate1 struct { // Output only. The book's ID. Id string `json:"id,omitempty"` // Output only. Creation time of the book. CreateTime time.Time `json:"createTime,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_the_book_to_update_the_books_name_field_is_used_to_identify_the_book_to_be_updated_format_publisherspublisherbooksbook.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "time" ) type TheBookToUpdateTheBooksNameFieldIsUsedToIdentifyTheBookToBeUpdatedFormatPublisherspublisherbooksbook struct { // Output only. The book's ID. Id string `json:"id,omitempty"` // Output only. Creation time of the book. CreateTime time.Time `json:"createTime,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_update_v2_request_request_for_update_includes_the_message_and_the_update_mask.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe type UpdateV2RequestRequestForUpdateIncludesTheMessageAndTheUpdateMask struct { Abe *ABitOfEverything4 `json:"abe,omitempty"` // The paths to update. UpdateMask string `json:"updateMask,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_update_v2_request_request_for_update_includes_the_message_and_the_update_mask_1.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe type UpdateV2RequestRequestForUpdateIncludesTheMessageAndTheUpdateMask1 struct { Abe *ABitOfEverything8 `json:"abe,omitempty"` // The paths to update. UpdateMask string `json:"updateMask,omitempty"` } ================================================ FILE: examples/internal/clients/abe/model_v1exampledeep_pathsingle_nested_name_single_nested.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe // Nested is nested type. type V1exampledeepPathsingleNestedNameSingleNested struct { Amount int64 `json:"amount,omitempty"` // DeepEnum description. Ok *NestedDeepEnum `json:"ok,omitempty"` } ================================================ FILE: examples/internal/clients/abe/response.go ================================================ /* * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package abe import ( "net/http" ) type APIResponse struct { *http.Response `json:"-"` Message string `json:"message,omitempty"` // Operation is the name of the swagger operation. Operation string `json:"operation,omitempty"` // RequestURL is the request URL. This value is always available, even if the // embedded *http.Response is nil. RequestURL string `json:"url,omitempty"` // Method is the HTTP method used for the request. This value is always // available, even if the embedded *http.Response is nil. Method string `json:"method,omitempty"` // Payload holds the contents of the response body (which may be nil or empty). // This is provided here as the raw response.Body() reader will have already // been drained. Payload []byte `json:"-"` } func NewAPIResponse(r *http.Response) *APIResponse { response := &APIResponse{Response: r} return response } func NewAPIResponseWithError(errorMessage string) *APIResponse { response := &APIResponse{Message: errorMessage} return response } ================================================ FILE: examples/internal/clients/echo/.gitignore ================================================ /docs ================================================ FILE: examples/internal/clients/echo/.swagger-codegen/VERSION ================================================ 2.4.8 ================================================ FILE: examples/internal/clients/echo/.swagger-codegen-ignore ================================================ .gitignore ================================================ FILE: examples/internal/clients/echo/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library") package(default_visibility = ["//visibility:public"]) go_library( name = "echo", srcs = [ "api_echo_service.go", "client.go", "configuration.go", "model_examplepb_dynamic_message.go", "model_examplepb_dynamic_message_update.go", "model_examplepb_embedded.go", "model_examplepb_nested_message.go", "model_examplepb_simple_message.go", "model_examplepb_status_check_request.go", "model_examplepb_status_check_response.go", "model_google_rpc_status.go", "model_proto_sub2_status.go", "model_proto_sub_status.go", "model_protobuf_any.go", "model_protobuf_null_value.go", "response.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/clients/echo", deps = [ "@com_github_antihax_optional//:optional", "@org_golang_x_oauth2//:oauth2", ], ) alias( name = "go_default_library", actual = ":echo", visibility = ["//examples:__subpackages__"], ) ================================================ FILE: examples/internal/clients/echo/api/swagger.yaml ================================================ --- swagger: "2.0" info: description: "Echo Service API consists of a single service which returns\na message." version: "version not set" title: "Echo Service" tags: - name: "EchoService" consumes: - "application/json" produces: - "application/json" paths: /v1/example/echo/nested/{nId.nId}: get: tags: - "EchoService" summary: "Echo method receives a simple message and returns it." description: "The message posted as the id parameter will also be\nreturned." operationId: "EchoService_Echo7" parameters: - name: "nId.nId" in: "path" required: true type: "string" x-exportParamName: "NIdNId" - name: "id" in: "query" description: "Id represents the message identifier." required: false type: "string" x-exportParamName: "Id" x-optionalDataType: "String" - name: "num" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Num" x-optionalDataType: "String" - name: "lineNum" in: "query" required: false type: "string" format: "int64" x-exportParamName: "LineNum" x-optionalDataType: "String" - name: "lang" in: "query" required: false type: "string" x-exportParamName: "Lang" x-optionalDataType: "String" - name: "status.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "StatusProgress" x-optionalDataType: "String" - name: "status.note" in: "query" required: false type: "string" x-exportParamName: "StatusNote" x-optionalDataType: "String" - name: "en" in: "query" required: false type: "string" format: "int64" x-exportParamName: "En" x-optionalDataType: "String" - name: "no.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "NoProgress" x-optionalDataType: "String" - name: "no.note" in: "query" required: false type: "string" x-exportParamName: "NoNote" x-optionalDataType: "String" - name: "resourceId" in: "query" required: false type: "string" x-exportParamName: "ResourceId" x-optionalDataType: "String" - name: "nId.val" in: "query" required: false type: "string" x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/echo/resource/{resourceId}: get: tags: - "EchoService" summary: "Echo method receives a simple message and returns it." description: "The message posted as the id parameter will also be\nreturned." operationId: "EchoService_Echo6" parameters: - name: "resourceId" in: "path" required: true type: "string" x-exportParamName: "ResourceId" - name: "id" in: "query" description: "Id represents the message identifier." required: false type: "string" x-exportParamName: "Id" x-optionalDataType: "String" - name: "num" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Num" x-optionalDataType: "String" - name: "lineNum" in: "query" required: false type: "string" format: "int64" x-exportParamName: "LineNum" x-optionalDataType: "String" - name: "lang" in: "query" required: false type: "string" x-exportParamName: "Lang" x-optionalDataType: "String" - name: "status.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "StatusProgress" x-optionalDataType: "String" - name: "status.note" in: "query" required: false type: "string" x-exportParamName: "StatusNote" x-optionalDataType: "String" - name: "en" in: "query" required: false type: "string" format: "int64" x-exportParamName: "En" x-optionalDataType: "String" - name: "no.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "NoProgress" x-optionalDataType: "String" - name: "no.note" in: "query" required: false type: "string" x-exportParamName: "NoNote" x-optionalDataType: "String" - name: "nId.nId" in: "query" required: false type: "string" x-exportParamName: "NIdNId" x-optionalDataType: "String" - name: "nId.val" in: "query" required: false type: "string" x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/echo/{id}: post: tags: - "EchoService" summary: "Echo method receives a simple message and returns it." description: "The message posted as the id parameter will also be\nreturned." operationId: "EchoService_Echo" parameters: - name: "id" in: "path" description: "Id represents the message identifier." required: true type: "string" x-exportParamName: "Id" - name: "num" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Num" x-optionalDataType: "String" - name: "lineNum" in: "query" required: false type: "string" format: "int64" x-exportParamName: "LineNum" x-optionalDataType: "String" - name: "lang" in: "query" required: false type: "string" x-exportParamName: "Lang" x-optionalDataType: "String" - name: "status.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "StatusProgress" x-optionalDataType: "String" - name: "status.note" in: "query" required: false type: "string" x-exportParamName: "StatusNote" x-optionalDataType: "String" - name: "en" in: "query" required: false type: "string" format: "int64" x-exportParamName: "En" x-optionalDataType: "String" - name: "no.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "NoProgress" x-optionalDataType: "String" - name: "no.note" in: "query" required: false type: "string" x-exportParamName: "NoNote" x-optionalDataType: "String" - name: "resourceId" in: "query" required: false type: "string" x-exportParamName: "ResourceId" x-optionalDataType: "String" - name: "nId.nId" in: "query" required: false type: "string" x-exportParamName: "NIdNId" x-optionalDataType: "String" - name: "nId.val" in: "query" required: false type: "string" x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/echo/{id}/{num}: get: tags: - "EchoService" summary: "Echo method receives a simple message and returns it." description: "The message posted as the id parameter will also be\nreturned." operationId: "EchoService_Echo2" parameters: - name: "id" in: "path" description: "Id represents the message identifier." required: true type: "string" x-exportParamName: "Id" - name: "num" in: "path" required: true type: "string" format: "int64" x-exportParamName: "Num" - name: "lineNum" in: "query" required: false type: "string" format: "int64" x-exportParamName: "LineNum" x-optionalDataType: "String" - name: "lang" in: "query" required: false type: "string" x-exportParamName: "Lang" x-optionalDataType: "String" - name: "status.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "StatusProgress" x-optionalDataType: "String" - name: "status.note" in: "query" required: false type: "string" x-exportParamName: "StatusNote" x-optionalDataType: "String" - name: "en" in: "query" required: false type: "string" format: "int64" x-exportParamName: "En" x-optionalDataType: "String" - name: "no.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "NoProgress" x-optionalDataType: "String" - name: "no.note" in: "query" required: false type: "string" x-exportParamName: "NoNote" x-optionalDataType: "String" - name: "resourceId" in: "query" required: false type: "string" x-exportParamName: "ResourceId" x-optionalDataType: "String" - name: "nId.nId" in: "query" required: false type: "string" x-exportParamName: "NIdNId" x-optionalDataType: "String" - name: "nId.val" in: "query" required: false type: "string" x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/echo/{id}/{num}/{lang}: get: tags: - "EchoService" summary: "Echo method receives a simple message and returns it." description: "The message posted as the id parameter will also be\nreturned." operationId: "EchoService_Echo3" parameters: - name: "id" in: "path" description: "Id represents the message identifier." required: true type: "string" x-exportParamName: "Id" - name: "num" in: "path" required: true type: "string" format: "int64" x-exportParamName: "Num" - name: "lang" in: "path" required: true type: "string" x-exportParamName: "Lang" - name: "lineNum" in: "query" required: false type: "string" format: "int64" x-exportParamName: "LineNum" x-optionalDataType: "String" - name: "status.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "StatusProgress" x-optionalDataType: "String" - name: "status.note" in: "query" required: false type: "string" x-exportParamName: "StatusNote" x-optionalDataType: "String" - name: "en" in: "query" required: false type: "string" format: "int64" x-exportParamName: "En" x-optionalDataType: "String" - name: "no.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "NoProgress" x-optionalDataType: "String" - name: "no.note" in: "query" required: false type: "string" x-exportParamName: "NoNote" x-optionalDataType: "String" - name: "resourceId" in: "query" required: false type: "string" x-exportParamName: "ResourceId" x-optionalDataType: "String" - name: "nId.nId" in: "query" required: false type: "string" x-exportParamName: "NIdNId" x-optionalDataType: "String" - name: "nId.val" in: "query" required: false type: "string" x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/echo1/{id}/{lineNum}/{status.note}: get: tags: - "EchoService" summary: "Echo method receives a simple message and returns it." description: "The message posted as the id parameter will also be\nreturned." operationId: "EchoService_Echo4" parameters: - name: "id" in: "path" description: "Id represents the message identifier." required: true type: "string" x-exportParamName: "Id" - name: "lineNum" in: "path" required: true type: "string" format: "int64" x-exportParamName: "LineNum" - name: "status.note" in: "path" required: true type: "string" x-exportParamName: "StatusNote" - name: "num" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Num" x-optionalDataType: "String" - name: "lang" in: "query" required: false type: "string" x-exportParamName: "Lang" x-optionalDataType: "String" - name: "status.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "StatusProgress" x-optionalDataType: "String" - name: "en" in: "query" required: false type: "string" format: "int64" x-exportParamName: "En" x-optionalDataType: "String" - name: "no.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "NoProgress" x-optionalDataType: "String" - name: "resourceId" in: "query" required: false type: "string" x-exportParamName: "ResourceId" x-optionalDataType: "String" - name: "nId.nId" in: "query" required: false type: "string" x-exportParamName: "NIdNId" x-optionalDataType: "String" - name: "nId.val" in: "query" required: false type: "string" x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/echo2/{no.note}: get: tags: - "EchoService" summary: "Echo method receives a simple message and returns it." description: "The message posted as the id parameter will also be\nreturned." operationId: "EchoService_Echo5" parameters: - name: "no.note" in: "path" required: true type: "string" x-exportParamName: "NoNote" - name: "id" in: "query" description: "Id represents the message identifier." required: false type: "string" x-exportParamName: "Id" x-optionalDataType: "String" - name: "num" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Num" x-optionalDataType: "String" - name: "lineNum" in: "query" required: false type: "string" format: "int64" x-exportParamName: "LineNum" x-optionalDataType: "String" - name: "lang" in: "query" required: false type: "string" x-exportParamName: "Lang" x-optionalDataType: "String" - name: "status.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "StatusProgress" x-optionalDataType: "String" - name: "en" in: "query" required: false type: "string" format: "int64" x-exportParamName: "En" x-optionalDataType: "String" - name: "no.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "NoProgress" x-optionalDataType: "String" - name: "resourceId" in: "query" required: false type: "string" x-exportParamName: "ResourceId" x-optionalDataType: "String" - name: "nId.nId" in: "query" required: false type: "string" x-exportParamName: "NIdNId" x-optionalDataType: "String" - name: "nId.val" in: "query" required: false type: "string" x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/echo_body: post: tags: - "EchoService" summary: "EchoBody method receives a simple message and returns it." operationId: "EchoService_EchoBody" parameters: - in: "body" name: "body" description: "SimpleMessage represents a simple message sent to the Echo service." required: true schema: $ref: "#/definitions/examplepbSimpleMessage" x-exportParamName: "Body" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/echo_body/{id}: put: tags: - "EchoService" summary: "EchoBody method receives a simple message and returns it." operationId: "EchoService_EchoBody2" parameters: - name: "id" in: "path" description: "Id represents the message identifier." required: true type: "string" x-exportParamName: "Id" - in: "body" name: "no" required: true schema: $ref: "#/definitions/examplepbEmbedded" x-exportParamName: "No" - name: "num" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Num" x-optionalDataType: "String" - name: "lineNum" in: "query" required: false type: "string" format: "int64" x-exportParamName: "LineNum" x-optionalDataType: "String" - name: "lang" in: "query" required: false type: "string" x-exportParamName: "Lang" x-optionalDataType: "String" - name: "status.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "StatusProgress" x-optionalDataType: "String" - name: "status.note" in: "query" required: false type: "string" x-exportParamName: "StatusNote" x-optionalDataType: "String" - name: "resourceId" in: "query" required: false type: "string" x-exportParamName: "ResourceId" x-optionalDataType: "String" - name: "nId.nId" in: "query" required: false type: "string" x-exportParamName: "NIdNId" x-optionalDataType: "String" - name: "nId.val" in: "query" required: false type: "string" x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/echo_delete: delete: tags: - "EchoService" summary: "EchoDelete method receives a simple message and returns it." operationId: "EchoService_EchoDelete" parameters: - name: "id" in: "query" description: "Id represents the message identifier." required: false type: "string" x-exportParamName: "Id" x-optionalDataType: "String" - name: "num" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Num" x-optionalDataType: "String" - name: "lineNum" in: "query" required: false type: "string" format: "int64" x-exportParamName: "LineNum" x-optionalDataType: "String" - name: "lang" in: "query" required: false type: "string" x-exportParamName: "Lang" x-optionalDataType: "String" - name: "status.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "StatusProgress" x-optionalDataType: "String" - name: "status.note" in: "query" required: false type: "string" x-exportParamName: "StatusNote" x-optionalDataType: "String" - name: "en" in: "query" required: false type: "string" format: "int64" x-exportParamName: "En" x-optionalDataType: "String" - name: "no.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "NoProgress" x-optionalDataType: "String" - name: "no.note" in: "query" required: false type: "string" x-exportParamName: "NoNote" x-optionalDataType: "String" - name: "resourceId" in: "query" required: false type: "string" x-exportParamName: "ResourceId" x-optionalDataType: "String" - name: "nId.nId" in: "query" required: false type: "string" x-exportParamName: "NIdNId" x-optionalDataType: "String" - name: "nId.val" in: "query" required: false type: "string" x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/echo_patch: patch: tags: - "EchoService" summary: "EchoPatch method receives a NonStandardUpdateRequest and returns it." operationId: "EchoService_EchoPatch" parameters: - in: "body" name: "body" required: true schema: $ref: "#/definitions/examplepbDynamicMessage" x-exportParamName: "Body" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbDynamicMessageUpdate" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/echo_status: post: tags: - "EchoService" summary: "EchoStatus demonstrates handling of name collisions.\nIt uses Status\ \ types from both sub and sub2 packages which have the same name\nbut different\ \ structures, demonstrating how the OpenAPI generator handles this scenario." operationId: "EchoService_EchoStatus" parameters: - in: "body" name: "body" description: "StatusCheckRequest demonstrates name collision handling.\nIt\ \ uses Status message from both sub and sub2 packages." required: true schema: $ref: "#/definitions/examplepbStatusCheckRequest" x-exportParamName: "Body" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbStatusCheckResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /v1/example/echo_unauthorized: get: tags: - "EchoService" summary: "EchoUnauthorized method receives a simple message and returns it.\ \ It must\nalways return a google.rpc.Code of `UNAUTHENTICATED` and a HTTP\ \ Status code\nof 401." operationId: "EchoService_EchoUnauthorized" parameters: - name: "id" in: "query" description: "Id represents the message identifier." required: false type: "string" x-exportParamName: "Id" x-optionalDataType: "String" - name: "num" in: "query" required: false type: "string" format: "int64" x-exportParamName: "Num" x-optionalDataType: "String" - name: "lineNum" in: "query" required: false type: "string" format: "int64" x-exportParamName: "LineNum" x-optionalDataType: "String" - name: "lang" in: "query" required: false type: "string" x-exportParamName: "Lang" x-optionalDataType: "String" - name: "status.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "StatusProgress" x-optionalDataType: "String" - name: "status.note" in: "query" required: false type: "string" x-exportParamName: "StatusNote" x-optionalDataType: "String" - name: "en" in: "query" required: false type: "string" format: "int64" x-exportParamName: "En" x-optionalDataType: "String" - name: "no.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "NoProgress" x-optionalDataType: "String" - name: "no.note" in: "query" required: false type: "string" x-exportParamName: "NoNote" x-optionalDataType: "String" - name: "resourceId" in: "query" required: false type: "string" x-exportParamName: "ResourceId" x-optionalDataType: "String" - name: "nId.nId" in: "query" required: false type: "string" x-exportParamName: "NIdNId" x-optionalDataType: "String" - name: "nId.val" in: "query" required: false type: "string" x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbSimpleMessage" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" definitions: examplepbDynamicMessage: type: "object" properties: structField: type: "object" properties: {} valueField: {} description: "DynamicMessage represents a message which can have its structure\n\ built dynamically using Struct and Values." example: structField: "{}" valueField: "" examplepbDynamicMessageUpdate: type: "object" properties: body: $ref: "#/definitions/examplepbDynamicMessage" updateMask: type: "string" example: body: structField: "{}" valueField: "" updateMask: "updateMask" examplepbEmbedded: type: "object" properties: progress: type: "string" format: "int64" note: type: "string" description: "Embedded represents a message embedded in SimpleMessage." example: note: "note" progress: "progress" examplepbNestedMessage: type: "object" properties: nId: type: "string" val: type: "string" example: val: "val" nId: "nId" examplepbSimpleMessage: type: "object" properties: id: type: "string" description: "Id represents the message identifier." num: type: "string" format: "int64" lineNum: type: "string" format: "int64" lang: type: "string" status: $ref: "#/definitions/examplepbEmbedded" en: type: "string" format: "int64" "no": $ref: "#/definitions/examplepbEmbedded" resourceId: type: "string" nId: $ref: "#/definitions/examplepbNestedMessage" description: "SimpleMessage represents a simple message sent to the Echo service." example: "no": note: "note" progress: "progress" resourceId: "resourceId" num: "num" nId: val: "val" nId: "nId" lineNum: "lineNum" en: "en" id: "id" lang: "lang" status: note: "note" progress: "progress" examplepbStatusCheckRequest: type: "object" properties: id: type: "string" subStatus: title: "Status from sub package" $ref: "#/definitions/protoSubStatus" sub2Status: title: "Status from sub2 package (different type with same name)" $ref: "#/definitions/protoSub2Status" description: "StatusCheckRequest demonstrates name collision handling.\nIt uses\ \ Status message from both sub and sub2 packages." examplepbStatusCheckResponse: type: "object" properties: result: type: "string" subStatus: title: "Both Status types used in response" $ref: "#/definitions/protoSubStatus" sub2Status: $ref: "#/definitions/protoSub2Status" example: result: "result" sub2Status: severity: 6 errorMessage: "errorMessage" errorCode: "errorCode" subStatus: code: 0 message: "message" googleRpcStatus: type: "object" properties: code: type: "integer" format: "int32" description: "The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]." message: type: "string" description: "A developer-facing error message, which should be in English.\ \ Any\nuser-facing error message should be localized and sent in the\n[google.rpc.Status.details][google.rpc.Status.details]\ \ field, or localized by the client." details: type: "array" description: "A list of messages that carry the error details. There is a\ \ common set of\nmessage types for APIs to use." items: $ref: "#/definitions/protobufAny" description: "The `Status` type defines a logical error model that is suitable\ \ for\ndifferent programming environments, including REST APIs and RPC APIs.\ \ It is\nused by [gRPC](https://github.com/grpc). Each `Status` message contains\n\ three pieces of data: error code, error message, and error details.\n\nYou can\ \ find out more about this error model and how to work with it in the\n[API\ \ Design Guide](https://cloud.google.com/apis/design/errors)." protoSub2Status: type: "object" properties: errorCode: type: "string" errorMessage: type: "string" severity: type: "integer" format: "int32" title: "Status message in sub2 package (different structure from sub.Status)" example: severity: 6 errorMessage: "errorMessage" errorCode: "errorCode" protoSubStatus: type: "object" properties: code: type: "integer" format: "int32" message: type: "string" title: "Status message in sub package" example: code: 0 message: "message" protobufAny: type: "object" properties: '@type': type: "string" description: "A URL/resource name that uniquely identifies the type of the\ \ serialized\nprotocol buffer message. This string must contain at least\n\ one \"/\" character. The last segment of the URL's path must represent\n\ the fully qualified name of the type (as in\n`path/google.protobuf.Duration`).\ \ The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\ \nIn practice, teams usually precompile into the binary all types that they\n\ expect it to use in the context of Any. However, for URLs which use the\n\ scheme `http`, `https`, or no scheme, one can optionally set up a type\n\ server that maps type URLs to message definitions as follows:\n\n* If no\ \ scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must\ \ yield a [google.protobuf.Type][]\n value in binary format, or produce\ \ an error.\n* Applications are allowed to cache lookup results based on\ \ the\n URL, or have them precompiled into a binary to avoid any\n lookup.\ \ Therefore, binary compatibility needs to be preserved\n on changes to\ \ types. (Use versioned type names to manage\n breaking changes.)\n\nNote:\ \ this functionality is not currently available in the official\nprotobuf\ \ release, and it is not used for type URLs beginning with\ntype.googleapis.com.\ \ As of May 2023, there are no widely used type server\nimplementations\ \ and no plans to implement one.\n\nSchemes other than `http`, `https` (or\ \ the empty scheme) might be\nused with implementation specific semantics." description: "`Any` contains an arbitrary serialized protocol buffer message along\ \ with a\nURL that describes the type of the serialized message.\n\nProtobuf\ \ library provides support to pack/unpack Any values in the form\nof utility\ \ functions or additional generated methods of the Any type.\n\nExample 1: Pack\ \ and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n\ \ ...\n if (any.UnpackTo(&foo)) {\n ...\n }\n\nExample 2: Pack\ \ and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n\ \ ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n\ \ }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n\ \ foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack\ \ and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n \ \ any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n\ \ ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := &pb.Foo{...}\n\ \ any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n\ \ ...\n foo := &pb.Foo{}\n if err := any.UnmarshalTo(foo); err !=\ \ nil {\n ...\n }\n\nThe pack methods provided by protobuf library\ \ will by default use\n'type.googleapis.com/full.type.name' as the type URL\ \ and the unpack\nmethods only use the fully qualified type name after the last\ \ '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\n\ name \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses\ \ the regular\nrepresentation of the deserialized, embedded message, with an\n\ additional field `@type` which contains the type URL. Example:\n\n package\ \ google.profile;\n message Person {\n string first_name = 1;\n \ \ string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\"\ ,\n \"firstName\": ,\n \"lastName\": \n }\n\nIf\ \ the embedded message type is well-known and has a custom JSON\nrepresentation,\ \ that representation will be embedded adding a field\n`value` which holds the\ \ custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\ \n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n\ \ \"value\": \"1.212s\"\n }" additionalProperties: {} protobufNullValue: type: "string" description: "`NullValue` is a singleton enumeration to represent the null value\ \ for the\n`Value` type union.\n\nThe JSON representation for `NullValue` is\ \ JSON `null`.\n\n - NULL_VALUE: Null value." enum: - "NULL_VALUE" default: "NULL_VALUE" ================================================ FILE: examples/internal/clients/echo/api_echo_service.go ================================================ /* * Echo Service * * Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo import ( "context" "io/ioutil" "net/http" "net/url" "strings" "fmt" "github.com/antihax/optional" ) // Linger please var ( _ context.Context ) type EchoServiceApiService service /* EchoServiceApiService Echo method receives a simple message and returns it. The message posted as the id parameter will also be returned. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param id Id represents the message identifier. * @param optional nil or *EchoServiceEchoOpts - Optional Parameters: * @param "Num" (optional.String) - * @param "LineNum" (optional.String) - * @param "Lang" (optional.String) - * @param "StatusProgress" (optional.String) - * @param "StatusNote" (optional.String) - * @param "En" (optional.String) - * @param "NoProgress" (optional.String) - * @param "NoNote" (optional.String) - * @param "ResourceId" (optional.String) - * @param "NIdNId" (optional.String) - * @param "NIdVal" (optional.String) - @return ExamplepbSimpleMessage */ type EchoServiceEchoOpts struct { Num optional.String LineNum optional.String Lang optional.String StatusProgress optional.String StatusNote optional.String En optional.String NoProgress optional.String NoNote optional.String ResourceId optional.String NIdNId optional.String NIdVal optional.String } func (a *EchoServiceApiService) EchoServiceEcho(ctx context.Context, id string, localVarOptionals *EchoServiceEchoOpts) (ExamplepbSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbSimpleMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/echo/{id}" localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.Num.IsSet() { localVarQueryParams.Add("num", parameterToString(localVarOptionals.Num.Value(), "")) } if localVarOptionals != nil && localVarOptionals.LineNum.IsSet() { localVarQueryParams.Add("lineNum", parameterToString(localVarOptionals.LineNum.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Lang.IsSet() { localVarQueryParams.Add("lang", parameterToString(localVarOptionals.Lang.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusProgress.IsSet() { localVarQueryParams.Add("status.progress", parameterToString(localVarOptionals.StatusProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusNote.IsSet() { localVarQueryParams.Add("status.note", parameterToString(localVarOptionals.StatusNote.Value(), "")) } if localVarOptionals != nil && localVarOptionals.En.IsSet() { localVarQueryParams.Add("en", parameterToString(localVarOptionals.En.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoProgress.IsSet() { localVarQueryParams.Add("no.progress", parameterToString(localVarOptionals.NoProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoNote.IsSet() { localVarQueryParams.Add("no.note", parameterToString(localVarOptionals.NoNote.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ResourceId.IsSet() { localVarQueryParams.Add("resourceId", parameterToString(localVarOptionals.ResourceId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdNId.IsSet() { localVarQueryParams.Add("nId.nId", parameterToString(localVarOptionals.NIdNId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdVal.IsSet() { localVarQueryParams.Add("nId.val", parameterToString(localVarOptionals.NIdVal.Value(), "")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbSimpleMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* EchoServiceApiService Echo method receives a simple message and returns it. The message posted as the id parameter will also be returned. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param id Id represents the message identifier. * @param num * @param optional nil or *EchoServiceEcho2Opts - Optional Parameters: * @param "LineNum" (optional.String) - * @param "Lang" (optional.String) - * @param "StatusProgress" (optional.String) - * @param "StatusNote" (optional.String) - * @param "En" (optional.String) - * @param "NoProgress" (optional.String) - * @param "NoNote" (optional.String) - * @param "ResourceId" (optional.String) - * @param "NIdNId" (optional.String) - * @param "NIdVal" (optional.String) - @return ExamplepbSimpleMessage */ type EchoServiceEcho2Opts struct { LineNum optional.String Lang optional.String StatusProgress optional.String StatusNote optional.String En optional.String NoProgress optional.String NoNote optional.String ResourceId optional.String NIdNId optional.String NIdVal optional.String } func (a *EchoServiceApiService) EchoServiceEcho2(ctx context.Context, id string, num string, localVarOptionals *EchoServiceEcho2Opts) (ExamplepbSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbSimpleMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/echo/{id}/{num}" localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) localVarPath = strings.Replace(localVarPath, "{"+"num"+"}", fmt.Sprintf("%v", num), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.LineNum.IsSet() { localVarQueryParams.Add("lineNum", parameterToString(localVarOptionals.LineNum.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Lang.IsSet() { localVarQueryParams.Add("lang", parameterToString(localVarOptionals.Lang.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusProgress.IsSet() { localVarQueryParams.Add("status.progress", parameterToString(localVarOptionals.StatusProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusNote.IsSet() { localVarQueryParams.Add("status.note", parameterToString(localVarOptionals.StatusNote.Value(), "")) } if localVarOptionals != nil && localVarOptionals.En.IsSet() { localVarQueryParams.Add("en", parameterToString(localVarOptionals.En.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoProgress.IsSet() { localVarQueryParams.Add("no.progress", parameterToString(localVarOptionals.NoProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoNote.IsSet() { localVarQueryParams.Add("no.note", parameterToString(localVarOptionals.NoNote.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ResourceId.IsSet() { localVarQueryParams.Add("resourceId", parameterToString(localVarOptionals.ResourceId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdNId.IsSet() { localVarQueryParams.Add("nId.nId", parameterToString(localVarOptionals.NIdNId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdVal.IsSet() { localVarQueryParams.Add("nId.val", parameterToString(localVarOptionals.NIdVal.Value(), "")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbSimpleMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* EchoServiceApiService Echo method receives a simple message and returns it. The message posted as the id parameter will also be returned. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param id Id represents the message identifier. * @param num * @param lang * @param optional nil or *EchoServiceEcho3Opts - Optional Parameters: * @param "LineNum" (optional.String) - * @param "StatusProgress" (optional.String) - * @param "StatusNote" (optional.String) - * @param "En" (optional.String) - * @param "NoProgress" (optional.String) - * @param "NoNote" (optional.String) - * @param "ResourceId" (optional.String) - * @param "NIdNId" (optional.String) - * @param "NIdVal" (optional.String) - @return ExamplepbSimpleMessage */ type EchoServiceEcho3Opts struct { LineNum optional.String StatusProgress optional.String StatusNote optional.String En optional.String NoProgress optional.String NoNote optional.String ResourceId optional.String NIdNId optional.String NIdVal optional.String } func (a *EchoServiceApiService) EchoServiceEcho3(ctx context.Context, id string, num string, lang string, localVarOptionals *EchoServiceEcho3Opts) (ExamplepbSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbSimpleMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/echo/{id}/{num}/{lang}" localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) localVarPath = strings.Replace(localVarPath, "{"+"num"+"}", fmt.Sprintf("%v", num), -1) localVarPath = strings.Replace(localVarPath, "{"+"lang"+"}", fmt.Sprintf("%v", lang), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.LineNum.IsSet() { localVarQueryParams.Add("lineNum", parameterToString(localVarOptionals.LineNum.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusProgress.IsSet() { localVarQueryParams.Add("status.progress", parameterToString(localVarOptionals.StatusProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusNote.IsSet() { localVarQueryParams.Add("status.note", parameterToString(localVarOptionals.StatusNote.Value(), "")) } if localVarOptionals != nil && localVarOptionals.En.IsSet() { localVarQueryParams.Add("en", parameterToString(localVarOptionals.En.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoProgress.IsSet() { localVarQueryParams.Add("no.progress", parameterToString(localVarOptionals.NoProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoNote.IsSet() { localVarQueryParams.Add("no.note", parameterToString(localVarOptionals.NoNote.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ResourceId.IsSet() { localVarQueryParams.Add("resourceId", parameterToString(localVarOptionals.ResourceId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdNId.IsSet() { localVarQueryParams.Add("nId.nId", parameterToString(localVarOptionals.NIdNId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdVal.IsSet() { localVarQueryParams.Add("nId.val", parameterToString(localVarOptionals.NIdVal.Value(), "")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbSimpleMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* EchoServiceApiService Echo method receives a simple message and returns it. The message posted as the id parameter will also be returned. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param id Id represents the message identifier. * @param lineNum * @param statusNote * @param optional nil or *EchoServiceEcho4Opts - Optional Parameters: * @param "Num" (optional.String) - * @param "Lang" (optional.String) - * @param "StatusProgress" (optional.String) - * @param "En" (optional.String) - * @param "NoProgress" (optional.String) - * @param "ResourceId" (optional.String) - * @param "NIdNId" (optional.String) - * @param "NIdVal" (optional.String) - @return ExamplepbSimpleMessage */ type EchoServiceEcho4Opts struct { Num optional.String Lang optional.String StatusProgress optional.String En optional.String NoProgress optional.String ResourceId optional.String NIdNId optional.String NIdVal optional.String } func (a *EchoServiceApiService) EchoServiceEcho4(ctx context.Context, id string, lineNum string, statusNote string, localVarOptionals *EchoServiceEcho4Opts) (ExamplepbSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbSimpleMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/echo1/{id}/{lineNum}/{status.note}" localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) localVarPath = strings.Replace(localVarPath, "{"+"lineNum"+"}", fmt.Sprintf("%v", lineNum), -1) localVarPath = strings.Replace(localVarPath, "{"+"status.note"+"}", fmt.Sprintf("%v", statusNote), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.Num.IsSet() { localVarQueryParams.Add("num", parameterToString(localVarOptionals.Num.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Lang.IsSet() { localVarQueryParams.Add("lang", parameterToString(localVarOptionals.Lang.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusProgress.IsSet() { localVarQueryParams.Add("status.progress", parameterToString(localVarOptionals.StatusProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.En.IsSet() { localVarQueryParams.Add("en", parameterToString(localVarOptionals.En.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoProgress.IsSet() { localVarQueryParams.Add("no.progress", parameterToString(localVarOptionals.NoProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ResourceId.IsSet() { localVarQueryParams.Add("resourceId", parameterToString(localVarOptionals.ResourceId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdNId.IsSet() { localVarQueryParams.Add("nId.nId", parameterToString(localVarOptionals.NIdNId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdVal.IsSet() { localVarQueryParams.Add("nId.val", parameterToString(localVarOptionals.NIdVal.Value(), "")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbSimpleMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* EchoServiceApiService Echo method receives a simple message and returns it. The message posted as the id parameter will also be returned. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param noNote * @param optional nil or *EchoServiceEcho5Opts - Optional Parameters: * @param "Id" (optional.String) - Id represents the message identifier. * @param "Num" (optional.String) - * @param "LineNum" (optional.String) - * @param "Lang" (optional.String) - * @param "StatusProgress" (optional.String) - * @param "En" (optional.String) - * @param "NoProgress" (optional.String) - * @param "ResourceId" (optional.String) - * @param "NIdNId" (optional.String) - * @param "NIdVal" (optional.String) - @return ExamplepbSimpleMessage */ type EchoServiceEcho5Opts struct { Id optional.String Num optional.String LineNum optional.String Lang optional.String StatusProgress optional.String En optional.String NoProgress optional.String ResourceId optional.String NIdNId optional.String NIdVal optional.String } func (a *EchoServiceApiService) EchoServiceEcho5(ctx context.Context, noNote string, localVarOptionals *EchoServiceEcho5Opts) (ExamplepbSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbSimpleMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/echo2/{no.note}" localVarPath = strings.Replace(localVarPath, "{"+"no.note"+"}", fmt.Sprintf("%v", noNote), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.Id.IsSet() { localVarQueryParams.Add("id", parameterToString(localVarOptionals.Id.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Num.IsSet() { localVarQueryParams.Add("num", parameterToString(localVarOptionals.Num.Value(), "")) } if localVarOptionals != nil && localVarOptionals.LineNum.IsSet() { localVarQueryParams.Add("lineNum", parameterToString(localVarOptionals.LineNum.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Lang.IsSet() { localVarQueryParams.Add("lang", parameterToString(localVarOptionals.Lang.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusProgress.IsSet() { localVarQueryParams.Add("status.progress", parameterToString(localVarOptionals.StatusProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.En.IsSet() { localVarQueryParams.Add("en", parameterToString(localVarOptionals.En.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoProgress.IsSet() { localVarQueryParams.Add("no.progress", parameterToString(localVarOptionals.NoProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ResourceId.IsSet() { localVarQueryParams.Add("resourceId", parameterToString(localVarOptionals.ResourceId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdNId.IsSet() { localVarQueryParams.Add("nId.nId", parameterToString(localVarOptionals.NIdNId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdVal.IsSet() { localVarQueryParams.Add("nId.val", parameterToString(localVarOptionals.NIdVal.Value(), "")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbSimpleMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* EchoServiceApiService Echo method receives a simple message and returns it. The message posted as the id parameter will also be returned. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param resourceId * @param optional nil or *EchoServiceEcho6Opts - Optional Parameters: * @param "Id" (optional.String) - Id represents the message identifier. * @param "Num" (optional.String) - * @param "LineNum" (optional.String) - * @param "Lang" (optional.String) - * @param "StatusProgress" (optional.String) - * @param "StatusNote" (optional.String) - * @param "En" (optional.String) - * @param "NoProgress" (optional.String) - * @param "NoNote" (optional.String) - * @param "NIdNId" (optional.String) - * @param "NIdVal" (optional.String) - @return ExamplepbSimpleMessage */ type EchoServiceEcho6Opts struct { Id optional.String Num optional.String LineNum optional.String Lang optional.String StatusProgress optional.String StatusNote optional.String En optional.String NoProgress optional.String NoNote optional.String NIdNId optional.String NIdVal optional.String } func (a *EchoServiceApiService) EchoServiceEcho6(ctx context.Context, resourceId string, localVarOptionals *EchoServiceEcho6Opts) (ExamplepbSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbSimpleMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/echo/resource/{resourceId}" localVarPath = strings.Replace(localVarPath, "{"+"resourceId"+"}", fmt.Sprintf("%v", resourceId), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.Id.IsSet() { localVarQueryParams.Add("id", parameterToString(localVarOptionals.Id.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Num.IsSet() { localVarQueryParams.Add("num", parameterToString(localVarOptionals.Num.Value(), "")) } if localVarOptionals != nil && localVarOptionals.LineNum.IsSet() { localVarQueryParams.Add("lineNum", parameterToString(localVarOptionals.LineNum.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Lang.IsSet() { localVarQueryParams.Add("lang", parameterToString(localVarOptionals.Lang.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusProgress.IsSet() { localVarQueryParams.Add("status.progress", parameterToString(localVarOptionals.StatusProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusNote.IsSet() { localVarQueryParams.Add("status.note", parameterToString(localVarOptionals.StatusNote.Value(), "")) } if localVarOptionals != nil && localVarOptionals.En.IsSet() { localVarQueryParams.Add("en", parameterToString(localVarOptionals.En.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoProgress.IsSet() { localVarQueryParams.Add("no.progress", parameterToString(localVarOptionals.NoProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoNote.IsSet() { localVarQueryParams.Add("no.note", parameterToString(localVarOptionals.NoNote.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdNId.IsSet() { localVarQueryParams.Add("nId.nId", parameterToString(localVarOptionals.NIdNId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdVal.IsSet() { localVarQueryParams.Add("nId.val", parameterToString(localVarOptionals.NIdVal.Value(), "")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbSimpleMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* EchoServiceApiService Echo method receives a simple message and returns it. The message posted as the id parameter will also be returned. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param nIdNId * @param optional nil or *EchoServiceEcho7Opts - Optional Parameters: * @param "Id" (optional.String) - Id represents the message identifier. * @param "Num" (optional.String) - * @param "LineNum" (optional.String) - * @param "Lang" (optional.String) - * @param "StatusProgress" (optional.String) - * @param "StatusNote" (optional.String) - * @param "En" (optional.String) - * @param "NoProgress" (optional.String) - * @param "NoNote" (optional.String) - * @param "ResourceId" (optional.String) - * @param "NIdVal" (optional.String) - @return ExamplepbSimpleMessage */ type EchoServiceEcho7Opts struct { Id optional.String Num optional.String LineNum optional.String Lang optional.String StatusProgress optional.String StatusNote optional.String En optional.String NoProgress optional.String NoNote optional.String ResourceId optional.String NIdVal optional.String } func (a *EchoServiceApiService) EchoServiceEcho7(ctx context.Context, nIdNId string, localVarOptionals *EchoServiceEcho7Opts) (ExamplepbSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbSimpleMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/echo/nested/{nId.nId}" localVarPath = strings.Replace(localVarPath, "{"+"nId.nId"+"}", fmt.Sprintf("%v", nIdNId), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.Id.IsSet() { localVarQueryParams.Add("id", parameterToString(localVarOptionals.Id.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Num.IsSet() { localVarQueryParams.Add("num", parameterToString(localVarOptionals.Num.Value(), "")) } if localVarOptionals != nil && localVarOptionals.LineNum.IsSet() { localVarQueryParams.Add("lineNum", parameterToString(localVarOptionals.LineNum.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Lang.IsSet() { localVarQueryParams.Add("lang", parameterToString(localVarOptionals.Lang.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusProgress.IsSet() { localVarQueryParams.Add("status.progress", parameterToString(localVarOptionals.StatusProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusNote.IsSet() { localVarQueryParams.Add("status.note", parameterToString(localVarOptionals.StatusNote.Value(), "")) } if localVarOptionals != nil && localVarOptionals.En.IsSet() { localVarQueryParams.Add("en", parameterToString(localVarOptionals.En.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoProgress.IsSet() { localVarQueryParams.Add("no.progress", parameterToString(localVarOptionals.NoProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoNote.IsSet() { localVarQueryParams.Add("no.note", parameterToString(localVarOptionals.NoNote.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ResourceId.IsSet() { localVarQueryParams.Add("resourceId", parameterToString(localVarOptionals.ResourceId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdVal.IsSet() { localVarQueryParams.Add("nId.val", parameterToString(localVarOptionals.NIdVal.Value(), "")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbSimpleMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* EchoServiceApiService EchoBody method receives a simple message and returns it. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param body SimpleMessage represents a simple message sent to the Echo service. @return ExamplepbSimpleMessage */ func (a *EchoServiceApiService) EchoServiceEchoBody(ctx context.Context, body ExamplepbSimpleMessage) (ExamplepbSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbSimpleMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/echo_body" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbSimpleMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* EchoServiceApiService EchoBody method receives a simple message and returns it. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param id Id represents the message identifier. * @param no * @param optional nil or *EchoServiceEchoBody2Opts - Optional Parameters: * @param "Num" (optional.String) - * @param "LineNum" (optional.String) - * @param "Lang" (optional.String) - * @param "StatusProgress" (optional.String) - * @param "StatusNote" (optional.String) - * @param "ResourceId" (optional.String) - * @param "NIdNId" (optional.String) - * @param "NIdVal" (optional.String) - @return ExamplepbSimpleMessage */ type EchoServiceEchoBody2Opts struct { Num optional.String LineNum optional.String Lang optional.String StatusProgress optional.String StatusNote optional.String ResourceId optional.String NIdNId optional.String NIdVal optional.String } func (a *EchoServiceApiService) EchoServiceEchoBody2(ctx context.Context, id string, no ExamplepbEmbedded, localVarOptionals *EchoServiceEchoBody2Opts) (ExamplepbSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Put") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbSimpleMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/echo_body/{id}" localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.Num.IsSet() { localVarQueryParams.Add("num", parameterToString(localVarOptionals.Num.Value(), "")) } if localVarOptionals != nil && localVarOptionals.LineNum.IsSet() { localVarQueryParams.Add("lineNum", parameterToString(localVarOptionals.LineNum.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Lang.IsSet() { localVarQueryParams.Add("lang", parameterToString(localVarOptionals.Lang.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusProgress.IsSet() { localVarQueryParams.Add("status.progress", parameterToString(localVarOptionals.StatusProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusNote.IsSet() { localVarQueryParams.Add("status.note", parameterToString(localVarOptionals.StatusNote.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ResourceId.IsSet() { localVarQueryParams.Add("resourceId", parameterToString(localVarOptionals.ResourceId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdNId.IsSet() { localVarQueryParams.Add("nId.nId", parameterToString(localVarOptionals.NIdNId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdVal.IsSet() { localVarQueryParams.Add("nId.val", parameterToString(localVarOptionals.NIdVal.Value(), "")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &no r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbSimpleMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* EchoServiceApiService EchoDelete method receives a simple message and returns it. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param optional nil or *EchoServiceEchoDeleteOpts - Optional Parameters: * @param "Id" (optional.String) - Id represents the message identifier. * @param "Num" (optional.String) - * @param "LineNum" (optional.String) - * @param "Lang" (optional.String) - * @param "StatusProgress" (optional.String) - * @param "StatusNote" (optional.String) - * @param "En" (optional.String) - * @param "NoProgress" (optional.String) - * @param "NoNote" (optional.String) - * @param "ResourceId" (optional.String) - * @param "NIdNId" (optional.String) - * @param "NIdVal" (optional.String) - @return ExamplepbSimpleMessage */ type EchoServiceEchoDeleteOpts struct { Id optional.String Num optional.String LineNum optional.String Lang optional.String StatusProgress optional.String StatusNote optional.String En optional.String NoProgress optional.String NoNote optional.String ResourceId optional.String NIdNId optional.String NIdVal optional.String } func (a *EchoServiceApiService) EchoServiceEchoDelete(ctx context.Context, localVarOptionals *EchoServiceEchoDeleteOpts) (ExamplepbSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Delete") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbSimpleMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/echo_delete" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.Id.IsSet() { localVarQueryParams.Add("id", parameterToString(localVarOptionals.Id.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Num.IsSet() { localVarQueryParams.Add("num", parameterToString(localVarOptionals.Num.Value(), "")) } if localVarOptionals != nil && localVarOptionals.LineNum.IsSet() { localVarQueryParams.Add("lineNum", parameterToString(localVarOptionals.LineNum.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Lang.IsSet() { localVarQueryParams.Add("lang", parameterToString(localVarOptionals.Lang.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusProgress.IsSet() { localVarQueryParams.Add("status.progress", parameterToString(localVarOptionals.StatusProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusNote.IsSet() { localVarQueryParams.Add("status.note", parameterToString(localVarOptionals.StatusNote.Value(), "")) } if localVarOptionals != nil && localVarOptionals.En.IsSet() { localVarQueryParams.Add("en", parameterToString(localVarOptionals.En.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoProgress.IsSet() { localVarQueryParams.Add("no.progress", parameterToString(localVarOptionals.NoProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoNote.IsSet() { localVarQueryParams.Add("no.note", parameterToString(localVarOptionals.NoNote.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ResourceId.IsSet() { localVarQueryParams.Add("resourceId", parameterToString(localVarOptionals.ResourceId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdNId.IsSet() { localVarQueryParams.Add("nId.nId", parameterToString(localVarOptionals.NIdNId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdVal.IsSet() { localVarQueryParams.Add("nId.val", parameterToString(localVarOptionals.NIdVal.Value(), "")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbSimpleMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* EchoServiceApiService EchoPatch method receives a NonStandardUpdateRequest and returns it. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param body @return ExamplepbDynamicMessageUpdate */ func (a *EchoServiceApiService) EchoServiceEchoPatch(ctx context.Context, body ExamplepbDynamicMessage) (ExamplepbDynamicMessageUpdate, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Patch") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbDynamicMessageUpdate ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/echo_patch" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbDynamicMessageUpdate err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* EchoServiceApiService EchoStatus demonstrates handling of name collisions. It uses Status types from both sub and sub2 packages which have the same name but different structures, demonstrating how the OpenAPI generator handles this scenario. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param body StatusCheckRequest demonstrates name collision handling. It uses Status message from both sub and sub2 packages. @return ExamplepbStatusCheckResponse */ func (a *EchoServiceApiService) EchoServiceEchoStatus(ctx context.Context, body ExamplepbStatusCheckRequest) (ExamplepbStatusCheckResponse, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbStatusCheckResponse ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/echo_status" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbStatusCheckResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* EchoServiceApiService EchoUnauthorized method receives a simple message and returns it. It must always return a google.rpc.Code of `UNAUTHENTICATED` and a HTTP Status code of 401. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param optional nil or *EchoServiceEchoUnauthorizedOpts - Optional Parameters: * @param "Id" (optional.String) - Id represents the message identifier. * @param "Num" (optional.String) - * @param "LineNum" (optional.String) - * @param "Lang" (optional.String) - * @param "StatusProgress" (optional.String) - * @param "StatusNote" (optional.String) - * @param "En" (optional.String) - * @param "NoProgress" (optional.String) - * @param "NoNote" (optional.String) - * @param "ResourceId" (optional.String) - * @param "NIdNId" (optional.String) - * @param "NIdVal" (optional.String) - @return ExamplepbSimpleMessage */ type EchoServiceEchoUnauthorizedOpts struct { Id optional.String Num optional.String LineNum optional.String Lang optional.String StatusProgress optional.String StatusNote optional.String En optional.String NoProgress optional.String NoNote optional.String ResourceId optional.String NIdNId optional.String NIdVal optional.String } func (a *EchoServiceApiService) EchoServiceEchoUnauthorized(ctx context.Context, localVarOptionals *EchoServiceEchoUnauthorizedOpts) (ExamplepbSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbSimpleMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/echo_unauthorized" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.Id.IsSet() { localVarQueryParams.Add("id", parameterToString(localVarOptionals.Id.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Num.IsSet() { localVarQueryParams.Add("num", parameterToString(localVarOptionals.Num.Value(), "")) } if localVarOptionals != nil && localVarOptionals.LineNum.IsSet() { localVarQueryParams.Add("lineNum", parameterToString(localVarOptionals.LineNum.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Lang.IsSet() { localVarQueryParams.Add("lang", parameterToString(localVarOptionals.Lang.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusProgress.IsSet() { localVarQueryParams.Add("status.progress", parameterToString(localVarOptionals.StatusProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusNote.IsSet() { localVarQueryParams.Add("status.note", parameterToString(localVarOptionals.StatusNote.Value(), "")) } if localVarOptionals != nil && localVarOptionals.En.IsSet() { localVarQueryParams.Add("en", parameterToString(localVarOptionals.En.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoProgress.IsSet() { localVarQueryParams.Add("no.progress", parameterToString(localVarOptionals.NoProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoNote.IsSet() { localVarQueryParams.Add("no.note", parameterToString(localVarOptionals.NoNote.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ResourceId.IsSet() { localVarQueryParams.Add("resourceId", parameterToString(localVarOptionals.ResourceId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdNId.IsSet() { localVarQueryParams.Add("nId.nId", parameterToString(localVarOptionals.NIdNId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdVal.IsSet() { localVarQueryParams.Add("nId.val", parameterToString(localVarOptionals.NIdVal.Value(), "")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbSimpleMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } ================================================ FILE: examples/internal/clients/echo/client.go ================================================ /* * Echo Service * * Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo import ( "bytes" "context" "encoding/json" "encoding/xml" "errors" "fmt" "io" "mime/multipart" "net/http" "net/url" "os" "path/filepath" "reflect" "regexp" "strconv" "strings" "time" "unicode/utf8" "golang.org/x/oauth2" ) var ( jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") ) // APIClient manages communication with the Echo Service API vversion not set // In most cases there should be only one, shared, APIClient. type APIClient struct { cfg *Configuration common service // Reuse a single struct instead of allocating one for each service on the heap. // API Services EchoServiceApi *EchoServiceApiService } type service struct { client *APIClient } // NewAPIClient creates a new API client. Requires a userAgent string describing your application. // optionally a custom http.Client to allow for advanced features such as caching. func NewAPIClient(cfg *Configuration) *APIClient { if cfg.HTTPClient == nil { cfg.HTTPClient = http.DefaultClient } c := &APIClient{} c.cfg = cfg c.common.client = c // API Services c.EchoServiceApi = (*EchoServiceApiService)(&c.common) return c } func atoi(in string) (int, error) { return strconv.Atoi(in) } // selectHeaderContentType select a content type from the available list. func selectHeaderContentType(contentTypes []string) string { if len(contentTypes) == 0 { return "" } if contains(contentTypes, "application/json") { return "application/json" } return contentTypes[0] // use the first content type specified in 'consumes' } // selectHeaderAccept join all accept types and return func selectHeaderAccept(accepts []string) string { if len(accepts) == 0 { return "" } if contains(accepts, "application/json") { return "application/json" } return strings.Join(accepts, ",") } // contains is a case insenstive match, finding needle in a haystack func contains(haystack []string, needle string) bool { for _, a := range haystack { if strings.ToLower(a) == strings.ToLower(needle) { return true } } return false } // Verify optional parameters are of the correct type. func typeCheckParameter(obj interface{}, expected string, name string) error { // Make sure there is an object. if obj == nil { return nil } // Check the type is as expected. if reflect.TypeOf(obj).String() != expected { return fmt.Errorf("Expected %s to be of type %s but received %s.", name, expected, reflect.TypeOf(obj).String()) } return nil } // parameterToString convert interface{} parameters to string, using a delimiter if format is provided. func parameterToString(obj interface{}, collectionFormat string) string { var delimiter string switch collectionFormat { case "pipes": delimiter = "|" case "ssv": delimiter = " " case "tsv": delimiter = "\t" case "csv": delimiter = "," } if reflect.TypeOf(obj).Kind() == reflect.Slice { return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]") } return fmt.Sprintf("%v", obj) } // callAPI do the request. func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { return c.cfg.HTTPClient.Do(request) } // Change base path to allow switching to mocks func (c *APIClient) ChangeBasePath(path string) { c.cfg.BasePath = path } // prepareRequest build the request func (c *APIClient) prepareRequest( ctx context.Context, path string, method string, postBody interface{}, headerParams map[string]string, queryParams url.Values, formParams url.Values, fileName string, fileBytes []byte) (localVarRequest *http.Request, err error) { var body *bytes.Buffer // Detect postBody type and post. if postBody != nil { contentType := headerParams["Content-Type"] if contentType == "" { contentType = detectContentType(postBody) headerParams["Content-Type"] = contentType } body, err = setBody(postBody, contentType) if err != nil { return nil, err } } // add form parameters and file if available. if len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") { if body != nil { return nil, errors.New("Cannot specify postBody and multipart form at the same time.") } body = &bytes.Buffer{} w := multipart.NewWriter(body) for k, v := range formParams { for _, iv := range v { if strings.HasPrefix(k, "@") { // file err = addFile(w, k[1:], iv) if err != nil { return nil, err } } else { // form value w.WriteField(k, iv) } } } if len(fileBytes) > 0 && fileName != "" { w.Boundary() //_, fileNm := filepath.Split(fileName) part, err := w.CreateFormFile("file", filepath.Base(fileName)) if err != nil { return nil, err } _, err = part.Write(fileBytes) if err != nil { return nil, err } // Set the Boundary in the Content-Type headerParams["Content-Type"] = w.FormDataContentType() } // Set Content-Length headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) w.Close() } // Setup path and query parameters url, err := url.Parse(path) if err != nil { return nil, err } // Adding Query Param query := url.Query() for k, v := range queryParams { for _, iv := range v { query.Add(k, iv) } } // Encode the parameters. url.RawQuery = query.Encode() // Generate a new request if body != nil { localVarRequest, err = http.NewRequest(method, url.String(), body) } else { localVarRequest, err = http.NewRequest(method, url.String(), nil) } if err != nil { return nil, err } // add header parameters, if any if len(headerParams) > 0 { headers := http.Header{} for h, v := range headerParams { headers.Set(h, v) } localVarRequest.Header = headers } // Override request host, if applicable if c.cfg.Host != "" { localVarRequest.Host = c.cfg.Host } // Add the user agent to the request. localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) if ctx != nil { // add context to the request localVarRequest = localVarRequest.WithContext(ctx) // Walk through any authentication. // OAuth2 authentication if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok { // We were able to grab an oauth2 token from the context var latestToken *oauth2.Token if latestToken, err = tok.Token(); err != nil { return nil, err } latestToken.SetAuthHeader(localVarRequest) } // Basic HTTP Authentication if auth, ok := ctx.Value(ContextBasicAuth).(BasicAuth); ok { localVarRequest.SetBasicAuth(auth.UserName, auth.Password) } // AccessToken Authentication if auth, ok := ctx.Value(ContextAccessToken).(string); ok { localVarRequest.Header.Add("Authorization", "Bearer "+auth) } } for header, value := range c.cfg.DefaultHeader { localVarRequest.Header.Add(header, value) } return localVarRequest, nil } func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { if strings.Contains(contentType, "application/xml") { if err = xml.Unmarshal(b, v); err != nil { return err } return nil } else if strings.Contains(contentType, "application/json") { if err = json.Unmarshal(b, v); err != nil { return err } return nil } return errors.New("undefined response type") } // Add a file to the multipart request func addFile(w *multipart.Writer, fieldName, path string) error { file, err := os.Open(path) if err != nil { return err } defer file.Close() part, err := w.CreateFormFile(fieldName, filepath.Base(path)) if err != nil { return err } _, err = io.Copy(part, file) return err } // Prevent trying to import "fmt" func reportError(format string, a ...interface{}) error { return fmt.Errorf(format, a...) } // Set request body from an interface{} func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { if bodyBuf == nil { bodyBuf = &bytes.Buffer{} } if reader, ok := body.(io.Reader); ok { _, err = bodyBuf.ReadFrom(reader) } else if b, ok := body.([]byte); ok { _, err = bodyBuf.Write(b) } else if s, ok := body.(string); ok { _, err = bodyBuf.WriteString(s) } else if s, ok := body.(*string); ok { _, err = bodyBuf.WriteString(*s) } else if jsonCheck.MatchString(contentType) { err = json.NewEncoder(bodyBuf).Encode(body) } else if xmlCheck.MatchString(contentType) { xml.NewEncoder(bodyBuf).Encode(body) } if err != nil { return nil, err } if bodyBuf.Len() == 0 { err = fmt.Errorf("Invalid body type %s\n", contentType) return nil, err } return bodyBuf, nil } // detectContentType method is used to figure out `Request.Body` content type for request header func detectContentType(body interface{}) string { contentType := "text/plain; charset=utf-8" kind := reflect.TypeOf(body).Kind() switch kind { case reflect.Struct, reflect.Map, reflect.Ptr: contentType = "application/json; charset=utf-8" case reflect.String: contentType = "text/plain; charset=utf-8" default: if b, ok := body.([]byte); ok { contentType = http.DetectContentType(b) } else if kind == reflect.Slice { contentType = "application/json; charset=utf-8" } } return contentType } // Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go type cacheControl map[string]string func parseCacheControl(headers http.Header) cacheControl { cc := cacheControl{} ccHeader := headers.Get("Cache-Control") for _, part := range strings.Split(ccHeader, ",") { part = strings.Trim(part, " ") if part == "" { continue } if strings.ContainsRune(part, '=') { keyval := strings.Split(part, "=") cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") } else { cc[part] = "" } } return cc } // CacheExpires helper function to determine remaining time before repeating a request. func CacheExpires(r *http.Response) time.Time { // Figure out when the cache expires. var expires time.Time now, err := time.Parse(time.RFC1123, r.Header.Get("date")) if err != nil { return time.Now() } respCacheControl := parseCacheControl(r.Header) if maxAge, ok := respCacheControl["max-age"]; ok { lifetime, err := time.ParseDuration(maxAge + "s") if err != nil { expires = now } expires = now.Add(lifetime) } else { expiresHeader := r.Header.Get("Expires") if expiresHeader != "" { expires, err = time.Parse(time.RFC1123, expiresHeader) if err != nil { expires = now } } } return expires } func strlen(s string) int { return utf8.RuneCountInString(s) } // GenericSwaggerError Provides access to the body, error and model on returned errors. type GenericSwaggerError struct { body []byte error string model interface{} } // Error returns non-empty string if there was an error. func (e GenericSwaggerError) Error() string { return e.error } // Body returns the raw bytes of the response func (e GenericSwaggerError) Body() []byte { return e.body } // Model returns the unpacked model of the error func (e GenericSwaggerError) Model() interface{} { return e.model } ================================================ FILE: examples/internal/clients/echo/configuration.go ================================================ /* * Echo Service * * Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo import ( "net/http" ) // contextKeys are used to identify the type of value in the context. // Since these are string, it is possible to get a short description of the // context key for logging and debugging using key.String(). type contextKey string func (c contextKey) String() string { return "auth " + string(c) } var ( // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. ContextOAuth2 = contextKey("token") // ContextBasicAuth takes BasicAuth as authentication for the request. ContextBasicAuth = contextKey("basic") // ContextAccessToken takes a string oauth2 access token as authentication for the request. ContextAccessToken = contextKey("accesstoken") // ContextAPIKey takes an APIKey as authentication for the request ContextAPIKey = contextKey("apikey") ) // BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth type BasicAuth struct { UserName string `json:"userName,omitempty"` Password string `json:"password,omitempty"` } // APIKey provides API key based authentication to a request passed via context using ContextAPIKey type APIKey struct { Key string Prefix string } type Configuration struct { BasePath string `json:"basePath,omitempty"` Host string `json:"host,omitempty"` Scheme string `json:"scheme,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"` UserAgent string `json:"userAgent,omitempty"` HTTPClient *http.Client } func NewConfiguration() *Configuration { cfg := &Configuration{ BasePath: "https://localhost", DefaultHeader: make(map[string]string), UserAgent: "Swagger-Codegen/1.0.0/go", } return cfg } func (c *Configuration) AddDefaultHeader(key string, value string) { c.DefaultHeader[key] = value } ================================================ FILE: examples/internal/clients/echo/model_examplepb_dynamic_message.go ================================================ /* * Echo Service * * Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo // DynamicMessage represents a message which can have its structure built dynamically using Struct and Values. type ExamplepbDynamicMessage struct { StructField *interface{} `json:"structField,omitempty"` ValueField *interface{} `json:"valueField,omitempty"` } ================================================ FILE: examples/internal/clients/echo/model_examplepb_dynamic_message_update.go ================================================ /* * Echo Service * * Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo type ExamplepbDynamicMessageUpdate struct { Body *ExamplepbDynamicMessage `json:"body,omitempty"` UpdateMask string `json:"updateMask,omitempty"` } ================================================ FILE: examples/internal/clients/echo/model_examplepb_embedded.go ================================================ /* * Echo Service * * Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo // Embedded represents a message embedded in SimpleMessage. type ExamplepbEmbedded struct { Progress string `json:"progress,omitempty"` Note string `json:"note,omitempty"` } ================================================ FILE: examples/internal/clients/echo/model_examplepb_nested_message.go ================================================ /* * Echo Service * * Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo type ExamplepbNestedMessage struct { NId string `json:"nId,omitempty"` Val string `json:"val,omitempty"` } ================================================ FILE: examples/internal/clients/echo/model_examplepb_simple_message.go ================================================ /* * Echo Service * * Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo // SimpleMessage represents a simple message sent to the Echo service. type ExamplepbSimpleMessage struct { // Id represents the message identifier. Id string `json:"id,omitempty"` Num string `json:"num,omitempty"` LineNum string `json:"lineNum,omitempty"` Lang string `json:"lang,omitempty"` Status *ExamplepbEmbedded `json:"status,omitempty"` En string `json:"en,omitempty"` No *ExamplepbEmbedded `json:"no,omitempty"` ResourceId string `json:"resourceId,omitempty"` NId *ExamplepbNestedMessage `json:"nId,omitempty"` } ================================================ FILE: examples/internal/clients/echo/model_examplepb_status_check_request.go ================================================ /* * Echo Service * * Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo // StatusCheckRequest demonstrates name collision handling. It uses Status message from both sub and sub2 packages. type ExamplepbStatusCheckRequest struct { Id string `json:"id,omitempty"` SubStatus *ProtoSubStatus `json:"subStatus,omitempty"` Sub2Status *ProtoSub2Status `json:"sub2Status,omitempty"` } ================================================ FILE: examples/internal/clients/echo/model_examplepb_status_check_response.go ================================================ /* * Echo Service * * Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo type ExamplepbStatusCheckResponse struct { Result string `json:"result,omitempty"` SubStatus *ProtoSubStatus `json:"subStatus,omitempty"` Sub2Status *ProtoSub2Status `json:"sub2Status,omitempty"` } ================================================ FILE: examples/internal/clients/echo/model_google_rpc_status.go ================================================ /* * Echo Service * * Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo // The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). type GoogleRpcStatus struct { // The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. Code int32 `json:"code,omitempty"` // A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. Message string `json:"message,omitempty"` // A list of messages that carry the error details. There is a common set of message types for APIs to use. Details []ProtobufAny `json:"details,omitempty"` } ================================================ FILE: examples/internal/clients/echo/model_proto_sub2_status.go ================================================ /* * Echo Service * * Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo type ProtoSub2Status struct { ErrorCode string `json:"errorCode,omitempty"` ErrorMessage string `json:"errorMessage,omitempty"` Severity int32 `json:"severity,omitempty"` } ================================================ FILE: examples/internal/clients/echo/model_proto_sub_status.go ================================================ /* * Echo Service * * Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo type ProtoSubStatus struct { Code int32 `json:"code,omitempty"` Message string `json:"message,omitempty"` } ================================================ FILE: examples/internal/clients/echo/model_protobuf_any.go ================================================ /* * Echo Service * * Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo // `Any` contains an arbitrary serialized protocol buffer message along with a URL that describes the type of the serialized message. Protobuf library provides support to pack/unpack Any values in the form of utility functions or additional generated methods of the Any type. Example 1: Pack and unpack a message in C++. Foo foo = ...; Any any; any.PackFrom(foo); ... if (any.UnpackTo(&foo)) { ... } Example 2: Pack and unpack a message in Java. Foo foo = ...; Any any = Any.pack(foo); ... if (any.is(Foo.class)) { foo = any.unpack(Foo.class); } // or ... if (any.isSameTypeAs(Foo.getDefaultInstance())) { foo = any.unpack(Foo.getDefaultInstance()); } Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() any.Pack(foo) ... if any.Is(Foo.DESCRIPTOR): any.Unpack(foo) ... Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) if err != nil { ... } ... foo := &pb.Foo{} if err := any.UnmarshalTo(foo); err != nil { ... } The pack methods provided by protobuf library will by default use 'type.googleapis.com/full.type.name' as the type URL and the unpack methods only use the fully qualified type name after the last '/' in the type URL, for example \"foo.bar.com/x/y.z\" will yield type name \"y.z\". JSON ==== The JSON representation of an `Any` value uses the regular representation of the deserialized, embedded message, with an additional field `@type` which contains the type URL. Example: package google.profile; message Person { string first_name = 1; string last_name = 2; } { \"@type\": \"type.googleapis.com/google.profile.Person\", \"firstName\": , \"lastName\": } If the embedded message type is well-known and has a custom JSON representation, that representation will be embedded adding a field `value` which holds the custom JSON in addition to the `@type` field. Example (for message [google.protobuf.Duration][]): { \"@type\": \"type.googleapis.com/google.protobuf.Duration\", \"value\": \"1.212s\" } type ProtobufAny struct { // A URL/resource name that uniquely identifies the type of the serialized protocol buffer message. This string must contain at least one \"/\" character. The last segment of the URL's path must represent the fully qualified name of the type (as in `path/google.protobuf.Duration`). The name should be in a canonical form (e.g., leading \".\" is not accepted). In practice, teams usually precompile into the binary all types that they expect it to use in the context of Any. However, for URLs which use the scheme `http`, `https`, or no scheme, one can optionally set up a type server that maps type URLs to message definitions as follows: * If no scheme is provided, `https` is assumed. * An HTTP GET on the URL must yield a [google.protobuf.Type][] value in binary format, or produce an error. * Applications are allowed to cache lookup results based on the URL, or have them precompiled into a binary to avoid any lookup. Therefore, binary compatibility needs to be preserved on changes to types. (Use versioned type names to manage breaking changes.) Note: this functionality is not currently available in the official protobuf release, and it is not used for type URLs beginning with type.googleapis.com. As of May 2023, there are no widely used type server implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) might be used with implementation specific semantics. Type_ string `json:"@type,omitempty"` } ================================================ FILE: examples/internal/clients/echo/model_protobuf_null_value.go ================================================ /* * Echo Service * * Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo // ProtobufNullValue : `NullValue` is a singleton enumeration to represent the null value for the `Value` type union. The JSON representation for `NullValue` is JSON `null`. - NULL_VALUE: Null value. type ProtobufNullValue string // List of protobufNullValue const ( NULL_VALUE_ProtobufNullValue ProtobufNullValue = "NULL_VALUE" ) ================================================ FILE: examples/internal/clients/echo/response.go ================================================ /* * Echo Service * * Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package echo import ( "net/http" ) type APIResponse struct { *http.Response `json:"-"` Message string `json:"message,omitempty"` // Operation is the name of the swagger operation. Operation string `json:"operation,omitempty"` // RequestURL is the request URL. This value is always available, even if the // embedded *http.Response is nil. RequestURL string `json:"url,omitempty"` // Method is the HTTP method used for the request. This value is always // available, even if the embedded *http.Response is nil. Method string `json:"method,omitempty"` // Payload holds the contents of the response body (which may be nil or empty). // This is provided here as the raw response.Body() reader will have already // been drained. Payload []byte `json:"-"` } func NewAPIResponse(r *http.Response) *APIResponse { response := &APIResponse{Response: r} return response } func NewAPIResponseWithError(errorMessage string) *APIResponse { response := &APIResponse{Message: errorMessage} return response } ================================================ FILE: examples/internal/clients/generateunboundmethods/.gitignore ================================================ /docs ================================================ FILE: examples/internal/clients/generateunboundmethods/.swagger-codegen/VERSION ================================================ 2.4.8 ================================================ FILE: examples/internal/clients/generateunboundmethods/.swagger-codegen-ignore ================================================ .gitignore ================================================ FILE: examples/internal/clients/generateunboundmethods/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "generateunboundmethods", srcs = [ "api_generate_unbound_methods_echo_service.go", "client.go", "configuration.go", "model_examplepb_generate_unbound_methods_simple_message.go", "model_protobuf_any.go", "model_rpc_status.go", "model_runtime_error.go", "response.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/clients/generateunboundmethods", visibility = ["//examples:__subpackages__"], deps = ["@org_golang_x_oauth2//:oauth2"], ) alias( name = "go_default_library", actual = ":generateunboundmethods", visibility = ["//examples:__subpackages__"], ) ================================================ FILE: examples/internal/clients/generateunboundmethods/api/swagger.yaml ================================================ --- swagger: "2.0" info: description: "Generate Unannotated Methods Echo Service\nSimilar to echo_service.proto\ \ but without annotations and without external configuration.\n\nGenerate Unannotated\ \ Methods Echo Service API consists of a single service which returns\na message." version: "version not set" title: "examples/internal/proto/examplepb/generate_unbound_methods.proto" tags: - name: "GenerateUnboundMethodsEchoService" consumes: - "application/json" produces: - "application/json" paths: /grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/Echo: post: tags: - "GenerateUnboundMethodsEchoService" summary: "Echo method receives a simple message and returns it." description: "The message posted as the id parameter will also be\nreturned." operationId: "GenerateUnboundMethodsEchoService_Echo" parameters: - in: "body" name: "body" description: "GenerateUnboundMethodsSimpleMessage represents a simple message\ \ sent to the unannotated GenerateUnboundMethodsEchoService service." required: true schema: $ref: "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage" x-exportParamName: "Body" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage" default: description: "An unexpected error response." schema: $ref: "#/definitions/rpcStatus" /grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoBody: post: tags: - "GenerateUnboundMethodsEchoService" summary: "EchoBody method receives a simple message and returns it." operationId: "GenerateUnboundMethodsEchoService_EchoBody" parameters: - in: "body" name: "body" description: "GenerateUnboundMethodsSimpleMessage represents a simple message\ \ sent to the unannotated GenerateUnboundMethodsEchoService service." required: true schema: $ref: "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage" x-exportParamName: "Body" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage" default: description: "An unexpected error response." schema: $ref: "#/definitions/rpcStatus" /grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoDelete: post: tags: - "GenerateUnboundMethodsEchoService" summary: "EchoDelete method receives a simple message and returns it." operationId: "GenerateUnboundMethodsEchoService_EchoDelete" parameters: - in: "body" name: "body" description: "GenerateUnboundMethodsSimpleMessage represents a simple message\ \ sent to the unannotated GenerateUnboundMethodsEchoService service." required: true schema: $ref: "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage" x-exportParamName: "Body" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage" default: description: "An unexpected error response." schema: $ref: "#/definitions/rpcStatus" definitions: examplepbGenerateUnboundMethodsSimpleMessage: type: "object" properties: id: type: "string" description: "Id represents the message identifier." num: type: "string" format: "int64" duration: type: "string" description: "GenerateUnboundMethodsSimpleMessage represents a simple message\ \ sent to the unannotated GenerateUnboundMethodsEchoService service." example: duration: "duration" num: "num" id: "id" protobufAny: type: "object" properties: '@type': type: "string" additionalProperties: {} rpcStatus: type: "object" properties: code: type: "integer" format: "int32" message: type: "string" details: type: "array" items: $ref: "#/definitions/protobufAny" ================================================ FILE: examples/internal/clients/generateunboundmethods/api_generate_unbound_methods_echo_service.go ================================================ /* * examples/internal/proto/examplepb/generate_unbound_methods.proto * * Generate Unannotated Methods Echo Service Similar to echo_service.proto but without annotations and without external configuration. Generate Unannotated Methods Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package generateunboundmethods import ( "context" "io/ioutil" "net/http" "net/url" "strings" ) // Linger please var ( _ context.Context ) type GenerateUnboundMethodsEchoServiceApiService service /* GenerateUnboundMethodsEchoServiceApiService Echo method receives a simple message and returns it. The message posted as the id parameter will also be returned. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param body GenerateUnboundMethodsSimpleMessage represents a simple message sent to the unannotated GenerateUnboundMethodsEchoService service. @return ExamplepbGenerateUnboundMethodsSimpleMessage */ func (a *GenerateUnboundMethodsEchoServiceApiService) GenerateUnboundMethodsEchoServiceEcho(ctx context.Context, body ExamplepbGenerateUnboundMethodsSimpleMessage) (ExamplepbGenerateUnboundMethodsSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbGenerateUnboundMethodsSimpleMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/Echo" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbGenerateUnboundMethodsSimpleMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v RpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* GenerateUnboundMethodsEchoServiceApiService EchoBody method receives a simple message and returns it. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param body GenerateUnboundMethodsSimpleMessage represents a simple message sent to the unannotated GenerateUnboundMethodsEchoService service. @return ExamplepbGenerateUnboundMethodsSimpleMessage */ func (a *GenerateUnboundMethodsEchoServiceApiService) GenerateUnboundMethodsEchoServiceEchoBody(ctx context.Context, body ExamplepbGenerateUnboundMethodsSimpleMessage) (ExamplepbGenerateUnboundMethodsSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbGenerateUnboundMethodsSimpleMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoBody" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbGenerateUnboundMethodsSimpleMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v RpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* GenerateUnboundMethodsEchoServiceApiService EchoDelete method receives a simple message and returns it. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param body GenerateUnboundMethodsSimpleMessage represents a simple message sent to the unannotated GenerateUnboundMethodsEchoService service. @return ExamplepbGenerateUnboundMethodsSimpleMessage */ func (a *GenerateUnboundMethodsEchoServiceApiService) GenerateUnboundMethodsEchoServiceEchoDelete(ctx context.Context, body ExamplepbGenerateUnboundMethodsSimpleMessage) (ExamplepbGenerateUnboundMethodsSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbGenerateUnboundMethodsSimpleMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoDelete" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbGenerateUnboundMethodsSimpleMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v RpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } ================================================ FILE: examples/internal/clients/generateunboundmethods/client.go ================================================ /* * examples/internal/proto/examplepb/generate_unbound_methods.proto * * Generate Unannotated Methods Echo Service Similar to echo_service.proto but without annotations and without external configuration. Generate Unannotated Methods Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package generateunboundmethods import ( "bytes" "context" "encoding/json" "encoding/xml" "errors" "fmt" "io" "mime/multipart" "net/http" "net/url" "os" "path/filepath" "reflect" "regexp" "strconv" "strings" "time" "unicode/utf8" "golang.org/x/oauth2" ) var ( jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") ) // APIClient manages communication with the examples/internal/proto/examplepb/generate_unbound_methods.proto API vversion not set // In most cases there should be only one, shared, APIClient. type APIClient struct { cfg *Configuration common service // Reuse a single struct instead of allocating one for each service on the heap. // API Services GenerateUnboundMethodsEchoServiceApi *GenerateUnboundMethodsEchoServiceApiService } type service struct { client *APIClient } // NewAPIClient creates a new API client. Requires a userAgent string describing your application. // optionally a custom http.Client to allow for advanced features such as caching. func NewAPIClient(cfg *Configuration) *APIClient { if cfg.HTTPClient == nil { cfg.HTTPClient = http.DefaultClient } c := &APIClient{} c.cfg = cfg c.common.client = c // API Services c.GenerateUnboundMethodsEchoServiceApi = (*GenerateUnboundMethodsEchoServiceApiService)(&c.common) return c } func atoi(in string) (int, error) { return strconv.Atoi(in) } // selectHeaderContentType select a content type from the available list. func selectHeaderContentType(contentTypes []string) string { if len(contentTypes) == 0 { return "" } if contains(contentTypes, "application/json") { return "application/json" } return contentTypes[0] // use the first content type specified in 'consumes' } // selectHeaderAccept join all accept types and return func selectHeaderAccept(accepts []string) string { if len(accepts) == 0 { return "" } if contains(accepts, "application/json") { return "application/json" } return strings.Join(accepts, ",") } // contains is a case insenstive match, finding needle in a haystack func contains(haystack []string, needle string) bool { for _, a := range haystack { if strings.ToLower(a) == strings.ToLower(needle) { return true } } return false } // Verify optional parameters are of the correct type. func typeCheckParameter(obj interface{}, expected string, name string) error { // Make sure there is an object. if obj == nil { return nil } // Check the type is as expected. if reflect.TypeOf(obj).String() != expected { return fmt.Errorf("Expected %s to be of type %s but received %s.", name, expected, reflect.TypeOf(obj).String()) } return nil } // parameterToString convert interface{} parameters to string, using a delimiter if format is provided. func parameterToString(obj interface{}, collectionFormat string) string { var delimiter string switch collectionFormat { case "pipes": delimiter = "|" case "ssv": delimiter = " " case "tsv": delimiter = "\t" case "csv": delimiter = "," } if reflect.TypeOf(obj).Kind() == reflect.Slice { return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]") } return fmt.Sprintf("%v", obj) } // callAPI do the request. func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { return c.cfg.HTTPClient.Do(request) } // Change base path to allow switching to mocks func (c *APIClient) ChangeBasePath(path string) { c.cfg.BasePath = path } // prepareRequest build the request func (c *APIClient) prepareRequest( ctx context.Context, path string, method string, postBody interface{}, headerParams map[string]string, queryParams url.Values, formParams url.Values, fileName string, fileBytes []byte) (localVarRequest *http.Request, err error) { var body *bytes.Buffer // Detect postBody type and post. if postBody != nil { contentType := headerParams["Content-Type"] if contentType == "" { contentType = detectContentType(postBody) headerParams["Content-Type"] = contentType } body, err = setBody(postBody, contentType) if err != nil { return nil, err } } // add form parameters and file if available. if len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") { if body != nil { return nil, errors.New("Cannot specify postBody and multipart form at the same time.") } body = &bytes.Buffer{} w := multipart.NewWriter(body) for k, v := range formParams { for _, iv := range v { if strings.HasPrefix(k, "@") { // file err = addFile(w, k[1:], iv) if err != nil { return nil, err } } else { // form value w.WriteField(k, iv) } } } if len(fileBytes) > 0 && fileName != "" { w.Boundary() //_, fileNm := filepath.Split(fileName) part, err := w.CreateFormFile("file", filepath.Base(fileName)) if err != nil { return nil, err } _, err = part.Write(fileBytes) if err != nil { return nil, err } // Set the Boundary in the Content-Type headerParams["Content-Type"] = w.FormDataContentType() } // Set Content-Length headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) w.Close() } // Setup path and query parameters url, err := url.Parse(path) if err != nil { return nil, err } // Adding Query Param query := url.Query() for k, v := range queryParams { for _, iv := range v { query.Add(k, iv) } } // Encode the parameters. url.RawQuery = query.Encode() // Generate a new request if body != nil { localVarRequest, err = http.NewRequest(method, url.String(), body) } else { localVarRequest, err = http.NewRequest(method, url.String(), nil) } if err != nil { return nil, err } // add header parameters, if any if len(headerParams) > 0 { headers := http.Header{} for h, v := range headerParams { headers.Set(h, v) } localVarRequest.Header = headers } // Override request host, if applicable if c.cfg.Host != "" { localVarRequest.Host = c.cfg.Host } // Add the user agent to the request. localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) if ctx != nil { // add context to the request localVarRequest = localVarRequest.WithContext(ctx) // Walk through any authentication. // OAuth2 authentication if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok { // We were able to grab an oauth2 token from the context var latestToken *oauth2.Token if latestToken, err = tok.Token(); err != nil { return nil, err } latestToken.SetAuthHeader(localVarRequest) } // Basic HTTP Authentication if auth, ok := ctx.Value(ContextBasicAuth).(BasicAuth); ok { localVarRequest.SetBasicAuth(auth.UserName, auth.Password) } // AccessToken Authentication if auth, ok := ctx.Value(ContextAccessToken).(string); ok { localVarRequest.Header.Add("Authorization", "Bearer "+auth) } } for header, value := range c.cfg.DefaultHeader { localVarRequest.Header.Add(header, value) } return localVarRequest, nil } func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { if strings.Contains(contentType, "application/xml") { if err = xml.Unmarshal(b, v); err != nil { return err } return nil } else if strings.Contains(contentType, "application/json") { if err = json.Unmarshal(b, v); err != nil { return err } return nil } return errors.New("undefined response type") } // Add a file to the multipart request func addFile(w *multipart.Writer, fieldName, path string) error { file, err := os.Open(path) if err != nil { return err } defer file.Close() part, err := w.CreateFormFile(fieldName, filepath.Base(path)) if err != nil { return err } _, err = io.Copy(part, file) return err } // Prevent trying to import "fmt" func reportError(format string, a ...interface{}) error { return fmt.Errorf(format, a...) } // Set request body from an interface{} func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { if bodyBuf == nil { bodyBuf = &bytes.Buffer{} } if reader, ok := body.(io.Reader); ok { _, err = bodyBuf.ReadFrom(reader) } else if b, ok := body.([]byte); ok { _, err = bodyBuf.Write(b) } else if s, ok := body.(string); ok { _, err = bodyBuf.WriteString(s) } else if s, ok := body.(*string); ok { _, err = bodyBuf.WriteString(*s) } else if jsonCheck.MatchString(contentType) { err = json.NewEncoder(bodyBuf).Encode(body) } else if xmlCheck.MatchString(contentType) { xml.NewEncoder(bodyBuf).Encode(body) } if err != nil { return nil, err } if bodyBuf.Len() == 0 { err = fmt.Errorf("Invalid body type %s\n", contentType) return nil, err } return bodyBuf, nil } // detectContentType method is used to figure out `Request.Body` content type for request header func detectContentType(body interface{}) string { contentType := "text/plain; charset=utf-8" kind := reflect.TypeOf(body).Kind() switch kind { case reflect.Struct, reflect.Map, reflect.Ptr: contentType = "application/json; charset=utf-8" case reflect.String: contentType = "text/plain; charset=utf-8" default: if b, ok := body.([]byte); ok { contentType = http.DetectContentType(b) } else if kind == reflect.Slice { contentType = "application/json; charset=utf-8" } } return contentType } // Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go type cacheControl map[string]string func parseCacheControl(headers http.Header) cacheControl { cc := cacheControl{} ccHeader := headers.Get("Cache-Control") for _, part := range strings.Split(ccHeader, ",") { part = strings.Trim(part, " ") if part == "" { continue } if strings.ContainsRune(part, '=') { keyval := strings.Split(part, "=") cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") } else { cc[part] = "" } } return cc } // CacheExpires helper function to determine remaining time before repeating a request. func CacheExpires(r *http.Response) time.Time { // Figure out when the cache expires. var expires time.Time now, err := time.Parse(time.RFC1123, r.Header.Get("date")) if err != nil { return time.Now() } respCacheControl := parseCacheControl(r.Header) if maxAge, ok := respCacheControl["max-age"]; ok { lifetime, err := time.ParseDuration(maxAge + "s") if err != nil { expires = now } expires = now.Add(lifetime) } else { expiresHeader := r.Header.Get("Expires") if expiresHeader != "" { expires, err = time.Parse(time.RFC1123, expiresHeader) if err != nil { expires = now } } } return expires } func strlen(s string) int { return utf8.RuneCountInString(s) } // GenericSwaggerError Provides access to the body, error and model on returned errors. type GenericSwaggerError struct { body []byte error string model interface{} } // Error returns non-empty string if there was an error. func (e GenericSwaggerError) Error() string { return e.error } // Body returns the raw bytes of the response func (e GenericSwaggerError) Body() []byte { return e.body } // Model returns the unpacked model of the error func (e GenericSwaggerError) Model() interface{} { return e.model } ================================================ FILE: examples/internal/clients/generateunboundmethods/configuration.go ================================================ /* * examples/internal/proto/examplepb/generate_unbound_methods.proto * * Generate Unannotated Methods Echo Service Similar to echo_service.proto but without annotations and without external configuration. Generate Unannotated Methods Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package generateunboundmethods import ( "net/http" ) // contextKeys are used to identify the type of value in the context. // Since these are string, it is possible to get a short description of the // context key for logging and debugging using key.String(). type contextKey string func (c contextKey) String() string { return "auth " + string(c) } var ( // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. ContextOAuth2 = contextKey("token") // ContextBasicAuth takes BasicAuth as authentication for the request. ContextBasicAuth = contextKey("basic") // ContextAccessToken takes a string oauth2 access token as authentication for the request. ContextAccessToken = contextKey("accesstoken") // ContextAPIKey takes an APIKey as authentication for the request ContextAPIKey = contextKey("apikey") ) // BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth type BasicAuth struct { UserName string `json:"userName,omitempty"` Password string `json:"password,omitempty"` } // APIKey provides API key based authentication to a request passed via context using ContextAPIKey type APIKey struct { Key string Prefix string } type Configuration struct { BasePath string `json:"basePath,omitempty"` Host string `json:"host,omitempty"` Scheme string `json:"scheme,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"` UserAgent string `json:"userAgent,omitempty"` HTTPClient *http.Client } func NewConfiguration() *Configuration { cfg := &Configuration{ BasePath: "https://localhost", DefaultHeader: make(map[string]string), UserAgent: "Swagger-Codegen/1.0.0/go", } return cfg } func (c *Configuration) AddDefaultHeader(key string, value string) { c.DefaultHeader[key] = value } ================================================ FILE: examples/internal/clients/generateunboundmethods/docs/ExamplepbGenerateUnboundMethodsSimpleMessage.md ================================================ # ExamplepbGenerateUnboundMethodsSimpleMessage ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Id** | **string** | Id represents the message identifier. | [optional] [default to null] **Num** | **string** | | [optional] [default to null] **Duration** | **string** | | [optional] [default to null] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ================================================ FILE: examples/internal/clients/generateunboundmethods/docs/GenerateUnboundMethodsEchoServiceApi.md ================================================ # \GenerateUnboundMethodsEchoServiceApi All URIs are relative to *https://localhost* Method | HTTP request | Description ------------- | ------------- | ------------- [**GenerateUnboundMethodsEchoServiceEcho**](GenerateUnboundMethodsEchoServiceApi.md#GenerateUnboundMethodsEchoServiceEcho) | **Post** /grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/Echo | Echo method receives a simple message and returns it. [**GenerateUnboundMethodsEchoServiceEchoBody**](GenerateUnboundMethodsEchoServiceApi.md#GenerateUnboundMethodsEchoServiceEchoBody) | **Post** /grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoBody | EchoBody method receives a simple message and returns it. [**GenerateUnboundMethodsEchoServiceEchoDelete**](GenerateUnboundMethodsEchoServiceApi.md#GenerateUnboundMethodsEchoServiceEchoDelete) | **Post** /grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoDelete | EchoDelete method receives a simple message and returns it. # **GenerateUnboundMethodsEchoServiceEcho** > ExamplepbGenerateUnboundMethodsSimpleMessage GenerateUnboundMethodsEchoServiceEcho(ctx, body) Echo method receives a simple message and returns it. The message posted as the id parameter will also be returned. ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **body** | [**ExamplepbGenerateUnboundMethodsSimpleMessage**](ExamplepbGenerateUnboundMethodsSimpleMessage.md)| GenerateUnboundMethodsSimpleMessage represents a simple message sent to the unannotated GenerateUnboundMethodsEchoService service. | ### Return type [**ExamplepbGenerateUnboundMethodsSimpleMessage**](examplepbGenerateUnboundMethodsSimpleMessage.md) ### Authorization No authorization required ### HTTP request headers - **Content-Type**: application/json - **Accept**: application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **GenerateUnboundMethodsEchoServiceEchoBody** > ExamplepbGenerateUnboundMethodsSimpleMessage GenerateUnboundMethodsEchoServiceEchoBody(ctx, body) EchoBody method receives a simple message and returns it. ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **body** | [**ExamplepbGenerateUnboundMethodsSimpleMessage**](ExamplepbGenerateUnboundMethodsSimpleMessage.md)| GenerateUnboundMethodsSimpleMessage represents a simple message sent to the unannotated GenerateUnboundMethodsEchoService service. | ### Return type [**ExamplepbGenerateUnboundMethodsSimpleMessage**](examplepbGenerateUnboundMethodsSimpleMessage.md) ### Authorization No authorization required ### HTTP request headers - **Content-Type**: application/json - **Accept**: application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **GenerateUnboundMethodsEchoServiceEchoDelete** > ExamplepbGenerateUnboundMethodsSimpleMessage GenerateUnboundMethodsEchoServiceEchoDelete(ctx, body) EchoDelete method receives a simple message and returns it. ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **body** | [**ExamplepbGenerateUnboundMethodsSimpleMessage**](ExamplepbGenerateUnboundMethodsSimpleMessage.md)| GenerateUnboundMethodsSimpleMessage represents a simple message sent to the unannotated GenerateUnboundMethodsEchoService service. | ### Return type [**ExamplepbGenerateUnboundMethodsSimpleMessage**](examplepbGenerateUnboundMethodsSimpleMessage.md) ### Authorization No authorization required ### HTTP request headers - **Content-Type**: application/json - **Accept**: application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) ================================================ FILE: examples/internal/clients/generateunboundmethods/docs/ProtobufAny.md ================================================ # ProtobufAny ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Type_** | **string** | | [optional] [default to null] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ================================================ FILE: examples/internal/clients/generateunboundmethods/docs/RuntimeError.md ================================================ # RuntimeError ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Error_** | **string** | | [optional] [default to null] **Code** | **int32** | | [optional] [default to null] **Message** | **string** | | [optional] [default to null] **Details** | [**[]ProtobufAny**](protobufAny.md) | | [optional] [default to null] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ================================================ FILE: examples/internal/clients/generateunboundmethods/model_examplepb_generate_unbound_methods_simple_message.go ================================================ /* * examples/internal/proto/examplepb/generate_unbound_methods.proto * * Generate Unannotated Methods Echo Service Similar to echo_service.proto but without annotations and without external configuration. Generate Unannotated Methods Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package generateunboundmethods // GenerateUnboundMethodsSimpleMessage represents a simple message sent to the unannotated GenerateUnboundMethodsEchoService service. type ExamplepbGenerateUnboundMethodsSimpleMessage struct { // Id represents the message identifier. Id string `json:"id,omitempty"` Num string `json:"num,omitempty"` Duration string `json:"duration,omitempty"` } ================================================ FILE: examples/internal/clients/generateunboundmethods/model_protobuf_any.go ================================================ /* * examples/internal/proto/examplepb/generate_unbound_methods.proto * * Generate Unannotated Methods Echo Service Similar to echo_service.proto but without annotations and without external configuration. Generate Unannotated Methods Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package generateunboundmethods type ProtobufAny struct { Type_ string `json:"@type,omitempty"` } ================================================ FILE: examples/internal/clients/generateunboundmethods/model_rpc_status.go ================================================ /* * examples/internal/proto/examplepb/generate_unbound_methods.proto * * Generate Unannotated Methods Echo Service Similar to echo_service.proto but without annotations and without external configuration. Generate Unannotated Methods Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package generateunboundmethods type RpcStatus struct { Code int32 `json:"code,omitempty"` Message string `json:"message,omitempty"` Details []ProtobufAny `json:"details,omitempty"` } ================================================ FILE: examples/internal/clients/generateunboundmethods/model_runtime_error.go ================================================ /* * examples/internal/proto/examplepb/generate_unbound_methods.proto * * Generate Unannotated Methods Echo Service Similar to echo_service.proto but without annotations and without external configuration. Generate Unannotated Methods Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package generateunboundmethods type RuntimeError struct { Error_ string `json:"error,omitempty"` Code int32 `json:"code,omitempty"` Message string `json:"message,omitempty"` Details []ProtobufAny `json:"details,omitempty"` } ================================================ FILE: examples/internal/clients/generateunboundmethods/response.go ================================================ /* * examples/internal/proto/examplepb/generate_unbound_methods.proto * * Generate Unannotated Methods Echo Service Similar to echo_service.proto but without annotations and without external configuration. Generate Unannotated Methods Echo Service API consists of a single service which returns a message. * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package generateunboundmethods import ( "net/http" ) type APIResponse struct { *http.Response `json:"-"` Message string `json:"message,omitempty"` // Operation is the name of the swagger operation. Operation string `json:"operation,omitempty"` // RequestURL is the request URL. This value is always available, even if the // embedded *http.Response is nil. RequestURL string `json:"url,omitempty"` // Method is the HTTP method used for the request. This value is always // available, even if the embedded *http.Response is nil. Method string `json:"method,omitempty"` // Payload holds the contents of the response body (which may be nil or empty). // This is provided here as the raw response.Body() reader will have already // been drained. Payload []byte `json:"-"` } func NewAPIResponse(r *http.Response) *APIResponse { response := &APIResponse{Response: r} return response } func NewAPIResponseWithError(errorMessage string) *APIResponse { response := &APIResponse{Message: errorMessage} return response } ================================================ FILE: examples/internal/clients/responsebody/.gitignore ================================================ # Compiled Object files, Static and Dynamic libs (Shared Objects) *.o *.a *.so # Folders _obj _test # Architecture specific extensions/prefixes *.[568vq] [568vq].out *.cgo1.go *.cgo2.c _cgo_defun.c _cgo_gotypes.go _cgo_export.* _testmain.go *.exe *.test *.prof ================================================ FILE: examples/internal/clients/responsebody/.swagger-codegen/VERSION ================================================ 2.4.8 ================================================ FILE: examples/internal/clients/responsebody/.swagger-codegen-ignore ================================================ # Swagger Codegen Ignore # Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen # Use this file to prevent files from being overwritten by the generator. # The patterns follow closely to .gitignore or .dockerignore. # As an example, the C# client generator defines ApiClient.cs. # You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: #ApiClient.cs # You can match any string of characters against a directory, file or extension with a single asterisk (*): #foo/*/qux # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux # You can recursively match patterns against a directory, file or extension with a double asterisk (**): #foo/**/qux # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux # You can also negate patterns with an exclamation (!). # For example, you can ignore all files in a docs folder with the file extension .md: #docs/*.md # Then explicitly reverse the ignore rule for a single file: #!docs/README.md ================================================ FILE: examples/internal/clients/responsebody/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "responsebody", srcs = [ "api_response_body_service.go", "client.go", "configuration.go", "model_examplepb_repeated_response_body_out.go", "model_examplepb_repeated_response_body_out_response.go", "model_examplepb_repeated_response_strings.go", "model_examplepb_response_body_out.go", "model_examplepb_response_body_out_response.go", "model_examplepb_response_body_value.go", "model_google_rpc_status.go", "model_protobuf_any.go", "model_response_response_type.go", "model_stream_result_of_examplepb_response_body_out.go", "response.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/clients/responsebody", visibility = ["//visibility:public"], deps = ["@org_golang_x_oauth2//:oauth2"], ) alias( name = "go_default_library", actual = ":responsebody", visibility = ["//examples:__subpackages__"], ) ================================================ FILE: examples/internal/clients/responsebody/api/swagger.yaml ================================================ --- swagger: "2.0" info: version: "version not set" title: "examples/internal/proto/examplepb/response_body_service.proto" tags: - name: "ResponseBodyService" consumes: - "application/json" produces: - "application/json" paths: /responsebodies/{data}: get: tags: - "ResponseBodyService" operationId: "ResponseBodyService_ListResponseBodies" parameters: - name: "data" in: "path" required: true type: "string" x-exportParamName: "Data" responses: 200: description: "" schema: type: "array" items: $ref: "#/definitions/examplepbRepeatedResponseBodyOutResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /responsebody/samename/{data}: get: tags: - "ResponseBodyService" operationId: "ResponseBodyService_GetResponseBodySameName" parameters: - name: "data" in: "path" required: true type: "string" x-exportParamName: "Data" responses: 200: description: "" schema: type: "string" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /responsebody/stream/{data}: get: tags: - "ResponseBodyService" operationId: "ResponseBodyService_GetResponseBodyStream" parameters: - name: "data" in: "path" required: true type: "string" x-exportParamName: "Data" responses: 200: description: "(streaming responses)" schema: type: "object" properties: result: $ref: "#/definitions/examplepbResponseBodyOutResponse" error: $ref: "#/definitions/googleRpcStatus" title: "Stream result of examplepbResponseBodyOut" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /responsebody/{data}: get: tags: - "ResponseBodyService" operationId: "ResponseBodyService_GetResponseBody" parameters: - name: "data" in: "path" required: true type: "string" x-exportParamName: "Data" responses: 200: description: "" schema: $ref: "#/definitions/examplepbResponseBodyOutResponse" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" /responsestrings/{data}: get: tags: - "ResponseBodyService" operationId: "ResponseBodyService_ListResponseStrings" parameters: - name: "data" in: "path" required: true type: "string" x-exportParamName: "Data" responses: 200: description: "" schema: type: "array" items: type: "string" default: description: "An unexpected error response." schema: $ref: "#/definitions/googleRpcStatus" definitions: ResponseResponseType: type: "string" title: "- UNKNOWN: UNKNOWN\n - A: A is 1\n - B: B is 2" enum: - "UNKNOWN" - "A" - "B" default: "UNKNOWN" examplepbRepeatedResponseBodyOut: type: "object" properties: response: type: "array" items: $ref: "#/definitions/examplepbRepeatedResponseBodyOutResponse" examplepbRepeatedResponseBodyOutResponse: type: "object" properties: data: type: "string" type: $ref: "#/definitions/ResponseResponseType" example: data: "data" type: {} examplepbRepeatedResponseStrings: type: "object" properties: values: type: "array" items: type: "string" examplepbResponseBodyOut: type: "object" properties: response: $ref: "#/definitions/examplepbResponseBodyOutResponse" examplepbResponseBodyOutResponse: type: "object" properties: data: type: "string" example: data: "data" examplepbResponseBodyValue: type: "object" properties: responseBodyValue: type: "string" googleRpcStatus: type: "object" properties: code: type: "integer" format: "int32" description: "The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]." message: type: "string" description: "A developer-facing error message, which should be in English.\ \ Any\nuser-facing error message should be localized and sent in the\n[google.rpc.Status.details][google.rpc.Status.details]\ \ field, or localized by the client." details: type: "array" description: "A list of messages that carry the error details. There is a\ \ common set of\nmessage types for APIs to use." items: $ref: "#/definitions/protobufAny" description: "The `Status` type defines a logical error model that is suitable\ \ for\ndifferent programming environments, including REST APIs and RPC APIs.\ \ It is\nused by [gRPC](https://github.com/grpc). Each `Status` message contains\n\ three pieces of data: error code, error message, and error details.\n\nYou can\ \ find out more about this error model and how to work with it in the\n[API\ \ Design Guide](https://cloud.google.com/apis/design/errors)." example: code: 0 details: - '@type': "@type" - '@type': "@type" message: "message" protobufAny: type: "object" properties: '@type': type: "string" description: "A URL/resource name that uniquely identifies the type of the\ \ serialized\nprotocol buffer message. This string must contain at least\n\ one \"/\" character. The last segment of the URL's path must represent\n\ the fully qualified name of the type (as in\n`path/google.protobuf.Duration`).\ \ The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\ \nIn practice, teams usually precompile into the binary all types that they\n\ expect it to use in the context of Any. However, for URLs which use the\n\ scheme `http`, `https`, or no scheme, one can optionally set up a type\n\ server that maps type URLs to message definitions as follows:\n\n* If no\ \ scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must\ \ yield a [google.protobuf.Type][]\n value in binary format, or produce\ \ an error.\n* Applications are allowed to cache lookup results based on\ \ the\n URL, or have them precompiled into a binary to avoid any\n lookup.\ \ Therefore, binary compatibility needs to be preserved\n on changes to\ \ types. (Use versioned type names to manage\n breaking changes.)\n\nNote:\ \ this functionality is not currently available in the official\nprotobuf\ \ release, and it is not used for type URLs beginning with\ntype.googleapis.com.\ \ As of May 2023, there are no widely used type server\nimplementations\ \ and no plans to implement one.\n\nSchemes other than `http`, `https` (or\ \ the empty scheme) might be\nused with implementation specific semantics." description: "`Any` contains an arbitrary serialized protocol buffer message along\ \ with a\nURL that describes the type of the serialized message.\n\nProtobuf\ \ library provides support to pack/unpack Any values in the form\nof utility\ \ functions or additional generated methods of the Any type.\n\nExample 1: Pack\ \ and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n\ \ ...\n if (any.UnpackTo(&foo)) {\n ...\n }\n\nExample 2: Pack\ \ and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n\ \ ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n\ \ }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n\ \ foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack\ \ and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n \ \ any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n\ \ ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := &pb.Foo{...}\n\ \ any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n\ \ ...\n foo := &pb.Foo{}\n if err := any.UnmarshalTo(foo); err !=\ \ nil {\n ...\n }\n\nThe pack methods provided by protobuf library\ \ will by default use\n'type.googleapis.com/full.type.name' as the type URL\ \ and the unpack\nmethods only use the fully qualified type name after the last\ \ '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\n\ name \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses\ \ the regular\nrepresentation of the deserialized, embedded message, with an\n\ additional field `@type` which contains the type URL. Example:\n\n package\ \ google.profile;\n message Person {\n string first_name = 1;\n \ \ string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\"\ ,\n \"firstName\": ,\n \"lastName\": \n }\n\nIf\ \ the embedded message type is well-known and has a custom JSON\nrepresentation,\ \ that representation will be embedded adding a field\n`value` which holds the\ \ custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\ \n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n\ \ \"value\": \"1.212s\"\n }" example: '@type': "@type" additionalProperties: {} Stream result of examplepbResponseBodyOut: properties: result: $ref: "#/definitions/examplepbResponseBodyOutResponse" error: $ref: "#/definitions/googleRpcStatus" example: result: data: "data" error: code: 0 details: - '@type': "@type" - '@type': "@type" message: "message" ================================================ FILE: examples/internal/clients/responsebody/api_response_body_service.go ================================================ /* * examples/internal/proto/examplepb/response_body_service.proto * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package responsebody import ( "context" "io/ioutil" "net/http" "net/url" "strings" "fmt" ) // Linger please var ( _ context.Context ) type ResponseBodyServiceApiService service /* ResponseBodyServiceApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param data @return ExamplepbResponseBodyOutResponse */ func (a *ResponseBodyServiceApiService) ResponseBodyServiceGetResponseBody(ctx context.Context, data string) (ExamplepbResponseBodyOutResponse, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbResponseBodyOutResponse ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/responsebody/{data}" localVarPath = strings.Replace(localVarPath, "{"+"data"+"}", fmt.Sprintf("%v", data), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbResponseBodyOutResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ResponseBodyServiceApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param data @return string */ func (a *ResponseBodyServiceApiService) ResponseBodyServiceGetResponseBodySameName(ctx context.Context, data string) (string, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue string ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/responsebody/samename/{data}" localVarPath = strings.Replace(localVarPath, "{"+"data"+"}", fmt.Sprintf("%v", data), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ResponseBodyServiceApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param data @return StreamResultOfExamplepbResponseBodyOut */ func (a *ResponseBodyServiceApiService) ResponseBodyServiceGetResponseBodyStream(ctx context.Context, data string) (StreamResultOfExamplepbResponseBodyOut, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue StreamResultOfExamplepbResponseBodyOut ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/responsebody/stream/{data}" localVarPath = strings.Replace(localVarPath, "{"+"data"+"}", fmt.Sprintf("%v", data), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v StreamResultOfExamplepbResponseBodyOut err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ResponseBodyServiceApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param data @return []ExamplepbRepeatedResponseBodyOutResponse */ func (a *ResponseBodyServiceApiService) ResponseBodyServiceListResponseBodies(ctx context.Context, data string) ([]ExamplepbRepeatedResponseBodyOutResponse, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue []ExamplepbRepeatedResponseBodyOutResponse ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/responsebodies/{data}" localVarPath = strings.Replace(localVarPath, "{"+"data"+"}", fmt.Sprintf("%v", data), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v []ExamplepbRepeatedResponseBodyOutResponse err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* ResponseBodyServiceApiService * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param data @return []string */ func (a *ResponseBodyServiceApiService) ResponseBodyServiceListResponseStrings(ctx context.Context, data string) ([]string, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue []string ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/responsestrings/{data}" localVarPath = strings.Replace(localVarPath, "{"+"data"+"}", fmt.Sprintf("%v", data), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v []string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v GoogleRpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } ================================================ FILE: examples/internal/clients/responsebody/client.go ================================================ /* * examples/internal/proto/examplepb/response_body_service.proto * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package responsebody import ( "bytes" "context" "encoding/json" "encoding/xml" "errors" "fmt" "io" "mime/multipart" "net/http" "net/url" "os" "path/filepath" "reflect" "regexp" "strconv" "strings" "time" "unicode/utf8" "golang.org/x/oauth2" ) var ( jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") ) // APIClient manages communication with the examples/internal/proto/examplepb/response_body_service.proto API vversion not set // In most cases there should be only one, shared, APIClient. type APIClient struct { cfg *Configuration common service // Reuse a single struct instead of allocating one for each service on the heap. // API Services ResponseBodyServiceApi *ResponseBodyServiceApiService } type service struct { client *APIClient } // NewAPIClient creates a new API client. Requires a userAgent string describing your application. // optionally a custom http.Client to allow for advanced features such as caching. func NewAPIClient(cfg *Configuration) *APIClient { if cfg.HTTPClient == nil { cfg.HTTPClient = http.DefaultClient } c := &APIClient{} c.cfg = cfg c.common.client = c // API Services c.ResponseBodyServiceApi = (*ResponseBodyServiceApiService)(&c.common) return c } func atoi(in string) (int, error) { return strconv.Atoi(in) } // selectHeaderContentType select a content type from the available list. func selectHeaderContentType(contentTypes []string) string { if len(contentTypes) == 0 { return "" } if contains(contentTypes, "application/json") { return "application/json" } return contentTypes[0] // use the first content type specified in 'consumes' } // selectHeaderAccept join all accept types and return func selectHeaderAccept(accepts []string) string { if len(accepts) == 0 { return "" } if contains(accepts, "application/json") { return "application/json" } return strings.Join(accepts, ",") } // contains is a case insenstive match, finding needle in a haystack func contains(haystack []string, needle string) bool { for _, a := range haystack { if strings.ToLower(a) == strings.ToLower(needle) { return true } } return false } // Verify optional parameters are of the correct type. func typeCheckParameter(obj interface{}, expected string, name string) error { // Make sure there is an object. if obj == nil { return nil } // Check the type is as expected. if reflect.TypeOf(obj).String() != expected { return fmt.Errorf("Expected %s to be of type %s but received %s.", name, expected, reflect.TypeOf(obj).String()) } return nil } // parameterToString convert interface{} parameters to string, using a delimiter if format is provided. func parameterToString(obj interface{}, collectionFormat string) string { var delimiter string switch collectionFormat { case "pipes": delimiter = "|" case "ssv": delimiter = " " case "tsv": delimiter = "\t" case "csv": delimiter = "," } if reflect.TypeOf(obj).Kind() == reflect.Slice { return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]") } return fmt.Sprintf("%v", obj) } // callAPI do the request. func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { return c.cfg.HTTPClient.Do(request) } // Change base path to allow switching to mocks func (c *APIClient) ChangeBasePath(path string) { c.cfg.BasePath = path } // prepareRequest build the request func (c *APIClient) prepareRequest( ctx context.Context, path string, method string, postBody interface{}, headerParams map[string]string, queryParams url.Values, formParams url.Values, fileName string, fileBytes []byte) (localVarRequest *http.Request, err error) { var body *bytes.Buffer // Detect postBody type and post. if postBody != nil { contentType := headerParams["Content-Type"] if contentType == "" { contentType = detectContentType(postBody) headerParams["Content-Type"] = contentType } body, err = setBody(postBody, contentType) if err != nil { return nil, err } } // add form parameters and file if available. if len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") { if body != nil { return nil, errors.New("Cannot specify postBody and multipart form at the same time.") } body = &bytes.Buffer{} w := multipart.NewWriter(body) for k, v := range formParams { for _, iv := range v { if strings.HasPrefix(k, "@") { // file err = addFile(w, k[1:], iv) if err != nil { return nil, err } } else { // form value w.WriteField(k, iv) } } } if len(fileBytes) > 0 && fileName != "" { w.Boundary() //_, fileNm := filepath.Split(fileName) part, err := w.CreateFormFile("file", filepath.Base(fileName)) if err != nil { return nil, err } _, err = part.Write(fileBytes) if err != nil { return nil, err } // Set the Boundary in the Content-Type headerParams["Content-Type"] = w.FormDataContentType() } // Set Content-Length headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) w.Close() } // Setup path and query parameters url, err := url.Parse(path) if err != nil { return nil, err } // Adding Query Param query := url.Query() for k, v := range queryParams { for _, iv := range v { query.Add(k, iv) } } // Encode the parameters. url.RawQuery = query.Encode() // Generate a new request if body != nil { localVarRequest, err = http.NewRequest(method, url.String(), body) } else { localVarRequest, err = http.NewRequest(method, url.String(), nil) } if err != nil { return nil, err } // add header parameters, if any if len(headerParams) > 0 { headers := http.Header{} for h, v := range headerParams { headers.Set(h, v) } localVarRequest.Header = headers } // Override request host, if applicable if c.cfg.Host != "" { localVarRequest.Host = c.cfg.Host } // Add the user agent to the request. localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) if ctx != nil { // add context to the request localVarRequest = localVarRequest.WithContext(ctx) // Walk through any authentication. // OAuth2 authentication if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok { // We were able to grab an oauth2 token from the context var latestToken *oauth2.Token if latestToken, err = tok.Token(); err != nil { return nil, err } latestToken.SetAuthHeader(localVarRequest) } // Basic HTTP Authentication if auth, ok := ctx.Value(ContextBasicAuth).(BasicAuth); ok { localVarRequest.SetBasicAuth(auth.UserName, auth.Password) } // AccessToken Authentication if auth, ok := ctx.Value(ContextAccessToken).(string); ok { localVarRequest.Header.Add("Authorization", "Bearer "+auth) } } for header, value := range c.cfg.DefaultHeader { localVarRequest.Header.Add(header, value) } return localVarRequest, nil } func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { if strings.Contains(contentType, "application/xml") { if err = xml.Unmarshal(b, v); err != nil { return err } return nil } else if strings.Contains(contentType, "application/json") { if err = json.Unmarshal(b, v); err != nil { return err } return nil } return errors.New("undefined response type") } // Add a file to the multipart request func addFile(w *multipart.Writer, fieldName, path string) error { file, err := os.Open(path) if err != nil { return err } defer file.Close() part, err := w.CreateFormFile(fieldName, filepath.Base(path)) if err != nil { return err } _, err = io.Copy(part, file) return err } // Prevent trying to import "fmt" func reportError(format string, a ...interface{}) error { return fmt.Errorf(format, a...) } // Set request body from an interface{} func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { if bodyBuf == nil { bodyBuf = &bytes.Buffer{} } if reader, ok := body.(io.Reader); ok { _, err = bodyBuf.ReadFrom(reader) } else if b, ok := body.([]byte); ok { _, err = bodyBuf.Write(b) } else if s, ok := body.(string); ok { _, err = bodyBuf.WriteString(s) } else if s, ok := body.(*string); ok { _, err = bodyBuf.WriteString(*s) } else if jsonCheck.MatchString(contentType) { err = json.NewEncoder(bodyBuf).Encode(body) } else if xmlCheck.MatchString(contentType) { xml.NewEncoder(bodyBuf).Encode(body) } if err != nil { return nil, err } if bodyBuf.Len() == 0 { err = fmt.Errorf("Invalid body type %s\n", contentType) return nil, err } return bodyBuf, nil } // detectContentType method is used to figure out `Request.Body` content type for request header func detectContentType(body interface{}) string { contentType := "text/plain; charset=utf-8" kind := reflect.TypeOf(body).Kind() switch kind { case reflect.Struct, reflect.Map, reflect.Ptr: contentType = "application/json; charset=utf-8" case reflect.String: contentType = "text/plain; charset=utf-8" default: if b, ok := body.([]byte); ok { contentType = http.DetectContentType(b) } else if kind == reflect.Slice { contentType = "application/json; charset=utf-8" } } return contentType } // Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go type cacheControl map[string]string func parseCacheControl(headers http.Header) cacheControl { cc := cacheControl{} ccHeader := headers.Get("Cache-Control") for _, part := range strings.Split(ccHeader, ",") { part = strings.Trim(part, " ") if part == "" { continue } if strings.ContainsRune(part, '=') { keyval := strings.Split(part, "=") cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") } else { cc[part] = "" } } return cc } // CacheExpires helper function to determine remaining time before repeating a request. func CacheExpires(r *http.Response) time.Time { // Figure out when the cache expires. var expires time.Time now, err := time.Parse(time.RFC1123, r.Header.Get("date")) if err != nil { return time.Now() } respCacheControl := parseCacheControl(r.Header) if maxAge, ok := respCacheControl["max-age"]; ok { lifetime, err := time.ParseDuration(maxAge + "s") if err != nil { expires = now } expires = now.Add(lifetime) } else { expiresHeader := r.Header.Get("Expires") if expiresHeader != "" { expires, err = time.Parse(time.RFC1123, expiresHeader) if err != nil { expires = now } } } return expires } func strlen(s string) int { return utf8.RuneCountInString(s) } // GenericSwaggerError Provides access to the body, error and model on returned errors. type GenericSwaggerError struct { body []byte error string model interface{} } // Error returns non-empty string if there was an error. func (e GenericSwaggerError) Error() string { return e.error } // Body returns the raw bytes of the response func (e GenericSwaggerError) Body() []byte { return e.body } // Model returns the unpacked model of the error func (e GenericSwaggerError) Model() interface{} { return e.model } ================================================ FILE: examples/internal/clients/responsebody/configuration.go ================================================ /* * examples/internal/proto/examplepb/response_body_service.proto * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package responsebody import ( "net/http" ) // contextKeys are used to identify the type of value in the context. // Since these are string, it is possible to get a short description of the // context key for logging and debugging using key.String(). type contextKey string func (c contextKey) String() string { return "auth " + string(c) } var ( // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. ContextOAuth2 = contextKey("token") // ContextBasicAuth takes BasicAuth as authentication for the request. ContextBasicAuth = contextKey("basic") // ContextAccessToken takes a string oauth2 access token as authentication for the request. ContextAccessToken = contextKey("accesstoken") // ContextAPIKey takes an APIKey as authentication for the request ContextAPIKey = contextKey("apikey") ) // BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth type BasicAuth struct { UserName string `json:"userName,omitempty"` Password string `json:"password,omitempty"` } // APIKey provides API key based authentication to a request passed via context using ContextAPIKey type APIKey struct { Key string Prefix string } type Configuration struct { BasePath string `json:"basePath,omitempty"` Host string `json:"host,omitempty"` Scheme string `json:"scheme,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"` UserAgent string `json:"userAgent,omitempty"` HTTPClient *http.Client } func NewConfiguration() *Configuration { cfg := &Configuration{ BasePath: "https://localhost", DefaultHeader: make(map[string]string), UserAgent: "Swagger-Codegen/1.0.0/go", } return cfg } func (c *Configuration) AddDefaultHeader(key string, value string) { c.DefaultHeader[key] = value } ================================================ FILE: examples/internal/clients/responsebody/docs/ExamplepbRepeatedResponseBodyOut.md ================================================ # ExamplepbRepeatedResponseBodyOut ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Response** | [**[]ExamplepbRepeatedResponseBodyOutResponse**](examplepbRepeatedResponseBodyOutResponse.md) | | [optional] [default to null] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ================================================ FILE: examples/internal/clients/responsebody/docs/ExamplepbRepeatedResponseBodyOutResponse.md ================================================ # ExamplepbRepeatedResponseBodyOutResponse ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Data** | **string** | | [optional] [default to null] **Type_** | [***ResponseResponseType**](ResponseResponseType.md) | | [optional] [default to null] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ================================================ FILE: examples/internal/clients/responsebody/docs/ExamplepbRepeatedResponseStrings.md ================================================ # ExamplepbRepeatedResponseStrings ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Values** | **[]string** | | [optional] [default to null] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ================================================ FILE: examples/internal/clients/responsebody/docs/ExamplepbResponseBodyMessage.md ================================================ # ExamplepbResponseBodyMessage ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Request** | **string** | | [optional] [default to null] **Response** | [**ExamplepbResponseBodyMessageResponse**](examplepbResponseBodyMessageResponse.md) | | [optional] [default to null] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ================================================ FILE: examples/internal/clients/responsebody/docs/ExamplepbResponseBodyMessageResponse.md ================================================ # ExamplepbResponseBodyMessageResponse ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Data** | **string** | | [optional] [default to null] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ================================================ FILE: examples/internal/clients/responsebody/docs/ExamplepbResponseBodyOut.md ================================================ # ExamplepbResponseBodyOut ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Response** | [***ExamplepbResponseBodyOutResponse**](examplepbResponseBodyOutResponse.md) | | [optional] [default to null] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ================================================ FILE: examples/internal/clients/responsebody/docs/ExamplepbResponseBodyOutResponse.md ================================================ # ExamplepbResponseBodyOutResponse ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Data** | **string** | | [optional] [default to null] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ================================================ FILE: examples/internal/clients/responsebody/docs/ExamplepbResponseBodyReq.md ================================================ # ExamplepbResponseBodyReq ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Data** | **string** | | [optional] [default to null] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ================================================ FILE: examples/internal/clients/responsebody/docs/ExamplepbResponseBodyValue.md ================================================ # ExamplepbResponseBodyValue ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **ResponseBodyValue** | **string** | | [optional] [default to null] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ================================================ FILE: examples/internal/clients/responsebody/docs/GoogleRpcStatus.md ================================================ # GoogleRpcStatus ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Code** | **int32** | The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. | [optional] [default to null] **Message** | **string** | A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. | [optional] [default to null] **Details** | [**[]ProtobufAny**](protobufAny.md) | A list of messages that carry the error details. There is a common set of message types for APIs to use. | [optional] [default to null] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ================================================ FILE: examples/internal/clients/responsebody/docs/ProtobufAny.md ================================================ # ProtobufAny ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Type_** | **string** | A URL/resource name that uniquely identifies the type of the serialized protocol buffer message. This string must contain at least one \"/\" character. The last segment of the URL's path must represent the fully qualified name of the type (as in `path/google.protobuf.Duration`). The name should be in a canonical form (e.g., leading \".\" is not accepted). In practice, teams usually precompile into the binary all types that they expect it to use in the context of Any. However, for URLs which use the scheme `http`, `https`, or no scheme, one can optionally set up a type server that maps type URLs to message definitions as follows: * If no scheme is provided, `https` is assumed. * An HTTP GET on the URL must yield a [google.protobuf.Type][] value in binary format, or produce an error. * Applications are allowed to cache lookup results based on the URL, or have them precompiled into a binary to avoid any lookup. Therefore, binary compatibility needs to be preserved on changes to types. (Use versioned type names to manage breaking changes.) Note: this functionality is not currently available in the official protobuf release, and it is not used for type URLs beginning with type.googleapis.com. As of May 2023, there are no widely used type server implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) might be used with implementation specific semantics. | [optional] [default to null] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ================================================ FILE: examples/internal/clients/responsebody/docs/ResponseBodyServiceApi.md ================================================ # \ResponseBodyServiceApi All URIs are relative to *https://localhost* Method | HTTP request | Description ------------- | ------------- | ------------- [**ResponseBodyServiceGetResponseBody**](ResponseBodyServiceApi.md#ResponseBodyServiceGetResponseBody) | **Get** /responsebody/{data} | [**ResponseBodyServiceGetResponseBodySameName**](ResponseBodyServiceApi.md#ResponseBodyServiceGetResponseBodySameName) | **Get** /responsebody/samename/{data} | [**ResponseBodyServiceGetResponseBodyStream**](ResponseBodyServiceApi.md#ResponseBodyServiceGetResponseBodyStream) | **Get** /responsebody/stream/{data} | [**ResponseBodyServiceListResponseBodies**](ResponseBodyServiceApi.md#ResponseBodyServiceListResponseBodies) | **Get** /responsebodies/{data} | [**ResponseBodyServiceListResponseStrings**](ResponseBodyServiceApi.md#ResponseBodyServiceListResponseStrings) | **Get** /responsestrings/{data} | # **ResponseBodyServiceGetResponseBody** > ExamplepbResponseBodyOutResponse ResponseBodyServiceGetResponseBody(ctx, data) ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **data** | **string**| | ### Return type [**ExamplepbResponseBodyOutResponse**](examplepbResponseBodyOutResponse.md) ### Authorization No authorization required ### HTTP request headers - **Content-Type**: application/json - **Accept**: application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **ResponseBodyServiceGetResponseBodySameName** > string ResponseBodyServiceGetResponseBodySameName(ctx, data) ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **data** | **string**| | ### Return type **string** ### Authorization No authorization required ### HTTP request headers - **Content-Type**: application/json - **Accept**: application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **ResponseBodyServiceGetResponseBodyStream** > StreamResultOfExamplepbResponseBodyOut ResponseBodyServiceGetResponseBodyStream(ctx, data) ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **data** | **string**| | ### Return type [**StreamResultOfExamplepbResponseBodyOut**](Stream result of examplepbResponseBodyOut.md) ### Authorization No authorization required ### HTTP request headers - **Content-Type**: application/json - **Accept**: application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **ResponseBodyServiceListResponseBodies** > []ExamplepbRepeatedResponseBodyOutResponse ResponseBodyServiceListResponseBodies(ctx, data) ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **data** | **string**| | ### Return type [**[]ExamplepbRepeatedResponseBodyOutResponse**](examplepbRepeatedResponseBodyOutResponse.md) ### Authorization No authorization required ### HTTP request headers - **Content-Type**: application/json - **Accept**: application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **ResponseBodyServiceListResponseStrings** > []string ResponseBodyServiceListResponseStrings(ctx, data) ### Required Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **data** | **string**| | ### Return type **[]string** ### Authorization No authorization required ### HTTP request headers - **Content-Type**: application/json - **Accept**: application/json [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) ================================================ FILE: examples/internal/clients/responsebody/docs/ResponseResponseType.md ================================================ # ResponseResponseType ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ================================================ FILE: examples/internal/clients/responsebody/docs/RpcStatus.md ================================================ # RpcStatus ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Code** | **int32** | The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. | [optional] [default to null] **Message** | **string** | A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. | [optional] [default to null] **Details** | [**[]ProtobufAny**](protobufAny.md) | A list of messages that carry the error details. There is a common set of message types for APIs to use. | [optional] [default to null] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ================================================ FILE: examples/internal/clients/responsebody/docs/RuntimeError.md ================================================ # RuntimeError ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Error_** | **string** | | [optional] [default to null] **Code** | **int32** | | [optional] [default to null] **Message** | **string** | | [optional] [default to null] **Details** | [**[]ProtobufAny**](protobufAny.md) | | [optional] [default to null] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ================================================ FILE: examples/internal/clients/responsebody/docs/StreamResultOfExamplepbResponseBodyOut.md ================================================ # StreamResultOfExamplepbResponseBodyOut ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Result** | [***ExamplepbResponseBodyOutResponse**](examplepbResponseBodyOutResponse.md) | | [optional] [default to null] **Error_** | [***GoogleRpcStatus**](googleRpcStatus.md) | | [optional] [default to null] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) ================================================ FILE: examples/internal/clients/responsebody/model_examplepb_repeated_response_body_out.go ================================================ /* * examples/internal/proto/examplepb/response_body_service.proto * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package responsebody type ExamplepbRepeatedResponseBodyOut struct { Response []ExamplepbRepeatedResponseBodyOutResponse `json:"response,omitempty"` } ================================================ FILE: examples/internal/clients/responsebody/model_examplepb_repeated_response_body_out_response.go ================================================ /* * examples/internal/proto/examplepb/response_body_service.proto * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package responsebody type ExamplepbRepeatedResponseBodyOutResponse struct { Data string `json:"data,omitempty"` Type_ *ResponseResponseType `json:"type,omitempty"` } ================================================ FILE: examples/internal/clients/responsebody/model_examplepb_repeated_response_strings.go ================================================ /* * examples/internal/proto/examplepb/response_body_service.proto * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package responsebody type ExamplepbRepeatedResponseStrings struct { Values []string `json:"values,omitempty"` } ================================================ FILE: examples/internal/clients/responsebody/model_examplepb_response_body_out.go ================================================ /* * examples/internal/proto/examplepb/response_body_service.proto * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package responsebody type ExamplepbResponseBodyOut struct { Response *ExamplepbResponseBodyOutResponse `json:"response,omitempty"` } ================================================ FILE: examples/internal/clients/responsebody/model_examplepb_response_body_out_response.go ================================================ /* * examples/internal/proto/examplepb/response_body_service.proto * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package responsebody type ExamplepbResponseBodyOutResponse struct { Data string `json:"data,omitempty"` } ================================================ FILE: examples/internal/clients/responsebody/model_examplepb_response_body_value.go ================================================ /* * examples/internal/proto/examplepb/response_body_service.proto * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package responsebody type ExamplepbResponseBodyValue struct { ResponseBodyValue string `json:"responseBodyValue,omitempty"` } ================================================ FILE: examples/internal/clients/responsebody/model_google_rpc_status.go ================================================ /* * examples/internal/proto/examplepb/response_body_service.proto * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package responsebody // The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). type GoogleRpcStatus struct { // The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. Code int32 `json:"code,omitempty"` // A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. Message string `json:"message,omitempty"` // A list of messages that carry the error details. There is a common set of message types for APIs to use. Details []ProtobufAny `json:"details,omitempty"` } ================================================ FILE: examples/internal/clients/responsebody/model_protobuf_any.go ================================================ /* * examples/internal/proto/examplepb/response_body_service.proto * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package responsebody // `Any` contains an arbitrary serialized protocol buffer message along with a URL that describes the type of the serialized message. Protobuf library provides support to pack/unpack Any values in the form of utility functions or additional generated methods of the Any type. Example 1: Pack and unpack a message in C++. Foo foo = ...; Any any; any.PackFrom(foo); ... if (any.UnpackTo(&foo)) { ... } Example 2: Pack and unpack a message in Java. Foo foo = ...; Any any = Any.pack(foo); ... if (any.is(Foo.class)) { foo = any.unpack(Foo.class); } // or ... if (any.isSameTypeAs(Foo.getDefaultInstance())) { foo = any.unpack(Foo.getDefaultInstance()); } Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() any.Pack(foo) ... if any.Is(Foo.DESCRIPTOR): any.Unpack(foo) ... Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) if err != nil { ... } ... foo := &pb.Foo{} if err := any.UnmarshalTo(foo); err != nil { ... } The pack methods provided by protobuf library will by default use 'type.googleapis.com/full.type.name' as the type URL and the unpack methods only use the fully qualified type name after the last '/' in the type URL, for example \"foo.bar.com/x/y.z\" will yield type name \"y.z\". JSON ==== The JSON representation of an `Any` value uses the regular representation of the deserialized, embedded message, with an additional field `@type` which contains the type URL. Example: package google.profile; message Person { string first_name = 1; string last_name = 2; } { \"@type\": \"type.googleapis.com/google.profile.Person\", \"firstName\": , \"lastName\": } If the embedded message type is well-known and has a custom JSON representation, that representation will be embedded adding a field `value` which holds the custom JSON in addition to the `@type` field. Example (for message [google.protobuf.Duration][]): { \"@type\": \"type.googleapis.com/google.protobuf.Duration\", \"value\": \"1.212s\" } type ProtobufAny struct { // A URL/resource name that uniquely identifies the type of the serialized protocol buffer message. This string must contain at least one \"/\" character. The last segment of the URL's path must represent the fully qualified name of the type (as in `path/google.protobuf.Duration`). The name should be in a canonical form (e.g., leading \".\" is not accepted). In practice, teams usually precompile into the binary all types that they expect it to use in the context of Any. However, for URLs which use the scheme `http`, `https`, or no scheme, one can optionally set up a type server that maps type URLs to message definitions as follows: * If no scheme is provided, `https` is assumed. * An HTTP GET on the URL must yield a [google.protobuf.Type][] value in binary format, or produce an error. * Applications are allowed to cache lookup results based on the URL, or have them precompiled into a binary to avoid any lookup. Therefore, binary compatibility needs to be preserved on changes to types. (Use versioned type names to manage breaking changes.) Note: this functionality is not currently available in the official protobuf release, and it is not used for type URLs beginning with type.googleapis.com. As of May 2023, there are no widely used type server implementations and no plans to implement one. Schemes other than `http`, `https` (or the empty scheme) might be used with implementation specific semantics. Type_ string `json:"@type,omitempty"` } ================================================ FILE: examples/internal/clients/responsebody/model_response_response_type.go ================================================ /* * examples/internal/proto/examplepb/response_body_service.proto * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package responsebody type ResponseResponseType string // List of ResponseResponseType const ( UNKNOWN_ResponseResponseType ResponseResponseType = "UNKNOWN" A_ResponseResponseType ResponseResponseType = "A" B_ResponseResponseType ResponseResponseType = "B" ) ================================================ FILE: examples/internal/clients/responsebody/model_stream_result_of_examplepb_response_body_out.go ================================================ /* * examples/internal/proto/examplepb/response_body_service.proto * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package responsebody type StreamResultOfExamplepbResponseBodyOut struct { Result *ExamplepbResponseBodyOutResponse `json:"result,omitempty"` Error_ *GoogleRpcStatus `json:"error,omitempty"` } ================================================ FILE: examples/internal/clients/responsebody/response.go ================================================ /* * examples/internal/proto/examplepb/response_body_service.proto * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * API version: version not set * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package responsebody import ( "net/http" ) type APIResponse struct { *http.Response `json:"-"` Message string `json:"message,omitempty"` // Operation is the name of the swagger operation. Operation string `json:"operation,omitempty"` // RequestURL is the request URL. This value is always available, even if the // embedded *http.Response is nil. RequestURL string `json:"url,omitempty"` // Method is the HTTP method used for the request. This value is always // available, even if the embedded *http.Response is nil. Method string `json:"method,omitempty"` // Payload holds the contents of the response body (which may be nil or empty). // This is provided here as the raw response.Body() reader will have already // been drained. Payload []byte `json:"-"` } func NewAPIResponse(r *http.Response) *APIResponse { response := &APIResponse{Response: r} return response } func NewAPIResponseWithError(errorMessage string) *APIResponse { response := &APIResponse{Message: errorMessage} return response } ================================================ FILE: examples/internal/clients/staticcheck.conf ================================================ checks = ["-all"] ================================================ FILE: examples/internal/clients/unannotatedecho/.gitignore ================================================ /docs ================================================ FILE: examples/internal/clients/unannotatedecho/.swagger-codegen/VERSION ================================================ 2.4.8 ================================================ FILE: examples/internal/clients/unannotatedecho/.swagger-codegen-ignore ================================================ .gitignore ================================================ FILE: examples/internal/clients/unannotatedecho/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library") package(default_visibility = ["//visibility:public"]) go_library( name = "unannotatedecho", srcs = [ "api_unannotated_echo_service.go", "client.go", "configuration.go", "model_examplepb_numeric_enum.go", "model_examplepb_unannotated_embedded.go", "model_examplepb_unannotated_nested_message.go", "model_examplepb_unannotated_simple_message.go", "model_protobuf_any.go", "model_rpc_status.go", "response.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/clients/unannotatedecho", deps = [ "@com_github_antihax_optional//:optional", "@org_golang_x_oauth2//:oauth2", ], ) alias( name = "go_default_library", actual = ":unannotatedecho", visibility = ["//examples:__subpackages__"], ) ================================================ FILE: examples/internal/clients/unannotatedecho/api/swagger.yaml ================================================ --- swagger: "2.0" info: description: "Unannotated Echo Service\nSimilar to echo_service.proto but without\ \ annotations. See\nunannotated_echo_service.yaml for the equivalent of the annotations\ \ in\ngRPC API configuration format.\n\nEcho Service API consists of a single\ \ service which returns\na message." version: "1.0" title: "Unannotated Echo" contact: name: "gRPC-Gateway project" url: "https://github.com/grpc-ecosystem/grpc-gateway" email: "none@example.com" license: name: "BSD 3-Clause License" url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE" x-something-something: "yadda" tags: - name: "Echo" description: "Echo description" - name: "Internal" description: "Internal description" x-traitTag: true - name: "UnannotatedEchoService" description: "UnannotatedEchoService description -- which should not be used in\ \ place of the documentation comment!" externalDocs: description: "Find out more about UnannotatedEchoService" url: "https://github.com/grpc-ecosystem/grpc-gateway" schemes: - "http" - "https" - "wss" consumes: - "application/json" - "application/x-foo-mime" produces: - "application/json" - "application/x-foo-mime" security: - ApiKeyAuth: [] BasicAuth: [] - ApiKeyAuth: [] OAuth2: - "read" - "write" paths: /v1/example/echo/{id}: post: tags: - "UnannotatedEchoService" summary: "Summary: Echo rpc" description: "Description Echo" operationId: "UnannotatedEchoService_Echo" parameters: - name: "id" in: "path" description: "Id represents the message identifier." required: true type: "string" x-exportParamName: "Id" - name: "num" in: "query" description: "Int value field" required: true type: "string" default: "42" format: "int64" x-exportParamName: "Num" - name: "duration" in: "query" required: false type: "string" x-exportParamName: "Duration" x-optionalDataType: "String" - name: "lineNum" in: "query" required: false type: "string" format: "int64" x-exportParamName: "LineNum" x-optionalDataType: "String" - name: "lang" in: "query" required: false type: "string" x-exportParamName: "Lang" x-optionalDataType: "String" - name: "status.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "StatusProgress" x-optionalDataType: "String" - name: "status.note" in: "query" required: false type: "string" x-exportParamName: "StatusNote" x-optionalDataType: "String" - name: "en" in: "query" required: false type: "string" format: "int64" x-exportParamName: "En" x-optionalDataType: "String" - name: "no.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "NoProgress" x-optionalDataType: "String" - name: "no.note" in: "query" required: false type: "string" x-exportParamName: "NoNote" x-optionalDataType: "String" - name: "resourceId" in: "query" required: false type: "string" x-exportParamName: "ResourceId" x-optionalDataType: "String" - name: "nId.nId" in: "query" required: false type: "string" x-exportParamName: "NIdNId" x-optionalDataType: "String" - name: "nId.val" in: "query" required: false type: "string" x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: 200: description: "A successful response." examples: application/json: value: "the input value" schema: $ref: "#/definitions/examplepbUnannotatedSimpleMessage" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "integer" format: "integer" 503: description: "Returned when the resource is temporarily unavailable." schema: {} x-number: 100 default: description: "An unexpected error response." schema: $ref: "#/definitions/rpcStatus" externalDocs: description: "Find out more Echo" url: "https://github.com/grpc-ecosystem/grpc-gateway" /v1/example/echo/{id}/{num}: get: tags: - "UnannotatedEchoService" summary: "Summary: Echo rpc" description: "Description Echo" operationId: "UnannotatedEchoService_Echo2" parameters: - name: "id" in: "path" description: "Id represents the message identifier." required: true type: "string" x-exportParamName: "Id" - name: "num" in: "path" description: "Int value field" required: true type: "string" default: "42" format: "int64" x-exportParamName: "Num" - name: "duration" in: "query" required: false type: "string" x-exportParamName: "Duration" x-optionalDataType: "String" - name: "lineNum" in: "query" required: false type: "string" format: "int64" x-exportParamName: "LineNum" x-optionalDataType: "String" - name: "lang" in: "query" required: false type: "string" x-exportParamName: "Lang" x-optionalDataType: "String" - name: "status.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "StatusProgress" x-optionalDataType: "String" - name: "status.note" in: "query" required: false type: "string" x-exportParamName: "StatusNote" x-optionalDataType: "String" - name: "en" in: "query" required: false type: "string" format: "int64" x-exportParamName: "En" x-optionalDataType: "String" - name: "no.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "NoProgress" x-optionalDataType: "String" - name: "no.note" in: "query" required: false type: "string" x-exportParamName: "NoNote" x-optionalDataType: "String" - name: "resourceId" in: "query" required: false type: "string" x-exportParamName: "ResourceId" x-optionalDataType: "String" - name: "nId.nId" in: "query" required: false type: "string" x-exportParamName: "NIdNId" x-optionalDataType: "String" - name: "nId.val" in: "query" required: false type: "string" x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: 200: description: "A successful response." examples: application/json: value: "the input value" schema: $ref: "#/definitions/examplepbUnannotatedSimpleMessage" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "integer" format: "integer" 503: description: "Returned when the resource is temporarily unavailable." schema: {} x-number: 100 default: description: "An unexpected error response." schema: $ref: "#/definitions/rpcStatus" externalDocs: description: "Find out more Echo" url: "https://github.com/grpc-ecosystem/grpc-gateway" /v1/example/echo_body: post: tags: - "UnannotatedEchoService" summary: "EchoBody method receives a simple message and returns it." operationId: "UnannotatedEchoService_EchoBody" parameters: - in: "body" name: "body" description: "A simple message with many types" required: true schema: $ref: "#/definitions/examplepbUnannotatedSimpleMessage" x-exportParamName: "Body" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbUnannotatedSimpleMessage" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" default: description: "An unexpected error response." schema: $ref: "#/definitions/rpcStatus" /v1/example/echo_delete: delete: tags: - "UnannotatedEchoService" summary: "EchoDelete method receives a simple message and returns it." operationId: "UnannotatedEchoService_EchoDelete" parameters: - name: "id" in: "query" description: "Id represents the message identifier." required: false type: "string" x-exportParamName: "Id" x-optionalDataType: "String" - name: "num" in: "query" description: "Int value field" required: true type: "string" default: "42" format: "int64" x-exportParamName: "Num" - name: "duration" in: "query" required: false type: "string" x-exportParamName: "Duration" x-optionalDataType: "String" - name: "lineNum" in: "query" required: false type: "string" format: "int64" x-exportParamName: "LineNum" x-optionalDataType: "String" - name: "lang" in: "query" required: false type: "string" x-exportParamName: "Lang" x-optionalDataType: "String" - name: "status.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "StatusProgress" x-optionalDataType: "String" - name: "status.note" in: "query" required: false type: "string" x-exportParamName: "StatusNote" x-optionalDataType: "String" - name: "en" in: "query" required: false type: "string" format: "int64" x-exportParamName: "En" x-optionalDataType: "String" - name: "no.progress" in: "query" required: false type: "string" format: "int64" x-exportParamName: "NoProgress" x-optionalDataType: "String" - name: "no.note" in: "query" required: false type: "string" x-exportParamName: "NoNote" x-optionalDataType: "String" - name: "resourceId" in: "query" required: false type: "string" x-exportParamName: "ResourceId" x-optionalDataType: "String" - name: "nId.nId" in: "query" required: false type: "string" x-exportParamName: "NIdNId" x-optionalDataType: "String" - name: "nId.val" in: "query" required: false type: "string" x-exportParamName: "NIdVal" x-optionalDataType: "String" responses: 200: description: "A successful response." schema: $ref: "#/definitions/examplepbUnannotatedSimpleMessage" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" default: description: "An unexpected error response." schema: $ref: "#/definitions/rpcStatus" /v1/example/echo_nested: put: tags: - "UnannotatedEchoService" summary: "EchoNested method receives a simple message and returns it." operationId: "UnannotatedEchoService_EchoNested" parameters: - in: "body" name: "body" description: "A simple message with many types" required: true schema: $ref: "#/definitions/examplepbUnannotatedSimpleMessage" x-exportParamName: "Body" responses: 200: description: "" schema: $ref: "#/definitions/examplepbUnannotatedNestedMessage" 403: description: "Returned when the user does not have permission to access\ \ the resource." schema: {} 404: description: "Returned when the resource does not exist." schema: type: "string" format: "string" default: description: "An unexpected error response." schema: $ref: "#/definitions/rpcStatus" securityDefinitions: ApiKeyAuth: type: "apiKey" name: "X-API-Key" in: "header" x-amazon-apigateway-authorizer: authorizerResultTtlInSeconds: 60 type: "token" x-amazon-apigateway-authtype: "oauth2" BasicAuth: type: "basic" definitions: examplepbUnannotatedEmbedded: type: "object" properties: progress: type: "string" format: "int64" note: type: "string" description: "Embedded represents a message embedded in SimpleMessage." x-go-type: import: package: "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb" type: "UnannotatedEmbedded" examplepbUnannotatedNestedMessage: type: "object" properties: nId: type: "string" val: type: "string" example: val: "val" nId: "nId" x-go-type: import: package: "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb" type: "UnannotatedNestedMessage" examplepbUnannotatedSimpleMessage: type: "object" required: - "id" - "num" properties: id: type: "string" description: "Id represents the message identifier." num: type: "string" format: "int64" description: "Int value field" default: "42" duration: type: "string" lineNum: type: "string" format: "int64" lang: type: "string" status: $ref: "#/definitions/examplepbUnannotatedEmbedded" en: type: "string" format: "int64" "no": $ref: "#/definitions/examplepbUnannotatedEmbedded" resourceId: type: "string" nId: $ref: "#/definitions/examplepbUnannotatedNestedMessage" externalDocs: description: "Find out more about UnannotatedSimpleMessage" url: "https://github.com/grpc-ecosystem/grpc-gateway" title: "A bit of everything" description: "A simple message with many types" example: id: "myid" protobufAny: type: "object" properties: '@type': type: "string" additionalProperties: {} x-go-type: import: package: "google.golang.org/protobuf/types/known/anypb" type: "Any" rpcStatus: type: "object" properties: code: type: "integer" format: "int32" message: type: "string" details: type: "array" items: $ref: "#/definitions/protobufAny" x-go-type: import: package: "google.golang.org/genproto/googleapis/rpc/status" type: "Status" externalDocs: description: "More about gRPC-Gateway" url: "https://github.com/grpc-ecosystem/grpc-gateway" x-grpc-gateway-baz-list: - "one" - true x-grpc-gateway-foo: "bar" ================================================ FILE: examples/internal/clients/unannotatedecho/api_unannotated_echo_service.go ================================================ /* * Unannotated Echo * * Unannotated Echo Service Similar to echo_service.proto but without annotations. See unannotated_echo_service.yaml for the equivalent of the annotations in gRPC API configuration format. Echo Service API consists of a single service which returns a message. * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package unannotatedecho import ( "context" "io/ioutil" "net/http" "net/url" "strings" "fmt" "github.com/antihax/optional" ) // Linger please var ( _ context.Context ) type UnannotatedEchoServiceApiService service /* UnannotatedEchoServiceApiService Summary: Echo rpc Description Echo * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param id Id represents the message identifier. * @param num Int value field * @param optional nil or *UnannotatedEchoServiceEchoOpts - Optional Parameters: * @param "Duration" (optional.String) - * @param "LineNum" (optional.String) - * @param "Lang" (optional.String) - * @param "StatusProgress" (optional.String) - * @param "StatusNote" (optional.String) - * @param "En" (optional.String) - * @param "NoProgress" (optional.String) - * @param "NoNote" (optional.String) - * @param "ResourceId" (optional.String) - * @param "NIdNId" (optional.String) - * @param "NIdVal" (optional.String) - @return ExamplepbUnannotatedSimpleMessage */ type UnannotatedEchoServiceEchoOpts struct { Duration optional.String LineNum optional.String Lang optional.String StatusProgress optional.String StatusNote optional.String En optional.String NoProgress optional.String NoNote optional.String ResourceId optional.String NIdNId optional.String NIdVal optional.String } func (a *UnannotatedEchoServiceApiService) UnannotatedEchoServiceEcho(ctx context.Context, id string, num string, localVarOptionals *UnannotatedEchoServiceEchoOpts) (ExamplepbUnannotatedSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbUnannotatedSimpleMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/echo/{id}" localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} localVarQueryParams.Add("num", parameterToString(num, "")) if localVarOptionals != nil && localVarOptionals.Duration.IsSet() { localVarQueryParams.Add("duration", parameterToString(localVarOptionals.Duration.Value(), "")) } if localVarOptionals != nil && localVarOptionals.LineNum.IsSet() { localVarQueryParams.Add("lineNum", parameterToString(localVarOptionals.LineNum.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Lang.IsSet() { localVarQueryParams.Add("lang", parameterToString(localVarOptionals.Lang.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusProgress.IsSet() { localVarQueryParams.Add("status.progress", parameterToString(localVarOptionals.StatusProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusNote.IsSet() { localVarQueryParams.Add("status.note", parameterToString(localVarOptionals.StatusNote.Value(), "")) } if localVarOptionals != nil && localVarOptionals.En.IsSet() { localVarQueryParams.Add("en", parameterToString(localVarOptionals.En.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoProgress.IsSet() { localVarQueryParams.Add("no.progress", parameterToString(localVarOptionals.NoProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoNote.IsSet() { localVarQueryParams.Add("no.note", parameterToString(localVarOptionals.NoNote.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ResourceId.IsSet() { localVarQueryParams.Add("resourceId", parameterToString(localVarOptionals.ResourceId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdNId.IsSet() { localVarQueryParams.Add("nId.nId", parameterToString(localVarOptionals.NIdNId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdVal.IsSet() { localVarQueryParams.Add("nId.val", parameterToString(localVarOptionals.NIdVal.Value(), "")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbUnannotatedSimpleMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v int32 err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 503 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v RpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* UnannotatedEchoServiceApiService Summary: Echo rpc Description Echo * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param id Id represents the message identifier. * @param num Int value field * @param optional nil or *UnannotatedEchoServiceEcho2Opts - Optional Parameters: * @param "Duration" (optional.String) - * @param "LineNum" (optional.String) - * @param "Lang" (optional.String) - * @param "StatusProgress" (optional.String) - * @param "StatusNote" (optional.String) - * @param "En" (optional.String) - * @param "NoProgress" (optional.String) - * @param "NoNote" (optional.String) - * @param "ResourceId" (optional.String) - * @param "NIdNId" (optional.String) - * @param "NIdVal" (optional.String) - @return ExamplepbUnannotatedSimpleMessage */ type UnannotatedEchoServiceEcho2Opts struct { Duration optional.String LineNum optional.String Lang optional.String StatusProgress optional.String StatusNote optional.String En optional.String NoProgress optional.String NoNote optional.String ResourceId optional.String NIdNId optional.String NIdVal optional.String } func (a *UnannotatedEchoServiceApiService) UnannotatedEchoServiceEcho2(ctx context.Context, id string, num string, localVarOptionals *UnannotatedEchoServiceEcho2Opts) (ExamplepbUnannotatedSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbUnannotatedSimpleMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/echo/{id}/{num}" localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) localVarPath = strings.Replace(localVarPath, "{"+"num"+"}", fmt.Sprintf("%v", num), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.Duration.IsSet() { localVarQueryParams.Add("duration", parameterToString(localVarOptionals.Duration.Value(), "")) } if localVarOptionals != nil && localVarOptionals.LineNum.IsSet() { localVarQueryParams.Add("lineNum", parameterToString(localVarOptionals.LineNum.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Lang.IsSet() { localVarQueryParams.Add("lang", parameterToString(localVarOptionals.Lang.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusProgress.IsSet() { localVarQueryParams.Add("status.progress", parameterToString(localVarOptionals.StatusProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusNote.IsSet() { localVarQueryParams.Add("status.note", parameterToString(localVarOptionals.StatusNote.Value(), "")) } if localVarOptionals != nil && localVarOptionals.En.IsSet() { localVarQueryParams.Add("en", parameterToString(localVarOptionals.En.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoProgress.IsSet() { localVarQueryParams.Add("no.progress", parameterToString(localVarOptionals.NoProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoNote.IsSet() { localVarQueryParams.Add("no.note", parameterToString(localVarOptionals.NoNote.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ResourceId.IsSet() { localVarQueryParams.Add("resourceId", parameterToString(localVarOptionals.ResourceId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdNId.IsSet() { localVarQueryParams.Add("nId.nId", parameterToString(localVarOptionals.NIdNId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdVal.IsSet() { localVarQueryParams.Add("nId.val", parameterToString(localVarOptionals.NIdVal.Value(), "")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbUnannotatedSimpleMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v int32 err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 503 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v RpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* UnannotatedEchoServiceApiService EchoBody method receives a simple message and returns it. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param body A simple message with many types @return ExamplepbUnannotatedSimpleMessage */ func (a *UnannotatedEchoServiceApiService) UnannotatedEchoServiceEchoBody(ctx context.Context, body ExamplepbUnannotatedSimpleMessage) (ExamplepbUnannotatedSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbUnannotatedSimpleMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/echo_body" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbUnannotatedSimpleMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v RpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* UnannotatedEchoServiceApiService EchoDelete method receives a simple message and returns it. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param num Int value field * @param optional nil or *UnannotatedEchoServiceEchoDeleteOpts - Optional Parameters: * @param "Id" (optional.String) - Id represents the message identifier. * @param "Duration" (optional.String) - * @param "LineNum" (optional.String) - * @param "Lang" (optional.String) - * @param "StatusProgress" (optional.String) - * @param "StatusNote" (optional.String) - * @param "En" (optional.String) - * @param "NoProgress" (optional.String) - * @param "NoNote" (optional.String) - * @param "ResourceId" (optional.String) - * @param "NIdNId" (optional.String) - * @param "NIdVal" (optional.String) - @return ExamplepbUnannotatedSimpleMessage */ type UnannotatedEchoServiceEchoDeleteOpts struct { Id optional.String Duration optional.String LineNum optional.String Lang optional.String StatusProgress optional.String StatusNote optional.String En optional.String NoProgress optional.String NoNote optional.String ResourceId optional.String NIdNId optional.String NIdVal optional.String } func (a *UnannotatedEchoServiceApiService) UnannotatedEchoServiceEchoDelete(ctx context.Context, num string, localVarOptionals *UnannotatedEchoServiceEchoDeleteOpts) (ExamplepbUnannotatedSimpleMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Delete") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbUnannotatedSimpleMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/echo_delete" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if localVarOptionals != nil && localVarOptionals.Id.IsSet() { localVarQueryParams.Add("id", parameterToString(localVarOptionals.Id.Value(), "")) } localVarQueryParams.Add("num", parameterToString(num, "")) if localVarOptionals != nil && localVarOptionals.Duration.IsSet() { localVarQueryParams.Add("duration", parameterToString(localVarOptionals.Duration.Value(), "")) } if localVarOptionals != nil && localVarOptionals.LineNum.IsSet() { localVarQueryParams.Add("lineNum", parameterToString(localVarOptionals.LineNum.Value(), "")) } if localVarOptionals != nil && localVarOptionals.Lang.IsSet() { localVarQueryParams.Add("lang", parameterToString(localVarOptionals.Lang.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusProgress.IsSet() { localVarQueryParams.Add("status.progress", parameterToString(localVarOptionals.StatusProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.StatusNote.IsSet() { localVarQueryParams.Add("status.note", parameterToString(localVarOptionals.StatusNote.Value(), "")) } if localVarOptionals != nil && localVarOptionals.En.IsSet() { localVarQueryParams.Add("en", parameterToString(localVarOptionals.En.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoProgress.IsSet() { localVarQueryParams.Add("no.progress", parameterToString(localVarOptionals.NoProgress.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NoNote.IsSet() { localVarQueryParams.Add("no.note", parameterToString(localVarOptionals.NoNote.Value(), "")) } if localVarOptionals != nil && localVarOptionals.ResourceId.IsSet() { localVarQueryParams.Add("resourceId", parameterToString(localVarOptionals.ResourceId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdNId.IsSet() { localVarQueryParams.Add("nId.nId", parameterToString(localVarOptionals.NIdNId.Value(), "")) } if localVarOptionals != nil && localVarOptionals.NIdVal.IsSet() { localVarQueryParams.Add("nId.val", parameterToString(localVarOptionals.NIdVal.Value(), "")) } // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbUnannotatedSimpleMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v RpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } /* UnannotatedEchoServiceApiService EchoNested method receives a simple message and returns it. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param body A simple message with many types @return ExamplepbUnannotatedNestedMessage */ func (a *UnannotatedEchoServiceApiService) UnannotatedEchoServiceEchoNested(ctx context.Context, body ExamplepbUnannotatedSimpleMessage) (ExamplepbUnannotatedNestedMessage, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Put") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte localVarReturnValue ExamplepbUnannotatedNestedMessage ) // create path and map variables localVarPath := a.client.cfg.BasePath + "/v1/example/echo_nested" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json", "application/x-foo-mime"} // set Content-Type header localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) if localVarHttpContentType != "" { localVarHeaderParams["Content-Type"] = localVarHttpContentType } // to determine the Accept header localVarHttpHeaderAccepts := []string{"application/json", "application/x-foo-mime"} // set Accept header localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } // body params localVarPostBody = &body if ctx != nil { // API Key Authentication if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { var key string if auth.Prefix != "" { key = auth.Prefix + " " + auth.Key } else { key = auth.Key } localVarHeaderParams["X-API-Key"] = key } } r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) if err != nil { return localVarReturnValue, nil, err } localVarHttpResponse, err := a.client.callAPI(r) if err != nil || localVarHttpResponse == nil { return localVarReturnValue, localVarHttpResponse, err } localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) localVarHttpResponse.Body.Close() if err != nil { return localVarReturnValue, localVarHttpResponse, err } if localVarHttpResponse.StatusCode < 300 { // If we succeed, return the data, otherwise pass on to decode error. err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err == nil { return localVarReturnValue, localVarHttpResponse, err } } if localVarHttpResponse.StatusCode >= 300 { newErr := GenericSwaggerError{ body: localVarBody, error: localVarHttpResponse.Status, } if localVarHttpResponse.StatusCode == 200 { var v ExamplepbUnannotatedNestedMessage err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 403 { var v interface{} err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 404 { var v string err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } if localVarHttpResponse.StatusCode == 0 { var v RpcStatus err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHttpResponse, newErr } newErr.model = v return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, newErr } return localVarReturnValue, localVarHttpResponse, nil } ================================================ FILE: examples/internal/clients/unannotatedecho/client.go ================================================ /* * Unannotated Echo * * Unannotated Echo Service Similar to echo_service.proto but without annotations. See unannotated_echo_service.yaml for the equivalent of the annotations in gRPC API configuration format. Echo Service API consists of a single service which returns a message. * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package unannotatedecho import ( "bytes" "context" "encoding/json" "encoding/xml" "errors" "fmt" "io" "mime/multipart" "net/http" "net/url" "os" "path/filepath" "reflect" "regexp" "strconv" "strings" "time" "unicode/utf8" "golang.org/x/oauth2" ) var ( jsonCheck = regexp.MustCompile("(?i:[application|text]/json)") xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)") ) // APIClient manages communication with the Unannotated Echo API v1.0 // In most cases there should be only one, shared, APIClient. type APIClient struct { cfg *Configuration common service // Reuse a single struct instead of allocating one for each service on the heap. // API Services UnannotatedEchoServiceApi *UnannotatedEchoServiceApiService } type service struct { client *APIClient } // NewAPIClient creates a new API client. Requires a userAgent string describing your application. // optionally a custom http.Client to allow for advanced features such as caching. func NewAPIClient(cfg *Configuration) *APIClient { if cfg.HTTPClient == nil { cfg.HTTPClient = http.DefaultClient } c := &APIClient{} c.cfg = cfg c.common.client = c // API Services c.UnannotatedEchoServiceApi = (*UnannotatedEchoServiceApiService)(&c.common) return c } func atoi(in string) (int, error) { return strconv.Atoi(in) } // selectHeaderContentType select a content type from the available list. func selectHeaderContentType(contentTypes []string) string { if len(contentTypes) == 0 { return "" } if contains(contentTypes, "application/json") { return "application/json" } return contentTypes[0] // use the first content type specified in 'consumes' } // selectHeaderAccept join all accept types and return func selectHeaderAccept(accepts []string) string { if len(accepts) == 0 { return "" } if contains(accepts, "application/json") { return "application/json" } return strings.Join(accepts, ",") } // contains is a case insenstive match, finding needle in a haystack func contains(haystack []string, needle string) bool { for _, a := range haystack { if strings.ToLower(a) == strings.ToLower(needle) { return true } } return false } // Verify optional parameters are of the correct type. func typeCheckParameter(obj interface{}, expected string, name string) error { // Make sure there is an object. if obj == nil { return nil } // Check the type is as expected. if reflect.TypeOf(obj).String() != expected { return fmt.Errorf("Expected %s to be of type %s but received %s.", name, expected, reflect.TypeOf(obj).String()) } return nil } // parameterToString convert interface{} parameters to string, using a delimiter if format is provided. func parameterToString(obj interface{}, collectionFormat string) string { var delimiter string switch collectionFormat { case "pipes": delimiter = "|" case "ssv": delimiter = " " case "tsv": delimiter = "\t" case "csv": delimiter = "," } if reflect.TypeOf(obj).Kind() == reflect.Slice { return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]") } return fmt.Sprintf("%v", obj) } // callAPI do the request. func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) { return c.cfg.HTTPClient.Do(request) } // Change base path to allow switching to mocks func (c *APIClient) ChangeBasePath(path string) { c.cfg.BasePath = path } // prepareRequest build the request func (c *APIClient) prepareRequest( ctx context.Context, path string, method string, postBody interface{}, headerParams map[string]string, queryParams url.Values, formParams url.Values, fileName string, fileBytes []byte) (localVarRequest *http.Request, err error) { var body *bytes.Buffer // Detect postBody type and post. if postBody != nil { contentType := headerParams["Content-Type"] if contentType == "" { contentType = detectContentType(postBody) headerParams["Content-Type"] = contentType } body, err = setBody(postBody, contentType) if err != nil { return nil, err } } // add form parameters and file if available. if len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") { if body != nil { return nil, errors.New("Cannot specify postBody and multipart form at the same time.") } body = &bytes.Buffer{} w := multipart.NewWriter(body) for k, v := range formParams { for _, iv := range v { if strings.HasPrefix(k, "@") { // file err = addFile(w, k[1:], iv) if err != nil { return nil, err } } else { // form value w.WriteField(k, iv) } } } if len(fileBytes) > 0 && fileName != "" { w.Boundary() //_, fileNm := filepath.Split(fileName) part, err := w.CreateFormFile("file", filepath.Base(fileName)) if err != nil { return nil, err } _, err = part.Write(fileBytes) if err != nil { return nil, err } // Set the Boundary in the Content-Type headerParams["Content-Type"] = w.FormDataContentType() } // Set Content-Length headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) w.Close() } // Setup path and query parameters url, err := url.Parse(path) if err != nil { return nil, err } // Adding Query Param query := url.Query() for k, v := range queryParams { for _, iv := range v { query.Add(k, iv) } } // Encode the parameters. url.RawQuery = query.Encode() // Generate a new request if body != nil { localVarRequest, err = http.NewRequest(method, url.String(), body) } else { localVarRequest, err = http.NewRequest(method, url.String(), nil) } if err != nil { return nil, err } // add header parameters, if any if len(headerParams) > 0 { headers := http.Header{} for h, v := range headerParams { headers.Set(h, v) } localVarRequest.Header = headers } // Override request host, if applicable if c.cfg.Host != "" { localVarRequest.Host = c.cfg.Host } // Add the user agent to the request. localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) if ctx != nil { // add context to the request localVarRequest = localVarRequest.WithContext(ctx) // Walk through any authentication. // OAuth2 authentication if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok { // We were able to grab an oauth2 token from the context var latestToken *oauth2.Token if latestToken, err = tok.Token(); err != nil { return nil, err } latestToken.SetAuthHeader(localVarRequest) } // Basic HTTP Authentication if auth, ok := ctx.Value(ContextBasicAuth).(BasicAuth); ok { localVarRequest.SetBasicAuth(auth.UserName, auth.Password) } // AccessToken Authentication if auth, ok := ctx.Value(ContextAccessToken).(string); ok { localVarRequest.Header.Add("Authorization", "Bearer "+auth) } } for header, value := range c.cfg.DefaultHeader { localVarRequest.Header.Add(header, value) } return localVarRequest, nil } func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { if strings.Contains(contentType, "application/xml") { if err = xml.Unmarshal(b, v); err != nil { return err } return nil } else if strings.Contains(contentType, "application/json") { if err = json.Unmarshal(b, v); err != nil { return err } return nil } return errors.New("undefined response type") } // Add a file to the multipart request func addFile(w *multipart.Writer, fieldName, path string) error { file, err := os.Open(path) if err != nil { return err } defer file.Close() part, err := w.CreateFormFile(fieldName, filepath.Base(path)) if err != nil { return err } _, err = io.Copy(part, file) return err } // Prevent trying to import "fmt" func reportError(format string, a ...interface{}) error { return fmt.Errorf(format, a...) } // Set request body from an interface{} func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { if bodyBuf == nil { bodyBuf = &bytes.Buffer{} } if reader, ok := body.(io.Reader); ok { _, err = bodyBuf.ReadFrom(reader) } else if b, ok := body.([]byte); ok { _, err = bodyBuf.Write(b) } else if s, ok := body.(string); ok { _, err = bodyBuf.WriteString(s) } else if s, ok := body.(*string); ok { _, err = bodyBuf.WriteString(*s) } else if jsonCheck.MatchString(contentType) { err = json.NewEncoder(bodyBuf).Encode(body) } else if xmlCheck.MatchString(contentType) { xml.NewEncoder(bodyBuf).Encode(body) } if err != nil { return nil, err } if bodyBuf.Len() == 0 { err = fmt.Errorf("Invalid body type %s\n", contentType) return nil, err } return bodyBuf, nil } // detectContentType method is used to figure out `Request.Body` content type for request header func detectContentType(body interface{}) string { contentType := "text/plain; charset=utf-8" kind := reflect.TypeOf(body).Kind() switch kind { case reflect.Struct, reflect.Map, reflect.Ptr: contentType = "application/json; charset=utf-8" case reflect.String: contentType = "text/plain; charset=utf-8" default: if b, ok := body.([]byte); ok { contentType = http.DetectContentType(b) } else if kind == reflect.Slice { contentType = "application/json; charset=utf-8" } } return contentType } // Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go type cacheControl map[string]string func parseCacheControl(headers http.Header) cacheControl { cc := cacheControl{} ccHeader := headers.Get("Cache-Control") for _, part := range strings.Split(ccHeader, ",") { part = strings.Trim(part, " ") if part == "" { continue } if strings.ContainsRune(part, '=') { keyval := strings.Split(part, "=") cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") } else { cc[part] = "" } } return cc } // CacheExpires helper function to determine remaining time before repeating a request. func CacheExpires(r *http.Response) time.Time { // Figure out when the cache expires. var expires time.Time now, err := time.Parse(time.RFC1123, r.Header.Get("date")) if err != nil { return time.Now() } respCacheControl := parseCacheControl(r.Header) if maxAge, ok := respCacheControl["max-age"]; ok { lifetime, err := time.ParseDuration(maxAge + "s") if err != nil { expires = now } expires = now.Add(lifetime) } else { expiresHeader := r.Header.Get("Expires") if expiresHeader != "" { expires, err = time.Parse(time.RFC1123, expiresHeader) if err != nil { expires = now } } } return expires } func strlen(s string) int { return utf8.RuneCountInString(s) } // GenericSwaggerError Provides access to the body, error and model on returned errors. type GenericSwaggerError struct { body []byte error string model interface{} } // Error returns non-empty string if there was an error. func (e GenericSwaggerError) Error() string { return e.error } // Body returns the raw bytes of the response func (e GenericSwaggerError) Body() []byte { return e.body } // Model returns the unpacked model of the error func (e GenericSwaggerError) Model() interface{} { return e.model } ================================================ FILE: examples/internal/clients/unannotatedecho/configuration.go ================================================ /* * Unannotated Echo * * Unannotated Echo Service Similar to echo_service.proto but without annotations. See unannotated_echo_service.yaml for the equivalent of the annotations in gRPC API configuration format. Echo Service API consists of a single service which returns a message. * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package unannotatedecho import ( "net/http" ) // contextKeys are used to identify the type of value in the context. // Since these are string, it is possible to get a short description of the // context key for logging and debugging using key.String(). type contextKey string func (c contextKey) String() string { return "auth " + string(c) } var ( // ContextOAuth2 takes a oauth2.TokenSource as authentication for the request. ContextOAuth2 = contextKey("token") // ContextBasicAuth takes BasicAuth as authentication for the request. ContextBasicAuth = contextKey("basic") // ContextAccessToken takes a string oauth2 access token as authentication for the request. ContextAccessToken = contextKey("accesstoken") // ContextAPIKey takes an APIKey as authentication for the request ContextAPIKey = contextKey("apikey") ) // BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth type BasicAuth struct { UserName string `json:"userName,omitempty"` Password string `json:"password,omitempty"` } // APIKey provides API key based authentication to a request passed via context using ContextAPIKey type APIKey struct { Key string Prefix string } type Configuration struct { BasePath string `json:"basePath,omitempty"` Host string `json:"host,omitempty"` Scheme string `json:"scheme,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"` UserAgent string `json:"userAgent,omitempty"` HTTPClient *http.Client } func NewConfiguration() *Configuration { cfg := &Configuration{ BasePath: "http://localhost", DefaultHeader: make(map[string]string), UserAgent: "Swagger-Codegen/1.0.0/go", } return cfg } func (c *Configuration) AddDefaultHeader(key string, value string) { c.DefaultHeader[key] = value } ================================================ FILE: examples/internal/clients/unannotatedecho/model_examplepb_numeric_enum.go ================================================ /* * Unannotated Echo * * Unannotated Echo Service Similar to echo_service.proto but without annotations. See unannotated_echo_service.yaml for the equivalent of the annotations in gRPC API configuration format. Echo Service API consists of a single service which returns a message. * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package unannotatedecho // ExamplepbNumericEnum : NumericEnum is one or zero. - ZERO: ZERO means 0 - ONE: ONE means 1 type ExamplepbNumericEnum string // List of examplepbNumericEnum const ( ZERO_ExamplepbNumericEnum ExamplepbNumericEnum = "ZERO" ONE_ExamplepbNumericEnum ExamplepbNumericEnum = "ONE" ) ================================================ FILE: examples/internal/clients/unannotatedecho/model_examplepb_unannotated_embedded.go ================================================ /* * Unannotated Echo * * Unannotated Echo Service Similar to echo_service.proto but without annotations. See unannotated_echo_service.yaml for the equivalent of the annotations in gRPC API configuration format. Echo Service API consists of a single service which returns a message. * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package unannotatedecho // Embedded represents a message embedded in SimpleMessage. type ExamplepbUnannotatedEmbedded struct { Progress string `json:"progress,omitempty"` Note string `json:"note,omitempty"` } ================================================ FILE: examples/internal/clients/unannotatedecho/model_examplepb_unannotated_nested_message.go ================================================ /* * Unannotated Echo * * Unannotated Echo Service Similar to echo_service.proto but without annotations. See unannotated_echo_service.yaml for the equivalent of the annotations in gRPC API configuration format. Echo Service API consists of a single service which returns a message. * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package unannotatedecho type ExamplepbUnannotatedNestedMessage struct { NId string `json:"nId,omitempty"` Val string `json:"val,omitempty"` } ================================================ FILE: examples/internal/clients/unannotatedecho/model_examplepb_unannotated_simple_message.go ================================================ /* * Unannotated Echo * * Unannotated Echo Service Similar to echo_service.proto but without annotations. See unannotated_echo_service.yaml for the equivalent of the annotations in gRPC API configuration format. Echo Service API consists of a single service which returns a message. * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package unannotatedecho // A simple message with many types type ExamplepbUnannotatedSimpleMessage struct { // Id represents the message identifier. Id string `json:"id"` // Int value field Num string `json:"num"` Duration string `json:"duration,omitempty"` LineNum string `json:"lineNum,omitempty"` Lang string `json:"lang,omitempty"` Status *ExamplepbUnannotatedEmbedded `json:"status,omitempty"` En string `json:"en,omitempty"` No *ExamplepbUnannotatedEmbedded `json:"no,omitempty"` ResourceId string `json:"resourceId,omitempty"` NId *ExamplepbUnannotatedNestedMessage `json:"nId,omitempty"` } ================================================ FILE: examples/internal/clients/unannotatedecho/model_protobuf_any.go ================================================ /* * Unannotated Echo * * Unannotated Echo Service Similar to echo_service.proto but without annotations. See unannotated_echo_service.yaml for the equivalent of the annotations in gRPC API configuration format. Echo Service API consists of a single service which returns a message. * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package unannotatedecho type ProtobufAny struct { Type_ string `json:"@type,omitempty"` } ================================================ FILE: examples/internal/clients/unannotatedecho/model_rpc_status.go ================================================ /* * Unannotated Echo * * Unannotated Echo Service Similar to echo_service.proto but without annotations. See unannotated_echo_service.yaml for the equivalent of the annotations in gRPC API configuration format. Echo Service API consists of a single service which returns a message. * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package unannotatedecho type RpcStatus struct { Code int32 `json:"code,omitempty"` Message string `json:"message,omitempty"` Details []ProtobufAny `json:"details,omitempty"` } ================================================ FILE: examples/internal/clients/unannotatedecho/response.go ================================================ /* * Unannotated Echo * * Unannotated Echo Service Similar to echo_service.proto but without annotations. See unannotated_echo_service.yaml for the equivalent of the annotations in gRPC API configuration format. Echo Service API consists of a single service which returns a message. * * API version: 1.0 * Contact: none@example.com * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package unannotatedecho import ( "net/http" ) type APIResponse struct { *http.Response `json:"-"` Message string `json:"message,omitempty"` // Operation is the name of the swagger operation. Operation string `json:"operation,omitempty"` // RequestURL is the request URL. This value is always available, even if the // embedded *http.Response is nil. RequestURL string `json:"url,omitempty"` // Method is the HTTP method used for the request. This value is always // available, even if the embedded *http.Response is nil. Method string `json:"method,omitempty"` // Payload holds the contents of the response body (which may be nil or empty). // This is provided here as the raw response.Body() reader will have already // been drained. Payload []byte `json:"-"` } func NewAPIResponse(r *http.Response) *APIResponse { response := &APIResponse{Response: r} return response } func NewAPIResponseWithError(errorMessage string) *APIResponse { response := &APIResponse{Message: errorMessage} return response } ================================================ FILE: examples/internal/cmd/example-gateway-server/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") go_library( name = "example-gateway-server_lib", srcs = ["main.go"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/cmd/example-gateway-server", visibility = ["//visibility:private"], deps = [ "//examples/internal/gateway", "@org_golang_google_grpc//grpclog", ], ) go_binary( name = "example-gateway-server", embed = [":example-gateway-server_lib"], visibility = ["//visibility:public"], ) ================================================ FILE: examples/internal/cmd/example-gateway-server/main.go ================================================ /* Command example-gateway-server is an example reverse-proxy implementation whose HTTP handler is generated by grpc-gateway. */ package main import ( "context" "flag" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/gateway" "google.golang.org/grpc/grpclog" ) var ( endpoint = flag.String("endpoint", "localhost:9090", "endpoint of the gRPC service") network = flag.String("network", "tcp", `one of "tcp" or "unix". Must be consistent to -endpoint`) openAPIDir = flag.String("openapi_dir", "examples/internal/proto/examplepb", "path to the directory which contains OpenAPI definitions") ) func main() { flag.Parse() ctx := context.Background() opts := gateway.Options{ Addr: ":8080", GRPCServer: gateway.Endpoint{ Network: *network, Addr: *endpoint, }, OpenAPIDir: *openAPIDir, } if err := gateway.Run(ctx, opts); err != nil { grpclog.Fatal(err) } } ================================================ FILE: examples/internal/cmd/example-grpc-server/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") package(default_visibility = ["//visibility:private"]) go_library( name = "example-grpc-server_lib", srcs = ["main.go"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/cmd/example-grpc-server", deps = [ "//examples/internal/server", "@org_golang_google_grpc//grpclog", ], ) go_binary( name = "example-server", embed = [":example-grpc-server_lib"], visibility = ["//visibility:public"], ) ================================================ FILE: examples/internal/cmd/example-grpc-server/main.go ================================================ /* Command example-grpc-server is an example grpc server to be called by example-gateway-server. */ package main import ( "context" "flag" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/server" "google.golang.org/grpc/grpclog" ) var ( addr = flag.String("addr", ":9090", "endpoint of the gRPC service") network = flag.String("network", "tcp", "a valid network type which is consistent to -addr") ) func main() { flag.Parse() ctx := context.Background() if err := server.Run(ctx, *network, *addr); err != nil { grpclog.Fatal(err) } } ================================================ FILE: examples/internal/gateway/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "gateway", srcs = [ "doc.go", "gateway.go", "handlers.go", "main.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/gateway", visibility = ["//visibility:public"], deps = [ "//examples/internal/proto/examplepb", "//examples/internal/proto/standalone", "//runtime", "@org_golang_google_genproto_googleapis_rpc//errdetails", "@org_golang_google_grpc//:grpc", "@org_golang_google_grpc//connectivity", "@org_golang_google_grpc//credentials/insecure", "@org_golang_google_grpc//grpclog", "@org_golang_google_protobuf//types/known/emptypb", ], ) alias( name = "go_default_library", actual = ":gateway", visibility = ["//examples:__subpackages__"], ) ================================================ FILE: examples/internal/gateway/doc.go ================================================ // Package gateway is an example of gRPC-Gateway server package gateway ================================================ FILE: examples/internal/gateway/gateway.go ================================================ package gateway import ( "context" "fmt" "net" "net/http" "google.golang.org/grpc/credentials/insecure" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb" standalone "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/standalone" gwruntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" _ "google.golang.org/genproto/googleapis/rpc/errdetails" "google.golang.org/grpc" ) // newGateway returns a new gateway server which translates HTTP into gRPC. func newGateway(ctx context.Context, conn *grpc.ClientConn, opts []gwruntime.ServeMuxOption) (http.Handler, error) { mux := gwruntime.NewServeMux(opts...) for _, f := range []func(context.Context, *gwruntime.ServeMux, *grpc.ClientConn) error{ examplepb.RegisterEchoServiceHandler, standalone.RegisterUnannotatedEchoServiceHandler, examplepb.RegisterStreamServiceHandler, examplepb.RegisterABitOfEverythingServiceHandler, examplepb.RegisterFlowCombinationHandler, examplepb.RegisterExcessBodyServiceHandler, examplepb.RegisterNonStandardServiceHandler, examplepb.RegisterResponseBodyServiceHandler, } { if err := f(ctx, mux, conn); err != nil { return nil, err } } return mux, nil } func dial(network, addr string) (*grpc.ClientConn, error) { switch network { case "tcp": return dialTCP(addr) case "unix": return dialUnix(addr) default: return nil, fmt.Errorf("unsupported network type %q", network) } } // dialTCP creates a client connection via TCP. // "addr" must be a valid TCP address with a port number. func dialTCP(addr string) (*grpc.ClientConn, error) { return grpc.NewClient(addr, grpc.WithTransportCredentials(insecure.NewCredentials())) } // dialUnix creates a client connection via a unix domain socket. // "addr" must be a valid path to the socket. func dialUnix(addr string) (*grpc.ClientConn, error) { d := func(ctx context.Context, addr string) (net.Conn, error) { return (&net.Dialer{}).DialContext(ctx, "unix", addr) } return grpc.NewClient(addr, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithContextDialer(d)) } ================================================ FILE: examples/internal/gateway/handlers.go ================================================ package gateway import ( "bytes" "fmt" "io" "net/http" "path" "strings" "google.golang.org/grpc" "google.golang.org/grpc/connectivity" "google.golang.org/grpc/grpclog" "google.golang.org/protobuf/types/known/emptypb" ) // openAPIServer returns OpenAPI specification files located under "/openapiv2/" func openAPIServer(dir string) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if !strings.HasSuffix(r.URL.Path, ".swagger.json") { grpclog.Errorf("Not Found: %s", r.URL.Path) http.NotFound(w, r) return } grpclog.Infof("Serving %s", r.URL.Path) p := strings.TrimPrefix(r.URL.Path, "/openapiv2/") p = path.Join(dir, p) http.ServeFile(w, r, p) } } // allowCORS allows Cross Origin Resource Sharing from any origin. // Don't do this without consideration in production systems. func allowCORS(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if origin := r.Header.Get("Origin"); origin != "" { w.Header().Set("Access-Control-Allow-Origin", origin) if r.Method == "OPTIONS" && r.Header.Get("Access-Control-Request-Method") != "" { preflightHandler(w, r) return } } h.ServeHTTP(w, r) }) } // preflightHandler adds the necessary headers in order to serve // CORS from any origin using the methods "GET", "HEAD", "POST", "PUT", "DELETE" // We insist, don't do this without consideration in production systems. func preflightHandler(w http.ResponseWriter, r *http.Request) { headers := []string{"Content-Type", "Accept", "Authorization"} w.Header().Set("Access-Control-Allow-Headers", strings.Join(headers, ",")) methods := []string{"GET", "HEAD", "POST", "PUT", "DELETE"} w.Header().Set("Access-Control-Allow-Methods", strings.Join(methods, ",")) grpclog.Infof("Preflight request for %s", r.URL.Path) } // healthzServer returns a simple health handler which returns ok. func healthzServer(conn *grpc.ClientConn) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain") if s := conn.GetState(); s == connectivity.Idle { // Invoke method to move connection from Idle to Ready conn.Invoke(r.Context(), "/grpc.health.v1.Health/Check", &emptypb.Empty{}, &emptypb.Empty{}) } if s := conn.GetState(); s != connectivity.Ready { http.Error(w, fmt.Sprintf("grpc server is %s", s), http.StatusBadGateway) return } fmt.Fprintln(w, "ok") } } type logResponseWriter struct { http.ResponseWriter statusCode int } func (rsp *logResponseWriter) WriteHeader(code int) { rsp.statusCode = code rsp.ResponseWriter.WriteHeader(code) } // Unwrap returns the original http.ResponseWriter. This is necessary // to expose Flush() and Push() on the underlying response writer. func (rsp *logResponseWriter) Unwrap() http.ResponseWriter { return rsp.ResponseWriter } func newLogResponseWriter(w http.ResponseWriter) *logResponseWriter { return &logResponseWriter{w, http.StatusOK} } // logRequestBody logs the request body when the response status code is not 200. // This addresses the issue of being unable to retrieve the request body in the customErrorHandler middleware. func logRequestBody(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { lw := newLogResponseWriter(w) body, err := io.ReadAll(r.Body) if err != nil { http.Error(w, fmt.Sprintf("grpc server read request body err %+v", err), http.StatusBadRequest) return } clonedR := r.Clone(r.Context()) clonedR.Body = io.NopCloser(bytes.NewReader(body)) h.ServeHTTP(lw, clonedR) if lw.statusCode != http.StatusOK { grpclog.Errorf("http error %+v request body %+v", lw.statusCode, string(body)) } }) } ================================================ FILE: examples/internal/gateway/main.go ================================================ package gateway import ( "context" "net/http" gwruntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "google.golang.org/grpc/grpclog" ) // Endpoint describes a gRPC endpoint type Endpoint struct { Network, Addr string } // Options is a set of options to be passed to Run type Options struct { // Addr is the address to listen Addr string // GRPCServer defines an endpoint of a gRPC service GRPCServer Endpoint // OpenAPIDir is a path to a directory from which the server // serves OpenAPI specs. OpenAPIDir string // Mux is a list of options to be passed to the gRPC-Gateway multiplexer Mux []gwruntime.ServeMuxOption } // Run starts a HTTP server and blocks while running if successful. // The server will be shutdown when "ctx" is canceled. func Run(ctx context.Context, opts Options) error { ctx, cancel := context.WithCancel(ctx) defer cancel() conn, err := dial(opts.GRPCServer.Network, opts.GRPCServer.Addr) if err != nil { return err } go func() { <-ctx.Done() if err := conn.Close(); err != nil { grpclog.Errorf("Failed to close a client connection to the gRPC server: %v", err) } }() mux := http.NewServeMux() mux.HandleFunc("/openapiv2/", openAPIServer(opts.OpenAPIDir)) mux.HandleFunc("/healthz", healthzServer(conn)) gw, err := newGateway(ctx, conn, opts.Mux) if err != nil { return err } mux.Handle("/", gw) // Do not use logRequestBody for ExcessBodyServer because it will perform // io.ReadAll and mask the issue: // https://github.com/grpc-ecosystem/grpc-gateway/issues/5236 hmux := http.NewServeMux() hmux.Handle("/rpc/excess-body/", allowCORS(mux)) hmux.Handle("/", logRequestBody(allowCORS(mux))) s := &http.Server{ Addr: opts.Addr, Handler: hmux, } go func() { <-ctx.Done() grpclog.Infof("Shutting down the http server") if err := s.Shutdown(context.Background()); err != nil { grpclog.Errorf("Failed to shutdown http server: %v", err) } }() grpclog.Infof("Starting listening at %s", opts.Addr) if err := s.ListenAndServe(); err != http.ErrServerClosed { grpclog.Errorf("Failed to listen and serve: %v", err) return err } return nil } ================================================ FILE: examples/internal/helloworld/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library") load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") load("@rules_proto//proto:defs.bzl", "proto_library") # gazelle:exclude helloworld.pb.gw.go # gazelle:exclude helloworld_grpc.pb.go # gazelle:go_grpc_compilers //:go_apiv2, //:go_grpc, //protoc-gen-grpc-gateway:go_gen_grpc_gateway proto_library( name = "helloworld_proto", srcs = ["helloworld.proto"], visibility = ["//visibility:public"], deps = [ "@com_google_protobuf//:wrappers_proto", "@googleapis//google/api:annotations_proto", ], ) go_proto_library( name = "helloworld_go_proto", compilers = [ "//:go_apiv2", "//:go_grpc", "//protoc-gen-grpc-gateway:go_gen_grpc_gateway", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/helloworld", proto = ":helloworld_proto", visibility = ["//visibility:public"], deps = [ "@org_golang_google_genproto_googleapis_api//annotations", ], ) go_library( name = "helloworld", embed = [":helloworld_go_proto"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/helloworld", visibility = ["//examples:__subpackages__"], ) alias( name = "go_default_library", actual = ":helloworld", visibility = ["//examples:__subpackages__"], ) ================================================ FILE: examples/internal/helloworld/helloworld.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/helloworld/helloworld.proto package helloworld import ( _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) type HelloRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` StrVal *wrapperspb.StringValue `protobuf:"bytes,2,opt,name=strVal,proto3" json:"strVal,omitempty"` FloatVal *wrapperspb.FloatValue `protobuf:"bytes,3,opt,name=floatVal,proto3" json:"floatVal,omitempty"` DoubleVal *wrapperspb.DoubleValue `protobuf:"bytes,4,opt,name=doubleVal,proto3" json:"doubleVal,omitempty"` BoolVal *wrapperspb.BoolValue `protobuf:"bytes,5,opt,name=boolVal,proto3" json:"boolVal,omitempty"` BytesVal *wrapperspb.BytesValue `protobuf:"bytes,6,opt,name=bytesVal,proto3" json:"bytesVal,omitempty"` Int32Val *wrapperspb.Int32Value `protobuf:"bytes,7,opt,name=int32Val,proto3" json:"int32Val,omitempty"` Uint32Val *wrapperspb.UInt32Value `protobuf:"bytes,8,opt,name=uint32Val,proto3" json:"uint32Val,omitempty"` Int64Val *wrapperspb.Int64Value `protobuf:"bytes,9,opt,name=int64Val,proto3" json:"int64Val,omitempty"` Uint64Val *wrapperspb.UInt64Value `protobuf:"bytes,10,opt,name=uint64Val,proto3" json:"uint64Val,omitempty"` } func (x *HelloRequest) Reset() { *x = HelloRequest{} mi := &file_examples_internal_helloworld_helloworld_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *HelloRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*HelloRequest) ProtoMessage() {} func (x *HelloRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_helloworld_helloworld_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead. func (*HelloRequest) Descriptor() ([]byte, []int) { return file_examples_internal_helloworld_helloworld_proto_rawDescGZIP(), []int{0} } func (x *HelloRequest) GetName() string { if x != nil { return x.Name } return "" } func (x *HelloRequest) GetStrVal() *wrapperspb.StringValue { if x != nil { return x.StrVal } return nil } func (x *HelloRequest) GetFloatVal() *wrapperspb.FloatValue { if x != nil { return x.FloatVal } return nil } func (x *HelloRequest) GetDoubleVal() *wrapperspb.DoubleValue { if x != nil { return x.DoubleVal } return nil } func (x *HelloRequest) GetBoolVal() *wrapperspb.BoolValue { if x != nil { return x.BoolVal } return nil } func (x *HelloRequest) GetBytesVal() *wrapperspb.BytesValue { if x != nil { return x.BytesVal } return nil } func (x *HelloRequest) GetInt32Val() *wrapperspb.Int32Value { if x != nil { return x.Int32Val } return nil } func (x *HelloRequest) GetUint32Val() *wrapperspb.UInt32Value { if x != nil { return x.Uint32Val } return nil } func (x *HelloRequest) GetInt64Val() *wrapperspb.Int64Value { if x != nil { return x.Int64Val } return nil } func (x *HelloRequest) GetUint64Val() *wrapperspb.UInt64Value { if x != nil { return x.Uint64Val } return nil } type HelloReply struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` } func (x *HelloReply) Reset() { *x = HelloReply{} mi := &file_examples_internal_helloworld_helloworld_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *HelloReply) String() string { return protoimpl.X.MessageStringOf(x) } func (*HelloReply) ProtoMessage() {} func (x *HelloReply) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_helloworld_helloworld_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use HelloReply.ProtoReflect.Descriptor instead. func (*HelloReply) Descriptor() ([]byte, []int) { return file_examples_internal_helloworld_helloworld_proto_rawDescGZIP(), []int{1} } func (x *HelloReply) GetMessage() string { if x != nil { return x.Message } return "" } var File_examples_internal_helloworld_helloworld_proto protoreflect.FileDescriptor var file_examples_internal_helloworld_helloworld_proto_rawDesc = []byte{ 0x0a, 0x2d, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x29, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa6, 0x04, 0x0a, 0x0c, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x34, 0x0a, 0x06, 0x73, 0x74, 0x72, 0x56, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x06, 0x73, 0x74, 0x72, 0x56, 0x61, 0x6c, 0x12, 0x37, 0x0a, 0x08, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x61, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x08, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x61, 0x6c, 0x12, 0x3a, 0x0a, 0x09, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x09, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x12, 0x34, 0x0a, 0x07, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x07, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x12, 0x37, 0x0a, 0x08, 0x62, 0x79, 0x74, 0x65, 0x73, 0x56, 0x61, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x42, 0x79, 0x74, 0x65, 0x73, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x08, 0x62, 0x79, 0x74, 0x65, 0x73, 0x56, 0x61, 0x6c, 0x12, 0x37, 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x12, 0x3a, 0x0a, 0x09, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x09, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x12, 0x37, 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x12, 0x3a, 0x0a, 0x09, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x09, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x22, 0x26, 0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x99, 0x03, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65, 0x74, 0x65, 0x72, 0x12, 0x8d, 0x03, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, 0x37, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x90, 0x02, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x89, 0x02, 0x5a, 0x16, 0x12, 0x14, 0x2f, 0x73, 0x61, 0x79, 0x2f, 0x73, 0x74, 0x72, 0x76, 0x61, 0x6c, 0x2f, 0x7b, 0x73, 0x74, 0x72, 0x56, 0x61, 0x6c, 0x7d, 0x5a, 0x1a, 0x12, 0x18, 0x2f, 0x73, 0x61, 0x79, 0x2f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x76, 0x61, 0x6c, 0x2f, 0x7b, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x61, 0x6c, 0x7d, 0x5a, 0x1c, 0x12, 0x1a, 0x2f, 0x73, 0x61, 0x79, 0x2f, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x76, 0x61, 0x6c, 0x2f, 0x7b, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x7d, 0x5a, 0x18, 0x12, 0x16, 0x2f, 0x73, 0x61, 0x79, 0x2f, 0x62, 0x6f, 0x6f, 0x6c, 0x76, 0x61, 0x6c, 0x2f, 0x7b, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x7d, 0x5a, 0x1a, 0x12, 0x18, 0x2f, 0x73, 0x61, 0x79, 0x2f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x76, 0x61, 0x6c, 0x2f, 0x7b, 0x62, 0x79, 0x74, 0x65, 0x73, 0x56, 0x61, 0x6c, 0x7d, 0x5a, 0x1a, 0x12, 0x18, 0x2f, 0x73, 0x61, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x76, 0x61, 0x6c, 0x2f, 0x7b, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x7d, 0x5a, 0x1c, 0x12, 0x1a, 0x2f, 0x73, 0x61, 0x79, 0x2f, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x76, 0x61, 0x6c, 0x2f, 0x7b, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x7d, 0x5a, 0x1a, 0x12, 0x18, 0x2f, 0x73, 0x61, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x76, 0x61, 0x6c, 0x2f, 0x7b, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x7d, 0x5a, 0x1c, 0x12, 0x1a, 0x2f, 0x73, 0x61, 0x79, 0x2f, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x76, 0x61, 0x6c, 0x2f, 0x7b, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x7d, 0x12, 0x0b, 0x2f, 0x73, 0x61, 0x79, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x7d, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_helloworld_helloworld_proto_rawDescOnce sync.Once file_examples_internal_helloworld_helloworld_proto_rawDescData = file_examples_internal_helloworld_helloworld_proto_rawDesc ) func file_examples_internal_helloworld_helloworld_proto_rawDescGZIP() []byte { file_examples_internal_helloworld_helloworld_proto_rawDescOnce.Do(func() { file_examples_internal_helloworld_helloworld_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_helloworld_helloworld_proto_rawDescData) }) return file_examples_internal_helloworld_helloworld_proto_rawDescData } var file_examples_internal_helloworld_helloworld_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_examples_internal_helloworld_helloworld_proto_goTypes = []any{ (*HelloRequest)(nil), // 0: grpc.gateway.examples.internal.helloworld.HelloRequest (*HelloReply)(nil), // 1: grpc.gateway.examples.internal.helloworld.HelloReply (*wrapperspb.StringValue)(nil), // 2: google.protobuf.StringValue (*wrapperspb.FloatValue)(nil), // 3: google.protobuf.FloatValue (*wrapperspb.DoubleValue)(nil), // 4: google.protobuf.DoubleValue (*wrapperspb.BoolValue)(nil), // 5: google.protobuf.BoolValue (*wrapperspb.BytesValue)(nil), // 6: google.protobuf.BytesValue (*wrapperspb.Int32Value)(nil), // 7: google.protobuf.Int32Value (*wrapperspb.UInt32Value)(nil), // 8: google.protobuf.UInt32Value (*wrapperspb.Int64Value)(nil), // 9: google.protobuf.Int64Value (*wrapperspb.UInt64Value)(nil), // 10: google.protobuf.UInt64Value } var file_examples_internal_helloworld_helloworld_proto_depIdxs = []int32{ 2, // 0: grpc.gateway.examples.internal.helloworld.HelloRequest.strVal:type_name -> google.protobuf.StringValue 3, // 1: grpc.gateway.examples.internal.helloworld.HelloRequest.floatVal:type_name -> google.protobuf.FloatValue 4, // 2: grpc.gateway.examples.internal.helloworld.HelloRequest.doubleVal:type_name -> google.protobuf.DoubleValue 5, // 3: grpc.gateway.examples.internal.helloworld.HelloRequest.boolVal:type_name -> google.protobuf.BoolValue 6, // 4: grpc.gateway.examples.internal.helloworld.HelloRequest.bytesVal:type_name -> google.protobuf.BytesValue 7, // 5: grpc.gateway.examples.internal.helloworld.HelloRequest.int32Val:type_name -> google.protobuf.Int32Value 8, // 6: grpc.gateway.examples.internal.helloworld.HelloRequest.uint32Val:type_name -> google.protobuf.UInt32Value 9, // 7: grpc.gateway.examples.internal.helloworld.HelloRequest.int64Val:type_name -> google.protobuf.Int64Value 10, // 8: grpc.gateway.examples.internal.helloworld.HelloRequest.uint64Val:type_name -> google.protobuf.UInt64Value 0, // 9: grpc.gateway.examples.internal.helloworld.Greeter.SayHello:input_type -> grpc.gateway.examples.internal.helloworld.HelloRequest 1, // 10: grpc.gateway.examples.internal.helloworld.Greeter.SayHello:output_type -> grpc.gateway.examples.internal.helloworld.HelloReply 10, // [10:11] is the sub-list for method output_type 9, // [9:10] is the sub-list for method input_type 9, // [9:9] is the sub-list for extension type_name 9, // [9:9] is the sub-list for extension extendee 0, // [0:9] is the sub-list for field type_name } func init() { file_examples_internal_helloworld_helloworld_proto_init() } func file_examples_internal_helloworld_helloworld_proto_init() { if File_examples_internal_helloworld_helloworld_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_helloworld_helloworld_proto_rawDesc, NumEnums: 0, NumMessages: 2, NumExtensions: 0, NumServices: 1, }, GoTypes: file_examples_internal_helloworld_helloworld_proto_goTypes, DependencyIndexes: file_examples_internal_helloworld_helloworld_proto_depIdxs, MessageInfos: file_examples_internal_helloworld_helloworld_proto_msgTypes, }.Build() File_examples_internal_helloworld_helloworld_proto = out.File file_examples_internal_helloworld_helloworld_proto_rawDesc = nil file_examples_internal_helloworld_helloworld_proto_goTypes = nil file_examples_internal_helloworld_helloworld_proto_depIdxs = nil } ================================================ FILE: examples/internal/helloworld/helloworld.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/helloworld/helloworld.proto /* Package helloworld is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package helloworld import ( "context" "errors" "io" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) var filter_Greeter_SayHello_0 = &utilities.DoubleArray{Encoding: map[string]int{"name": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_Greeter_SayHello_0(ctx context.Context, marshaler runtime.Marshaler, client GreeterClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq HelloRequest metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") } protoReq.Name, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Greeter_SayHello_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.SayHello(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_Greeter_SayHello_0(ctx context.Context, marshaler runtime.Marshaler, server GreeterServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq HelloRequest metadata runtime.ServerMetadata err error ) val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") } protoReq.Name, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Greeter_SayHello_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.SayHello(ctx, &protoReq) return msg, metadata, err } var filter_Greeter_SayHello_1 = &utilities.DoubleArray{Encoding: map[string]int{"strVal": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_Greeter_SayHello_1(ctx context.Context, marshaler runtime.Marshaler, client GreeterClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq HelloRequest metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["strVal"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "strVal") } protoReq.StrVal, err = runtime.StringValue(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "strVal", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Greeter_SayHello_1); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.SayHello(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_Greeter_SayHello_1(ctx context.Context, marshaler runtime.Marshaler, server GreeterServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq HelloRequest metadata runtime.ServerMetadata err error ) val, ok := pathParams["strVal"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "strVal") } protoReq.StrVal, err = runtime.StringValue(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "strVal", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Greeter_SayHello_1); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.SayHello(ctx, &protoReq) return msg, metadata, err } var filter_Greeter_SayHello_2 = &utilities.DoubleArray{Encoding: map[string]int{"floatVal": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_Greeter_SayHello_2(ctx context.Context, marshaler runtime.Marshaler, client GreeterClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq HelloRequest metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["floatVal"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "floatVal") } protoReq.FloatVal, err = runtime.FloatValue(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "floatVal", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Greeter_SayHello_2); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.SayHello(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_Greeter_SayHello_2(ctx context.Context, marshaler runtime.Marshaler, server GreeterServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq HelloRequest metadata runtime.ServerMetadata err error ) val, ok := pathParams["floatVal"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "floatVal") } protoReq.FloatVal, err = runtime.FloatValue(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "floatVal", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Greeter_SayHello_2); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.SayHello(ctx, &protoReq) return msg, metadata, err } var filter_Greeter_SayHello_3 = &utilities.DoubleArray{Encoding: map[string]int{"doubleVal": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_Greeter_SayHello_3(ctx context.Context, marshaler runtime.Marshaler, client GreeterClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq HelloRequest metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["doubleVal"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "doubleVal") } protoReq.DoubleVal, err = runtime.DoubleValue(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "doubleVal", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Greeter_SayHello_3); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.SayHello(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_Greeter_SayHello_3(ctx context.Context, marshaler runtime.Marshaler, server GreeterServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq HelloRequest metadata runtime.ServerMetadata err error ) val, ok := pathParams["doubleVal"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "doubleVal") } protoReq.DoubleVal, err = runtime.DoubleValue(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "doubleVal", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Greeter_SayHello_3); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.SayHello(ctx, &protoReq) return msg, metadata, err } var filter_Greeter_SayHello_4 = &utilities.DoubleArray{Encoding: map[string]int{"boolVal": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_Greeter_SayHello_4(ctx context.Context, marshaler runtime.Marshaler, client GreeterClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq HelloRequest metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["boolVal"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "boolVal") } protoReq.BoolVal, err = runtime.BoolValue(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "boolVal", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Greeter_SayHello_4); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.SayHello(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_Greeter_SayHello_4(ctx context.Context, marshaler runtime.Marshaler, server GreeterServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq HelloRequest metadata runtime.ServerMetadata err error ) val, ok := pathParams["boolVal"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "boolVal") } protoReq.BoolVal, err = runtime.BoolValue(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "boolVal", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Greeter_SayHello_4); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.SayHello(ctx, &protoReq) return msg, metadata, err } var filter_Greeter_SayHello_5 = &utilities.DoubleArray{Encoding: map[string]int{"bytesVal": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_Greeter_SayHello_5(ctx context.Context, marshaler runtime.Marshaler, client GreeterClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq HelloRequest metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["bytesVal"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "bytesVal") } protoReq.BytesVal, err = runtime.BytesValue(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "bytesVal", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Greeter_SayHello_5); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.SayHello(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_Greeter_SayHello_5(ctx context.Context, marshaler runtime.Marshaler, server GreeterServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq HelloRequest metadata runtime.ServerMetadata err error ) val, ok := pathParams["bytesVal"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "bytesVal") } protoReq.BytesVal, err = runtime.BytesValue(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "bytesVal", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Greeter_SayHello_5); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.SayHello(ctx, &protoReq) return msg, metadata, err } var filter_Greeter_SayHello_6 = &utilities.DoubleArray{Encoding: map[string]int{"int32Val": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_Greeter_SayHello_6(ctx context.Context, marshaler runtime.Marshaler, client GreeterClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq HelloRequest metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["int32Val"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "int32Val") } protoReq.Int32Val, err = runtime.Int32Value(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "int32Val", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Greeter_SayHello_6); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.SayHello(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_Greeter_SayHello_6(ctx context.Context, marshaler runtime.Marshaler, server GreeterServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq HelloRequest metadata runtime.ServerMetadata err error ) val, ok := pathParams["int32Val"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "int32Val") } protoReq.Int32Val, err = runtime.Int32Value(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "int32Val", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Greeter_SayHello_6); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.SayHello(ctx, &protoReq) return msg, metadata, err } var filter_Greeter_SayHello_7 = &utilities.DoubleArray{Encoding: map[string]int{"uint32Val": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_Greeter_SayHello_7(ctx context.Context, marshaler runtime.Marshaler, client GreeterClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq HelloRequest metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["uint32Val"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uint32Val") } protoReq.Uint32Val, err = runtime.UInt32Value(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uint32Val", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Greeter_SayHello_7); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.SayHello(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_Greeter_SayHello_7(ctx context.Context, marshaler runtime.Marshaler, server GreeterServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq HelloRequest metadata runtime.ServerMetadata err error ) val, ok := pathParams["uint32Val"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uint32Val") } protoReq.Uint32Val, err = runtime.UInt32Value(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uint32Val", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Greeter_SayHello_7); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.SayHello(ctx, &protoReq) return msg, metadata, err } var filter_Greeter_SayHello_8 = &utilities.DoubleArray{Encoding: map[string]int{"int64Val": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_Greeter_SayHello_8(ctx context.Context, marshaler runtime.Marshaler, client GreeterClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq HelloRequest metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["int64Val"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "int64Val") } protoReq.Int64Val, err = runtime.Int64Value(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "int64Val", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Greeter_SayHello_8); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.SayHello(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_Greeter_SayHello_8(ctx context.Context, marshaler runtime.Marshaler, server GreeterServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq HelloRequest metadata runtime.ServerMetadata err error ) val, ok := pathParams["int64Val"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "int64Val") } protoReq.Int64Val, err = runtime.Int64Value(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "int64Val", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Greeter_SayHello_8); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.SayHello(ctx, &protoReq) return msg, metadata, err } var filter_Greeter_SayHello_9 = &utilities.DoubleArray{Encoding: map[string]int{"uint64Val": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_Greeter_SayHello_9(ctx context.Context, marshaler runtime.Marshaler, client GreeterClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq HelloRequest metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["uint64Val"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uint64Val") } protoReq.Uint64Val, err = runtime.UInt64Value(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uint64Val", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Greeter_SayHello_9); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.SayHello(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_Greeter_SayHello_9(ctx context.Context, marshaler runtime.Marshaler, server GreeterServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq HelloRequest metadata runtime.ServerMetadata err error ) val, ok := pathParams["uint64Val"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uint64Val") } protoReq.Uint64Val, err = runtime.UInt64Value(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uint64Val", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Greeter_SayHello_9); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.SayHello(ctx, &protoReq) return msg, metadata, err } // RegisterGreeterHandlerServer registers the http handlers for service Greeter to "mux". // UnaryRPC :call GreeterServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterGreeterHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterGreeterHandlerServer(ctx context.Context, mux *runtime.ServeMux, server GreeterServer) error { mux.Handle(http.MethodGet, pattern_Greeter_SayHello_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.helloworld.Greeter/SayHello", runtime.WithHTTPPathPattern("/say/{name}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_Greeter_SayHello_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Greeter_SayHello_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_Greeter_SayHello_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.helloworld.Greeter/SayHello", runtime.WithHTTPPathPattern("/say/strval/{strVal}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_Greeter_SayHello_1(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Greeter_SayHello_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_Greeter_SayHello_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.helloworld.Greeter/SayHello", runtime.WithHTTPPathPattern("/say/floatval/{floatVal}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_Greeter_SayHello_2(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Greeter_SayHello_2(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_Greeter_SayHello_3, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.helloworld.Greeter/SayHello", runtime.WithHTTPPathPattern("/say/doubleval/{doubleVal}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_Greeter_SayHello_3(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Greeter_SayHello_3(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_Greeter_SayHello_4, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.helloworld.Greeter/SayHello", runtime.WithHTTPPathPattern("/say/boolval/{boolVal}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_Greeter_SayHello_4(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Greeter_SayHello_4(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_Greeter_SayHello_5, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.helloworld.Greeter/SayHello", runtime.WithHTTPPathPattern("/say/bytesval/{bytesVal}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_Greeter_SayHello_5(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Greeter_SayHello_5(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_Greeter_SayHello_6, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.helloworld.Greeter/SayHello", runtime.WithHTTPPathPattern("/say/int32val/{int32Val}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_Greeter_SayHello_6(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Greeter_SayHello_6(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_Greeter_SayHello_7, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.helloworld.Greeter/SayHello", runtime.WithHTTPPathPattern("/say/uint32val/{uint32Val}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_Greeter_SayHello_7(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Greeter_SayHello_7(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_Greeter_SayHello_8, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.helloworld.Greeter/SayHello", runtime.WithHTTPPathPattern("/say/int64val/{int64Val}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_Greeter_SayHello_8(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Greeter_SayHello_8(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_Greeter_SayHello_9, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.helloworld.Greeter/SayHello", runtime.WithHTTPPathPattern("/say/uint64val/{uint64Val}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_Greeter_SayHello_9(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Greeter_SayHello_9(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } // RegisterGreeterHandlerFromEndpoint is same as RegisterGreeterHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterGreeterHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterGreeterHandler(ctx, mux, conn) } // RegisterGreeterHandler registers the http handlers for service Greeter to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterGreeterHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterGreeterHandlerClient(ctx, mux, NewGreeterClient(conn)) } // RegisterGreeterHandlerClient registers the http handlers for service Greeter // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "GreeterClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "GreeterClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "GreeterClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterGreeterHandlerClient(ctx context.Context, mux *runtime.ServeMux, client GreeterClient) error { mux.Handle(http.MethodGet, pattern_Greeter_SayHello_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.helloworld.Greeter/SayHello", runtime.WithHTTPPathPattern("/say/{name}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_Greeter_SayHello_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Greeter_SayHello_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_Greeter_SayHello_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.helloworld.Greeter/SayHello", runtime.WithHTTPPathPattern("/say/strval/{strVal}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_Greeter_SayHello_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Greeter_SayHello_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_Greeter_SayHello_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.helloworld.Greeter/SayHello", runtime.WithHTTPPathPattern("/say/floatval/{floatVal}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_Greeter_SayHello_2(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Greeter_SayHello_2(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_Greeter_SayHello_3, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.helloworld.Greeter/SayHello", runtime.WithHTTPPathPattern("/say/doubleval/{doubleVal}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_Greeter_SayHello_3(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Greeter_SayHello_3(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_Greeter_SayHello_4, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.helloworld.Greeter/SayHello", runtime.WithHTTPPathPattern("/say/boolval/{boolVal}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_Greeter_SayHello_4(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Greeter_SayHello_4(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_Greeter_SayHello_5, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.helloworld.Greeter/SayHello", runtime.WithHTTPPathPattern("/say/bytesval/{bytesVal}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_Greeter_SayHello_5(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Greeter_SayHello_5(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_Greeter_SayHello_6, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.helloworld.Greeter/SayHello", runtime.WithHTTPPathPattern("/say/int32val/{int32Val}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_Greeter_SayHello_6(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Greeter_SayHello_6(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_Greeter_SayHello_7, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.helloworld.Greeter/SayHello", runtime.WithHTTPPathPattern("/say/uint32val/{uint32Val}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_Greeter_SayHello_7(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Greeter_SayHello_7(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_Greeter_SayHello_8, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.helloworld.Greeter/SayHello", runtime.WithHTTPPathPattern("/say/int64val/{int64Val}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_Greeter_SayHello_8(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Greeter_SayHello_8(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_Greeter_SayHello_9, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.helloworld.Greeter/SayHello", runtime.WithHTTPPathPattern("/say/uint64val/{uint64Val}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_Greeter_SayHello_9(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Greeter_SayHello_9(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_Greeter_SayHello_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"say", "name"}, "")) pattern_Greeter_SayHello_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"say", "strval", "strVal"}, "")) pattern_Greeter_SayHello_2 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"say", "floatval", "floatVal"}, "")) pattern_Greeter_SayHello_3 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"say", "doubleval", "doubleVal"}, "")) pattern_Greeter_SayHello_4 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"say", "boolval", "boolVal"}, "")) pattern_Greeter_SayHello_5 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"say", "bytesval", "bytesVal"}, "")) pattern_Greeter_SayHello_6 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"say", "int32val", "int32Val"}, "")) pattern_Greeter_SayHello_7 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"say", "uint32val", "uint32Val"}, "")) pattern_Greeter_SayHello_8 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"say", "int64val", "int64Val"}, "")) pattern_Greeter_SayHello_9 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"say", "uint64val", "uint64Val"}, "")) ) var ( forward_Greeter_SayHello_0 = runtime.ForwardResponseMessage forward_Greeter_SayHello_1 = runtime.ForwardResponseMessage forward_Greeter_SayHello_2 = runtime.ForwardResponseMessage forward_Greeter_SayHello_3 = runtime.ForwardResponseMessage forward_Greeter_SayHello_4 = runtime.ForwardResponseMessage forward_Greeter_SayHello_5 = runtime.ForwardResponseMessage forward_Greeter_SayHello_6 = runtime.ForwardResponseMessage forward_Greeter_SayHello_7 = runtime.ForwardResponseMessage forward_Greeter_SayHello_8 = runtime.ForwardResponseMessage forward_Greeter_SayHello_9 = runtime.ForwardResponseMessage ) ================================================ FILE: examples/internal/helloworld/helloworld.proto ================================================ syntax = "proto3"; package grpc.gateway.examples.internal.helloworld; import "google/api/annotations.proto"; import "google/protobuf/wrappers.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/helloworld"; service Greeter { rpc SayHello(HelloRequest) returns (HelloReply) { option (google.api.http) = { get: "/say/{name}" additional_bindings: {get: "/say/strval/{strVal}"} additional_bindings: {get: "/say/floatval/{floatVal}"} additional_bindings: {get: "/say/doubleval/{doubleVal}"} additional_bindings: {get: "/say/boolval/{boolVal}"} additional_bindings: {get: "/say/bytesval/{bytesVal}"} additional_bindings: {get: "/say/int32val/{int32Val}"} additional_bindings: {get: "/say/uint32val/{uint32Val}"} additional_bindings: {get: "/say/int64val/{int64Val}"} additional_bindings: {get: "/say/uint64val/{uint64Val}"} }; } } message HelloRequest { string name = 1; google.protobuf.StringValue strVal = 2; google.protobuf.FloatValue floatVal = 3; google.protobuf.DoubleValue doubleVal = 4; google.protobuf.BoolValue boolVal = 5; google.protobuf.BytesValue bytesVal = 6; google.protobuf.Int32Value int32Val = 7; google.protobuf.UInt32Value uint32Val = 8; google.protobuf.Int64Value int64Val = 9; google.protobuf.UInt64Value uint64Val = 10; } message HelloReply { string message = 1; } ================================================ FILE: examples/internal/helloworld/helloworld.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/helloworld/helloworld.proto", "version": "version not set" }, "tags": [ { "name": "Greeter" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/say/boolval/{boolVal}": { "get": { "operationId": "Greeter_SayHello5", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/helloworldHelloReply" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "boolVal", "in": "path", "required": true, "type": "boolean" }, { "name": "name", "in": "query", "required": false, "type": "string" }, { "name": "strVal", "in": "query", "required": false, "type": "string" }, { "name": "floatVal", "in": "query", "required": false, "type": "number", "format": "float" }, { "name": "doubleVal", "in": "query", "required": false, "type": "number", "format": "double" }, { "name": "bytesVal", "in": "query", "required": false, "type": "string", "format": "byte" }, { "name": "int32Val", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "uint32Val", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "int64Val", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "uint64Val", "in": "query", "required": false, "type": "string", "format": "uint64" } ], "tags": [ "Greeter" ] } }, "/say/bytesval/{bytesVal}": { "get": { "operationId": "Greeter_SayHello6", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/helloworldHelloReply" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "bytesVal", "in": "path", "required": true, "type": "string", "format": "byte" }, { "name": "name", "in": "query", "required": false, "type": "string" }, { "name": "strVal", "in": "query", "required": false, "type": "string" }, { "name": "floatVal", "in": "query", "required": false, "type": "number", "format": "float" }, { "name": "doubleVal", "in": "query", "required": false, "type": "number", "format": "double" }, { "name": "boolVal", "in": "query", "required": false, "type": "boolean" }, { "name": "int32Val", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "uint32Val", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "int64Val", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "uint64Val", "in": "query", "required": false, "type": "string", "format": "uint64" } ], "tags": [ "Greeter" ] } }, "/say/doubleval/{doubleVal}": { "get": { "operationId": "Greeter_SayHello4", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/helloworldHelloReply" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "doubleVal", "in": "path", "required": true, "type": "number", "format": "double" }, { "name": "name", "in": "query", "required": false, "type": "string" }, { "name": "strVal", "in": "query", "required": false, "type": "string" }, { "name": "floatVal", "in": "query", "required": false, "type": "number", "format": "float" }, { "name": "boolVal", "in": "query", "required": false, "type": "boolean" }, { "name": "bytesVal", "in": "query", "required": false, "type": "string", "format": "byte" }, { "name": "int32Val", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "uint32Val", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "int64Val", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "uint64Val", "in": "query", "required": false, "type": "string", "format": "uint64" } ], "tags": [ "Greeter" ] } }, "/say/floatval/{floatVal}": { "get": { "operationId": "Greeter_SayHello3", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/helloworldHelloReply" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "floatVal", "in": "path", "required": true, "type": "number", "format": "float" }, { "name": "name", "in": "query", "required": false, "type": "string" }, { "name": "strVal", "in": "query", "required": false, "type": "string" }, { "name": "doubleVal", "in": "query", "required": false, "type": "number", "format": "double" }, { "name": "boolVal", "in": "query", "required": false, "type": "boolean" }, { "name": "bytesVal", "in": "query", "required": false, "type": "string", "format": "byte" }, { "name": "int32Val", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "uint32Val", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "int64Val", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "uint64Val", "in": "query", "required": false, "type": "string", "format": "uint64" } ], "tags": [ "Greeter" ] } }, "/say/int32val/{int32Val}": { "get": { "operationId": "Greeter_SayHello7", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/helloworldHelloReply" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "int32Val", "in": "path", "required": true, "type": "integer", "format": "int32" }, { "name": "name", "in": "query", "required": false, "type": "string" }, { "name": "strVal", "in": "query", "required": false, "type": "string" }, { "name": "floatVal", "in": "query", "required": false, "type": "number", "format": "float" }, { "name": "doubleVal", "in": "query", "required": false, "type": "number", "format": "double" }, { "name": "boolVal", "in": "query", "required": false, "type": "boolean" }, { "name": "bytesVal", "in": "query", "required": false, "type": "string", "format": "byte" }, { "name": "uint32Val", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "int64Val", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "uint64Val", "in": "query", "required": false, "type": "string", "format": "uint64" } ], "tags": [ "Greeter" ] } }, "/say/int64val/{int64Val}": { "get": { "operationId": "Greeter_SayHello9", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/helloworldHelloReply" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "int64Val", "in": "path", "required": true, "type": "string", "format": "int64" }, { "name": "name", "in": "query", "required": false, "type": "string" }, { "name": "strVal", "in": "query", "required": false, "type": "string" }, { "name": "floatVal", "in": "query", "required": false, "type": "number", "format": "float" }, { "name": "doubleVal", "in": "query", "required": false, "type": "number", "format": "double" }, { "name": "boolVal", "in": "query", "required": false, "type": "boolean" }, { "name": "bytesVal", "in": "query", "required": false, "type": "string", "format": "byte" }, { "name": "int32Val", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "uint32Val", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "uint64Val", "in": "query", "required": false, "type": "string", "format": "uint64" } ], "tags": [ "Greeter" ] } }, "/say/strval/{strVal}": { "get": { "operationId": "Greeter_SayHello2", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/helloworldHelloReply" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "strVal", "in": "path", "required": true, "type": "string" }, { "name": "name", "in": "query", "required": false, "type": "string" }, { "name": "floatVal", "in": "query", "required": false, "type": "number", "format": "float" }, { "name": "doubleVal", "in": "query", "required": false, "type": "number", "format": "double" }, { "name": "boolVal", "in": "query", "required": false, "type": "boolean" }, { "name": "bytesVal", "in": "query", "required": false, "type": "string", "format": "byte" }, { "name": "int32Val", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "uint32Val", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "int64Val", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "uint64Val", "in": "query", "required": false, "type": "string", "format": "uint64" } ], "tags": [ "Greeter" ] } }, "/say/uint32val/{uint32Val}": { "get": { "operationId": "Greeter_SayHello8", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/helloworldHelloReply" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "uint32Val", "in": "path", "required": true, "type": "integer", "format": "int64" }, { "name": "name", "in": "query", "required": false, "type": "string" }, { "name": "strVal", "in": "query", "required": false, "type": "string" }, { "name": "floatVal", "in": "query", "required": false, "type": "number", "format": "float" }, { "name": "doubleVal", "in": "query", "required": false, "type": "number", "format": "double" }, { "name": "boolVal", "in": "query", "required": false, "type": "boolean" }, { "name": "bytesVal", "in": "query", "required": false, "type": "string", "format": "byte" }, { "name": "int32Val", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "int64Val", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "uint64Val", "in": "query", "required": false, "type": "string", "format": "uint64" } ], "tags": [ "Greeter" ] } }, "/say/uint64val/{uint64Val}": { "get": { "operationId": "Greeter_SayHello10", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/helloworldHelloReply" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "uint64Val", "in": "path", "required": true, "type": "string", "format": "uint64" }, { "name": "name", "in": "query", "required": false, "type": "string" }, { "name": "strVal", "in": "query", "required": false, "type": "string" }, { "name": "floatVal", "in": "query", "required": false, "type": "number", "format": "float" }, { "name": "doubleVal", "in": "query", "required": false, "type": "number", "format": "double" }, { "name": "boolVal", "in": "query", "required": false, "type": "boolean" }, { "name": "bytesVal", "in": "query", "required": false, "type": "string", "format": "byte" }, { "name": "int32Val", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "uint32Val", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "int64Val", "in": "query", "required": false, "type": "string", "format": "int64" } ], "tags": [ "Greeter" ] } }, "/say/{name}": { "get": { "operationId": "Greeter_SayHello", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/helloworldHelloReply" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "name", "in": "path", "required": true, "type": "string" }, { "name": "strVal", "in": "query", "required": false, "type": "string" }, { "name": "floatVal", "in": "query", "required": false, "type": "number", "format": "float" }, { "name": "doubleVal", "in": "query", "required": false, "type": "number", "format": "double" }, { "name": "boolVal", "in": "query", "required": false, "type": "boolean" }, { "name": "bytesVal", "in": "query", "required": false, "type": "string", "format": "byte" }, { "name": "int32Val", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "uint32Val", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "int64Val", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "uint64Val", "in": "query", "required": false, "type": "string", "format": "uint64" } ], "tags": [ "Greeter" ] } } }, "definitions": { "helloworldHelloReply": { "type": "object", "properties": { "message": { "type": "string" } } }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string" } }, "additionalProperties": {} }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } } } } ================================================ FILE: examples/internal/helloworld/helloworld_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: examples/internal/helloworld/helloworld.proto package helloworld import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( Greeter_SayHello_FullMethodName = "/grpc.gateway.examples.internal.helloworld.Greeter/SayHello" ) // GreeterClient is the client API for Greeter service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type GreeterClient interface { SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) } type greeterClient struct { cc grpc.ClientConnInterface } func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient { return &greeterClient{cc} } func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(HelloReply) err := c.cc.Invoke(ctx, Greeter_SayHello_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // GreeterServer is the server API for Greeter service. // All implementations should embed UnimplementedGreeterServer // for forward compatibility. type GreeterServer interface { SayHello(context.Context, *HelloRequest) (*HelloReply, error) } // UnimplementedGreeterServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedGreeterServer struct{} func (UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) { return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") } func (UnimplementedGreeterServer) testEmbeddedByValue() {} // UnsafeGreeterServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to GreeterServer will // result in compilation errors. type UnsafeGreeterServer interface { mustEmbedUnimplementedGreeterServer() } func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer) { // If the following call pancis, it indicates UnimplementedGreeterServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&Greeter_ServiceDesc, srv) } func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(HelloRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(GreeterServer).SayHello(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: Greeter_SayHello_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest)) } return interceptor(ctx, in, info, handler) } // Greeter_ServiceDesc is the grpc.ServiceDesc for Greeter service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var Greeter_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.helloworld.Greeter", HandlerType: (*GreeterServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "SayHello", Handler: _Greeter_SayHello_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/internal/helloworld/helloworld.proto", } ================================================ FILE: examples/internal/integration/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_test") go_test( name = "integration_test", srcs = [ "client_test.go", "integration_test.go", "main_test.go", ], deps = [ "//examples/internal/clients/abe", "//examples/internal/clients/echo", "//examples/internal/clients/unannotatedecho", "//examples/internal/gateway", "//examples/internal/proto/examplepb", "//examples/internal/proto/pathenum", "//examples/internal/proto/sub", "//examples/internal/server", "//runtime", "@com_github_google_go_cmp//cmp", "@com_github_rogpeppe_fastuuid//:fastuuid", "@org_golang_google_genproto_googleapis_rpc//status", "@org_golang_google_grpc//codes", "@org_golang_google_grpc//grpclog", "@org_golang_google_protobuf//encoding/protojson", "@org_golang_google_protobuf//proto", "@org_golang_google_protobuf//testing/protocmp", "@org_golang_google_protobuf//types/known/emptypb", "@org_golang_google_protobuf//types/known/fieldmaskpb", "@org_golang_google_protobuf//types/known/structpb", ], ) ================================================ FILE: examples/internal/integration/client_test.go ================================================ package integration_test import ( "context" "fmt" "testing" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/clients/abe" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/clients/echo" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/clients/unannotatedecho" "github.com/rogpeppe/fastuuid" ) var uuidgen = fastuuid.MustNewGenerator() func TestEchoClient(t *testing.T) { if testing.Short() { t.Skip() return } cfg := echo.NewConfiguration() cfg.BasePath = "http://localhost:8088" cl := echo.NewAPIClient(cfg) resp, _, err := cl.EchoServiceApi.EchoServiceEcho(context.Background(), "foo", nil) if err != nil { t.Errorf(`cl.EchoServiceApi.Echo("foo") failed with %v; want success`, err) } if got, want := resp.Id, "foo"; got != want { t.Errorf("resp.Id = %q; want %q", got, want) } } func TestEchoBodyClient(t *testing.T) { if testing.Short() { t.Skip() return } cfg := echo.NewConfiguration() cfg.BasePath = "http://localhost:8088" cl := echo.NewAPIClient(cfg) req := echo.ExamplepbSimpleMessage{Id: "foo"} resp, _, err := cl.EchoServiceApi.EchoServiceEchoBody(context.Background(), req) if err != nil { t.Errorf("cl.EchoBody(%#v) failed with %v; want success", req, err) } if got, want := resp.Id, "foo"; got != want { t.Errorf("resp.Id = %q; want %q", got, want) } } func TestEchoBody2Client(t *testing.T) { if testing.Short() { t.Skip() return } cfg := echo.NewConfiguration() cfg.BasePath = "http://localhost:8088" cl := echo.NewAPIClient(cfg) req := echo.ExamplepbEmbedded{Note: "note"} resp, _, err := cl.EchoServiceApi.EchoServiceEchoBody2(context.Background(), "foo", req, nil) if err != nil { t.Errorf("cl.EchoBody(%#v) failed with %v; want success", req, err) } if got, want := resp.Id, "foo"; got != want { t.Errorf("resp.Id = %q; want %q", got, want) } } func TestAbitOfEverythingClient(t *testing.T) { if testing.Short() { t.Skip() return } cfg := abe.NewConfiguration() cfg.BasePath = "http://localhost:8088" cl := abe.NewAPIClient(cfg) testABEClientCreate(t, cl) } func testABEClientCreate(t *testing.T, cl *abe.APIClient) { enumZero := abe.ZERO_ExamplepbNumericEnum enumPath := abe.ABC_PathenumPathEnum messagePath := abe.JKL_MessagePathEnumNestedPathEnum want := &abe.ExamplepbABitOfEverything{ FloatValue: 1.5, DoubleValue: 2.5, Int64Value: "4294967296", Uint64Value: "9223372036854775807", Int32Value: -2147483648, Fixed64Value: "9223372036854775807", Fixed32Value: 4294967295, BoolValue: true, StringValue: "strprefix/foo", Uint32Value: 4294967295, Sfixed32Value: 2147483647, Sfixed64Value: "-4611686018427387904", Sint32Value: 2147483647, Sint64Value: "4611686018427387903", NonConventionalNameValue: "camelCase", EnumValue: &enumZero, PathEnumValue: &enumPath, NestedPathEnumValue: &messagePath, EnumValueAnnotation: &enumZero, Uuid: fmt.Sprintf("%x", uuidgen.Next()), RequiredFieldBehaviorJsonNameCustom: "test", RequiredFieldSchemaJsonNameCustom: "test", } resp, _, err := cl.ABitOfEverythingApi.ABitOfEverythingServiceCreate( context.Background(), want.FloatValue, want.DoubleValue, want.Int64Value, want.Uint64Value, want.Int32Value, want.Fixed64Value, want.Fixed32Value, want.BoolValue, want.StringValue, want.Uint32Value, want.Sfixed32Value, want.Sfixed64Value, want.Sint32Value, want.Sint64Value, want.NonConventionalNameValue, want.EnumValue.String(), want.PathEnumValue.String(), want.NestedPathEnumValue.String(), want.EnumValueAnnotation.String(), want.Uuid, want.RequiredStringViaFieldBehaviorAnnotation, want.StringValue, want.StringValue, want.RequiredFieldBehaviorJsonNameCustom, want.RequiredFieldSchemaJsonNameCustom, nil, ) if err != nil { t.Fatalf("cl.Create(%#v) failed with %v; want success", want, err) } if resp.Uuid == "" { t.Errorf("resp.Uuid is empty; want not empty") } resp.Uuid = "" if resp.FloatValue != want.FloatValue { t.Error("float") } if resp.DoubleValue != want.DoubleValue { t.Error("double") } if resp.Int64Value != want.Int64Value { t.Error("double") } if resp.Uint64Value != want.Uint64Value { t.Error("double") } if resp.Int32Value != want.Int32Value { t.Error("double") } if resp.Fixed32Value != want.Fixed32Value { t.Error("bool") } if resp.Fixed64Value != want.Fixed64Value { t.Error("bool") } if resp.BoolValue != want.BoolValue { t.Error("bool") } if resp.StringValue != want.StringValue { t.Error("bool") } if resp.Uint32Value != want.Uint32Value { t.Error("bool") } if resp.Sfixed32Value != want.Sfixed32Value { t.Error("bool") } if resp.Sfixed64Value != want.Sfixed64Value { t.Error("bool") } if resp.Sint32Value != want.Sint32Value { t.Error("bool") } if resp.Sint64Value != want.Sint64Value { t.Error("enum") } if resp.NonConventionalNameValue != want.NonConventionalNameValue { t.Error("enum") } if resp.EnumValue.String() != want.EnumValue.String() { t.Error("enum") } if resp.PathEnumValue.String() != want.PathEnumValue.String() { t.Error("path enum") } if resp.NestedPathEnumValue.String() != want.NestedPathEnumValue.String() { t.Error("nested path enum") } if resp.NestedPathEnumValue.String() != want.NestedPathEnumValue.String() { t.Error("nested path enum") } } func TestUnannotatedEchoClient(t *testing.T) { if testing.Short() { t.Skip() return } cfg := unannotatedecho.NewConfiguration() cfg.BasePath = "http://localhost:8088" cl := unannotatedecho.NewAPIClient(cfg) resp, _, err := cl.UnannotatedEchoServiceApi.UnannotatedEchoServiceEcho(context.Background(), "foo", "1", nil) if err != nil { t.Errorf(`cl.Echo("foo") failed with %v; want success`, err) } if got, want := resp.Id, "foo"; got != want { t.Errorf("resp.Id = %q; want %q", got, want) } } func TestUnannotatedEchoBodyClient(t *testing.T) { if testing.Short() { t.Skip() return } cfg := unannotatedecho.NewConfiguration() cfg.BasePath = "http://localhost:8088" cl := unannotatedecho.NewAPIClient(cfg) req := unannotatedecho.ExamplepbUnannotatedSimpleMessage{Id: "foo", Num: "1"} resp, _, err := cl.UnannotatedEchoServiceApi.UnannotatedEchoServiceEchoBody(context.Background(), req) if err != nil { t.Errorf("cl.EchoBody(%#v) failed with %v; want success", req, err) } if got, want := resp.Id, "foo"; got != want { t.Errorf("resp.Id = %q; want %q", got, want) } } ================================================ FILE: examples/internal/integration/integration_test.go ================================================ package integration_test import ( "bufio" "bytes" "context" "encoding/base64" "encoding/json" "fmt" "io" "net/http" "net/url" "reflect" "strconv" "strings" "sync" "testing" "time" "github.com/google/go-cmp/cmp" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/pathenum" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/server" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" statuspb "google.golang.org/genproto/googleapis/rpc/status" "google.golang.org/grpc/codes" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/testing/protocmp" "google.golang.org/protobuf/types/known/emptypb" fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" "google.golang.org/protobuf/types/known/structpb" ) var marshaler = &runtime.JSONPb{} func TestEcho(t *testing.T) { if testing.Short() { t.Skip() return } for _, apiPrefix := range []string{"v1", "v2"} { t.Run(apiPrefix, func(t *testing.T) { testEcho(t, 8088, apiPrefix, "application/json") testEchoOneof(t, 8088, apiPrefix, "application/json") testEchoOneof1(t, 8088, apiPrefix, "application/json") testEchoOneof2(t, 8088, apiPrefix, "application/json") testEchoPathParamOverwrite(t, 8088) testEchoNested(t, 8088) testEchoNestedOverride(t, 8088) testEchoBody(t, 8088, apiPrefix, true) testEchoBody(t, 8088, apiPrefix, false) // Use SendHeader/SetTrailer without gRPC server https://github.com/grpc-ecosystem/grpc-gateway/issues/517#issuecomment-684625645 testEchoBody(t, 8089, apiPrefix, true) testEchoBody(t, 8089, apiPrefix, false) testEchoWithNonASCIIHeaderValues(t, 8088, apiPrefix) testEchoWithInvalidHeaderKey(t, 8088, apiPrefix) }) } } func TestEchoUnauthorized(t *testing.T) { if testing.Short() { t.Skip() return } apiURL := "http://localhost:8088/v1/example/echo_unauthorized" resp, err := http.Get(apiURL) if err != nil { t.Errorf("http.Get(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } msg := new(statuspb.Status) if err := marshaler.Unmarshal(buf, msg); err != nil { t.Errorf("marshaler.Unmarshal(%s, msg) failed with %v; want success", buf, err) return } if got, want := resp.StatusCode, http.StatusUnauthorized; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) } if value := resp.Header.Get("WWW-Authenticate"); value == "" { t.Errorf("WWW-Authenticate header should not be empty") } } func TestEchoPatch(t *testing.T) { if testing.Short() { t.Skip() return } sent := &examplepb.DynamicMessage{ StructField: &structpb.Struct{Fields: map[string]*structpb.Value{ "struct_key": {Kind: &structpb.Value_StructValue{ StructValue: &structpb.Struct{Fields: map[string]*structpb.Value{ "layered_struct_key": {Kind: &structpb.Value_StringValue{StringValue: "struct_val"}}, }}, }}, }}, ValueField: &structpb.Value{Kind: &structpb.Value_StructValue{ StructValue: &structpb.Struct{Fields: map[string]*structpb.Value{ "value_struct_key": {Kind: &structpb.Value_StringValue{StringValue: "value_struct_val"}}, }}, }}, } payload, err := protojson.MarshalOptions{UseProtoNames: true}.Marshal(sent) if err != nil { t.Fatalf("marshaler.Marshal(%#v) failed with %v; want success", payload, err) } apiURL := "http://localhost:8088/v1/example/echo_patch" req, err := http.NewRequest("PATCH", apiURL, bytes.NewReader(payload)) if err != nil { t.Errorf("http.NewRequest(PATCH, %q) failed with %v; want success", apiURL, err) return } resp, err := http.DefaultClient.Do(req) if err != nil { t.Errorf("http.Post(%#v) failed with %v; want success", req, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } var received examplepb.DynamicMessageUpdate if err := marshaler.Unmarshal(buf, &received); err != nil { t.Errorf("marshaler.Unmarshal(%s, msg) failed with %v; want success", buf, err) return } if diff := cmp.Diff(received.Body, sent, protocmp.Transform()); diff != "" { t.Error(diff) } if diff := cmp.Diff(received.UpdateMask, fieldmaskpb.FieldMask{Paths: []string{ "struct_field.struct_key.layered_struct_key", "value_field.value_struct_key", }}, protocmp.Transform(), protocmp.SortRepeatedFields(received.UpdateMask, "paths")); diff != "" { t.Error(diff) } } func TestForwardResponseOption(t *testing.T) { if testing.Short() { t.Skip() return } ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() port := 7079 go func() { if err := runGateway( ctx, fmt.Sprintf(":%d", port), runtime.WithForwardResponseOption( func(_ context.Context, w http.ResponseWriter, _ proto.Message) error { w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1.1+json") return nil }, ), ); err != nil { t.Errorf("runGateway() failed with %v; want success", err) return } }() if err := waitForGateway(ctx, uint16(port)); err != nil { t.Errorf("waitForGateway(ctx, %d) failed with %v; want success", port, err) } testEcho(t, port, "v1", "application/vnd.docker.plugins.v1.1+json") } func TestForwardResponseOptionHTTPPathPattern(t *testing.T) { if testing.Short() { t.Skip() return } ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() port := 7080 go func() { if err := runGateway( ctx, fmt.Sprintf(":%d", port), runtime.WithForwardResponseOption( func(ctx context.Context, w http.ResponseWriter, _ proto.Message) error { path, _ := runtime.HTTPPathPattern(ctx) w.Header().Set("Content-Type", path) return nil }, ), ); err != nil { t.Errorf("runGateway() failed with %v; want success", err) return } }() if err := waitForGateway(ctx, uint16(port)); err != nil { t.Errorf("waitForGateway(ctx, %d) failed with %v; want success", port, err) } testEcho(t, port, "v1", "/v1/example/echo/{id}") } func testEcho(t *testing.T, port int, apiPrefix string, contentType string) { apiURL := fmt.Sprintf("http://localhost:%d/%s/example/echo/myid", port, apiPrefix) resp, err := http.Post(apiURL, "application/json", strings.NewReader("{}")) if err != nil { t.Errorf("http.Post(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } msg := new(examplepb.UnannotatedSimpleMessage) if err := marshaler.Unmarshal(buf, msg); err != nil { t.Errorf("marshaler.Unmarshal(%s, msg) failed with %v; want success", buf, err) return } if got, want := msg.Id, "myid"; got != want { t.Errorf("msg.Id = %q; want %q", got, want) } if value := resp.Header.Get("Content-Type"); value != contentType { t.Errorf("Content-Type was %s, wanted %s", value, contentType) } } func testEchoOneof(t *testing.T, port int, apiPrefix string, contentType string) { apiURL := fmt.Sprintf("http://localhost:%d/%s/example/echo/myid/10/golang", port, apiPrefix) resp, err := http.Get(apiURL) if err != nil { t.Errorf("http.Get(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } msg := new(examplepb.UnannotatedSimpleMessage) if err := marshaler.Unmarshal(buf, msg); err != nil { t.Errorf("marshaler.Unmarshal(%s, msg) failed with %v; want success", buf, err) return } if got, want := msg.GetLang(), "golang"; got != want { t.Errorf("msg.GetLang() = %q; want %q", got, want) } if value := resp.Header.Get("Content-Type"); value != contentType { t.Errorf("Content-Type was %s, wanted %s", value, contentType) } } func testEchoOneof1(t *testing.T, port int, apiPrefix string, contentType string) { apiURL := fmt.Sprintf("http://localhost:%d/%s/example/echo1/myid/10/golang", port, apiPrefix) resp, err := http.Get(apiURL) if err != nil { t.Errorf("http.Get(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } msg := new(examplepb.UnannotatedSimpleMessage) if err := marshaler.Unmarshal(buf, msg); err != nil { t.Errorf("marshaler.Unmarshal(%s, msg) failed with %v; want success", buf, err) return } if got, want := msg.GetStatus().GetNote(), "golang"; got != want { t.Errorf("msg.GetStatus().GetNote() = %q; want %q", got, want) } if value := resp.Header.Get("Content-Type"); value != contentType { t.Errorf("Content-Type was %s, wanted %s", value, contentType) } } func testEchoOneof2(t *testing.T, port int, apiPrefix string, contentType string) { apiURL := fmt.Sprintf("http://localhost:%d/%s/example/echo2/golang", port, apiPrefix) resp, err := http.Get(apiURL) if err != nil { t.Errorf("http.Get(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } msg := new(examplepb.UnannotatedSimpleMessage) if err := marshaler.Unmarshal(buf, msg); err != nil { t.Errorf("marshaler.Unmarshal(%s, msg) failed with %v; want success", buf, err) return } if got, want := msg.GetNo().GetNote(), "golang"; got != want { t.Errorf("msg.GetNo().GetNote() = %q; want %q", got, want) } if value := resp.Header.Get("Content-Type"); value != contentType { t.Errorf("Content-Type was %s, wanted %s", value, contentType) } } func testEchoPathParamOverwrite(t *testing.T, port int) { apiURL := fmt.Sprintf("http://localhost:%d/v1/example/echo/resource/my_resource_id?resourceId=bad_resource_id", port) resp, err := http.Get(apiURL) if err != nil { t.Errorf("http.Get(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } msg := new(examplepb.UnannotatedSimpleMessage) if err := marshaler.Unmarshal(buf, msg); err != nil { t.Errorf("marshaler.Unmarshal(%s, msg) failed with %v; want success", buf, err) return } if got, want := msg.GetResourceId(), "my_resource_id"; got != want { t.Errorf("msg.GetResourceId() = %q; want %q", got, want) } } func testEchoNested(t *testing.T, port int) { resp, err := http.Get(fmt.Sprintf("http://localhost:%d/v1/example/echo/nested/my_nested_id?n_id.val=foo", port)) if err != nil { t.Errorf("http.Get() failed with %v; want success", err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } msg := new(examplepb.UnannotatedSimpleMessage) if err := marshaler.Unmarshal(buf, msg); err != nil { t.Errorf("marshaler.Unmarshal(%s, msg) failed with %v; want success", buf, err) return } if got, want := msg.NId.Val, "foo"; got != want { t.Errorf("msg.NId.Val = %q; want %q", got, want) } } func testEchoNestedOverride(t *testing.T, port int) { resp, err := http.Get(fmt.Sprintf("http://localhost:%d/v1/example/echo/nested/my_nested_id?nId.nId=bad_id", port)) if err != nil { t.Errorf("http.Get() failed with %v; want success", err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } msg := new(examplepb.UnannotatedSimpleMessage) if err := marshaler.Unmarshal(buf, msg); err != nil { t.Errorf("marshaler.Unmarshal(%s, msg) failed with %v; want success", buf, err) return } if got, want := msg.NId.NId, "my_nested_id"; got != want { t.Errorf("msg.NId.NId = %q; want %q", got, want) } } func testEchoBody(t *testing.T, port int, apiPrefix string, useTrailers bool) { sent := examplepb.UnannotatedSimpleMessage{Id: "example"} payload, err := marshaler.Marshal(&sent) if err != nil { t.Fatalf("marshaler.Marshal(%#v) failed with %v; want success", payload, err) } apiURL := fmt.Sprintf("http://localhost:%d/%s/example/echo_body", port, apiPrefix) req, err := http.NewRequest("POST", apiURL, bytes.NewReader(payload)) if err != nil { t.Errorf("http.NewRequest() failed with %v; want success", err) return } if useTrailers { req.Header.Set("TE", "trailers") } resp, err := http.DefaultClient.Do(req) if err != nil { t.Errorf("client.Do(%v) failed with %v; want success", req, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } var received examplepb.UnannotatedSimpleMessage if err := marshaler.Unmarshal(buf, &received); err != nil { t.Errorf("marshaler.Unmarshal(%s, msg) failed with %v; want success", buf, err) return } if diff := cmp.Diff(&received, &sent, protocmp.Transform()); diff != "" { t.Error(diff) } if got, want := resp.Header.Get("Grpc-Metadata-Foo"), "foo1"; got != want { t.Errorf("Grpc-Metadata-Foo was %q, wanted %q", got, want) } if got, want := resp.Header.Get("Grpc-Metadata-Bar"), "bar1"; got != want { t.Errorf("Grpc-Metadata-Bar was %q, wanted %q", got, want) } wantedTrailers := map[bool]map[string]string{ true: { "Grpc-Trailer-Foo": "foo2", "Grpc-Trailer-Bar": "bar2", }, false: {}, } for trailer, want := range wantedTrailers[useTrailers] { if got := resp.Trailer.Get(trailer); got != want { t.Errorf("%s was %q, wanted %q", trailer, got, want) } } } func TestABE(t *testing.T) { if testing.Short() { t.Skip() return } testABECreate(t, 8088) testABECreateBody(t, 8088) testABEBulkCreate(t, 8088, true) testABEBulkCreate(t, 8088, false) testABEBulkCreateWithError(t, 8088) testABELookup(t, 8088) testABELookupNotFound(t, 8088, true) testABELookupNotFound(t, 8088, false) testABEList(t, 8088) testABEDownload(t, 8088) testABEBulkEcho(t, 8088) testABEBulkEchoZeroLength(t, 8088) testAdditionalBindings(t, 8088) testABERepeated(t, 8088) testABEExists(t, 8088) testABEExistsNotFound(t, 8088) testABEOptions(t, 8088) testABETrace(t, 8088) } func testABECreate(t *testing.T, port int) { want := &examplepb.ABitOfEverything{ FloatValue: 1.5, DoubleValue: 2.5, Int64Value: 4294967296, Uint64Value: 9223372036854775807, Int32Value: -2147483648, Fixed64Value: 9223372036854775807, Fixed32Value: 4294967295, BoolValue: true, StringValue: "strprefix/foo", Uint32Value: 4294967295, Sfixed32Value: 2147483647, Sfixed64Value: -4611686018427387904, Sint32Value: 2147483647, Sint64Value: 4611686018427387903, NonConventionalNameValue: "camelCase", EnumValue: examplepb.NumericEnum_ZERO, PathEnumValue: pathenum.PathEnum_DEF, NestedPathEnumValue: pathenum.MessagePathEnum_JKL, EnumValueAnnotation: examplepb.NumericEnum_ONE, } apiURL := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything/%f/%f/%d/separator/%d/%d/%d/%d/%v/%s/%d/%d/%d/%d/%d/%s/%s/%s/%s/%s", port, want.FloatValue, want.DoubleValue, want.Int64Value, want.Uint64Value, want.Int32Value, want.Fixed64Value, want.Fixed32Value, want.BoolValue, want.StringValue, want.Uint32Value, want.Sfixed32Value, want.Sfixed64Value, want.Sint32Value, want.Sint64Value, want.NonConventionalNameValue, want.EnumValue, want.PathEnumValue, want.NestedPathEnumValue, want.EnumValueAnnotation) resp, err := http.Post(apiURL, "application/json", strings.NewReader("{}")) if err != nil { t.Errorf("http.Post(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } msg := new(examplepb.ABitOfEverything) if err := marshaler.Unmarshal(buf, msg); err != nil { t.Errorf("marshaler.Unmarshal(%s, msg) failed with %v; want success", buf, err) return } if msg.Uuid == "" { t.Error("msg.Uuid is empty; want not empty") } msg.Uuid = "" if diff := cmp.Diff(msg, want, protocmp.Transform()); diff != "" { t.Error(diff) } } func testABECreateBody(t *testing.T, port int) { optionalStrVal := "optional-str" want := &examplepb.ABitOfEverything{ FloatValue: 1.5, DoubleValue: 2.5, Int64Value: 4294967296, Uint64Value: 9223372036854775807, Int32Value: -2147483648, Fixed64Value: 9223372036854775807, Fixed32Value: 4294967295, BoolValue: true, StringValue: "strprefix/foo", Uint32Value: 4294967295, Sfixed32Value: 2147483647, Sfixed64Value: -4611686018427387904, Sint32Value: 2147483647, Sint64Value: 4611686018427387903, NonConventionalNameValue: "camelCase", EnumValue: examplepb.NumericEnum_ONE, PathEnumValue: pathenum.PathEnum_ABC, NestedPathEnumValue: pathenum.MessagePathEnum_GHI, Nested: []*examplepb.ABitOfEverything_Nested{ { Name: "bar", Amount: 10, }, { Name: "baz", Amount: 20, }, }, RepeatedStringValue: []string{"a", "b", "c"}, OneofValue: &examplepb.ABitOfEverything_OneofString{ OneofString: "x", }, MapValue: map[string]examplepb.NumericEnum{ "a": examplepb.NumericEnum_ONE, "b": examplepb.NumericEnum_ZERO, }, MappedStringValue: map[string]string{ "a": "x", "b": "y", }, MappedNestedValue: map[string]*examplepb.ABitOfEverything_Nested{ "a": {Name: "x", Amount: 1}, "b": {Name: "y", Amount: 2}, }, RepeatedEnumAnnotation: []examplepb.NumericEnum{ examplepb.NumericEnum_ONE, examplepb.NumericEnum_ZERO, }, EnumValueAnnotation: examplepb.NumericEnum_ONE, RepeatedStringAnnotation: []string{ "a", "b", }, RepeatedNestedAnnotation: []*examplepb.ABitOfEverything_Nested{ { Name: "hoge", Amount: 10, }, { Name: "fuga", Amount: 20, }, }, NestedAnnotation: &examplepb.ABitOfEverything_Nested{ Name: "hoge", Amount: 10, }, OptionalStringValue: &optionalStrVal, } apiURL := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything", port) payload, err := marshaler.Marshal(want) if err != nil { t.Fatalf("marshaler.Marshal(%#v) failed with %v; want success", want, err) } resp, err := http.Post(apiURL, "application/json", bytes.NewReader(payload)) if err != nil { t.Errorf("http.Post(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } msg := new(examplepb.ABitOfEverything) if err := marshaler.Unmarshal(buf, msg); err != nil { t.Errorf("marshaler.Unmarshal(%s, msg) failed with %v; want success", buf, err) return } if msg.Uuid == "" { t.Error("msg.Uuid is empty; want not empty") } msg.Uuid = "" if diff := cmp.Diff(msg, want, protocmp.Transform()); diff != "" { t.Error(diff) } } func testABEBulkCreate(t *testing.T, port int, useTrailers bool) { count := 0 r, w := io.Pipe() go func(w io.WriteCloser) { defer func() { if cerr := w.Close(); cerr != nil { t.Errorf("w.Close() failed with %v; want success", cerr) } }() for _, val := range []string{ "foo", "bar", "baz", "qux", "quux", } { strVal := fmt.Sprintf("strprefix/%s", val) want := &examplepb.ABitOfEverything{ FloatValue: 1.5, DoubleValue: 2.5, Int64Value: 4294967296, Uint64Value: 9223372036854775807, Int32Value: -2147483648, Fixed64Value: 9223372036854775807, Fixed32Value: 4294967295, BoolValue: true, StringValue: strVal, Uint32Value: 4294967295, Sfixed32Value: 2147483647, Sfixed64Value: -4611686018427387904, Sint32Value: 2147483647, Sint64Value: 4611686018427387903, NonConventionalNameValue: "camelCase", EnumValue: examplepb.NumericEnum_ONE, PathEnumValue: pathenum.PathEnum_ABC, NestedPathEnumValue: pathenum.MessagePathEnum_GHI, Nested: []*examplepb.ABitOfEverything_Nested{ { Name: "hoge", Amount: 10, }, { Name: "fuga", Amount: 20, }, }, RepeatedEnumAnnotation: []examplepb.NumericEnum{ examplepb.NumericEnum_ONE, examplepb.NumericEnum_ZERO, }, EnumValueAnnotation: examplepb.NumericEnum_ONE, RepeatedStringAnnotation: []string{ "a", "b", }, RepeatedNestedAnnotation: []*examplepb.ABitOfEverything_Nested{ { Name: "hoge", Amount: 10, }, { Name: "fuga", Amount: 20, }, }, NestedAnnotation: &examplepb.ABitOfEverything_Nested{ Name: "hoge", Amount: 10, }, OptionalStringValue: &strVal, } out, err := marshaler.Marshal(want) if err != nil { t.Errorf("marshaler.Marshal(%#v, w) failed with %v; want success", want, err) return } if _, err := w.Write(out); err != nil { t.Errorf("w.Write() failed with %v; want success", err) return } if _, err := io.WriteString(w, "\n"); err != nil { t.Errorf("w.Write(%q) failed with %v; want success", "\n", err) return } count++ } }(w) apiURL := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything/bulk", port) req, err := http.NewRequest("POST", apiURL, r) if err != nil { t.Errorf("http.NewRequest() failed with %v; want success", err) return } req.Header.Set("Content-Type", "application/json") if useTrailers { req.Header.Set("TE", "trailers") } resp, err := http.DefaultClient.Do(req) if err != nil { t.Errorf("client.Do(%v) failed with %v; want success", req, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } msg := new(emptypb.Empty) if err := marshaler.Unmarshal(buf, msg); err != nil { t.Errorf("marshaler.Unmarshal(%s, msg) failed with %v; want success", buf, err) return } if got, want := resp.Header.Get("Grpc-Metadata-Count"), fmt.Sprintf("%d", count); got != want { t.Errorf("Grpc-Metadata-Count was %q, wanted %q", got, want) } wantedTrailers := map[bool]map[string]string{ true: { "Grpc-Trailer-Foo": "foo2", "Grpc-Trailer-Bar": "bar2", }, false: {}, } for trailer, want := range wantedTrailers[useTrailers] { if got := resp.Trailer.Get(trailer); got != want { t.Errorf("%s was %q, wanted %q", trailer, got, want) } } } func testABEBulkCreateWithError(t *testing.T, port int) { count := 0 r, w := io.Pipe() go func(w io.WriteCloser) { defer func() { if cerr := w.Close(); cerr != nil { t.Errorf("w.Close() failed with %v; want success", cerr) } }() for _, val := range []string{ "foo", "bar", "baz", "qux", "quux", } { time.Sleep(1 * time.Millisecond) want := &examplepb.ABitOfEverything{ StringValue: fmt.Sprintf("strprefix/%s", val), } out, err := marshaler.Marshal(want) if err != nil { t.Errorf("marshaler.Marshal(%#v, w) failed with %v; want success", want, err) return } if _, err := w.Write(out); err != nil { t.Errorf("w.Write() failed with %v; want success", err) return } if _, err := io.WriteString(w, "\n"); err != nil { t.Errorf("w.Write(%q) failed with %v; want success", "\n", err) return } count++ } }(w) apiURL := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything/bulk", port) request, err := http.NewRequest("POST", apiURL, r) if err != nil { t.Fatalf("http.NewRequest(%q, %q, nil) failed with %v; want success", "POST", apiURL, err) } request.Header.Add("Grpc-Metadata-error", "some error") resp, err := http.DefaultClient.Do(request) if err != nil { t.Errorf("http.Post(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusBadRequest; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } msg := new(statuspb.Status) if err := marshaler.Unmarshal(buf, msg); err != nil { t.Fatalf("marshaler.Unmarshal(%s, msg) failed with %v; want success", buf, err) } } func testABELookup(t *testing.T, port int) { apiURL := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything", port) cresp, err := http.Post(apiURL, "application/json", strings.NewReader(` {"bool_value": true, "string_value": "strprefix/example"} `)) if err != nil { t.Errorf("http.Post(%q) failed with %v; want success", apiURL, err) return } defer cresp.Body.Close() buf, err := io.ReadAll(cresp.Body) if err != nil { t.Errorf("io.ReadAll(cresp.Body) failed with %v; want success", err) return } if got, want := cresp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) return } want := new(examplepb.ABitOfEverything) if err := marshaler.Unmarshal(buf, want); err != nil { t.Errorf("marshaler.Unmarshal(%s, want) failed with %v; want success", buf, err) return } apiURL = fmt.Sprintf("%s/%s", apiURL, want.Uuid) resp, err := http.Get(apiURL) if err != nil { t.Errorf("http.Get(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() buf, err = io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } msg := new(examplepb.ABitOfEverything) if err := marshaler.Unmarshal(buf, msg); err != nil { t.Errorf("marshaler.Unmarshal(%s, msg) failed with %v; want success", buf, err) return } if diff := cmp.Diff(msg, want, protocmp.Transform()); diff != "" { t.Error(diff) } if got, want := resp.Header.Get("Grpc-Metadata-Uuid"), want.Uuid; got != want { t.Errorf("Grpc-Metadata-Uuid was %s, wanted %s", got, want) } } // TestABEPatch demonstrates partially updating a resource. // First, we'll create an ABE resource with known values for string_value and int32_value // Then, issue a PATCH request updating only the string_value // Then, GET the resource and verify that string_value is changed, but int32_value isn't func TestABEPatch(t *testing.T) { if testing.Short() { t.Skip() return } port := 8088 // create a record with a known string_value and int32_value uuid := postABE(t, port, &examplepb.ABitOfEverything{StringValue: "strprefix/bar", Int32Value: 32}) // issue PATCH request, only updating string_value req, err := http.NewRequest( http.MethodPatch, fmt.Sprintf("http://localhost:%d/v2/example/a_bit_of_everything/%s", port, uuid), strings.NewReader(`{"string_value": "strprefix/foo"}`), ) if err != nil { t.Fatalf("http.NewRequest(PATCH) failed with %v; want success", err) } patchResp, err := http.DefaultClient.Do(req) if err != nil { t.Fatalf("failed to issue PATCH request: %v", err) } if got, want := patchResp.StatusCode, http.StatusOK; got != want { if body, err := io.ReadAll(patchResp.Body); err != nil { t.Errorf("patchResp body couldn't be read: %v", err) } else { t.Errorf("patchResp.StatusCode= %d; want %d resp: %v", got, want, string(body)) } } // issue GET request, verifying that string_value is changed and int32_value is not getRestatuspbody := getABE(t, port, uuid) if got, want := getRestatuspbody.StringValue, "strprefix/foo"; got != want { t.Errorf("string_value= %q; want %q", got, want) } if got, want := getRestatuspbody.Int32Value, int32(32); got != want { t.Errorf("int_32_value= %d; want %d", got, want) } } // TestABEPatchBody demonstrates the ability to specify an update mask within the request body. // This binding does not use an automatically generated update_mask. func TestABEPatchBody(t *testing.T) { if testing.Short() { t.Skip() return } port := 8088 for _, tc := range []struct { name string originalValue *examplepb.ABitOfEverything input *examplepb.UpdateV2Request want *examplepb.ABitOfEverything }{ { name: "with fieldmask provided", originalValue: &examplepb.ABitOfEverything{ Int32Value: 42, StringValue: "rabbit", SingleNested: &examplepb.ABitOfEverything_Nested{ Name: "some value that will get overwritten", Amount: 345, }, }, input: &examplepb.UpdateV2Request{ Abe: &examplepb.ABitOfEverything{ StringValue: "some value that won't get updated because it's not in the field mask", SingleNested: &examplepb.ABitOfEverything_Nested{ Amount: 456, }, }, UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"single_nested"}}, }, want: &examplepb.ABitOfEverything{ Int32Value: 42, StringValue: "rabbit", SingleNested: &examplepb.ABitOfEverything_Nested{ Amount: 456, }, }, }, { // N.B. This case passes the empty field mask to the UpdateV2 method so falls back to PUT semantics as per the implementation. name: "with empty fieldmask", originalValue: &examplepb.ABitOfEverything{ Int32Value: 42, StringValue: "some value that will get overwritten", SingleNested: &examplepb.ABitOfEverything_Nested{ Name: "value that will get empty", Amount: 345, }, }, input: &examplepb.UpdateV2Request{ Abe: &examplepb.ABitOfEverything{ StringValue: "some updated value because the fieldMask is nil", SingleNested: &examplepb.ABitOfEverything_Nested{ Amount: 456, }, }, UpdateMask: &fieldmaskpb.FieldMask{}, }, want: &examplepb.ABitOfEverything{ StringValue: "some updated value because the fieldMask is nil", SingleNested: &examplepb.ABitOfEverything_Nested{ Amount: 456, }, }, }, { // N.B. This case passes the nil field mask to the UpdateV2 method so falls back to PUT semantics as per the implementation. name: "with nil fieldmask", originalValue: &examplepb.ABitOfEverything{ Int32Value: 42, StringValue: "some value that will get overwritten", SingleNested: &examplepb.ABitOfEverything_Nested{ Name: "value that will get empty", Amount: 123, }, }, input: &examplepb.UpdateV2Request{ Abe: &examplepb.ABitOfEverything{ StringValue: "some updated value because the fieldMask is nil", SingleNested: &examplepb.ABitOfEverything_Nested{ Amount: 657, }, }, UpdateMask: nil, }, want: &examplepb.ABitOfEverything{ StringValue: "some updated value because the fieldMask is nil", SingleNested: &examplepb.ABitOfEverything_Nested{ Amount: 657, }, }, }, } { t.Run(tc.name, func(t *testing.T) { originalABE := tc.originalValue uuid := postABE(t, port, originalABE) patchBody := tc.input patchReq, err := http.NewRequest( http.MethodPatch, fmt.Sprintf("http://localhost:%d/v2a/example/a_bit_of_everything/%s", port, uuid), strings.NewReader(mustMarshal(t, patchBody)), ) if err != nil { t.Fatalf("http.NewRequest(PATCH) failed with %v; want success", err) } patchResp, err := http.DefaultClient.Do(patchReq) if err != nil { t.Fatalf("failed to issue PATCH request: %v", err) } if got, want := patchResp.StatusCode, http.StatusOK; got != want { if body, err := io.ReadAll(patchResp.Body); err != nil { t.Errorf("patchResp body couldn't be read: %v", err) } else { t.Errorf("patchResp.StatusCode= %d; want %d resp: %v", got, want, string(body)) } } want, got := tc.want, getABE(t, port, uuid) got.Uuid = "" // empty out uuid so we don't need to worry about it in comparisons if diff := cmp.Diff(got, want, protocmp.Transform()); diff != "" { t.Error(diff) } }) } } // mustMarshal marshals the given object into a json string, calling t.Fatal if an error occurs. Useful in testing to // inline marshalling whenever you don't expect the marshalling to return an error func mustMarshal(t *testing.T, i interface{}) string { b, err := marshaler.Marshal(i) if err != nil { t.Fatalf("failed to marshal %#v: %v", i, err) } return string(b) } // postABE conveniently creates a new ABE record for ease in testing func postABE(t *testing.T, port int, abe *examplepb.ABitOfEverything) (uuid string) { apiURL := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything", port) postResp, err := http.Post(apiURL, "application/json", strings.NewReader(mustMarshal(t, abe))) if err != nil { t.Fatalf("http.Post(%q) failed with %v; want success", apiURL, err) return } body, err := io.ReadAll(postResp.Body) if err != nil { t.Fatalf("postResp body couldn't be read: %v", err) } var f struct { UUID string `json:"uuid"` } if err := marshaler.Unmarshal(body, &f); err != nil { t.Fatalf("postResp body couldn't be unmarshalled: %v. body: %s", err, string(body)) } if f.UUID == "" { t.Fatalf("want uuid from postResp, but got none. body: %s", string(body)) } return f.UUID } // getABE conveniently fetches an ABE record for ease in testing func getABE(t *testing.T, port int, uuid string) *examplepb.ABitOfEverything { gURL := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything/%s", port, uuid) getResp, err := http.Get(gURL) if err != nil { t.Fatalf("http.Get(%s) failed with %v; want success", gURL, err) } defer getResp.Body.Close() if got, want := getResp.StatusCode, http.StatusOK; got != want { t.Fatalf("getResp.StatusCode= %d, want %d. resp: %v", got, want, getResp) } var getRestatuspbody examplepb.ABitOfEverything body, err := io.ReadAll(getResp.Body) if err != nil { t.Fatalf("getResp body couldn't be read: %v", err) } if err := marshaler.Unmarshal(body, &getRestatuspbody); err != nil { t.Fatalf("getResp body couldn't be unmarshalled: %v body: %s", err, string(body)) } return &getRestatuspbody } func testABELookupNotFound(t *testing.T, port int, useTrailers bool) { apiURL := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything", port) uuid := "not_exist" apiURL = fmt.Sprintf("%s/%s", apiURL, uuid) req, err := http.NewRequest("GET", apiURL, nil) if err != nil { t.Errorf("http.NewRequest() failed with %v; want success", err) return } if useTrailers { req.Header.Set("TE", "trailers") } resp, err := http.DefaultClient.Do(req) if err != nil { t.Errorf("client.Do(%v) failed with %v; want success", req, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusNotFound; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) return } msg := new(statuspb.Status) if err := marshaler.Unmarshal(buf, msg); err != nil { t.Errorf("marshaler.Unmarshal(%s, msg) failed with %v; want success", buf, err) return } if got, want := msg.Code, int32(codes.NotFound); got != want { t.Errorf("msg.Code = %d; want %d", got, want) return } if got, want := msg.Message, "not found"; got != want { t.Errorf("msg.Message = %s; want %s", got, want) return } if got, want := resp.Header.Get("Grpc-Metadata-Uuid"), uuid; got != want { t.Errorf("Grpc-Metadata-Uuid was %s, wanted %s", got, want) } trailers := map[bool]map[string]string{ true: { "Grpc-Trailer-Foo": "foo2", "Grpc-Trailer-Bar": "bar2", }, false: { "Grpc-Trailer-Foo": "", "Grpc-Trailer-Bar": "", }, } for trailer, want := range trailers[useTrailers] { if got := resp.Trailer.Get(trailer); got != want { t.Errorf("%s was %q, wanted %q", trailer, got, want) } } } func testABEList(t *testing.T, port int) { apiURL := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything", port) resp, err := http.Get(apiURL) if err != nil { t.Errorf("http.Get(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() dec := marshaler.NewDecoder(resp.Body) var i int for i = 0; ; i++ { var item struct { Result json.RawMessage `json:"result"` Error map[string]interface{} `json:"error"` } err := dec.Decode(&item) if err == io.EOF { break } if err != nil { t.Errorf("dec.Decode(&item) failed with %v; want success; i = %d", err, i) } if len(item.Error) != 0 { t.Errorf("item.Error = %#v; want empty; i = %d", item.Error, i) continue } msg := new(examplepb.ABitOfEverything) if err := marshaler.Unmarshal(item.Result, msg); err != nil { t.Errorf("marshaler.Unmarshal(%s, msg) failed with %v; want success", item.Result, err) } } if i <= 0 { t.Errorf("i == %d; want > 0", i) } value := resp.Header.Get("Grpc-Metadata-Count") if value == "" { t.Errorf("Grpc-Metadata-Count should not be empty") } count, err := strconv.Atoi(value) if err != nil { t.Errorf("failed to Atoi %q: %v", value, err) } if count <= 0 { t.Errorf("count == %d; want > 0", count) } } func testABEDownload(t *testing.T, port int) { apiURL := fmt.Sprintf("http://localhost:%d/v1/example/download", port) resp, err := http.Get(apiURL) if err != nil { t.Errorf("http.Get(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() wantHeader := "text/html" if value := resp.Header.Get("Content-Type"); value != wantHeader { t.Fatalf("testABEDownload() Content-Type failed: got %s, want %s", value, wantHeader) } body, err := readAll(resp.Body) if err != nil { t.Fatalf("readAll(resp.Body) failed with %v; want success", err) } want := []string{"Hello 1", "Hello 2"} if !reflect.DeepEqual(body, want) { t.Errorf("testABEDownload() failed: got %v, want %v", body, want) } } func testABEBulkEcho(t *testing.T, port int) { reqr, reqw := io.Pipe() var wg sync.WaitGroup var want []*sub.StringMessage wg.Add(1) go func() { defer wg.Done() defer reqw.Close() for i := 0; i < 10; i++ { s := fmt.Sprintf("message %d", i) msg := &sub.StringMessage{Value: &s} buf, err := marshaler.Marshal(msg) if err != nil { t.Errorf("marshaler.Marshal(%v) failed with %v; want success", msg, err) return } if _, err = reqw.Write(buf); err != nil { t.Errorf("reqw.Write(%q) failed with %v; want success", string(buf), err) return } want = append(want, msg) } }() apiURL := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything/echo", port) req, err := http.NewRequest("POST", apiURL, reqr) if err != nil { t.Errorf("http.NewRequest(%q, %q, reqr) failed with %v; want success", "POST", apiURL, err) return } req.Header.Set("Content-Type", "application/json") req.Header.Set("Transfer-Encoding", "chunked") resp, err := http.DefaultClient.Do(req) if err != nil { t.Errorf("http.Post(%q, %q, req) failed with %v; want success", apiURL, "application/json", err) return } defer resp.Body.Close() if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) } var got []*sub.StringMessage wg.Add(1) go func() { defer wg.Done() dec := marshaler.NewDecoder(resp.Body) for i := 0; ; i++ { var item struct { Result json.RawMessage `json:"result"` Error map[string]interface{} `json:"error"` } err := dec.Decode(&item) if err == io.EOF { break } if err != nil { t.Errorf("dec.Decode(&item) failed with %v; want success; i = %d", err, i) } if len(item.Error) != 0 { t.Errorf("item.Error = %#v; want empty; i = %d", item.Error, i) continue } msg := new(sub.StringMessage) if err := marshaler.Unmarshal(item.Result, msg); err != nil { t.Errorf("marshaler.Unmarshal(%q, msg) failed with %v; want success", item.Result, err) } got = append(got, msg) } }() wg.Wait() if diff := cmp.Diff(got, want, protocmp.Transform()); diff != "" { t.Error(diff) } } func testABEBulkEchoZeroLength(t *testing.T, port int) { apiURL := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything/echo", port) req, err := http.NewRequest("POST", apiURL, bytes.NewReader(nil)) if err != nil { t.Errorf("http.NewRequest(%q, %q, bytes.NewReader(nil)) failed with %v; want success", "POST", apiURL, err) return } req.Header.Set("Content-Type", "application/json") req.Header.Set("Transfer-Encoding", "chunked") resp, err := http.DefaultClient.Do(req) if err != nil { t.Errorf("http.Post(%q, %q, req) failed with %v; want success", apiURL, "application/json", err) return } defer resp.Body.Close() if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) } dec := marshaler.NewDecoder(resp.Body) var item struct { Result json.RawMessage `json:"result"` Error map[string]interface{} `json:"error"` } if err := dec.Decode(&item); err == nil { t.Errorf("dec.Decode(&item) succeeded; want io.EOF; item = %#v", item) } else if err != io.EOF { t.Errorf("dec.Decode(&item) failed with %v; want success", err) return } } func testAdditionalBindings(t *testing.T, port int) { for i, f := range []func() *http.Response{ func() *http.Response { apiURL := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything/echo/hello", port) resp, err := http.Get(apiURL) if err != nil { t.Errorf("http.Get(%q) failed with %v; want success", apiURL, err) return nil } return resp }, func() *http.Response { apiURL := fmt.Sprintf("http://localhost:%d/v2/example/echo", port) resp, err := http.Post(apiURL, "application/json", strings.NewReader(`"hello"`)) if err != nil { t.Errorf("http.Post(%q, %q, %q) failed with %v; want success", apiURL, "application/json", `"hello"`, err) return nil } return resp }, func() *http.Response { r, w := io.Pipe() go func() { defer w.Close() w.Write([]byte(`"hello"`)) }() apiURL := fmt.Sprintf("http://localhost:%d/v2/example/echo", port) resp, err := http.Post(apiURL, "application/json", r) if err != nil { t.Errorf("http.Post(%q, %q, %q) failed with %v; want success", apiURL, "application/json", `"hello"`, err) return nil } return resp }, func() *http.Response { apiURL := fmt.Sprintf("http://localhost:%d/v2/example/echo?value=hello", port) resp, err := http.Get(apiURL) if err != nil { t.Errorf("http.Get(%q) failed with %v; want success", apiURL, err) return nil } return resp }, } { resp := f() if resp == nil { continue } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success; i=%d", err, i) return } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d; i=%d", got, want, i) t.Logf("%s", buf) } msg := new(sub.StringMessage) if err := marshaler.Unmarshal(buf, msg); err != nil { t.Errorf("marshaler.Unmarshal(%s, msg) failed with %v; want success; %d", buf, err, i) return } if got, want := msg.GetValue(), "hello"; got != want { t.Errorf("msg.GetValue() = %q; want %q", got, want) } } } func testABERepeated(t *testing.T, port int) { f := func(v reflect.Value) string { var f func(v reflect.Value, idx int) string s := make([]string, v.Len()) switch v.Index(0).Kind() { case reflect.Slice: f = func(v reflect.Value, idx int) string { t := v.Index(idx).Type().Elem().Kind() if t == reflect.Uint8 { return base64.URLEncoding.EncodeToString(v.Index(idx).Interface().([]byte)) } // Could handle more elegantly panic("unknown slice of type: " + t.String()) } default: f = func(v reflect.Value, idx int) string { return fmt.Sprintf("%v", v.Index(idx).Interface()) } } for i := 0; i < v.Len(); i++ { s[i] = f(v, i) } return strings.Join(s, ",") } want := &examplepb.ABitOfEverythingRepeated{ PathRepeatedFloatValue: []float32{ 1.5, -1.5, }, PathRepeatedDoubleValue: []float64{ 2.5, -2.5, }, PathRepeatedInt64Value: []int64{ 4294967296, -4294967296, }, PathRepeatedUint64Value: []uint64{ 0, 9223372036854775807, }, PathRepeatedInt32Value: []int32{ 2147483647, -2147483648, }, PathRepeatedFixed64Value: []uint64{ 0, 9223372036854775807, }, PathRepeatedFixed32Value: []uint32{ 0, 4294967295, }, PathRepeatedBoolValue: []bool{ true, false, }, PathRepeatedStringValue: []string{ "foo", "bar", }, PathRepeatedBytesValue: [][]byte{ {0x00}, {0xFF}, }, PathRepeatedUint32Value: []uint32{ 0, 4294967295, }, PathRepeatedEnumValue: []examplepb.NumericEnum{ examplepb.NumericEnum_ZERO, examplepb.NumericEnum_ONE, }, PathRepeatedSfixed32Value: []int32{ 2147483647, -2147483648, }, PathRepeatedSfixed64Value: []int64{ 4294967296, -4294967296, }, PathRepeatedSint32Value: []int32{ 2147483647, -2147483648, }, PathRepeatedSint64Value: []int64{ 4611686018427387903, -4611686018427387904, }, } apiURL := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything_repeated/%s/%s/%s/%s/%s/%s/%s/%s/%s/%s/%s/%s/%s/%s/%s/%s", port, f(reflect.ValueOf(want.PathRepeatedFloatValue)), f(reflect.ValueOf(want.PathRepeatedDoubleValue)), f(reflect.ValueOf(want.PathRepeatedInt64Value)), f(reflect.ValueOf(want.PathRepeatedUint64Value)), f(reflect.ValueOf(want.PathRepeatedInt32Value)), f(reflect.ValueOf(want.PathRepeatedFixed64Value)), f(reflect.ValueOf(want.PathRepeatedFixed32Value)), f(reflect.ValueOf(want.PathRepeatedBoolValue)), f(reflect.ValueOf(want.PathRepeatedStringValue)), f(reflect.ValueOf(want.PathRepeatedBytesValue)), f(reflect.ValueOf(want.PathRepeatedUint32Value)), f(reflect.ValueOf(want.PathRepeatedEnumValue)), f(reflect.ValueOf(want.PathRepeatedSfixed32Value)), f(reflect.ValueOf(want.PathRepeatedSfixed64Value)), f(reflect.ValueOf(want.PathRepeatedSint32Value)), f(reflect.ValueOf(want.PathRepeatedSint64Value))) resp, err := http.Get(apiURL) if err != nil { t.Errorf("http.Post(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } msg := new(examplepb.ABitOfEverythingRepeated) if err := marshaler.Unmarshal(buf, msg); err != nil { t.Errorf("marshaler.Unmarshal(%s, msg) failed with %v; want success", buf, err) return } if diff := cmp.Diff(msg, want, protocmp.Transform()); diff != "" { t.Error(diff) } } func TestTimeout(t *testing.T) { if testing.Short() { t.Skip() return } apiURL := "http://localhost:8088/v2/example/timeout" req, err := http.NewRequest("GET", apiURL, nil) if err != nil { t.Errorf(`http.NewRequest("GET", %q, nil) failed with %v; want success`, apiURL, err) return } req.Header.Set("Grpc-Timeout", "10m") resp, err := http.DefaultClient.Do(req) if err != nil { t.Errorf("http.DefaultClient.Do(%#v) failed with %v; want success", req, err) return } defer resp.Body.Close() if got, want := resp.StatusCode, http.StatusGatewayTimeout; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) } } func TestInvalidTimeout(t *testing.T) { if testing.Short() { t.Skip() return } apiURL := "http://localhost:8088/v2/example/timeout" req, err := http.NewRequest("GET", apiURL, nil) if err != nil { t.Errorf(`http.NewRequest("GET", %q, nil) failed with %v; want success`, apiURL, err) return } req.Header.Set("Grpc-Timeout", "INVALID") resp, err := http.DefaultClient.Do(req) if err != nil { t.Errorf("http.DefaultClient.Do(%#v) failed with %v; want success", req, err) return } defer resp.Body.Close() if got, want := resp.StatusCode, http.StatusBadRequest; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) } } func TestPostWithEmptyBody(t *testing.T) { if testing.Short() { t.Skip() return } apiURL := "http://localhost:8088/v2/example/postwithemptybody/name" rep, err := http.Post(apiURL, "application/json", nil) if err != nil { t.Errorf("http.Post(%q) failed with %v; want success", apiURL, err) return } if rep.StatusCode != http.StatusOK { t.Errorf("http.Post(%q) response code is %d; want %d", apiURL, rep.StatusCode, http.StatusOK) return } } func TestUnknownPath(t *testing.T) { if testing.Short() { t.Skip() return } apiURL := "http://localhost:8088" resp, err := http.Post(apiURL, "application/json", strings.NewReader("{}")) if err != nil { t.Errorf("http.Post(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusNotFound; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } } func TestNotImplemented(t *testing.T) { if testing.Short() { t.Skip() return } apiURL := "http://localhost:8088/v1/example/echo/myid" resp, err := http.Get(apiURL) if err != nil { t.Errorf("http.Post(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusNotImplemented; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } } func TestInvalidArgument(t *testing.T) { if testing.Short() { t.Skip() return } apiURL := "http://localhost:8088/v1/example/echo/myid/not_int64" resp, err := http.Get(apiURL) if err != nil { t.Errorf("http.Get(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusBadRequest; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } } func TestResponseBody(t *testing.T) { if testing.Short() { t.Skip() return } testResponseBody(t, 8088) testResponseBodies(t, 8088) testResponseStrings(t, 8088) } func testResponseBody(t *testing.T, port int) { apiURL := fmt.Sprintf("http://localhost:%d/responsebody/foo", port) resp, err := http.Get(apiURL) if err != nil { t.Fatalf("http.Get(%q) failed with %v; want success", apiURL, err) } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Fatalf("io.ReadAll(resp.Body) failed with %v; want success", err) } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } if diff := cmp.Diff(string(buf), `{"data":"foo"}`); diff != "" { t.Error(diff) } } func TestResponseBodySameName(t *testing.T) { apiURL := "http://localhost:8088/responsebody/samename/foo" resp, err := http.Get(apiURL) if err != nil { t.Fatalf("http.Get(%q) failed with %v; want success", apiURL, err) } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Fatalf("io.ReadAll(resp.Body) failed with %v; want success", err) } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } if diff := cmp.Diff(string(buf), `"foo"`); diff != "" { t.Error(diff) } } func TestResponseBodyStream(t *testing.T) { apiURL := "http://localhost:8088/responsebody/stream/foo" resp, err := http.Get(apiURL) if err != nil { t.Fatalf("http.Get(%q) failed with %v; want success", apiURL, err) } defer resp.Body.Close() body, err := readAll(resp.Body) if err != nil { t.Fatalf("readAll(resp.Body) failed with %v; want success", err) } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) } if diff := cmp.Diff(body, []string{`{"result":{"data":"first foo"}}`, `{"result":{"data":"second foo"}}`}); diff != "" { t.Error(diff) } } func TestResponseBodyStreamHttpBody(t *testing.T) { apiURL := "http://localhost:8088/v1/example/download" resp, err := http.Get(apiURL) if err != nil { t.Fatalf("http.Get(%q) failed with %v; want success", apiURL, err) } defer resp.Body.Close() body, err := readAll(resp.Body) if err != nil { t.Fatalf("readAll(resp.Body) failed with %v; want success", err) } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) } if diff := cmp.Diff(body, []string{"Hello 1", "Hello 2"}); diff != "" { t.Error(diff) } } func TestResponseBodyStreamHttpBodyError(t *testing.T) { apiURL := "http://localhost:8088/v1/example/download?error=true" resp, err := http.Get(apiURL) if err != nil { t.Fatalf("http.Get(%q) failed with %v; want success", apiURL, err) } defer resp.Body.Close() body, err := readAll(resp.Body) if err != nil { t.Fatalf("readAll(resp.Body) failed with %v; want success", err) } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) } if diff := cmp.Diff(body, []string{"Hello 1", "Hello 2", `{"error":{"code":3,"message":"error","details":[]}}`}); diff != "" { t.Error(diff) } } func readAll(body io.ReadCloser) ([]string, error) { var b []string reader := bufio.NewReader(body) for { l, err := reader.ReadBytes('\n') switch { case err == io.EOF: return b, nil case err != nil: return nil, err } b = append(b, string(bytes.TrimSpace(l))) } } func testResponseBodies(t *testing.T, port int) { apiURL := fmt.Sprintf("http://localhost:%d/responsebodies/foo", port) resp, err := http.Get(apiURL) if err != nil { t.Errorf("http.Get(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } var got []*examplepb.RepeatedResponseBodyOut_Response err = marshaler.Unmarshal(buf, &got) if err != nil { t.Errorf("marshaler.Unmarshal failed with %v; want success", err) return } want := []*examplepb.RepeatedResponseBodyOut_Response{ { Data: "foo", Type: examplepb.RepeatedResponseBodyOut_Response_UNKNOWN, }, } if diff := cmp.Diff(got, want, protocmp.Transform()); diff != "" { t.Error(diff) } } func testResponseStrings(t *testing.T, port int) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() port = 8087 // Run Secondary server with different marshalling ch := make(chan error) go func() { err := runGateway( ctx, fmt.Sprintf(":%d", port), ) if err != nil { ch <- fmt.Errorf("cannot run gateway service: %v", err) } }() if err := waitForGateway(ctx, uint16(port)); err != nil { t.Fatalf("waitForGateway(ctx, %d) failed with %v; want success", port, err) } t.Run("Response strings", func(t *testing.T) { apiURL := fmt.Sprintf("http://localhost:%d/responsestrings/foo", port) resp, err := http.Get(apiURL) if err != nil { t.Errorf("http.Get(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } var got []string err = marshaler.Unmarshal(buf, &got) if err != nil { t.Errorf("marshaler.Unmarshal failed with %v; want success", err) return } want := []string{"hello", "foo"} if diff := cmp.Diff(got, want); diff != "" { t.Error(diff) } }) t.Run("Empty response strings", func(t *testing.T) { apiURL := fmt.Sprintf("http://localhost:%d/responsestrings/empty", port) resp, err := http.Get(apiURL) if err != nil { t.Errorf("http.Get(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } var got []string err = marshaler.Unmarshal(buf, &got) if err != nil { t.Errorf("marshaler.Unmarshal failed with %v; want success", err) return } want := []string{} if diff := cmp.Diff(got, want); diff != "" { t.Error(diff) } }) t.Run("Response bodies", func(t *testing.T) { apiURL := fmt.Sprintf("http://localhost:%d/responsebodies/foo", port) resp, err := http.Get(apiURL) if err != nil { t.Errorf("http.Get(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } var got []*examplepb.RepeatedResponseBodyOut_Response err = marshaler.Unmarshal(buf, &got) if err != nil { t.Errorf("marshaler.Unmarshal failed with %v; want success", err) return } want := []*examplepb.RepeatedResponseBodyOut_Response{ { Data: "foo", Type: examplepb.RepeatedResponseBodyOut_Response_UNKNOWN, }, } if diff := cmp.Diff(got, want, protocmp.Transform()); diff != "" { t.Error(diff) } }) } func TestRequestQueryParams(t *testing.T) { testRequestQueryParams(t, 8088) } func TestRequestQueryParamsInProcessGateway(t *testing.T) { testRequestQueryParams(t, 8089) } func testRequestQueryParams(t *testing.T, port int) { if testing.Short() { t.Skip() return } formValues := url.Values{} formValues.Set("string_value", "hello-world") formValues.Add("repeated_string_value", "demo1") formValues.Add("repeated_string_value", "demo2") formValues.Add("optional_string_value", "optional-val") mappedStringValueStr := fmt.Sprintf("mapped_string_value[%v]=%v", "map_key", "map_value") testCases := []struct { name string httpMethod string contentType string apiURL string wantContent *examplepb.ABitOfEverything requestContent io.Reader }{ { name: "get url query values", httpMethod: "GET", contentType: "application/json", apiURL: fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything/params/get/foo?double_value=%v&bool_value=%v&%v", port, 1234.56, true, mappedStringValueStr), wantContent: &examplepb.ABitOfEverything{ SingleNested: &examplepb.ABitOfEverything_Nested{ Name: "foo", }, DoubleValue: 1234.56, BoolValue: true, MappedStringValue: map[string]string{ "map_key": "map_value", }, }, }, { name: "get nested enum url parameter", httpMethod: "GET", contentType: "application/json", // If nested_enum.OK were FALSE, the content of single_nested would be {} due to how 0 values are serialized apiURL: fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything/params/get/nested_enum/TRUE", port), wantContent: &examplepb.ABitOfEverything{ SingleNested: &examplepb.ABitOfEverything_Nested{ Ok: examplepb.ABitOfEverything_Nested_TRUE, }, }, }, { name: "post url query values", httpMethod: "POST", contentType: "application/json", apiURL: fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything/params/post/hello-world?double_value=%v&bool_value=%v", port, 1234.56, true), wantContent: &examplepb.ABitOfEverything{ SingleNested: &examplepb.ABitOfEverything_Nested{ Name: "foo", Amount: 100, }, DoubleValue: 1234.56, BoolValue: true, StringValue: "hello-world", }, requestContent: strings.NewReader(`{"name":"foo","amount":100}`), }, { name: "post form and url query values", httpMethod: "POST", contentType: "application/x-www-form-urlencoded", apiURL: fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything/params/get/foo?double_value=%v&bool_value=%v", port, 1234.56, true), wantContent: &examplepb.ABitOfEverything{ SingleNested: &examplepb.ABitOfEverything_Nested{ Name: "foo", }, DoubleValue: 1234.56, BoolValue: true, StringValue: "hello-world", RepeatedStringValue: []string{"demo1", "demo2"}, OptionalStringValue: func() *string { val := formValues.Get("optional_string_value") return &val }(), }, requestContent: strings.NewReader(formValues.Encode()), }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { req, err := http.NewRequest(tc.httpMethod, tc.apiURL, tc.requestContent) if err != nil { t.Errorf("http.method (%q) http.url (%q) failed with %v; want success", tc.httpMethod, tc.apiURL, err) return } req.Header.Add("Content-Type", tc.contentType) resp, err := http.DefaultClient.Do(req) if err != nil { t.Errorf("http.method (%q) http.url (%q) failed with %v; want success", tc.httpMethod, tc.apiURL, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if gotCode, wantCode := resp.StatusCode, http.StatusOK; gotCode != wantCode { t.Errorf("resp.StatusCode = %d; want %d", gotCode, wantCode) t.Logf("%s", buf) } got := new(examplepb.ABitOfEverything) err = marshaler.Unmarshal(buf, &got) if err != nil { t.Errorf("marshaler.Unmarshal(buf, got) failed with %v; want success", err) return } if diff := cmp.Diff(got, tc.wantContent, protocmp.Transform()); diff != "" { t.Errorf("http.method (%q) http.url (%q)\n%s", tc.httpMethod, tc.apiURL, diff) } }) } } func TestNonStandardNames(t *testing.T) { if testing.Short() { t.Skip() return } ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() go func() { marshaler := &runtime.JSONPb{ MarshalOptions: protojson.MarshalOptions{ UseEnumNumbers: false, EmitUnpopulated: true, UseProtoNames: true, }, } err := runGateway( ctx, ":8081", runtime.WithMarshalerOption(runtime.MIMEWildcard, marshaler), ) if err != nil { t.Errorf("runGateway() failed with %v; want success", err) return } }() go func() { err := runGateway( ctx, ":8082", ) if err != nil { t.Errorf("runGateway() failed with %v; want success", err) return } }() if err := waitForGateway(ctx, 8081); err != nil { t.Errorf("waitForGateway(ctx, 8081) failed with %v; want success", err) } if err := waitForGateway(ctx, 8082); err != nil { t.Errorf("waitForGateway(ctx, 8082) failed with %v; want success", err) } for _, tc := range []struct { name string port int method string jsonBody string want proto.Message }{ { "Test standard update method", 8081, "update", `{ "id": "foo", "Num": "1", "line_num": "42", "langIdent": "English", "STATUS": "good", "en_GB": "1", "no": "yes", "thing": { "subThing": { "sub_value": "hi" } } }`, &examplepb.NonStandardMessage{ Id: "foo", Num: 1, LineNum: 42, LangIdent: "English", STATUS: "good", En_GB: 1, No: "yes", Thing: &examplepb.NonStandardMessage_Thing{ SubThing: &examplepb.NonStandardMessage_Thing_SubThing{ SubValue: "hi", }, }, }, }, { "Test update method using json_names in message", 8081, "update_with_json_names", // N.B. json_names have no effect if not using UseProtoNames: false `{ "id": "foo", "Num": "1", "line_num": "42", "langIdent": "English", "STATUS": "good", "en_GB": "1", "no": "yes", "thing": { "subThing": { "sub_value": "hi" } } }`, &examplepb.NonStandardMessageWithJSONNames{ Id: "foo", Num: 1, LineNum: 42, LangIdent: "English", STATUS: "good", En_GB: 1, No: "yes", Thing: &examplepb.NonStandardMessageWithJSONNames_Thing{ SubThing: &examplepb.NonStandardMessageWithJSONNames_Thing_SubThing{ SubValue: "hi", }, }, }, }, { "Test standard update method with UseProtoNames: false marshaller option", 8082, "update", `{ "id": "foo", "Num": "1", "lineNum": "42", "langIdent": "English", "STATUS": "good", "enGB": "1", "no": "yes", "thing": { "subThing": { "subValue": "hi" } } }`, &examplepb.NonStandardMessage{ Id: "foo", Num: 1, LineNum: 42, LangIdent: "English", STATUS: "good", En_GB: 1, No: "yes", Thing: &examplepb.NonStandardMessage_Thing{ SubThing: &examplepb.NonStandardMessage_Thing_SubThing{ SubValue: "hi", }, }, }, }, { "Test update method using json_names in message with UseProtoNames: false marshaller option", 8082, "update_with_json_names", `{ "ID": "foo", "Num": "1", "LineNum": "42", "langIdent": "English", "status": "good", "En_GB": "1", "yes": "yes", "Thingy": { "SubThing": { "sub_Value": "hi" } } }`, &examplepb.NonStandardMessageWithJSONNames{ Id: "foo", Num: 1, LineNum: 42, LangIdent: "English", STATUS: "good", En_GB: 1, No: "yes", Thing: &examplepb.NonStandardMessageWithJSONNames_Thing{ SubThing: &examplepb.NonStandardMessageWithJSONNames_Thing_SubThing{ SubValue: "hi", }, }, }, }, } { t.Run(tc.name, func(t *testing.T) { testNonStandardNames(t, tc.port, tc.method, tc.jsonBody, tc.want) }) } } func testNonStandardNames(t *testing.T, port int, method string, jsonBody string, want proto.Message) { req, err := http.NewRequest( http.MethodPatch, fmt.Sprintf("http://localhost:%d/v1/example/non_standard/%s", port, method), strings.NewReader(jsonBody), ) if err != nil { t.Fatalf("http.NewRequest(PATCH) failed with %v; want success", err) } patchResp, err := http.DefaultClient.Do(req) if err != nil { t.Fatalf("failed to issue PATCH request: %v", err) } body, err := io.ReadAll(patchResp.Body) if err != nil { t.Errorf("patchResp body couldn't be read: %v", err) } t.Log(string(body)) if got, want := patchResp.StatusCode, http.StatusOK; got != want { t.Errorf("patchResp.StatusCode= %d; want %d resp: %v", got, want, string(body)) } got := want.ProtoReflect().New().Interface() err = marshaler.Unmarshal(body, got) if err != nil { t.Fatalf("marshaler.Unmarshal failed: %v", err) } if diff := cmp.Diff(got, want, protocmp.Transform()); diff != "" { t.Error(diff) } } func testABEExists(t *testing.T, port int) { apiURL := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything", port) cresp, err := http.Post(apiURL, "application/json", strings.NewReader(` {"bool_value": true, "string_value": "strprefix/example"} `)) if err != nil { t.Errorf("http.Post(%q) failed with %v; want success", apiURL, err) return } defer cresp.Body.Close() buf, err := io.ReadAll(cresp.Body) if err != nil { t.Errorf("io.ReadAll(cresp.Body) failed with %v; want success", err) return } if got, want := cresp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) return } want := new(examplepb.ABitOfEverything) if err := marshaler.Unmarshal(buf, want); err != nil { t.Errorf("marshaler.Unmarshal(%s, want) failed with %v; want success", buf, err) return } apiURL = fmt.Sprintf("%s/%s", apiURL, want.Uuid) resp, err := http.Head(apiURL) if err != nil { t.Errorf("http.Head(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } } func testABEExistsNotFound(t *testing.T, port int) { apiURL := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything", port) apiURL = fmt.Sprintf("%s/%s", apiURL, "not_exist") resp, err := http.Head(apiURL) if err != nil { t.Errorf("http.Head(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() if got, want := resp.StatusCode, http.StatusNotFound; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) return } } func testABEOptions(t *testing.T, port int) { apiURL := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything/test", port) req, err := http.NewRequest(http.MethodOptions, apiURL, strings.NewReader(` {"bool_value": true, "string_value": "strprefix/example"} `)) req.Header.Set("Content-Type", "application/json") if err != nil { t.Errorf("http.NewRequest(http.MethodTrace, %q, ...) failed with %v; want success", apiURL, err) return } client := &http.Client{} resp, err := client.Do(req) if err != nil { t.Fatal(err) } defer resp.Body.Close() if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) return } value := resp.Header.Get("Grpc-Metadata-Allow") if value != "OPTIONS, GET, HEAD, POST, PUT, TRACE" { t.Errorf("Grpc-Metadata-Allow does not have the expected HTTP methods") t.Logf("%s", value) } } func testABETrace(t *testing.T, port int) { apiURL := fmt.Sprintf("http://localhost:%d/v1/example/a_bit_of_everything/test", port) req, err := http.NewRequest(http.MethodTrace, apiURL, strings.NewReader(` {"bool_value": true, "string_value": "strprefix/example"} `)) req.Header.Set("Content-Type", "application/json") if err != nil { t.Errorf("http.NewRequest(http.MethodTrace, %q, ...) failed with %v; want success", apiURL, err) return } client := &http.Client{} resp, err := client.Do(req) if err != nil { t.Fatal(err) } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(cresp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) return } want := new(examplepb.ABitOfEverything) if err := marshaler.Unmarshal(buf, want); err != nil { t.Errorf("marshaler.Unmarshal(%s, want) failed with %v; want success", buf, err) return } } func testEchoWithNonASCIIHeaderValues(t *testing.T, port int, apiPrefix string) { apiURL := fmt.Sprintf("http://localhost:%d/%s/example/echo/myid", port, apiPrefix) req, err := http.NewRequest("POST", apiURL, strings.NewReader("{}")) if err != nil { t.Errorf("http.NewRequest() = err: %v", err) return } req.Header.Add("Content-Type", "application/json") req.Header.Add("Grpc-Metadata-Location", "Gjøvik") resp, err := http.DefaultClient.Do(req) if err != nil { t.Errorf("http.Post(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } msg := new(examplepb.UnannotatedSimpleMessage) if err := marshaler.Unmarshal(buf, msg); err != nil { t.Errorf("marshaler.Unmarshal(%s, msg) failed with %v; want success", buf, err) return } if got, want := msg.Id, "myid"; got != want { t.Errorf("msg.Id = %q; want %q", got, want) } } func testEchoWithInvalidHeaderKey(t *testing.T, port int, apiPrefix string) { apiURL := fmt.Sprintf("http://localhost:%d/%s/example/echo/myid", port, apiPrefix) req, err := http.NewRequest("POST", apiURL, strings.NewReader("{}")) if err != nil { t.Errorf("http.NewRequest() = err: %v", err) return } req.Header.Add("Content-Type", "application/json") req.Header.Add("Grpc-Metadata-Foo+Bar", "Hello") resp, err := http.DefaultClient.Do(req) if err != nil { t.Errorf("http.Post(%q) failed with %v; want success", apiURL, err) return } defer resp.Body.Close() buf, err := io.ReadAll(resp.Body) if err != nil { t.Errorf("io.ReadAll(resp.Body) failed with %v; want success", err) return } if got, want := resp.StatusCode, http.StatusOK; got != want { t.Errorf("resp.StatusCode = %d; want %d", got, want) t.Logf("%s", buf) } msg := new(examplepb.UnannotatedSimpleMessage) if err := marshaler.Unmarshal(buf, msg); err != nil { t.Errorf("marshaler.Unmarshal(%s, msg) failed with %v; want success", buf, err) return } if got, want := msg.Id, "myid"; got != want { t.Errorf("msg.Id = %q; want %q", got, want) } } // Test server context closing when body is sent on a POST method which has no // "body" annotation defined. func TestExcessBody(t *testing.T) { if testing.Short() { t.Skip() return } testExcessBodyRPC(t, 8088) testExcessBodyStream(t, 8088) testExcessBodyRPCUnexpected(t, 8088) testExcessBodyStreamUnexpected(t, 8088) testExcessBodyRPCWithBody(t, 8088) testExcessBodyStreamWithBody(t, 8088) testExcessBodyRPCWithBodyUnexpected(t, 8089) testExcessBodyStreamWithBodyUnexpected(t, 8088) } func testExcessBodyRPC(t *testing.T, port int) { apiURL := fmt.Sprintf("http://localhost:%d/rpc/excess-body/rpc", port) ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() req, err := http.NewRequestWithContext(ctx, "POST", apiURL, nil) if err != nil { t.Errorf("http.NewRequest() failed with %v; want success", err) return } go http.DefaultClient.Do(req) // Wait for the server to start processing the request. ctxServer := server.ExcessBodyServer_RetrieveContextRPC() cancel() // Wait for server context to be done select { case <-ctxServer.Done(): case <-time.After(time.Second): t.Errorf("server context not done") } } func testExcessBodyStream(t *testing.T, port int) { apiURL := fmt.Sprintf("http://localhost:%d/rpc/excess-body/stream", port) ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() req, err := http.NewRequestWithContext(ctx, "POST", apiURL, nil) if err != nil { t.Errorf("http.NewRequest() failed with %v; want success", err) return } go http.DefaultClient.Do(req) // Wait for the server to start processing the request. ctxServer := server.ExcessBodyServer_RetrieveContextStream() cancel() // Wait for server context to be done select { case <-ctxServer.Done(): case <-time.After(time.Second): t.Errorf("server context not done") } } func testExcessBodyRPCUnexpected(t *testing.T, port int) { apiURL := fmt.Sprintf("http://localhost:%d/rpc/excess-body/rpc", port) ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() body := strings.NewReader("{}") req, err := http.NewRequestWithContext(ctx, "POST", apiURL, body) if err != nil { t.Errorf("http.NewRequest() failed with %v; want success", err) return } go http.DefaultClient.Do(req) // Wait for the server to start processing the request. ctxServer := server.ExcessBodyServer_RetrieveContextRPC() cancel() // Wait for server context to be done select { case <-ctxServer.Done(): case <-time.After(time.Second): t.Errorf("server context not done") } } func testExcessBodyStreamUnexpected(t *testing.T, port int) { apiURL := fmt.Sprintf("http://localhost:%d/rpc/excess-body/stream", port) ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() body := strings.NewReader("{}") req, err := http.NewRequestWithContext(ctx, "POST", apiURL, body) if err != nil { t.Errorf("http.NewRequest() failed with %v; want success", err) return } go http.DefaultClient.Do(req) // Wait for the server to start processing the request. ctxServer := server.ExcessBodyServer_RetrieveContextStream() cancel() // Wait for server context to be done select { case <-ctxServer.Done(): case <-time.After(time.Second): t.Errorf("server context not done") } } func testExcessBodyRPCWithBody(t *testing.T, port int) { apiURL := fmt.Sprintf("http://localhost:%d/rpc/excess-body/rpc/with-body", port) ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() body := strings.NewReader("{}") req, err := http.NewRequestWithContext(ctx, "POST", apiURL, body) if err != nil { t.Errorf("http.NewRequest() failed with %v; want success", err) return } go http.DefaultClient.Do(req) // Wait for the server to start processing the request. ctxServer := server.ExcessBodyServer_RetrieveContextRPC() cancel() // Wait for server context to be done select { case <-ctxServer.Done(): case <-time.After(time.Second): t.Errorf("server context not done") } } func testExcessBodyStreamWithBody(t *testing.T, port int) { apiURL := fmt.Sprintf("http://localhost:%d/rpc/excess-body/stream/with-body", port) ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() body := strings.NewReader("{}") req, err := http.NewRequestWithContext(ctx, "POST", apiURL, body) if err != nil { t.Errorf("http.NewRequest() failed with %v; want success", err) return } go http.DefaultClient.Do(req) // Wait for the server to start processing the request. ctxServer := server.ExcessBodyServer_RetrieveContextStream() cancel() // Wait for server context to be done select { case <-ctxServer.Done(): case <-time.After(time.Second): t.Errorf("server context not done") } } func testExcessBodyRPCWithBodyUnexpected(t *testing.T, port int) { apiURL := fmt.Sprintf("http://localhost:%d/rpc/excess-body/rpc/with-body", port) ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() body := strings.NewReader("{}.") req, err := http.NewRequestWithContext(ctx, "POST", apiURL, body) if err != nil { t.Errorf("http.NewRequest() failed with %v; want success", err) return } go http.DefaultClient.Do(req) // Wait for the server to start processing the request. ctxServer := server.ExcessBodyServer_RetrieveContextRPC() cancel() // Wait for server context to be done select { case <-ctxServer.Done(): case <-time.After(time.Second): t.Errorf("server context not done") } } func testExcessBodyStreamWithBodyUnexpected(t *testing.T, port int) { apiURL := fmt.Sprintf("http://localhost:%d/rpc/excess-body/stream/with-body", port) ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() body := strings.NewReader("{}" + strings.Repeat(".", 511)) req, err := http.NewRequestWithContext(ctx, "POST", apiURL, body) if err != nil { t.Errorf("http.NewRequest() failed with %v; want success", err) return } go http.DefaultClient.Do(req) // Wait for the server to start processing the request. ctxServer := server.ExcessBodyServer_RetrieveContextStream() cancel() // Wait for server context to be done select { case <-ctxServer.Done(): case <-time.After(time.Second): t.Errorf("server context not done") } } ================================================ FILE: examples/internal/integration/main_test.go ================================================ package integration_test import ( "context" "flag" "fmt" "net/http" "os" "testing" "time" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/gateway" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/server" gwruntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "google.golang.org/grpc/grpclog" ) var ( endpoint = flag.String("endpoint", "localhost:9090", "endpoint of the gRPC service") network = flag.String("network", "tcp", `one of "tcp" or "unix". Must be consistent to -endpoint`) openAPIDir = flag.String("openapi_dir", "examples/internal/proto/examplepb", "path to the directory which contains OpenAPI definitions") ) func runGateway(ctx context.Context, addr string, opts ...gwruntime.ServeMuxOption) error { return gateway.Run(ctx, gateway.Options{ Addr: addr, GRPCServer: gateway.Endpoint{ Network: *network, Addr: *endpoint, }, OpenAPIDir: *openAPIDir, Mux: opts, }) } func waitForGateway(ctx context.Context, port uint16) error { ch := time.After(10 * time.Second) for { r, err := http.Get(fmt.Sprintf("http://localhost:%d/healthz", port)) if err == nil && r.StatusCode == http.StatusOK { return nil } grpclog.Infof("Waiting for localhost:%d to get ready", port) select { case <-ctx.Done(): return err case <-ch: return err case <-time.After(10 * time.Millisecond): } } } func runServers(ctx context.Context) <-chan error { ch := make(chan error, 3) go func() { if err := server.Run(ctx, *network, *endpoint); err != nil { ch <- fmt.Errorf("cannot run grpc service: %v", err) } }() go func() { if err := runGateway(ctx, ":8088"); err != nil { ch <- fmt.Errorf("cannot run gateway service: %v", err) } }() go func() { if err := server.RunInProcessGateway(ctx, ":8089"); err != nil { ch <- fmt.Errorf("cannot run in process gateway service: %v", err) } }() return ch } func TestMain(m *testing.M) { flag.Parse() ctx, cancel := context.WithCancel(context.Background()) defer cancel() errCh := runServers(ctx) ch := make(chan int, 1) go func() { if err := waitForGateway(ctx, 8088); err != nil { grpclog.Errorf("waitForGateway(ctx, 8088) failed with %v; want success", err) } ch <- m.Run() }() select { case err := <-errCh: fmt.Fprintln(os.Stderr, err) os.Exit(1) case status := <-ch: cancel() os.Exit(status) } } ================================================ FILE: examples/internal/proto/examplepb/BUILD.bazel ================================================ load("@grpc_ecosystem_grpc_gateway//protoc-gen-openapiv2:defs.bzl", "protoc_gen_openapiv2") load("@io_bazel_rules_go//go:def.bzl", "go_library") load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") load("@rules_proto//proto:defs.bzl", "proto_library") package(default_visibility = ["//visibility:public"]) # TODO(yannic): Add examples/tests that use import_prefix/strip_import_prefix. # gazelle:exclude a_bit_of_everything.pb.gw.go # gazelle:exclude a_bit_of_everything_grpc.pb.go # gazelle:exclude camel_case_service.pb.gw.go # gazelle:exclude camel_case_service_grpc.pb.go # gazelle:exclude echo_service.pb.gw.go # gazelle:exclude echo_service_grpc.pb.go # gazelle:exclude enum_with_single_value.pb.gw.go # gazelle:exclude enum_with_single_value.pb.go # gazelle:exclude excess_body.pb.gw.go # gazelle:exclude excess_body_grpc.pb.go # gazelle:exclude flow_combination.pb.gw.go # gazelle:exclude flow_combination_grpc.pb.go # gazelle:exclude generate_unbound_methods.pb.gw.go # gazelle:exclude generate_unbound_methods_grpc.pb.go # gazelle:exclude generated_input.proto # gazelle:exclude non_standard_names.pb.gw.go # gazelle:exclude non_standard_names_grpc.pb.go # gazelle:exclude response_body_service.pb.gw.go # gazelle:exclude response_body_service_grpc.pb.go # gazelle:exclude stream.pb.gw.go # gazelle:exclude stream_grpc.pb.go # gazelle:exclude use_go_template.pb.gw.go # gazelle:exclude use_go_template_grpc.pb.go # gazelle:exclude ignore_comment.pb.gw.go # gazelle:exclude remove_internal_comment.pb.gw.go # gazelle:exclude ignore_comment_grpc.pb.go # gazelle:exclude wrappers.pb.gw.go # gazelle:exclude wrappers_grpc.pb.go # gazelle:exclude unannotated_echo_service.pb.gw.go # gazelle:exclude unannotated_echo_service_grpc.pb.go # gazelle:exclude visibility_rule_echo_service.pb.gw.go # gazelle:exclude visibility_rule_echo_service_grpc.pb.go # gazelle:exclude opaque.proto # gazelle:exclude opaque.pb.go # gazelle:exclude opaque.pb.gw.go # gazelle:exclude opaque_grpc.pb.go # gazelle:exclude openapi_merge_a.proto # gazelle:exclude openapi_merge_b.proto # gazelle:exclude proto3_field_semantics.pb.gw.go # gazelle:go_grpc_compilers //:go_apiv2, //:go_grpc, //protoc-gen-grpc-gateway:go_gen_grpc_gateway genrule( name = "generated_proto", srcs = ["generated_input.proto"], outs = ["generated_output.proto"], cmd = "cp $< $@", # A simple copy simulates a generated proto file. ) proto_library( name = "examplepb_proto", srcs = [ "a_bit_of_everything.proto", "camel_case_service.proto", "echo_service.proto", "enum_with_single_value.proto", "excess_body.proto", "flow_combination.proto", "generate_unbound_methods.proto", "generated_output.proto", "ignore_comment.proto", "non_standard_names.proto", "proto3_field_semantics.proto", "remove_internal_comment.proto", "response_body_service.proto", "stream.proto", "unannotated_echo_service.proto", "use_go_template.proto", "visibility_rule_echo_service.proto", "wrappers.proto", ], deps = [ "//examples/internal/proto/oneofenum:oneofenum_proto", "//examples/internal/proto/pathenum:pathenum_proto", "//examples/internal/proto/sub:sub_proto", "//examples/internal/proto/sub2:sub2_proto", "//protoc-gen-openapiv2/options:options_proto", "@com_google_protobuf//:duration_proto", "@com_google_protobuf//:empty_proto", "@com_google_protobuf//:field_mask_proto", "@com_google_protobuf//:struct_proto", "@com_google_protobuf//:timestamp_proto", "@com_google_protobuf//:wrappers_proto", "@googleapis//google/api:annotations_proto", "@googleapis//google/api:field_behavior_proto", "@googleapis//google/api:httpbody_proto", "@googleapis//google/api:visibility_proto", "@googleapis//google/rpc:status_proto", ], ) #keep proto_library( name = "examplepb_opaque_proto", srcs = [ "opaque.proto", ], deps = [ "//examples/internal/proto/sub:sub_proto", "@com_google_protobuf//:duration_proto", "@com_google_protobuf//:field_mask_proto", "@com_google_protobuf//:timestamp_proto", "@com_google_protobuf//:wrappers_proto", "@googleapis//google/api:annotations_proto", "@googleapis//google/api:client_proto", ], ) #keep proto_library( name = "openapi_merge_proto", srcs = [ "openapi_merge_a.proto", "openapi_merge_b.proto", ], deps = [ "@com_google_protobuf//:api_proto", "@googleapis//google/api:annotations_proto", "@googleapis//google/api:field_behavior_proto", "@googleapis//google/rpc:status_proto", ], ) #keep go_proto_library( name = "examplepb_go_proto", compilers = [ "//:go_apiv2", "//:go_grpc", "//protoc-gen-grpc-gateway:go_gen_grpc_gateway", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb", proto = ":examplepb_proto", deps = [ "//examples/internal/proto/oneofenum", "//examples/internal/proto/pathenum", "//examples/internal/proto/sub", "//examples/internal/proto/sub2", "//protoc-gen-openapiv2/options", "@com_github_golang_protobuf//descriptor:go_default_library_gen", # keep "@org_golang_google_genproto_googleapis_api//annotations", "@org_golang_google_genproto_googleapis_api//httpbody", "@org_golang_google_genproto_googleapis_api//visibility", "@org_golang_google_genproto_googleapis_rpc//status", ], ) #keep go_proto_library( name = "examplepb_opaque_go_proto", compilers = [ "//:go_apiv2_opaque", "//:go_grpc", "//protoc-gen-grpc-gateway:go_gen_grpc_gateway_opaque", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb", proto = ":examplepb_opaque_proto", deps = [ "//examples/internal/proto/sub", "@com_github_golang_protobuf//descriptor:go_default_library_gen", "@org_golang_google_genproto_googleapis_api//annotations", ], ) go_library( name = "examplepb", srcs = [ "openapi_merge_a.pb.go", "openapi_merge_a.pb.gw.go", "openapi_merge_a_grpc.pb.go", "openapi_merge_b.pb.go", "openapi_merge_b.pb.gw.go", "openapi_merge_b_grpc.pb.go", ], embed = [ ":examplepb_go_proto", ":examplepb_opaque_go_proto", #keep ], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb", deps = [ "//runtime", "//utilities", "@org_golang_google_genproto_googleapis_api//annotations", "@org_golang_google_grpc//:grpc", "@org_golang_google_grpc//codes", "@org_golang_google_grpc//grpclog", "@org_golang_google_grpc//metadata", "@org_golang_google_grpc//status", "@org_golang_google_protobuf//proto", "@org_golang_google_protobuf//reflect/protoreflect", "@org_golang_google_protobuf//runtime/protoimpl", ], ) protoc_gen_openapiv2( name = "examplepb_protoc_gen_openapiv2", proto = ":examplepb_proto", ) protoc_gen_openapiv2( name = "examplepb_protoc_gen_openapiv2_merged", proto = ":examplepb_proto", single_output = True, # Outputs a single swagger.json file. ) protoc_gen_openapiv2( name = "examplepb_openapi_merge", proto = ":openapi_merge_proto", single_output = True, # Outputs a single swagger.json file. ) alias( name = "go_default_library", actual = ":examplepb", visibility = ["//examples:__subpackages__"], ) ================================================ FILE: examples/internal/proto/examplepb/a_bit_of_everything.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/examplepb/a_bit_of_everything.proto package examplepb import ( oneofenum "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/oneofenum" pathenum "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/pathenum" sub "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub" sub2 "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub2" _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" _ "google.golang.org/genproto/googleapis/api/annotations" status "google.golang.org/genproto/googleapis/rpc/status" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" durationpb "google.golang.org/protobuf/types/known/durationpb" emptypb "google.golang.org/protobuf/types/known/emptypb" fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" timestamppb "google.golang.org/protobuf/types/known/timestamppb" wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) // NumericEnum is one or zero. type NumericEnum int32 const ( // ZERO means 0 NumericEnum_ZERO NumericEnum = 0 // ONE means 1 NumericEnum_ONE NumericEnum = 1 ) // Enum value maps for NumericEnum. var ( NumericEnum_name = map[int32]string{ 0: "ZERO", 1: "ONE", } NumericEnum_value = map[string]int32{ "ZERO": 0, "ONE": 1, } ) func (x NumericEnum) Enum() *NumericEnum { p := new(NumericEnum) *p = x return p } func (x NumericEnum) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (NumericEnum) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_enumTypes[0].Descriptor() } func (NumericEnum) Type() protoreflect.EnumType { return &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_enumTypes[0] } func (x NumericEnum) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use NumericEnum.Descriptor instead. func (NumericEnum) EnumDescriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP(), []int{0} } // Ignoring lint warnings as this enum type exist to validate proper functionality // for projects that don't follow these lint rules. // buf:lint:ignore ENUM_PASCAL_CASE type SnakeCaseEnum int32 const ( // buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE SnakeCaseEnum_value_c SnakeCaseEnum = 0 // buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE SnakeCaseEnum_value_d SnakeCaseEnum = 1 ) // Enum value maps for SnakeCaseEnum. var ( SnakeCaseEnum_name = map[int32]string{ 0: "value_c", 1: "value_d", } SnakeCaseEnum_value = map[string]int32{ "value_c": 0, "value_d": 1, } ) func (x SnakeCaseEnum) Enum() *SnakeCaseEnum { p := new(SnakeCaseEnum) *p = x return p } func (x SnakeCaseEnum) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (SnakeCaseEnum) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_enumTypes[1].Descriptor() } func (SnakeCaseEnum) Type() protoreflect.EnumType { return &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_enumTypes[1] } func (x SnakeCaseEnum) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use SnakeCaseEnum.Descriptor instead. func (SnakeCaseEnum) EnumDescriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP(), []int{1} } // Ignoring lint warnings as this enum type exist to validate proper functionality // for projects that don't follow these lint rules. // buf:lint:ignore ENUM_PASCAL_CASE type SnakeCase_0Enum int32 const ( // buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE SnakeCase_0Enum_value_e SnakeCase_0Enum = 0 // buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE SnakeCase_0Enum_value_f SnakeCase_0Enum = 1 ) // Enum value maps for SnakeCase_0Enum. var ( SnakeCase_0Enum_name = map[int32]string{ 0: "value_e", 1: "value_f", } SnakeCase_0Enum_value = map[string]int32{ "value_e": 0, "value_f": 1, } ) func (x SnakeCase_0Enum) Enum() *SnakeCase_0Enum { p := new(SnakeCase_0Enum) *p = x return p } func (x SnakeCase_0Enum) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (SnakeCase_0Enum) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_enumTypes[2].Descriptor() } func (SnakeCase_0Enum) Type() protoreflect.EnumType { return &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_enumTypes[2] } func (x SnakeCase_0Enum) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use SnakeCase_0Enum.Descriptor instead. func (SnakeCase_0Enum) EnumDescriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP(), []int{2} } // DeepEnum is one or zero. type ABitOfEverything_Nested_DeepEnum int32 const ( // FALSE is false. ABitOfEverything_Nested_FALSE ABitOfEverything_Nested_DeepEnum = 0 // TRUE is true. ABitOfEverything_Nested_TRUE ABitOfEverything_Nested_DeepEnum = 1 ) // Enum value maps for ABitOfEverything_Nested_DeepEnum. var ( ABitOfEverything_Nested_DeepEnum_name = map[int32]string{ 0: "FALSE", 1: "TRUE", } ABitOfEverything_Nested_DeepEnum_value = map[string]int32{ "FALSE": 0, "TRUE": 1, } ) func (x ABitOfEverything_Nested_DeepEnum) Enum() *ABitOfEverything_Nested_DeepEnum { p := new(ABitOfEverything_Nested_DeepEnum) *p = x return p } func (x ABitOfEverything_Nested_DeepEnum) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (ABitOfEverything_Nested_DeepEnum) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_enumTypes[3].Descriptor() } func (ABitOfEverything_Nested_DeepEnum) Type() protoreflect.EnumType { return &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_enumTypes[3] } func (x ABitOfEverything_Nested_DeepEnum) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use ABitOfEverything_Nested_DeepEnum.Descriptor instead. func (ABitOfEverything_Nested_DeepEnum) EnumDescriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP(), []int{2, 0, 0} } type ErrorResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields CorrelationId string `protobuf:"bytes,1,opt,name=correlationId,proto3" json:"correlationId,omitempty"` Error *ErrorObject `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` } func (x *ErrorResponse) Reset() { *x = ErrorResponse{} mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *ErrorResponse) String() string { return protoimpl.X.MessageStringOf(x) } func (*ErrorResponse) ProtoMessage() {} func (x *ErrorResponse) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use ErrorResponse.ProtoReflect.Descriptor instead. func (*ErrorResponse) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP(), []int{0} } func (x *ErrorResponse) GetCorrelationId() string { if x != nil { return x.CorrelationId } return "" } func (x *ErrorResponse) GetError() *ErrorObject { if x != nil { return x.Error } return nil } type ErrorObject struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` } func (x *ErrorObject) Reset() { *x = ErrorObject{} mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *ErrorObject) String() string { return protoimpl.X.MessageStringOf(x) } func (*ErrorObject) ProtoMessage() {} func (x *ErrorObject) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use ErrorObject.ProtoReflect.Descriptor instead. func (*ErrorObject) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP(), []int{1} } func (x *ErrorObject) GetCode() int32 { if x != nil { return x.Code } return 0 } func (x *ErrorObject) GetMessage() string { if x != nil { return x.Message } return "" } // Intentionally complicated message type to cover many features of Protobuf. type ABitOfEverything struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields SingleNested *ABitOfEverything_Nested `protobuf:"bytes,25,opt,name=single_nested,json=singleNested,proto3" json:"single_nested,omitempty"` Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` Nested []*ABitOfEverything_Nested `protobuf:"bytes,2,rep,name=nested,proto3" json:"nested,omitempty"` FloatValue float32 `protobuf:"fixed32,3,opt,name=float_value,json=floatValue,proto3" json:"float_value,omitempty"` DoubleValue float64 `protobuf:"fixed64,4,opt,name=double_value,json=doubleValue,proto3" json:"double_value,omitempty"` Int64Value int64 `protobuf:"varint,5,opt,name=int64_value,json=int64Value,proto3" json:"int64_value,omitempty"` Uint64Value uint64 `protobuf:"varint,6,opt,name=uint64_value,json=uint64Value,proto3" json:"uint64_value,omitempty"` Int32Value int32 `protobuf:"varint,7,opt,name=int32_value,json=int32Value,proto3" json:"int32_value,omitempty"` Fixed64Value uint64 `protobuf:"fixed64,8,opt,name=fixed64_value,json=fixed64Value,proto3" json:"fixed64_value,omitempty"` Fixed32Value uint32 `protobuf:"fixed32,9,opt,name=fixed32_value,json=fixed32Value,proto3" json:"fixed32_value,omitempty"` BoolValue bool `protobuf:"varint,10,opt,name=bool_value,json=boolValue,proto3" json:"bool_value,omitempty"` StringValue string `protobuf:"bytes,11,opt,name=string_value,json=stringValue,proto3" json:"string_value,omitempty"` BytesValue []byte `protobuf:"bytes,29,opt,name=bytes_value,json=bytesValue,proto3" json:"bytes_value,omitempty"` Uint32Value uint32 `protobuf:"varint,13,opt,name=uint32_value,json=uint32Value,proto3" json:"uint32_value,omitempty"` EnumValue NumericEnum `protobuf:"varint,14,opt,name=enum_value,json=enumValue,proto3,enum=grpc.gateway.examples.internal.proto.examplepb.NumericEnum" json:"enum_value,omitempty"` PathEnumValue pathenum.PathEnum `protobuf:"varint,30,opt,name=path_enum_value,json=pathEnumValue,proto3,enum=grpc.gateway.examples.internal.pathenum.PathEnum" json:"path_enum_value,omitempty"` NestedPathEnumValue pathenum.MessagePathEnum_NestedPathEnum `protobuf:"varint,31,opt,name=nested_path_enum_value,json=nestedPathEnumValue,proto3,enum=grpc.gateway.examples.internal.pathenum.MessagePathEnum_NestedPathEnum" json:"nested_path_enum_value,omitempty"` Sfixed32Value int32 `protobuf:"fixed32,15,opt,name=sfixed32_value,json=sfixed32Value,proto3" json:"sfixed32_value,omitempty"` Sfixed64Value int64 `protobuf:"fixed64,16,opt,name=sfixed64_value,json=sfixed64Value,proto3" json:"sfixed64_value,omitempty"` Sint32Value int32 `protobuf:"zigzag32,17,opt,name=sint32_value,json=sint32Value,proto3" json:"sint32_value,omitempty"` Sint64Value int64 `protobuf:"zigzag64,18,opt,name=sint64_value,json=sint64Value,proto3" json:"sint64_value,omitempty"` RepeatedStringValue []string `protobuf:"bytes,19,rep,name=repeated_string_value,json=repeatedStringValue,proto3" json:"repeated_string_value,omitempty"` // Types that are assignable to OneofValue: // // *ABitOfEverything_OneofEmpty // *ABitOfEverything_OneofString OneofValue isABitOfEverything_OneofValue `protobuf_oneof:"oneof_value"` // map of numeric enum MapValue map[string]NumericEnum `protobuf:"bytes,22,rep,name=map_value,json=mapValue,proto3" json:"map_value,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3,enum=grpc.gateway.examples.internal.proto.examplepb.NumericEnum"` // map of string (This comment is overridden by the field annotation) MappedStringValue map[string]string `protobuf:"bytes,23,rep,name=mapped_string_value,json=mappedStringValue,proto3" json:"mapped_string_value,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` MappedNestedValue map[string]*ABitOfEverything_Nested `protobuf:"bytes,24,rep,name=mapped_nested_value,json=mappedNestedValue,proto3" json:"mapped_nested_value,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` NonConventionalNameValue string `protobuf:"bytes,26,opt,name=nonConventionalNameValue,proto3" json:"nonConventionalNameValue,omitempty"` TimestampValue *timestamppb.Timestamp `protobuf:"bytes,27,opt,name=timestamp_value,json=timestampValue,proto3" json:"timestamp_value,omitempty"` // repeated enum value. it is comma-separated in query RepeatedEnumValue []NumericEnum `protobuf:"varint,28,rep,packed,name=repeated_enum_value,json=repeatedEnumValue,proto3,enum=grpc.gateway.examples.internal.proto.examplepb.NumericEnum" json:"repeated_enum_value,omitempty"` // repeated numeric enum comment (This comment is overridden by the field annotation) RepeatedEnumAnnotation []NumericEnum `protobuf:"varint,32,rep,packed,name=repeated_enum_annotation,json=repeatedEnumAnnotation,proto3,enum=grpc.gateway.examples.internal.proto.examplepb.NumericEnum" json:"repeated_enum_annotation,omitempty"` // numeric enum comment (This comment is overridden by the field annotation) EnumValueAnnotation NumericEnum `protobuf:"varint,33,opt,name=enum_value_annotation,json=enumValueAnnotation,proto3,enum=grpc.gateway.examples.internal.proto.examplepb.NumericEnum" json:"enum_value_annotation,omitempty"` // repeated string comment (This comment is overridden by the field annotation) RepeatedStringAnnotation []string `protobuf:"bytes,34,rep,name=repeated_string_annotation,json=repeatedStringAnnotation,proto3" json:"repeated_string_annotation,omitempty"` // repeated nested object comment (This comment is overridden by the field annotation) RepeatedNestedAnnotation []*ABitOfEverything_Nested `protobuf:"bytes,35,rep,name=repeated_nested_annotation,json=repeatedNestedAnnotation,proto3" json:"repeated_nested_annotation,omitempty"` // nested object comments (This comment is overridden by the field annotation) NestedAnnotation *ABitOfEverything_Nested `protobuf:"bytes,36,opt,name=nested_annotation,json=nestedAnnotation,proto3" json:"nested_annotation,omitempty"` Int64OverrideType int64 `protobuf:"varint,37,opt,name=int64_override_type,json=int64OverrideType,proto3" json:"int64_override_type,omitempty"` // mark a field as required in Open API definition RequiredStringViaFieldBehaviorAnnotation string `protobuf:"bytes,38,opt,name=required_string_via_field_behavior_annotation,json=requiredStringViaFieldBehaviorAnnotation,proto3" json:"required_string_via_field_behavior_annotation,omitempty"` // mark a field as readonly in Open API definition OutputOnlyStringViaFieldBehaviorAnnotation string `protobuf:"bytes,39,opt,name=output_only_string_via_field_behavior_annotation,json=outputOnlyStringViaFieldBehaviorAnnotation,proto3" json:"output_only_string_via_field_behavior_annotation,omitempty"` OptionalStringValue *string `protobuf:"bytes,40,opt,name=optional_string_value,json=optionalStringValue,proto3,oneof" json:"optional_string_value,omitempty"` // Test openapiv2 generation of repeated fields ProductId []string `protobuf:"bytes,41,rep,name=product_id,json=productId,proto3" json:"product_id,omitempty"` // Test openapiv2 generation of required fields with annotation and jsonschema to reproduce OptionalStringField string `protobuf:"bytes,42,opt,name=optional_string_field,json=optionalStringField,proto3" json:"optional_string_field,omitempty"` RequiredStringField_1 string `protobuf:"bytes,43,opt,name=required_string_field_1,json=requiredStringField1,proto3" json:"required_string_field_1,omitempty"` RequiredStringField_2 string `protobuf:"bytes,44,opt,name=required_string_field_2,json=requiredStringField2,proto3" json:"required_string_field_2,omitempty"` // Test openapiv2 handling of required json_name fields RequiredFieldBehaviorJsonName string `protobuf:"bytes,45,opt,name=required_field_behavior_json_name,json=required_field_behavior_json_name_custom,proto3" json:"required_field_behavior_json_name,omitempty"` RequiredFieldSchemaJsonName string `protobuf:"bytes,46,opt,name=required_field_schema_json_name,json=required_field_schema_json_name_custom,proto3" json:"required_field_schema_json_name,omitempty"` TrailingOnly string `protobuf:"bytes,47,opt,name=trailing_only,json=trailingOnly,proto3" json:"trailing_only,omitempty"` // Trailing only TrailingOnlyDot string `protobuf:"bytes,48,opt,name=trailing_only_dot,json=trailingOnlyDot,proto3" json:"trailing_only_dot,omitempty"` // Trailing only dot. // Leading both TrailingBoth string `protobuf:"bytes,49,opt,name=trailing_both,json=trailingBoth,proto3" json:"trailing_both,omitempty"` // Trailing both. // Leading multiline // // This is an example of a multi-line comment. TrailingMultiline string `protobuf:"bytes,50,opt,name=trailing_multiline,json=trailingMultiline,proto3" json:"trailing_multiline,omitempty"` // Trailing multiline. // Specify a custom format of repeated field items Uuids []string `protobuf:"bytes,51,rep,name=uuids,proto3" json:"uuids,omitempty"` } func (x *ABitOfEverything) Reset() { *x = ABitOfEverything{} mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *ABitOfEverything) String() string { return protoimpl.X.MessageStringOf(x) } func (*ABitOfEverything) ProtoMessage() {} func (x *ABitOfEverything) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use ABitOfEverything.ProtoReflect.Descriptor instead. func (*ABitOfEverything) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP(), []int{2} } func (x *ABitOfEverything) GetSingleNested() *ABitOfEverything_Nested { if x != nil { return x.SingleNested } return nil } func (x *ABitOfEverything) GetUuid() string { if x != nil { return x.Uuid } return "" } func (x *ABitOfEverything) GetNested() []*ABitOfEverything_Nested { if x != nil { return x.Nested } return nil } func (x *ABitOfEverything) GetFloatValue() float32 { if x != nil { return x.FloatValue } return 0 } func (x *ABitOfEverything) GetDoubleValue() float64 { if x != nil { return x.DoubleValue } return 0 } func (x *ABitOfEverything) GetInt64Value() int64 { if x != nil { return x.Int64Value } return 0 } func (x *ABitOfEverything) GetUint64Value() uint64 { if x != nil { return x.Uint64Value } return 0 } func (x *ABitOfEverything) GetInt32Value() int32 { if x != nil { return x.Int32Value } return 0 } func (x *ABitOfEverything) GetFixed64Value() uint64 { if x != nil { return x.Fixed64Value } return 0 } func (x *ABitOfEverything) GetFixed32Value() uint32 { if x != nil { return x.Fixed32Value } return 0 } func (x *ABitOfEverything) GetBoolValue() bool { if x != nil { return x.BoolValue } return false } func (x *ABitOfEverything) GetStringValue() string { if x != nil { return x.StringValue } return "" } func (x *ABitOfEverything) GetBytesValue() []byte { if x != nil { return x.BytesValue } return nil } func (x *ABitOfEverything) GetUint32Value() uint32 { if x != nil { return x.Uint32Value } return 0 } func (x *ABitOfEverything) GetEnumValue() NumericEnum { if x != nil { return x.EnumValue } return NumericEnum_ZERO } func (x *ABitOfEverything) GetPathEnumValue() pathenum.PathEnum { if x != nil { return x.PathEnumValue } return pathenum.PathEnum(0) } func (x *ABitOfEverything) GetNestedPathEnumValue() pathenum.MessagePathEnum_NestedPathEnum { if x != nil { return x.NestedPathEnumValue } return pathenum.MessagePathEnum_NestedPathEnum(0) } func (x *ABitOfEverything) GetSfixed32Value() int32 { if x != nil { return x.Sfixed32Value } return 0 } func (x *ABitOfEverything) GetSfixed64Value() int64 { if x != nil { return x.Sfixed64Value } return 0 } func (x *ABitOfEverything) GetSint32Value() int32 { if x != nil { return x.Sint32Value } return 0 } func (x *ABitOfEverything) GetSint64Value() int64 { if x != nil { return x.Sint64Value } return 0 } func (x *ABitOfEverything) GetRepeatedStringValue() []string { if x != nil { return x.RepeatedStringValue } return nil } func (m *ABitOfEverything) GetOneofValue() isABitOfEverything_OneofValue { if m != nil { return m.OneofValue } return nil } func (x *ABitOfEverything) GetOneofEmpty() *emptypb.Empty { if x, ok := x.GetOneofValue().(*ABitOfEverything_OneofEmpty); ok { return x.OneofEmpty } return nil } func (x *ABitOfEverything) GetOneofString() string { if x, ok := x.GetOneofValue().(*ABitOfEverything_OneofString); ok { return x.OneofString } return "" } func (x *ABitOfEverything) GetMapValue() map[string]NumericEnum { if x != nil { return x.MapValue } return nil } func (x *ABitOfEverything) GetMappedStringValue() map[string]string { if x != nil { return x.MappedStringValue } return nil } func (x *ABitOfEverything) GetMappedNestedValue() map[string]*ABitOfEverything_Nested { if x != nil { return x.MappedNestedValue } return nil } func (x *ABitOfEverything) GetNonConventionalNameValue() string { if x != nil { return x.NonConventionalNameValue } return "" } func (x *ABitOfEverything) GetTimestampValue() *timestamppb.Timestamp { if x != nil { return x.TimestampValue } return nil } func (x *ABitOfEverything) GetRepeatedEnumValue() []NumericEnum { if x != nil { return x.RepeatedEnumValue } return nil } func (x *ABitOfEverything) GetRepeatedEnumAnnotation() []NumericEnum { if x != nil { return x.RepeatedEnumAnnotation } return nil } func (x *ABitOfEverything) GetEnumValueAnnotation() NumericEnum { if x != nil { return x.EnumValueAnnotation } return NumericEnum_ZERO } func (x *ABitOfEverything) GetRepeatedStringAnnotation() []string { if x != nil { return x.RepeatedStringAnnotation } return nil } func (x *ABitOfEverything) GetRepeatedNestedAnnotation() []*ABitOfEverything_Nested { if x != nil { return x.RepeatedNestedAnnotation } return nil } func (x *ABitOfEverything) GetNestedAnnotation() *ABitOfEverything_Nested { if x != nil { return x.NestedAnnotation } return nil } func (x *ABitOfEverything) GetInt64OverrideType() int64 { if x != nil { return x.Int64OverrideType } return 0 } func (x *ABitOfEverything) GetRequiredStringViaFieldBehaviorAnnotation() string { if x != nil { return x.RequiredStringViaFieldBehaviorAnnotation } return "" } func (x *ABitOfEverything) GetOutputOnlyStringViaFieldBehaviorAnnotation() string { if x != nil { return x.OutputOnlyStringViaFieldBehaviorAnnotation } return "" } func (x *ABitOfEverything) GetOptionalStringValue() string { if x != nil && x.OptionalStringValue != nil { return *x.OptionalStringValue } return "" } func (x *ABitOfEverything) GetProductId() []string { if x != nil { return x.ProductId } return nil } func (x *ABitOfEverything) GetOptionalStringField() string { if x != nil { return x.OptionalStringField } return "" } func (x *ABitOfEverything) GetRequiredStringField_1() string { if x != nil { return x.RequiredStringField_1 } return "" } func (x *ABitOfEverything) GetRequiredStringField_2() string { if x != nil { return x.RequiredStringField_2 } return "" } func (x *ABitOfEverything) GetRequiredFieldBehaviorJsonName() string { if x != nil { return x.RequiredFieldBehaviorJsonName } return "" } func (x *ABitOfEverything) GetRequiredFieldSchemaJsonName() string { if x != nil { return x.RequiredFieldSchemaJsonName } return "" } func (x *ABitOfEverything) GetTrailingOnly() string { if x != nil { return x.TrailingOnly } return "" } func (x *ABitOfEverything) GetTrailingOnlyDot() string { if x != nil { return x.TrailingOnlyDot } return "" } func (x *ABitOfEverything) GetTrailingBoth() string { if x != nil { return x.TrailingBoth } return "" } func (x *ABitOfEverything) GetTrailingMultiline() string { if x != nil { return x.TrailingMultiline } return "" } func (x *ABitOfEverything) GetUuids() []string { if x != nil { return x.Uuids } return nil } type isABitOfEverything_OneofValue interface { isABitOfEverything_OneofValue() } type ABitOfEverything_OneofEmpty struct { OneofEmpty *emptypb.Empty `protobuf:"bytes,20,opt,name=oneof_empty,json=oneofEmpty,proto3,oneof"` } type ABitOfEverything_OneofString struct { OneofString string `protobuf:"bytes,21,opt,name=oneof_string,json=oneofString,proto3,oneof"` } func (*ABitOfEverything_OneofEmpty) isABitOfEverything_OneofValue() {} func (*ABitOfEverything_OneofString) isABitOfEverything_OneofValue() {} // ABitOfEverythingRepeated is used to validate repeated path parameter functionality type ABitOfEverythingRepeated struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // repeated values. they are comma-separated in path PathRepeatedFloatValue []float32 `protobuf:"fixed32,1,rep,packed,name=path_repeated_float_value,json=pathRepeatedFloatValue,proto3" json:"path_repeated_float_value,omitempty"` PathRepeatedDoubleValue []float64 `protobuf:"fixed64,2,rep,packed,name=path_repeated_double_value,json=pathRepeatedDoubleValue,proto3" json:"path_repeated_double_value,omitempty"` PathRepeatedInt64Value []int64 `protobuf:"varint,3,rep,packed,name=path_repeated_int64_value,json=pathRepeatedInt64Value,proto3" json:"path_repeated_int64_value,omitempty"` PathRepeatedUint64Value []uint64 `protobuf:"varint,4,rep,packed,name=path_repeated_uint64_value,json=pathRepeatedUint64Value,proto3" json:"path_repeated_uint64_value,omitempty"` PathRepeatedInt32Value []int32 `protobuf:"varint,5,rep,packed,name=path_repeated_int32_value,json=pathRepeatedInt32Value,proto3" json:"path_repeated_int32_value,omitempty"` PathRepeatedFixed64Value []uint64 `protobuf:"fixed64,6,rep,packed,name=path_repeated_fixed64_value,json=pathRepeatedFixed64Value,proto3" json:"path_repeated_fixed64_value,omitempty"` PathRepeatedFixed32Value []uint32 `protobuf:"fixed32,7,rep,packed,name=path_repeated_fixed32_value,json=pathRepeatedFixed32Value,proto3" json:"path_repeated_fixed32_value,omitempty"` PathRepeatedBoolValue []bool `protobuf:"varint,8,rep,packed,name=path_repeated_bool_value,json=pathRepeatedBoolValue,proto3" json:"path_repeated_bool_value,omitempty"` PathRepeatedStringValue []string `protobuf:"bytes,9,rep,name=path_repeated_string_value,json=pathRepeatedStringValue,proto3" json:"path_repeated_string_value,omitempty"` PathRepeatedBytesValue [][]byte `protobuf:"bytes,10,rep,name=path_repeated_bytes_value,json=pathRepeatedBytesValue,proto3" json:"path_repeated_bytes_value,omitempty"` PathRepeatedUint32Value []uint32 `protobuf:"varint,11,rep,packed,name=path_repeated_uint32_value,json=pathRepeatedUint32Value,proto3" json:"path_repeated_uint32_value,omitempty"` PathRepeatedEnumValue []NumericEnum `protobuf:"varint,12,rep,packed,name=path_repeated_enum_value,json=pathRepeatedEnumValue,proto3,enum=grpc.gateway.examples.internal.proto.examplepb.NumericEnum" json:"path_repeated_enum_value,omitempty"` PathRepeatedSfixed32Value []int32 `protobuf:"fixed32,13,rep,packed,name=path_repeated_sfixed32_value,json=pathRepeatedSfixed32Value,proto3" json:"path_repeated_sfixed32_value,omitempty"` PathRepeatedSfixed64Value []int64 `protobuf:"fixed64,14,rep,packed,name=path_repeated_sfixed64_value,json=pathRepeatedSfixed64Value,proto3" json:"path_repeated_sfixed64_value,omitempty"` PathRepeatedSint32Value []int32 `protobuf:"zigzag32,15,rep,packed,name=path_repeated_sint32_value,json=pathRepeatedSint32Value,proto3" json:"path_repeated_sint32_value,omitempty"` PathRepeatedSint64Value []int64 `protobuf:"zigzag64,16,rep,packed,name=path_repeated_sint64_value,json=pathRepeatedSint64Value,proto3" json:"path_repeated_sint64_value,omitempty"` } func (x *ABitOfEverythingRepeated) Reset() { *x = ABitOfEverythingRepeated{} mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *ABitOfEverythingRepeated) String() string { return protoimpl.X.MessageStringOf(x) } func (*ABitOfEverythingRepeated) ProtoMessage() {} func (x *ABitOfEverythingRepeated) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use ABitOfEverythingRepeated.ProtoReflect.Descriptor instead. func (*ABitOfEverythingRepeated) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP(), []int{3} } func (x *ABitOfEverythingRepeated) GetPathRepeatedFloatValue() []float32 { if x != nil { return x.PathRepeatedFloatValue } return nil } func (x *ABitOfEverythingRepeated) GetPathRepeatedDoubleValue() []float64 { if x != nil { return x.PathRepeatedDoubleValue } return nil } func (x *ABitOfEverythingRepeated) GetPathRepeatedInt64Value() []int64 { if x != nil { return x.PathRepeatedInt64Value } return nil } func (x *ABitOfEverythingRepeated) GetPathRepeatedUint64Value() []uint64 { if x != nil { return x.PathRepeatedUint64Value } return nil } func (x *ABitOfEverythingRepeated) GetPathRepeatedInt32Value() []int32 { if x != nil { return x.PathRepeatedInt32Value } return nil } func (x *ABitOfEverythingRepeated) GetPathRepeatedFixed64Value() []uint64 { if x != nil { return x.PathRepeatedFixed64Value } return nil } func (x *ABitOfEverythingRepeated) GetPathRepeatedFixed32Value() []uint32 { if x != nil { return x.PathRepeatedFixed32Value } return nil } func (x *ABitOfEverythingRepeated) GetPathRepeatedBoolValue() []bool { if x != nil { return x.PathRepeatedBoolValue } return nil } func (x *ABitOfEverythingRepeated) GetPathRepeatedStringValue() []string { if x != nil { return x.PathRepeatedStringValue } return nil } func (x *ABitOfEverythingRepeated) GetPathRepeatedBytesValue() [][]byte { if x != nil { return x.PathRepeatedBytesValue } return nil } func (x *ABitOfEverythingRepeated) GetPathRepeatedUint32Value() []uint32 { if x != nil { return x.PathRepeatedUint32Value } return nil } func (x *ABitOfEverythingRepeated) GetPathRepeatedEnumValue() []NumericEnum { if x != nil { return x.PathRepeatedEnumValue } return nil } func (x *ABitOfEverythingRepeated) GetPathRepeatedSfixed32Value() []int32 { if x != nil { return x.PathRepeatedSfixed32Value } return nil } func (x *ABitOfEverythingRepeated) GetPathRepeatedSfixed64Value() []int64 { if x != nil { return x.PathRepeatedSfixed64Value } return nil } func (x *ABitOfEverythingRepeated) GetPathRepeatedSint32Value() []int32 { if x != nil { return x.PathRepeatedSint32Value } return nil } func (x *ABitOfEverythingRepeated) GetPathRepeatedSint64Value() []int64 { if x != nil { return x.PathRepeatedSint64Value } return nil } type CheckStatusResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Status *status.Status `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` } func (x *CheckStatusResponse) Reset() { *x = CheckStatusResponse{} mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *CheckStatusResponse) String() string { return protoimpl.X.MessageStringOf(x) } func (*CheckStatusResponse) ProtoMessage() {} func (x *CheckStatusResponse) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use CheckStatusResponse.ProtoReflect.Descriptor instead. func (*CheckStatusResponse) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP(), []int{4} } func (x *CheckStatusResponse) GetStatus() *status.Status { if x != nil { return x.Status } return nil } type Body struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` } func (x *Body) Reset() { *x = Body{} mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Body) String() string { return protoimpl.X.MessageStringOf(x) } func (*Body) ProtoMessage() {} func (x *Body) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Body.ProtoReflect.Descriptor instead. func (*Body) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP(), []int{5} } func (x *Body) GetName() string { if x != nil { return x.Name } return "" } type MessageWithBody struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Data *Body `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` } func (x *MessageWithBody) Reset() { *x = MessageWithBody{} mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *MessageWithBody) String() string { return protoimpl.X.MessageStringOf(x) } func (*MessageWithBody) ProtoMessage() {} func (x *MessageWithBody) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use MessageWithBody.ProtoReflect.Descriptor instead. func (*MessageWithBody) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP(), []int{6} } func (x *MessageWithBody) GetId() string { if x != nil { return x.Id } return "" } func (x *MessageWithBody) GetData() *Body { if x != nil { return x.Data } return nil } // UpdateV2Request request for update includes the message and the update mask type UpdateV2Request struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Abe *ABitOfEverything `protobuf:"bytes,1,opt,name=abe,proto3" json:"abe,omitempty"` // The paths to update. UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,2,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"` } func (x *UpdateV2Request) Reset() { *x = UpdateV2Request{} mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *UpdateV2Request) String() string { return protoimpl.X.MessageStringOf(x) } func (*UpdateV2Request) ProtoMessage() {} func (x *UpdateV2Request) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use UpdateV2Request.ProtoReflect.Descriptor instead. func (*UpdateV2Request) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP(), []int{7} } func (x *UpdateV2Request) GetAbe() *ABitOfEverything { if x != nil { return x.Abe } return nil } func (x *UpdateV2Request) GetUpdateMask() *fieldmaskpb.FieldMask { if x != nil { return x.UpdateMask } return nil } // An example resource type from AIP-123 used to test the behavior described in // the CreateBookRequest message. // // See: https://google.aip.dev/123 type Book struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // The resource name of the book. // // Format: `publishers/{publisher}/books/{book}` // // Example: `publishers/1257894000000000000/books/my-book` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // Output only. The book's ID. Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` // Output only. Creation time of the book. CreateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"` } func (x *Book) Reset() { *x = Book{} mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Book) String() string { return protoimpl.X.MessageStringOf(x) } func (*Book) ProtoMessage() {} func (x *Book) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Book.ProtoReflect.Descriptor instead. func (*Book) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP(), []int{8} } func (x *Book) GetName() string { if x != nil { return x.Name } return "" } func (x *Book) GetId() string { if x != nil { return x.Id } return "" } func (x *Book) GetCreateTime() *timestamppb.Timestamp { if x != nil { return x.CreateTime } return nil } // A standard Create message from AIP-133 with a user-specified ID. // The user-specified ID (the `book_id` field in this example) must become a // query parameter in the OpenAPI spec. // // See: https://google.aip.dev/133#user-specified-ids type CreateBookRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // The publisher in which to create the book. // // Format: `publishers/{publisher}` // // Example: `publishers/1257894000000000000` Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` // The book to create. Book *Book `protobuf:"bytes,2,opt,name=book,proto3" json:"book,omitempty"` // The ID to use for the book. // // This must start with an alphanumeric character. BookId string `protobuf:"bytes,3,opt,name=book_id,json=bookId,proto3" json:"book_id,omitempty"` } func (x *CreateBookRequest) Reset() { *x = CreateBookRequest{} mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *CreateBookRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*CreateBookRequest) ProtoMessage() {} func (x *CreateBookRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use CreateBookRequest.ProtoReflect.Descriptor instead. func (*CreateBookRequest) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP(), []int{9} } func (x *CreateBookRequest) GetParent() string { if x != nil { return x.Parent } return "" } func (x *CreateBookRequest) GetBook() *Book { if x != nil { return x.Book } return nil } func (x *CreateBookRequest) GetBookId() string { if x != nil { return x.BookId } return "" } // A standard Update message from AIP-134 // // See: https://google.aip.dev/134#request-message type UpdateBookRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // The book to update. // // The book's `name` field is used to identify the book to be updated. // Format: publishers/{publisher}/books/{book} Book *Book `protobuf:"bytes,1,opt,name=book,proto3" json:"book,omitempty"` // The list of fields to be updated. UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,2,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"` // If set to true, and the book is not found, a new book will be created. // In this situation, `update_mask` is ignored. AllowMissing bool `protobuf:"varint,3,opt,name=allow_missing,json=allowMissing,proto3" json:"allow_missing,omitempty"` } func (x *UpdateBookRequest) Reset() { *x = UpdateBookRequest{} mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *UpdateBookRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*UpdateBookRequest) ProtoMessage() {} func (x *UpdateBookRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use UpdateBookRequest.ProtoReflect.Descriptor instead. func (*UpdateBookRequest) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP(), []int{10} } func (x *UpdateBookRequest) GetBook() *Book { if x != nil { return x.Book } return nil } func (x *UpdateBookRequest) GetUpdateMask() *fieldmaskpb.FieldMask { if x != nil { return x.UpdateMask } return nil } func (x *UpdateBookRequest) GetAllowMissing() bool { if x != nil { return x.AllowMissing } return false } type SnakeEnumRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields What SnakeCaseEnum `protobuf:"varint,1,opt,name=what,proto3,enum=grpc.gateway.examples.internal.proto.examplepb.SnakeCaseEnum" json:"what,omitempty"` Who SnakeCase_0Enum `protobuf:"varint,2,opt,name=who,proto3,enum=grpc.gateway.examples.internal.proto.examplepb.SnakeCase_0Enum" json:"who,omitempty"` Where pathenum.SnakeCaseForImport `protobuf:"varint,3,opt,name=where,proto3,enum=grpc.gateway.examples.internal.pathenum.SnakeCaseForImport" json:"where,omitempty"` } func (x *SnakeEnumRequest) Reset() { *x = SnakeEnumRequest{} mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *SnakeEnumRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*SnakeEnumRequest) ProtoMessage() {} func (x *SnakeEnumRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use SnakeEnumRequest.ProtoReflect.Descriptor instead. func (*SnakeEnumRequest) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP(), []int{11} } func (x *SnakeEnumRequest) GetWhat() SnakeCaseEnum { if x != nil { return x.What } return SnakeCaseEnum_value_c } func (x *SnakeEnumRequest) GetWho() SnakeCase_0Enum { if x != nil { return x.Who } return SnakeCase_0Enum_value_e } func (x *SnakeEnumRequest) GetWhere() pathenum.SnakeCaseForImport { if x != nil { return x.Where } return pathenum.SnakeCaseForImport(0) } type SnakeEnumResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields } func (x *SnakeEnumResponse) Reset() { *x = SnakeEnumResponse{} mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *SnakeEnumResponse) String() string { return protoimpl.X.MessageStringOf(x) } func (*SnakeEnumResponse) ProtoMessage() {} func (x *SnakeEnumResponse) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use SnakeEnumResponse.ProtoReflect.Descriptor instead. func (*SnakeEnumResponse) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP(), []int{12} } // Required message type -> OpenAPI // https://github.com/grpc-ecosystem/grpc-gateway/issues/2837 type RequiredMessageTypeRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Foo *Foo `protobuf:"bytes,2,opt,name=foo,proto3" json:"foo,omitempty"` } func (x *RequiredMessageTypeRequest) Reset() { *x = RequiredMessageTypeRequest{} mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *RequiredMessageTypeRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*RequiredMessageTypeRequest) ProtoMessage() {} func (x *RequiredMessageTypeRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use RequiredMessageTypeRequest.ProtoReflect.Descriptor instead. func (*RequiredMessageTypeRequest) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP(), []int{13} } func (x *RequiredMessageTypeRequest) GetId() string { if x != nil { return x.Id } return "" } func (x *RequiredMessageTypeRequest) GetFoo() *Foo { if x != nil { return x.Foo } return nil } type Foo struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Bar *Bar `protobuf:"bytes,1,opt,name=bar,proto3" json:"bar,omitempty"` } func (x *Foo) Reset() { *x = Foo{} mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Foo) String() string { return protoimpl.X.MessageStringOf(x) } func (*Foo) ProtoMessage() {} func (x *Foo) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Foo.ProtoReflect.Descriptor instead. func (*Foo) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP(), []int{14} } func (x *Foo) GetBar() *Bar { if x != nil { return x.Bar } return nil } type Bar struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` } func (x *Bar) Reset() { *x = Bar{} mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Bar) String() string { return protoimpl.X.MessageStringOf(x) } func (*Bar) ProtoMessage() {} func (x *Bar) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Bar.ProtoReflect.Descriptor instead. func (*Bar) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP(), []int{15} } func (x *Bar) GetId() string { if x != nil { return x.Id } return "" } // Nested is nested type. type ABitOfEverything_Nested struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // name is nested field. Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Amount uint32 `protobuf:"varint,2,opt,name=amount,proto3" json:"amount,omitempty"` // DeepEnum comment. Ok ABitOfEverything_Nested_DeepEnum `protobuf:"varint,3,opt,name=ok,proto3,enum=grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything_Nested_DeepEnum" json:"ok,omitempty"` } func (x *ABitOfEverything_Nested) Reset() { *x = ABitOfEverything_Nested{} mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *ABitOfEverything_Nested) String() string { return protoimpl.X.MessageStringOf(x) } func (*ABitOfEverything_Nested) ProtoMessage() {} func (x *ABitOfEverything_Nested) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use ABitOfEverything_Nested.ProtoReflect.Descriptor instead. func (*ABitOfEverything_Nested) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP(), []int{2, 0} } func (x *ABitOfEverything_Nested) GetName() string { if x != nil { return x.Name } return "" } func (x *ABitOfEverything_Nested) GetAmount() uint32 { if x != nil { return x.Amount } return 0 } func (x *ABitOfEverything_Nested) GetOk() ABitOfEverything_Nested_DeepEnum { if x != nil { return x.Ok } return ABitOfEverything_Nested_FALSE } var File_examples_internal_proto_examplepb_a_bit_of_everything_proto protoreflect.FileDescriptor var file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDesc = []byte{ 0x0a, 0x3b, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x32, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x65, 0x6e, 0x75, 0x6d, 0x2f, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x30, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x65, 0x6e, 0x75, 0x6d, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x29, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x75, 0x62, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2a, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x75, 0x62, 0x32, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc6, 0x02, 0x0a, 0x0d, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0xe1, 0x01, 0x0a, 0x0d, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0xba, 0x01, 0x92, 0x41, 0xb6, 0x01, 0x2a, 0x10, 0x78, 0x2d, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2d, 0x69, 0x64, 0x32, 0x2b, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x20, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x20, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x4a, 0x26, 0x22, 0x32, 0x34, 0x33, 0x38, 0x61, 0x63, 0x33, 0x63, 0x2d, 0x33, 0x37, 0x65, 0x62, 0x2d, 0x34, 0x39, 0x30, 0x32, 0x2d, 0x61, 0x64, 0x65, 0x66, 0x2d, 0x65, 0x64, 0x31, 0x36, 0x62, 0x34, 0x34, 0x33, 0x31, 0x30, 0x33, 0x30, 0x22, 0x8a, 0x01, 0x45, 0x5e, 0x5b, 0x30, 0x2d, 0x39, 0x41, 0x2d, 0x46, 0x5d, 0x7b, 0x38, 0x7d, 0x2d, 0x5b, 0x30, 0x2d, 0x39, 0x41, 0x2d, 0x46, 0x5d, 0x7b, 0x34, 0x7d, 0x2d, 0x34, 0x5b, 0x30, 0x2d, 0x39, 0x41, 0x2d, 0x46, 0x5d, 0x7b, 0x33, 0x7d, 0x2d, 0x5b, 0x38, 0x39, 0x41, 0x42, 0x5d, 0x5b, 0x30, 0x2d, 0x39, 0x41, 0x2d, 0x46, 0x5d, 0x7b, 0x33, 0x7d, 0x2d, 0x5b, 0x30, 0x2d, 0x39, 0x41, 0x2d, 0x46, 0x5d, 0x7b, 0x31, 0x32, 0x7d, 0x24, 0xa2, 0x02, 0x04, 0x75, 0x75, 0x69, 0x64, 0x52, 0x0d, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x51, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x3b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xa0, 0x01, 0x0a, 0x0b, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x40, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x42, 0x2c, 0x92, 0x41, 0x29, 0x2a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x32, 0x0d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x20, 0x63, 0x6f, 0x64, 0x65, 0x8a, 0x01, 0x07, 0x5e, 0x5b, 0x30, 0x2d, 0x39, 0x5d, 0x24, 0xa2, 0x02, 0x07, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x4f, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x35, 0x92, 0x41, 0x32, 0x2a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x10, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x8a, 0x01, 0x14, 0x5e, 0x5b, 0x61, 0x2d, 0x7a, 0x41, 0x2d, 0x5a, 0x30, 0x2d, 0x39, 0x5d, 0x7b, 0x31, 0x2c, 0x20, 0x33, 0x32, 0x7d, 0x24, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xe4, 0x25, 0x0a, 0x10, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x6c, 0x0a, 0x0d, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x5f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x18, 0x19, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x47, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x0c, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x12, 0x90, 0x01, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x7c, 0x92, 0x41, 0x79, 0x80, 0x01, 0x01, 0x8a, 0x01, 0x4b, 0x5b, 0x61, 0x2d, 0x66, 0x41, 0x2d, 0x46, 0x30, 0x2d, 0x39, 0x5d, 0x7b, 0x38, 0x7d, 0x2d, 0x5b, 0x61, 0x2d, 0x66, 0x41, 0x2d, 0x46, 0x30, 0x2d, 0x39, 0x5d, 0x7b, 0x34, 0x7d, 0x2d, 0x5b, 0x61, 0x2d, 0x66, 0x41, 0x2d, 0x46, 0x30, 0x2d, 0x39, 0x5d, 0x7b, 0x34, 0x7d, 0x2d, 0x5b, 0x61, 0x2d, 0x66, 0x41, 0x2d, 0x46, 0x30, 0x2d, 0x39, 0x5d, 0x7b, 0x34, 0x7d, 0x2d, 0x5b, 0x61, 0x2d, 0x66, 0x41, 0x2d, 0x46, 0x30, 0x2d, 0x39, 0x5d, 0x7b, 0x31, 0x32, 0x7d, 0xa2, 0x02, 0x04, 0x75, 0x75, 0x69, 0x64, 0x82, 0x03, 0x10, 0x0a, 0x0a, 0x78, 0x2d, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x12, 0x02, 0x20, 0x01, 0xca, 0x3e, 0x0b, 0xfa, 0x02, 0x08, 0x75, 0x75, 0x69, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x5f, 0x0a, 0x06, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x47, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x06, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x12, 0x4a, 0x0a, 0x0b, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x42, 0x29, 0x92, 0x41, 0x26, 0x32, 0x11, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x3a, 0x03, 0x30, 0x2e, 0x32, 0xd2, 0x01, 0x0b, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0b, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x06, 0x52, 0x0c, 0x66, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x07, 0x52, 0x0c, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x1d, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x62, 0x79, 0x74, 0x65, 0x73, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x5a, 0x0a, 0x0a, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x09, 0x65, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x59, 0x0a, 0x0f, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x31, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x61, 0x74, 0x68, 0x65, 0x6e, 0x75, 0x6d, 0x2e, 0x50, 0x61, 0x74, 0x68, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x0d, 0x70, 0x61, 0x74, 0x68, 0x45, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x7c, 0x0a, 0x16, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x1f, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x47, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x61, 0x74, 0x68, 0x65, 0x6e, 0x75, 0x6d, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x50, 0x61, 0x74, 0x68, 0x45, 0x6e, 0x75, 0x6d, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x74, 0x68, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x13, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x74, 0x68, 0x45, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0f, 0x52, 0x0d, 0x73, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x66, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x10, 0x20, 0x01, 0x28, 0x10, 0x52, 0x0d, 0x73, 0x66, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x11, 0x20, 0x01, 0x28, 0x11, 0x52, 0x0b, 0x73, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x12, 0x20, 0x01, 0x28, 0x12, 0x52, 0x0b, 0x73, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x32, 0x0a, 0x15, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x13, 0x20, 0x03, 0x28, 0x09, 0x52, 0x13, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x39, 0x0a, 0x0b, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x5f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x48, 0x00, 0x52, 0x0a, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x23, 0x0a, 0x0c, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x15, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0b, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x6b, 0x0a, 0x09, 0x6d, 0x61, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x16, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x4e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x6d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0xbd, 0x01, 0x0a, 0x13, 0x6d, 0x61, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x17, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x57, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x4d, 0x61, 0x70, 0x70, 0x65, 0x64, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x42, 0x34, 0x92, 0x41, 0x31, 0x2a, 0x13, 0x4d, 0x61, 0x70, 0x20, 0x6f, 0x66, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x32, 0x1a, 0x4d, 0x61, 0x70, 0x20, 0x6f, 0x66, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x11, 0x6d, 0x61, 0x70, 0x70, 0x65, 0x64, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x87, 0x01, 0x0a, 0x13, 0x6d, 0x61, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x18, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x57, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x4d, 0x61, 0x70, 0x70, 0x65, 0x64, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x11, 0x6d, 0x61, 0x70, 0x70, 0x65, 0x64, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3a, 0x0a, 0x18, 0x6e, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x1a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x18, 0x6e, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x43, 0x0a, 0x0f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x1b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x6b, 0x0a, 0x13, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x1c, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x3b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x11, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x45, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0xbb, 0x01, 0x0a, 0x18, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x20, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x3b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x45, 0x6e, 0x75, 0x6d, 0x42, 0x44, 0x92, 0x41, 0x41, 0x2a, 0x1b, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x6e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x20, 0x65, 0x6e, 0x75, 0x6d, 0x20, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x32, 0x22, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x6e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x20, 0x65, 0x6e, 0x75, 0x6d, 0x20, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x16, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x45, 0x6e, 0x75, 0x6d, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0xa3, 0x01, 0x0a, 0x15, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x21, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x45, 0x6e, 0x75, 0x6d, 0x42, 0x32, 0x92, 0x41, 0x2f, 0x2a, 0x12, 0x4e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x20, 0x65, 0x6e, 0x75, 0x6d, 0x20, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x32, 0x19, 0x4e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x20, 0x65, 0x6e, 0x75, 0x6d, 0x20, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x13, 0x65, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x76, 0x0a, 0x1a, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x22, 0x20, 0x03, 0x28, 0x09, 0x42, 0x38, 0x92, 0x41, 0x35, 0x2a, 0x15, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x32, 0x1c, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x18, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0xcd, 0x01, 0x0a, 0x1a, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x23, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x47, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x42, 0x46, 0x92, 0x41, 0x43, 0x2a, 0x1c, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x32, 0x23, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x18, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0xaa, 0x01, 0x0a, 0x11, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x24, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x47, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x42, 0x34, 0x92, 0x41, 0x31, 0x2a, 0x13, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x32, 0x1a, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x20, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x10, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x37, 0x0a, 0x13, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x25, 0x20, 0x01, 0x28, 0x03, 0x42, 0x07, 0x92, 0x41, 0x04, 0x9a, 0x02, 0x01, 0x03, 0x52, 0x11, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x65, 0x0a, 0x2d, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x69, 0x61, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x5f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x26, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x28, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x69, 0x61, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x42, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x6a, 0x0a, 0x30, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x69, 0x61, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x5f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x27, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x03, 0x52, 0x2a, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x4f, 0x6e, 0x6c, 0x79, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x69, 0x61, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x42, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x37, 0x0a, 0x15, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x28, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x13, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x88, 0x01, 0x01, 0x12, 0x4c, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x29, 0x20, 0x03, 0x28, 0x09, 0x42, 0x2d, 0x92, 0x41, 0x2a, 0x32, 0x18, 0x4f, 0x6e, 0x6c, 0x79, 0x20, 0x64, 0x69, 0x67, 0x69, 0x74, 0x73, 0x20, 0x61, 0x72, 0x65, 0x20, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x2e, 0x78, 0x13, 0x80, 0x01, 0x01, 0x8a, 0x01, 0x08, 0x5e, 0x5b, 0x30, 0x2d, 0x39, 0x5d, 0x2b, 0x24, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x12, 0x32, 0x0a, 0x15, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x2a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x3b, 0x0a, 0x17, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x31, 0x18, 0x2b, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x14, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x31, 0x12, 0x3b, 0x0a, 0x17, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x32, 0x18, 0x2c, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x14, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x32, 0x12, 0x59, 0x0a, 0x21, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x2d, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x28, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x62, 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x12, 0x4f, 0x0a, 0x1f, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x2e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x26, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x12, 0x23, 0x0a, 0x0d, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x67, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x2f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x67, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x2a, 0x0a, 0x11, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x67, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x5f, 0x64, 0x6f, 0x74, 0x18, 0x30, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x67, 0x4f, 0x6e, 0x6c, 0x79, 0x44, 0x6f, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x67, 0x5f, 0x62, 0x6f, 0x74, 0x68, 0x18, 0x31, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x67, 0x42, 0x6f, 0x74, 0x68, 0x12, 0x2d, 0x0a, 0x12, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x67, 0x5f, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x32, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x67, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x20, 0x0a, 0x05, 0x75, 0x75, 0x69, 0x64, 0x73, 0x18, 0x33, 0x20, 0x03, 0x28, 0x09, 0x42, 0x0a, 0x92, 0x41, 0x07, 0xa2, 0x02, 0x04, 0x75, 0x75, 0x69, 0x64, 0x52, 0x05, 0x75, 0x75, 0x69, 0x64, 0x73, 0x1a, 0xe8, 0x01, 0x0a, 0x06, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x7c, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x50, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x2e, 0x44, 0x65, 0x65, 0x70, 0x45, 0x6e, 0x75, 0x6d, 0x42, 0x1a, 0x92, 0x41, 0x17, 0x32, 0x15, 0x44, 0x65, 0x65, 0x70, 0x45, 0x6e, 0x75, 0x6d, 0x20, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x02, 0x6f, 0x6b, 0x22, 0x1f, 0x0a, 0x08, 0x44, 0x65, 0x65, 0x70, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x09, 0x0a, 0x05, 0x46, 0x41, 0x4c, 0x53, 0x45, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x54, 0x52, 0x55, 0x45, 0x10, 0x01, 0x3a, 0x13, 0x92, 0x41, 0x10, 0x32, 0x0e, 0x7b, 0x22, 0x6f, 0x6b, 0x22, 0x3a, 0x20, 0x22, 0x54, 0x52, 0x55, 0x45, 0x22, 0x7d, 0x1a, 0x78, 0x0a, 0x0d, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x51, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x44, 0x0a, 0x16, 0x4d, 0x61, 0x70, 0x70, 0x65, 0x64, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x8d, 0x01, 0x0a, 0x16, 0x4d, 0x61, 0x70, 0x70, 0x65, 0x64, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x5d, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x47, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x3a, 0xd6, 0x02, 0x92, 0x41, 0xd2, 0x02, 0x0a, 0xcc, 0x01, 0x2a, 0x13, 0x41, 0x20, 0x62, 0x69, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x32, 0x4a, 0x49, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x6c, 0x79, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x65, 0x64, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x74, 0x79, 0x70, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x20, 0x6d, 0x61, 0x6e, 0x79, 0x20, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x20, 0x6f, 0x66, 0x20, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0xd2, 0x01, 0x04, 0x75, 0x75, 0x69, 0x64, 0xd2, 0x01, 0x0b, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0xd2, 0x01, 0x0c, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0xd2, 0x01, 0x1f, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x82, 0x03, 0x22, 0x0a, 0x19, 0x78, 0x2d, 0x61, 0x2d, 0x62, 0x69, 0x74, 0x2d, 0x6f, 0x66, 0x2d, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2d, 0x66, 0x6f, 0x6f, 0x12, 0x05, 0x1a, 0x03, 0x62, 0x61, 0x72, 0x2a, 0x56, 0x0a, 0x24, 0x46, 0x69, 0x6e, 0x64, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x6d, 0x6f, 0x72, 0x65, 0x20, 0x61, 0x62, 0x6f, 0x75, 0x74, 0x20, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x32, 0x29, 0x7b, 0x22, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x20, 0x31, 0x32, 0x2c, 0x20, 0x22, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x20, 0x31, 0x32, 0x2e, 0x33, 0x7d, 0x42, 0x0d, 0x0a, 0x0b, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x18, 0x0a, 0x16, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x89, 0x09, 0x0a, 0x18, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x12, 0x39, 0x0a, 0x19, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x02, 0x52, 0x16, 0x70, 0x61, 0x74, 0x68, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3b, 0x0a, 0x1a, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x01, 0x52, 0x17, 0x70, 0x61, 0x74, 0x68, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x39, 0x0a, 0x19, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x03, 0x52, 0x16, 0x70, 0x61, 0x74, 0x68, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3b, 0x0a, 0x1a, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x03, 0x28, 0x04, 0x52, 0x17, 0x70, 0x61, 0x74, 0x68, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x55, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x39, 0x0a, 0x19, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x03, 0x28, 0x05, 0x52, 0x16, 0x70, 0x61, 0x74, 0x68, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3d, 0x0a, 0x1b, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x66, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, 0x20, 0x03, 0x28, 0x06, 0x52, 0x18, 0x70, 0x61, 0x74, 0x68, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x46, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3d, 0x0a, 0x1b, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x07, 0x20, 0x03, 0x28, 0x07, 0x52, 0x18, 0x70, 0x61, 0x74, 0x68, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x46, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x37, 0x0a, 0x18, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x08, 0x20, 0x03, 0x28, 0x08, 0x52, 0x15, 0x70, 0x61, 0x74, 0x68, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x42, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3b, 0x0a, 0x1a, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x17, 0x70, 0x61, 0x74, 0x68, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x39, 0x0a, 0x19, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x16, 0x70, 0x61, 0x74, 0x68, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x42, 0x79, 0x74, 0x65, 0x73, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3b, 0x0a, 0x1a, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0d, 0x52, 0x17, 0x70, 0x61, 0x74, 0x68, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x55, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x74, 0x0a, 0x18, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x3b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x15, 0x70, 0x61, 0x74, 0x68, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x45, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3f, 0x0a, 0x1c, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x73, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0f, 0x52, 0x19, 0x70, 0x61, 0x74, 0x68, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x53, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3f, 0x0a, 0x1c, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x73, 0x66, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x10, 0x52, 0x19, 0x70, 0x61, 0x74, 0x68, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x53, 0x66, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3b, 0x0a, 0x1a, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x73, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x11, 0x52, 0x17, 0x70, 0x61, 0x74, 0x68, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x53, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3b, 0x0a, 0x1a, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x73, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x10, 0x20, 0x03, 0x28, 0x12, 0x52, 0x17, 0x70, 0x61, 0x74, 0x68, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x53, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x64, 0x92, 0x41, 0x61, 0x32, 0x5f, 0x7b, 0x22, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x20, 0x5b, 0x74, 0x72, 0x75, 0x65, 0x2c, 0x20, 0x74, 0x72, 0x75, 0x65, 0x2c, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x2c, 0x20, 0x74, 0x72, 0x75, 0x65, 0x5d, 0x2c, 0x20, 0x22, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x20, 0x5b, 0x31, 0x2c, 0x20, 0x32, 0x2c, 0x20, 0x33, 0x5d, 0x7d, 0x22, 0x41, 0x0a, 0x13, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x1a, 0x0a, 0x04, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x6b, 0x0a, 0x0f, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x57, 0x69, 0x74, 0x68, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x48, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x42, 0x6f, 0x64, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xa2, 0x01, 0x0a, 0x0f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x32, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x52, 0x0a, 0x03, 0x61, 0x62, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x52, 0x03, 0x61, 0x62, 0x65, 0x12, 0x3b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x6b, 0x22, 0x67, 0x0a, 0x04, 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x94, 0x01, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x4e, 0x0a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x12, 0x17, 0x0a, 0x07, 0x62, 0x6f, 0x6f, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x62, 0x6f, 0x6f, 0x6b, 0x49, 0x64, 0x22, 0xc5, 0x01, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x4e, 0x0a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x12, 0x3b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x6b, 0x12, 0x23, 0x0a, 0x0d, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x4d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x22, 0x92, 0x02, 0x0a, 0x10, 0x53, 0x6e, 0x61, 0x6b, 0x65, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x53, 0x0a, 0x04, 0x77, 0x68, 0x61, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x73, 0x6e, 0x61, 0x6b, 0x65, 0x5f, 0x63, 0x61, 0x73, 0x65, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x52, 0x04, 0x77, 0x68, 0x61, 0x74, 0x12, 0x53, 0x0a, 0x03, 0x77, 0x68, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x41, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x73, 0x6e, 0x61, 0x6b, 0x65, 0x5f, 0x63, 0x61, 0x73, 0x65, 0x5f, 0x30, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x52, 0x03, 0x77, 0x68, 0x6f, 0x12, 0x54, 0x0a, 0x05, 0x77, 0x68, 0x65, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x61, 0x74, 0x68, 0x65, 0x6e, 0x75, 0x6d, 0x2e, 0x73, 0x6e, 0x61, 0x6b, 0x65, 0x5f, 0x63, 0x61, 0x73, 0x65, 0x5f, 0x66, 0x6f, 0x72, 0x5f, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x05, 0x77, 0x68, 0x65, 0x72, 0x65, 0x22, 0x13, 0x0a, 0x11, 0x53, 0x6e, 0x61, 0x6b, 0x65, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x7f, 0x0a, 0x1a, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x02, 0x69, 0x64, 0x12, 0x4b, 0x0a, 0x03, 0x66, 0x6f, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x46, 0x6f, 0x6f, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x03, 0x66, 0x6f, 0x6f, 0x22, 0x52, 0x0a, 0x03, 0x46, 0x6f, 0x6f, 0x12, 0x4b, 0x0a, 0x03, 0x62, 0x61, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x42, 0x61, 0x72, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x03, 0x62, 0x61, 0x72, 0x22, 0x1b, 0x0a, 0x03, 0x42, 0x61, 0x72, 0x12, 0x14, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xe2, 0x41, 0x01, 0x02, 0x52, 0x02, 0x69, 0x64, 0x2a, 0xd5, 0x01, 0x0a, 0x0b, 0x4e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x08, 0x0a, 0x04, 0x5a, 0x45, 0x52, 0x4f, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x4e, 0x45, 0x10, 0x01, 0x1a, 0xb2, 0x01, 0x92, 0x41, 0xae, 0x01, 0x0a, 0x1b, 0x4e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x45, 0x6e, 0x75, 0x6d, 0x20, 0x69, 0x73, 0x20, 0x6f, 0x6e, 0x65, 0x20, 0x6f, 0x72, 0x20, 0x7a, 0x65, 0x72, 0x6f, 0x2e, 0x1a, 0x0b, 0x4e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x45, 0x6e, 0x75, 0x6d, 0x32, 0x56, 0x0a, 0x24, 0x46, 0x69, 0x6e, 0x64, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x6d, 0x6f, 0x72, 0x65, 0x20, 0x61, 0x62, 0x6f, 0x75, 0x74, 0x20, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x3a, 0x06, 0x22, 0x5a, 0x45, 0x52, 0x4f, 0x22, 0x4a, 0x22, 0x0a, 0x19, 0x78, 0x2d, 0x61, 0x2d, 0x62, 0x69, 0x74, 0x2d, 0x6f, 0x66, 0x2d, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2d, 0x66, 0x6f, 0x6f, 0x12, 0x05, 0x1a, 0x03, 0x62, 0x61, 0x72, 0x2a, 0x2b, 0x0a, 0x0f, 0x73, 0x6e, 0x61, 0x6b, 0x65, 0x5f, 0x63, 0x61, 0x73, 0x65, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x12, 0x0b, 0x0a, 0x07, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x63, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x64, 0x10, 0x01, 0x2a, 0x2d, 0x0a, 0x11, 0x73, 0x6e, 0x61, 0x6b, 0x65, 0x5f, 0x63, 0x61, 0x73, 0x65, 0x5f, 0x30, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x12, 0x0b, 0x0a, 0x07, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x65, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x66, 0x10, 0x01, 0x32, 0xa7, 0x38, 0x0a, 0x17, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x8c, 0x04, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x22, 0xfd, 0x02, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0xf6, 0x02, 0x22, 0xf3, 0x02, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x7b, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x73, 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x2f, 0x7b, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x66, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d, 0x73, 0x74, 0x72, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x2f, 0x2a, 0x7d, 0x2f, 0x7b, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x73, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x73, 0x66, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x73, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x73, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x6e, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x7d, 0x12, 0xbc, 0x01, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x22, 0x2a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x24, 0x3a, 0x01, 0x2a, 0x22, 0x1f, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x12, 0xb4, 0x01, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x41, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x22, 0x2d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x27, 0x3a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x22, 0x1f, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x3d, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x7d, 0x2f, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x12, 0xb9, 0x01, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x41, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x42, 0x6f, 0x6f, 0x6b, 0x22, 0x32, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2c, 0x3a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x32, 0x24, 0x2f, 0x76, 0x31, 0x2f, 0x7b, 0x62, 0x6f, 0x6f, 0x6b, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x73, 0x2f, 0x2a, 0x2f, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x2f, 0x2a, 0x7d, 0x12, 0xb0, 0x01, 0x0a, 0x06, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x12, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x73, 0x75, 0x62, 0x32, 0x2e, 0x49, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x22, 0x2e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x28, 0x12, 0x26, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x7b, 0x75, 0x75, 0x69, 0x64, 0x7d, 0x12, 0x85, 0x02, 0x0a, 0x06, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x12, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x22, 0x77, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x71, 0x5a, 0x40, 0x12, 0x3e, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x2f, 0x7b, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x22, 0x2d, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x7b, 0x75, 0x75, 0x69, 0x64, 0x7d, 0x3a, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x12, 0xcf, 0x01, 0x0a, 0x0b, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x43, 0x6f, 0x6c, 0x6f, 0x6e, 0x12, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x22, 0x3c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x36, 0x22, 0x34, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x7b, 0x75, 0x75, 0x69, 0x64, 0x7d, 0x3a, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x3a, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x12, 0x95, 0x01, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x31, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2b, 0x3a, 0x01, 0x2a, 0x1a, 0x26, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x7b, 0x75, 0x75, 0x69, 0x64, 0x7d, 0x12, 0x83, 0x02, 0x0a, 0x08, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x32, 0x12, 0x3f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x56, 0x32, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x9d, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x96, 0x01, 0x3a, 0x03, 0x61, 0x62, 0x65, 0x5a, 0x31, 0x3a, 0x03, 0x61, 0x62, 0x65, 0x32, 0x2a, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x7b, 0x61, 0x62, 0x65, 0x2e, 0x75, 0x75, 0x69, 0x64, 0x7d, 0x5a, 0x30, 0x3a, 0x01, 0x2a, 0x32, 0x2b, 0x2f, 0x76, 0x32, 0x61, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x7b, 0x61, 0x62, 0x65, 0x2e, 0x75, 0x75, 0x69, 0x64, 0x7d, 0x1a, 0x2a, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x7b, 0x61, 0x62, 0x65, 0x2e, 0x75, 0x75, 0x69, 0x64, 0x7d, 0x12, 0xca, 0x01, 0x0a, 0x06, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x73, 0x75, 0x62, 0x32, 0x2e, 0x49, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x72, 0x92, 0x41, 0x41, 0x62, 0x29, 0x0a, 0x0e, 0x0a, 0x0a, 0x41, 0x70, 0x69, 0x4b, 0x65, 0x79, 0x41, 0x75, 0x74, 0x68, 0x12, 0x00, 0x0a, 0x17, 0x0a, 0x06, 0x4f, 0x41, 0x75, 0x74, 0x68, 0x32, 0x12, 0x0d, 0x0a, 0x04, 0x72, 0x65, 0x61, 0x64, 0x0a, 0x05, 0x77, 0x72, 0x69, 0x74, 0x65, 0x6a, 0x14, 0x0a, 0x0e, 0x78, 0x2d, 0x69, 0x72, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x02, 0x20, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x28, 0x2a, 0x26, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x7b, 0x75, 0x75, 0x69, 0x64, 0x7d, 0x12, 0xf2, 0x01, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x8b, 0x01, 0x92, 0x41, 0x54, 0x22, 0x4e, 0x0a, 0x1c, 0x46, 0x69, 0x6e, 0x64, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x6d, 0x6f, 0x72, 0x65, 0x20, 0x61, 0x62, 0x6f, 0x75, 0x74, 0x20, 0x47, 0x65, 0x74, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x58, 0x01, 0x62, 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2e, 0x12, 0x2c, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x7b, 0x75, 0x75, 0x69, 0x64, 0x7d, 0x12, 0xa9, 0x05, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x48, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x1a, 0x48, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x22, 0x80, 0x04, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0xf9, 0x03, 0x12, 0xf6, 0x03, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x66, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x73, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x73, 0x66, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x73, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x2f, 0x7b, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x73, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x12, 0xa7, 0x04, 0x0a, 0x04, 0x45, 0x63, 0x68, 0x6f, 0x12, 0x37, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x73, 0x75, 0x62, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x37, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x73, 0x75, 0x62, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xac, 0x03, 0x92, 0x41, 0xc5, 0x02, 0x0a, 0x08, 0x65, 0x63, 0x68, 0x6f, 0x20, 0x72, 0x70, 0x63, 0x12, 0x11, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x3a, 0x20, 0x45, 0x63, 0x68, 0x6f, 0x20, 0x72, 0x70, 0x63, 0x1a, 0x10, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x45, 0x63, 0x68, 0x6f, 0x22, 0x44, 0x0a, 0x12, 0x46, 0x69, 0x6e, 0x64, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x6d, 0x6f, 0x72, 0x65, 0x20, 0x45, 0x63, 0x68, 0x6f, 0x12, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x4a, 0x39, 0x0a, 0x03, 0x32, 0x30, 0x30, 0x12, 0x32, 0x22, 0x30, 0x0a, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6a, 0x73, 0x6f, 0x6e, 0x12, 0x1c, 0x7b, 0x22, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x74, 0x68, 0x65, 0x20, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x7d, 0x4a, 0x3b, 0x0a, 0x03, 0x34, 0x30, 0x34, 0x12, 0x34, 0x0a, 0x2a, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x20, 0x77, 0x68, 0x65, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20, 0x64, 0x6f, 0x65, 0x73, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x65, 0x78, 0x69, 0x73, 0x74, 0x2e, 0x12, 0x06, 0x0a, 0x04, 0x9a, 0x02, 0x01, 0x03, 0x4a, 0x56, 0x0a, 0x03, 0x35, 0x30, 0x33, 0x12, 0x4f, 0x0a, 0x36, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x20, 0x77, 0x68, 0x65, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20, 0x69, 0x73, 0x20, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x72, 0x69, 0x6c, 0x79, 0x20, 0x75, 0x6e, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x2a, 0x15, 0x0a, 0x08, 0x78, 0x2d, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x09, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x40, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x5d, 0x5a, 0x19, 0x3a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x10, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x5a, 0x12, 0x12, 0x10, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x12, 0x2c, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x2f, 0x7b, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x12, 0xc9, 0x01, 0x0a, 0x0c, 0x44, 0x65, 0x65, 0x70, 0x50, 0x61, 0x74, 0x68, 0x45, 0x63, 0x68, 0x6f, 0x12, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x22, 0x35, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2f, 0x3a, 0x01, 0x2a, 0x22, 0x2a, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x64, 0x65, 0x65, 0x70, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x2f, 0x7b, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x5f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x7d, 0x12, 0x41, 0x0a, 0x0a, 0x4e, 0x6f, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x56, 0x0a, 0x07, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x12, 0x13, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x68, 0x0a, 0x10, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x57, 0x69, 0x74, 0x68, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x24, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x12, 0x1c, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x77, 0x69, 0x74, 0x68, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x96, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x57, 0x69, 0x74, 0x68, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x3f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x57, 0x69, 0x74, 0x68, 0x42, 0x6f, 0x64, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x27, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x21, 0x3a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x19, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x77, 0x69, 0x74, 0x68, 0x62, 0x6f, 0x64, 0x79, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x92, 0x01, 0x0a, 0x11, 0x50, 0x6f, 0x73, 0x74, 0x57, 0x69, 0x74, 0x68, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x42, 0x6f, 0x64, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x2f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x29, 0x3a, 0x01, 0x2a, 0x22, 0x24, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x70, 0x6f, 0x73, 0x74, 0x77, 0x69, 0x74, 0x68, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x62, 0x6f, 0x64, 0x79, 0x2f, 0x7b, 0x6e, 0x61, 0x6d, 0x65, 0x7d, 0x12, 0xe2, 0x01, 0x0a, 0x13, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x47, 0x65, 0x74, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x22, 0x47, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x41, 0x12, 0x3f, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2f, 0x67, 0x65, 0x74, 0x2f, 0x7b, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x5f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x7d, 0x12, 0xf6, 0x01, 0x0a, 0x1d, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x45, 0x6e, 0x75, 0x6d, 0x47, 0x65, 0x74, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x22, 0x51, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x4b, 0x12, 0x49, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2f, 0x67, 0x65, 0x74, 0x2f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x2f, 0x7b, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x5f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x2e, 0x6f, 0x6b, 0x7d, 0x12, 0xed, 0x01, 0x0a, 0x14, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x6f, 0x73, 0x74, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x22, 0x51, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x4b, 0x3a, 0x0d, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x5f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x22, 0x3a, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2f, 0x70, 0x6f, 0x73, 0x74, 0x2f, 0x7b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x12, 0xba, 0x01, 0x0a, 0x1b, 0x4f, 0x76, 0x65, 0x72, 0x77, 0x72, 0x69, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x42, 0x6f, 0x64, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x4d, 0x92, 0x41, 0x18, 0x32, 0x16, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78, 0x2d, 0x62, 0x61, 0x72, 0x2d, 0x6d, 0x69, 0x6d, 0x65, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2c, 0x3a, 0x01, 0x2a, 0x22, 0x27, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x6f, 0x76, 0x65, 0x72, 0x77, 0x72, 0x69, 0x74, 0x65, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x74, 0x79, 0x70, 0x65, 0x12, 0x9b, 0x01, 0x0a, 0x1c, 0x4f, 0x76, 0x65, 0x72, 0x77, 0x72, 0x69, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x45, 0x92, 0x41, 0x12, 0x3a, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x74, 0x65, 0x78, 0x74, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2a, 0x12, 0x28, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x6f, 0x76, 0x65, 0x72, 0x77, 0x72, 0x69, 0x74, 0x65, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x74, 0x79, 0x70, 0x65, 0x12, 0x88, 0x01, 0x0a, 0x15, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x50, 0x61, 0x74, 0x68, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x3c, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x61, 0x74, 0x68, 0x65, 0x6e, 0x75, 0x6d, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x57, 0x69, 0x74, 0x68, 0x50, 0x61, 0x74, 0x68, 0x45, 0x6e, 0x75, 0x6d, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x12, 0x11, 0x2f, 0x76, 0x32, 0x2f, 0x7b, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x3a, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x94, 0x01, 0x0a, 0x1b, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x74, 0x68, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x42, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x61, 0x74, 0x68, 0x65, 0x6e, 0x75, 0x6d, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x57, 0x69, 0x74, 0x68, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x74, 0x68, 0x45, 0x6e, 0x75, 0x6d, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x12, 0x11, 0x2f, 0x76, 0x33, 0x2f, 0x7b, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x7d, 0x3a, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x8b, 0x01, 0x0a, 0x0b, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x43, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x12, 0x17, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x9a, 0x01, 0x0a, 0x06, 0x45, 0x78, 0x69, 0x73, 0x74, 0x73, 0x12, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x36, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x30, 0x42, 0x2e, 0x0a, 0x04, 0x48, 0x45, 0x41, 0x44, 0x12, 0x26, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x7b, 0x75, 0x75, 0x69, 0x64, 0x7d, 0x12, 0xab, 0x01, 0x0a, 0x14, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x39, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x33, 0x42, 0x31, 0x0a, 0x07, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0x12, 0x26, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x7b, 0x75, 0x75, 0x69, 0x64, 0x7d, 0x12, 0xcb, 0x01, 0x0a, 0x0c, 0x54, 0x72, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x22, 0x37, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x31, 0x42, 0x2f, 0x0a, 0x05, 0x54, 0x52, 0x41, 0x43, 0x45, 0x12, 0x26, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x7b, 0x75, 0x75, 0x69, 0x64, 0x7d, 0x12, 0x96, 0x01, 0x0a, 0x0d, 0x50, 0x6f, 0x73, 0x74, 0x4f, 0x6e, 0x65, 0x6f, 0x66, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x65, 0x6e, 0x75, 0x6d, 0x2e, 0x4f, 0x6e, 0x65, 0x6f, 0x66, 0x45, 0x6e, 0x75, 0x6d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x2b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x25, 0x3a, 0x0c, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x22, 0x15, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x65, 0x6e, 0x75, 0x6d, 0x12, 0xa9, 0x01, 0x0a, 0x17, 0x50, 0x6f, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x4a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x2a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x24, 0x3a, 0x01, 0x2a, 0x22, 0x1f, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x74, 0x79, 0x70, 0x65, 0x1a, 0xd1, 0x01, 0x92, 0x41, 0xcd, 0x01, 0x0a, 0x10, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x66, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x20, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x2d, 0x2d, 0x20, 0x77, 0x68, 0x69, 0x63, 0x68, 0x20, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x62, 0x65, 0x20, 0x75, 0x73, 0x65, 0x64, 0x20, 0x69, 0x6e, 0x20, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x21, 0x1a, 0x51, 0x0a, 0x1f, 0x46, 0x69, 0x6e, 0x64, 0x20, 0x6f, 0x75, 0x74, 0x20, 0x6d, 0x6f, 0x72, 0x65, 0x20, 0x61, 0x62, 0x6f, 0x75, 0x74, 0x20, 0x45, 0x63, 0x68, 0x6f, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x32, 0x6a, 0x0a, 0x14, 0x63, 0x61, 0x6d, 0x65, 0x6c, 0x43, 0x61, 0x73, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x52, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x12, 0x11, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x32, 0x5e, 0x0a, 0x1c, 0x41, 0x6e, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x57, 0x69, 0x74, 0x68, 0x4e, 0x6f, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x3e, 0x0a, 0x0a, 0x4e, 0x6f, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x32, 0xd5, 0x01, 0x0a, 0x10, 0x53, 0x6e, 0x61, 0x6b, 0x65, 0x45, 0x6e, 0x75, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xc0, 0x01, 0x0a, 0x09, 0x53, 0x6e, 0x61, 0x6b, 0x65, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x53, 0x6e, 0x61, 0x6b, 0x65, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x41, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x53, 0x6e, 0x61, 0x6b, 0x65, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x28, 0x12, 0x26, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x73, 0x6e, 0x61, 0x6b, 0x65, 0x2f, 0x7b, 0x77, 0x68, 0x6f, 0x7d, 0x2f, 0x7b, 0x77, 0x68, 0x61, 0x74, 0x7d, 0x2f, 0x7b, 0x77, 0x68, 0x65, 0x72, 0x65, 0x7d, 0x42, 0xcf, 0x0c, 0x92, 0x41, 0xfe, 0x0b, 0x12, 0xf0, 0x01, 0x0a, 0x13, 0x41, 0x20, 0x42, 0x69, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x22, 0x58, 0x0a, 0x14, 0x67, 0x52, 0x50, 0x43, 0x2d, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x20, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x1a, 0x10, 0x6e, 0x6f, 0x6e, 0x65, 0x40, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2a, 0x58, 0x0a, 0x14, 0x42, 0x53, 0x44, 0x20, 0x33, 0x2d, 0x43, 0x6c, 0x61, 0x75, 0x73, 0x65, 0x20, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x12, 0x40, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x62, 0x6c, 0x6f, 0x62, 0x2f, 0x6d, 0x61, 0x69, 0x6e, 0x2f, 0x4c, 0x49, 0x43, 0x45, 0x4e, 0x53, 0x45, 0x32, 0x03, 0x31, 0x2e, 0x30, 0x3a, 0x20, 0x0a, 0x15, 0x78, 0x2d, 0x73, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2d, 0x73, 0x6f, 0x6d, 0x65, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x07, 0x1a, 0x05, 0x79, 0x61, 0x64, 0x64, 0x61, 0x2a, 0x03, 0x01, 0x02, 0x04, 0x32, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6a, 0x73, 0x6f, 0x6e, 0x32, 0x16, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78, 0x2d, 0x66, 0x6f, 0x6f, 0x2d, 0x6d, 0x69, 0x6d, 0x65, 0x3a, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x16, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78, 0x2d, 0x66, 0x6f, 0x6f, 0x2d, 0x6d, 0x69, 0x6d, 0x65, 0x52, 0x50, 0x0a, 0x03, 0x34, 0x30, 0x33, 0x12, 0x49, 0x0a, 0x47, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x20, 0x77, 0x68, 0x65, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x75, 0x73, 0x65, 0x72, 0x20, 0x64, 0x6f, 0x65, 0x73, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x68, 0x61, 0x76, 0x65, 0x20, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x6f, 0x20, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x52, 0x3b, 0x0a, 0x03, 0x34, 0x30, 0x34, 0x12, 0x34, 0x0a, 0x2a, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x20, 0x77, 0x68, 0x65, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x20, 0x64, 0x6f, 0x65, 0x73, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x65, 0x78, 0x69, 0x73, 0x74, 0x2e, 0x12, 0x06, 0x0a, 0x04, 0x9a, 0x02, 0x01, 0x07, 0x52, 0x57, 0x0a, 0x03, 0x34, 0x31, 0x38, 0x12, 0x50, 0x0a, 0x0d, 0x49, 0x27, 0x6d, 0x20, 0x61, 0x20, 0x74, 0x65, 0x61, 0x70, 0x6f, 0x74, 0x2e, 0x12, 0x3f, 0x0a, 0x3d, 0x1a, 0x3b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x9b, 0x02, 0x0a, 0x03, 0x35, 0x30, 0x30, 0x12, 0x93, 0x02, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x41, 0x0a, 0x3f, 0x1a, 0x3d, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0xbf, 0x01, 0x0a, 0x10, 0x58, 0x2d, 0x43, 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2d, 0x49, 0x64, 0x12, 0xaa, 0x01, 0x0a, 0x2b, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x20, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x20, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x12, 0x06, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x1a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x32, 0x26, 0x22, 0x32, 0x34, 0x33, 0x38, 0x61, 0x63, 0x33, 0x63, 0x2d, 0x33, 0x37, 0x65, 0x62, 0x2d, 0x34, 0x39, 0x30, 0x32, 0x2d, 0x61, 0x64, 0x65, 0x66, 0x2d, 0x65, 0x64, 0x31, 0x36, 0x62, 0x34, 0x34, 0x33, 0x31, 0x30, 0x33, 0x30, 0x22, 0x6a, 0x45, 0x5e, 0x5b, 0x30, 0x2d, 0x39, 0x41, 0x2d, 0x46, 0x5d, 0x7b, 0x38, 0x7d, 0x2d, 0x5b, 0x30, 0x2d, 0x39, 0x41, 0x2d, 0x46, 0x5d, 0x7b, 0x34, 0x7d, 0x2d, 0x34, 0x5b, 0x30, 0x2d, 0x39, 0x41, 0x2d, 0x46, 0x5d, 0x7b, 0x33, 0x7d, 0x2d, 0x5b, 0x38, 0x39, 0x41, 0x42, 0x5d, 0x5b, 0x30, 0x2d, 0x39, 0x41, 0x2d, 0x46, 0x5d, 0x7b, 0x33, 0x7d, 0x2d, 0x5b, 0x30, 0x2d, 0x39, 0x41, 0x2d, 0x46, 0x5d, 0x7b, 0x31, 0x32, 0x7d, 0x24, 0x5a, 0x97, 0x03, 0x0a, 0xaa, 0x01, 0x0a, 0x0a, 0x41, 0x70, 0x69, 0x4b, 0x65, 0x79, 0x41, 0x75, 0x74, 0x68, 0x12, 0x9b, 0x01, 0x08, 0x02, 0x1a, 0x09, 0x58, 0x2d, 0x41, 0x50, 0x49, 0x2d, 0x4b, 0x65, 0x79, 0x20, 0x02, 0x4a, 0x60, 0x0a, 0x1e, 0x78, 0x2d, 0x61, 0x6d, 0x61, 0x7a, 0x6f, 0x6e, 0x2d, 0x61, 0x70, 0x69, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2d, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x72, 0x12, 0x3e, 0x2a, 0x3c, 0x0a, 0x29, 0x0a, 0x1c, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x72, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x54, 0x74, 0x6c, 0x49, 0x6e, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x12, 0x09, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4e, 0x40, 0x0a, 0x0f, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x07, 0x1a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x4a, 0x28, 0x0a, 0x1c, 0x78, 0x2d, 0x61, 0x6d, 0x61, 0x7a, 0x6f, 0x6e, 0x2d, 0x61, 0x70, 0x69, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2d, 0x61, 0x75, 0x74, 0x68, 0x74, 0x79, 0x70, 0x65, 0x12, 0x08, 0x1a, 0x06, 0x6f, 0x61, 0x75, 0x74, 0x68, 0x32, 0x0a, 0x0f, 0x0a, 0x09, 0x42, 0x61, 0x73, 0x69, 0x63, 0x41, 0x75, 0x74, 0x68, 0x12, 0x02, 0x08, 0x01, 0x0a, 0xd6, 0x01, 0x0a, 0x06, 0x4f, 0x41, 0x75, 0x74, 0x68, 0x32, 0x12, 0xcb, 0x01, 0x08, 0x03, 0x28, 0x04, 0x32, 0x23, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x3a, 0x1f, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x42, 0x7f, 0x0a, 0x43, 0x0a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x3a, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x73, 0x20, 0x72, 0x65, 0x61, 0x64, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x77, 0x72, 0x69, 0x74, 0x65, 0x20, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x76, 0x65, 0x20, 0x69, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x1a, 0x0a, 0x04, 0x72, 0x65, 0x61, 0x64, 0x12, 0x12, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x73, 0x20, 0x72, 0x65, 0x61, 0x64, 0x20, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x0a, 0x1c, 0x0a, 0x05, 0x77, 0x72, 0x69, 0x74, 0x65, 0x12, 0x13, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x73, 0x20, 0x77, 0x72, 0x69, 0x74, 0x65, 0x20, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x62, 0x1f, 0x0a, 0x0e, 0x0a, 0x0a, 0x41, 0x70, 0x69, 0x4b, 0x65, 0x79, 0x41, 0x75, 0x74, 0x68, 0x12, 0x00, 0x0a, 0x0d, 0x0a, 0x09, 0x42, 0x61, 0x73, 0x69, 0x63, 0x41, 0x75, 0x74, 0x68, 0x12, 0x00, 0x62, 0x29, 0x0a, 0x0e, 0x0a, 0x0a, 0x41, 0x70, 0x69, 0x4b, 0x65, 0x79, 0x41, 0x75, 0x74, 0x68, 0x12, 0x00, 0x0a, 0x17, 0x0a, 0x06, 0x4f, 0x41, 0x75, 0x74, 0x68, 0x32, 0x12, 0x0d, 0x0a, 0x04, 0x72, 0x65, 0x61, 0x64, 0x0a, 0x05, 0x77, 0x72, 0x69, 0x74, 0x65, 0x6a, 0x32, 0x0a, 0x08, 0x65, 0x63, 0x68, 0x6f, 0x20, 0x72, 0x70, 0x63, 0x12, 0x14, 0x45, 0x63, 0x68, 0x6f, 0x20, 0x52, 0x70, 0x63, 0x20, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x10, 0x0a, 0x0a, 0x78, 0x2d, 0x74, 0x72, 0x61, 0x69, 0x74, 0x54, 0x61, 0x67, 0x12, 0x02, 0x20, 0x01, 0x72, 0x49, 0x0a, 0x17, 0x4d, 0x6f, 0x72, 0x65, 0x20, 0x61, 0x62, 0x6f, 0x75, 0x74, 0x20, 0x67, 0x52, 0x50, 0x43, 0x2d, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x12, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x7a, 0x28, 0x0a, 0x17, 0x78, 0x2d, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2d, 0x62, 0x61, 0x7a, 0x2d, 0x6c, 0x69, 0x73, 0x74, 0x12, 0x0d, 0x32, 0x0b, 0x0a, 0x05, 0x1a, 0x03, 0x6f, 0x6e, 0x65, 0x0a, 0x02, 0x20, 0x01, 0x7a, 0x1b, 0x0a, 0x12, 0x78, 0x2d, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2d, 0x66, 0x6f, 0x6f, 0x12, 0x05, 0x1a, 0x03, 0x62, 0x61, 0x72, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescOnce sync.Once file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescData = file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDesc ) func file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescGZIP() []byte { file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescOnce.Do(func() { file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescData) }) return file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDescData } var file_examples_internal_proto_examplepb_a_bit_of_everything_proto_enumTypes = make([]protoimpl.EnumInfo, 4) var file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes = make([]protoimpl.MessageInfo, 20) var file_examples_internal_proto_examplepb_a_bit_of_everything_proto_goTypes = []any{ (NumericEnum)(0), // 0: grpc.gateway.examples.internal.proto.examplepb.NumericEnum (SnakeCaseEnum)(0), // 1: grpc.gateway.examples.internal.proto.examplepb.snake_case_enum (SnakeCase_0Enum)(0), // 2: grpc.gateway.examples.internal.proto.examplepb.snake_case_0_enum (ABitOfEverything_Nested_DeepEnum)(0), // 3: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.Nested.DeepEnum (*ErrorResponse)(nil), // 4: grpc.gateway.examples.internal.proto.examplepb.ErrorResponse (*ErrorObject)(nil), // 5: grpc.gateway.examples.internal.proto.examplepb.ErrorObject (*ABitOfEverything)(nil), // 6: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything (*ABitOfEverythingRepeated)(nil), // 7: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingRepeated (*CheckStatusResponse)(nil), // 8: grpc.gateway.examples.internal.proto.examplepb.CheckStatusResponse (*Body)(nil), // 9: grpc.gateway.examples.internal.proto.examplepb.Body (*MessageWithBody)(nil), // 10: grpc.gateway.examples.internal.proto.examplepb.MessageWithBody (*UpdateV2Request)(nil), // 11: grpc.gateway.examples.internal.proto.examplepb.UpdateV2Request (*Book)(nil), // 12: grpc.gateway.examples.internal.proto.examplepb.Book (*CreateBookRequest)(nil), // 13: grpc.gateway.examples.internal.proto.examplepb.CreateBookRequest (*UpdateBookRequest)(nil), // 14: grpc.gateway.examples.internal.proto.examplepb.UpdateBookRequest (*SnakeEnumRequest)(nil), // 15: grpc.gateway.examples.internal.proto.examplepb.SnakeEnumRequest (*SnakeEnumResponse)(nil), // 16: grpc.gateway.examples.internal.proto.examplepb.SnakeEnumResponse (*RequiredMessageTypeRequest)(nil), // 17: grpc.gateway.examples.internal.proto.examplepb.RequiredMessageTypeRequest (*Foo)(nil), // 18: grpc.gateway.examples.internal.proto.examplepb.Foo (*Bar)(nil), // 19: grpc.gateway.examples.internal.proto.examplepb.Bar (*ABitOfEverything_Nested)(nil), // 20: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.Nested nil, // 21: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.MapValueEntry nil, // 22: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.MappedStringValueEntry nil, // 23: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.MappedNestedValueEntry (pathenum.PathEnum)(0), // 24: grpc.gateway.examples.internal.pathenum.PathEnum (pathenum.MessagePathEnum_NestedPathEnum)(0), // 25: grpc.gateway.examples.internal.pathenum.MessagePathEnum.NestedPathEnum (*emptypb.Empty)(nil), // 26: google.protobuf.Empty (*timestamppb.Timestamp)(nil), // 27: google.protobuf.Timestamp (*status.Status)(nil), // 28: google.rpc.Status (*fieldmaskpb.FieldMask)(nil), // 29: google.protobuf.FieldMask (pathenum.SnakeCaseForImport)(0), // 30: grpc.gateway.examples.internal.pathenum.snake_case_for_import (*sub2.IdMessage)(nil), // 31: grpc.gateway.examples.internal.proto.sub2.IdMessage (*sub.StringMessage)(nil), // 32: grpc.gateway.examples.internal.proto.sub.StringMessage (*durationpb.Duration)(nil), // 33: google.protobuf.Duration (*pathenum.MessageWithPathEnum)(nil), // 34: grpc.gateway.examples.internal.pathenum.MessageWithPathEnum (*pathenum.MessageWithNestedPathEnum)(nil), // 35: grpc.gateway.examples.internal.pathenum.MessageWithNestedPathEnum (*oneofenum.OneofEnumMessage)(nil), // 36: grpc.gateway.examples.internal.proto.oneofenum.OneofEnumMessage (*wrapperspb.StringValue)(nil), // 37: google.protobuf.StringValue } var file_examples_internal_proto_examplepb_a_bit_of_everything_proto_depIdxs = []int32{ 5, // 0: grpc.gateway.examples.internal.proto.examplepb.ErrorResponse.error:type_name -> grpc.gateway.examples.internal.proto.examplepb.ErrorObject 20, // 1: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.single_nested:type_name -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.Nested 20, // 2: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.nested:type_name -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.Nested 0, // 3: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.enum_value:type_name -> grpc.gateway.examples.internal.proto.examplepb.NumericEnum 24, // 4: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.path_enum_value:type_name -> grpc.gateway.examples.internal.pathenum.PathEnum 25, // 5: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.nested_path_enum_value:type_name -> grpc.gateway.examples.internal.pathenum.MessagePathEnum.NestedPathEnum 26, // 6: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.oneof_empty:type_name -> google.protobuf.Empty 21, // 7: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.map_value:type_name -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.MapValueEntry 22, // 8: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.mapped_string_value:type_name -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.MappedStringValueEntry 23, // 9: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.mapped_nested_value:type_name -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.MappedNestedValueEntry 27, // 10: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.timestamp_value:type_name -> google.protobuf.Timestamp 0, // 11: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.repeated_enum_value:type_name -> grpc.gateway.examples.internal.proto.examplepb.NumericEnum 0, // 12: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.repeated_enum_annotation:type_name -> grpc.gateway.examples.internal.proto.examplepb.NumericEnum 0, // 13: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.enum_value_annotation:type_name -> grpc.gateway.examples.internal.proto.examplepb.NumericEnum 20, // 14: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.repeated_nested_annotation:type_name -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.Nested 20, // 15: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.nested_annotation:type_name -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.Nested 0, // 16: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingRepeated.path_repeated_enum_value:type_name -> grpc.gateway.examples.internal.proto.examplepb.NumericEnum 28, // 17: grpc.gateway.examples.internal.proto.examplepb.CheckStatusResponse.status:type_name -> google.rpc.Status 9, // 18: grpc.gateway.examples.internal.proto.examplepb.MessageWithBody.data:type_name -> grpc.gateway.examples.internal.proto.examplepb.Body 6, // 19: grpc.gateway.examples.internal.proto.examplepb.UpdateV2Request.abe:type_name -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 29, // 20: grpc.gateway.examples.internal.proto.examplepb.UpdateV2Request.update_mask:type_name -> google.protobuf.FieldMask 27, // 21: grpc.gateway.examples.internal.proto.examplepb.Book.create_time:type_name -> google.protobuf.Timestamp 12, // 22: grpc.gateway.examples.internal.proto.examplepb.CreateBookRequest.book:type_name -> grpc.gateway.examples.internal.proto.examplepb.Book 12, // 23: grpc.gateway.examples.internal.proto.examplepb.UpdateBookRequest.book:type_name -> grpc.gateway.examples.internal.proto.examplepb.Book 29, // 24: grpc.gateway.examples.internal.proto.examplepb.UpdateBookRequest.update_mask:type_name -> google.protobuf.FieldMask 1, // 25: grpc.gateway.examples.internal.proto.examplepb.SnakeEnumRequest.what:type_name -> grpc.gateway.examples.internal.proto.examplepb.snake_case_enum 2, // 26: grpc.gateway.examples.internal.proto.examplepb.SnakeEnumRequest.who:type_name -> grpc.gateway.examples.internal.proto.examplepb.snake_case_0_enum 30, // 27: grpc.gateway.examples.internal.proto.examplepb.SnakeEnumRequest.where:type_name -> grpc.gateway.examples.internal.pathenum.snake_case_for_import 18, // 28: grpc.gateway.examples.internal.proto.examplepb.RequiredMessageTypeRequest.foo:type_name -> grpc.gateway.examples.internal.proto.examplepb.Foo 19, // 29: grpc.gateway.examples.internal.proto.examplepb.Foo.bar:type_name -> grpc.gateway.examples.internal.proto.examplepb.Bar 3, // 30: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.Nested.ok:type_name -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.Nested.DeepEnum 0, // 31: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.MapValueEntry.value:type_name -> grpc.gateway.examples.internal.proto.examplepb.NumericEnum 20, // 32: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.MappedNestedValueEntry.value:type_name -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything.Nested 6, // 33: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.Create:input_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 6, // 34: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.CreateBody:input_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 13, // 35: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.CreateBook:input_type -> grpc.gateway.examples.internal.proto.examplepb.CreateBookRequest 14, // 36: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.UpdateBook:input_type -> grpc.gateway.examples.internal.proto.examplepb.UpdateBookRequest 31, // 37: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.Lookup:input_type -> grpc.gateway.examples.internal.proto.sub2.IdMessage 6, // 38: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.Custom:input_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 6, // 39: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.DoubleColon:input_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 6, // 40: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.Update:input_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 11, // 41: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.UpdateV2:input_type -> grpc.gateway.examples.internal.proto.examplepb.UpdateV2Request 31, // 42: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.Delete:input_type -> grpc.gateway.examples.internal.proto.sub2.IdMessage 6, // 43: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.GetQuery:input_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 7, // 44: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.GetRepeatedQuery:input_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingRepeated 32, // 45: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.Echo:input_type -> grpc.gateway.examples.internal.proto.sub.StringMessage 6, // 46: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.DeepPathEcho:input_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 33, // 47: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.NoBindings:input_type -> google.protobuf.Duration 26, // 48: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.Timeout:input_type -> google.protobuf.Empty 26, // 49: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.ErrorWithDetails:input_type -> google.protobuf.Empty 10, // 50: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.GetMessageWithBody:input_type -> grpc.gateway.examples.internal.proto.examplepb.MessageWithBody 9, // 51: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.PostWithEmptyBody:input_type -> grpc.gateway.examples.internal.proto.examplepb.Body 6, // 52: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.CheckGetQueryParams:input_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 6, // 53: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.CheckNestedEnumGetQueryParams:input_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 6, // 54: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.CheckPostQueryParams:input_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 9, // 55: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.OverwriteRequestContentType:input_type -> grpc.gateway.examples.internal.proto.examplepb.Body 26, // 56: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.OverwriteResponseContentType:input_type -> google.protobuf.Empty 34, // 57: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.CheckExternalPathEnum:input_type -> grpc.gateway.examples.internal.pathenum.MessageWithPathEnum 35, // 58: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.CheckExternalNestedPathEnum:input_type -> grpc.gateway.examples.internal.pathenum.MessageWithNestedPathEnum 26, // 59: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.CheckStatus:input_type -> google.protobuf.Empty 6, // 60: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.Exists:input_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 6, // 61: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.CustomOptionsRequest:input_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 6, // 62: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.TraceRequest:input_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 36, // 63: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.PostOneofEnum:input_type -> grpc.gateway.examples.internal.proto.oneofenum.OneofEnumMessage 17, // 64: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.PostRequiredMessageType:input_type -> grpc.gateway.examples.internal.proto.examplepb.RequiredMessageTypeRequest 26, // 65: grpc.gateway.examples.internal.proto.examplepb.camelCaseServiceName.Empty:input_type -> google.protobuf.Empty 26, // 66: grpc.gateway.examples.internal.proto.examplepb.AnotherServiceWithNoBindings.NoBindings:input_type -> google.protobuf.Empty 15, // 67: grpc.gateway.examples.internal.proto.examplepb.SnakeEnumService.SnakeEnum:input_type -> grpc.gateway.examples.internal.proto.examplepb.SnakeEnumRequest 6, // 68: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.Create:output_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 6, // 69: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.CreateBody:output_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 12, // 70: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.CreateBook:output_type -> grpc.gateway.examples.internal.proto.examplepb.Book 12, // 71: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.UpdateBook:output_type -> grpc.gateway.examples.internal.proto.examplepb.Book 6, // 72: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.Lookup:output_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 6, // 73: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.Custom:output_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 6, // 74: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.DoubleColon:output_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 26, // 75: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.Update:output_type -> google.protobuf.Empty 26, // 76: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.UpdateV2:output_type -> google.protobuf.Empty 26, // 77: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.Delete:output_type -> google.protobuf.Empty 26, // 78: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.GetQuery:output_type -> google.protobuf.Empty 7, // 79: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.GetRepeatedQuery:output_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingRepeated 32, // 80: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.Echo:output_type -> grpc.gateway.examples.internal.proto.sub.StringMessage 6, // 81: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.DeepPathEcho:output_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 26, // 82: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.NoBindings:output_type -> google.protobuf.Empty 26, // 83: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.Timeout:output_type -> google.protobuf.Empty 26, // 84: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.ErrorWithDetails:output_type -> google.protobuf.Empty 26, // 85: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.GetMessageWithBody:output_type -> google.protobuf.Empty 26, // 86: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.PostWithEmptyBody:output_type -> google.protobuf.Empty 6, // 87: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.CheckGetQueryParams:output_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 6, // 88: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.CheckNestedEnumGetQueryParams:output_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 6, // 89: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.CheckPostQueryParams:output_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 26, // 90: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.OverwriteRequestContentType:output_type -> google.protobuf.Empty 37, // 91: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.OverwriteResponseContentType:output_type -> google.protobuf.StringValue 26, // 92: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.CheckExternalPathEnum:output_type -> google.protobuf.Empty 26, // 93: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.CheckExternalNestedPathEnum:output_type -> google.protobuf.Empty 8, // 94: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.CheckStatus:output_type -> grpc.gateway.examples.internal.proto.examplepb.CheckStatusResponse 26, // 95: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.Exists:output_type -> google.protobuf.Empty 26, // 96: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.CustomOptionsRequest:output_type -> google.protobuf.Empty 6, // 97: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.TraceRequest:output_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 26, // 98: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.PostOneofEnum:output_type -> google.protobuf.Empty 26, // 99: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService.PostRequiredMessageType:output_type -> google.protobuf.Empty 26, // 100: grpc.gateway.examples.internal.proto.examplepb.camelCaseServiceName.Empty:output_type -> google.protobuf.Empty 26, // 101: grpc.gateway.examples.internal.proto.examplepb.AnotherServiceWithNoBindings.NoBindings:output_type -> google.protobuf.Empty 16, // 102: grpc.gateway.examples.internal.proto.examplepb.SnakeEnumService.SnakeEnum:output_type -> grpc.gateway.examples.internal.proto.examplepb.SnakeEnumResponse 68, // [68:103] is the sub-list for method output_type 33, // [33:68] is the sub-list for method input_type 33, // [33:33] is the sub-list for extension type_name 33, // [33:33] is the sub-list for extension extendee 0, // [0:33] is the sub-list for field type_name } func init() { file_examples_internal_proto_examplepb_a_bit_of_everything_proto_init() } func file_examples_internal_proto_examplepb_a_bit_of_everything_proto_init() { if File_examples_internal_proto_examplepb_a_bit_of_everything_proto != nil { return } file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes[2].OneofWrappers = []any{ (*ABitOfEverything_OneofEmpty)(nil), (*ABitOfEverything_OneofString)(nil), } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDesc, NumEnums: 4, NumMessages: 20, NumExtensions: 0, NumServices: 4, }, GoTypes: file_examples_internal_proto_examplepb_a_bit_of_everything_proto_goTypes, DependencyIndexes: file_examples_internal_proto_examplepb_a_bit_of_everything_proto_depIdxs, EnumInfos: file_examples_internal_proto_examplepb_a_bit_of_everything_proto_enumTypes, MessageInfos: file_examples_internal_proto_examplepb_a_bit_of_everything_proto_msgTypes, }.Build() File_examples_internal_proto_examplepb_a_bit_of_everything_proto = out.File file_examples_internal_proto_examplepb_a_bit_of_everything_proto_rawDesc = nil file_examples_internal_proto_examplepb_a_bit_of_everything_proto_goTypes = nil file_examples_internal_proto_examplepb_a_bit_of_everything_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/examplepb/a_bit_of_everything.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/proto/examplepb/a_bit_of_everything.proto /* Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package examplepb import ( "context" "errors" "io" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/oneofenum" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/pathenum" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub2" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/emptypb" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) var filter_ABitOfEverythingService_Create_0 = &utilities.DoubleArray{Encoding: map[string]int{"float_value": 0, "double_value": 1, "int64_value": 2, "uint64_value": 3, "int32_value": 4, "fixed64_value": 5, "fixed32_value": 6, "bool_value": 7, "string_value": 8, "uint32_value": 9, "sfixed32_value": 10, "sfixed64_value": 11, "sint32_value": 12, "sint64_value": 13, "nonConventionalNameValue": 14, "enum_value": 15, "path_enum_value": 16, "nested_path_enum_value": 17, "enum_value_annotation": 18}, Base: []int{1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, Check: []int{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}} func request_ABitOfEverythingService_Create_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata e int32 err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["float_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "float_value") } protoReq.FloatValue, err = runtime.Float32(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "float_value", err) } val, ok = pathParams["double_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "double_value") } protoReq.DoubleValue, err = runtime.Float64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "double_value", err) } val, ok = pathParams["int64_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "int64_value") } protoReq.Int64Value, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "int64_value", err) } val, ok = pathParams["uint64_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uint64_value") } protoReq.Uint64Value, err = runtime.Uint64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uint64_value", err) } val, ok = pathParams["int32_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "int32_value") } protoReq.Int32Value, err = runtime.Int32(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "int32_value", err) } val, ok = pathParams["fixed64_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "fixed64_value") } protoReq.Fixed64Value, err = runtime.Uint64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "fixed64_value", err) } val, ok = pathParams["fixed32_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "fixed32_value") } protoReq.Fixed32Value, err = runtime.Uint32(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "fixed32_value", err) } val, ok = pathParams["bool_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "bool_value") } protoReq.BoolValue, err = runtime.Bool(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "bool_value", err) } val, ok = pathParams["string_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "string_value") } protoReq.StringValue, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "string_value", err) } val, ok = pathParams["uint32_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uint32_value") } protoReq.Uint32Value, err = runtime.Uint32(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uint32_value", err) } val, ok = pathParams["sfixed32_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sfixed32_value") } protoReq.Sfixed32Value, err = runtime.Int32(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sfixed32_value", err) } val, ok = pathParams["sfixed64_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sfixed64_value") } protoReq.Sfixed64Value, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sfixed64_value", err) } val, ok = pathParams["sint32_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sint32_value") } protoReq.Sint32Value, err = runtime.Int32(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sint32_value", err) } val, ok = pathParams["sint64_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sint64_value") } protoReq.Sint64Value, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sint64_value", err) } val, ok = pathParams["nonConventionalNameValue"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "nonConventionalNameValue") } protoReq.NonConventionalNameValue, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "nonConventionalNameValue", err) } val, ok = pathParams["enum_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "enum_value") } e, err = runtime.Enum(val, NumericEnum_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "enum_value", err) } protoReq.EnumValue = NumericEnum(e) val, ok = pathParams["path_enum_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_enum_value") } e, err = runtime.Enum(val, pathenum.PathEnum_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_enum_value", err) } protoReq.PathEnumValue = pathenum.PathEnum(e) val, ok = pathParams["nested_path_enum_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "nested_path_enum_value") } e, err = runtime.Enum(val, pathenum.MessagePathEnum_NestedPathEnum_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "nested_path_enum_value", err) } protoReq.NestedPathEnumValue = pathenum.MessagePathEnum_NestedPathEnum(e) val, ok = pathParams["enum_value_annotation"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "enum_value_annotation") } e, err = runtime.Enum(val, NumericEnum_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "enum_value_annotation", err) } protoReq.EnumValueAnnotation = NumericEnum(e) if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_Create_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Create(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_Create_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata e int32 err error ) val, ok := pathParams["float_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "float_value") } protoReq.FloatValue, err = runtime.Float32(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "float_value", err) } val, ok = pathParams["double_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "double_value") } protoReq.DoubleValue, err = runtime.Float64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "double_value", err) } val, ok = pathParams["int64_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "int64_value") } protoReq.Int64Value, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "int64_value", err) } val, ok = pathParams["uint64_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uint64_value") } protoReq.Uint64Value, err = runtime.Uint64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uint64_value", err) } val, ok = pathParams["int32_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "int32_value") } protoReq.Int32Value, err = runtime.Int32(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "int32_value", err) } val, ok = pathParams["fixed64_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "fixed64_value") } protoReq.Fixed64Value, err = runtime.Uint64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "fixed64_value", err) } val, ok = pathParams["fixed32_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "fixed32_value") } protoReq.Fixed32Value, err = runtime.Uint32(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "fixed32_value", err) } val, ok = pathParams["bool_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "bool_value") } protoReq.BoolValue, err = runtime.Bool(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "bool_value", err) } val, ok = pathParams["string_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "string_value") } protoReq.StringValue, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "string_value", err) } val, ok = pathParams["uint32_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uint32_value") } protoReq.Uint32Value, err = runtime.Uint32(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uint32_value", err) } val, ok = pathParams["sfixed32_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sfixed32_value") } protoReq.Sfixed32Value, err = runtime.Int32(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sfixed32_value", err) } val, ok = pathParams["sfixed64_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sfixed64_value") } protoReq.Sfixed64Value, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sfixed64_value", err) } val, ok = pathParams["sint32_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sint32_value") } protoReq.Sint32Value, err = runtime.Int32(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sint32_value", err) } val, ok = pathParams["sint64_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sint64_value") } protoReq.Sint64Value, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sint64_value", err) } val, ok = pathParams["nonConventionalNameValue"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "nonConventionalNameValue") } protoReq.NonConventionalNameValue, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "nonConventionalNameValue", err) } val, ok = pathParams["enum_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "enum_value") } e, err = runtime.Enum(val, NumericEnum_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "enum_value", err) } protoReq.EnumValue = NumericEnum(e) val, ok = pathParams["path_enum_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_enum_value") } e, err = runtime.Enum(val, pathenum.PathEnum_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_enum_value", err) } protoReq.PathEnumValue = pathenum.PathEnum(e) val, ok = pathParams["nested_path_enum_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "nested_path_enum_value") } e, err = runtime.Enum(val, pathenum.MessagePathEnum_NestedPathEnum_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "nested_path_enum_value", err) } protoReq.NestedPathEnumValue = pathenum.MessagePathEnum_NestedPathEnum(e) val, ok = pathParams["enum_value_annotation"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "enum_value_annotation") } e, err = runtime.Enum(val, NumericEnum_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "enum_value_annotation", err) } protoReq.EnumValueAnnotation = NumericEnum(e) if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_Create_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Create(ctx, &protoReq) return msg, metadata, err } func request_ABitOfEverythingService_CreateBody_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.CreateBody(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_CreateBody_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CreateBody(ctx, &protoReq) return msg, metadata, err } var filter_ABitOfEverythingService_CreateBook_0 = &utilities.DoubleArray{Encoding: map[string]int{"book": 0, "parent": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} func request_ABitOfEverythingService_CreateBook_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq CreateBookRequest metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Book); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["parent"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") } protoReq.Parent, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_CreateBook_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.CreateBook(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_CreateBook_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq CreateBookRequest metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Book); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["parent"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") } protoReq.Parent, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_CreateBook_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CreateBook(ctx, &protoReq) return msg, metadata, err } var filter_ABitOfEverythingService_UpdateBook_0 = &utilities.DoubleArray{Encoding: map[string]int{"book": 0, "name": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} func request_ABitOfEverythingService_UpdateBook_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UpdateBookRequest metadata runtime.ServerMetadata err error ) newReader, berr := utilities.IOReaderFactory(req.Body) if berr != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) } if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Book); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Book); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } else { protoReq.UpdateMask = fieldMask } } val, ok := pathParams["book.name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "book.name") } err = runtime.PopulateFieldFromPath(&protoReq, "book.name", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "book.name", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_UpdateBook_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.UpdateBook(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_UpdateBook_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UpdateBookRequest metadata runtime.ServerMetadata err error ) newReader, berr := utilities.IOReaderFactory(req.Body) if berr != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) } if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Book); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Book); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } else { protoReq.UpdateMask = fieldMask } } val, ok := pathParams["book.name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "book.name") } err = runtime.PopulateFieldFromPath(&protoReq, "book.name", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "book.name", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_UpdateBook_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.UpdateBook(ctx, &protoReq) return msg, metadata, err } func request_ABitOfEverythingService_Lookup_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq sub2.IdMessage metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uuid") } protoReq.Uuid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uuid", err) } msg, err := client.Lookup(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_Lookup_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq sub2.IdMessage metadata runtime.ServerMetadata err error ) val, ok := pathParams["uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uuid") } protoReq.Uuid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uuid", err) } msg, err := server.Lookup(ctx, &protoReq) return msg, metadata, err } var filter_ABitOfEverythingService_Custom_0 = &utilities.DoubleArray{Encoding: map[string]int{"uuid": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_ABitOfEverythingService_Custom_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uuid") } protoReq.Uuid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uuid", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_Custom_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Custom(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_Custom_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) val, ok := pathParams["uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uuid") } protoReq.Uuid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uuid", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_Custom_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Custom(ctx, &protoReq) return msg, metadata, err } var filter_ABitOfEverythingService_Custom_1 = &utilities.DoubleArray{Encoding: map[string]int{"optional_string_value": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_ABitOfEverythingService_Custom_1(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["optional_string_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "optional_string_value") } protoReq.OptionalStringValue, err = runtime.StringP(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "optional_string_value", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_Custom_1); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Custom(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_Custom_1(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) val, ok := pathParams["optional_string_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "optional_string_value") } protoReq.OptionalStringValue, err = runtime.StringP(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "optional_string_value", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_Custom_1); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Custom(ctx, &protoReq) return msg, metadata, err } var filter_ABitOfEverythingService_DoubleColon_0 = &utilities.DoubleArray{Encoding: map[string]int{"uuid": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_ABitOfEverythingService_DoubleColon_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uuid") } protoReq.Uuid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uuid", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_DoubleColon_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.DoubleColon(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_DoubleColon_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) val, ok := pathParams["uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uuid") } protoReq.Uuid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uuid", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_DoubleColon_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.DoubleColon(ctx, &protoReq) return msg, metadata, err } func request_ABitOfEverythingService_Update_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uuid") } protoReq.Uuid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uuid", err) } msg, err := client.Update(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_Update_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uuid") } protoReq.Uuid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uuid", err) } msg, err := server.Update(ctx, &protoReq) return msg, metadata, err } var filter_ABitOfEverythingService_UpdateV2_0 = &utilities.DoubleArray{Encoding: map[string]int{"abe": 0, "uuid": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} func request_ABitOfEverythingService_UpdateV2_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UpdateV2Request metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Abe); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["abe.uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "abe.uuid") } err = runtime.PopulateFieldFromPath(&protoReq, "abe.uuid", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "abe.uuid", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_UpdateV2_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.UpdateV2(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_UpdateV2_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UpdateV2Request metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Abe); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["abe.uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "abe.uuid") } err = runtime.PopulateFieldFromPath(&protoReq, "abe.uuid", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "abe.uuid", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_UpdateV2_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.UpdateV2(ctx, &protoReq) return msg, metadata, err } var filter_ABitOfEverythingService_UpdateV2_1 = &utilities.DoubleArray{Encoding: map[string]int{"abe": 0, "uuid": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} func request_ABitOfEverythingService_UpdateV2_1(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UpdateV2Request metadata runtime.ServerMetadata err error ) newReader, berr := utilities.IOReaderFactory(req.Body) if berr != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) } if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Abe); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Abe); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } else { protoReq.UpdateMask = fieldMask } } val, ok := pathParams["abe.uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "abe.uuid") } err = runtime.PopulateFieldFromPath(&protoReq, "abe.uuid", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "abe.uuid", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_UpdateV2_1); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.UpdateV2(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_UpdateV2_1(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UpdateV2Request metadata runtime.ServerMetadata err error ) newReader, berr := utilities.IOReaderFactory(req.Body) if berr != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) } if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Abe); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Abe); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } else { protoReq.UpdateMask = fieldMask } } val, ok := pathParams["abe.uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "abe.uuid") } err = runtime.PopulateFieldFromPath(&protoReq, "abe.uuid", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "abe.uuid", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_UpdateV2_1); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.UpdateV2(ctx, &protoReq) return msg, metadata, err } func request_ABitOfEverythingService_UpdateV2_2(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UpdateV2Request metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["abe.uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "abe.uuid") } err = runtime.PopulateFieldFromPath(&protoReq, "abe.uuid", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "abe.uuid", err) } msg, err := client.UpdateV2(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_UpdateV2_2(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UpdateV2Request metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["abe.uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "abe.uuid") } err = runtime.PopulateFieldFromPath(&protoReq, "abe.uuid", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "abe.uuid", err) } msg, err := server.UpdateV2(ctx, &protoReq) return msg, metadata, err } func request_ABitOfEverythingService_Delete_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq sub2.IdMessage metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uuid") } protoReq.Uuid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uuid", err) } msg, err := client.Delete(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_Delete_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq sub2.IdMessage metadata runtime.ServerMetadata err error ) val, ok := pathParams["uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uuid") } protoReq.Uuid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uuid", err) } msg, err := server.Delete(ctx, &protoReq) return msg, metadata, err } var filter_ABitOfEverythingService_GetQuery_0 = &utilities.DoubleArray{Encoding: map[string]int{"uuid": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_ABitOfEverythingService_GetQuery_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uuid") } protoReq.Uuid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uuid", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_GetQuery_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.GetQuery(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_GetQuery_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) val, ok := pathParams["uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uuid") } protoReq.Uuid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uuid", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_GetQuery_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.GetQuery(ctx, &protoReq) return msg, metadata, err } func request_ABitOfEverythingService_GetRepeatedQuery_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverythingRepeated metadata runtime.ServerMetadata es []int32 err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["path_repeated_float_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_float_value") } protoReq.PathRepeatedFloatValue, err = runtime.Float32Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_float_value", err) } val, ok = pathParams["path_repeated_double_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_double_value") } protoReq.PathRepeatedDoubleValue, err = runtime.Float64Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_double_value", err) } val, ok = pathParams["path_repeated_int64_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_int64_value") } protoReq.PathRepeatedInt64Value, err = runtime.Int64Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_int64_value", err) } val, ok = pathParams["path_repeated_uint64_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_uint64_value") } protoReq.PathRepeatedUint64Value, err = runtime.Uint64Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_uint64_value", err) } val, ok = pathParams["path_repeated_int32_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_int32_value") } protoReq.PathRepeatedInt32Value, err = runtime.Int32Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_int32_value", err) } val, ok = pathParams["path_repeated_fixed64_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_fixed64_value") } protoReq.PathRepeatedFixed64Value, err = runtime.Uint64Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_fixed64_value", err) } val, ok = pathParams["path_repeated_fixed32_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_fixed32_value") } protoReq.PathRepeatedFixed32Value, err = runtime.Uint32Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_fixed32_value", err) } val, ok = pathParams["path_repeated_bool_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_bool_value") } protoReq.PathRepeatedBoolValue, err = runtime.BoolSlice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_bool_value", err) } val, ok = pathParams["path_repeated_string_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_string_value") } protoReq.PathRepeatedStringValue, err = runtime.StringSlice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_string_value", err) } val, ok = pathParams["path_repeated_bytes_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_bytes_value") } protoReq.PathRepeatedBytesValue, err = runtime.BytesSlice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_bytes_value", err) } val, ok = pathParams["path_repeated_uint32_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_uint32_value") } protoReq.PathRepeatedUint32Value, err = runtime.Uint32Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_uint32_value", err) } val, ok = pathParams["path_repeated_enum_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_enum_value") } es, err = runtime.EnumSlice(val, ",", NumericEnum_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_enum_value", err) } s := make([]NumericEnum, len(es)) for i, v := range es { s[i] = NumericEnum(v) } protoReq.PathRepeatedEnumValue = s val, ok = pathParams["path_repeated_sfixed32_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_sfixed32_value") } protoReq.PathRepeatedSfixed32Value, err = runtime.Int32Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_sfixed32_value", err) } val, ok = pathParams["path_repeated_sfixed64_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_sfixed64_value") } protoReq.PathRepeatedSfixed64Value, err = runtime.Int64Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_sfixed64_value", err) } val, ok = pathParams["path_repeated_sint32_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_sint32_value") } protoReq.PathRepeatedSint32Value, err = runtime.Int32Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_sint32_value", err) } val, ok = pathParams["path_repeated_sint64_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_sint64_value") } protoReq.PathRepeatedSint64Value, err = runtime.Int64Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_sint64_value", err) } msg, err := client.GetRepeatedQuery(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_GetRepeatedQuery_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverythingRepeated metadata runtime.ServerMetadata es []int32 err error ) val, ok := pathParams["path_repeated_float_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_float_value") } protoReq.PathRepeatedFloatValue, err = runtime.Float32Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_float_value", err) } val, ok = pathParams["path_repeated_double_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_double_value") } protoReq.PathRepeatedDoubleValue, err = runtime.Float64Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_double_value", err) } val, ok = pathParams["path_repeated_int64_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_int64_value") } protoReq.PathRepeatedInt64Value, err = runtime.Int64Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_int64_value", err) } val, ok = pathParams["path_repeated_uint64_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_uint64_value") } protoReq.PathRepeatedUint64Value, err = runtime.Uint64Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_uint64_value", err) } val, ok = pathParams["path_repeated_int32_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_int32_value") } protoReq.PathRepeatedInt32Value, err = runtime.Int32Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_int32_value", err) } val, ok = pathParams["path_repeated_fixed64_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_fixed64_value") } protoReq.PathRepeatedFixed64Value, err = runtime.Uint64Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_fixed64_value", err) } val, ok = pathParams["path_repeated_fixed32_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_fixed32_value") } protoReq.PathRepeatedFixed32Value, err = runtime.Uint32Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_fixed32_value", err) } val, ok = pathParams["path_repeated_bool_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_bool_value") } protoReq.PathRepeatedBoolValue, err = runtime.BoolSlice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_bool_value", err) } val, ok = pathParams["path_repeated_string_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_string_value") } protoReq.PathRepeatedStringValue, err = runtime.StringSlice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_string_value", err) } val, ok = pathParams["path_repeated_bytes_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_bytes_value") } protoReq.PathRepeatedBytesValue, err = runtime.BytesSlice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_bytes_value", err) } val, ok = pathParams["path_repeated_uint32_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_uint32_value") } protoReq.PathRepeatedUint32Value, err = runtime.Uint32Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_uint32_value", err) } val, ok = pathParams["path_repeated_enum_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_enum_value") } es, err = runtime.EnumSlice(val, ",", NumericEnum_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_enum_value", err) } s := make([]NumericEnum, len(es)) for i, v := range es { s[i] = NumericEnum(v) } protoReq.PathRepeatedEnumValue = s val, ok = pathParams["path_repeated_sfixed32_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_sfixed32_value") } protoReq.PathRepeatedSfixed32Value, err = runtime.Int32Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_sfixed32_value", err) } val, ok = pathParams["path_repeated_sfixed64_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_sfixed64_value") } protoReq.PathRepeatedSfixed64Value, err = runtime.Int64Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_sfixed64_value", err) } val, ok = pathParams["path_repeated_sint32_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_sint32_value") } protoReq.PathRepeatedSint32Value, err = runtime.Int32Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_sint32_value", err) } val, ok = pathParams["path_repeated_sint64_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "path_repeated_sint64_value") } protoReq.PathRepeatedSint64Value, err = runtime.Int64Slice(val, ",") if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "path_repeated_sint64_value", err) } msg, err := server.GetRepeatedQuery(ctx, &protoReq) return msg, metadata, err } func request_ABitOfEverythingService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq sub.StringMessage metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "value") } protoReq.Value, err = runtime.StringP(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "value", err) } msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq sub.StringMessage metadata runtime.ServerMetadata err error ) val, ok := pathParams["value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "value") } protoReq.Value, err = runtime.StringP(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "value", err) } msg, err := server.Echo(ctx, &protoReq) return msg, metadata, err } func request_ABitOfEverythingService_Echo_1(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq sub.StringMessage metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Value); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_Echo_1(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq sub.StringMessage metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Value); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Echo(ctx, &protoReq) return msg, metadata, err } var filter_ABitOfEverythingService_Echo_2 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_ABitOfEverythingService_Echo_2(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq sub.StringMessage metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_Echo_2); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_Echo_2(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq sub.StringMessage metadata runtime.ServerMetadata ) if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_Echo_2); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Echo(ctx, &protoReq) return msg, metadata, err } func request_ABitOfEverythingService_DeepPathEcho_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["single_nested.name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "single_nested.name") } err = runtime.PopulateFieldFromPath(&protoReq, "single_nested.name", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "single_nested.name", err) } msg, err := client.DeepPathEcho(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_DeepPathEcho_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["single_nested.name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "single_nested.name") } err = runtime.PopulateFieldFromPath(&protoReq, "single_nested.name", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "single_nested.name", err) } msg, err := server.DeepPathEcho(ctx, &protoReq) return msg, metadata, err } func request_ABitOfEverythingService_Timeout_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq emptypb.Empty metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.Timeout(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_Timeout_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq emptypb.Empty metadata runtime.ServerMetadata ) msg, err := server.Timeout(ctx, &protoReq) return msg, metadata, err } func request_ABitOfEverythingService_ErrorWithDetails_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq emptypb.Empty metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.ErrorWithDetails(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_ErrorWithDetails_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq emptypb.Empty metadata runtime.ServerMetadata ) msg, err := server.ErrorWithDetails(ctx, &protoReq) return msg, metadata, err } func request_ABitOfEverythingService_GetMessageWithBody_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq MessageWithBody metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } msg, err := client.GetMessageWithBody(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_GetMessageWithBody_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq MessageWithBody metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } msg, err := server.GetMessageWithBody(ctx, &protoReq) return msg, metadata, err } func request_ABitOfEverythingService_PostWithEmptyBody_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq Body metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") } protoReq.Name, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) } msg, err := client.PostWithEmptyBody(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_PostWithEmptyBody_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq Body metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") } protoReq.Name, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) } msg, err := server.PostWithEmptyBody(ctx, &protoReq) return msg, metadata, err } var filter_ABitOfEverythingService_CheckGetQueryParams_0 = &utilities.DoubleArray{Encoding: map[string]int{"single_nested": 0, "name": 1}, Base: []int{1, 1, 1, 0}, Check: []int{0, 1, 2, 3}} func request_ABitOfEverythingService_CheckGetQueryParams_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["single_nested.name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "single_nested.name") } err = runtime.PopulateFieldFromPath(&protoReq, "single_nested.name", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "single_nested.name", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_CheckGetQueryParams_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.CheckGetQueryParams(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_CheckGetQueryParams_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) val, ok := pathParams["single_nested.name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "single_nested.name") } err = runtime.PopulateFieldFromPath(&protoReq, "single_nested.name", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "single_nested.name", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_CheckGetQueryParams_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CheckGetQueryParams(ctx, &protoReq) return msg, metadata, err } var filter_ABitOfEverythingService_CheckNestedEnumGetQueryParams_0 = &utilities.DoubleArray{Encoding: map[string]int{"single_nested": 0, "ok": 1}, Base: []int{1, 1, 1, 0}, Check: []int{0, 1, 2, 3}} func request_ABitOfEverythingService_CheckNestedEnumGetQueryParams_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata e int32 err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["single_nested.ok"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "single_nested.ok") } err = runtime.PopulateFieldFromPath(&protoReq, "single_nested.ok", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "single_nested.ok", err) } e, err = runtime.Enum(val, ABitOfEverything_Nested_DeepEnum_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "could not parse path as enum value, parameter: %s, error: %v", "single_nested.ok", err) } protoReq.SingleNested.Ok = ABitOfEverything_Nested_DeepEnum(e) if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_CheckNestedEnumGetQueryParams_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.CheckNestedEnumGetQueryParams(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_CheckNestedEnumGetQueryParams_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata e int32 err error ) val, ok := pathParams["single_nested.ok"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "single_nested.ok") } err = runtime.PopulateFieldFromPath(&protoReq, "single_nested.ok", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "single_nested.ok", err) } e, err = runtime.Enum(val, ABitOfEverything_Nested_DeepEnum_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "could not parse path as enum value, parameter: %s, error: %v", "single_nested.ok", err) } protoReq.SingleNested.Ok = ABitOfEverything_Nested_DeepEnum(e) if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_CheckNestedEnumGetQueryParams_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CheckNestedEnumGetQueryParams(ctx, &protoReq) return msg, metadata, err } var filter_ABitOfEverythingService_CheckPostQueryParams_0 = &utilities.DoubleArray{Encoding: map[string]int{"single_nested": 0, "string_value": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} func request_ABitOfEverythingService_CheckPostQueryParams_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.SingleNested); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["string_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "string_value") } protoReq.StringValue, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "string_value", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_CheckPostQueryParams_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.CheckPostQueryParams(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_CheckPostQueryParams_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.SingleNested); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["string_value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "string_value") } protoReq.StringValue, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "string_value", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_CheckPostQueryParams_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CheckPostQueryParams(ctx, &protoReq) return msg, metadata, err } func request_ABitOfEverythingService_OverwriteRequestContentType_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq Body metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.OverwriteRequestContentType(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_OverwriteRequestContentType_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq Body metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.OverwriteRequestContentType(ctx, &protoReq) return msg, metadata, err } func request_ABitOfEverythingService_OverwriteResponseContentType_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq emptypb.Empty metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.OverwriteResponseContentType(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_OverwriteResponseContentType_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq emptypb.Empty metadata runtime.ServerMetadata ) msg, err := server.OverwriteResponseContentType(ctx, &protoReq) return msg, metadata, err } func request_ABitOfEverythingService_CheckExternalPathEnum_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq pathenum.MessageWithPathEnum metadata runtime.ServerMetadata e int32 err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "value") } e, err = runtime.Enum(val, pathenum.PathEnum_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "value", err) } protoReq.Value = pathenum.PathEnum(e) msg, err := client.CheckExternalPathEnum(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_CheckExternalPathEnum_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq pathenum.MessageWithPathEnum metadata runtime.ServerMetadata e int32 err error ) val, ok := pathParams["value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "value") } e, err = runtime.Enum(val, pathenum.PathEnum_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "value", err) } protoReq.Value = pathenum.PathEnum(e) msg, err := server.CheckExternalPathEnum(ctx, &protoReq) return msg, metadata, err } func request_ABitOfEverythingService_CheckExternalNestedPathEnum_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq pathenum.MessageWithNestedPathEnum metadata runtime.ServerMetadata e int32 err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "value") } e, err = runtime.Enum(val, pathenum.MessagePathEnum_NestedPathEnum_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "value", err) } protoReq.Value = pathenum.MessagePathEnum_NestedPathEnum(e) msg, err := client.CheckExternalNestedPathEnum(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_CheckExternalNestedPathEnum_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq pathenum.MessageWithNestedPathEnum metadata runtime.ServerMetadata e int32 err error ) val, ok := pathParams["value"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "value") } e, err = runtime.Enum(val, pathenum.MessagePathEnum_NestedPathEnum_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "value", err) } protoReq.Value = pathenum.MessagePathEnum_NestedPathEnum(e) msg, err := server.CheckExternalNestedPathEnum(ctx, &protoReq) return msg, metadata, err } func request_ABitOfEverythingService_CheckStatus_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq emptypb.Empty metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.CheckStatus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_CheckStatus_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq emptypb.Empty metadata runtime.ServerMetadata ) msg, err := server.CheckStatus(ctx, &protoReq) return msg, metadata, err } var filter_ABitOfEverythingService_Exists_0 = &utilities.DoubleArray{Encoding: map[string]int{"uuid": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_ABitOfEverythingService_Exists_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uuid") } protoReq.Uuid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uuid", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_Exists_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Exists(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_Exists_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) val, ok := pathParams["uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uuid") } protoReq.Uuid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uuid", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_Exists_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Exists(ctx, &protoReq) return msg, metadata, err } var filter_ABitOfEverythingService_CustomOptionsRequest_0 = &utilities.DoubleArray{Encoding: map[string]int{"uuid": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_ABitOfEverythingService_CustomOptionsRequest_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uuid") } protoReq.Uuid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uuid", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_CustomOptionsRequest_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.CustomOptionsRequest(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_CustomOptionsRequest_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) val, ok := pathParams["uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uuid") } protoReq.Uuid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uuid", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_CustomOptionsRequest_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CustomOptionsRequest(ctx, &protoReq) return msg, metadata, err } var filter_ABitOfEverythingService_TraceRequest_0 = &utilities.DoubleArray{Encoding: map[string]int{"uuid": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_ABitOfEverythingService_TraceRequest_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uuid") } protoReq.Uuid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uuid", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_TraceRequest_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.TraceRequest(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_TraceRequest_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ABitOfEverything metadata runtime.ServerMetadata err error ) val, ok := pathParams["uuid"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "uuid") } protoReq.Uuid, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "uuid", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ABitOfEverythingService_TraceRequest_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.TraceRequest(ctx, &protoReq) return msg, metadata, err } func request_ABitOfEverythingService_PostOneofEnum_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq oneofenum.OneofEnumMessage metadata runtime.ServerMetadata ) if protoReq.One == nil { protoReq.One = &oneofenum.OneofEnumMessage_ExampleEnum{} } else if _, ok := protoReq.One.(*oneofenum.OneofEnumMessage_ExampleEnum); !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "expect type: *oneofenum.OneofEnumMessage_ExampleEnum, but: %t\n", protoReq.One) } if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.One.(*oneofenum.OneofEnumMessage_ExampleEnum).ExampleEnum); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.PostOneofEnum(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_PostOneofEnum_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq oneofenum.OneofEnumMessage metadata runtime.ServerMetadata ) if protoReq.One == nil { protoReq.One = &oneofenum.OneofEnumMessage_ExampleEnum{} } else if _, ok := protoReq.One.(*oneofenum.OneofEnumMessage_ExampleEnum); !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "expect type: *oneofenum.OneofEnumMessage_ExampleEnum, but: %t\n", protoReq.One) } if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.One.(*oneofenum.OneofEnumMessage_ExampleEnum).ExampleEnum); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.PostOneofEnum(ctx, &protoReq) return msg, metadata, err } func request_ABitOfEverythingService_PostRequiredMessageType_0(ctx context.Context, marshaler runtime.Marshaler, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq RequiredMessageTypeRequest metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.PostRequiredMessageType(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ABitOfEverythingService_PostRequiredMessageType_0(ctx context.Context, marshaler runtime.Marshaler, server ABitOfEverythingServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq RequiredMessageTypeRequest metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.PostRequiredMessageType(ctx, &protoReq) return msg, metadata, err } func request_CamelCaseServiceName_Empty_0(ctx context.Context, marshaler runtime.Marshaler, client CamelCaseServiceNameClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq emptypb.Empty metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.Empty(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_CamelCaseServiceName_Empty_0(ctx context.Context, marshaler runtime.Marshaler, server CamelCaseServiceNameServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq emptypb.Empty metadata runtime.ServerMetadata ) msg, err := server.Empty(ctx, &protoReq) return msg, metadata, err } func request_SnakeEnumService_SnakeEnum_0(ctx context.Context, marshaler runtime.Marshaler, client SnakeEnumServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SnakeEnumRequest metadata runtime.ServerMetadata e int32 err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["who"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "who") } e, err = runtime.Enum(val, SnakeCase_0Enum_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "who", err) } protoReq.Who = SnakeCase_0Enum(e) val, ok = pathParams["what"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "what") } e, err = runtime.Enum(val, SnakeCaseEnum_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "what", err) } protoReq.What = SnakeCaseEnum(e) val, ok = pathParams["where"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "where") } e, err = runtime.Enum(val, pathenum.SnakeCaseForImport_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "where", err) } protoReq.Where = pathenum.SnakeCaseForImport(e) msg, err := client.SnakeEnum(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_SnakeEnumService_SnakeEnum_0(ctx context.Context, marshaler runtime.Marshaler, server SnakeEnumServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SnakeEnumRequest metadata runtime.ServerMetadata e int32 err error ) val, ok := pathParams["who"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "who") } e, err = runtime.Enum(val, SnakeCase_0Enum_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "who", err) } protoReq.Who = SnakeCase_0Enum(e) val, ok = pathParams["what"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "what") } e, err = runtime.Enum(val, SnakeCaseEnum_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "what", err) } protoReq.What = SnakeCaseEnum(e) val, ok = pathParams["where"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "where") } e, err = runtime.Enum(val, pathenum.SnakeCaseForImport_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "where", err) } protoReq.Where = pathenum.SnakeCaseForImport(e) msg, err := server.SnakeEnum(ctx, &protoReq) return msg, metadata, err } // RegisterABitOfEverythingServiceHandlerServer registers the http handlers for service ABitOfEverythingService to "mux". // UnaryRPC :call ABitOfEverythingServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterABitOfEverythingServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterABitOfEverythingServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ABitOfEverythingServiceServer) error { mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_Create_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Create", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/{float_value}/{double_value}/{int64_value}/separator/{uint64_value}/{int32_value}/{fixed64_value}/{fixed32_value}/{bool_value}/{string_value=strprefix/*}/{uint32_value}/{sfixed32_value}/{sfixed64_value}/{sint32_value}/{sint64_value}/{nonConventionalNameValue}/{enum_value}/{path_enum_value}/{nested_path_enum_value}/{enum_value_annotation}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_Create_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Create_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_CreateBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CreateBody", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_CreateBody_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_CreateBody_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_CreateBook_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CreateBook", runtime.WithHTTPPathPattern("/v1/{parent=publishers/*}/books")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_CreateBook_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_CreateBook_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPatch, pattern_ABitOfEverythingService_UpdateBook_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/UpdateBook", runtime.WithHTTPPathPattern("/v1/{book.name=publishers/*/books/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_UpdateBook_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_UpdateBook_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_Lookup_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Lookup", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/{uuid}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_Lookup_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Lookup_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_Custom_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Custom", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/{uuid}:custom")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_Custom_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Custom_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_Custom_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Custom", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/custom/{optional_string_value}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_Custom_1(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Custom_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_DoubleColon_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/DoubleColon", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/{uuid}:custom:custom")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_DoubleColon_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_DoubleColon_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPut, pattern_ABitOfEverythingService_Update_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Update", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/{uuid}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_Update_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Update_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPut, pattern_ABitOfEverythingService_UpdateV2_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/UpdateV2", runtime.WithHTTPPathPattern("/v2/example/a_bit_of_everything/{abe.uuid}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_UpdateV2_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_UpdateV2_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPatch, pattern_ABitOfEverythingService_UpdateV2_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/UpdateV2", runtime.WithHTTPPathPattern("/v2/example/a_bit_of_everything/{abe.uuid}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_UpdateV2_1(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_UpdateV2_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPatch, pattern_ABitOfEverythingService_UpdateV2_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/UpdateV2", runtime.WithHTTPPathPattern("/v2a/example/a_bit_of_everything/{abe.uuid}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_UpdateV2_2(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_UpdateV2_2(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodDelete, pattern_ABitOfEverythingService_Delete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Delete", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/{uuid}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_Delete_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Delete_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_GetQuery_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/GetQuery", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/query/{uuid}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_GetQuery_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_GetQuery_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_GetRepeatedQuery_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/GetRepeatedQuery", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything_repeated/{path_repeated_float_value}/{path_repeated_double_value}/{path_repeated_int64_value}/{path_repeated_uint64_value}/{path_repeated_int32_value}/{path_repeated_fixed64_value}/{path_repeated_fixed32_value}/{path_repeated_bool_value}/{path_repeated_string_value}/{path_repeated_bytes_value}/{path_repeated_uint32_value}/{path_repeated_enum_value}/{path_repeated_sfixed32_value}/{path_repeated_sfixed64_value}/{path_repeated_sint32_value}/{path_repeated_sint64_value}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_GetRepeatedQuery_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_GetRepeatedQuery_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Echo", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/echo/{value}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_Echo_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_Echo_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Echo", runtime.WithHTTPPathPattern("/v2/example/echo")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_Echo_1(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Echo_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_Echo_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Echo", runtime.WithHTTPPathPattern("/v2/example/echo")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_Echo_2(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Echo_2(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_DeepPathEcho_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/DeepPathEcho", runtime.WithHTTPPathPattern("/v1/example/deep_path/{single_nested.name}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_DeepPathEcho_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_DeepPathEcho_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_Timeout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Timeout", runtime.WithHTTPPathPattern("/v2/example/timeout")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_Timeout_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Timeout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_ErrorWithDetails_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/ErrorWithDetails", runtime.WithHTTPPathPattern("/v2/example/errorwithdetails")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_ErrorWithDetails_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_ErrorWithDetails_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_GetMessageWithBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/GetMessageWithBody", runtime.WithHTTPPathPattern("/v2/example/withbody/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_GetMessageWithBody_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_GetMessageWithBody_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_PostWithEmptyBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/PostWithEmptyBody", runtime.WithHTTPPathPattern("/v2/example/postwithemptybody/{name}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_PostWithEmptyBody_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_PostWithEmptyBody_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_CheckGetQueryParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CheckGetQueryParams", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/params/get/{single_nested.name}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_CheckGetQueryParams_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_CheckGetQueryParams_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_CheckNestedEnumGetQueryParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CheckNestedEnumGetQueryParams", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/params/get/nested_enum/{single_nested.ok}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_CheckNestedEnumGetQueryParams_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_CheckNestedEnumGetQueryParams_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_CheckPostQueryParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CheckPostQueryParams", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/params/post/{string_value}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_CheckPostQueryParams_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_CheckPostQueryParams_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_OverwriteRequestContentType_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/OverwriteRequestContentType", runtime.WithHTTPPathPattern("/v2/example/overwriterequestcontenttype")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_OverwriteRequestContentType_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_OverwriteRequestContentType_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_OverwriteResponseContentType_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/OverwriteResponseContentType", runtime.WithHTTPPathPattern("/v2/example/overwriteresponsecontenttype")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_OverwriteResponseContentType_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_OverwriteResponseContentType_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_CheckExternalPathEnum_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CheckExternalPathEnum", runtime.WithHTTPPathPattern("/v2/{value}:check")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_CheckExternalPathEnum_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_CheckExternalPathEnum_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_CheckExternalNestedPathEnum_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CheckExternalNestedPathEnum", runtime.WithHTTPPathPattern("/v3/{value}:check")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_CheckExternalNestedPathEnum_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_CheckExternalNestedPathEnum_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_CheckStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CheckStatus", runtime.WithHTTPPathPattern("/v1/example/checkStatus")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_CheckStatus_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_CheckStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodHead, pattern_ABitOfEverythingService_Exists_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Exists", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/{uuid}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_Exists_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Exists_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodOptions, pattern_ABitOfEverythingService_CustomOptionsRequest_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CustomOptionsRequest", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/{uuid}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_CustomOptionsRequest_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_CustomOptionsRequest_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodTrace, pattern_ABitOfEverythingService_TraceRequest_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/TraceRequest", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/{uuid}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_TraceRequest_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_TraceRequest_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_PostOneofEnum_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/PostOneofEnum", runtime.WithHTTPPathPattern("/v1/example/oneofenum")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_PostOneofEnum_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_PostOneofEnum_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_PostRequiredMessageType_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/PostRequiredMessageType", runtime.WithHTTPPathPattern("/v1/example/requiredmessagetype")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ABitOfEverythingService_PostRequiredMessageType_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_PostRequiredMessageType_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } // RegisterCamelCaseServiceNameHandlerServer registers the http handlers for service CamelCaseServiceName to "mux". // UnaryRPC :call CamelCaseServiceNameServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterCamelCaseServiceNameHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterCamelCaseServiceNameHandlerServer(ctx context.Context, mux *runtime.ServeMux, server CamelCaseServiceNameServer) error { mux.Handle(http.MethodGet, pattern_CamelCaseServiceName_Empty_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.CamelCaseServiceName/Empty", runtime.WithHTTPPathPattern("/v2/example/empty")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_CamelCaseServiceName_Empty_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_CamelCaseServiceName_Empty_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } // RegisterSnakeEnumServiceHandlerServer registers the http handlers for service SnakeEnumService to "mux". // UnaryRPC :call SnakeEnumServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterSnakeEnumServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterSnakeEnumServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server SnakeEnumServiceServer) error { mux.Handle(http.MethodGet, pattern_SnakeEnumService_SnakeEnum_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.SnakeEnumService/SnakeEnum", runtime.WithHTTPPathPattern("/v1/example/snake/{who}/{what}/{where}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_SnakeEnumService_SnakeEnum_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_SnakeEnumService_SnakeEnum_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } // RegisterABitOfEverythingServiceHandlerFromEndpoint is same as RegisterABitOfEverythingServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterABitOfEverythingServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterABitOfEverythingServiceHandler(ctx, mux, conn) } // RegisterABitOfEverythingServiceHandler registers the http handlers for service ABitOfEverythingService to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterABitOfEverythingServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterABitOfEverythingServiceHandlerClient(ctx, mux, NewABitOfEverythingServiceClient(conn)) } // RegisterABitOfEverythingServiceHandlerClient registers the http handlers for service ABitOfEverythingService // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ABitOfEverythingServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ABitOfEverythingServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "ABitOfEverythingServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterABitOfEverythingServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ABitOfEverythingServiceClient) error { mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_Create_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Create", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/{float_value}/{double_value}/{int64_value}/separator/{uint64_value}/{int32_value}/{fixed64_value}/{fixed32_value}/{bool_value}/{string_value=strprefix/*}/{uint32_value}/{sfixed32_value}/{sfixed64_value}/{sint32_value}/{sint64_value}/{nonConventionalNameValue}/{enum_value}/{path_enum_value}/{nested_path_enum_value}/{enum_value_annotation}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_Create_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Create_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_CreateBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CreateBody", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_CreateBody_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_CreateBody_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_CreateBook_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CreateBook", runtime.WithHTTPPathPattern("/v1/{parent=publishers/*}/books")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_CreateBook_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_CreateBook_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPatch, pattern_ABitOfEverythingService_UpdateBook_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/UpdateBook", runtime.WithHTTPPathPattern("/v1/{book.name=publishers/*/books/*}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_UpdateBook_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_UpdateBook_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_Lookup_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Lookup", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/{uuid}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_Lookup_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Lookup_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_Custom_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Custom", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/{uuid}:custom")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_Custom_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Custom_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_Custom_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Custom", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/custom/{optional_string_value}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_Custom_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Custom_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_DoubleColon_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/DoubleColon", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/{uuid}:custom:custom")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_DoubleColon_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_DoubleColon_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPut, pattern_ABitOfEverythingService_Update_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Update", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/{uuid}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_Update_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Update_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPut, pattern_ABitOfEverythingService_UpdateV2_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/UpdateV2", runtime.WithHTTPPathPattern("/v2/example/a_bit_of_everything/{abe.uuid}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_UpdateV2_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_UpdateV2_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPatch, pattern_ABitOfEverythingService_UpdateV2_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/UpdateV2", runtime.WithHTTPPathPattern("/v2/example/a_bit_of_everything/{abe.uuid}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_UpdateV2_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_UpdateV2_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPatch, pattern_ABitOfEverythingService_UpdateV2_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/UpdateV2", runtime.WithHTTPPathPattern("/v2a/example/a_bit_of_everything/{abe.uuid}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_UpdateV2_2(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_UpdateV2_2(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodDelete, pattern_ABitOfEverythingService_Delete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Delete", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/{uuid}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_Delete_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Delete_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_GetQuery_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/GetQuery", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/query/{uuid}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_GetQuery_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_GetQuery_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_GetRepeatedQuery_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/GetRepeatedQuery", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything_repeated/{path_repeated_float_value}/{path_repeated_double_value}/{path_repeated_int64_value}/{path_repeated_uint64_value}/{path_repeated_int32_value}/{path_repeated_fixed64_value}/{path_repeated_fixed32_value}/{path_repeated_bool_value}/{path_repeated_string_value}/{path_repeated_bytes_value}/{path_repeated_uint32_value}/{path_repeated_enum_value}/{path_repeated_sfixed32_value}/{path_repeated_sfixed64_value}/{path_repeated_sint32_value}/{path_repeated_sint64_value}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_GetRepeatedQuery_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_GetRepeatedQuery_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Echo", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/echo/{value}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_Echo_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_Echo_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Echo", runtime.WithHTTPPathPattern("/v2/example/echo")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_Echo_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Echo_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_Echo_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Echo", runtime.WithHTTPPathPattern("/v2/example/echo")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_Echo_2(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Echo_2(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_DeepPathEcho_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/DeepPathEcho", runtime.WithHTTPPathPattern("/v1/example/deep_path/{single_nested.name}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_DeepPathEcho_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_DeepPathEcho_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_Timeout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Timeout", runtime.WithHTTPPathPattern("/v2/example/timeout")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_Timeout_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Timeout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_ErrorWithDetails_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/ErrorWithDetails", runtime.WithHTTPPathPattern("/v2/example/errorwithdetails")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_ErrorWithDetails_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_ErrorWithDetails_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_GetMessageWithBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/GetMessageWithBody", runtime.WithHTTPPathPattern("/v2/example/withbody/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_GetMessageWithBody_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_GetMessageWithBody_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_PostWithEmptyBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/PostWithEmptyBody", runtime.WithHTTPPathPattern("/v2/example/postwithemptybody/{name}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_PostWithEmptyBody_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_PostWithEmptyBody_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_CheckGetQueryParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CheckGetQueryParams", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/params/get/{single_nested.name}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_CheckGetQueryParams_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_CheckGetQueryParams_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_CheckNestedEnumGetQueryParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CheckNestedEnumGetQueryParams", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/params/get/nested_enum/{single_nested.ok}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_CheckNestedEnumGetQueryParams_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_CheckNestedEnumGetQueryParams_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_CheckPostQueryParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CheckPostQueryParams", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/params/post/{string_value}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_CheckPostQueryParams_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_CheckPostQueryParams_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_OverwriteRequestContentType_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/OverwriteRequestContentType", runtime.WithHTTPPathPattern("/v2/example/overwriterequestcontenttype")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_OverwriteRequestContentType_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_OverwriteRequestContentType_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_OverwriteResponseContentType_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/OverwriteResponseContentType", runtime.WithHTTPPathPattern("/v2/example/overwriteresponsecontenttype")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_OverwriteResponseContentType_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_OverwriteResponseContentType_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_CheckExternalPathEnum_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CheckExternalPathEnum", runtime.WithHTTPPathPattern("/v2/{value}:check")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_CheckExternalPathEnum_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_CheckExternalPathEnum_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_CheckExternalNestedPathEnum_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CheckExternalNestedPathEnum", runtime.WithHTTPPathPattern("/v3/{value}:check")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_CheckExternalNestedPathEnum_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_CheckExternalNestedPathEnum_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ABitOfEverythingService_CheckStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CheckStatus", runtime.WithHTTPPathPattern("/v1/example/checkStatus")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_CheckStatus_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_CheckStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodHead, pattern_ABitOfEverythingService_Exists_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Exists", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/{uuid}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_Exists_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_Exists_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodOptions, pattern_ABitOfEverythingService_CustomOptionsRequest_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CustomOptionsRequest", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/{uuid}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_CustomOptionsRequest_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_CustomOptionsRequest_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodTrace, pattern_ABitOfEverythingService_TraceRequest_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/TraceRequest", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/{uuid}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_TraceRequest_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_TraceRequest_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_PostOneofEnum_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/PostOneofEnum", runtime.WithHTTPPathPattern("/v1/example/oneofenum")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_PostOneofEnum_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_PostOneofEnum_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ABitOfEverythingService_PostRequiredMessageType_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/PostRequiredMessageType", runtime.WithHTTPPathPattern("/v1/example/requiredmessagetype")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ABitOfEverythingService_PostRequiredMessageType_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ABitOfEverythingService_PostRequiredMessageType_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_ABitOfEverythingService_Create_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5, 2, 6, 1, 0, 4, 1, 5, 7, 1, 0, 4, 1, 5, 8, 1, 0, 4, 1, 5, 9, 1, 0, 4, 1, 5, 10, 1, 0, 4, 1, 5, 11, 2, 12, 1, 0, 4, 2, 5, 13, 1, 0, 4, 1, 5, 14, 1, 0, 4, 1, 5, 15, 1, 0, 4, 1, 5, 16, 1, 0, 4, 1, 5, 17, 1, 0, 4, 1, 5, 18, 1, 0, 4, 1, 5, 19, 1, 0, 4, 1, 5, 20, 1, 0, 4, 1, 5, 21, 1, 0, 4, 1, 5, 22, 1, 0, 4, 1, 5, 23}, []string{"v1", "example", "a_bit_of_everything", "float_value", "double_value", "int64_value", "separator", "uint64_value", "int32_value", "fixed64_value", "fixed32_value", "bool_value", "strprefix", "string_value", "uint32_value", "sfixed32_value", "sfixed64_value", "sint32_value", "sint64_value", "nonConventionalNameValue", "enum_value", "path_enum_value", "nested_path_enum_value", "enum_value_annotation"}, "")) pattern_ABitOfEverythingService_CreateBody_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "a_bit_of_everything"}, "")) pattern_ABitOfEverythingService_CreateBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2, 2, 3}, []string{"v1", "publishers", "parent", "books"}, "")) pattern_ABitOfEverythingService_UpdateBook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 4, 4, 5, 3}, []string{"v1", "publishers", "books", "book.name"}, "")) pattern_ABitOfEverythingService_Lookup_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "example", "a_bit_of_everything", "uuid"}, "")) pattern_ABitOfEverythingService_Custom_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "example", "a_bit_of_everything", "uuid"}, "custom")) pattern_ABitOfEverythingService_Custom_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"v1", "example", "a_bit_of_everything", "custom", "optional_string_value"}, "")) pattern_ABitOfEverythingService_DoubleColon_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "example", "a_bit_of_everything", "uuid"}, "custom:custom")) pattern_ABitOfEverythingService_Update_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "example", "a_bit_of_everything", "uuid"}, "")) pattern_ABitOfEverythingService_UpdateV2_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v2", "example", "a_bit_of_everything", "abe.uuid"}, "")) pattern_ABitOfEverythingService_UpdateV2_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v2", "example", "a_bit_of_everything", "abe.uuid"}, "")) pattern_ABitOfEverythingService_UpdateV2_2 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v2a", "example", "a_bit_of_everything", "abe.uuid"}, "")) pattern_ABitOfEverythingService_Delete_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "example", "a_bit_of_everything", "uuid"}, "")) pattern_ABitOfEverythingService_GetQuery_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"v1", "example", "a_bit_of_everything", "query", "uuid"}, "")) pattern_ABitOfEverythingService_GetRepeatedQuery_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5, 1, 0, 4, 1, 5, 6, 1, 0, 4, 1, 5, 7, 1, 0, 4, 1, 5, 8, 1, 0, 4, 1, 5, 9, 1, 0, 4, 1, 5, 10, 1, 0, 4, 1, 5, 11, 1, 0, 4, 1, 5, 12, 1, 0, 4, 1, 5, 13, 1, 0, 4, 1, 5, 14, 1, 0, 4, 1, 5, 15, 1, 0, 4, 1, 5, 16, 1, 0, 4, 1, 5, 17, 1, 0, 4, 1, 5, 18}, []string{"v1", "example", "a_bit_of_everything_repeated", "path_repeated_float_value", "path_repeated_double_value", "path_repeated_int64_value", "path_repeated_uint64_value", "path_repeated_int32_value", "path_repeated_fixed64_value", "path_repeated_fixed32_value", "path_repeated_bool_value", "path_repeated_string_value", "path_repeated_bytes_value", "path_repeated_uint32_value", "path_repeated_enum_value", "path_repeated_sfixed32_value", "path_repeated_sfixed64_value", "path_repeated_sint32_value", "path_repeated_sint64_value"}, "")) pattern_ABitOfEverythingService_Echo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"v1", "example", "a_bit_of_everything", "echo", "value"}, "")) pattern_ABitOfEverythingService_Echo_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "example", "echo"}, "")) pattern_ABitOfEverythingService_Echo_2 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "example", "echo"}, "")) pattern_ABitOfEverythingService_DeepPathEcho_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "example", "deep_path", "single_nested.name"}, "")) pattern_ABitOfEverythingService_Timeout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "example", "timeout"}, "")) pattern_ABitOfEverythingService_ErrorWithDetails_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "example", "errorwithdetails"}, "")) pattern_ABitOfEverythingService_GetMessageWithBody_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v2", "example", "withbody", "id"}, "")) pattern_ABitOfEverythingService_PostWithEmptyBody_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v2", "example", "postwithemptybody", "name"}, "")) pattern_ABitOfEverythingService_CheckGetQueryParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"v1", "example", "a_bit_of_everything", "params", "get", "single_nested.name"}, "")) pattern_ABitOfEverythingService_CheckNestedEnumGetQueryParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6}, []string{"v1", "example", "a_bit_of_everything", "params", "get", "nested_enum", "single_nested.ok"}, "")) pattern_ABitOfEverythingService_CheckPostQueryParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"v1", "example", "a_bit_of_everything", "params", "post", "string_value"}, "")) pattern_ABitOfEverythingService_OverwriteRequestContentType_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "example", "overwriterequestcontenttype"}, "")) pattern_ABitOfEverythingService_OverwriteResponseContentType_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "example", "overwriteresponsecontenttype"}, "")) pattern_ABitOfEverythingService_CheckExternalPathEnum_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"v2", "value"}, "check")) pattern_ABitOfEverythingService_CheckExternalNestedPathEnum_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"v3", "value"}, "check")) pattern_ABitOfEverythingService_CheckStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "checkStatus"}, "")) pattern_ABitOfEverythingService_Exists_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "example", "a_bit_of_everything", "uuid"}, "")) pattern_ABitOfEverythingService_CustomOptionsRequest_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "example", "a_bit_of_everything", "uuid"}, "")) pattern_ABitOfEverythingService_TraceRequest_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "example", "a_bit_of_everything", "uuid"}, "")) pattern_ABitOfEverythingService_PostOneofEnum_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "oneofenum"}, "")) pattern_ABitOfEverythingService_PostRequiredMessageType_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "requiredmessagetype"}, "")) ) var ( forward_ABitOfEverythingService_Create_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_CreateBody_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_CreateBook_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_UpdateBook_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_Lookup_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_Custom_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_Custom_1 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_DoubleColon_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_Update_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_UpdateV2_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_UpdateV2_1 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_UpdateV2_2 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_Delete_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_GetQuery_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_GetRepeatedQuery_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_Echo_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_Echo_1 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_Echo_2 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_DeepPathEcho_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_Timeout_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_ErrorWithDetails_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_GetMessageWithBody_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_PostWithEmptyBody_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_CheckGetQueryParams_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_CheckNestedEnumGetQueryParams_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_CheckPostQueryParams_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_OverwriteRequestContentType_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_OverwriteResponseContentType_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_CheckExternalPathEnum_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_CheckExternalNestedPathEnum_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_CheckStatus_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_Exists_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_CustomOptionsRequest_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_TraceRequest_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_PostOneofEnum_0 = runtime.ForwardResponseMessage forward_ABitOfEverythingService_PostRequiredMessageType_0 = runtime.ForwardResponseMessage ) // RegisterCamelCaseServiceNameHandlerFromEndpoint is same as RegisterCamelCaseServiceNameHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterCamelCaseServiceNameHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterCamelCaseServiceNameHandler(ctx, mux, conn) } // RegisterCamelCaseServiceNameHandler registers the http handlers for service CamelCaseServiceName to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterCamelCaseServiceNameHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterCamelCaseServiceNameHandlerClient(ctx, mux, NewCamelCaseServiceNameClient(conn)) } // RegisterCamelCaseServiceNameHandlerClient registers the http handlers for service CamelCaseServiceName // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "CamelCaseServiceNameClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "CamelCaseServiceNameClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "CamelCaseServiceNameClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterCamelCaseServiceNameHandlerClient(ctx context.Context, mux *runtime.ServeMux, client CamelCaseServiceNameClient) error { mux.Handle(http.MethodGet, pattern_CamelCaseServiceName_Empty_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.CamelCaseServiceName/Empty", runtime.WithHTTPPathPattern("/v2/example/empty")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_CamelCaseServiceName_Empty_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_CamelCaseServiceName_Empty_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_CamelCaseServiceName_Empty_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "example", "empty"}, "")) ) var ( forward_CamelCaseServiceName_Empty_0 = runtime.ForwardResponseMessage ) // RegisterSnakeEnumServiceHandlerFromEndpoint is same as RegisterSnakeEnumServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterSnakeEnumServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterSnakeEnumServiceHandler(ctx, mux, conn) } // RegisterSnakeEnumServiceHandler registers the http handlers for service SnakeEnumService to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterSnakeEnumServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterSnakeEnumServiceHandlerClient(ctx, mux, NewSnakeEnumServiceClient(conn)) } // RegisterSnakeEnumServiceHandlerClient registers the http handlers for service SnakeEnumService // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "SnakeEnumServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "SnakeEnumServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "SnakeEnumServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterSnakeEnumServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client SnakeEnumServiceClient) error { mux.Handle(http.MethodGet, pattern_SnakeEnumService_SnakeEnum_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.SnakeEnumService/SnakeEnum", runtime.WithHTTPPathPattern("/v1/example/snake/{who}/{what}/{where}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_SnakeEnumService_SnakeEnum_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_SnakeEnumService_SnakeEnum_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_SnakeEnumService_SnakeEnum_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"v1", "example", "snake", "who", "what", "where"}, "")) ) var ( forward_SnakeEnumService_SnakeEnum_0 = runtime.ForwardResponseMessage ) ================================================ FILE: examples/internal/proto/examplepb/a_bit_of_everything.proto ================================================ syntax = "proto3"; package grpc.gateway.examples.internal.proto.examplepb; import "examples/internal/proto/oneofenum/oneof_enum.proto"; import "examples/internal/proto/pathenum/path_enum.proto"; import "examples/internal/proto/sub/message.proto"; import "examples/internal/proto/sub2/message.proto"; import "google/api/annotations.proto"; import "google/api/field_behavior.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/empty.proto"; import "google/protobuf/field_mask.proto"; import "google/protobuf/timestamp.proto"; import "google/protobuf/wrappers.proto"; import "google/rpc/status.proto"; import "protoc-gen-openapiv2/options/annotations.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { info: { title: "A Bit of Everything" version: "1.0" contact: { name: "gRPC-Gateway project" url: "https://github.com/grpc-ecosystem/grpc-gateway" email: "none@example.com" } license: { name: "BSD 3-Clause License" url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE" } extensions: { key: "x-something-something" value: {string_value: "yadda"} } } // Overwriting host entry breaks tests, so this is not done here. external_docs: { url: "https://github.com/grpc-ecosystem/grpc-gateway" description: "More about gRPC-Gateway" } schemes: HTTP schemes: HTTPS schemes: WSS consumes: "application/json" consumes: "application/x-foo-mime" produces: "application/json" produces: "application/x-foo-mime" security_definitions: { security: { key: "BasicAuth" value: {type: TYPE_BASIC} } security: { key: "ApiKeyAuth" value: { type: TYPE_API_KEY in: IN_HEADER name: "X-API-Key" extensions: { key: "x-amazon-apigateway-authtype" value: {string_value: "oauth2"} } extensions: { key: "x-amazon-apigateway-authorizer" value: { struct_value: { fields: { key: "type" value: {string_value: "token"} } fields: { key: "authorizerResultTtlInSeconds" value: {number_value: 60} } } } } } } security: { key: "OAuth2" value: { type: TYPE_OAUTH2 flow: FLOW_ACCESS_CODE authorization_url: "https://example.com/oauth/authorize" token_url: "https://example.com/oauth/token" scopes: { scope: { key: "read" value: "Grants read access" } scope: { key: "write" value: "Grants write access" } scope: { key: "admin" value: "Grants read and write access to administrative information" } } } } } security: { security_requirement: { key: "BasicAuth" value: {} } security_requirement: { key: "ApiKeyAuth" value: {} } } security: { security_requirement: { key: "OAuth2" value: { scope: "read" scope: "write" } } security_requirement: { key: "ApiKeyAuth" value: {} } } responses: { key: "403" value: {description: "Returned when the user does not have permission to access the resource."} } responses: { key: "404" value: { description: "Returned when the resource does not exist." schema: { json_schema: {type: STRING} } } } responses: { key: "418" value: { description: "I'm a teapot." schema: { json_schema: {ref: ".grpc.gateway.examples.internal.proto.examplepb.NumericEnum"} } } } responses: { key: "500" value: { description: "Server error" headers: { key: "X-Correlation-Id" value: { description: "Unique event identifier for server requests" type: "string" format: "uuid" default: "\"2438ac3c-37eb-4902-adef-ed16b4431030\"" pattern: "^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$" } } schema: { json_schema: {ref: ".grpc.gateway.examples.internal.proto.examplepb.ErrorResponse"} } } } tags: { name: "echo rpc" description: "Echo Rpc description" extensions: { key: "x-traitTag" value: {bool_value: true} } } extensions: { key: "x-grpc-gateway-foo" value: {string_value: "bar"} } extensions: { key: "x-grpc-gateway-baz-list" value: { list_value: { values: {string_value: "one"} values: {bool_value: true} } } } }; message ErrorResponse { string correlationId = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { pattern: "^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$" title: "x-correlation-id" description: "Unique event identifier for server requests" format: "uuid" example: "\"2438ac3c-37eb-4902-adef-ed16b4431030\"" }]; ErrorObject error = 2; } message ErrorObject { int32 code = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { pattern: "^[0-9]$" title: "code" description: "Response code" format: "integer" }]; string message = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { pattern: "^[a-zA-Z0-9]{1, 32}$" title: "message" description: "Response message" }]; } // Intentionally complicated message type to cover many features of Protobuf. message ABitOfEverything { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { json_schema: { title: "A bit of everything" description: "Intentionally complicated message type to cover many features of Protobuf." required: [ "uuid", "int64_value", "double_value", "required_field_schema_json_name" ] extensions: { key: "x-a-bit-of-everything-foo" value: {string_value: "bar"} } } external_docs: { url: "https://github.com/grpc-ecosystem/grpc-gateway" description: "Find out more about ABitOfEverything" } example: "{\"int64_value\": 12, \"double_value\": 12.3}" }; // Nested is nested type. message Nested { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = {example: "{\"ok\": \"TRUE\"}"}; // name is nested field. string name = 1; uint32 amount = 2; // DeepEnum is one or zero. enum DeepEnum { // FALSE is false. FALSE = 0; // TRUE is true. TRUE = 1; } // DeepEnum comment. DeepEnum ok = 3 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "DeepEnum description."}]; } Nested single_nested = 25; string uuid = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { pattern: "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}" min_length: 1 field_configuration: {path_param_name: "uuidName"} format: "uuid" extensions: { key: "x-internal" value: {bool_value: true} } }]; repeated Nested nested = 2; float float_value = 3 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { description: "Float value field" default: "0.2" required: ["float_value"] }]; double double_value = 4; int64 int64_value = 5; uint64 uint64_value = 6; int32 int32_value = 7; fixed64 fixed64_value = 8; fixed32 fixed32_value = 9; bool bool_value = 10; string string_value = 11; bytes bytes_value = 29; uint32 uint32_value = 13; NumericEnum enum_value = 14; pathenum.PathEnum path_enum_value = 30; pathenum.MessagePathEnum.NestedPathEnum nested_path_enum_value = 31; sfixed32 sfixed32_value = 15; sfixed64 sfixed64_value = 16; sint32 sint32_value = 17; sint64 sint64_value = 18; repeated string repeated_string_value = 19; oneof oneof_value { google.protobuf.Empty oneof_empty = 20; string oneof_string = 21; } // map of numeric enum map map_value = 22; // map of string (This comment is overridden by the field annotation) map mapped_string_value = 23 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { title: "Map of string title" description: "Map of string description." }]; map mapped_nested_value = 24; string nonConventionalNameValue = 26; google.protobuf.Timestamp timestamp_value = 27; // repeated enum value. it is comma-separated in query repeated NumericEnum repeated_enum_value = 28; // repeated numeric enum comment (This comment is overridden by the field annotation) repeated NumericEnum repeated_enum_annotation = 32 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { title: "Repeated numeric enum title" description: "Repeated numeric enum description." }]; // numeric enum comment (This comment is overridden by the field annotation) NumericEnum enum_value_annotation = 33 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { title: "Numeric enum title" description: "Numeric enum description." }]; // repeated string comment (This comment is overridden by the field annotation) repeated string repeated_string_annotation = 34 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { title: "Repeated string title" description: "Repeated string description." }]; // repeated nested object comment (This comment is overridden by the field annotation) repeated Nested repeated_nested_annotation = 35 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { title: "Repeated nested object title" description: "Repeated nested object description." }]; // nested object comments (This comment is overridden by the field annotation) Nested nested_annotation = 36 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { title: "Nested object title" description: "Nested object description." }]; int64 int64_override_type = 37 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {type: INTEGER}]; // mark a field as required in Open API definition string required_string_via_field_behavior_annotation = 38 [(google.api.field_behavior) = REQUIRED]; // mark a field as readonly in Open API definition string output_only_string_via_field_behavior_annotation = 39 [(google.api.field_behavior) = OUTPUT_ONLY]; optional string optional_string_value = 40; // Test openapiv2 generation of repeated fields repeated string product_id = 41 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { pattern: "^[0-9]+$" max_length: 19 min_length: 1 description: "Only digits are allowed." }]; // Test openapiv2 generation of required fields with annotation and jsonschema to reproduce string optional_string_field = 42; string required_string_field_1 = 43 [(google.api.field_behavior) = REQUIRED]; string required_string_field_2 = 44 [(google.api.field_behavior) = REQUIRED]; // Test openapiv2 handling of required json_name fields string required_field_behavior_json_name = 45 [ json_name = "required_field_behavior_json_name_custom", (google.api.field_behavior) = REQUIRED ]; string required_field_schema_json_name = 46 [json_name = "required_field_schema_json_name_custom"]; string trailing_only = 47; // Trailing only string trailing_only_dot = 48; // Trailing only dot. // Leading both string trailing_both = 49; // Trailing both. // Leading multiline // // This is an example of a multi-line comment. string trailing_multiline = 50; // Trailing multiline. // Specify a custom format of repeated field items repeated string uuids = 51 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {format: "uuid"}]; } // ABitOfEverythingRepeated is used to validate repeated path parameter functionality message ABitOfEverythingRepeated { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = {example: "{\"path_repeated_bool_value\": [true, true, false, true], \"path_repeated_int32_value\": [1, 2, 3]}"}; // repeated values. they are comma-separated in path repeated float path_repeated_float_value = 1; repeated double path_repeated_double_value = 2; repeated int64 path_repeated_int64_value = 3; repeated uint64 path_repeated_uint64_value = 4; repeated int32 path_repeated_int32_value = 5; repeated fixed64 path_repeated_fixed64_value = 6; repeated fixed32 path_repeated_fixed32_value = 7; repeated bool path_repeated_bool_value = 8; repeated string path_repeated_string_value = 9; repeated bytes path_repeated_bytes_value = 10; repeated uint32 path_repeated_uint32_value = 11; repeated NumericEnum path_repeated_enum_value = 12; repeated sfixed32 path_repeated_sfixed32_value = 13; repeated sfixed64 path_repeated_sfixed64_value = 14; repeated sint32 path_repeated_sint32_value = 15; repeated sint64 path_repeated_sint64_value = 16; } message CheckStatusResponse { google.rpc.Status status = 1; } message Body { string name = 1; } message MessageWithBody { string id = 1; Body data = 2; } // NumericEnum is one or zero. enum NumericEnum { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_enum) = { description: "NumericEnum is one or zero." title: "NumericEnum" extensions: { key: "x-a-bit-of-everything-foo" value: {string_value: "bar"} } external_docs: { url: "https://github.com/grpc-ecosystem/grpc-gateway" description: "Find out more about ABitOfEverything" } example: "\"ZERO\"" }; // ZERO means 0 ZERO = 0; // ONE means 1 ONE = 1; } // UpdateV2Request request for update includes the message and the update mask message UpdateV2Request { ABitOfEverything abe = 1; // The paths to update. google.protobuf.FieldMask update_mask = 2; } // An example resource type from AIP-123 used to test the behavior described in // the CreateBookRequest message. // // See: https://google.aip.dev/123 message Book { // The resource name of the book. // // Format: `publishers/{publisher}/books/{book}` // // Example: `publishers/1257894000000000000/books/my-book` string name = 1; // Output only. The book's ID. string id = 2; // Output only. Creation time of the book. google.protobuf.Timestamp create_time = 3; } // A standard Create message from AIP-133 with a user-specified ID. // The user-specified ID (the `book_id` field in this example) must become a // query parameter in the OpenAPI spec. // // See: https://google.aip.dev/133#user-specified-ids message CreateBookRequest { // The publisher in which to create the book. // // Format: `publishers/{publisher}` // // Example: `publishers/1257894000000000000` string parent = 1; // The book to create. Book book = 2 [(google.api.field_behavior) = REQUIRED]; // The ID to use for the book. // // This must start with an alphanumeric character. string book_id = 3; } // A standard Update message from AIP-134 // // See: https://google.aip.dev/134#request-message message UpdateBookRequest { // The book to update. // // The book's `name` field is used to identify the book to be updated. // Format: publishers/{publisher}/books/{book} Book book = 1 [(google.api.field_behavior) = REQUIRED]; // The list of fields to be updated. google.protobuf.FieldMask update_mask = 2; // If set to true, and the book is not found, a new book will be created. // In this situation, `update_mask` is ignored. bool allow_missing = 3; } // ABitOfEverything service is used to validate that APIs with complicated // proto messages and URL templates are still processed correctly. service ABitOfEverythingService { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag) = { name: "ABitOfEverything" description: "ABitOfEverythingService description -- which should not be used in place of the documentation comment!" external_docs: { url: "https://github.com/grpc-ecosystem/grpc-gateway" description: "Find out more about EchoService" } }; // Create a new ABitOfEverything // // This API creates a new ABitOfEverything rpc Create(ABitOfEverything) returns (ABitOfEverything) { option (google.api.http) = {post: "/v1/example/a_bit_of_everything/{float_value}/{double_value}/{int64_value}/separator/{uint64_value}/{int32_value}/{fixed64_value}/{fixed32_value}/{bool_value}/{string_value=strprefix/*}/{uint32_value}/{sfixed32_value}/{sfixed64_value}/{sint32_value}/{sint64_value}/{nonConventionalNameValue}/{enum_value}/{path_enum_value}/{nested_path_enum_value}/{enum_value_annotation}"}; } rpc CreateBody(ABitOfEverything) returns (ABitOfEverything) { option (google.api.http) = { post: "/v1/example/a_bit_of_everything" body: "*" }; } // Create a book. rpc CreateBook(CreateBookRequest) returns (Book) { option (google.api.http) = { post: "/v1/{parent=publishers/*}/books" body: "book" }; } rpc UpdateBook(UpdateBookRequest) returns (Book) { option (google.api.http) = { patch: "/v1/{book.name=publishers/*/books/*}" body: "book" }; } rpc Lookup(grpc.gateway.examples.internal.proto.sub2.IdMessage) returns (ABitOfEverything) { option (google.api.http) = {get: "/v1/example/a_bit_of_everything/{uuid}"}; } rpc Custom(ABitOfEverything) returns (ABitOfEverything) { option (google.api.http) = { post: "/v1/example/a_bit_of_everything/{uuid}:custom" additional_bindings: { // Testing proto3 optional field get: "/v1/example/a_bit_of_everything/custom/{optional_string_value}" } }; } rpc DoubleColon(ABitOfEverything) returns (ABitOfEverything) { option (google.api.http) = {post: "/v1/example/a_bit_of_everything/{uuid}:custom:custom"}; } rpc Update(ABitOfEverything) returns (google.protobuf.Empty) { option (google.api.http) = { put: "/v1/example/a_bit_of_everything/{uuid}" body: "*" }; } rpc UpdateV2(UpdateV2Request) returns (google.protobuf.Empty) { option (google.api.http) = { put: "/v2/example/a_bit_of_everything/{abe.uuid}" body: "abe" additional_bindings: [ { patch: "/v2/example/a_bit_of_everything/{abe.uuid}" body: "abe" }, { patch: "/v2a/example/a_bit_of_everything/{abe.uuid}" body: "*" } ] }; } rpc Delete(grpc.gateway.examples.internal.proto.sub2.IdMessage) returns (google.protobuf.Empty) { option (google.api.http) = {delete: "/v1/example/a_bit_of_everything/{uuid}"}; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { security: { security_requirement: { key: "ApiKeyAuth" value: {} } security_requirement: { key: "OAuth2" value: { scope: "read" scope: "write" } } } extensions: { key: "x-irreversible" value: {bool_value: true} } }; } rpc GetQuery(ABitOfEverything) returns (google.protobuf.Empty) { option (google.api.http) = {get: "/v1/example/a_bit_of_everything/query/{uuid}"}; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { deprecated: true // For testing purposes. external_docs: { url: "https://github.com/grpc-ecosystem/grpc-gateway" description: "Find out more about GetQuery" } security: {} }; } rpc GetRepeatedQuery(ABitOfEverythingRepeated) returns (ABitOfEverythingRepeated) { option (google.api.http) = {get: "/v1/example/a_bit_of_everything_repeated/{path_repeated_float_value}/{path_repeated_double_value}/{path_repeated_int64_value}/{path_repeated_uint64_value}/{path_repeated_int32_value}/{path_repeated_fixed64_value}/{path_repeated_fixed32_value}/{path_repeated_bool_value}/{path_repeated_string_value}/{path_repeated_bytes_value}/{path_repeated_uint32_value}/{path_repeated_enum_value}/{path_repeated_sfixed32_value}/{path_repeated_sfixed64_value}/{path_repeated_sint32_value}/{path_repeated_sint64_value}"}; } // Echo allows posting a StringMessage value. // // It also exposes multiple bindings. // // This makes it useful when validating that the OpenAPI v2 API // description exposes documentation correctly on all paths // defined as additional_bindings in the proto. rpc Echo(grpc.gateway.examples.internal.proto.sub.StringMessage) returns (grpc.gateway.examples.internal.proto.sub.StringMessage) { option (google.api.http) = { get: "/v1/example/a_bit_of_everything/echo/{value}" additional_bindings: { post: "/v2/example/echo" body: "value" } additional_bindings: {get: "/v2/example/echo"} }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { description: "Description Echo" summary: "Summary: Echo rpc" tags: "echo rpc" external_docs: { url: "https://github.com/grpc-ecosystem/grpc-gateway" description: "Find out more Echo" } responses: { key: "200" value: { examples: { key: "application/json" value: "{\"value\": \"the input value\"}" } } } responses: { key: "503" value: { description: "Returned when the resource is temporarily unavailable." extensions: { key: "x-number" value: {number_value: 100} } } } responses: { // Overwrites global definition. key: "404" value: { description: "Returned when the resource does not exist." schema: { json_schema: {type: INTEGER} } } } }; } rpc DeepPathEcho(ABitOfEverything) returns (ABitOfEverything) { option (google.api.http) = { post: "/v1/example/deep_path/{single_nested.name}" body: "*" }; } rpc NoBindings(google.protobuf.Duration) returns (google.protobuf.Empty) {} rpc Timeout(google.protobuf.Empty) returns (google.protobuf.Empty) { option (google.api.http) = {get: "/v2/example/timeout"}; } rpc ErrorWithDetails(google.protobuf.Empty) returns (google.protobuf.Empty) { option (google.api.http) = {get: "/v2/example/errorwithdetails"}; } rpc GetMessageWithBody(MessageWithBody) returns (google.protobuf.Empty) { option (google.api.http) = { post: "/v2/example/withbody/{id}" body: "data" }; } rpc PostWithEmptyBody(Body) returns (google.protobuf.Empty) { option (google.api.http) = { post: "/v2/example/postwithemptybody/{name}" body: "*" }; } rpc CheckGetQueryParams(ABitOfEverything) returns (ABitOfEverything) { option (google.api.http) = {get: "/v1/example/a_bit_of_everything/params/get/{single_nested.name}"}; } rpc CheckNestedEnumGetQueryParams(ABitOfEverything) returns (ABitOfEverything) { option (google.api.http) = {get: "/v1/example/a_bit_of_everything/params/get/nested_enum/{single_nested.ok}"}; } rpc CheckPostQueryParams(ABitOfEverything) returns (ABitOfEverything) { option (google.api.http) = { post: "/v1/example/a_bit_of_everything/params/post/{string_value}" body: "single_nested" }; } rpc OverwriteRequestContentType(Body) returns (google.protobuf.Empty) { option (google.api.http) = { post: "/v2/example/overwriterequestcontenttype" body: "*" }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {consumes: "application/x-bar-mime"}; } rpc OverwriteResponseContentType(google.protobuf.Empty) returns (google.protobuf.StringValue) { option (google.api.http) = {get: "/v2/example/overwriteresponsecontenttype"}; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {produces: "application/text"}; } rpc CheckExternalPathEnum(pathenum.MessageWithPathEnum) returns (google.protobuf.Empty) { option (google.api.http) = {get: "/v2/{value}:check"}; } rpc CheckExternalNestedPathEnum(pathenum.MessageWithNestedPathEnum) returns (google.protobuf.Empty) { option (google.api.http) = {get: "/v3/{value}:check"}; } rpc CheckStatus(google.protobuf.Empty) returns (CheckStatusResponse) { option (google.api.http) = {get: "/v1/example/checkStatus"}; } rpc Exists(ABitOfEverything) returns (google.protobuf.Empty) { option (google.api.http) = { custom: { kind: "HEAD" path: "/v1/example/a_bit_of_everything/{uuid}" } }; } rpc CustomOptionsRequest(ABitOfEverything) returns (google.protobuf.Empty) { option (google.api.http) = { custom: { kind: "OPTIONS" path: "/v1/example/a_bit_of_everything/{uuid}" } }; } rpc TraceRequest(ABitOfEverything) returns (ABitOfEverything) { option (google.api.http) = { custom: { kind: "TRACE" path: "/v1/example/a_bit_of_everything/{uuid}" } }; } rpc PostOneofEnum(grpc.gateway.examples.internal.proto.oneofenum.OneofEnumMessage) returns (google.protobuf.Empty) { option (google.api.http) = { post: "/v1/example/oneofenum" body: "example_enum" }; } rpc PostRequiredMessageType(RequiredMessageTypeRequest) returns (google.protobuf.Empty) { option (google.api.http) = { post: "/v1/example/requiredmessagetype" body: "*" }; } } // camelCase and lowercase service names are valid but not recommended (use TitleCase instead) service camelCaseServiceName { rpc Empty(google.protobuf.Empty) returns (google.protobuf.Empty) { option (google.api.http) = {get: "/v2/example/empty"}; } } service AnotherServiceWithNoBindings { rpc NoBindings(google.protobuf.Empty) returns (google.protobuf.Empty) {} } service SnakeEnumService { rpc SnakeEnum(SnakeEnumRequest) returns (SnakeEnumResponse) { option (google.api.http) = {get: "/v1/example/snake/{who}/{what}/{where}"}; } } // Ignoring lint warnings as this enum type exist to validate proper functionality // for projects that don't follow these lint rules. // buf:lint:ignore ENUM_PASCAL_CASE enum snake_case_enum { // buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE value_c = 0; // buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE value_d = 1; } // Ignoring lint warnings as this enum type exist to validate proper functionality // for projects that don't follow these lint rules. // buf:lint:ignore ENUM_PASCAL_CASE enum snake_case_0_enum { // buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE value_e = 0; // buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE value_f = 1; } message SnakeEnumRequest { snake_case_enum what = 1; snake_case_0_enum who = 2; pathenum.snake_case_for_import where = 3; } message SnakeEnumResponse {} // Required message type -> OpenAPI // https://github.com/grpc-ecosystem/grpc-gateway/issues/2837 message RequiredMessageTypeRequest { string id = 1 [(google.api.field_behavior) = REQUIRED]; Foo foo = 2 [(google.api.field_behavior) = REQUIRED]; } message Foo { Bar bar = 1 [(google.api.field_behavior) = REQUIRED]; } message Bar { string id = 1 [(google.api.field_behavior) = REQUIRED]; } ================================================ FILE: examples/internal/proto/examplepb/a_bit_of_everything.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "A Bit of Everything", "version": "1.0", "contact": { "name": "gRPC-Gateway project", "url": "https://github.com/grpc-ecosystem/grpc-gateway", "email": "none@example.com" }, "license": { "name": "BSD 3-Clause License", "url": "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE" }, "x-something-something": "yadda" }, "tags": [ { "name": "echo rpc", "description": "Echo Rpc description", "x-traitTag": true }, { "name": "ABitOfEverything", "description": "ABitOfEverythingService description -- which should not be used in place of the documentation comment!", "externalDocs": { "description": "Find out more about EchoService", "url": "https://github.com/grpc-ecosystem/grpc-gateway" } }, { "name": "camelCaseServiceName" }, { "name": "AnotherServiceWithNoBindings" }, { "name": "SnakeEnumService" } ], "schemes": [ "http", "https", "wss" ], "consumes": [ "application/json", "application/x-foo-mime" ], "produces": [ "application/json", "application/x-foo-mime" ], "paths": { "/v1/example/a_bit_of_everything": { "post": { "operationId": "ABitOfEverythingService_CreateBody", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbABitOfEverything" } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "description": "Intentionally complicated message type to cover many features of Protobuf.", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbABitOfEverything" } } ], "tags": [ "ABitOfEverything" ] } }, "/v1/example/a_bit_of_everything/custom/{optionalStringValue}": { "get": { "operationId": "ABitOfEverythingService_Custom2", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbABitOfEverything" } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "optionalStringValue", "in": "path", "required": true, "type": "string" }, { "name": "singleNested.name", "description": "name is nested field.", "in": "query", "required": false, "type": "string" }, { "name": "singleNested.amount", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "singleNested.ok", "description": "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE: TRUE is true.", "in": "query", "required": false, "type": "string", "enum": [ "FALSE", "TRUE" ], "default": "FALSE" }, { "name": "uuid", "in": "query", "required": true, "type": "string", "format": "uuid", "pattern": "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}", "x-internal": true }, { "name": "floatValue", "description": "Float value field", "in": "query", "required": true, "type": "number", "format": "float", "default": "0.2" }, { "name": "doubleValue", "in": "query", "required": true, "type": "number", "format": "double" }, { "name": "int64Value", "in": "query", "required": true, "type": "string", "format": "int64" }, { "name": "uint64Value", "in": "query", "required": false, "type": "string", "format": "uint64" }, { "name": "int32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "fixed64Value", "in": "query", "required": false, "type": "string", "format": "uint64" }, { "name": "fixed32Value", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "boolValue", "in": "query", "required": false, "type": "boolean" }, { "name": "stringValue", "in": "query", "required": false, "type": "string" }, { "name": "bytesValue", "in": "query", "required": false, "type": "string", "format": "byte" }, { "name": "uint32Value", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "enumValue", "description": " - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "string", "enum": [ "ZERO", "ONE" ], "default": "ZERO" }, { "name": "pathEnumValue", "in": "query", "required": false, "type": "string", "enum": [ "ABC", "DEF" ], "default": "ABC" }, { "name": "nestedPathEnumValue", "in": "query", "required": false, "type": "string", "enum": [ "GHI", "JKL" ], "default": "GHI" }, { "name": "sfixed32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "sfixed64Value", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "sint32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "sint64Value", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "repeatedStringValue", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "oneofEmpty", "in": "query", "required": false, "type": "object" }, { "name": "oneofString", "in": "query", "required": false, "type": "string" }, { "name": "mapValue", "description": "map of numeric enum", "in": "query", "required": false }, { "name": "mappedStringValue", "description": "Map of string title\n\nMap of string description.", "in": "query", "required": false, "type": "string" }, { "name": "mappedNestedValue", "in": "query", "required": false }, { "name": "nonConventionalNameValue", "in": "query", "required": false, "type": "string" }, { "name": "timestampValue", "in": "query", "required": false, "type": "string", "format": "date-time" }, { "name": "repeatedEnumValue", "description": "repeated enum value. it is comma-separated in query\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "array", "items": { "type": "string", "enum": [ "ZERO", "ONE" ] }, "collectionFormat": "multi" }, { "name": "repeatedEnumAnnotation", "description": "Repeated numeric enum title\n\nRepeated numeric enum description.\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "array", "items": { "type": "string", "enum": [ "ZERO", "ONE" ] }, "collectionFormat": "multi" }, { "name": "enumValueAnnotation", "description": "Numeric enum title\n\nNumeric enum description.\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "string", "enum": [ "ZERO", "ONE" ], "default": "ZERO" }, { "name": "repeatedStringAnnotation", "description": "Repeated string title\n\nRepeated string description.", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "nestedAnnotation.name", "description": "name is nested field.", "in": "query", "required": false, "type": "string" }, { "name": "nestedAnnotation.amount", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "nestedAnnotation.ok", "description": "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE: TRUE is true.", "in": "query", "required": false, "type": "string", "enum": [ "FALSE", "TRUE" ], "default": "FALSE" }, { "name": "int64OverrideType", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "requiredStringViaFieldBehaviorAnnotation", "description": "mark a field as required in Open API definition", "in": "query", "required": true, "type": "string" }, { "name": "outputOnlyStringViaFieldBehaviorAnnotation", "description": "mark a field as readonly in Open API definition", "in": "query", "required": false, "type": "string" }, { "name": "productId", "description": "Test openapiv2 generation of repeated fields\n\nOnly digits are allowed.", "in": "query", "required": false, "type": "array", "items": { "type": "string", "maxLength": 19, "minLength": 1, "pattern": "^[0-9]+$" }, "collectionFormat": "multi" }, { "name": "optionalStringField", "description": "Test openapiv2 generation of required fields with annotation and jsonschema to reproduce", "in": "query", "required": false, "type": "string" }, { "name": "requiredStringField1", "in": "query", "required": true, "type": "string" }, { "name": "requiredStringField2", "in": "query", "required": true, "type": "string" }, { "name": "required_field_behavior_json_name_custom", "description": "Test openapiv2 handling of required json_name fields", "in": "query", "required": true, "type": "string" }, { "name": "required_field_schema_json_name_custom", "in": "query", "required": true, "type": "string" }, { "name": "trailingOnly", "description": "Trailing only", "in": "query", "required": false, "type": "string" }, { "name": "trailingOnlyDot", "description": "Trailing only dot.", "in": "query", "required": false, "type": "string" }, { "name": "trailingBoth", "description": "Leading both\n\nTrailing both.", "in": "query", "required": false, "type": "string" }, { "name": "trailingMultiline", "description": "Leading multiline\n\nThis is an example of a multi-line comment.\n\nTrailing multiline.", "in": "query", "required": false, "type": "string" }, { "name": "uuids", "description": "Specify a custom format of repeated field items", "in": "query", "required": false, "type": "array", "items": { "type": "string", "format": "uuid" }, "collectionFormat": "multi" } ], "tags": [ "ABitOfEverything" ] } }, "/v1/example/a_bit_of_everything/echo/{value}": { "get": { "summary": "Summary: Echo rpc", "description": "Description Echo", "operationId": "ABitOfEverythingService_Echo", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/subStringMessage" }, "examples": { "application/json": { "value": "the input value" } } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "integer", "format": "integer" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "503": { "description": "Returned when the resource is temporarily unavailable.", "schema": {}, "x-number": 100 }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "value", "in": "path", "required": true, "type": "string" } ], "tags": [ "echo rpc" ], "externalDocs": { "description": "Find out more Echo", "url": "https://github.com/grpc-ecosystem/grpc-gateway" } } }, "/v1/example/a_bit_of_everything/params/get/nested_enum/{singleNested.ok}": { "get": { "operationId": "ABitOfEverythingService_CheckNestedEnumGetQueryParams", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbABitOfEverything" } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "singleNested.ok", "description": "DeepEnum description.", "in": "path", "required": true, "type": "string", "enum": [ "FALSE", "TRUE" ] }, { "name": "singleNested.name", "description": "name is nested field.", "in": "query", "required": false, "type": "string" }, { "name": "singleNested.amount", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "uuid", "in": "query", "required": true, "type": "string", "format": "uuid", "pattern": "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}", "x-internal": true }, { "name": "floatValue", "description": "Float value field", "in": "query", "required": true, "type": "number", "format": "float", "default": "0.2" }, { "name": "doubleValue", "in": "query", "required": true, "type": "number", "format": "double" }, { "name": "int64Value", "in": "query", "required": true, "type": "string", "format": "int64" }, { "name": "uint64Value", "in": "query", "required": false, "type": "string", "format": "uint64" }, { "name": "int32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "fixed64Value", "in": "query", "required": false, "type": "string", "format": "uint64" }, { "name": "fixed32Value", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "boolValue", "in": "query", "required": false, "type": "boolean" }, { "name": "stringValue", "in": "query", "required": false, "type": "string" }, { "name": "bytesValue", "in": "query", "required": false, "type": "string", "format": "byte" }, { "name": "uint32Value", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "enumValue", "description": " - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "string", "enum": [ "ZERO", "ONE" ], "default": "ZERO" }, { "name": "pathEnumValue", "in": "query", "required": false, "type": "string", "enum": [ "ABC", "DEF" ], "default": "ABC" }, { "name": "nestedPathEnumValue", "in": "query", "required": false, "type": "string", "enum": [ "GHI", "JKL" ], "default": "GHI" }, { "name": "sfixed32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "sfixed64Value", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "sint32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "sint64Value", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "repeatedStringValue", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "oneofEmpty", "in": "query", "required": false, "type": "object" }, { "name": "oneofString", "in": "query", "required": false, "type": "string" }, { "name": "mapValue", "description": "map of numeric enum", "in": "query", "required": false }, { "name": "mappedStringValue", "description": "Map of string title\n\nMap of string description.", "in": "query", "required": false, "type": "string" }, { "name": "mappedNestedValue", "in": "query", "required": false }, { "name": "nonConventionalNameValue", "in": "query", "required": false, "type": "string" }, { "name": "timestampValue", "in": "query", "required": false, "type": "string", "format": "date-time" }, { "name": "repeatedEnumValue", "description": "repeated enum value. it is comma-separated in query\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "array", "items": { "type": "string", "enum": [ "ZERO", "ONE" ] }, "collectionFormat": "multi" }, { "name": "repeatedEnumAnnotation", "description": "Repeated numeric enum title\n\nRepeated numeric enum description.\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "array", "items": { "type": "string", "enum": [ "ZERO", "ONE" ] }, "collectionFormat": "multi" }, { "name": "enumValueAnnotation", "description": "Numeric enum title\n\nNumeric enum description.\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "string", "enum": [ "ZERO", "ONE" ], "default": "ZERO" }, { "name": "repeatedStringAnnotation", "description": "Repeated string title\n\nRepeated string description.", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "nestedAnnotation.name", "description": "name is nested field.", "in": "query", "required": false, "type": "string" }, { "name": "nestedAnnotation.amount", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "int64OverrideType", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "requiredStringViaFieldBehaviorAnnotation", "description": "mark a field as required in Open API definition", "in": "query", "required": true, "type": "string" }, { "name": "outputOnlyStringViaFieldBehaviorAnnotation", "description": "mark a field as readonly in Open API definition", "in": "query", "required": false, "type": "string" }, { "name": "optionalStringValue", "in": "query", "required": false, "type": "string" }, { "name": "productId", "description": "Test openapiv2 generation of repeated fields\n\nOnly digits are allowed.", "in": "query", "required": false, "type": "array", "items": { "type": "string", "maxLength": 19, "minLength": 1, "pattern": "^[0-9]+$" }, "collectionFormat": "multi" }, { "name": "optionalStringField", "description": "Test openapiv2 generation of required fields with annotation and jsonschema to reproduce", "in": "query", "required": false, "type": "string" }, { "name": "requiredStringField1", "in": "query", "required": true, "type": "string" }, { "name": "requiredStringField2", "in": "query", "required": true, "type": "string" }, { "name": "required_field_behavior_json_name_custom", "description": "Test openapiv2 handling of required json_name fields", "in": "query", "required": true, "type": "string" }, { "name": "required_field_schema_json_name_custom", "in": "query", "required": true, "type": "string" }, { "name": "trailingOnly", "description": "Trailing only", "in": "query", "required": false, "type": "string" }, { "name": "trailingOnlyDot", "description": "Trailing only dot.", "in": "query", "required": false, "type": "string" }, { "name": "trailingBoth", "description": "Leading both\n\nTrailing both.", "in": "query", "required": false, "type": "string" }, { "name": "trailingMultiline", "description": "Leading multiline\n\nThis is an example of a multi-line comment.\n\nTrailing multiline.", "in": "query", "required": false, "type": "string" }, { "name": "uuids", "description": "Specify a custom format of repeated field items", "in": "query", "required": false, "type": "array", "items": { "type": "string", "format": "uuid" }, "collectionFormat": "multi" } ], "tags": [ "ABitOfEverything" ] } }, "/v1/example/a_bit_of_everything/params/get/{singleNested.name}": { "get": { "operationId": "ABitOfEverythingService_CheckGetQueryParams", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbABitOfEverything" } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "singleNested.name", "description": "name is nested field.", "in": "path", "required": true, "type": "string" }, { "name": "singleNested.amount", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "singleNested.ok", "description": "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE: TRUE is true.", "in": "query", "required": false, "type": "string", "enum": [ "FALSE", "TRUE" ], "default": "FALSE" }, { "name": "uuid", "in": "query", "required": true, "type": "string", "format": "uuid", "pattern": "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}", "x-internal": true }, { "name": "floatValue", "description": "Float value field", "in": "query", "required": true, "type": "number", "format": "float", "default": "0.2" }, { "name": "doubleValue", "in": "query", "required": true, "type": "number", "format": "double" }, { "name": "int64Value", "in": "query", "required": true, "type": "string", "format": "int64" }, { "name": "uint64Value", "in": "query", "required": false, "type": "string", "format": "uint64" }, { "name": "int32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "fixed64Value", "in": "query", "required": false, "type": "string", "format": "uint64" }, { "name": "fixed32Value", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "boolValue", "in": "query", "required": false, "type": "boolean" }, { "name": "stringValue", "in": "query", "required": false, "type": "string" }, { "name": "bytesValue", "in": "query", "required": false, "type": "string", "format": "byte" }, { "name": "uint32Value", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "enumValue", "description": " - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "string", "enum": [ "ZERO", "ONE" ], "default": "ZERO" }, { "name": "pathEnumValue", "in": "query", "required": false, "type": "string", "enum": [ "ABC", "DEF" ], "default": "ABC" }, { "name": "nestedPathEnumValue", "in": "query", "required": false, "type": "string", "enum": [ "GHI", "JKL" ], "default": "GHI" }, { "name": "sfixed32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "sfixed64Value", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "sint32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "sint64Value", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "repeatedStringValue", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "oneofEmpty", "in": "query", "required": false, "type": "object" }, { "name": "oneofString", "in": "query", "required": false, "type": "string" }, { "name": "mapValue", "description": "map of numeric enum", "in": "query", "required": false }, { "name": "mappedStringValue", "description": "Map of string title\n\nMap of string description.", "in": "query", "required": false, "type": "string" }, { "name": "mappedNestedValue", "in": "query", "required": false }, { "name": "nonConventionalNameValue", "in": "query", "required": false, "type": "string" }, { "name": "timestampValue", "in": "query", "required": false, "type": "string", "format": "date-time" }, { "name": "repeatedEnumValue", "description": "repeated enum value. it is comma-separated in query\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "array", "items": { "type": "string", "enum": [ "ZERO", "ONE" ] }, "collectionFormat": "multi" }, { "name": "repeatedEnumAnnotation", "description": "Repeated numeric enum title\n\nRepeated numeric enum description.\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "array", "items": { "type": "string", "enum": [ "ZERO", "ONE" ] }, "collectionFormat": "multi" }, { "name": "enumValueAnnotation", "description": "Numeric enum title\n\nNumeric enum description.\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "string", "enum": [ "ZERO", "ONE" ], "default": "ZERO" }, { "name": "repeatedStringAnnotation", "description": "Repeated string title\n\nRepeated string description.", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "nestedAnnotation.amount", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "nestedAnnotation.ok", "description": "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE: TRUE is true.", "in": "query", "required": false, "type": "string", "enum": [ "FALSE", "TRUE" ], "default": "FALSE" }, { "name": "int64OverrideType", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "requiredStringViaFieldBehaviorAnnotation", "description": "mark a field as required in Open API definition", "in": "query", "required": true, "type": "string" }, { "name": "outputOnlyStringViaFieldBehaviorAnnotation", "description": "mark a field as readonly in Open API definition", "in": "query", "required": false, "type": "string" }, { "name": "optionalStringValue", "in": "query", "required": false, "type": "string" }, { "name": "productId", "description": "Test openapiv2 generation of repeated fields\n\nOnly digits are allowed.", "in": "query", "required": false, "type": "array", "items": { "type": "string", "maxLength": 19, "minLength": 1, "pattern": "^[0-9]+$" }, "collectionFormat": "multi" }, { "name": "optionalStringField", "description": "Test openapiv2 generation of required fields with annotation and jsonschema to reproduce", "in": "query", "required": false, "type": "string" }, { "name": "requiredStringField1", "in": "query", "required": true, "type": "string" }, { "name": "requiredStringField2", "in": "query", "required": true, "type": "string" }, { "name": "required_field_behavior_json_name_custom", "description": "Test openapiv2 handling of required json_name fields", "in": "query", "required": true, "type": "string" }, { "name": "required_field_schema_json_name_custom", "in": "query", "required": true, "type": "string" }, { "name": "trailingOnly", "description": "Trailing only", "in": "query", "required": false, "type": "string" }, { "name": "trailingOnlyDot", "description": "Trailing only dot.", "in": "query", "required": false, "type": "string" }, { "name": "trailingBoth", "description": "Leading both\n\nTrailing both.", "in": "query", "required": false, "type": "string" }, { "name": "trailingMultiline", "description": "Leading multiline\n\nThis is an example of a multi-line comment.\n\nTrailing multiline.", "in": "query", "required": false, "type": "string" }, { "name": "uuids", "description": "Specify a custom format of repeated field items", "in": "query", "required": false, "type": "array", "items": { "type": "string", "format": "uuid" }, "collectionFormat": "multi" } ], "tags": [ "ABitOfEverything" ] } }, "/v1/example/a_bit_of_everything/params/post/{stringValue}": { "post": { "operationId": "ABitOfEverythingService_CheckPostQueryParams", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbABitOfEverything" } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "stringValue", "in": "path", "required": true, "type": "string" }, { "name": "singleNested", "in": "body", "required": true, "schema": { "$ref": "#/definitions/ABitOfEverythingNested" } }, { "name": "uuid", "in": "query", "required": true, "type": "string", "format": "uuid", "pattern": "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}", "x-internal": true }, { "name": "floatValue", "description": "Float value field", "in": "query", "required": true, "type": "number", "format": "float", "default": "0.2" }, { "name": "doubleValue", "in": "query", "required": true, "type": "number", "format": "double" }, { "name": "int64Value", "in": "query", "required": true, "type": "string", "format": "int64" }, { "name": "uint64Value", "in": "query", "required": false, "type": "string", "format": "uint64" }, { "name": "int32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "fixed64Value", "in": "query", "required": false, "type": "string", "format": "uint64" }, { "name": "fixed32Value", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "boolValue", "in": "query", "required": false, "type": "boolean" }, { "name": "bytesValue", "in": "query", "required": false, "type": "string", "format": "byte" }, { "name": "uint32Value", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "enumValue", "description": " - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "string", "enum": [ "ZERO", "ONE" ], "default": "ZERO" }, { "name": "pathEnumValue", "in": "query", "required": false, "type": "string", "enum": [ "ABC", "DEF" ], "default": "ABC" }, { "name": "nestedPathEnumValue", "in": "query", "required": false, "type": "string", "enum": [ "GHI", "JKL" ], "default": "GHI" }, { "name": "sfixed32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "sfixed64Value", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "sint32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "sint64Value", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "repeatedStringValue", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "oneofEmpty", "in": "query", "required": false, "type": "object" }, { "name": "oneofString", "in": "query", "required": false, "type": "string" }, { "name": "mapValue", "description": "map of numeric enum", "in": "query", "required": false }, { "name": "mappedStringValue", "description": "Map of string title\n\nMap of string description.", "in": "query", "required": false, "type": "string" }, { "name": "mappedNestedValue", "in": "query", "required": false }, { "name": "nonConventionalNameValue", "in": "query", "required": false, "type": "string" }, { "name": "timestampValue", "in": "query", "required": false, "type": "string", "format": "date-time" }, { "name": "repeatedEnumValue", "description": "repeated enum value. it is comma-separated in query\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "array", "items": { "type": "string", "enum": [ "ZERO", "ONE" ] }, "collectionFormat": "multi" }, { "name": "repeatedEnumAnnotation", "description": "Repeated numeric enum title\n\nRepeated numeric enum description.\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "array", "items": { "type": "string", "enum": [ "ZERO", "ONE" ] }, "collectionFormat": "multi" }, { "name": "enumValueAnnotation", "description": "Numeric enum title\n\nNumeric enum description.\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "string", "enum": [ "ZERO", "ONE" ], "default": "ZERO" }, { "name": "repeatedStringAnnotation", "description": "Repeated string title\n\nRepeated string description.", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "nestedAnnotation.name", "description": "name is nested field.", "in": "query", "required": false, "type": "string" }, { "name": "nestedAnnotation.amount", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "nestedAnnotation.ok", "description": "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE: TRUE is true.", "in": "query", "required": false, "type": "string", "enum": [ "FALSE", "TRUE" ], "default": "FALSE" }, { "name": "int64OverrideType", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "requiredStringViaFieldBehaviorAnnotation", "description": "mark a field as required in Open API definition", "in": "query", "required": true, "type": "string" }, { "name": "outputOnlyStringViaFieldBehaviorAnnotation", "description": "mark a field as readonly in Open API definition", "in": "query", "required": false, "type": "string" }, { "name": "optionalStringValue", "in": "query", "required": false, "type": "string" }, { "name": "productId", "description": "Test openapiv2 generation of repeated fields\n\nOnly digits are allowed.", "in": "query", "required": false, "type": "array", "items": { "type": "string", "maxLength": 19, "minLength": 1, "pattern": "^[0-9]+$" }, "collectionFormat": "multi" }, { "name": "optionalStringField", "description": "Test openapiv2 generation of required fields with annotation and jsonschema to reproduce", "in": "query", "required": false, "type": "string" }, { "name": "requiredStringField1", "in": "query", "required": true, "type": "string" }, { "name": "requiredStringField2", "in": "query", "required": true, "type": "string" }, { "name": "required_field_behavior_json_name_custom", "description": "Test openapiv2 handling of required json_name fields", "in": "query", "required": true, "type": "string" }, { "name": "required_field_schema_json_name_custom", "in": "query", "required": true, "type": "string" }, { "name": "trailingOnly", "description": "Trailing only", "in": "query", "required": false, "type": "string" }, { "name": "trailingOnlyDot", "description": "Trailing only dot.", "in": "query", "required": false, "type": "string" }, { "name": "trailingBoth", "description": "Leading both\n\nTrailing both.", "in": "query", "required": false, "type": "string" }, { "name": "trailingMultiline", "description": "Leading multiline\n\nThis is an example of a multi-line comment.\n\nTrailing multiline.", "in": "query", "required": false, "type": "string" }, { "name": "uuids", "description": "Specify a custom format of repeated field items", "in": "query", "required": false, "type": "array", "items": { "type": "string", "format": "uuid" }, "collectionFormat": "multi" } ], "tags": [ "ABitOfEverything" ] } }, "/v1/example/a_bit_of_everything/query/{uuidName}": { "get": { "operationId": "ABitOfEverythingService_GetQuery", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "uuidName", "in": "path", "required": true, "type": "string", "format": "uuid", "x-internal": true }, { "name": "singleNested.name", "description": "name is nested field.", "in": "query", "required": false, "type": "string" }, { "name": "singleNested.amount", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "singleNested.ok", "description": "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE: TRUE is true.", "in": "query", "required": false, "type": "string", "enum": [ "FALSE", "TRUE" ], "default": "FALSE" }, { "name": "floatValue", "description": "Float value field", "in": "query", "required": true, "type": "number", "format": "float", "default": "0.2" }, { "name": "doubleValue", "in": "query", "required": true, "type": "number", "format": "double" }, { "name": "int64Value", "in": "query", "required": true, "type": "string", "format": "int64" }, { "name": "uint64Value", "in": "query", "required": false, "type": "string", "format": "uint64" }, { "name": "int32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "fixed64Value", "in": "query", "required": false, "type": "string", "format": "uint64" }, { "name": "fixed32Value", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "boolValue", "in": "query", "required": false, "type": "boolean" }, { "name": "stringValue", "in": "query", "required": false, "type": "string" }, { "name": "bytesValue", "in": "query", "required": false, "type": "string", "format": "byte" }, { "name": "uint32Value", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "enumValue", "description": " - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "string", "enum": [ "ZERO", "ONE" ], "default": "ZERO" }, { "name": "pathEnumValue", "in": "query", "required": false, "type": "string", "enum": [ "ABC", "DEF" ], "default": "ABC" }, { "name": "nestedPathEnumValue", "in": "query", "required": false, "type": "string", "enum": [ "GHI", "JKL" ], "default": "GHI" }, { "name": "sfixed32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "sfixed64Value", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "sint32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "sint64Value", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "repeatedStringValue", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "oneofEmpty", "in": "query", "required": false, "type": "object" }, { "name": "oneofString", "in": "query", "required": false, "type": "string" }, { "name": "mapValue", "description": "map of numeric enum", "in": "query", "required": false }, { "name": "mappedStringValue", "description": "Map of string title\n\nMap of string description.", "in": "query", "required": false, "type": "string" }, { "name": "mappedNestedValue", "in": "query", "required": false }, { "name": "nonConventionalNameValue", "in": "query", "required": false, "type": "string" }, { "name": "timestampValue", "in": "query", "required": false, "type": "string", "format": "date-time" }, { "name": "repeatedEnumValue", "description": "repeated enum value. it is comma-separated in query\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "array", "items": { "type": "string", "enum": [ "ZERO", "ONE" ] }, "collectionFormat": "multi" }, { "name": "repeatedEnumAnnotation", "description": "Repeated numeric enum title\n\nRepeated numeric enum description.\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "array", "items": { "type": "string", "enum": [ "ZERO", "ONE" ] }, "collectionFormat": "multi" }, { "name": "enumValueAnnotation", "description": "Numeric enum title\n\nNumeric enum description.\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "string", "enum": [ "ZERO", "ONE" ], "default": "ZERO" }, { "name": "repeatedStringAnnotation", "description": "Repeated string title\n\nRepeated string description.", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "nestedAnnotation.name", "description": "name is nested field.", "in": "query", "required": false, "type": "string" }, { "name": "nestedAnnotation.amount", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "nestedAnnotation.ok", "description": "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE: TRUE is true.", "in": "query", "required": false, "type": "string", "enum": [ "FALSE", "TRUE" ], "default": "FALSE" }, { "name": "int64OverrideType", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "requiredStringViaFieldBehaviorAnnotation", "description": "mark a field as required in Open API definition", "in": "query", "required": true, "type": "string" }, { "name": "outputOnlyStringViaFieldBehaviorAnnotation", "description": "mark a field as readonly in Open API definition", "in": "query", "required": false, "type": "string" }, { "name": "optionalStringValue", "in": "query", "required": false, "type": "string" }, { "name": "productId", "description": "Test openapiv2 generation of repeated fields\n\nOnly digits are allowed.", "in": "query", "required": false, "type": "array", "items": { "type": "string", "maxLength": 19, "minLength": 1, "pattern": "^[0-9]+$" }, "collectionFormat": "multi" }, { "name": "optionalStringField", "description": "Test openapiv2 generation of required fields with annotation and jsonschema to reproduce", "in": "query", "required": false, "type": "string" }, { "name": "requiredStringField1", "in": "query", "required": true, "type": "string" }, { "name": "requiredStringField2", "in": "query", "required": true, "type": "string" }, { "name": "required_field_behavior_json_name_custom", "description": "Test openapiv2 handling of required json_name fields", "in": "query", "required": true, "type": "string" }, { "name": "required_field_schema_json_name_custom", "in": "query", "required": true, "type": "string" }, { "name": "trailingOnly", "description": "Trailing only", "in": "query", "required": false, "type": "string" }, { "name": "trailingOnlyDot", "description": "Trailing only dot.", "in": "query", "required": false, "type": "string" }, { "name": "trailingBoth", "description": "Leading both\n\nTrailing both.", "in": "query", "required": false, "type": "string" }, { "name": "trailingMultiline", "description": "Leading multiline\n\nThis is an example of a multi-line comment.\n\nTrailing multiline.", "in": "query", "required": false, "type": "string" }, { "name": "uuids", "description": "Specify a custom format of repeated field items", "in": "query", "required": false, "type": "array", "items": { "type": "string", "format": "uuid" }, "collectionFormat": "multi" } ], "tags": [ "ABitOfEverything" ], "deprecated": true, "security": [], "externalDocs": { "description": "Find out more about GetQuery", "url": "https://github.com/grpc-ecosystem/grpc-gateway" } } }, "/v1/example/a_bit_of_everything/{floatValue}/{doubleValue}/{int64Value}/separator/{uint64Value}/{int32Value}/{fixed64Value}/{fixed32Value}/{boolValue}/{stringValue}/{uint32Value}/{sfixed32Value}/{sfixed64Value}/{sint32Value}/{sint64Value}/{nonConventionalNameValue}/{enumValue}/{pathEnumValue}/{nestedPathEnumValue}/{enumValueAnnotation}": { "post": { "summary": "Create a new ABitOfEverything", "description": "This API creates a new ABitOfEverything", "operationId": "ABitOfEverythingService_Create", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbABitOfEverything" } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "floatValue", "description": "Float value field", "in": "path", "required": true, "type": "number", "format": "float", "default": "0.2" }, { "name": "doubleValue", "in": "path", "required": true, "type": "number", "format": "double" }, { "name": "int64Value", "in": "path", "required": true, "type": "string", "format": "int64" }, { "name": "uint64Value", "in": "path", "required": true, "type": "string", "format": "uint64" }, { "name": "int32Value", "in": "path", "required": true, "type": "integer", "format": "int32" }, { "name": "fixed64Value", "in": "path", "required": true, "type": "string", "format": "uint64" }, { "name": "fixed32Value", "in": "path", "required": true, "type": "integer", "format": "int64" }, { "name": "boolValue", "in": "path", "required": true, "type": "boolean" }, { "name": "stringValue", "in": "path", "required": true, "type": "string", "pattern": "strprefix/[^/]+" }, { "name": "uint32Value", "in": "path", "required": true, "type": "integer", "format": "int64" }, { "name": "sfixed32Value", "in": "path", "required": true, "type": "integer", "format": "int32" }, { "name": "sfixed64Value", "in": "path", "required": true, "type": "string", "format": "int64" }, { "name": "sint32Value", "in": "path", "required": true, "type": "integer", "format": "int32" }, { "name": "sint64Value", "in": "path", "required": true, "type": "string", "format": "int64" }, { "name": "nonConventionalNameValue", "in": "path", "required": true, "type": "string" }, { "name": "enumValue", "in": "path", "required": true, "type": "string", "enum": [ "ZERO", "ONE" ] }, { "name": "pathEnumValue", "in": "path", "required": true, "type": "string", "enum": [ "ABC", "DEF" ] }, { "name": "nestedPathEnumValue", "in": "path", "required": true, "type": "string", "enum": [ "GHI", "JKL" ] }, { "name": "enumValueAnnotation", "description": "Numeric enum description.", "in": "path", "required": true, "type": "string", "enum": [ "ZERO", "ONE" ] }, { "name": "singleNested.name", "description": "name is nested field.", "in": "query", "required": false, "type": "string" }, { "name": "singleNested.amount", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "singleNested.ok", "description": "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE: TRUE is true.", "in": "query", "required": false, "type": "string", "enum": [ "FALSE", "TRUE" ], "default": "FALSE" }, { "name": "uuid", "in": "query", "required": true, "type": "string", "format": "uuid", "pattern": "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}", "x-internal": true }, { "name": "bytesValue", "in": "query", "required": false, "type": "string", "format": "byte" }, { "name": "repeatedStringValue", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "oneofEmpty", "in": "query", "required": false, "type": "object" }, { "name": "oneofString", "in": "query", "required": false, "type": "string" }, { "name": "mapValue", "description": "map of numeric enum", "in": "query", "required": false }, { "name": "mappedStringValue", "description": "Map of string title\n\nMap of string description.", "in": "query", "required": false, "type": "string" }, { "name": "mappedNestedValue", "in": "query", "required": false }, { "name": "timestampValue", "in": "query", "required": false, "type": "string", "format": "date-time" }, { "name": "repeatedEnumValue", "description": "repeated enum value. it is comma-separated in query\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "array", "items": { "type": "string", "enum": [ "ZERO", "ONE" ] }, "collectionFormat": "multi" }, { "name": "repeatedEnumAnnotation", "description": "Repeated numeric enum title\n\nRepeated numeric enum description.\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "array", "items": { "type": "string", "enum": [ "ZERO", "ONE" ] }, "collectionFormat": "multi" }, { "name": "repeatedStringAnnotation", "description": "Repeated string title\n\nRepeated string description.", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "nestedAnnotation.name", "description": "name is nested field.", "in": "query", "required": false, "type": "string" }, { "name": "nestedAnnotation.amount", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "nestedAnnotation.ok", "description": "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE: TRUE is true.", "in": "query", "required": false, "type": "string", "enum": [ "FALSE", "TRUE" ], "default": "FALSE" }, { "name": "int64OverrideType", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "requiredStringViaFieldBehaviorAnnotation", "description": "mark a field as required in Open API definition", "in": "query", "required": true, "type": "string" }, { "name": "outputOnlyStringViaFieldBehaviorAnnotation", "description": "mark a field as readonly in Open API definition", "in": "query", "required": false, "type": "string" }, { "name": "optionalStringValue", "in": "query", "required": false, "type": "string" }, { "name": "productId", "description": "Test openapiv2 generation of repeated fields\n\nOnly digits are allowed.", "in": "query", "required": false, "type": "array", "items": { "type": "string", "maxLength": 19, "minLength": 1, "pattern": "^[0-9]+$" }, "collectionFormat": "multi" }, { "name": "optionalStringField", "description": "Test openapiv2 generation of required fields with annotation and jsonschema to reproduce", "in": "query", "required": false, "type": "string" }, { "name": "requiredStringField1", "in": "query", "required": true, "type": "string" }, { "name": "requiredStringField2", "in": "query", "required": true, "type": "string" }, { "name": "required_field_behavior_json_name_custom", "description": "Test openapiv2 handling of required json_name fields", "in": "query", "required": true, "type": "string" }, { "name": "required_field_schema_json_name_custom", "in": "query", "required": true, "type": "string" }, { "name": "trailingOnly", "description": "Trailing only", "in": "query", "required": false, "type": "string" }, { "name": "trailingOnlyDot", "description": "Trailing only dot.", "in": "query", "required": false, "type": "string" }, { "name": "trailingBoth", "description": "Leading both\n\nTrailing both.", "in": "query", "required": false, "type": "string" }, { "name": "trailingMultiline", "description": "Leading multiline\n\nThis is an example of a multi-line comment.\n\nTrailing multiline.", "in": "query", "required": false, "type": "string" }, { "name": "uuids", "description": "Specify a custom format of repeated field items", "in": "query", "required": false, "type": "array", "items": { "type": "string", "format": "uuid" }, "collectionFormat": "multi" } ], "tags": [ "ABitOfEverything" ] } }, "/v1/example/a_bit_of_everything/{uuidName}": { "put": { "operationId": "ABitOfEverythingService_Update", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "uuidName", "in": "path", "required": true, "type": "string", "format": "uuid", "x-internal": true }, { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbABitOfEverythingServiceUpdateBody" } } ], "tags": [ "ABitOfEverything" ] }, "head": { "operationId": "ABitOfEverythingService_Exists", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "uuidName", "in": "path", "required": true, "type": "string", "format": "uuid", "x-internal": true }, { "name": "singleNested.name", "description": "name is nested field.", "in": "query", "required": false, "type": "string" }, { "name": "singleNested.amount", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "singleNested.ok", "description": "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE: TRUE is true.", "in": "query", "required": false, "type": "string", "enum": [ "FALSE", "TRUE" ], "default": "FALSE" }, { "name": "floatValue", "description": "Float value field", "in": "query", "required": true, "type": "number", "format": "float", "default": "0.2" }, { "name": "doubleValue", "in": "query", "required": true, "type": "number", "format": "double" }, { "name": "int64Value", "in": "query", "required": true, "type": "string", "format": "int64" }, { "name": "uint64Value", "in": "query", "required": false, "type": "string", "format": "uint64" }, { "name": "int32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "fixed64Value", "in": "query", "required": false, "type": "string", "format": "uint64" }, { "name": "fixed32Value", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "boolValue", "in": "query", "required": false, "type": "boolean" }, { "name": "stringValue", "in": "query", "required": false, "type": "string" }, { "name": "bytesValue", "in": "query", "required": false, "type": "string", "format": "byte" }, { "name": "uint32Value", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "enumValue", "description": " - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "string", "enum": [ "ZERO", "ONE" ], "default": "ZERO" }, { "name": "pathEnumValue", "in": "query", "required": false, "type": "string", "enum": [ "ABC", "DEF" ], "default": "ABC" }, { "name": "nestedPathEnumValue", "in": "query", "required": false, "type": "string", "enum": [ "GHI", "JKL" ], "default": "GHI" }, { "name": "sfixed32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "sfixed64Value", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "sint32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "sint64Value", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "repeatedStringValue", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "oneofEmpty", "in": "query", "required": false, "type": "object" }, { "name": "oneofString", "in": "query", "required": false, "type": "string" }, { "name": "mapValue", "description": "map of numeric enum", "in": "query", "required": false }, { "name": "mappedStringValue", "description": "Map of string title\n\nMap of string description.", "in": "query", "required": false, "type": "string" }, { "name": "mappedNestedValue", "in": "query", "required": false }, { "name": "nonConventionalNameValue", "in": "query", "required": false, "type": "string" }, { "name": "timestampValue", "in": "query", "required": false, "type": "string", "format": "date-time" }, { "name": "repeatedEnumValue", "description": "repeated enum value. it is comma-separated in query\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "array", "items": { "type": "string", "enum": [ "ZERO", "ONE" ] }, "collectionFormat": "multi" }, { "name": "repeatedEnumAnnotation", "description": "Repeated numeric enum title\n\nRepeated numeric enum description.\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "array", "items": { "type": "string", "enum": [ "ZERO", "ONE" ] }, "collectionFormat": "multi" }, { "name": "enumValueAnnotation", "description": "Numeric enum title\n\nNumeric enum description.\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "string", "enum": [ "ZERO", "ONE" ], "default": "ZERO" }, { "name": "repeatedStringAnnotation", "description": "Repeated string title\n\nRepeated string description.", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "nestedAnnotation.name", "description": "name is nested field.", "in": "query", "required": false, "type": "string" }, { "name": "nestedAnnotation.amount", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "nestedAnnotation.ok", "description": "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE: TRUE is true.", "in": "query", "required": false, "type": "string", "enum": [ "FALSE", "TRUE" ], "default": "FALSE" }, { "name": "int64OverrideType", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "requiredStringViaFieldBehaviorAnnotation", "description": "mark a field as required in Open API definition", "in": "query", "required": true, "type": "string" }, { "name": "outputOnlyStringViaFieldBehaviorAnnotation", "description": "mark a field as readonly in Open API definition", "in": "query", "required": false, "type": "string" }, { "name": "optionalStringValue", "in": "query", "required": false, "type": "string" }, { "name": "productId", "description": "Test openapiv2 generation of repeated fields\n\nOnly digits are allowed.", "in": "query", "required": false, "type": "array", "items": { "type": "string", "maxLength": 19, "minLength": 1, "pattern": "^[0-9]+$" }, "collectionFormat": "multi" }, { "name": "optionalStringField", "description": "Test openapiv2 generation of required fields with annotation and jsonschema to reproduce", "in": "query", "required": false, "type": "string" }, { "name": "requiredStringField1", "in": "query", "required": true, "type": "string" }, { "name": "requiredStringField2", "in": "query", "required": true, "type": "string" }, { "name": "required_field_behavior_json_name_custom", "description": "Test openapiv2 handling of required json_name fields", "in": "query", "required": true, "type": "string" }, { "name": "required_field_schema_json_name_custom", "in": "query", "required": true, "type": "string" }, { "name": "trailingOnly", "description": "Trailing only", "in": "query", "required": false, "type": "string" }, { "name": "trailingOnlyDot", "description": "Trailing only dot.", "in": "query", "required": false, "type": "string" }, { "name": "trailingBoth", "description": "Leading both\n\nTrailing both.", "in": "query", "required": false, "type": "string" }, { "name": "trailingMultiline", "description": "Leading multiline\n\nThis is an example of a multi-line comment.\n\nTrailing multiline.", "in": "query", "required": false, "type": "string" }, { "name": "uuids", "description": "Specify a custom format of repeated field items", "in": "query", "required": false, "type": "array", "items": { "type": "string", "format": "uuid" }, "collectionFormat": "multi" } ], "tags": [ "ABitOfEverything" ] }, "options": { "operationId": "ABitOfEverythingService_CustomOptionsRequest", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "uuidName", "in": "path", "required": true, "type": "string", "format": "uuid", "x-internal": true }, { "name": "singleNested.name", "description": "name is nested field.", "in": "query", "required": false, "type": "string" }, { "name": "singleNested.amount", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "singleNested.ok", "description": "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE: TRUE is true.", "in": "query", "required": false, "type": "string", "enum": [ "FALSE", "TRUE" ], "default": "FALSE" }, { "name": "floatValue", "description": "Float value field", "in": "query", "required": true, "type": "number", "format": "float", "default": "0.2" }, { "name": "doubleValue", "in": "query", "required": true, "type": "number", "format": "double" }, { "name": "int64Value", "in": "query", "required": true, "type": "string", "format": "int64" }, { "name": "uint64Value", "in": "query", "required": false, "type": "string", "format": "uint64" }, { "name": "int32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "fixed64Value", "in": "query", "required": false, "type": "string", "format": "uint64" }, { "name": "fixed32Value", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "boolValue", "in": "query", "required": false, "type": "boolean" }, { "name": "stringValue", "in": "query", "required": false, "type": "string" }, { "name": "bytesValue", "in": "query", "required": false, "type": "string", "format": "byte" }, { "name": "uint32Value", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "enumValue", "description": " - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "string", "enum": [ "ZERO", "ONE" ], "default": "ZERO" }, { "name": "pathEnumValue", "in": "query", "required": false, "type": "string", "enum": [ "ABC", "DEF" ], "default": "ABC" }, { "name": "nestedPathEnumValue", "in": "query", "required": false, "type": "string", "enum": [ "GHI", "JKL" ], "default": "GHI" }, { "name": "sfixed32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "sfixed64Value", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "sint32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "sint64Value", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "repeatedStringValue", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "oneofEmpty", "in": "query", "required": false, "type": "object" }, { "name": "oneofString", "in": "query", "required": false, "type": "string" }, { "name": "mapValue", "description": "map of numeric enum", "in": "query", "required": false }, { "name": "mappedStringValue", "description": "Map of string title\n\nMap of string description.", "in": "query", "required": false, "type": "string" }, { "name": "mappedNestedValue", "in": "query", "required": false }, { "name": "nonConventionalNameValue", "in": "query", "required": false, "type": "string" }, { "name": "timestampValue", "in": "query", "required": false, "type": "string", "format": "date-time" }, { "name": "repeatedEnumValue", "description": "repeated enum value. it is comma-separated in query\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "array", "items": { "type": "string", "enum": [ "ZERO", "ONE" ] }, "collectionFormat": "multi" }, { "name": "repeatedEnumAnnotation", "description": "Repeated numeric enum title\n\nRepeated numeric enum description.\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "array", "items": { "type": "string", "enum": [ "ZERO", "ONE" ] }, "collectionFormat": "multi" }, { "name": "enumValueAnnotation", "description": "Numeric enum title\n\nNumeric enum description.\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "string", "enum": [ "ZERO", "ONE" ], "default": "ZERO" }, { "name": "repeatedStringAnnotation", "description": "Repeated string title\n\nRepeated string description.", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "nestedAnnotation.name", "description": "name is nested field.", "in": "query", "required": false, "type": "string" }, { "name": "nestedAnnotation.amount", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "nestedAnnotation.ok", "description": "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE: TRUE is true.", "in": "query", "required": false, "type": "string", "enum": [ "FALSE", "TRUE" ], "default": "FALSE" }, { "name": "int64OverrideType", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "requiredStringViaFieldBehaviorAnnotation", "description": "mark a field as required in Open API definition", "in": "query", "required": true, "type": "string" }, { "name": "outputOnlyStringViaFieldBehaviorAnnotation", "description": "mark a field as readonly in Open API definition", "in": "query", "required": false, "type": "string" }, { "name": "optionalStringValue", "in": "query", "required": false, "type": "string" }, { "name": "productId", "description": "Test openapiv2 generation of repeated fields\n\nOnly digits are allowed.", "in": "query", "required": false, "type": "array", "items": { "type": "string", "maxLength": 19, "minLength": 1, "pattern": "^[0-9]+$" }, "collectionFormat": "multi" }, { "name": "optionalStringField", "description": "Test openapiv2 generation of required fields with annotation and jsonschema to reproduce", "in": "query", "required": false, "type": "string" }, { "name": "requiredStringField1", "in": "query", "required": true, "type": "string" }, { "name": "requiredStringField2", "in": "query", "required": true, "type": "string" }, { "name": "required_field_behavior_json_name_custom", "description": "Test openapiv2 handling of required json_name fields", "in": "query", "required": true, "type": "string" }, { "name": "required_field_schema_json_name_custom", "in": "query", "required": true, "type": "string" }, { "name": "trailingOnly", "description": "Trailing only", "in": "query", "required": false, "type": "string" }, { "name": "trailingOnlyDot", "description": "Trailing only dot.", "in": "query", "required": false, "type": "string" }, { "name": "trailingBoth", "description": "Leading both\n\nTrailing both.", "in": "query", "required": false, "type": "string" }, { "name": "trailingMultiline", "description": "Leading multiline\n\nThis is an example of a multi-line comment.\n\nTrailing multiline.", "in": "query", "required": false, "type": "string" }, { "name": "uuids", "description": "Specify a custom format of repeated field items", "in": "query", "required": false, "type": "array", "items": { "type": "string", "format": "uuid" }, "collectionFormat": "multi" } ], "tags": [ "ABitOfEverything" ] } }, "/v1/example/a_bit_of_everything/{uuidName}:custom": { "post": { "operationId": "ABitOfEverythingService_Custom", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbABitOfEverything" } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "uuidName", "in": "path", "required": true, "type": "string", "format": "uuid", "x-internal": true }, { "name": "singleNested.name", "description": "name is nested field.", "in": "query", "required": false, "type": "string" }, { "name": "singleNested.amount", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "singleNested.ok", "description": "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE: TRUE is true.", "in": "query", "required": false, "type": "string", "enum": [ "FALSE", "TRUE" ], "default": "FALSE" }, { "name": "floatValue", "description": "Float value field", "in": "query", "required": true, "type": "number", "format": "float", "default": "0.2" }, { "name": "doubleValue", "in": "query", "required": true, "type": "number", "format": "double" }, { "name": "int64Value", "in": "query", "required": true, "type": "string", "format": "int64" }, { "name": "uint64Value", "in": "query", "required": false, "type": "string", "format": "uint64" }, { "name": "int32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "fixed64Value", "in": "query", "required": false, "type": "string", "format": "uint64" }, { "name": "fixed32Value", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "boolValue", "in": "query", "required": false, "type": "boolean" }, { "name": "stringValue", "in": "query", "required": false, "type": "string" }, { "name": "bytesValue", "in": "query", "required": false, "type": "string", "format": "byte" }, { "name": "uint32Value", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "enumValue", "description": " - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "string", "enum": [ "ZERO", "ONE" ], "default": "ZERO" }, { "name": "pathEnumValue", "in": "query", "required": false, "type": "string", "enum": [ "ABC", "DEF" ], "default": "ABC" }, { "name": "nestedPathEnumValue", "in": "query", "required": false, "type": "string", "enum": [ "GHI", "JKL" ], "default": "GHI" }, { "name": "sfixed32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "sfixed64Value", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "sint32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "sint64Value", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "repeatedStringValue", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "oneofEmpty", "in": "query", "required": false, "type": "object" }, { "name": "oneofString", "in": "query", "required": false, "type": "string" }, { "name": "mapValue", "description": "map of numeric enum", "in": "query", "required": false }, { "name": "mappedStringValue", "description": "Map of string title\n\nMap of string description.", "in": "query", "required": false, "type": "string" }, { "name": "mappedNestedValue", "in": "query", "required": false }, { "name": "nonConventionalNameValue", "in": "query", "required": false, "type": "string" }, { "name": "timestampValue", "in": "query", "required": false, "type": "string", "format": "date-time" }, { "name": "repeatedEnumValue", "description": "repeated enum value. it is comma-separated in query\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "array", "items": { "type": "string", "enum": [ "ZERO", "ONE" ] }, "collectionFormat": "multi" }, { "name": "repeatedEnumAnnotation", "description": "Repeated numeric enum title\n\nRepeated numeric enum description.\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "array", "items": { "type": "string", "enum": [ "ZERO", "ONE" ] }, "collectionFormat": "multi" }, { "name": "enumValueAnnotation", "description": "Numeric enum title\n\nNumeric enum description.\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "string", "enum": [ "ZERO", "ONE" ], "default": "ZERO" }, { "name": "repeatedStringAnnotation", "description": "Repeated string title\n\nRepeated string description.", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "nestedAnnotation.name", "description": "name is nested field.", "in": "query", "required": false, "type": "string" }, { "name": "nestedAnnotation.amount", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "nestedAnnotation.ok", "description": "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE: TRUE is true.", "in": "query", "required": false, "type": "string", "enum": [ "FALSE", "TRUE" ], "default": "FALSE" }, { "name": "int64OverrideType", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "requiredStringViaFieldBehaviorAnnotation", "description": "mark a field as required in Open API definition", "in": "query", "required": true, "type": "string" }, { "name": "outputOnlyStringViaFieldBehaviorAnnotation", "description": "mark a field as readonly in Open API definition", "in": "query", "required": false, "type": "string" }, { "name": "optionalStringValue", "in": "query", "required": false, "type": "string" }, { "name": "productId", "description": "Test openapiv2 generation of repeated fields\n\nOnly digits are allowed.", "in": "query", "required": false, "type": "array", "items": { "type": "string", "maxLength": 19, "minLength": 1, "pattern": "^[0-9]+$" }, "collectionFormat": "multi" }, { "name": "optionalStringField", "description": "Test openapiv2 generation of required fields with annotation and jsonschema to reproduce", "in": "query", "required": false, "type": "string" }, { "name": "requiredStringField1", "in": "query", "required": true, "type": "string" }, { "name": "requiredStringField2", "in": "query", "required": true, "type": "string" }, { "name": "required_field_behavior_json_name_custom", "description": "Test openapiv2 handling of required json_name fields", "in": "query", "required": true, "type": "string" }, { "name": "required_field_schema_json_name_custom", "in": "query", "required": true, "type": "string" }, { "name": "trailingOnly", "description": "Trailing only", "in": "query", "required": false, "type": "string" }, { "name": "trailingOnlyDot", "description": "Trailing only dot.", "in": "query", "required": false, "type": "string" }, { "name": "trailingBoth", "description": "Leading both\n\nTrailing both.", "in": "query", "required": false, "type": "string" }, { "name": "trailingMultiline", "description": "Leading multiline\n\nThis is an example of a multi-line comment.\n\nTrailing multiline.", "in": "query", "required": false, "type": "string" }, { "name": "uuids", "description": "Specify a custom format of repeated field items", "in": "query", "required": false, "type": "array", "items": { "type": "string", "format": "uuid" }, "collectionFormat": "multi" } ], "tags": [ "ABitOfEverything" ] } }, "/v1/example/a_bit_of_everything/{uuidName}:custom:custom": { "post": { "operationId": "ABitOfEverythingService_DoubleColon", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbABitOfEverything" } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "uuidName", "in": "path", "required": true, "type": "string", "format": "uuid", "x-internal": true }, { "name": "singleNested.name", "description": "name is nested field.", "in": "query", "required": false, "type": "string" }, { "name": "singleNested.amount", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "singleNested.ok", "description": "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE: TRUE is true.", "in": "query", "required": false, "type": "string", "enum": [ "FALSE", "TRUE" ], "default": "FALSE" }, { "name": "floatValue", "description": "Float value field", "in": "query", "required": true, "type": "number", "format": "float", "default": "0.2" }, { "name": "doubleValue", "in": "query", "required": true, "type": "number", "format": "double" }, { "name": "int64Value", "in": "query", "required": true, "type": "string", "format": "int64" }, { "name": "uint64Value", "in": "query", "required": false, "type": "string", "format": "uint64" }, { "name": "int32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "fixed64Value", "in": "query", "required": false, "type": "string", "format": "uint64" }, { "name": "fixed32Value", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "boolValue", "in": "query", "required": false, "type": "boolean" }, { "name": "stringValue", "in": "query", "required": false, "type": "string" }, { "name": "bytesValue", "in": "query", "required": false, "type": "string", "format": "byte" }, { "name": "uint32Value", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "enumValue", "description": " - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "string", "enum": [ "ZERO", "ONE" ], "default": "ZERO" }, { "name": "pathEnumValue", "in": "query", "required": false, "type": "string", "enum": [ "ABC", "DEF" ], "default": "ABC" }, { "name": "nestedPathEnumValue", "in": "query", "required": false, "type": "string", "enum": [ "GHI", "JKL" ], "default": "GHI" }, { "name": "sfixed32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "sfixed64Value", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "sint32Value", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "sint64Value", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "repeatedStringValue", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "oneofEmpty", "in": "query", "required": false, "type": "object" }, { "name": "oneofString", "in": "query", "required": false, "type": "string" }, { "name": "mapValue", "description": "map of numeric enum", "in": "query", "required": false }, { "name": "mappedStringValue", "description": "Map of string title\n\nMap of string description.", "in": "query", "required": false, "type": "string" }, { "name": "mappedNestedValue", "in": "query", "required": false }, { "name": "nonConventionalNameValue", "in": "query", "required": false, "type": "string" }, { "name": "timestampValue", "in": "query", "required": false, "type": "string", "format": "date-time" }, { "name": "repeatedEnumValue", "description": "repeated enum value. it is comma-separated in query\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "array", "items": { "type": "string", "enum": [ "ZERO", "ONE" ] }, "collectionFormat": "multi" }, { "name": "repeatedEnumAnnotation", "description": "Repeated numeric enum title\n\nRepeated numeric enum description.\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "array", "items": { "type": "string", "enum": [ "ZERO", "ONE" ] }, "collectionFormat": "multi" }, { "name": "enumValueAnnotation", "description": "Numeric enum title\n\nNumeric enum description.\n\n - ZERO: ZERO means 0\n - ONE: ONE means 1", "in": "query", "required": false, "type": "string", "enum": [ "ZERO", "ONE" ], "default": "ZERO" }, { "name": "repeatedStringAnnotation", "description": "Repeated string title\n\nRepeated string description.", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "nestedAnnotation.name", "description": "name is nested field.", "in": "query", "required": false, "type": "string" }, { "name": "nestedAnnotation.amount", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "nestedAnnotation.ok", "description": "DeepEnum description.\n\n - FALSE: FALSE is false.\n - TRUE: TRUE is true.", "in": "query", "required": false, "type": "string", "enum": [ "FALSE", "TRUE" ], "default": "FALSE" }, { "name": "int64OverrideType", "in": "query", "required": false, "type": "integer", "format": "int64" }, { "name": "requiredStringViaFieldBehaviorAnnotation", "description": "mark a field as required in Open API definition", "in": "query", "required": true, "type": "string" }, { "name": "outputOnlyStringViaFieldBehaviorAnnotation", "description": "mark a field as readonly in Open API definition", "in": "query", "required": false, "type": "string" }, { "name": "optionalStringValue", "in": "query", "required": false, "type": "string" }, { "name": "productId", "description": "Test openapiv2 generation of repeated fields\n\nOnly digits are allowed.", "in": "query", "required": false, "type": "array", "items": { "type": "string", "maxLength": 19, "minLength": 1, "pattern": "^[0-9]+$" }, "collectionFormat": "multi" }, { "name": "optionalStringField", "description": "Test openapiv2 generation of required fields with annotation and jsonschema to reproduce", "in": "query", "required": false, "type": "string" }, { "name": "requiredStringField1", "in": "query", "required": true, "type": "string" }, { "name": "requiredStringField2", "in": "query", "required": true, "type": "string" }, { "name": "required_field_behavior_json_name_custom", "description": "Test openapiv2 handling of required json_name fields", "in": "query", "required": true, "type": "string" }, { "name": "required_field_schema_json_name_custom", "in": "query", "required": true, "type": "string" }, { "name": "trailingOnly", "description": "Trailing only", "in": "query", "required": false, "type": "string" }, { "name": "trailingOnlyDot", "description": "Trailing only dot.", "in": "query", "required": false, "type": "string" }, { "name": "trailingBoth", "description": "Leading both\n\nTrailing both.", "in": "query", "required": false, "type": "string" }, { "name": "trailingMultiline", "description": "Leading multiline\n\nThis is an example of a multi-line comment.\n\nTrailing multiline.", "in": "query", "required": false, "type": "string" }, { "name": "uuids", "description": "Specify a custom format of repeated field items", "in": "query", "required": false, "type": "array", "items": { "type": "string", "format": "uuid" }, "collectionFormat": "multi" } ], "tags": [ "ABitOfEverything" ] } }, "/v1/example/a_bit_of_everything/{uuid}": { "get": { "operationId": "ABitOfEverythingService_Lookup", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbABitOfEverything" } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "uuid", "in": "path", "required": true, "type": "string" } ], "tags": [ "ABitOfEverything" ] }, "delete": { "operationId": "ABitOfEverythingService_Delete", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "uuid", "in": "path", "required": true, "type": "string" } ], "tags": [ "ABitOfEverything" ], "security": [ { "ApiKeyAuth": [], "OAuth2": [ "read", "write" ] } ], "x-irreversible": true } }, "/v1/example/a_bit_of_everything_repeated/{pathRepeatedFloatValue}/{pathRepeatedDoubleValue}/{pathRepeatedInt64Value}/{pathRepeatedUint64Value}/{pathRepeatedInt32Value}/{pathRepeatedFixed64Value}/{pathRepeatedFixed32Value}/{pathRepeatedBoolValue}/{pathRepeatedStringValue}/{pathRepeatedBytesValue}/{pathRepeatedUint32Value}/{pathRepeatedEnumValue}/{pathRepeatedSfixed32Value}/{pathRepeatedSfixed64Value}/{pathRepeatedSint32Value}/{pathRepeatedSint64Value}": { "get": { "operationId": "ABitOfEverythingService_GetRepeatedQuery", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbABitOfEverythingRepeated" } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "pathRepeatedFloatValue", "description": "repeated values. they are comma-separated in path", "in": "path", "required": true, "type": "array", "items": { "type": "number", "format": "float" }, "collectionFormat": "csv", "minItems": 1 }, { "name": "pathRepeatedDoubleValue", "in": "path", "required": true, "type": "array", "items": { "type": "number", "format": "double" }, "collectionFormat": "csv", "minItems": 1 }, { "name": "pathRepeatedInt64Value", "in": "path", "required": true, "type": "array", "items": { "type": "string", "format": "int64" }, "collectionFormat": "csv", "minItems": 1 }, { "name": "pathRepeatedUint64Value", "in": "path", "required": true, "type": "array", "items": { "type": "string", "format": "uint64" }, "collectionFormat": "csv", "minItems": 1 }, { "name": "pathRepeatedInt32Value", "in": "path", "required": true, "type": "array", "items": { "type": "integer", "format": "int32" }, "collectionFormat": "csv", "minItems": 1 }, { "name": "pathRepeatedFixed64Value", "in": "path", "required": true, "type": "array", "items": { "type": "string", "format": "uint64" }, "collectionFormat": "csv", "minItems": 1 }, { "name": "pathRepeatedFixed32Value", "in": "path", "required": true, "type": "array", "items": { "type": "integer", "format": "int64" }, "collectionFormat": "csv", "minItems": 1 }, { "name": "pathRepeatedBoolValue", "in": "path", "required": true, "type": "array", "items": { "type": "boolean" }, "collectionFormat": "csv", "minItems": 1 }, { "name": "pathRepeatedStringValue", "in": "path", "required": true, "type": "array", "items": { "type": "string" }, "collectionFormat": "csv", "minItems": 1 }, { "name": "pathRepeatedBytesValue", "in": "path", "required": true, "type": "array", "items": { "type": "string", "format": "byte" }, "collectionFormat": "csv", "minItems": 1 }, { "name": "pathRepeatedUint32Value", "in": "path", "required": true, "type": "array", "items": { "type": "integer", "format": "int64" }, "collectionFormat": "csv", "minItems": 1 }, { "name": "pathRepeatedEnumValue", "in": "path", "required": true, "type": "array", "items": { "type": "string", "enum": [ "ZERO", "ONE" ] }, "collectionFormat": "csv", "minItems": 1 }, { "name": "pathRepeatedSfixed32Value", "in": "path", "required": true, "type": "array", "items": { "type": "integer", "format": "int32" }, "collectionFormat": "csv", "minItems": 1 }, { "name": "pathRepeatedSfixed64Value", "in": "path", "required": true, "type": "array", "items": { "type": "string", "format": "int64" }, "collectionFormat": "csv", "minItems": 1 }, { "name": "pathRepeatedSint32Value", "in": "path", "required": true, "type": "array", "items": { "type": "integer", "format": "int32" }, "collectionFormat": "csv", "minItems": 1 }, { "name": "pathRepeatedSint64Value", "in": "path", "required": true, "type": "array", "items": { "type": "string", "format": "int64" }, "collectionFormat": "csv", "minItems": 1 } ], "tags": [ "ABitOfEverything" ] } }, "/v1/example/checkStatus": { "get": { "operationId": "ABitOfEverythingService_CheckStatus", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbCheckStatusResponse" } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "tags": [ "ABitOfEverything" ] } }, "/v1/example/deep_path/{singleNested.name}": { "post": { "operationId": "ABitOfEverythingService_DeepPathEcho", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbABitOfEverything" } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "singleNested.name", "description": "name is nested field.", "in": "path", "required": true, "type": "string" }, { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/ABitOfEverythingServiceDeepPathEchoBody" } } ], "tags": [ "ABitOfEverything" ] } }, "/v1/example/oneofenum": { "post": { "operationId": "ABitOfEverythingService_PostOneofEnum", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "exampleEnum", "in": "body", "required": true, "schema": { "$ref": "#/definitions/oneofenumExampleEnum" } } ], "tags": [ "ABitOfEverything" ] } }, "/v1/example/requiredmessagetype": { "post": { "operationId": "ABitOfEverythingService_PostRequiredMessageType", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbRequiredMessageTypeRequest" } } ], "tags": [ "ABitOfEverything" ] } }, "/v1/example/snake/{who}/{what}/{where}": { "get": { "operationId": "SnakeEnumService_SnakeEnum", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbSnakeEnumResponse" } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "who", "in": "path", "required": true, "type": "string", "enum": [ "value_e", "value_f" ] }, { "name": "what", "in": "path", "required": true, "type": "string", "enum": [ "value_c", "value_d" ] }, { "name": "where", "in": "path", "required": true, "type": "string", "enum": [ "value_x", "value_y" ] } ], "tags": [ "SnakeEnumService" ] } }, "/v1/{book.name}": { "patch": { "operationId": "ABitOfEverythingService_UpdateBook", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbBook" } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "book.name", "description": "The resource name of the book.\n\nFormat: `publishers/{publisher}/books/{book}`\n\nExample: `publishers/1257894000000000000/books/my-book`", "in": "path", "required": true, "type": "string", "pattern": "publishers/[^/]+/books/[^/]+" }, { "name": "book", "description": "The book to update.\n\nThe book's `name` field is used to identify the book to be updated.\nFormat: publishers/{publisher}/books/{book}", "in": "body", "required": true, "schema": { "type": "object", "properties": { "id": { "type": "string", "description": "Output only. The book's ID.", "readOnly": true }, "createTime": { "type": "string", "format": "date-time", "description": "Output only. Creation time of the book.", "readOnly": true } }, "description": "The book's `name` field is used to identify the book to be updated.\nFormat: publishers/{publisher}/books/{book}", "title": "The book to update." } }, { "name": "allowMissing", "description": "If set to true, and the book is not found, a new book will be created.\nIn this situation, `update_mask` is ignored.", "in": "query", "required": false, "type": "boolean" } ], "tags": [ "ABitOfEverything" ] } }, "/v1/{parent}/books": { "post": { "summary": "Create a book.", "operationId": "ABitOfEverythingService_CreateBook", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbBook" } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "parent", "description": "The publisher in which to create the book.\n\nFormat: `publishers/{publisher}`\n\nExample: `publishers/1257894000000000000`", "in": "path", "required": true, "type": "string", "pattern": "publishers/[^/]+" }, { "name": "book", "description": "The book to create.", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbBook" } }, { "name": "bookId", "description": "The ID to use for the book.\n\nThis must start with an alphanumeric character.", "in": "query", "required": false, "type": "string" } ], "tags": [ "ABitOfEverything" ] } }, "/v2/example/a_bit_of_everything/{uuidName}": { "put": { "operationId": "ABitOfEverythingService_UpdateV2", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "uuidName", "in": "path", "required": true, "type": "string", "format": "uuid", "x-internal": true }, { "name": "abe", "description": "A bit of everything\n\nIntentionally complicated message type to cover many features of Protobuf.", "in": "body", "required": true, "schema": { "type": "object", "example": { "int64_value": 12, "double_value": 12.3 }, "properties": { "singleNested": { "$ref": "#/definitions/ABitOfEverythingNested" }, "nested": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/ABitOfEverythingNested" } }, "floatValue": { "type": "number", "format": "float", "default": "0.2", "description": "Float value field" }, "doubleValue": { "type": "number", "format": "double" }, "int64Value": { "type": "string", "format": "int64" }, "uint64Value": { "type": "string", "format": "uint64" }, "int32Value": { "type": "integer", "format": "int32" }, "fixed64Value": { "type": "string", "format": "uint64" }, "fixed32Value": { "type": "integer", "format": "int64" }, "boolValue": { "type": "boolean" }, "stringValue": { "type": "string" }, "bytesValue": { "type": "string", "format": "byte" }, "uint32Value": { "type": "integer", "format": "int64" }, "enumValue": { "$ref": "#/definitions/examplepbNumericEnum" }, "pathEnumValue": { "$ref": "#/definitions/pathenumPathEnum" }, "nestedPathEnumValue": { "$ref": "#/definitions/MessagePathEnumNestedPathEnum" }, "sfixed32Value": { "type": "integer", "format": "int32" }, "sfixed64Value": { "type": "string", "format": "int64" }, "sint32Value": { "type": "integer", "format": "int32" }, "sint64Value": { "type": "string", "format": "int64" }, "repeatedStringValue": { "type": "array", "items": { "type": "string" } }, "oneofEmpty": { "type": "object", "properties": {} }, "oneofString": { "type": "string" }, "mapValue": { "type": "object", "additionalProperties": { "$ref": "#/definitions/examplepbNumericEnum" }, "title": "map of numeric enum" }, "mappedStringValue": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Map of string description.", "title": "Map of string title" }, "mappedNestedValue": { "type": "object", "additionalProperties": { "$ref": "#/definitions/ABitOfEverythingNested" } }, "nonConventionalNameValue": { "type": "string" }, "timestampValue": { "type": "string", "format": "date-time" }, "repeatedEnumValue": { "type": "array", "items": { "$ref": "#/definitions/examplepbNumericEnum" }, "title": "repeated enum value. it is comma-separated in query" }, "repeatedEnumAnnotation": { "type": "array", "items": { "$ref": "#/definitions/examplepbNumericEnum" }, "description": "Repeated numeric enum description.", "title": "Repeated numeric enum title" }, "enumValueAnnotation": { "$ref": "#/definitions/examplepbNumericEnum", "description": "Numeric enum description.", "title": "Numeric enum title" }, "repeatedStringAnnotation": { "type": "array", "items": { "type": "string" }, "description": "Repeated string description.", "title": "Repeated string title" }, "repeatedNestedAnnotation": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/ABitOfEverythingNested" }, "description": "Repeated nested object description.", "title": "Repeated nested object title" }, "nestedAnnotation": { "$ref": "#/definitions/ABitOfEverythingNested", "description": "Nested object description.", "title": "Nested object title" }, "int64OverrideType": { "type": "integer", "format": "int64" }, "requiredStringViaFieldBehaviorAnnotation": { "type": "string", "title": "mark a field as required in Open API definition" }, "outputOnlyStringViaFieldBehaviorAnnotation": { "type": "string", "title": "mark a field as readonly in Open API definition", "readOnly": true }, "optionalStringValue": { "type": "string" }, "productId": { "type": "array", "items": { "type": "string", "maxLength": 19, "minLength": 1, "pattern": "^[0-9]+$" }, "description": "Only digits are allowed.", "title": "Test openapiv2 generation of repeated fields" }, "optionalStringField": { "type": "string", "title": "Test openapiv2 generation of required fields with annotation and jsonschema to reproduce" }, "requiredStringField1": { "type": "string" }, "requiredStringField2": { "type": "string" }, "required_field_behavior_json_name_custom": { "type": "string", "title": "Test openapiv2 handling of required json_name fields" }, "required_field_schema_json_name_custom": { "type": "string" }, "trailingOnly": { "type": "string", "title": "Trailing only" }, "trailingOnlyDot": { "type": "string", "description": "Trailing only dot." }, "trailingBoth": { "type": "string", "description": "Trailing both.", "title": "Leading both" }, "trailingMultiline": { "type": "string", "description": "This is an example of a multi-line comment.\n\nTrailing multiline.", "title": "Leading multiline" }, "uuids": { "type": "array", "items": { "type": "string", "format": "uuid" }, "title": "Specify a custom format of repeated field items" } }, "description": "Intentionally complicated message type to cover many features of Protobuf.", "title": "A bit of everything", "externalDocs": { "description": "Find out more about ABitOfEverything", "url": "https://github.com/grpc-ecosystem/grpc-gateway" }, "required": [ "int64Value", "doubleValue", "required_field_schema_json_name_custom", "floatValue", "requiredStringViaFieldBehaviorAnnotation", "requiredStringField1", "requiredStringField2", "required_field_behavior_json_name_custom" ], "x-a-bit-of-everything-foo": "bar" } }, { "name": "updateMask", "description": "The paths to update.", "in": "query", "required": false, "type": "string" } ], "tags": [ "ABitOfEverything" ] }, "patch": { "operationId": "ABitOfEverythingService_UpdateV22", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "uuidName", "in": "path", "required": true, "type": "string", "format": "uuid", "x-internal": true }, { "name": "abe", "description": "A bit of everything\n\nIntentionally complicated message type to cover many features of Protobuf.", "in": "body", "required": true, "schema": { "type": "object", "example": { "int64_value": 12, "double_value": 12.3 }, "properties": { "singleNested": { "$ref": "#/definitions/ABitOfEverythingNested" }, "nested": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/ABitOfEverythingNested" } }, "floatValue": { "type": "number", "format": "float", "default": "0.2", "description": "Float value field" }, "doubleValue": { "type": "number", "format": "double" }, "int64Value": { "type": "string", "format": "int64" }, "uint64Value": { "type": "string", "format": "uint64" }, "int32Value": { "type": "integer", "format": "int32" }, "fixed64Value": { "type": "string", "format": "uint64" }, "fixed32Value": { "type": "integer", "format": "int64" }, "boolValue": { "type": "boolean" }, "stringValue": { "type": "string" }, "bytesValue": { "type": "string", "format": "byte" }, "uint32Value": { "type": "integer", "format": "int64" }, "enumValue": { "$ref": "#/definitions/examplepbNumericEnum" }, "pathEnumValue": { "$ref": "#/definitions/pathenumPathEnum" }, "nestedPathEnumValue": { "$ref": "#/definitions/MessagePathEnumNestedPathEnum" }, "sfixed32Value": { "type": "integer", "format": "int32" }, "sfixed64Value": { "type": "string", "format": "int64" }, "sint32Value": { "type": "integer", "format": "int32" }, "sint64Value": { "type": "string", "format": "int64" }, "repeatedStringValue": { "type": "array", "items": { "type": "string" } }, "oneofEmpty": { "type": "object", "properties": {} }, "oneofString": { "type": "string" }, "mapValue": { "type": "object", "additionalProperties": { "$ref": "#/definitions/examplepbNumericEnum" }, "title": "map of numeric enum" }, "mappedStringValue": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Map of string description.", "title": "Map of string title" }, "mappedNestedValue": { "type": "object", "additionalProperties": { "$ref": "#/definitions/ABitOfEverythingNested" } }, "nonConventionalNameValue": { "type": "string" }, "timestampValue": { "type": "string", "format": "date-time" }, "repeatedEnumValue": { "type": "array", "items": { "$ref": "#/definitions/examplepbNumericEnum" }, "title": "repeated enum value. it is comma-separated in query" }, "repeatedEnumAnnotation": { "type": "array", "items": { "$ref": "#/definitions/examplepbNumericEnum" }, "description": "Repeated numeric enum description.", "title": "Repeated numeric enum title" }, "enumValueAnnotation": { "$ref": "#/definitions/examplepbNumericEnum", "description": "Numeric enum description.", "title": "Numeric enum title" }, "repeatedStringAnnotation": { "type": "array", "items": { "type": "string" }, "description": "Repeated string description.", "title": "Repeated string title" }, "repeatedNestedAnnotation": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/ABitOfEverythingNested" }, "description": "Repeated nested object description.", "title": "Repeated nested object title" }, "nestedAnnotation": { "$ref": "#/definitions/ABitOfEverythingNested", "description": "Nested object description.", "title": "Nested object title" }, "int64OverrideType": { "type": "integer", "format": "int64" }, "requiredStringViaFieldBehaviorAnnotation": { "type": "string", "title": "mark a field as required in Open API definition" }, "outputOnlyStringViaFieldBehaviorAnnotation": { "type": "string", "title": "mark a field as readonly in Open API definition", "readOnly": true }, "optionalStringValue": { "type": "string" }, "productId": { "type": "array", "items": { "type": "string", "maxLength": 19, "minLength": 1, "pattern": "^[0-9]+$" }, "description": "Only digits are allowed.", "title": "Test openapiv2 generation of repeated fields" }, "optionalStringField": { "type": "string", "title": "Test openapiv2 generation of required fields with annotation and jsonschema to reproduce" }, "requiredStringField1": { "type": "string" }, "requiredStringField2": { "type": "string" }, "required_field_behavior_json_name_custom": { "type": "string", "title": "Test openapiv2 handling of required json_name fields" }, "required_field_schema_json_name_custom": { "type": "string" }, "trailingOnly": { "type": "string", "title": "Trailing only" }, "trailingOnlyDot": { "type": "string", "description": "Trailing only dot." }, "trailingBoth": { "type": "string", "description": "Trailing both.", "title": "Leading both" }, "trailingMultiline": { "type": "string", "description": "This is an example of a multi-line comment.\n\nTrailing multiline.", "title": "Leading multiline" }, "uuids": { "type": "array", "items": { "type": "string", "format": "uuid" }, "title": "Specify a custom format of repeated field items" } }, "description": "Intentionally complicated message type to cover many features of Protobuf.", "title": "A bit of everything", "externalDocs": { "description": "Find out more about ABitOfEverything", "url": "https://github.com/grpc-ecosystem/grpc-gateway" }, "required": [ "int64Value", "doubleValue", "required_field_schema_json_name_custom", "floatValue", "requiredStringViaFieldBehaviorAnnotation", "requiredStringField1", "requiredStringField2", "required_field_behavior_json_name_custom" ], "x-a-bit-of-everything-foo": "bar" } } ], "tags": [ "ABitOfEverything" ] } }, "/v2/example/echo": { "get": { "summary": "Summary: Echo rpc", "description": "Description Echo", "operationId": "ABitOfEverythingService_Echo3", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/subStringMessage" }, "examples": { "application/json": { "value": "the input value" } } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "integer", "format": "integer" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "503": { "description": "Returned when the resource is temporarily unavailable.", "schema": {}, "x-number": 100 }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "value", "in": "query", "required": false, "type": "string" } ], "tags": [ "echo rpc" ], "externalDocs": { "description": "Find out more Echo", "url": "https://github.com/grpc-ecosystem/grpc-gateway" } }, "post": { "summary": "Summary: Echo rpc", "description": "Description Echo", "operationId": "ABitOfEverythingService_Echo2", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/subStringMessage" }, "examples": { "application/json": { "value": "the input value" } } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "integer", "format": "integer" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "503": { "description": "Returned when the resource is temporarily unavailable.", "schema": {}, "x-number": 100 }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "value", "in": "body", "required": true, "schema": { "type": "string" } } ], "tags": [ "echo rpc" ], "externalDocs": { "description": "Find out more Echo", "url": "https://github.com/grpc-ecosystem/grpc-gateway" } } }, "/v2/example/empty": { "get": { "operationId": "camelCaseServiceName_Empty", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "tags": [ "camelCaseServiceName" ] } }, "/v2/example/errorwithdetails": { "get": { "operationId": "ABitOfEverythingService_ErrorWithDetails", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "tags": [ "ABitOfEverything" ] } }, "/v2/example/overwriterequestcontenttype": { "post": { "operationId": "ABitOfEverythingService_OverwriteRequestContentType", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbBody" } } ], "tags": [ "ABitOfEverything" ], "consumes": [ "application/x-bar-mime" ] } }, "/v2/example/overwriteresponsecontenttype": { "get": { "operationId": "ABitOfEverythingService_OverwriteResponseContentType", "responses": { "200": { "description": "A successful response.", "schema": { "type": "string" } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "tags": [ "ABitOfEverything" ], "produces": [ "application/text" ] } }, "/v2/example/postwithemptybody/{name}": { "post": { "operationId": "ABitOfEverythingService_PostWithEmptyBody", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "name", "in": "path", "required": true, "type": "string" }, { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/ABitOfEverythingServicePostWithEmptyBodyBody" } } ], "tags": [ "ABitOfEverything" ] } }, "/v2/example/timeout": { "get": { "operationId": "ABitOfEverythingService_Timeout", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "tags": [ "ABitOfEverything" ] } }, "/v2/example/withbody/{id}": { "post": { "operationId": "ABitOfEverythingService_GetMessageWithBody", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "id", "in": "path", "required": true, "type": "string" }, { "name": "data", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbBody" } } ], "tags": [ "ABitOfEverything" ] } }, "/v2/{value}:check": { "get": { "operationId": "ABitOfEverythingService_CheckExternalPathEnum", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "value", "in": "path", "required": true, "type": "string", "enum": [ "ABC", "DEF" ] } ], "tags": [ "ABitOfEverything" ] } }, "/v2a/example/a_bit_of_everything/{uuidName}": { "patch": { "operationId": "ABitOfEverythingService_UpdateV23", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "uuidName", "in": "path", "required": true, "type": "string", "format": "uuid", "x-internal": true }, { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/ABitOfEverythingServiceUpdateV2Body" } } ], "tags": [ "ABitOfEverything" ] } }, "/v3/{value}:check": { "get": { "operationId": "ABitOfEverythingService_CheckExternalNestedPathEnum", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "418": { "description": "I'm a teapot.", "schema": { "$ref": "#/definitions/examplepbNumericEnum" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/examplepbErrorResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "value", "in": "path", "required": true, "type": "string", "enum": [ "GHI", "JKL" ] } ], "tags": [ "ABitOfEverything" ] } } }, "definitions": { "ABitOfEverythingNested": { "type": "object", "example": { "ok": "TRUE" }, "properties": { "name": { "type": "string", "description": "name is nested field." }, "amount": { "type": "integer", "format": "int64" }, "ok": { "$ref": "#/definitions/NestedDeepEnum", "description": "DeepEnum description." } }, "description": "Nested is nested type." }, "ABitOfEverythingServiceDeepPathEchoBody": { "type": "object", "example": { "int64_value": 12, "double_value": 12.3 }, "properties": { "singleNested": { "type": "object", "example": { "ok": "TRUE" }, "properties": { "amount": { "type": "integer", "format": "int64" }, "ok": { "$ref": "#/definitions/NestedDeepEnum", "description": "DeepEnum description." } }, "description": "Nested is nested type." }, "uuid": { "type": "string", "format": "uuid", "minLength": 1, "pattern": "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}", "x-internal": true }, "nested": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/ABitOfEverythingNested" } }, "floatValue": { "type": "number", "format": "float", "default": "0.2", "description": "Float value field" }, "doubleValue": { "type": "number", "format": "double" }, "int64Value": { "type": "string", "format": "int64" }, "uint64Value": { "type": "string", "format": "uint64" }, "int32Value": { "type": "integer", "format": "int32" }, "fixed64Value": { "type": "string", "format": "uint64" }, "fixed32Value": { "type": "integer", "format": "int64" }, "boolValue": { "type": "boolean" }, "stringValue": { "type": "string" }, "bytesValue": { "type": "string", "format": "byte" }, "uint32Value": { "type": "integer", "format": "int64" }, "enumValue": { "$ref": "#/definitions/examplepbNumericEnum" }, "pathEnumValue": { "$ref": "#/definitions/pathenumPathEnum" }, "nestedPathEnumValue": { "$ref": "#/definitions/MessagePathEnumNestedPathEnum" }, "sfixed32Value": { "type": "integer", "format": "int32" }, "sfixed64Value": { "type": "string", "format": "int64" }, "sint32Value": { "type": "integer", "format": "int32" }, "sint64Value": { "type": "string", "format": "int64" }, "repeatedStringValue": { "type": "array", "items": { "type": "string" } }, "oneofEmpty": { "type": "object", "properties": {} }, "oneofString": { "type": "string" }, "mapValue": { "type": "object", "additionalProperties": { "$ref": "#/definitions/examplepbNumericEnum" }, "title": "map of numeric enum" }, "mappedStringValue": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Map of string description.", "title": "Map of string title" }, "mappedNestedValue": { "type": "object", "additionalProperties": { "$ref": "#/definitions/ABitOfEverythingNested" } }, "nonConventionalNameValue": { "type": "string" }, "timestampValue": { "type": "string", "format": "date-time" }, "repeatedEnumValue": { "type": "array", "items": { "$ref": "#/definitions/examplepbNumericEnum" }, "title": "repeated enum value. it is comma-separated in query" }, "repeatedEnumAnnotation": { "type": "array", "items": { "$ref": "#/definitions/examplepbNumericEnum" }, "description": "Repeated numeric enum description.", "title": "Repeated numeric enum title" }, "enumValueAnnotation": { "$ref": "#/definitions/examplepbNumericEnum", "description": "Numeric enum description.", "title": "Numeric enum title" }, "repeatedStringAnnotation": { "type": "array", "items": { "type": "string" }, "description": "Repeated string description.", "title": "Repeated string title" }, "repeatedNestedAnnotation": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/ABitOfEverythingNested" }, "description": "Repeated nested object description.", "title": "Repeated nested object title" }, "nestedAnnotation": { "$ref": "#/definitions/ABitOfEverythingNested", "description": "Nested object description.", "title": "Nested object title" }, "int64OverrideType": { "type": "integer", "format": "int64" }, "requiredStringViaFieldBehaviorAnnotation": { "type": "string", "title": "mark a field as required in Open API definition" }, "outputOnlyStringViaFieldBehaviorAnnotation": { "type": "string", "title": "mark a field as readonly in Open API definition", "readOnly": true }, "optionalStringValue": { "type": "string" }, "productId": { "type": "array", "items": { "type": "string", "maxLength": 19, "minLength": 1, "pattern": "^[0-9]+$" }, "description": "Only digits are allowed.", "title": "Test openapiv2 generation of repeated fields" }, "optionalStringField": { "type": "string", "title": "Test openapiv2 generation of required fields with annotation and jsonschema to reproduce" }, "requiredStringField1": { "type": "string" }, "requiredStringField2": { "type": "string" }, "required_field_behavior_json_name_custom": { "type": "string", "title": "Test openapiv2 handling of required json_name fields" }, "required_field_schema_json_name_custom": { "type": "string" }, "trailingOnly": { "type": "string", "title": "Trailing only" }, "trailingOnlyDot": { "type": "string", "description": "Trailing only dot." }, "trailingBoth": { "type": "string", "description": "Trailing both.", "title": "Leading both" }, "trailingMultiline": { "type": "string", "description": "This is an example of a multi-line comment.\n\nTrailing multiline.", "title": "Leading multiline" }, "uuids": { "type": "array", "items": { "type": "string", "format": "uuid" }, "title": "Specify a custom format of repeated field items" } }, "description": "Intentionally complicated message type to cover many features of Protobuf.", "title": "A bit of everything", "externalDocs": { "description": "Find out more about ABitOfEverything", "url": "https://github.com/grpc-ecosystem/grpc-gateway" }, "required": [ "uuid", "int64Value", "doubleValue", "required_field_schema_json_name_custom", "floatValue", "requiredStringViaFieldBehaviorAnnotation", "requiredStringField1", "requiredStringField2", "required_field_behavior_json_name_custom" ], "x-a-bit-of-everything-foo": "bar" }, "ABitOfEverythingServicePostWithEmptyBodyBody": { "type": "object" }, "ABitOfEverythingServiceUpdateV2Body": { "type": "object", "properties": { "abe": { "type": "object", "example": { "int64_value": 12, "double_value": 12.3 }, "properties": { "singleNested": { "$ref": "#/definitions/ABitOfEverythingNested" }, "nested": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/ABitOfEverythingNested" } }, "floatValue": { "type": "number", "format": "float", "default": "0.2", "description": "Float value field" }, "doubleValue": { "type": "number", "format": "double" }, "int64Value": { "type": "string", "format": "int64" }, "uint64Value": { "type": "string", "format": "uint64" }, "int32Value": { "type": "integer", "format": "int32" }, "fixed64Value": { "type": "string", "format": "uint64" }, "fixed32Value": { "type": "integer", "format": "int64" }, "boolValue": { "type": "boolean" }, "stringValue": { "type": "string" }, "bytesValue": { "type": "string", "format": "byte" }, "uint32Value": { "type": "integer", "format": "int64" }, "enumValue": { "$ref": "#/definitions/examplepbNumericEnum" }, "pathEnumValue": { "$ref": "#/definitions/pathenumPathEnum" }, "nestedPathEnumValue": { "$ref": "#/definitions/MessagePathEnumNestedPathEnum" }, "sfixed32Value": { "type": "integer", "format": "int32" }, "sfixed64Value": { "type": "string", "format": "int64" }, "sint32Value": { "type": "integer", "format": "int32" }, "sint64Value": { "type": "string", "format": "int64" }, "repeatedStringValue": { "type": "array", "items": { "type": "string" } }, "oneofEmpty": { "type": "object", "properties": {} }, "oneofString": { "type": "string" }, "mapValue": { "type": "object", "additionalProperties": { "$ref": "#/definitions/examplepbNumericEnum" }, "title": "map of numeric enum" }, "mappedStringValue": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Map of string description.", "title": "Map of string title" }, "mappedNestedValue": { "type": "object", "additionalProperties": { "$ref": "#/definitions/ABitOfEverythingNested" } }, "nonConventionalNameValue": { "type": "string" }, "timestampValue": { "type": "string", "format": "date-time" }, "repeatedEnumValue": { "type": "array", "items": { "$ref": "#/definitions/examplepbNumericEnum" }, "title": "repeated enum value. it is comma-separated in query" }, "repeatedEnumAnnotation": { "type": "array", "items": { "$ref": "#/definitions/examplepbNumericEnum" }, "description": "Repeated numeric enum description.", "title": "Repeated numeric enum title" }, "enumValueAnnotation": { "$ref": "#/definitions/examplepbNumericEnum", "description": "Numeric enum description.", "title": "Numeric enum title" }, "repeatedStringAnnotation": { "type": "array", "items": { "type": "string" }, "description": "Repeated string description.", "title": "Repeated string title" }, "repeatedNestedAnnotation": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/ABitOfEverythingNested" }, "description": "Repeated nested object description.", "title": "Repeated nested object title" }, "nestedAnnotation": { "$ref": "#/definitions/ABitOfEverythingNested", "description": "Nested object description.", "title": "Nested object title" }, "int64OverrideType": { "type": "integer", "format": "int64" }, "requiredStringViaFieldBehaviorAnnotation": { "type": "string", "title": "mark a field as required in Open API definition" }, "outputOnlyStringViaFieldBehaviorAnnotation": { "type": "string", "title": "mark a field as readonly in Open API definition", "readOnly": true }, "optionalStringValue": { "type": "string" }, "productId": { "type": "array", "items": { "type": "string", "maxLength": 19, "minLength": 1, "pattern": "^[0-9]+$" }, "description": "Only digits are allowed.", "title": "Test openapiv2 generation of repeated fields" }, "optionalStringField": { "type": "string", "title": "Test openapiv2 generation of required fields with annotation and jsonschema to reproduce" }, "requiredStringField1": { "type": "string" }, "requiredStringField2": { "type": "string" }, "required_field_behavior_json_name_custom": { "type": "string", "title": "Test openapiv2 handling of required json_name fields" }, "required_field_schema_json_name_custom": { "type": "string" }, "trailingOnly": { "type": "string", "title": "Trailing only" }, "trailingOnlyDot": { "type": "string", "description": "Trailing only dot." }, "trailingBoth": { "type": "string", "description": "Trailing both.", "title": "Leading both" }, "trailingMultiline": { "type": "string", "description": "This is an example of a multi-line comment.\n\nTrailing multiline.", "title": "Leading multiline" }, "uuids": { "type": "array", "items": { "type": "string", "format": "uuid" }, "title": "Specify a custom format of repeated field items" } }, "description": "Intentionally complicated message type to cover many features of Protobuf.", "title": "A bit of everything", "externalDocs": { "description": "Find out more about ABitOfEverything", "url": "https://github.com/grpc-ecosystem/grpc-gateway" }, "required": [ "int64Value", "doubleValue", "required_field_schema_json_name_custom", "floatValue", "requiredStringViaFieldBehaviorAnnotation", "requiredStringField1", "requiredStringField2", "required_field_behavior_json_name_custom" ], "x-a-bit-of-everything-foo": "bar" }, "updateMask": { "type": "string", "description": "The paths to update." } }, "title": "UpdateV2Request request for update includes the message and the update mask" }, "MessagePathEnumNestedPathEnum": { "type": "string", "enum": [ "GHI", "JKL" ], "default": "GHI" }, "NestedDeepEnum": { "type": "string", "enum": [ "FALSE", "TRUE" ], "default": "FALSE", "description": "DeepEnum is one or zero.\n\n - FALSE: FALSE is false.\n - TRUE: TRUE is true." }, "examplepbABitOfEverything": { "type": "object", "example": { "int64_value": 12, "double_value": 12.3 }, "properties": { "singleNested": { "$ref": "#/definitions/ABitOfEverythingNested" }, "uuid": { "type": "string", "format": "uuid", "minLength": 1, "pattern": "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}", "x-internal": true }, "nested": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/ABitOfEverythingNested" } }, "floatValue": { "type": "number", "format": "float", "default": "0.2", "description": "Float value field" }, "doubleValue": { "type": "number", "format": "double" }, "int64Value": { "type": "string", "format": "int64" }, "uint64Value": { "type": "string", "format": "uint64" }, "int32Value": { "type": "integer", "format": "int32" }, "fixed64Value": { "type": "string", "format": "uint64" }, "fixed32Value": { "type": "integer", "format": "int64" }, "boolValue": { "type": "boolean" }, "stringValue": { "type": "string" }, "bytesValue": { "type": "string", "format": "byte" }, "uint32Value": { "type": "integer", "format": "int64" }, "enumValue": { "$ref": "#/definitions/examplepbNumericEnum" }, "pathEnumValue": { "$ref": "#/definitions/pathenumPathEnum" }, "nestedPathEnumValue": { "$ref": "#/definitions/MessagePathEnumNestedPathEnum" }, "sfixed32Value": { "type": "integer", "format": "int32" }, "sfixed64Value": { "type": "string", "format": "int64" }, "sint32Value": { "type": "integer", "format": "int32" }, "sint64Value": { "type": "string", "format": "int64" }, "repeatedStringValue": { "type": "array", "items": { "type": "string" } }, "oneofEmpty": { "type": "object", "properties": {} }, "oneofString": { "type": "string" }, "mapValue": { "type": "object", "additionalProperties": { "$ref": "#/definitions/examplepbNumericEnum" }, "title": "map of numeric enum" }, "mappedStringValue": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Map of string description.", "title": "Map of string title" }, "mappedNestedValue": { "type": "object", "additionalProperties": { "$ref": "#/definitions/ABitOfEverythingNested" } }, "nonConventionalNameValue": { "type": "string" }, "timestampValue": { "type": "string", "format": "date-time" }, "repeatedEnumValue": { "type": "array", "items": { "$ref": "#/definitions/examplepbNumericEnum" }, "title": "repeated enum value. it is comma-separated in query" }, "repeatedEnumAnnotation": { "type": "array", "items": { "$ref": "#/definitions/examplepbNumericEnum" }, "description": "Repeated numeric enum description.", "title": "Repeated numeric enum title" }, "enumValueAnnotation": { "$ref": "#/definitions/examplepbNumericEnum", "description": "Numeric enum description.", "title": "Numeric enum title" }, "repeatedStringAnnotation": { "type": "array", "items": { "type": "string" }, "description": "Repeated string description.", "title": "Repeated string title" }, "repeatedNestedAnnotation": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/ABitOfEverythingNested" }, "description": "Repeated nested object description.", "title": "Repeated nested object title" }, "nestedAnnotation": { "$ref": "#/definitions/ABitOfEverythingNested", "description": "Nested object description.", "title": "Nested object title" }, "int64OverrideType": { "type": "integer", "format": "int64" }, "requiredStringViaFieldBehaviorAnnotation": { "type": "string", "title": "mark a field as required in Open API definition" }, "outputOnlyStringViaFieldBehaviorAnnotation": { "type": "string", "title": "mark a field as readonly in Open API definition", "readOnly": true }, "optionalStringValue": { "type": "string" }, "productId": { "type": "array", "items": { "type": "string", "maxLength": 19, "minLength": 1, "pattern": "^[0-9]+$" }, "description": "Only digits are allowed.", "title": "Test openapiv2 generation of repeated fields" }, "optionalStringField": { "type": "string", "title": "Test openapiv2 generation of required fields with annotation and jsonschema to reproduce" }, "requiredStringField1": { "type": "string" }, "requiredStringField2": { "type": "string" }, "required_field_behavior_json_name_custom": { "type": "string", "title": "Test openapiv2 handling of required json_name fields" }, "required_field_schema_json_name_custom": { "type": "string" }, "trailingOnly": { "type": "string", "title": "Trailing only" }, "trailingOnlyDot": { "type": "string", "description": "Trailing only dot." }, "trailingBoth": { "type": "string", "description": "Trailing both.", "title": "Leading both" }, "trailingMultiline": { "type": "string", "description": "This is an example of a multi-line comment.\n\nTrailing multiline.", "title": "Leading multiline" }, "uuids": { "type": "array", "items": { "type": "string", "format": "uuid" }, "title": "Specify a custom format of repeated field items" } }, "description": "Intentionally complicated message type to cover many features of Protobuf.", "title": "A bit of everything", "externalDocs": { "description": "Find out more about ABitOfEverything", "url": "https://github.com/grpc-ecosystem/grpc-gateway" }, "required": [ "uuid", "int64Value", "doubleValue", "required_field_schema_json_name_custom", "floatValue", "requiredStringViaFieldBehaviorAnnotation", "requiredStringField1", "requiredStringField2", "required_field_behavior_json_name_custom" ], "x-a-bit-of-everything-foo": "bar" }, "examplepbABitOfEverythingRepeated": { "type": "object", "example": { "path_repeated_bool_value": [ true, true, false, true ], "path_repeated_int32_value": [ 1, 2, 3 ] }, "properties": { "pathRepeatedFloatValue": { "type": "array", "items": { "type": "number", "format": "float" }, "title": "repeated values. they are comma-separated in path" }, "pathRepeatedDoubleValue": { "type": "array", "items": { "type": "number", "format": "double" } }, "pathRepeatedInt64Value": { "type": "array", "items": { "type": "string", "format": "int64" } }, "pathRepeatedUint64Value": { "type": "array", "items": { "type": "string", "format": "uint64" } }, "pathRepeatedInt32Value": { "type": "array", "items": { "type": "integer", "format": "int32" } }, "pathRepeatedFixed64Value": { "type": "array", "items": { "type": "string", "format": "uint64" } }, "pathRepeatedFixed32Value": { "type": "array", "items": { "type": "integer", "format": "int64" } }, "pathRepeatedBoolValue": { "type": "array", "items": { "type": "boolean" } }, "pathRepeatedStringValue": { "type": "array", "items": { "type": "string" } }, "pathRepeatedBytesValue": { "type": "array", "items": { "type": "string", "format": "byte" } }, "pathRepeatedUint32Value": { "type": "array", "items": { "type": "integer", "format": "int64" } }, "pathRepeatedEnumValue": { "type": "array", "items": { "$ref": "#/definitions/examplepbNumericEnum" } }, "pathRepeatedSfixed32Value": { "type": "array", "items": { "type": "integer", "format": "int32" } }, "pathRepeatedSfixed64Value": { "type": "array", "items": { "type": "string", "format": "int64" } }, "pathRepeatedSint32Value": { "type": "array", "items": { "type": "integer", "format": "int32" } }, "pathRepeatedSint64Value": { "type": "array", "items": { "type": "string", "format": "int64" } } }, "title": "ABitOfEverythingRepeated is used to validate repeated path parameter functionality" }, "examplepbABitOfEverythingServiceUpdateBody": { "type": "object", "example": { "int64_value": 12, "double_value": 12.3 }, "properties": { "singleNested": { "$ref": "#/definitions/ABitOfEverythingNested" }, "nested": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/ABitOfEverythingNested" } }, "floatValue": { "type": "number", "format": "float", "default": "0.2", "description": "Float value field" }, "doubleValue": { "type": "number", "format": "double" }, "int64Value": { "type": "string", "format": "int64" }, "uint64Value": { "type": "string", "format": "uint64" }, "int32Value": { "type": "integer", "format": "int32" }, "fixed64Value": { "type": "string", "format": "uint64" }, "fixed32Value": { "type": "integer", "format": "int64" }, "boolValue": { "type": "boolean" }, "stringValue": { "type": "string" }, "bytesValue": { "type": "string", "format": "byte" }, "uint32Value": { "type": "integer", "format": "int64" }, "enumValue": { "$ref": "#/definitions/examplepbNumericEnum" }, "pathEnumValue": { "$ref": "#/definitions/pathenumPathEnum" }, "nestedPathEnumValue": { "$ref": "#/definitions/MessagePathEnumNestedPathEnum" }, "sfixed32Value": { "type": "integer", "format": "int32" }, "sfixed64Value": { "type": "string", "format": "int64" }, "sint32Value": { "type": "integer", "format": "int32" }, "sint64Value": { "type": "string", "format": "int64" }, "repeatedStringValue": { "type": "array", "items": { "type": "string" } }, "oneofEmpty": { "type": "object", "properties": {} }, "oneofString": { "type": "string" }, "mapValue": { "type": "object", "additionalProperties": { "$ref": "#/definitions/examplepbNumericEnum" }, "title": "map of numeric enum" }, "mappedStringValue": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Map of string description.", "title": "Map of string title" }, "mappedNestedValue": { "type": "object", "additionalProperties": { "$ref": "#/definitions/ABitOfEverythingNested" } }, "nonConventionalNameValue": { "type": "string" }, "timestampValue": { "type": "string", "format": "date-time" }, "repeatedEnumValue": { "type": "array", "items": { "$ref": "#/definitions/examplepbNumericEnum" }, "title": "repeated enum value. it is comma-separated in query" }, "repeatedEnumAnnotation": { "type": "array", "items": { "$ref": "#/definitions/examplepbNumericEnum" }, "description": "Repeated numeric enum description.", "title": "Repeated numeric enum title" }, "enumValueAnnotation": { "$ref": "#/definitions/examplepbNumericEnum", "description": "Numeric enum description.", "title": "Numeric enum title" }, "repeatedStringAnnotation": { "type": "array", "items": { "type": "string" }, "description": "Repeated string description.", "title": "Repeated string title" }, "repeatedNestedAnnotation": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/ABitOfEverythingNested" }, "description": "Repeated nested object description.", "title": "Repeated nested object title" }, "nestedAnnotation": { "$ref": "#/definitions/ABitOfEverythingNested", "description": "Nested object description.", "title": "Nested object title" }, "int64OverrideType": { "type": "integer", "format": "int64" }, "requiredStringViaFieldBehaviorAnnotation": { "type": "string", "title": "mark a field as required in Open API definition" }, "outputOnlyStringViaFieldBehaviorAnnotation": { "type": "string", "title": "mark a field as readonly in Open API definition", "readOnly": true }, "optionalStringValue": { "type": "string" }, "productId": { "type": "array", "items": { "type": "string", "maxLength": 19, "minLength": 1, "pattern": "^[0-9]+$" }, "description": "Only digits are allowed.", "title": "Test openapiv2 generation of repeated fields" }, "optionalStringField": { "type": "string", "title": "Test openapiv2 generation of required fields with annotation and jsonschema to reproduce" }, "requiredStringField1": { "type": "string" }, "requiredStringField2": { "type": "string" }, "required_field_behavior_json_name_custom": { "type": "string", "title": "Test openapiv2 handling of required json_name fields" }, "required_field_schema_json_name_custom": { "type": "string" }, "trailingOnly": { "type": "string", "title": "Trailing only" }, "trailingOnlyDot": { "type": "string", "description": "Trailing only dot." }, "trailingBoth": { "type": "string", "description": "Trailing both.", "title": "Leading both" }, "trailingMultiline": { "type": "string", "description": "This is an example of a multi-line comment.\n\nTrailing multiline.", "title": "Leading multiline" }, "uuids": { "type": "array", "items": { "type": "string", "format": "uuid" }, "title": "Specify a custom format of repeated field items" } }, "description": "Intentionally complicated message type to cover many features of Protobuf.", "title": "A bit of everything", "externalDocs": { "description": "Find out more about ABitOfEverything", "url": "https://github.com/grpc-ecosystem/grpc-gateway" }, "required": [ "int64Value", "doubleValue", "required_field_schema_json_name_custom", "floatValue", "requiredStringViaFieldBehaviorAnnotation", "requiredStringField1", "requiredStringField2", "required_field_behavior_json_name_custom" ], "x-a-bit-of-everything-foo": "bar" }, "examplepbBar": { "type": "object", "properties": { "id": { "type": "string" } }, "required": [ "id" ] }, "examplepbBody": { "type": "object", "properties": { "name": { "type": "string" } } }, "examplepbBook": { "type": "object", "properties": { "name": { "type": "string", "description": "The resource name of the book.\n\nFormat: `publishers/{publisher}/books/{book}`\n\nExample: `publishers/1257894000000000000/books/my-book`" }, "id": { "type": "string", "description": "Output only. The book's ID.", "readOnly": true }, "createTime": { "type": "string", "format": "date-time", "description": "Output only. Creation time of the book.", "readOnly": true } }, "description": "An example resource type from AIP-123 used to test the behavior described in\nthe CreateBookRequest message.\n\nSee: https://google.aip.dev/123" }, "examplepbCheckStatusResponse": { "type": "object", "properties": { "status": { "$ref": "#/definitions/googleRpcStatus" } } }, "examplepbErrorObject": { "type": "object", "properties": { "code": { "type": "integer", "format": "integer", "description": "Response code", "title": "code", "pattern": "^[0-9]$" }, "message": { "type": "string", "description": "Response message", "title": "message", "pattern": "^[a-zA-Z0-9]{1, 32}$" } } }, "examplepbErrorResponse": { "type": "object", "properties": { "correlationId": { "type": "string", "format": "uuid", "example": "2438ac3c-37eb-4902-adef-ed16b4431030", "description": "Unique event identifier for server requests", "title": "x-correlation-id", "pattern": "^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$" }, "error": { "$ref": "#/definitions/examplepbErrorObject" } } }, "examplepbNumericEnum": { "type": "string", "example": "ZERO", "enum": [ "ZERO", "ONE" ], "default": "ZERO", "description": "NumericEnum is one or zero.", "title": "NumericEnum", "externalDocs": { "description": "Find out more about ABitOfEverything", "url": "https://github.com/grpc-ecosystem/grpc-gateway" }, "x-a-bit-of-everything-foo": "bar" }, "examplepbRequiredMessageTypeRequest": { "type": "object", "properties": { "id": { "type": "string" }, "foo": { "$ref": "#/definitions/protoExamplepbFoo" } }, "title": "Required message type -\u003e OpenAPI\nhttps://github.com/grpc-ecosystem/grpc-gateway/issues/2837", "required": [ "id", "foo" ] }, "examplepbSnakeEnumResponse": { "type": "object" }, "examplepbSnake_case_0_enum": { "type": "string", "enum": [ "value_e", "value_f" ], "default": "value_e", "description": "- value_e: buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE\n - value_f: buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE", "title": "Ignoring lint warnings as this enum type exist to validate proper functionality\nfor projects that don't follow these lint rules.\nbuf:lint:ignore ENUM_PASCAL_CASE" }, "examplepbSnake_case_enum": { "type": "string", "enum": [ "value_c", "value_d" ], "default": "value_c", "description": "- value_c: buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE\n - value_d: buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE", "title": "Ignoring lint warnings as this enum type exist to validate proper functionality\nfor projects that don't follow these lint rules.\nbuf:lint:ignore ENUM_PASCAL_CASE" }, "googleRpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32", "description": "The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]." }, "message": { "type": "string", "description": "A developer-facing error message, which should be in English. Any\nuser-facing error message should be localized and sent in the\n[google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client." }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" }, "description": "A list of messages that carry the error details. There is a common set of\nmessage types for APIs to use." } }, "description": "The `Status` type defines a logical error model that is suitable for\ndifferent programming environments, including REST APIs and RPC APIs. It is\nused by [gRPC](https://github.com/grpc). Each `Status` message contains\nthree pieces of data: error code, error message, and error details.\n\nYou can find out more about this error model and how to work with it in the\n[API Design Guide](https://cloud.google.com/apis/design/errors)." }, "oneofenumExampleEnum": { "type": "string", "enum": [ "EXAMPLE_ENUM_UNSPECIFIED", "EXAMPLE_ENUM_FIRST" ], "default": "EXAMPLE_ENUM_UNSPECIFIED" }, "pathenumPathEnum": { "type": "string", "enum": [ "ABC", "DEF" ], "default": "ABC" }, "pathenumSnake_case_for_import": { "type": "string", "enum": [ "value_x", "value_y" ], "default": "value_x", "description": "- value_x: buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE\n - value_y: buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE", "title": "Ignoring lint warnings as this enum type exist to validate proper functionality\nfor projects that don't follow these lint rules.\nbuf:lint:ignore ENUM_PASCAL_CASE" }, "protoExamplepbFoo": { "type": "object", "properties": { "bar": { "$ref": "#/definitions/examplepbBar" } }, "required": [ "bar" ] }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string", "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics." } }, "additionalProperties": {}, "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }" }, "subStringMessage": { "type": "object", "properties": { "value": { "type": "string" } } } }, "securityDefinitions": { "ApiKeyAuth": { "type": "apiKey", "name": "X-API-Key", "in": "header", "x-amazon-apigateway-authorizer": { "authorizerResultTtlInSeconds": 60, "type": "token" }, "x-amazon-apigateway-authtype": "oauth2" }, "BasicAuth": { "type": "basic" }, "OAuth2": { "type": "oauth2", "flow": "accessCode", "authorizationUrl": "https://example.com/oauth/authorize", "tokenUrl": "https://example.com/oauth/token", "scopes": { "admin": "Grants read and write access to administrative information", "read": "Grants read access", "write": "Grants write access" } } }, "security": [ { "ApiKeyAuth": [], "BasicAuth": [] }, { "ApiKeyAuth": [], "OAuth2": [ "read", "write" ] } ], "externalDocs": { "description": "More about gRPC-Gateway", "url": "https://github.com/grpc-ecosystem/grpc-gateway" }, "x-grpc-gateway-baz-list": [ "one", true ], "x-grpc-gateway-foo": "bar" } ================================================ FILE: examples/internal/proto/examplepb/a_bit_of_everything_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: examples/internal/proto/examplepb/a_bit_of_everything.proto package examplepb import ( context "context" oneofenum "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/oneofenum" pathenum "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/pathenum" sub "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub" sub2 "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub2" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" durationpb "google.golang.org/protobuf/types/known/durationpb" emptypb "google.golang.org/protobuf/types/known/emptypb" wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( ABitOfEverythingService_Create_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Create" ABitOfEverythingService_CreateBody_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CreateBody" ABitOfEverythingService_CreateBook_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CreateBook" ABitOfEverythingService_UpdateBook_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/UpdateBook" ABitOfEverythingService_Lookup_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Lookup" ABitOfEverythingService_Custom_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Custom" ABitOfEverythingService_DoubleColon_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/DoubleColon" ABitOfEverythingService_Update_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Update" ABitOfEverythingService_UpdateV2_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/UpdateV2" ABitOfEverythingService_Delete_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Delete" ABitOfEverythingService_GetQuery_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/GetQuery" ABitOfEverythingService_GetRepeatedQuery_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/GetRepeatedQuery" ABitOfEverythingService_Echo_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Echo" ABitOfEverythingService_DeepPathEcho_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/DeepPathEcho" ABitOfEverythingService_NoBindings_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/NoBindings" ABitOfEverythingService_Timeout_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Timeout" ABitOfEverythingService_ErrorWithDetails_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/ErrorWithDetails" ABitOfEverythingService_GetMessageWithBody_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/GetMessageWithBody" ABitOfEverythingService_PostWithEmptyBody_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/PostWithEmptyBody" ABitOfEverythingService_CheckGetQueryParams_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CheckGetQueryParams" ABitOfEverythingService_CheckNestedEnumGetQueryParams_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CheckNestedEnumGetQueryParams" ABitOfEverythingService_CheckPostQueryParams_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CheckPostQueryParams" ABitOfEverythingService_OverwriteRequestContentType_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/OverwriteRequestContentType" ABitOfEverythingService_OverwriteResponseContentType_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/OverwriteResponseContentType" ABitOfEverythingService_CheckExternalPathEnum_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CheckExternalPathEnum" ABitOfEverythingService_CheckExternalNestedPathEnum_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CheckExternalNestedPathEnum" ABitOfEverythingService_CheckStatus_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CheckStatus" ABitOfEverythingService_Exists_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/Exists" ABitOfEverythingService_CustomOptionsRequest_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/CustomOptionsRequest" ABitOfEverythingService_TraceRequest_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/TraceRequest" ABitOfEverythingService_PostOneofEnum_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/PostOneofEnum" ABitOfEverythingService_PostRequiredMessageType_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService/PostRequiredMessageType" ) // ABitOfEverythingServiceClient is the client API for ABitOfEverythingService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // // ABitOfEverything service is used to validate that APIs with complicated // proto messages and URL templates are still processed correctly. type ABitOfEverythingServiceClient interface { // Create a new ABitOfEverything // // This API creates a new ABitOfEverything Create(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) CreateBody(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) // Create a book. CreateBook(ctx context.Context, in *CreateBookRequest, opts ...grpc.CallOption) (*Book, error) UpdateBook(ctx context.Context, in *UpdateBookRequest, opts ...grpc.CallOption) (*Book, error) Lookup(ctx context.Context, in *sub2.IdMessage, opts ...grpc.CallOption) (*ABitOfEverything, error) Custom(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) DoubleColon(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) Update(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*emptypb.Empty, error) UpdateV2(ctx context.Context, in *UpdateV2Request, opts ...grpc.CallOption) (*emptypb.Empty, error) Delete(ctx context.Context, in *sub2.IdMessage, opts ...grpc.CallOption) (*emptypb.Empty, error) GetQuery(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*emptypb.Empty, error) GetRepeatedQuery(ctx context.Context, in *ABitOfEverythingRepeated, opts ...grpc.CallOption) (*ABitOfEverythingRepeated, error) // Echo allows posting a StringMessage value. // // It also exposes multiple bindings. // // This makes it useful when validating that the OpenAPI v2 API // description exposes documentation correctly on all paths // defined as additional_bindings in the proto. Echo(ctx context.Context, in *sub.StringMessage, opts ...grpc.CallOption) (*sub.StringMessage, error) DeepPathEcho(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) NoBindings(ctx context.Context, in *durationpb.Duration, opts ...grpc.CallOption) (*emptypb.Empty, error) Timeout(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) ErrorWithDetails(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) GetMessageWithBody(ctx context.Context, in *MessageWithBody, opts ...grpc.CallOption) (*emptypb.Empty, error) PostWithEmptyBody(ctx context.Context, in *Body, opts ...grpc.CallOption) (*emptypb.Empty, error) CheckGetQueryParams(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) CheckNestedEnumGetQueryParams(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) CheckPostQueryParams(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) OverwriteRequestContentType(ctx context.Context, in *Body, opts ...grpc.CallOption) (*emptypb.Empty, error) OverwriteResponseContentType(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*wrapperspb.StringValue, error) CheckExternalPathEnum(ctx context.Context, in *pathenum.MessageWithPathEnum, opts ...grpc.CallOption) (*emptypb.Empty, error) CheckExternalNestedPathEnum(ctx context.Context, in *pathenum.MessageWithNestedPathEnum, opts ...grpc.CallOption) (*emptypb.Empty, error) CheckStatus(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*CheckStatusResponse, error) Exists(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*emptypb.Empty, error) CustomOptionsRequest(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*emptypb.Empty, error) TraceRequest(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) PostOneofEnum(ctx context.Context, in *oneofenum.OneofEnumMessage, opts ...grpc.CallOption) (*emptypb.Empty, error) PostRequiredMessageType(ctx context.Context, in *RequiredMessageTypeRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) } type aBitOfEverythingServiceClient struct { cc grpc.ClientConnInterface } func NewABitOfEverythingServiceClient(cc grpc.ClientConnInterface) ABitOfEverythingServiceClient { return &aBitOfEverythingServiceClient{cc} } func (c *aBitOfEverythingServiceClient) Create(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ABitOfEverything) err := c.cc.Invoke(ctx, ABitOfEverythingService_Create_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) CreateBody(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ABitOfEverything) err := c.cc.Invoke(ctx, ABitOfEverythingService_CreateBody_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) CreateBook(ctx context.Context, in *CreateBookRequest, opts ...grpc.CallOption) (*Book, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Book) err := c.cc.Invoke(ctx, ABitOfEverythingService_CreateBook_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) UpdateBook(ctx context.Context, in *UpdateBookRequest, opts ...grpc.CallOption) (*Book, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Book) err := c.cc.Invoke(ctx, ABitOfEverythingService_UpdateBook_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) Lookup(ctx context.Context, in *sub2.IdMessage, opts ...grpc.CallOption) (*ABitOfEverything, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ABitOfEverything) err := c.cc.Invoke(ctx, ABitOfEverythingService_Lookup_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) Custom(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ABitOfEverything) err := c.cc.Invoke(ctx, ABitOfEverythingService_Custom_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) DoubleColon(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ABitOfEverything) err := c.cc.Invoke(ctx, ABitOfEverythingService_DoubleColon_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) Update(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) err := c.cc.Invoke(ctx, ABitOfEverythingService_Update_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) UpdateV2(ctx context.Context, in *UpdateV2Request, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) err := c.cc.Invoke(ctx, ABitOfEverythingService_UpdateV2_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) Delete(ctx context.Context, in *sub2.IdMessage, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) err := c.cc.Invoke(ctx, ABitOfEverythingService_Delete_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) GetQuery(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) err := c.cc.Invoke(ctx, ABitOfEverythingService_GetQuery_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) GetRepeatedQuery(ctx context.Context, in *ABitOfEverythingRepeated, opts ...grpc.CallOption) (*ABitOfEverythingRepeated, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ABitOfEverythingRepeated) err := c.cc.Invoke(ctx, ABitOfEverythingService_GetRepeatedQuery_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) Echo(ctx context.Context, in *sub.StringMessage, opts ...grpc.CallOption) (*sub.StringMessage, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(sub.StringMessage) err := c.cc.Invoke(ctx, ABitOfEverythingService_Echo_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) DeepPathEcho(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ABitOfEverything) err := c.cc.Invoke(ctx, ABitOfEverythingService_DeepPathEcho_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) NoBindings(ctx context.Context, in *durationpb.Duration, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) err := c.cc.Invoke(ctx, ABitOfEverythingService_NoBindings_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) Timeout(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) err := c.cc.Invoke(ctx, ABitOfEverythingService_Timeout_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) ErrorWithDetails(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) err := c.cc.Invoke(ctx, ABitOfEverythingService_ErrorWithDetails_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) GetMessageWithBody(ctx context.Context, in *MessageWithBody, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) err := c.cc.Invoke(ctx, ABitOfEverythingService_GetMessageWithBody_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) PostWithEmptyBody(ctx context.Context, in *Body, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) err := c.cc.Invoke(ctx, ABitOfEverythingService_PostWithEmptyBody_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) CheckGetQueryParams(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ABitOfEverything) err := c.cc.Invoke(ctx, ABitOfEverythingService_CheckGetQueryParams_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) CheckNestedEnumGetQueryParams(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ABitOfEverything) err := c.cc.Invoke(ctx, ABitOfEverythingService_CheckNestedEnumGetQueryParams_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) CheckPostQueryParams(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ABitOfEverything) err := c.cc.Invoke(ctx, ABitOfEverythingService_CheckPostQueryParams_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) OverwriteRequestContentType(ctx context.Context, in *Body, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) err := c.cc.Invoke(ctx, ABitOfEverythingService_OverwriteRequestContentType_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) OverwriteResponseContentType(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*wrapperspb.StringValue, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(wrapperspb.StringValue) err := c.cc.Invoke(ctx, ABitOfEverythingService_OverwriteResponseContentType_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) CheckExternalPathEnum(ctx context.Context, in *pathenum.MessageWithPathEnum, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) err := c.cc.Invoke(ctx, ABitOfEverythingService_CheckExternalPathEnum_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) CheckExternalNestedPathEnum(ctx context.Context, in *pathenum.MessageWithNestedPathEnum, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) err := c.cc.Invoke(ctx, ABitOfEverythingService_CheckExternalNestedPathEnum_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) CheckStatus(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*CheckStatusResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(CheckStatusResponse) err := c.cc.Invoke(ctx, ABitOfEverythingService_CheckStatus_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) Exists(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) err := c.cc.Invoke(ctx, ABitOfEverythingService_Exists_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) CustomOptionsRequest(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) err := c.cc.Invoke(ctx, ABitOfEverythingService_CustomOptionsRequest_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) TraceRequest(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ABitOfEverything) err := c.cc.Invoke(ctx, ABitOfEverythingService_TraceRequest_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) PostOneofEnum(ctx context.Context, in *oneofenum.OneofEnumMessage, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) err := c.cc.Invoke(ctx, ABitOfEverythingService_PostOneofEnum_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *aBitOfEverythingServiceClient) PostRequiredMessageType(ctx context.Context, in *RequiredMessageTypeRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) err := c.cc.Invoke(ctx, ABitOfEverythingService_PostRequiredMessageType_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // ABitOfEverythingServiceServer is the server API for ABitOfEverythingService service. // All implementations should embed UnimplementedABitOfEverythingServiceServer // for forward compatibility. // // ABitOfEverything service is used to validate that APIs with complicated // proto messages and URL templates are still processed correctly. type ABitOfEverythingServiceServer interface { // Create a new ABitOfEverything // // This API creates a new ABitOfEverything Create(context.Context, *ABitOfEverything) (*ABitOfEverything, error) CreateBody(context.Context, *ABitOfEverything) (*ABitOfEverything, error) // Create a book. CreateBook(context.Context, *CreateBookRequest) (*Book, error) UpdateBook(context.Context, *UpdateBookRequest) (*Book, error) Lookup(context.Context, *sub2.IdMessage) (*ABitOfEverything, error) Custom(context.Context, *ABitOfEverything) (*ABitOfEverything, error) DoubleColon(context.Context, *ABitOfEverything) (*ABitOfEverything, error) Update(context.Context, *ABitOfEverything) (*emptypb.Empty, error) UpdateV2(context.Context, *UpdateV2Request) (*emptypb.Empty, error) Delete(context.Context, *sub2.IdMessage) (*emptypb.Empty, error) GetQuery(context.Context, *ABitOfEverything) (*emptypb.Empty, error) GetRepeatedQuery(context.Context, *ABitOfEverythingRepeated) (*ABitOfEverythingRepeated, error) // Echo allows posting a StringMessage value. // // It also exposes multiple bindings. // // This makes it useful when validating that the OpenAPI v2 API // description exposes documentation correctly on all paths // defined as additional_bindings in the proto. Echo(context.Context, *sub.StringMessage) (*sub.StringMessage, error) DeepPathEcho(context.Context, *ABitOfEverything) (*ABitOfEverything, error) NoBindings(context.Context, *durationpb.Duration) (*emptypb.Empty, error) Timeout(context.Context, *emptypb.Empty) (*emptypb.Empty, error) ErrorWithDetails(context.Context, *emptypb.Empty) (*emptypb.Empty, error) GetMessageWithBody(context.Context, *MessageWithBody) (*emptypb.Empty, error) PostWithEmptyBody(context.Context, *Body) (*emptypb.Empty, error) CheckGetQueryParams(context.Context, *ABitOfEverything) (*ABitOfEverything, error) CheckNestedEnumGetQueryParams(context.Context, *ABitOfEverything) (*ABitOfEverything, error) CheckPostQueryParams(context.Context, *ABitOfEverything) (*ABitOfEverything, error) OverwriteRequestContentType(context.Context, *Body) (*emptypb.Empty, error) OverwriteResponseContentType(context.Context, *emptypb.Empty) (*wrapperspb.StringValue, error) CheckExternalPathEnum(context.Context, *pathenum.MessageWithPathEnum) (*emptypb.Empty, error) CheckExternalNestedPathEnum(context.Context, *pathenum.MessageWithNestedPathEnum) (*emptypb.Empty, error) CheckStatus(context.Context, *emptypb.Empty) (*CheckStatusResponse, error) Exists(context.Context, *ABitOfEverything) (*emptypb.Empty, error) CustomOptionsRequest(context.Context, *ABitOfEverything) (*emptypb.Empty, error) TraceRequest(context.Context, *ABitOfEverything) (*ABitOfEverything, error) PostOneofEnum(context.Context, *oneofenum.OneofEnumMessage) (*emptypb.Empty, error) PostRequiredMessageType(context.Context, *RequiredMessageTypeRequest) (*emptypb.Empty, error) } // UnimplementedABitOfEverythingServiceServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedABitOfEverythingServiceServer struct{} func (UnimplementedABitOfEverythingServiceServer) Create(context.Context, *ABitOfEverything) (*ABitOfEverything, error) { return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") } func (UnimplementedABitOfEverythingServiceServer) CreateBody(context.Context, *ABitOfEverything) (*ABitOfEverything, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateBody not implemented") } func (UnimplementedABitOfEverythingServiceServer) CreateBook(context.Context, *CreateBookRequest) (*Book, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateBook not implemented") } func (UnimplementedABitOfEverythingServiceServer) UpdateBook(context.Context, *UpdateBookRequest) (*Book, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateBook not implemented") } func (UnimplementedABitOfEverythingServiceServer) Lookup(context.Context, *sub2.IdMessage) (*ABitOfEverything, error) { return nil, status.Errorf(codes.Unimplemented, "method Lookup not implemented") } func (UnimplementedABitOfEverythingServiceServer) Custom(context.Context, *ABitOfEverything) (*ABitOfEverything, error) { return nil, status.Errorf(codes.Unimplemented, "method Custom not implemented") } func (UnimplementedABitOfEverythingServiceServer) DoubleColon(context.Context, *ABitOfEverything) (*ABitOfEverything, error) { return nil, status.Errorf(codes.Unimplemented, "method DoubleColon not implemented") } func (UnimplementedABitOfEverythingServiceServer) Update(context.Context, *ABitOfEverything) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method Update not implemented") } func (UnimplementedABitOfEverythingServiceServer) UpdateV2(context.Context, *UpdateV2Request) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateV2 not implemented") } func (UnimplementedABitOfEverythingServiceServer) Delete(context.Context, *sub2.IdMessage) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") } func (UnimplementedABitOfEverythingServiceServer) GetQuery(context.Context, *ABitOfEverything) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method GetQuery not implemented") } func (UnimplementedABitOfEverythingServiceServer) GetRepeatedQuery(context.Context, *ABitOfEverythingRepeated) (*ABitOfEverythingRepeated, error) { return nil, status.Errorf(codes.Unimplemented, "method GetRepeatedQuery not implemented") } func (UnimplementedABitOfEverythingServiceServer) Echo(context.Context, *sub.StringMessage) (*sub.StringMessage, error) { return nil, status.Errorf(codes.Unimplemented, "method Echo not implemented") } func (UnimplementedABitOfEverythingServiceServer) DeepPathEcho(context.Context, *ABitOfEverything) (*ABitOfEverything, error) { return nil, status.Errorf(codes.Unimplemented, "method DeepPathEcho not implemented") } func (UnimplementedABitOfEverythingServiceServer) NoBindings(context.Context, *durationpb.Duration) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method NoBindings not implemented") } func (UnimplementedABitOfEverythingServiceServer) Timeout(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method Timeout not implemented") } func (UnimplementedABitOfEverythingServiceServer) ErrorWithDetails(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method ErrorWithDetails not implemented") } func (UnimplementedABitOfEverythingServiceServer) GetMessageWithBody(context.Context, *MessageWithBody) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method GetMessageWithBody not implemented") } func (UnimplementedABitOfEverythingServiceServer) PostWithEmptyBody(context.Context, *Body) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method PostWithEmptyBody not implemented") } func (UnimplementedABitOfEverythingServiceServer) CheckGetQueryParams(context.Context, *ABitOfEverything) (*ABitOfEverything, error) { return nil, status.Errorf(codes.Unimplemented, "method CheckGetQueryParams not implemented") } func (UnimplementedABitOfEverythingServiceServer) CheckNestedEnumGetQueryParams(context.Context, *ABitOfEverything) (*ABitOfEverything, error) { return nil, status.Errorf(codes.Unimplemented, "method CheckNestedEnumGetQueryParams not implemented") } func (UnimplementedABitOfEverythingServiceServer) CheckPostQueryParams(context.Context, *ABitOfEverything) (*ABitOfEverything, error) { return nil, status.Errorf(codes.Unimplemented, "method CheckPostQueryParams not implemented") } func (UnimplementedABitOfEverythingServiceServer) OverwriteRequestContentType(context.Context, *Body) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method OverwriteRequestContentType not implemented") } func (UnimplementedABitOfEverythingServiceServer) OverwriteResponseContentType(context.Context, *emptypb.Empty) (*wrapperspb.StringValue, error) { return nil, status.Errorf(codes.Unimplemented, "method OverwriteResponseContentType not implemented") } func (UnimplementedABitOfEverythingServiceServer) CheckExternalPathEnum(context.Context, *pathenum.MessageWithPathEnum) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method CheckExternalPathEnum not implemented") } func (UnimplementedABitOfEverythingServiceServer) CheckExternalNestedPathEnum(context.Context, *pathenum.MessageWithNestedPathEnum) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method CheckExternalNestedPathEnum not implemented") } func (UnimplementedABitOfEverythingServiceServer) CheckStatus(context.Context, *emptypb.Empty) (*CheckStatusResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CheckStatus not implemented") } func (UnimplementedABitOfEverythingServiceServer) Exists(context.Context, *ABitOfEverything) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method Exists not implemented") } func (UnimplementedABitOfEverythingServiceServer) CustomOptionsRequest(context.Context, *ABitOfEverything) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method CustomOptionsRequest not implemented") } func (UnimplementedABitOfEverythingServiceServer) TraceRequest(context.Context, *ABitOfEverything) (*ABitOfEverything, error) { return nil, status.Errorf(codes.Unimplemented, "method TraceRequest not implemented") } func (UnimplementedABitOfEverythingServiceServer) PostOneofEnum(context.Context, *oneofenum.OneofEnumMessage) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method PostOneofEnum not implemented") } func (UnimplementedABitOfEverythingServiceServer) PostRequiredMessageType(context.Context, *RequiredMessageTypeRequest) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method PostRequiredMessageType not implemented") } func (UnimplementedABitOfEverythingServiceServer) testEmbeddedByValue() {} // UnsafeABitOfEverythingServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to ABitOfEverythingServiceServer will // result in compilation errors. type UnsafeABitOfEverythingServiceServer interface { mustEmbedUnimplementedABitOfEverythingServiceServer() } func RegisterABitOfEverythingServiceServer(s grpc.ServiceRegistrar, srv ABitOfEverythingServiceServer) { // If the following call pancis, it indicates UnimplementedABitOfEverythingServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&ABitOfEverythingService_ServiceDesc, srv) } func _ABitOfEverythingService_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ABitOfEverything) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).Create(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_Create_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).Create(ctx, req.(*ABitOfEverything)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_CreateBody_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ABitOfEverything) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).CreateBody(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_CreateBody_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).CreateBody(ctx, req.(*ABitOfEverything)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_CreateBook_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(CreateBookRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).CreateBook(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_CreateBook_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).CreateBook(ctx, req.(*CreateBookRequest)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_UpdateBook_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(UpdateBookRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).UpdateBook(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_UpdateBook_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).UpdateBook(ctx, req.(*UpdateBookRequest)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_Lookup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(sub2.IdMessage) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).Lookup(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_Lookup_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).Lookup(ctx, req.(*sub2.IdMessage)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_Custom_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ABitOfEverything) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).Custom(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_Custom_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).Custom(ctx, req.(*ABitOfEverything)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_DoubleColon_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ABitOfEverything) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).DoubleColon(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_DoubleColon_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).DoubleColon(ctx, req.(*ABitOfEverything)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ABitOfEverything) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).Update(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_Update_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).Update(ctx, req.(*ABitOfEverything)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_UpdateV2_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(UpdateV2Request) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).UpdateV2(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_UpdateV2_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).UpdateV2(ctx, req.(*UpdateV2Request)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(sub2.IdMessage) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).Delete(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_Delete_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).Delete(ctx, req.(*sub2.IdMessage)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_GetQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ABitOfEverything) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).GetQuery(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_GetQuery_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).GetQuery(ctx, req.(*ABitOfEverything)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_GetRepeatedQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ABitOfEverythingRepeated) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).GetRepeatedQuery(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_GetRepeatedQuery_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).GetRepeatedQuery(ctx, req.(*ABitOfEverythingRepeated)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_Echo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(sub.StringMessage) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).Echo(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_Echo_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).Echo(ctx, req.(*sub.StringMessage)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_DeepPathEcho_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ABitOfEverything) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).DeepPathEcho(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_DeepPathEcho_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).DeepPathEcho(ctx, req.(*ABitOfEverything)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_NoBindings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(durationpb.Duration) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).NoBindings(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_NoBindings_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).NoBindings(ctx, req.(*durationpb.Duration)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_Timeout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(emptypb.Empty) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).Timeout(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_Timeout_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).Timeout(ctx, req.(*emptypb.Empty)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_ErrorWithDetails_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(emptypb.Empty) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).ErrorWithDetails(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_ErrorWithDetails_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).ErrorWithDetails(ctx, req.(*emptypb.Empty)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_GetMessageWithBody_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MessageWithBody) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).GetMessageWithBody(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_GetMessageWithBody_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).GetMessageWithBody(ctx, req.(*MessageWithBody)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_PostWithEmptyBody_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(Body) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).PostWithEmptyBody(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_PostWithEmptyBody_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).PostWithEmptyBody(ctx, req.(*Body)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_CheckGetQueryParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ABitOfEverything) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).CheckGetQueryParams(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_CheckGetQueryParams_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).CheckGetQueryParams(ctx, req.(*ABitOfEverything)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_CheckNestedEnumGetQueryParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ABitOfEverything) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).CheckNestedEnumGetQueryParams(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_CheckNestedEnumGetQueryParams_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).CheckNestedEnumGetQueryParams(ctx, req.(*ABitOfEverything)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_CheckPostQueryParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ABitOfEverything) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).CheckPostQueryParams(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_CheckPostQueryParams_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).CheckPostQueryParams(ctx, req.(*ABitOfEverything)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_OverwriteRequestContentType_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(Body) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).OverwriteRequestContentType(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_OverwriteRequestContentType_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).OverwriteRequestContentType(ctx, req.(*Body)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_OverwriteResponseContentType_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(emptypb.Empty) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).OverwriteResponseContentType(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_OverwriteResponseContentType_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).OverwriteResponseContentType(ctx, req.(*emptypb.Empty)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_CheckExternalPathEnum_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(pathenum.MessageWithPathEnum) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).CheckExternalPathEnum(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_CheckExternalPathEnum_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).CheckExternalPathEnum(ctx, req.(*pathenum.MessageWithPathEnum)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_CheckExternalNestedPathEnum_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(pathenum.MessageWithNestedPathEnum) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).CheckExternalNestedPathEnum(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_CheckExternalNestedPathEnum_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).CheckExternalNestedPathEnum(ctx, req.(*pathenum.MessageWithNestedPathEnum)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_CheckStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(emptypb.Empty) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).CheckStatus(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_CheckStatus_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).CheckStatus(ctx, req.(*emptypb.Empty)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_Exists_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ABitOfEverything) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).Exists(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_Exists_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).Exists(ctx, req.(*ABitOfEverything)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_CustomOptionsRequest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ABitOfEverything) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).CustomOptionsRequest(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_CustomOptionsRequest_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).CustomOptionsRequest(ctx, req.(*ABitOfEverything)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_TraceRequest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ABitOfEverything) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).TraceRequest(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_TraceRequest_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).TraceRequest(ctx, req.(*ABitOfEverything)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_PostOneofEnum_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(oneofenum.OneofEnumMessage) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).PostOneofEnum(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_PostOneofEnum_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).PostOneofEnum(ctx, req.(*oneofenum.OneofEnumMessage)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_PostRequiredMessageType_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(RequiredMessageTypeRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ABitOfEverythingServiceServer).PostRequiredMessageType(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ABitOfEverythingService_PostRequiredMessageType_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ABitOfEverythingServiceServer).PostRequiredMessageType(ctx, req.(*RequiredMessageTypeRequest)) } return interceptor(ctx, in, info, handler) } // ABitOfEverythingService_ServiceDesc is the grpc.ServiceDesc for ABitOfEverythingService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var ABitOfEverythingService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.ABitOfEverythingService", HandlerType: (*ABitOfEverythingServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Create", Handler: _ABitOfEverythingService_Create_Handler, }, { MethodName: "CreateBody", Handler: _ABitOfEverythingService_CreateBody_Handler, }, { MethodName: "CreateBook", Handler: _ABitOfEverythingService_CreateBook_Handler, }, { MethodName: "UpdateBook", Handler: _ABitOfEverythingService_UpdateBook_Handler, }, { MethodName: "Lookup", Handler: _ABitOfEverythingService_Lookup_Handler, }, { MethodName: "Custom", Handler: _ABitOfEverythingService_Custom_Handler, }, { MethodName: "DoubleColon", Handler: _ABitOfEverythingService_DoubleColon_Handler, }, { MethodName: "Update", Handler: _ABitOfEverythingService_Update_Handler, }, { MethodName: "UpdateV2", Handler: _ABitOfEverythingService_UpdateV2_Handler, }, { MethodName: "Delete", Handler: _ABitOfEverythingService_Delete_Handler, }, { MethodName: "GetQuery", Handler: _ABitOfEverythingService_GetQuery_Handler, }, { MethodName: "GetRepeatedQuery", Handler: _ABitOfEverythingService_GetRepeatedQuery_Handler, }, { MethodName: "Echo", Handler: _ABitOfEverythingService_Echo_Handler, }, { MethodName: "DeepPathEcho", Handler: _ABitOfEverythingService_DeepPathEcho_Handler, }, { MethodName: "NoBindings", Handler: _ABitOfEverythingService_NoBindings_Handler, }, { MethodName: "Timeout", Handler: _ABitOfEverythingService_Timeout_Handler, }, { MethodName: "ErrorWithDetails", Handler: _ABitOfEverythingService_ErrorWithDetails_Handler, }, { MethodName: "GetMessageWithBody", Handler: _ABitOfEverythingService_GetMessageWithBody_Handler, }, { MethodName: "PostWithEmptyBody", Handler: _ABitOfEverythingService_PostWithEmptyBody_Handler, }, { MethodName: "CheckGetQueryParams", Handler: _ABitOfEverythingService_CheckGetQueryParams_Handler, }, { MethodName: "CheckNestedEnumGetQueryParams", Handler: _ABitOfEverythingService_CheckNestedEnumGetQueryParams_Handler, }, { MethodName: "CheckPostQueryParams", Handler: _ABitOfEverythingService_CheckPostQueryParams_Handler, }, { MethodName: "OverwriteRequestContentType", Handler: _ABitOfEverythingService_OverwriteRequestContentType_Handler, }, { MethodName: "OverwriteResponseContentType", Handler: _ABitOfEverythingService_OverwriteResponseContentType_Handler, }, { MethodName: "CheckExternalPathEnum", Handler: _ABitOfEverythingService_CheckExternalPathEnum_Handler, }, { MethodName: "CheckExternalNestedPathEnum", Handler: _ABitOfEverythingService_CheckExternalNestedPathEnum_Handler, }, { MethodName: "CheckStatus", Handler: _ABitOfEverythingService_CheckStatus_Handler, }, { MethodName: "Exists", Handler: _ABitOfEverythingService_Exists_Handler, }, { MethodName: "CustomOptionsRequest", Handler: _ABitOfEverythingService_CustomOptionsRequest_Handler, }, { MethodName: "TraceRequest", Handler: _ABitOfEverythingService_TraceRequest_Handler, }, { MethodName: "PostOneofEnum", Handler: _ABitOfEverythingService_PostOneofEnum_Handler, }, { MethodName: "PostRequiredMessageType", Handler: _ABitOfEverythingService_PostRequiredMessageType_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/internal/proto/examplepb/a_bit_of_everything.proto", } const ( CamelCaseServiceName_Empty_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.camelCaseServiceName/Empty" ) // CamelCaseServiceNameClient is the client API for CamelCaseServiceName service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // // camelCase and lowercase service names are valid but not recommended (use TitleCase instead) type CamelCaseServiceNameClient interface { Empty(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) } type camelCaseServiceNameClient struct { cc grpc.ClientConnInterface } func NewCamelCaseServiceNameClient(cc grpc.ClientConnInterface) CamelCaseServiceNameClient { return &camelCaseServiceNameClient{cc} } func (c *camelCaseServiceNameClient) Empty(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) err := c.cc.Invoke(ctx, CamelCaseServiceName_Empty_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // CamelCaseServiceNameServer is the server API for CamelCaseServiceName service. // All implementations should embed UnimplementedCamelCaseServiceNameServer // for forward compatibility. // // camelCase and lowercase service names are valid but not recommended (use TitleCase instead) type CamelCaseServiceNameServer interface { Empty(context.Context, *emptypb.Empty) (*emptypb.Empty, error) } // UnimplementedCamelCaseServiceNameServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedCamelCaseServiceNameServer struct{} func (UnimplementedCamelCaseServiceNameServer) Empty(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method Empty not implemented") } func (UnimplementedCamelCaseServiceNameServer) testEmbeddedByValue() {} // UnsafeCamelCaseServiceNameServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to CamelCaseServiceNameServer will // result in compilation errors. type UnsafeCamelCaseServiceNameServer interface { mustEmbedUnimplementedCamelCaseServiceNameServer() } func RegisterCamelCaseServiceNameServer(s grpc.ServiceRegistrar, srv CamelCaseServiceNameServer) { // If the following call pancis, it indicates UnimplementedCamelCaseServiceNameServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&CamelCaseServiceName_ServiceDesc, srv) } func _CamelCaseServiceName_Empty_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(emptypb.Empty) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(CamelCaseServiceNameServer).Empty(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: CamelCaseServiceName_Empty_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(CamelCaseServiceNameServer).Empty(ctx, req.(*emptypb.Empty)) } return interceptor(ctx, in, info, handler) } // CamelCaseServiceName_ServiceDesc is the grpc.ServiceDesc for CamelCaseServiceName service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var CamelCaseServiceName_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.camelCaseServiceName", HandlerType: (*CamelCaseServiceNameServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Empty", Handler: _CamelCaseServiceName_Empty_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/internal/proto/examplepb/a_bit_of_everything.proto", } const ( AnotherServiceWithNoBindings_NoBindings_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.AnotherServiceWithNoBindings/NoBindings" ) // AnotherServiceWithNoBindingsClient is the client API for AnotherServiceWithNoBindings service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type AnotherServiceWithNoBindingsClient interface { NoBindings(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) } type anotherServiceWithNoBindingsClient struct { cc grpc.ClientConnInterface } func NewAnotherServiceWithNoBindingsClient(cc grpc.ClientConnInterface) AnotherServiceWithNoBindingsClient { return &anotherServiceWithNoBindingsClient{cc} } func (c *anotherServiceWithNoBindingsClient) NoBindings(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) err := c.cc.Invoke(ctx, AnotherServiceWithNoBindings_NoBindings_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // AnotherServiceWithNoBindingsServer is the server API for AnotherServiceWithNoBindings service. // All implementations should embed UnimplementedAnotherServiceWithNoBindingsServer // for forward compatibility. type AnotherServiceWithNoBindingsServer interface { NoBindings(context.Context, *emptypb.Empty) (*emptypb.Empty, error) } // UnimplementedAnotherServiceWithNoBindingsServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedAnotherServiceWithNoBindingsServer struct{} func (UnimplementedAnotherServiceWithNoBindingsServer) NoBindings(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method NoBindings not implemented") } func (UnimplementedAnotherServiceWithNoBindingsServer) testEmbeddedByValue() {} // UnsafeAnotherServiceWithNoBindingsServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to AnotherServiceWithNoBindingsServer will // result in compilation errors. type UnsafeAnotherServiceWithNoBindingsServer interface { mustEmbedUnimplementedAnotherServiceWithNoBindingsServer() } func RegisterAnotherServiceWithNoBindingsServer(s grpc.ServiceRegistrar, srv AnotherServiceWithNoBindingsServer) { // If the following call pancis, it indicates UnimplementedAnotherServiceWithNoBindingsServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&AnotherServiceWithNoBindings_ServiceDesc, srv) } func _AnotherServiceWithNoBindings_NoBindings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(emptypb.Empty) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(AnotherServiceWithNoBindingsServer).NoBindings(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: AnotherServiceWithNoBindings_NoBindings_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(AnotherServiceWithNoBindingsServer).NoBindings(ctx, req.(*emptypb.Empty)) } return interceptor(ctx, in, info, handler) } // AnotherServiceWithNoBindings_ServiceDesc is the grpc.ServiceDesc for AnotherServiceWithNoBindings service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var AnotherServiceWithNoBindings_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.AnotherServiceWithNoBindings", HandlerType: (*AnotherServiceWithNoBindingsServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "NoBindings", Handler: _AnotherServiceWithNoBindings_NoBindings_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/internal/proto/examplepb/a_bit_of_everything.proto", } const ( SnakeEnumService_SnakeEnum_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.SnakeEnumService/SnakeEnum" ) // SnakeEnumServiceClient is the client API for SnakeEnumService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type SnakeEnumServiceClient interface { SnakeEnum(ctx context.Context, in *SnakeEnumRequest, opts ...grpc.CallOption) (*SnakeEnumResponse, error) } type snakeEnumServiceClient struct { cc grpc.ClientConnInterface } func NewSnakeEnumServiceClient(cc grpc.ClientConnInterface) SnakeEnumServiceClient { return &snakeEnumServiceClient{cc} } func (c *snakeEnumServiceClient) SnakeEnum(ctx context.Context, in *SnakeEnumRequest, opts ...grpc.CallOption) (*SnakeEnumResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(SnakeEnumResponse) err := c.cc.Invoke(ctx, SnakeEnumService_SnakeEnum_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // SnakeEnumServiceServer is the server API for SnakeEnumService service. // All implementations should embed UnimplementedSnakeEnumServiceServer // for forward compatibility. type SnakeEnumServiceServer interface { SnakeEnum(context.Context, *SnakeEnumRequest) (*SnakeEnumResponse, error) } // UnimplementedSnakeEnumServiceServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedSnakeEnumServiceServer struct{} func (UnimplementedSnakeEnumServiceServer) SnakeEnum(context.Context, *SnakeEnumRequest) (*SnakeEnumResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SnakeEnum not implemented") } func (UnimplementedSnakeEnumServiceServer) testEmbeddedByValue() {} // UnsafeSnakeEnumServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to SnakeEnumServiceServer will // result in compilation errors. type UnsafeSnakeEnumServiceServer interface { mustEmbedUnimplementedSnakeEnumServiceServer() } func RegisterSnakeEnumServiceServer(s grpc.ServiceRegistrar, srv SnakeEnumServiceServer) { // If the following call pancis, it indicates UnimplementedSnakeEnumServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&SnakeEnumService_ServiceDesc, srv) } func _SnakeEnumService_SnakeEnum_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SnakeEnumRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(SnakeEnumServiceServer).SnakeEnum(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: SnakeEnumService_SnakeEnum_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(SnakeEnumServiceServer).SnakeEnum(ctx, req.(*SnakeEnumRequest)) } return interceptor(ctx, in, info, handler) } // SnakeEnumService_ServiceDesc is the grpc.ServiceDesc for SnakeEnumService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var SnakeEnumService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.SnakeEnumService", HandlerType: (*SnakeEnumServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "SnakeEnum", Handler: _SnakeEnumService_SnakeEnum_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/internal/proto/examplepb/a_bit_of_everything.proto", } ================================================ FILE: examples/internal/proto/examplepb/camel_case_service.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/examplepb/camel_case_service.proto package examplepb import ( sub "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) type CamelStatus int32 const ( CamelStatus_CAMEL_STATUS_UNSPECIFIED CamelStatus = 0 CamelStatus_CAMEL_STATUS_AVAILABLE CamelStatus = 1 CamelStatus_CAMEL_STATUS_PENDING CamelStatus = 2 ) // Enum value maps for CamelStatus. var ( CamelStatus_name = map[int32]string{ 0: "CAMEL_STATUS_UNSPECIFIED", 1: "CAMEL_STATUS_AVAILABLE", 2: "CAMEL_STATUS_PENDING", } CamelStatus_value = map[string]int32{ "CAMEL_STATUS_UNSPECIFIED": 0, "CAMEL_STATUS_AVAILABLE": 1, "CAMEL_STATUS_PENDING": 2, } ) func (x CamelStatus) Enum() *CamelStatus { p := new(CamelStatus) *p = x return p } func (x CamelStatus) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (CamelStatus) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_examplepb_camel_case_service_proto_enumTypes[0].Descriptor() } func (CamelStatus) Type() protoreflect.EnumType { return &file_examples_internal_proto_examplepb_camel_case_service_proto_enumTypes[0] } func (x CamelStatus) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use CamelStatus.Descriptor instead. func (CamelStatus) EnumDescriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_camel_case_service_proto_rawDescGZIP(), []int{0} } type GetStatusRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields State CamelStatus `protobuf:"varint,1,opt,name=state,proto3,enum=grpc.gateway.examples.internal.proto.examplepb.CamelStatus" json:"state,omitempty"` } func (x *GetStatusRequest) Reset() { *x = GetStatusRequest{} mi := &file_examples_internal_proto_examplepb_camel_case_service_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *GetStatusRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*GetStatusRequest) ProtoMessage() {} func (x *GetStatusRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_camel_case_service_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use GetStatusRequest.ProtoReflect.Descriptor instead. func (*GetStatusRequest) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_camel_case_service_proto_rawDescGZIP(), []int{0} } func (x *GetStatusRequest) GetState() CamelStatus { if x != nil { return x.State } return CamelStatus_CAMEL_STATUS_UNSPECIFIED } type GetStatusResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields State CamelStatus `protobuf:"varint,1,opt,name=state,proto3,enum=grpc.gateway.examples.internal.proto.examplepb.CamelStatus" json:"state,omitempty"` } func (x *GetStatusResponse) Reset() { *x = GetStatusResponse{} mi := &file_examples_internal_proto_examplepb_camel_case_service_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *GetStatusResponse) String() string { return protoimpl.X.MessageStringOf(x) } func (*GetStatusResponse) ProtoMessage() {} func (x *GetStatusResponse) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_camel_case_service_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use GetStatusResponse.ProtoReflect.Descriptor instead. func (*GetStatusResponse) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_camel_case_service_proto_rawDescGZIP(), []int{1} } func (x *GetStatusResponse) GetState() CamelStatus { if x != nil { return x.State } return CamelStatus_CAMEL_STATUS_UNSPECIFIED } type PostBookRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Book *sub.CreateBook `protobuf:"bytes,1,opt,name=book,proto3" json:"book,omitempty"` } func (x *PostBookRequest) Reset() { *x = PostBookRequest{} mi := &file_examples_internal_proto_examplepb_camel_case_service_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *PostBookRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*PostBookRequest) ProtoMessage() {} func (x *PostBookRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_camel_case_service_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use PostBookRequest.ProtoReflect.Descriptor instead. func (*PostBookRequest) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_camel_case_service_proto_rawDescGZIP(), []int{2} } func (x *PostBookRequest) GetBook() *sub.CreateBook { if x != nil { return x.Book } return nil } type PostBookResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Book *sub.CreateBook `protobuf:"bytes,1,opt,name=book,proto3" json:"book,omitempty"` } func (x *PostBookResponse) Reset() { *x = PostBookResponse{} mi := &file_examples_internal_proto_examplepb_camel_case_service_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *PostBookResponse) String() string { return protoimpl.X.MessageStringOf(x) } func (*PostBookResponse) ProtoMessage() {} func (x *PostBookResponse) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_camel_case_service_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use PostBookResponse.ProtoReflect.Descriptor instead. func (*PostBookResponse) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_camel_case_service_proto_rawDescGZIP(), []int{3} } func (x *PostBookResponse) GetBook() *sub.CreateBook { if x != nil { return x.Book } return nil } var File_examples_internal_proto_examplepb_camel_case_service_proto protoreflect.FileDescriptor var file_examples_internal_proto_examplepb_camel_case_service_proto_rawDesc = []byte{ 0x0a, 0x3a, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x63, 0x61, 0x6d, 0x65, 0x6c, 0x5f, 0x63, 0x61, 0x73, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x34, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x75, 0x62, 0x2f, 0x63, 0x61, 0x6d, 0x65, 0x6c, 0x5f, 0x63, 0x61, 0x73, 0x65, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x65, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x51, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x43, 0x61, 0x6d, 0x65, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x22, 0x66, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x51, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x43, 0x61, 0x6d, 0x65, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x22, 0x5c, 0x0a, 0x0f, 0x50, 0x6f, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x49, 0x0a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x73, 0x75, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x62, 0x6f, 0x6f, 0x6b, 0x52, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x22, 0x5d, 0x0a, 0x10, 0x50, 0x6f, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x73, 0x75, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x62, 0x6f, 0x6f, 0x6b, 0x52, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x2a, 0x61, 0x0a, 0x0b, 0x43, 0x61, 0x6d, 0x65, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x0a, 0x18, 0x43, 0x41, 0x4d, 0x45, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1a, 0x0a, 0x16, 0x43, 0x41, 0x4d, 0x45, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x41, 0x56, 0x41, 0x49, 0x4c, 0x41, 0x42, 0x4c, 0x45, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x43, 0x41, 0x4d, 0x45, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x50, 0x45, 0x4e, 0x44, 0x49, 0x4e, 0x47, 0x10, 0x02, 0x32, 0xfd, 0x02, 0x0a, 0x12, 0x43, 0x61, 0x6d, 0x65, 0x6c, 0x5f, 0x43, 0x61, 0x73, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xb1, 0x01, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x41, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x18, 0x12, 0x16, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x61, 0x6d, 0x65, 0x6c, 0x5f, 0x63, 0x61, 0x73, 0x65, 0x2f, 0x7b, 0x73, 0x74, 0x61, 0x74, 0x65, 0x7d, 0x12, 0xb2, 0x01, 0x0a, 0x09, 0x50, 0x6f, 0x73, 0x74, 0x5f, 0x42, 0x6f, 0x6f, 0x6b, 0x12, 0x3f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x50, 0x6f, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x22, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c, 0x3a, 0x04, 0x62, 0x6f, 0x6f, 0x6b, 0x22, 0x14, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x61, 0x6d, 0x65, 0x6c, 0x5f, 0x63, 0x61, 0x73, 0x65, 0x2f, 0x62, 0x6f, 0x6f, 0x6b, 0x73, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_examplepb_camel_case_service_proto_rawDescOnce sync.Once file_examples_internal_proto_examplepb_camel_case_service_proto_rawDescData = file_examples_internal_proto_examplepb_camel_case_service_proto_rawDesc ) func file_examples_internal_proto_examplepb_camel_case_service_proto_rawDescGZIP() []byte { file_examples_internal_proto_examplepb_camel_case_service_proto_rawDescOnce.Do(func() { file_examples_internal_proto_examplepb_camel_case_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_examplepb_camel_case_service_proto_rawDescData) }) return file_examples_internal_proto_examplepb_camel_case_service_proto_rawDescData } var file_examples_internal_proto_examplepb_camel_case_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_examples_internal_proto_examplepb_camel_case_service_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_examples_internal_proto_examplepb_camel_case_service_proto_goTypes = []any{ (CamelStatus)(0), // 0: grpc.gateway.examples.internal.proto.examplepb.CamelStatus (*GetStatusRequest)(nil), // 1: grpc.gateway.examples.internal.proto.examplepb.GetStatusRequest (*GetStatusResponse)(nil), // 2: grpc.gateway.examples.internal.proto.examplepb.GetStatusResponse (*PostBookRequest)(nil), // 3: grpc.gateway.examples.internal.proto.examplepb.PostBookRequest (*PostBookResponse)(nil), // 4: grpc.gateway.examples.internal.proto.examplepb.PostBookResponse (*sub.CreateBook)(nil), // 5: grpc.gateway.examples.internal.proto.sub.Create_book } var file_examples_internal_proto_examplepb_camel_case_service_proto_depIdxs = []int32{ 0, // 0: grpc.gateway.examples.internal.proto.examplepb.GetStatusRequest.state:type_name -> grpc.gateway.examples.internal.proto.examplepb.CamelStatus 0, // 1: grpc.gateway.examples.internal.proto.examplepb.GetStatusResponse.state:type_name -> grpc.gateway.examples.internal.proto.examplepb.CamelStatus 5, // 2: grpc.gateway.examples.internal.proto.examplepb.PostBookRequest.book:type_name -> grpc.gateway.examples.internal.proto.sub.Create_book 5, // 3: grpc.gateway.examples.internal.proto.examplepb.PostBookResponse.book:type_name -> grpc.gateway.examples.internal.proto.sub.Create_book 1, // 4: grpc.gateway.examples.internal.proto.examplepb.Camel_Case_service.Get_status:input_type -> grpc.gateway.examples.internal.proto.examplepb.GetStatusRequest 3, // 5: grpc.gateway.examples.internal.proto.examplepb.Camel_Case_service.Post_Book:input_type -> grpc.gateway.examples.internal.proto.examplepb.PostBookRequest 2, // 6: grpc.gateway.examples.internal.proto.examplepb.Camel_Case_service.Get_status:output_type -> grpc.gateway.examples.internal.proto.examplepb.GetStatusResponse 4, // 7: grpc.gateway.examples.internal.proto.examplepb.Camel_Case_service.Post_Book:output_type -> grpc.gateway.examples.internal.proto.examplepb.PostBookResponse 6, // [6:8] is the sub-list for method output_type 4, // [4:6] is the sub-list for method input_type 4, // [4:4] is the sub-list for extension type_name 4, // [4:4] is the sub-list for extension extendee 0, // [0:4] is the sub-list for field type_name } func init() { file_examples_internal_proto_examplepb_camel_case_service_proto_init() } func file_examples_internal_proto_examplepb_camel_case_service_proto_init() { if File_examples_internal_proto_examplepb_camel_case_service_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_examplepb_camel_case_service_proto_rawDesc, NumEnums: 1, NumMessages: 4, NumExtensions: 0, NumServices: 1, }, GoTypes: file_examples_internal_proto_examplepb_camel_case_service_proto_goTypes, DependencyIndexes: file_examples_internal_proto_examplepb_camel_case_service_proto_depIdxs, EnumInfos: file_examples_internal_proto_examplepb_camel_case_service_proto_enumTypes, MessageInfos: file_examples_internal_proto_examplepb_camel_case_service_proto_msgTypes, }.Build() File_examples_internal_proto_examplepb_camel_case_service_proto = out.File file_examples_internal_proto_examplepb_camel_case_service_proto_rawDesc = nil file_examples_internal_proto_examplepb_camel_case_service_proto_goTypes = nil file_examples_internal_proto_examplepb_camel_case_service_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/examplepb/camel_case_service.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/proto/examplepb/camel_case_service.proto /* Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package examplepb import ( "context" "errors" "io" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) func request_Camel_CaseService_GetStatus_0(ctx context.Context, marshaler runtime.Marshaler, client Camel_CaseServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq GetStatusRequest metadata runtime.ServerMetadata e int32 err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["state"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "state") } e, err = runtime.Enum(val, CamelStatus_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "state", err) } protoReq.State = CamelStatus(e) msg, err := client.GetStatus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_Camel_CaseService_GetStatus_0(ctx context.Context, marshaler runtime.Marshaler, server Camel_CaseServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq GetStatusRequest metadata runtime.ServerMetadata e int32 err error ) val, ok := pathParams["state"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "state") } e, err = runtime.Enum(val, CamelStatus_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "state", err) } protoReq.State = CamelStatus(e) msg, err := server.GetStatus(ctx, &protoReq) return msg, metadata, err } func request_Camel_CaseService_Post_Book_0(ctx context.Context, marshaler runtime.Marshaler, client Camel_CaseServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq PostBookRequest metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Book); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.Post_Book(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_Camel_CaseService_Post_Book_0(ctx context.Context, marshaler runtime.Marshaler, server Camel_CaseServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq PostBookRequest metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Book); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Post_Book(ctx, &protoReq) return msg, metadata, err } // RegisterCamel_CaseServiceHandlerServer registers the http handlers for service Camel_CaseService to "mux". // UnaryRPC :call Camel_CaseServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterCamel_CaseServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterCamel_CaseServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server Camel_CaseServiceServer) error { mux.Handle(http.MethodGet, pattern_Camel_CaseService_GetStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.Camel_CaseService/GetStatus", runtime.WithHTTPPathPattern("/v1/camel_case/{state}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_Camel_CaseService_GetStatus_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Camel_CaseService_GetStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_Camel_CaseService_Post_Book_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.Camel_CaseService/Post_Book", runtime.WithHTTPPathPattern("/v1/camel_case/books")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_Camel_CaseService_Post_Book_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Camel_CaseService_Post_Book_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } // RegisterCamel_CaseServiceHandlerFromEndpoint is same as RegisterCamel_CaseServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterCamel_CaseServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterCamel_CaseServiceHandler(ctx, mux, conn) } // RegisterCamel_CaseServiceHandler registers the http handlers for service Camel_CaseService to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterCamel_CaseServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterCamel_CaseServiceHandlerClient(ctx, mux, NewCamel_CaseServiceClient(conn)) } // RegisterCamel_CaseServiceHandlerClient registers the http handlers for service Camel_CaseService // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "Camel_CaseServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "Camel_CaseServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "Camel_CaseServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterCamel_CaseServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client Camel_CaseServiceClient) error { mux.Handle(http.MethodGet, pattern_Camel_CaseService_GetStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.Camel_CaseService/GetStatus", runtime.WithHTTPPathPattern("/v1/camel_case/{state}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_Camel_CaseService_GetStatus_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Camel_CaseService_GetStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_Camel_CaseService_Post_Book_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.Camel_CaseService/Post_Book", runtime.WithHTTPPathPattern("/v1/camel_case/books")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_Camel_CaseService_Post_Book_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Camel_CaseService_Post_Book_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_Camel_CaseService_GetStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "camel_case", "state"}, "")) pattern_Camel_CaseService_Post_Book_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "camel_case", "books"}, "")) ) var ( forward_Camel_CaseService_GetStatus_0 = runtime.ForwardResponseMessage forward_Camel_CaseService_Post_Book_0 = runtime.ForwardResponseMessage ) ================================================ FILE: examples/internal/proto/examplepb/camel_case_service.proto ================================================ syntax = "proto3"; package grpc.gateway.examples.internal.proto.examplepb; import "examples/internal/proto/sub/camel_case_message.proto"; import "google/api/annotations.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; // Camel_Case_service consumes snake_case identifiers declared in the sub // package to ensure generated code camel-cases enum/message references, even // when service and RPC names are snake_case. service Camel_Case_service { rpc Get_status(GetStatusRequest) returns (GetStatusResponse) { option (google.api.http) = {get: "/v1/camel_case/{state}"}; } rpc Post_Book(PostBookRequest) returns (PostBookResponse) { option (google.api.http) = { post: "/v1/camel_case/books" body: "book" }; } } message GetStatusRequest { CamelStatus state = 1; } message GetStatusResponse { CamelStatus state = 1; } message PostBookRequest { grpc.gateway.examples.internal.proto.sub.Create_book book = 1; } message PostBookResponse { grpc.gateway.examples.internal.proto.sub.Create_book book = 1; } enum CamelStatus { CAMEL_STATUS_UNSPECIFIED = 0; CAMEL_STATUS_AVAILABLE = 1; CAMEL_STATUS_PENDING = 2; } ================================================ FILE: examples/internal/proto/examplepb/camel_case_service.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/examplepb/camel_case_service.proto", "version": "version not set" }, "tags": [ { "name": "Camel_Case_service" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/v1/camel_case/books": { "post": { "operationId": "Camel_Case_service_Post_Book", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbPostBookResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "book", "in": "body", "required": true, "schema": { "$ref": "#/definitions/subCreate_book" } } ], "tags": [ "Camel_Case_service" ] } }, "/v1/camel_case/{state}": { "get": { "operationId": "Camel_Case_service_Get_status", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbGetStatusResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "state", "in": "path", "required": true, "type": "string", "enum": [ "CAMEL_STATUS_UNSPECIFIED", "CAMEL_STATUS_AVAILABLE", "CAMEL_STATUS_PENDING" ] } ], "tags": [ "Camel_Case_service" ] } } }, "definitions": { "examplepbCamelStatus": { "type": "string", "enum": [ "CAMEL_STATUS_UNSPECIFIED", "CAMEL_STATUS_AVAILABLE", "CAMEL_STATUS_PENDING" ], "default": "CAMEL_STATUS_UNSPECIFIED" }, "examplepbGetStatusResponse": { "type": "object", "properties": { "state": { "$ref": "#/definitions/examplepbCamelStatus" } } }, "examplepbPostBookResponse": { "type": "object", "properties": { "book": { "$ref": "#/definitions/subCreate_book" } } }, "googleRpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32", "description": "The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]." }, "message": { "type": "string", "description": "A developer-facing error message, which should be in English. Any\nuser-facing error message should be localized and sent in the\n[google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client." }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" }, "description": "A list of messages that carry the error details. There is a common set of\nmessage types for APIs to use." } }, "description": "The `Status` type defines a logical error model that is suitable for\ndifferent programming environments, including REST APIs and RPC APIs. It is\nused by [gRPC](https://github.com/grpc). Each `Status` message contains\nthree pieces of data: error code, error message, and error details.\n\nYou can find out more about this error model and how to work with it in the\n[API Design Guide](https://cloud.google.com/apis/design/errors)." }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string", "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics." } }, "additionalProperties": {}, "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }" }, "subCreate_book": { "type": "object", "properties": { "title": { "type": "string" }, "author": { "type": "string" } }, "description": "Create_book and Status_enum demonstrate snake_case identifiers that need to\nbe resolved to Go camel case when referenced by other packages." } } } ================================================ FILE: examples/internal/proto/examplepb/camel_case_service_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: examples/internal/proto/examplepb/camel_case_service.proto package examplepb import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( Camel_CaseService_GetStatus_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.Camel_Case_service/Get_status" Camel_CaseService_Post_Book_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.Camel_Case_service/Post_Book" ) // Camel_CaseServiceClient is the client API for Camel_CaseService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // // Camel_Case_service consumes snake_case identifiers declared in the sub // package to ensure generated code camel-cases enum/message references, even // when service and RPC names are snake_case. type Camel_CaseServiceClient interface { GetStatus(ctx context.Context, in *GetStatusRequest, opts ...grpc.CallOption) (*GetStatusResponse, error) Post_Book(ctx context.Context, in *PostBookRequest, opts ...grpc.CallOption) (*PostBookResponse, error) } type camel_CaseServiceClient struct { cc grpc.ClientConnInterface } func NewCamel_CaseServiceClient(cc grpc.ClientConnInterface) Camel_CaseServiceClient { return &camel_CaseServiceClient{cc} } func (c *camel_CaseServiceClient) GetStatus(ctx context.Context, in *GetStatusRequest, opts ...grpc.CallOption) (*GetStatusResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(GetStatusResponse) err := c.cc.Invoke(ctx, Camel_CaseService_GetStatus_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *camel_CaseServiceClient) Post_Book(ctx context.Context, in *PostBookRequest, opts ...grpc.CallOption) (*PostBookResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(PostBookResponse) err := c.cc.Invoke(ctx, Camel_CaseService_Post_Book_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // Camel_CaseServiceServer is the server API for Camel_CaseService service. // All implementations should embed UnimplementedCamel_CaseServiceServer // for forward compatibility. // // Camel_Case_service consumes snake_case identifiers declared in the sub // package to ensure generated code camel-cases enum/message references, even // when service and RPC names are snake_case. type Camel_CaseServiceServer interface { GetStatus(context.Context, *GetStatusRequest) (*GetStatusResponse, error) Post_Book(context.Context, *PostBookRequest) (*PostBookResponse, error) } // UnimplementedCamel_CaseServiceServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedCamel_CaseServiceServer struct{} func (UnimplementedCamel_CaseServiceServer) GetStatus(context.Context, *GetStatusRequest) (*GetStatusResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetStatus not implemented") } func (UnimplementedCamel_CaseServiceServer) Post_Book(context.Context, *PostBookRequest) (*PostBookResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Post_Book not implemented") } func (UnimplementedCamel_CaseServiceServer) testEmbeddedByValue() {} // UnsafeCamel_CaseServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to Camel_CaseServiceServer will // result in compilation errors. type UnsafeCamel_CaseServiceServer interface { mustEmbedUnimplementedCamel_CaseServiceServer() } func RegisterCamel_CaseServiceServer(s grpc.ServiceRegistrar, srv Camel_CaseServiceServer) { // If the following call pancis, it indicates UnimplementedCamel_CaseServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&Camel_CaseService_ServiceDesc, srv) } func _Camel_CaseService_GetStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GetStatusRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(Camel_CaseServiceServer).GetStatus(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: Camel_CaseService_GetStatus_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(Camel_CaseServiceServer).GetStatus(ctx, req.(*GetStatusRequest)) } return interceptor(ctx, in, info, handler) } func _Camel_CaseService_Post_Book_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(PostBookRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(Camel_CaseServiceServer).Post_Book(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: Camel_CaseService_Post_Book_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(Camel_CaseServiceServer).Post_Book(ctx, req.(*PostBookRequest)) } return interceptor(ctx, in, info, handler) } // Camel_CaseService_ServiceDesc is the grpc.ServiceDesc for Camel_CaseService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var Camel_CaseService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.Camel_Case_service", HandlerType: (*Camel_CaseServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Get_status", Handler: _Camel_CaseService_GetStatus_Handler, }, { MethodName: "Post_Book", Handler: _Camel_CaseService_Post_Book_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/internal/proto/examplepb/camel_case_service.proto", } ================================================ FILE: examples/internal/proto/examplepb/echo_service.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/examplepb/echo_service.proto // Echo Service // // Echo Service API consists of a single service which returns // a message. package examplepb import ( sub "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub" sub2 "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub2" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" structpb "google.golang.org/protobuf/types/known/structpb" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) // Embedded represents a message embedded in SimpleMessage. type Embedded struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Types that are assignable to Mark: // // *Embedded_Progress // *Embedded_Note Mark isEmbedded_Mark `protobuf_oneof:"mark"` } func (x *Embedded) Reset() { *x = Embedded{} mi := &file_examples_internal_proto_examplepb_echo_service_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Embedded) String() string { return protoimpl.X.MessageStringOf(x) } func (*Embedded) ProtoMessage() {} func (x *Embedded) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_echo_service_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Embedded.ProtoReflect.Descriptor instead. func (*Embedded) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_echo_service_proto_rawDescGZIP(), []int{0} } func (m *Embedded) GetMark() isEmbedded_Mark { if m != nil { return m.Mark } return nil } func (x *Embedded) GetProgress() int64 { if x, ok := x.GetMark().(*Embedded_Progress); ok { return x.Progress } return 0 } func (x *Embedded) GetNote() string { if x, ok := x.GetMark().(*Embedded_Note); ok { return x.Note } return "" } type isEmbedded_Mark interface { isEmbedded_Mark() } type Embedded_Progress struct { Progress int64 `protobuf:"varint,1,opt,name=progress,proto3,oneof"` } type Embedded_Note struct { Note string `protobuf:"bytes,2,opt,name=note,proto3,oneof"` } func (*Embedded_Progress) isEmbedded_Mark() {} func (*Embedded_Note) isEmbedded_Mark() {} type NestedMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields NId string `protobuf:"bytes,1,opt,name=n_id,json=nId,proto3" json:"n_id,omitempty"` Val string `protobuf:"bytes,2,opt,name=val,proto3" json:"val,omitempty"` } func (x *NestedMessage) Reset() { *x = NestedMessage{} mi := &file_examples_internal_proto_examplepb_echo_service_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NestedMessage) String() string { return protoimpl.X.MessageStringOf(x) } func (*NestedMessage) ProtoMessage() {} func (x *NestedMessage) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_echo_service_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NestedMessage.ProtoReflect.Descriptor instead. func (*NestedMessage) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_echo_service_proto_rawDescGZIP(), []int{1} } func (x *NestedMessage) GetNId() string { if x != nil { return x.NId } return "" } func (x *NestedMessage) GetVal() string { if x != nil { return x.Val } return "" } // SimpleMessage represents a simple message sent to the Echo service. type SimpleMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Id represents the message identifier. Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Num int64 `protobuf:"varint,2,opt,name=num,proto3" json:"num,omitempty"` // Types that are assignable to Code: // // *SimpleMessage_LineNum // *SimpleMessage_Lang Code isSimpleMessage_Code `protobuf_oneof:"code"` Status *Embedded `protobuf:"bytes,5,opt,name=status,proto3" json:"status,omitempty"` // Types that are assignable to Ext: // // *SimpleMessage_En // *SimpleMessage_No Ext isSimpleMessage_Ext `protobuf_oneof:"ext"` ResourceId string `protobuf:"bytes,8,opt,name=resource_id,json=resourceId,proto3" json:"resource_id,omitempty"` NId *NestedMessage `protobuf:"bytes,9,opt,name=n_id,json=nId,proto3" json:"n_id,omitempty"` } func (x *SimpleMessage) Reset() { *x = SimpleMessage{} mi := &file_examples_internal_proto_examplepb_echo_service_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *SimpleMessage) String() string { return protoimpl.X.MessageStringOf(x) } func (*SimpleMessage) ProtoMessage() {} func (x *SimpleMessage) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_echo_service_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use SimpleMessage.ProtoReflect.Descriptor instead. func (*SimpleMessage) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_echo_service_proto_rawDescGZIP(), []int{2} } func (x *SimpleMessage) GetId() string { if x != nil { return x.Id } return "" } func (x *SimpleMessage) GetNum() int64 { if x != nil { return x.Num } return 0 } func (m *SimpleMessage) GetCode() isSimpleMessage_Code { if m != nil { return m.Code } return nil } func (x *SimpleMessage) GetLineNum() int64 { if x, ok := x.GetCode().(*SimpleMessage_LineNum); ok { return x.LineNum } return 0 } func (x *SimpleMessage) GetLang() string { if x, ok := x.GetCode().(*SimpleMessage_Lang); ok { return x.Lang } return "" } func (x *SimpleMessage) GetStatus() *Embedded { if x != nil { return x.Status } return nil } func (m *SimpleMessage) GetExt() isSimpleMessage_Ext { if m != nil { return m.Ext } return nil } func (x *SimpleMessage) GetEn() int64 { if x, ok := x.GetExt().(*SimpleMessage_En); ok { return x.En } return 0 } func (x *SimpleMessage) GetNo() *Embedded { if x, ok := x.GetExt().(*SimpleMessage_No); ok { return x.No } return nil } func (x *SimpleMessage) GetResourceId() string { if x != nil { return x.ResourceId } return "" } func (x *SimpleMessage) GetNId() *NestedMessage { if x != nil { return x.NId } return nil } type isSimpleMessage_Code interface { isSimpleMessage_Code() } type SimpleMessage_LineNum struct { LineNum int64 `protobuf:"varint,3,opt,name=line_num,json=lineNum,proto3,oneof"` } type SimpleMessage_Lang struct { Lang string `protobuf:"bytes,4,opt,name=lang,proto3,oneof"` } func (*SimpleMessage_LineNum) isSimpleMessage_Code() {} func (*SimpleMessage_Lang) isSimpleMessage_Code() {} type isSimpleMessage_Ext interface { isSimpleMessage_Ext() } type SimpleMessage_En struct { En int64 `protobuf:"varint,6,opt,name=en,proto3,oneof"` } type SimpleMessage_No struct { No *Embedded `protobuf:"bytes,7,opt,name=no,proto3,oneof"` } func (*SimpleMessage_En) isSimpleMessage_Ext() {} func (*SimpleMessage_No) isSimpleMessage_Ext() {} // DynamicMessage represents a message which can have its structure // built dynamically using Struct and Values. type DynamicMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields StructField *structpb.Struct `protobuf:"bytes,1,opt,name=struct_field,json=structField,proto3" json:"struct_field,omitempty"` ValueField *structpb.Value `protobuf:"bytes,2,opt,name=value_field,json=valueField,proto3" json:"value_field,omitempty"` } func (x *DynamicMessage) Reset() { *x = DynamicMessage{} mi := &file_examples_internal_proto_examplepb_echo_service_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *DynamicMessage) String() string { return protoimpl.X.MessageStringOf(x) } func (*DynamicMessage) ProtoMessage() {} func (x *DynamicMessage) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_echo_service_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use DynamicMessage.ProtoReflect.Descriptor instead. func (*DynamicMessage) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_echo_service_proto_rawDescGZIP(), []int{3} } func (x *DynamicMessage) GetStructField() *structpb.Struct { if x != nil { return x.StructField } return nil } func (x *DynamicMessage) GetValueField() *structpb.Value { if x != nil { return x.ValueField } return nil } type DynamicMessageUpdate struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Body *DynamicMessage `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"` UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,2,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"` } func (x *DynamicMessageUpdate) Reset() { *x = DynamicMessageUpdate{} mi := &file_examples_internal_proto_examplepb_echo_service_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *DynamicMessageUpdate) String() string { return protoimpl.X.MessageStringOf(x) } func (*DynamicMessageUpdate) ProtoMessage() {} func (x *DynamicMessageUpdate) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_echo_service_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use DynamicMessageUpdate.ProtoReflect.Descriptor instead. func (*DynamicMessageUpdate) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_echo_service_proto_rawDescGZIP(), []int{4} } func (x *DynamicMessageUpdate) GetBody() *DynamicMessage { if x != nil { return x.Body } return nil } func (x *DynamicMessageUpdate) GetUpdateMask() *fieldmaskpb.FieldMask { if x != nil { return x.UpdateMask } return nil } // StatusCheckRequest demonstrates name collision handling. // It uses Status message from both sub and sub2 packages. type StatusCheckRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // Status from sub package SubStatus *sub.Status `protobuf:"bytes,2,opt,name=sub_status,json=subStatus,proto3" json:"sub_status,omitempty"` // Status from sub2 package (different type with same name) Sub2Status *sub2.Status `protobuf:"bytes,3,opt,name=sub2_status,json=sub2Status,proto3" json:"sub2_status,omitempty"` } func (x *StatusCheckRequest) Reset() { *x = StatusCheckRequest{} mi := &file_examples_internal_proto_examplepb_echo_service_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *StatusCheckRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*StatusCheckRequest) ProtoMessage() {} func (x *StatusCheckRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_echo_service_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use StatusCheckRequest.ProtoReflect.Descriptor instead. func (*StatusCheckRequest) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_echo_service_proto_rawDescGZIP(), []int{5} } func (x *StatusCheckRequest) GetId() string { if x != nil { return x.Id } return "" } func (x *StatusCheckRequest) GetSubStatus() *sub.Status { if x != nil { return x.SubStatus } return nil } func (x *StatusCheckRequest) GetSub2Status() *sub2.Status { if x != nil { return x.Sub2Status } return nil } type StatusCheckResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Result string `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` // Both Status types used in response SubStatus *sub.Status `protobuf:"bytes,2,opt,name=sub_status,json=subStatus,proto3" json:"sub_status,omitempty"` Sub2Status *sub2.Status `protobuf:"bytes,3,opt,name=sub2_status,json=sub2Status,proto3" json:"sub2_status,omitempty"` } func (x *StatusCheckResponse) Reset() { *x = StatusCheckResponse{} mi := &file_examples_internal_proto_examplepb_echo_service_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *StatusCheckResponse) String() string { return protoimpl.X.MessageStringOf(x) } func (*StatusCheckResponse) ProtoMessage() {} func (x *StatusCheckResponse) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_echo_service_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use StatusCheckResponse.ProtoReflect.Descriptor instead. func (*StatusCheckResponse) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_echo_service_proto_rawDescGZIP(), []int{6} } func (x *StatusCheckResponse) GetResult() string { if x != nil { return x.Result } return "" } func (x *StatusCheckResponse) GetSubStatus() *sub.Status { if x != nil { return x.SubStatus } return nil } func (x *StatusCheckResponse) GetSub2Status() *sub2.Status { if x != nil { return x.Sub2Status } return nil } var File_examples_internal_proto_examplepb_echo_service_proto protoreflect.FileDescriptor var file_examples_internal_proto_examplepb_echo_service_proto_rawDesc = []byte{ 0x0a, 0x34, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x29, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x75, 0x62, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2a, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x75, 0x62, 0x32, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x46, 0x0a, 0x08, 0x45, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x12, 0x1c, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x14, 0x0a, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x42, 0x06, 0x0a, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x22, 0x34, 0x0a, 0x0d, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x11, 0x0a, 0x04, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6e, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x22, 0x96, 0x03, 0x0a, 0x0d, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6e, 0x75, 0x6d, 0x12, 0x1b, 0x0a, 0x08, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00, 0x52, 0x07, 0x6c, 0x69, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x14, 0x0a, 0x04, 0x6c, 0x61, 0x6e, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04, 0x6c, 0x61, 0x6e, 0x67, 0x12, 0x50, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x38, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x10, 0x0a, 0x02, 0x65, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x48, 0x01, 0x52, 0x02, 0x65, 0x6e, 0x12, 0x4a, 0x0a, 0x02, 0x6e, 0x6f, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x38, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x48, 0x01, 0x52, 0x02, 0x6e, 0x6f, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x12, 0x50, 0x0a, 0x04, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x3d, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x03, 0x6e, 0x49, 0x64, 0x42, 0x06, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x42, 0x05, 0x0a, 0x03, 0x65, 0x78, 0x74, 0x22, 0x85, 0x01, 0x0a, 0x0e, 0x44, 0x79, 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x3a, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x37, 0x0a, 0x0b, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x22, 0xa7, 0x01, 0x0a, 0x14, 0x44, 0x79, 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x52, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x3e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x44, 0x79, 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x3b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x6b, 0x22, 0xc9, 0x01, 0x0a, 0x12, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x4f, 0x0a, 0x0a, 0x73, 0x75, 0x62, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x73, 0x75, 0x62, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x09, 0x73, 0x75, 0x62, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x52, 0x0a, 0x0b, 0x73, 0x75, 0x62, 0x32, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x73, 0x75, 0x62, 0x32, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x0a, 0x73, 0x75, 0x62, 0x32, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0xd2, 0x01, 0x0a, 0x13, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x4f, 0x0a, 0x0a, 0x73, 0x75, 0x62, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x73, 0x75, 0x62, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x09, 0x73, 0x75, 0x62, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x52, 0x0a, 0x0b, 0x73, 0x75, 0x62, 0x32, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x73, 0x75, 0x62, 0x32, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x0a, 0x73, 0x75, 0x62, 0x32, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x32, 0xd1, 0x0a, 0x0a, 0x0b, 0x45, 0x63, 0x68, 0x6f, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x8e, 0x03, 0x0a, 0x04, 0x45, 0x63, 0x68, 0x6f, 0x12, 0x3d, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x3d, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x87, 0x02, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x80, 0x02, 0x5a, 0x1d, 0x12, 0x1b, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x2f, 0x7b, 0x6e, 0x75, 0x6d, 0x7d, 0x5a, 0x24, 0x12, 0x22, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x2f, 0x7b, 0x6e, 0x75, 0x6d, 0x7d, 0x2f, 0x7b, 0x6c, 0x61, 0x6e, 0x67, 0x7d, 0x5a, 0x31, 0x12, 0x2f, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x31, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x2f, 0x7b, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x7d, 0x2f, 0x7b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x7d, 0x5a, 0x1d, 0x12, 0x1b, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x32, 0x2f, 0x7b, 0x6e, 0x6f, 0x2e, 0x6e, 0x6f, 0x74, 0x65, 0x7d, 0x5a, 0x29, 0x12, 0x27, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2f, 0x7b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x7d, 0x5a, 0x25, 0x12, 0x23, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x2f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x2f, 0x7b, 0x6e, 0x5f, 0x69, 0x64, 0x2e, 0x6e, 0x5f, 0x69, 0x64, 0x7d, 0x22, 0x15, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0xcc, 0x01, 0x0a, 0x08, 0x45, 0x63, 0x68, 0x6f, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x3d, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x3d, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x42, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x3c, 0x3a, 0x01, 0x2a, 0x5a, 0x20, 0x3a, 0x02, 0x6e, 0x6f, 0x1a, 0x1a, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x5f, 0x62, 0x6f, 0x64, 0x79, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x22, 0x15, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x5f, 0x62, 0x6f, 0x64, 0x79, 0x12, 0xab, 0x01, 0x0a, 0x0a, 0x45, 0x63, 0x68, 0x6f, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x3d, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x3d, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x1f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x2a, 0x17, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x5f, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0xbd, 0x01, 0x0a, 0x09, 0x45, 0x63, 0x68, 0x6f, 0x50, 0x61, 0x74, 0x63, 0x68, 0x12, 0x44, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x44, 0x79, 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x1a, 0x44, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x44, 0x79, 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x22, 0x24, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x3a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x32, 0x16, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x5f, 0x70, 0x61, 0x74, 0x63, 0x68, 0x12, 0xb7, 0x01, 0x0a, 0x10, 0x45, 0x63, 0x68, 0x6f, 0x55, 0x6e, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x12, 0x3d, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x3d, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x25, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1f, 0x12, 0x1d, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x5f, 0x75, 0x6e, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x12, 0xb9, 0x01, 0x0a, 0x0a, 0x45, 0x63, 0x68, 0x6f, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x42, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x43, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x22, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c, 0x3a, 0x01, 0x2a, 0x22, 0x17, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_examplepb_echo_service_proto_rawDescOnce sync.Once file_examples_internal_proto_examplepb_echo_service_proto_rawDescData = file_examples_internal_proto_examplepb_echo_service_proto_rawDesc ) func file_examples_internal_proto_examplepb_echo_service_proto_rawDescGZIP() []byte { file_examples_internal_proto_examplepb_echo_service_proto_rawDescOnce.Do(func() { file_examples_internal_proto_examplepb_echo_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_examplepb_echo_service_proto_rawDescData) }) return file_examples_internal_proto_examplepb_echo_service_proto_rawDescData } var file_examples_internal_proto_examplepb_echo_service_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_examples_internal_proto_examplepb_echo_service_proto_goTypes = []any{ (*Embedded)(nil), // 0: grpc.gateway.examples.internal.proto.examplepb.Embedded (*NestedMessage)(nil), // 1: grpc.gateway.examples.internal.proto.examplepb.NestedMessage (*SimpleMessage)(nil), // 2: grpc.gateway.examples.internal.proto.examplepb.SimpleMessage (*DynamicMessage)(nil), // 3: grpc.gateway.examples.internal.proto.examplepb.DynamicMessage (*DynamicMessageUpdate)(nil), // 4: grpc.gateway.examples.internal.proto.examplepb.DynamicMessageUpdate (*StatusCheckRequest)(nil), // 5: grpc.gateway.examples.internal.proto.examplepb.StatusCheckRequest (*StatusCheckResponse)(nil), // 6: grpc.gateway.examples.internal.proto.examplepb.StatusCheckResponse (*structpb.Struct)(nil), // 7: google.protobuf.Struct (*structpb.Value)(nil), // 8: google.protobuf.Value (*fieldmaskpb.FieldMask)(nil), // 9: google.protobuf.FieldMask (*sub.Status)(nil), // 10: grpc.gateway.examples.internal.proto.sub.Status (*sub2.Status)(nil), // 11: grpc.gateway.examples.internal.proto.sub2.Status } var file_examples_internal_proto_examplepb_echo_service_proto_depIdxs = []int32{ 0, // 0: grpc.gateway.examples.internal.proto.examplepb.SimpleMessage.status:type_name -> grpc.gateway.examples.internal.proto.examplepb.Embedded 0, // 1: grpc.gateway.examples.internal.proto.examplepb.SimpleMessage.no:type_name -> grpc.gateway.examples.internal.proto.examplepb.Embedded 1, // 2: grpc.gateway.examples.internal.proto.examplepb.SimpleMessage.n_id:type_name -> grpc.gateway.examples.internal.proto.examplepb.NestedMessage 7, // 3: grpc.gateway.examples.internal.proto.examplepb.DynamicMessage.struct_field:type_name -> google.protobuf.Struct 8, // 4: grpc.gateway.examples.internal.proto.examplepb.DynamicMessage.value_field:type_name -> google.protobuf.Value 3, // 5: grpc.gateway.examples.internal.proto.examplepb.DynamicMessageUpdate.body:type_name -> grpc.gateway.examples.internal.proto.examplepb.DynamicMessage 9, // 6: grpc.gateway.examples.internal.proto.examplepb.DynamicMessageUpdate.update_mask:type_name -> google.protobuf.FieldMask 10, // 7: grpc.gateway.examples.internal.proto.examplepb.StatusCheckRequest.sub_status:type_name -> grpc.gateway.examples.internal.proto.sub.Status 11, // 8: grpc.gateway.examples.internal.proto.examplepb.StatusCheckRequest.sub2_status:type_name -> grpc.gateway.examples.internal.proto.sub2.Status 10, // 9: grpc.gateway.examples.internal.proto.examplepb.StatusCheckResponse.sub_status:type_name -> grpc.gateway.examples.internal.proto.sub.Status 11, // 10: grpc.gateway.examples.internal.proto.examplepb.StatusCheckResponse.sub2_status:type_name -> grpc.gateway.examples.internal.proto.sub2.Status 2, // 11: grpc.gateway.examples.internal.proto.examplepb.EchoService.Echo:input_type -> grpc.gateway.examples.internal.proto.examplepb.SimpleMessage 2, // 12: grpc.gateway.examples.internal.proto.examplepb.EchoService.EchoBody:input_type -> grpc.gateway.examples.internal.proto.examplepb.SimpleMessage 2, // 13: grpc.gateway.examples.internal.proto.examplepb.EchoService.EchoDelete:input_type -> grpc.gateway.examples.internal.proto.examplepb.SimpleMessage 4, // 14: grpc.gateway.examples.internal.proto.examplepb.EchoService.EchoPatch:input_type -> grpc.gateway.examples.internal.proto.examplepb.DynamicMessageUpdate 2, // 15: grpc.gateway.examples.internal.proto.examplepb.EchoService.EchoUnauthorized:input_type -> grpc.gateway.examples.internal.proto.examplepb.SimpleMessage 5, // 16: grpc.gateway.examples.internal.proto.examplepb.EchoService.EchoStatus:input_type -> grpc.gateway.examples.internal.proto.examplepb.StatusCheckRequest 2, // 17: grpc.gateway.examples.internal.proto.examplepb.EchoService.Echo:output_type -> grpc.gateway.examples.internal.proto.examplepb.SimpleMessage 2, // 18: grpc.gateway.examples.internal.proto.examplepb.EchoService.EchoBody:output_type -> grpc.gateway.examples.internal.proto.examplepb.SimpleMessage 2, // 19: grpc.gateway.examples.internal.proto.examplepb.EchoService.EchoDelete:output_type -> grpc.gateway.examples.internal.proto.examplepb.SimpleMessage 4, // 20: grpc.gateway.examples.internal.proto.examplepb.EchoService.EchoPatch:output_type -> grpc.gateway.examples.internal.proto.examplepb.DynamicMessageUpdate 2, // 21: grpc.gateway.examples.internal.proto.examplepb.EchoService.EchoUnauthorized:output_type -> grpc.gateway.examples.internal.proto.examplepb.SimpleMessage 6, // 22: grpc.gateway.examples.internal.proto.examplepb.EchoService.EchoStatus:output_type -> grpc.gateway.examples.internal.proto.examplepb.StatusCheckResponse 17, // [17:23] is the sub-list for method output_type 11, // [11:17] is the sub-list for method input_type 11, // [11:11] is the sub-list for extension type_name 11, // [11:11] is the sub-list for extension extendee 0, // [0:11] is the sub-list for field type_name } func init() { file_examples_internal_proto_examplepb_echo_service_proto_init() } func file_examples_internal_proto_examplepb_echo_service_proto_init() { if File_examples_internal_proto_examplepb_echo_service_proto != nil { return } file_examples_internal_proto_examplepb_echo_service_proto_msgTypes[0].OneofWrappers = []any{ (*Embedded_Progress)(nil), (*Embedded_Note)(nil), } file_examples_internal_proto_examplepb_echo_service_proto_msgTypes[2].OneofWrappers = []any{ (*SimpleMessage_LineNum)(nil), (*SimpleMessage_Lang)(nil), (*SimpleMessage_En)(nil), (*SimpleMessage_No)(nil), } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_examplepb_echo_service_proto_rawDesc, NumEnums: 0, NumMessages: 7, NumExtensions: 0, NumServices: 1, }, GoTypes: file_examples_internal_proto_examplepb_echo_service_proto_goTypes, DependencyIndexes: file_examples_internal_proto_examplepb_echo_service_proto_depIdxs, MessageInfos: file_examples_internal_proto_examplepb_echo_service_proto_msgTypes, }.Build() File_examples_internal_proto_examplepb_echo_service_proto = out.File file_examples_internal_proto_examplepb_echo_service_proto_rawDesc = nil file_examples_internal_proto_examplepb_echo_service_proto_goTypes = nil file_examples_internal_proto_examplepb_echo_service_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/examplepb/echo_service.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/proto/examplepb/echo_service.proto /* Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package examplepb import ( "context" "errors" "io" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) var filter_EchoService_Echo_0 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_EchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_Echo_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_EchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, server EchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata err error ) val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_Echo_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Echo(ctx, &protoReq) return msg, metadata, err } var filter_EchoService_Echo_1 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0, "num": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} func request_EchoService_Echo_1(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } val, ok = pathParams["num"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "num") } protoReq.Num, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "num", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_Echo_1); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_EchoService_Echo_1(ctx context.Context, marshaler runtime.Marshaler, server EchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata err error ) val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } val, ok = pathParams["num"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "num") } protoReq.Num, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "num", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_Echo_1); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Echo(ctx, &protoReq) return msg, metadata, err } var filter_EchoService_Echo_2 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0, "num": 1, "lang": 2}, Base: []int{1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 1, 1, 2, 3, 4}} func request_EchoService_Echo_2(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } val, ok = pathParams["num"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "num") } protoReq.Num, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "num", err) } val, ok = pathParams["lang"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "lang") } if protoReq.Code == nil { protoReq.Code = &SimpleMessage_Lang{} } else if _, ok := protoReq.Code.(*SimpleMessage_Lang); !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "expect type: *SimpleMessage_Lang, but: %t\n", protoReq.Code) } protoReq.Code.(*SimpleMessage_Lang).Lang, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "lang", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_Echo_2); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_EchoService_Echo_2(ctx context.Context, marshaler runtime.Marshaler, server EchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata err error ) val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } val, ok = pathParams["num"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "num") } protoReq.Num, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "num", err) } val, ok = pathParams["lang"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "lang") } if protoReq.Code == nil { protoReq.Code = &SimpleMessage_Lang{} } else if _, ok := protoReq.Code.(*SimpleMessage_Lang); !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "expect type: *SimpleMessage_Lang, but: %t\n", protoReq.Code) } protoReq.Code.(*SimpleMessage_Lang).Lang, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "lang", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_Echo_2); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Echo(ctx, &protoReq) return msg, metadata, err } var filter_EchoService_Echo_3 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0, "line_num": 1, "status": 2, "note": 3}, Base: []int{1, 1, 2, 1, 3, 0, 0, 0}, Check: []int{0, 1, 1, 1, 4, 2, 3, 5}} func request_EchoService_Echo_3(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } val, ok = pathParams["line_num"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "line_num") } if protoReq.Code == nil { protoReq.Code = &SimpleMessage_LineNum{} } else if _, ok := protoReq.Code.(*SimpleMessage_LineNum); !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "expect type: *SimpleMessage_LineNum, but: %t\n", protoReq.Code) } protoReq.Code.(*SimpleMessage_LineNum).LineNum, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "line_num", err) } val, ok = pathParams["status.note"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "status.note") } err = runtime.PopulateFieldFromPath(&protoReq, "status.note", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "status.note", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_Echo_3); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_EchoService_Echo_3(ctx context.Context, marshaler runtime.Marshaler, server EchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata err error ) val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } val, ok = pathParams["line_num"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "line_num") } if protoReq.Code == nil { protoReq.Code = &SimpleMessage_LineNum{} } else if _, ok := protoReq.Code.(*SimpleMessage_LineNum); !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "expect type: *SimpleMessage_LineNum, but: %t\n", protoReq.Code) } protoReq.Code.(*SimpleMessage_LineNum).LineNum, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "line_num", err) } val, ok = pathParams["status.note"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "status.note") } err = runtime.PopulateFieldFromPath(&protoReq, "status.note", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "status.note", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_Echo_3); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Echo(ctx, &protoReq) return msg, metadata, err } var filter_EchoService_Echo_4 = &utilities.DoubleArray{Encoding: map[string]int{"no": 0, "note": 1}, Base: []int{1, 1, 1, 0}, Check: []int{0, 1, 2, 3}} func request_EchoService_Echo_4(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["no.note"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "no.note") } err = runtime.PopulateFieldFromPath(&protoReq, "no.note", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "no.note", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_Echo_4); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_EchoService_Echo_4(ctx context.Context, marshaler runtime.Marshaler, server EchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata err error ) val, ok := pathParams["no.note"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "no.note") } err = runtime.PopulateFieldFromPath(&protoReq, "no.note", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "no.note", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_Echo_4); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Echo(ctx, &protoReq) return msg, metadata, err } var filter_EchoService_Echo_5 = &utilities.DoubleArray{Encoding: map[string]int{"resource_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_EchoService_Echo_5(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["resource_id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "resource_id") } protoReq.ResourceId, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "resource_id", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_Echo_5); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_EchoService_Echo_5(ctx context.Context, marshaler runtime.Marshaler, server EchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata err error ) val, ok := pathParams["resource_id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "resource_id") } protoReq.ResourceId, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "resource_id", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_Echo_5); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Echo(ctx, &protoReq) return msg, metadata, err } var filter_EchoService_Echo_6 = &utilities.DoubleArray{Encoding: map[string]int{"n_id": 0}, Base: []int{1, 2, 2, 0}, Check: []int{0, 1, 2, 3}} func request_EchoService_Echo_6(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["n_id.n_id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "n_id.n_id") } err = runtime.PopulateFieldFromPath(&protoReq, "n_id.n_id", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "n_id.n_id", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_Echo_6); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_EchoService_Echo_6(ctx context.Context, marshaler runtime.Marshaler, server EchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata err error ) val, ok := pathParams["n_id.n_id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "n_id.n_id") } err = runtime.PopulateFieldFromPath(&protoReq, "n_id.n_id", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "n_id.n_id", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_Echo_6); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Echo(ctx, &protoReq) return msg, metadata, err } func request_EchoService_EchoBody_0(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.EchoBody(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_EchoService_EchoBody_0(ctx context.Context, marshaler runtime.Marshaler, server EchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.EchoBody(ctx, &protoReq) return msg, metadata, err } var filter_EchoService_EchoBody_1 = &utilities.DoubleArray{Encoding: map[string]int{"no": 0, "id": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} func request_EchoService_EchoBody_1(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata err error ) if protoReq.Ext == nil { protoReq.Ext = &SimpleMessage_No{} } else if _, ok := protoReq.Ext.(*SimpleMessage_No); !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "expect type: *SimpleMessage_No, but: %t\n", protoReq.Ext) } if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Ext.(*SimpleMessage_No).No); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_EchoBody_1); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.EchoBody(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_EchoService_EchoBody_1(ctx context.Context, marshaler runtime.Marshaler, server EchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata err error ) if protoReq.Ext == nil { protoReq.Ext = &SimpleMessage_No{} } else if _, ok := protoReq.Ext.(*SimpleMessage_No); !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "expect type: *SimpleMessage_No, but: %t\n", protoReq.Ext) } if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Ext.(*SimpleMessage_No).No); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_EchoBody_1); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.EchoBody(ctx, &protoReq) return msg, metadata, err } var filter_EchoService_EchoDelete_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_EchoService_EchoDelete_0(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_EchoDelete_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.EchoDelete(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_EchoService_EchoDelete_0(ctx context.Context, marshaler runtime.Marshaler, server EchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata ) if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_EchoDelete_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.EchoDelete(ctx, &protoReq) return msg, metadata, err } var filter_EchoService_EchoPatch_0 = &utilities.DoubleArray{Encoding: map[string]int{"body": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_EchoService_EchoPatch_0(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq DynamicMessageUpdate metadata runtime.ServerMetadata ) newReader, berr := utilities.IOReaderFactory(req.Body) if berr != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) } if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Body); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Body); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } else { protoReq.UpdateMask = fieldMask } } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_EchoPatch_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.EchoPatch(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_EchoService_EchoPatch_0(ctx context.Context, marshaler runtime.Marshaler, server EchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq DynamicMessageUpdate metadata runtime.ServerMetadata ) newReader, berr := utilities.IOReaderFactory(req.Body) if berr != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) } if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Body); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Body); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } else { protoReq.UpdateMask = fieldMask } } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_EchoPatch_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.EchoPatch(ctx, &protoReq) return msg, metadata, err } var filter_EchoService_EchoUnauthorized_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_EchoService_EchoUnauthorized_0(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_EchoUnauthorized_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.EchoUnauthorized(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_EchoService_EchoUnauthorized_0(ctx context.Context, marshaler runtime.Marshaler, server EchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SimpleMessage metadata runtime.ServerMetadata ) if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EchoService_EchoUnauthorized_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.EchoUnauthorized(ctx, &protoReq) return msg, metadata, err } func request_EchoService_EchoStatus_0(ctx context.Context, marshaler runtime.Marshaler, client EchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq StatusCheckRequest metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.EchoStatus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_EchoService_EchoStatus_0(ctx context.Context, marshaler runtime.Marshaler, server EchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq StatusCheckRequest metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.EchoStatus(ctx, &protoReq) return msg, metadata, err } // RegisterEchoServiceHandlerServer registers the http handlers for service EchoService to "mux". // UnaryRPC :call EchoServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterEchoServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterEchoServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server EchoServiceServer) error { mux.Handle(http.MethodPost, pattern_EchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_EchoService_Echo_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_EchoService_Echo_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo/{id}/{num}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_EchoService_Echo_1(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_Echo_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_EchoService_Echo_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo/{id}/{num}/{lang}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_EchoService_Echo_2(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_Echo_2(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_EchoService_Echo_3, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo1/{id}/{line_num}/{status.note}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_EchoService_Echo_3(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_Echo_3(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_EchoService_Echo_4, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo2/{no.note}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_EchoService_Echo_4(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_Echo_4(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_EchoService_Echo_5, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo/resource/{resource_id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_EchoService_Echo_5(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_Echo_5(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_EchoService_Echo_6, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo/nested/{n_id.n_id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_EchoService_Echo_6(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_Echo_6(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_EchoService_EchoBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/EchoBody", runtime.WithHTTPPathPattern("/v1/example/echo_body")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_EchoService_EchoBody_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_EchoBody_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPut, pattern_EchoService_EchoBody_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/EchoBody", runtime.WithHTTPPathPattern("/v1/example/echo_body/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_EchoService_EchoBody_1(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_EchoBody_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodDelete, pattern_EchoService_EchoDelete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/EchoDelete", runtime.WithHTTPPathPattern("/v1/example/echo_delete")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_EchoService_EchoDelete_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_EchoDelete_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPatch, pattern_EchoService_EchoPatch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/EchoPatch", runtime.WithHTTPPathPattern("/v1/example/echo_patch")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_EchoService_EchoPatch_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_EchoPatch_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_EchoService_EchoUnauthorized_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/EchoUnauthorized", runtime.WithHTTPPathPattern("/v1/example/echo_unauthorized")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_EchoService_EchoUnauthorized_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_EchoUnauthorized_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_EchoService_EchoStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/EchoStatus", runtime.WithHTTPPathPattern("/v1/example/echo_status")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_EchoService_EchoStatus_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_EchoStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } // RegisterEchoServiceHandlerFromEndpoint is same as RegisterEchoServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterEchoServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterEchoServiceHandler(ctx, mux, conn) } // RegisterEchoServiceHandler registers the http handlers for service EchoService to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterEchoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterEchoServiceHandlerClient(ctx, mux, NewEchoServiceClient(conn)) } // RegisterEchoServiceHandlerClient registers the http handlers for service EchoService // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "EchoServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "EchoServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "EchoServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterEchoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client EchoServiceClient) error { mux.Handle(http.MethodPost, pattern_EchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_EchoService_Echo_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_EchoService_Echo_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo/{id}/{num}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_EchoService_Echo_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_Echo_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_EchoService_Echo_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo/{id}/{num}/{lang}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_EchoService_Echo_2(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_Echo_2(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_EchoService_Echo_3, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo1/{id}/{line_num}/{status.note}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_EchoService_Echo_3(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_Echo_3(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_EchoService_Echo_4, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo2/{no.note}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_EchoService_Echo_4(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_Echo_4(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_EchoService_Echo_5, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo/resource/{resource_id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_EchoService_Echo_5(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_Echo_5(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_EchoService_Echo_6, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo/nested/{n_id.n_id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_EchoService_Echo_6(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_Echo_6(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_EchoService_EchoBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/EchoBody", runtime.WithHTTPPathPattern("/v1/example/echo_body")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_EchoService_EchoBody_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_EchoBody_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPut, pattern_EchoService_EchoBody_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/EchoBody", runtime.WithHTTPPathPattern("/v1/example/echo_body/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_EchoService_EchoBody_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_EchoBody_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodDelete, pattern_EchoService_EchoDelete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/EchoDelete", runtime.WithHTTPPathPattern("/v1/example/echo_delete")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_EchoService_EchoDelete_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_EchoDelete_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPatch, pattern_EchoService_EchoPatch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/EchoPatch", runtime.WithHTTPPathPattern("/v1/example/echo_patch")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_EchoService_EchoPatch_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_EchoPatch_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_EchoService_EchoUnauthorized_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/EchoUnauthorized", runtime.WithHTTPPathPattern("/v1/example/echo_unauthorized")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_EchoService_EchoUnauthorized_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_EchoUnauthorized_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_EchoService_EchoStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EchoService/EchoStatus", runtime.WithHTTPPathPattern("/v1/example/echo_status")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_EchoService_EchoStatus_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EchoService_EchoStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_EchoService_Echo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "example", "echo", "id"}, "")) pattern_EchoService_Echo_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"v1", "example", "echo", "id", "num"}, "")) pattern_EchoService_Echo_2 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"v1", "example", "echo", "id", "num", "lang"}, "")) pattern_EchoService_Echo_3 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"v1", "example", "echo1", "id", "line_num", "status.note"}, "")) pattern_EchoService_Echo_4 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "example", "echo2", "no.note"}, "")) pattern_EchoService_Echo_5 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"v1", "example", "echo", "resource", "resource_id"}, "")) pattern_EchoService_Echo_6 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"v1", "example", "echo", "nested", "n_id.n_id"}, "")) pattern_EchoService_EchoBody_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "echo_body"}, "")) pattern_EchoService_EchoBody_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "example", "echo_body", "id"}, "")) pattern_EchoService_EchoDelete_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "echo_delete"}, "")) pattern_EchoService_EchoPatch_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "echo_patch"}, "")) pattern_EchoService_EchoUnauthorized_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "echo_unauthorized"}, "")) pattern_EchoService_EchoStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "echo_status"}, "")) ) var ( forward_EchoService_Echo_0 = runtime.ForwardResponseMessage forward_EchoService_Echo_1 = runtime.ForwardResponseMessage forward_EchoService_Echo_2 = runtime.ForwardResponseMessage forward_EchoService_Echo_3 = runtime.ForwardResponseMessage forward_EchoService_Echo_4 = runtime.ForwardResponseMessage forward_EchoService_Echo_5 = runtime.ForwardResponseMessage forward_EchoService_Echo_6 = runtime.ForwardResponseMessage forward_EchoService_EchoBody_0 = runtime.ForwardResponseMessage forward_EchoService_EchoBody_1 = runtime.ForwardResponseMessage forward_EchoService_EchoDelete_0 = runtime.ForwardResponseMessage forward_EchoService_EchoPatch_0 = runtime.ForwardResponseMessage forward_EchoService_EchoUnauthorized_0 = runtime.ForwardResponseMessage forward_EchoService_EchoStatus_0 = runtime.ForwardResponseMessage ) ================================================ FILE: examples/internal/proto/examplepb/echo_service.proto ================================================ syntax = "proto3"; // Echo Service // // Echo Service API consists of a single service which returns // a message. package grpc.gateway.examples.internal.proto.examplepb; import "examples/internal/proto/sub/message.proto"; import "examples/internal/proto/sub2/message.proto"; import "google/api/annotations.proto"; import "google/protobuf/field_mask.proto"; import "google/protobuf/struct.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; // Embedded represents a message embedded in SimpleMessage. message Embedded { oneof mark { int64 progress = 1; string note = 2; } } message NestedMessage { string n_id = 1; string val = 2; } // SimpleMessage represents a simple message sent to the Echo service. message SimpleMessage { // Id represents the message identifier. string id = 1; int64 num = 2; oneof code { int64 line_num = 3; string lang = 4; } Embedded status = 5; oneof ext { int64 en = 6; Embedded no = 7; } string resource_id = 8; NestedMessage n_id = 9; } // DynamicMessage represents a message which can have its structure // built dynamically using Struct and Values. message DynamicMessage { google.protobuf.Struct struct_field = 1; google.protobuf.Value value_field = 2; } message DynamicMessageUpdate { DynamicMessage body = 1; google.protobuf.FieldMask update_mask = 2; } // StatusCheckRequest demonstrates name collision handling. // It uses Status message from both sub and sub2 packages. message StatusCheckRequest { string id = 1; // Status from sub package grpc.gateway.examples.internal.proto.sub.Status sub_status = 2; // Status from sub2 package (different type with same name) grpc.gateway.examples.internal.proto.sub2.Status sub2_status = 3; } message StatusCheckResponse { string result = 1; // Both Status types used in response grpc.gateway.examples.internal.proto.sub.Status sub_status = 2; grpc.gateway.examples.internal.proto.sub2.Status sub2_status = 3; } // Echo service responds to incoming echo requests. service EchoService { // Echo method receives a simple message and returns it. // // The message posted as the id parameter will also be // returned. rpc Echo(SimpleMessage) returns (SimpleMessage) { option (google.api.http) = { post: "/v1/example/echo/{id}" additional_bindings: {get: "/v1/example/echo/{id}/{num}"} additional_bindings: {get: "/v1/example/echo/{id}/{num}/{lang}"} additional_bindings: {get: "/v1/example/echo1/{id}/{line_num}/{status.note}"} additional_bindings: {get: "/v1/example/echo2/{no.note}"} additional_bindings: {get: "/v1/example/echo/resource/{resource_id}"} additional_bindings: {get: "/v1/example/echo/nested/{n_id.n_id}"} }; } // EchoBody method receives a simple message and returns it. rpc EchoBody(SimpleMessage) returns (SimpleMessage) { option (google.api.http) = { post: "/v1/example/echo_body" body: "*" additional_bindings: { put: "/v1/example/echo_body/{id}" body: "no" } }; } // EchoDelete method receives a simple message and returns it. rpc EchoDelete(SimpleMessage) returns (SimpleMessage) { option (google.api.http) = {delete: "/v1/example/echo_delete"}; } // EchoPatch method receives a NonStandardUpdateRequest and returns it. rpc EchoPatch(DynamicMessageUpdate) returns (DynamicMessageUpdate) { option (google.api.http) = { patch: "/v1/example/echo_patch" body: "body" }; } // EchoUnauthorized method receives a simple message and returns it. It must // always return a google.rpc.Code of `UNAUTHENTICATED` and a HTTP Status code // of 401. rpc EchoUnauthorized(SimpleMessage) returns (SimpleMessage) { option (google.api.http) = {get: "/v1/example/echo_unauthorized"}; } // EchoStatus demonstrates handling of name collisions. // It uses Status types from both sub and sub2 packages which have the same name // but different structures, demonstrating how the OpenAPI generator handles this scenario. rpc EchoStatus(StatusCheckRequest) returns (StatusCheckResponse) { option (google.api.http) = { post: "/v1/example/echo_status" body: "*" }; } } ================================================ FILE: examples/internal/proto/examplepb/echo_service.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "Echo Service", "description": "Echo Service API consists of a single service which returns\na message.", "version": "version not set" }, "tags": [ { "name": "EchoService" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/v1/example/echo/nested/{nId.nId}": { "get": { "summary": "Echo method receives a simple message and returns it.", "description": "The message posted as the id parameter will also be\nreturned.", "operationId": "EchoService_Echo7", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "nId.nId", "in": "path", "required": true, "type": "string" }, { "name": "id", "description": "Id represents the message identifier.", "in": "query", "required": false, "type": "string" }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "resourceId", "in": "query", "required": false, "type": "string" }, { "name": "nId.val", "in": "query", "required": false, "type": "string" } ], "tags": [ "EchoService" ] } }, "/v1/example/echo/resource/{resourceId}": { "get": { "summary": "Echo method receives a simple message and returns it.", "description": "The message posted as the id parameter will also be\nreturned.", "operationId": "EchoService_Echo6", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "resourceId", "in": "path", "required": true, "type": "string" }, { "name": "id", "description": "Id represents the message identifier.", "in": "query", "required": false, "type": "string" }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "nId.nId", "in": "query", "required": false, "type": "string" }, { "name": "nId.val", "in": "query", "required": false, "type": "string" } ], "tags": [ "EchoService" ] } }, "/v1/example/echo/{id}": { "post": { "summary": "Echo method receives a simple message and returns it.", "description": "The message posted as the id parameter will also be\nreturned.", "operationId": "EchoService_Echo", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "path", "required": true, "type": "string" }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "resourceId", "in": "query", "required": false, "type": "string" }, { "name": "nId.nId", "in": "query", "required": false, "type": "string" }, { "name": "nId.val", "in": "query", "required": false, "type": "string" } ], "tags": [ "EchoService" ] } }, "/v1/example/echo/{id}/{num}": { "get": { "summary": "Echo method receives a simple message and returns it.", "description": "The message posted as the id parameter will also be\nreturned.", "operationId": "EchoService_Echo2", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "path", "required": true, "type": "string" }, { "name": "num", "in": "path", "required": true, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "resourceId", "in": "query", "required": false, "type": "string" }, { "name": "nId.nId", "in": "query", "required": false, "type": "string" }, { "name": "nId.val", "in": "query", "required": false, "type": "string" } ], "tags": [ "EchoService" ] } }, "/v1/example/echo/{id}/{num}/{lang}": { "get": { "summary": "Echo method receives a simple message and returns it.", "description": "The message posted as the id parameter will also be\nreturned.", "operationId": "EchoService_Echo3", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "path", "required": true, "type": "string" }, { "name": "num", "in": "path", "required": true, "type": "string", "format": "int64" }, { "name": "lang", "in": "path", "required": true, "type": "string" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "resourceId", "in": "query", "required": false, "type": "string" }, { "name": "nId.nId", "in": "query", "required": false, "type": "string" }, { "name": "nId.val", "in": "query", "required": false, "type": "string" } ], "tags": [ "EchoService" ] } }, "/v1/example/echo1/{id}/{lineNum}/{status.note}": { "get": { "summary": "Echo method receives a simple message and returns it.", "description": "The message posted as the id parameter will also be\nreturned.", "operationId": "EchoService_Echo4", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "path", "required": true, "type": "string" }, { "name": "lineNum", "in": "path", "required": true, "type": "string", "format": "int64" }, { "name": "status.note", "in": "path", "required": true, "type": "string" }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "resourceId", "in": "query", "required": false, "type": "string" }, { "name": "nId.nId", "in": "query", "required": false, "type": "string" }, { "name": "nId.val", "in": "query", "required": false, "type": "string" } ], "tags": [ "EchoService" ] } }, "/v1/example/echo2/{no.note}": { "get": { "summary": "Echo method receives a simple message and returns it.", "description": "The message posted as the id parameter will also be\nreturned.", "operationId": "EchoService_Echo5", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "no.note", "in": "path", "required": true, "type": "string" }, { "name": "id", "description": "Id represents the message identifier.", "in": "query", "required": false, "type": "string" }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "resourceId", "in": "query", "required": false, "type": "string" }, { "name": "nId.nId", "in": "query", "required": false, "type": "string" }, { "name": "nId.val", "in": "query", "required": false, "type": "string" } ], "tags": [ "EchoService" ] } }, "/v1/example/echo_body": { "post": { "summary": "EchoBody method receives a simple message and returns it.", "operationId": "EchoService_EchoBody", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "description": "SimpleMessage represents a simple message sent to the Echo service.", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbSimpleMessage" } } ], "tags": [ "EchoService" ] } }, "/v1/example/echo_body/{id}": { "put": { "summary": "EchoBody method receives a simple message and returns it.", "operationId": "EchoService_EchoBody2", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "path", "required": true, "type": "string" }, { "name": "no", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbEmbedded" } }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "resourceId", "in": "query", "required": false, "type": "string" }, { "name": "nId.nId", "in": "query", "required": false, "type": "string" }, { "name": "nId.val", "in": "query", "required": false, "type": "string" } ], "tags": [ "EchoService" ] } }, "/v1/example/echo_delete": { "delete": { "summary": "EchoDelete method receives a simple message and returns it.", "operationId": "EchoService_EchoDelete", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "query", "required": false, "type": "string" }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "resourceId", "in": "query", "required": false, "type": "string" }, { "name": "nId.nId", "in": "query", "required": false, "type": "string" }, { "name": "nId.val", "in": "query", "required": false, "type": "string" } ], "tags": [ "EchoService" ] } }, "/v1/example/echo_patch": { "patch": { "summary": "EchoPatch method receives a NonStandardUpdateRequest and returns it.", "operationId": "EchoService_EchoPatch", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbDynamicMessageUpdate" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbDynamicMessage" } } ], "tags": [ "EchoService" ] } }, "/v1/example/echo_status": { "post": { "summary": "EchoStatus demonstrates handling of name collisions.\nIt uses Status types from both sub and sub2 packages which have the same name\nbut different structures, demonstrating how the OpenAPI generator handles this scenario.", "operationId": "EchoService_EchoStatus", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbStatusCheckResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "description": "StatusCheckRequest demonstrates name collision handling.\nIt uses Status message from both sub and sub2 packages.", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbStatusCheckRequest" } } ], "tags": [ "EchoService" ] } }, "/v1/example/echo_unauthorized": { "get": { "summary": "EchoUnauthorized method receives a simple message and returns it. It must\nalways return a google.rpc.Code of `UNAUTHENTICATED` and a HTTP Status code\nof 401.", "operationId": "EchoService_EchoUnauthorized", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "query", "required": false, "type": "string" }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "resourceId", "in": "query", "required": false, "type": "string" }, { "name": "nId.nId", "in": "query", "required": false, "type": "string" }, { "name": "nId.val", "in": "query", "required": false, "type": "string" } ], "tags": [ "EchoService" ] } } }, "definitions": { "examplepbDynamicMessage": { "type": "object", "properties": { "structField": { "type": "object" }, "valueField": {} }, "description": "DynamicMessage represents a message which can have its structure\nbuilt dynamically using Struct and Values." }, "examplepbDynamicMessageUpdate": { "type": "object", "properties": { "body": { "$ref": "#/definitions/examplepbDynamicMessage" }, "updateMask": { "type": "string" } } }, "examplepbEmbedded": { "type": "object", "properties": { "progress": { "type": "string", "format": "int64" }, "note": { "type": "string" } }, "description": "Embedded represents a message embedded in SimpleMessage." }, "examplepbNestedMessage": { "type": "object", "properties": { "nId": { "type": "string" }, "val": { "type": "string" } } }, "examplepbSimpleMessage": { "type": "object", "properties": { "id": { "type": "string", "description": "Id represents the message identifier." }, "num": { "type": "string", "format": "int64" }, "lineNum": { "type": "string", "format": "int64" }, "lang": { "type": "string" }, "status": { "$ref": "#/definitions/examplepbEmbedded" }, "en": { "type": "string", "format": "int64" }, "no": { "$ref": "#/definitions/examplepbEmbedded" }, "resourceId": { "type": "string" }, "nId": { "$ref": "#/definitions/examplepbNestedMessage" } }, "description": "SimpleMessage represents a simple message sent to the Echo service." }, "examplepbStatusCheckRequest": { "type": "object", "properties": { "id": { "type": "string" }, "subStatus": { "$ref": "#/definitions/protoSubStatus", "title": "Status from sub package" }, "sub2Status": { "$ref": "#/definitions/protoSub2Status", "title": "Status from sub2 package (different type with same name)" } }, "description": "StatusCheckRequest demonstrates name collision handling.\nIt uses Status message from both sub and sub2 packages." }, "examplepbStatusCheckResponse": { "type": "object", "properties": { "result": { "type": "string" }, "subStatus": { "$ref": "#/definitions/protoSubStatus", "title": "Both Status types used in response" }, "sub2Status": { "$ref": "#/definitions/protoSub2Status" } } }, "googleRpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32", "description": "The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]." }, "message": { "type": "string", "description": "A developer-facing error message, which should be in English. Any\nuser-facing error message should be localized and sent in the\n[google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client." }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" }, "description": "A list of messages that carry the error details. There is a common set of\nmessage types for APIs to use." } }, "description": "The `Status` type defines a logical error model that is suitable for\ndifferent programming environments, including REST APIs and RPC APIs. It is\nused by [gRPC](https://github.com/grpc). Each `Status` message contains\nthree pieces of data: error code, error message, and error details.\n\nYou can find out more about this error model and how to work with it in the\n[API Design Guide](https://cloud.google.com/apis/design/errors)." }, "protoSub2Status": { "type": "object", "properties": { "errorCode": { "type": "string" }, "errorMessage": { "type": "string" }, "severity": { "type": "integer", "format": "int32" } }, "title": "Status message in sub2 package (different structure from sub.Status)" }, "protoSubStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" } }, "title": "Status message in sub package" }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string", "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics." } }, "additionalProperties": {}, "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }" }, "protobufNullValue": { "type": "string", "enum": [ "NULL_VALUE" ], "default": "NULL_VALUE", "description": "`NullValue` is a singleton enumeration to represent the null value for the\n`Value` type union.\n\nThe JSON representation for `NullValue` is JSON `null`.\n\n - NULL_VALUE: Null value." } } } ================================================ FILE: examples/internal/proto/examplepb/echo_service_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: examples/internal/proto/examplepb/echo_service.proto // Echo Service // // Echo Service API consists of a single service which returns // a message. package examplepb import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( EchoService_Echo_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.EchoService/Echo" EchoService_EchoBody_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.EchoService/EchoBody" EchoService_EchoDelete_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.EchoService/EchoDelete" EchoService_EchoPatch_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.EchoService/EchoPatch" EchoService_EchoUnauthorized_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.EchoService/EchoUnauthorized" EchoService_EchoStatus_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.EchoService/EchoStatus" ) // EchoServiceClient is the client API for EchoService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // // Echo service responds to incoming echo requests. type EchoServiceClient interface { // Echo method receives a simple message and returns it. // // The message posted as the id parameter will also be // returned. Echo(ctx context.Context, in *SimpleMessage, opts ...grpc.CallOption) (*SimpleMessage, error) // EchoBody method receives a simple message and returns it. EchoBody(ctx context.Context, in *SimpleMessage, opts ...grpc.CallOption) (*SimpleMessage, error) // EchoDelete method receives a simple message and returns it. EchoDelete(ctx context.Context, in *SimpleMessage, opts ...grpc.CallOption) (*SimpleMessage, error) // EchoPatch method receives a NonStandardUpdateRequest and returns it. EchoPatch(ctx context.Context, in *DynamicMessageUpdate, opts ...grpc.CallOption) (*DynamicMessageUpdate, error) // EchoUnauthorized method receives a simple message and returns it. It must // always return a google.rpc.Code of `UNAUTHENTICATED` and a HTTP Status code // of 401. EchoUnauthorized(ctx context.Context, in *SimpleMessage, opts ...grpc.CallOption) (*SimpleMessage, error) // EchoStatus demonstrates handling of name collisions. // It uses Status types from both sub and sub2 packages which have the same name // but different structures, demonstrating how the OpenAPI generator handles this scenario. EchoStatus(ctx context.Context, in *StatusCheckRequest, opts ...grpc.CallOption) (*StatusCheckResponse, error) } type echoServiceClient struct { cc grpc.ClientConnInterface } func NewEchoServiceClient(cc grpc.ClientConnInterface) EchoServiceClient { return &echoServiceClient{cc} } func (c *echoServiceClient) Echo(ctx context.Context, in *SimpleMessage, opts ...grpc.CallOption) (*SimpleMessage, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(SimpleMessage) err := c.cc.Invoke(ctx, EchoService_Echo_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *echoServiceClient) EchoBody(ctx context.Context, in *SimpleMessage, opts ...grpc.CallOption) (*SimpleMessage, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(SimpleMessage) err := c.cc.Invoke(ctx, EchoService_EchoBody_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *echoServiceClient) EchoDelete(ctx context.Context, in *SimpleMessage, opts ...grpc.CallOption) (*SimpleMessage, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(SimpleMessage) err := c.cc.Invoke(ctx, EchoService_EchoDelete_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *echoServiceClient) EchoPatch(ctx context.Context, in *DynamicMessageUpdate, opts ...grpc.CallOption) (*DynamicMessageUpdate, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(DynamicMessageUpdate) err := c.cc.Invoke(ctx, EchoService_EchoPatch_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *echoServiceClient) EchoUnauthorized(ctx context.Context, in *SimpleMessage, opts ...grpc.CallOption) (*SimpleMessage, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(SimpleMessage) err := c.cc.Invoke(ctx, EchoService_EchoUnauthorized_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *echoServiceClient) EchoStatus(ctx context.Context, in *StatusCheckRequest, opts ...grpc.CallOption) (*StatusCheckResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(StatusCheckResponse) err := c.cc.Invoke(ctx, EchoService_EchoStatus_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // EchoServiceServer is the server API for EchoService service. // All implementations should embed UnimplementedEchoServiceServer // for forward compatibility. // // Echo service responds to incoming echo requests. type EchoServiceServer interface { // Echo method receives a simple message and returns it. // // The message posted as the id parameter will also be // returned. Echo(context.Context, *SimpleMessage) (*SimpleMessage, error) // EchoBody method receives a simple message and returns it. EchoBody(context.Context, *SimpleMessage) (*SimpleMessage, error) // EchoDelete method receives a simple message and returns it. EchoDelete(context.Context, *SimpleMessage) (*SimpleMessage, error) // EchoPatch method receives a NonStandardUpdateRequest and returns it. EchoPatch(context.Context, *DynamicMessageUpdate) (*DynamicMessageUpdate, error) // EchoUnauthorized method receives a simple message and returns it. It must // always return a google.rpc.Code of `UNAUTHENTICATED` and a HTTP Status code // of 401. EchoUnauthorized(context.Context, *SimpleMessage) (*SimpleMessage, error) // EchoStatus demonstrates handling of name collisions. // It uses Status types from both sub and sub2 packages which have the same name // but different structures, demonstrating how the OpenAPI generator handles this scenario. EchoStatus(context.Context, *StatusCheckRequest) (*StatusCheckResponse, error) } // UnimplementedEchoServiceServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedEchoServiceServer struct{} func (UnimplementedEchoServiceServer) Echo(context.Context, *SimpleMessage) (*SimpleMessage, error) { return nil, status.Errorf(codes.Unimplemented, "method Echo not implemented") } func (UnimplementedEchoServiceServer) EchoBody(context.Context, *SimpleMessage) (*SimpleMessage, error) { return nil, status.Errorf(codes.Unimplemented, "method EchoBody not implemented") } func (UnimplementedEchoServiceServer) EchoDelete(context.Context, *SimpleMessage) (*SimpleMessage, error) { return nil, status.Errorf(codes.Unimplemented, "method EchoDelete not implemented") } func (UnimplementedEchoServiceServer) EchoPatch(context.Context, *DynamicMessageUpdate) (*DynamicMessageUpdate, error) { return nil, status.Errorf(codes.Unimplemented, "method EchoPatch not implemented") } func (UnimplementedEchoServiceServer) EchoUnauthorized(context.Context, *SimpleMessage) (*SimpleMessage, error) { return nil, status.Errorf(codes.Unimplemented, "method EchoUnauthorized not implemented") } func (UnimplementedEchoServiceServer) EchoStatus(context.Context, *StatusCheckRequest) (*StatusCheckResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method EchoStatus not implemented") } func (UnimplementedEchoServiceServer) testEmbeddedByValue() {} // UnsafeEchoServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to EchoServiceServer will // result in compilation errors. type UnsafeEchoServiceServer interface { mustEmbedUnimplementedEchoServiceServer() } func RegisterEchoServiceServer(s grpc.ServiceRegistrar, srv EchoServiceServer) { // If the following call pancis, it indicates UnimplementedEchoServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&EchoService_ServiceDesc, srv) } func _EchoService_Echo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SimpleMessage) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(EchoServiceServer).Echo(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: EchoService_Echo_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(EchoServiceServer).Echo(ctx, req.(*SimpleMessage)) } return interceptor(ctx, in, info, handler) } func _EchoService_EchoBody_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SimpleMessage) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(EchoServiceServer).EchoBody(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: EchoService_EchoBody_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(EchoServiceServer).EchoBody(ctx, req.(*SimpleMessage)) } return interceptor(ctx, in, info, handler) } func _EchoService_EchoDelete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SimpleMessage) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(EchoServiceServer).EchoDelete(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: EchoService_EchoDelete_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(EchoServiceServer).EchoDelete(ctx, req.(*SimpleMessage)) } return interceptor(ctx, in, info, handler) } func _EchoService_EchoPatch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(DynamicMessageUpdate) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(EchoServiceServer).EchoPatch(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: EchoService_EchoPatch_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(EchoServiceServer).EchoPatch(ctx, req.(*DynamicMessageUpdate)) } return interceptor(ctx, in, info, handler) } func _EchoService_EchoUnauthorized_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SimpleMessage) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(EchoServiceServer).EchoUnauthorized(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: EchoService_EchoUnauthorized_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(EchoServiceServer).EchoUnauthorized(ctx, req.(*SimpleMessage)) } return interceptor(ctx, in, info, handler) } func _EchoService_EchoStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(StatusCheckRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(EchoServiceServer).EchoStatus(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: EchoService_EchoStatus_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(EchoServiceServer).EchoStatus(ctx, req.(*StatusCheckRequest)) } return interceptor(ctx, in, info, handler) } // EchoService_ServiceDesc is the grpc.ServiceDesc for EchoService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var EchoService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.EchoService", HandlerType: (*EchoServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Echo", Handler: _EchoService_Echo_Handler, }, { MethodName: "EchoBody", Handler: _EchoService_EchoBody_Handler, }, { MethodName: "EchoDelete", Handler: _EchoService_EchoDelete_Handler, }, { MethodName: "EchoPatch", Handler: _EchoService_EchoPatch_Handler, }, { MethodName: "EchoUnauthorized", Handler: _EchoService_EchoUnauthorized_Handler, }, { MethodName: "EchoStatus", Handler: _EchoService_EchoStatus_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/internal/proto/examplepb/echo_service.proto", } ================================================ FILE: examples/internal/proto/examplepb/enum_with_single_value.buf.gen.yaml ================================================ version: v2 plugins: - local: protoc-gen-openapiv2 out: . opt: - omit_enum_default_value=true ================================================ FILE: examples/internal/proto/examplepb/enum_with_single_value.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/examplepb/enum_with_single_value.proto package examplepb import ( _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) // EnumWithSingleValue is an enum with a single value. Since it has just a single value // the `enum` field should be omitted in the generated OpenAPI spec for the type when // the omit_enum_default_value option is set to true. type EnumWithSingleValue int32 const ( EnumWithSingleValue_ENUM_WITH_SINGLE_VALUE_UNSPECIFIED EnumWithSingleValue = 0 ) // Enum value maps for EnumWithSingleValue. var ( EnumWithSingleValue_name = map[int32]string{ 0: "ENUM_WITH_SINGLE_VALUE_UNSPECIFIED", } EnumWithSingleValue_value = map[string]int32{ "ENUM_WITH_SINGLE_VALUE_UNSPECIFIED": 0, } ) func (x EnumWithSingleValue) Enum() *EnumWithSingleValue { p := new(EnumWithSingleValue) *p = x return p } func (x EnumWithSingleValue) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (EnumWithSingleValue) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_examplepb_enum_with_single_value_proto_enumTypes[0].Descriptor() } func (EnumWithSingleValue) Type() protoreflect.EnumType { return &file_examples_internal_proto_examplepb_enum_with_single_value_proto_enumTypes[0] } func (x EnumWithSingleValue) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use EnumWithSingleValue.Descriptor instead. func (EnumWithSingleValue) EnumDescriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_enum_with_single_value_proto_rawDescGZIP(), []int{0} } type EnumWithSingleValueServiceEchoRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Value EnumWithSingleValue `protobuf:"varint,1,opt,name=value,proto3,enum=grpc.gateway.examples.internal.proto.examplepb.EnumWithSingleValue" json:"value,omitempty"` } func (x *EnumWithSingleValueServiceEchoRequest) Reset() { *x = EnumWithSingleValueServiceEchoRequest{} mi := &file_examples_internal_proto_examplepb_enum_with_single_value_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *EnumWithSingleValueServiceEchoRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*EnumWithSingleValueServiceEchoRequest) ProtoMessage() {} func (x *EnumWithSingleValueServiceEchoRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_enum_with_single_value_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use EnumWithSingleValueServiceEchoRequest.ProtoReflect.Descriptor instead. func (*EnumWithSingleValueServiceEchoRequest) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_enum_with_single_value_proto_rawDescGZIP(), []int{0} } func (x *EnumWithSingleValueServiceEchoRequest) GetValue() EnumWithSingleValue { if x != nil { return x.Value } return EnumWithSingleValue_ENUM_WITH_SINGLE_VALUE_UNSPECIFIED } type EnumWithSingleValueServiceEchoResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields } func (x *EnumWithSingleValueServiceEchoResponse) Reset() { *x = EnumWithSingleValueServiceEchoResponse{} mi := &file_examples_internal_proto_examplepb_enum_with_single_value_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *EnumWithSingleValueServiceEchoResponse) String() string { return protoimpl.X.MessageStringOf(x) } func (*EnumWithSingleValueServiceEchoResponse) ProtoMessage() {} func (x *EnumWithSingleValueServiceEchoResponse) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_enum_with_single_value_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use EnumWithSingleValueServiceEchoResponse.ProtoReflect.Descriptor instead. func (*EnumWithSingleValueServiceEchoResponse) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_enum_with_single_value_proto_rawDescGZIP(), []int{1} } var File_examples_internal_proto_examplepb_enum_with_single_value_proto protoreflect.FileDescriptor var file_examples_internal_proto_examplepb_enum_with_single_value_proto_rawDesc = []byte{ 0x0a, 0x3e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x5f, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x82, 0x01, 0x0a, 0x25, 0x45, 0x6e, 0x75, 0x6d, 0x57, 0x69, 0x74, 0x68, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x45, 0x63, 0x68, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x59, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x43, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x57, 0x69, 0x74, 0x68, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x28, 0x0a, 0x26, 0x45, 0x6e, 0x75, 0x6d, 0x57, 0x69, 0x74, 0x68, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x45, 0x63, 0x68, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2a, 0x3d, 0x0a, 0x13, 0x45, 0x6e, 0x75, 0x6d, 0x57, 0x69, 0x74, 0x68, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x26, 0x0a, 0x22, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x53, 0x49, 0x4e, 0x47, 0x4c, 0x45, 0x5f, 0x56, 0x41, 0x4c, 0x55, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x32, 0x88, 0x02, 0x0a, 0x1a, 0x45, 0x6e, 0x75, 0x6d, 0x57, 0x69, 0x74, 0x68, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xe9, 0x01, 0x0a, 0x04, 0x45, 0x63, 0x68, 0x6f, 0x12, 0x55, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x57, 0x69, 0x74, 0x68, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x45, 0x63, 0x68, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x56, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x57, 0x69, 0x74, 0x68, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x45, 0x63, 0x68, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x32, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2c, 0x3a, 0x01, 0x2a, 0x22, 0x27, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x6e, 0x75, 0x6d, 0x2d, 0x77, 0x69, 0x74, 0x68, 0x2d, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x2d, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_examplepb_enum_with_single_value_proto_rawDescOnce sync.Once file_examples_internal_proto_examplepb_enum_with_single_value_proto_rawDescData = file_examples_internal_proto_examplepb_enum_with_single_value_proto_rawDesc ) func file_examples_internal_proto_examplepb_enum_with_single_value_proto_rawDescGZIP() []byte { file_examples_internal_proto_examplepb_enum_with_single_value_proto_rawDescOnce.Do(func() { file_examples_internal_proto_examplepb_enum_with_single_value_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_examplepb_enum_with_single_value_proto_rawDescData) }) return file_examples_internal_proto_examplepb_enum_with_single_value_proto_rawDescData } var file_examples_internal_proto_examplepb_enum_with_single_value_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_examples_internal_proto_examplepb_enum_with_single_value_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_examples_internal_proto_examplepb_enum_with_single_value_proto_goTypes = []any{ (EnumWithSingleValue)(0), // 0: grpc.gateway.examples.internal.proto.examplepb.EnumWithSingleValue (*EnumWithSingleValueServiceEchoRequest)(nil), // 1: grpc.gateway.examples.internal.proto.examplepb.EnumWithSingleValueServiceEchoRequest (*EnumWithSingleValueServiceEchoResponse)(nil), // 2: grpc.gateway.examples.internal.proto.examplepb.EnumWithSingleValueServiceEchoResponse } var file_examples_internal_proto_examplepb_enum_with_single_value_proto_depIdxs = []int32{ 0, // 0: grpc.gateway.examples.internal.proto.examplepb.EnumWithSingleValueServiceEchoRequest.value:type_name -> grpc.gateway.examples.internal.proto.examplepb.EnumWithSingleValue 1, // 1: grpc.gateway.examples.internal.proto.examplepb.EnumWithSingleValueService.Echo:input_type -> grpc.gateway.examples.internal.proto.examplepb.EnumWithSingleValueServiceEchoRequest 2, // 2: grpc.gateway.examples.internal.proto.examplepb.EnumWithSingleValueService.Echo:output_type -> grpc.gateway.examples.internal.proto.examplepb.EnumWithSingleValueServiceEchoResponse 2, // [2:3] is the sub-list for method output_type 1, // [1:2] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension extendee 0, // [0:1] is the sub-list for field type_name } func init() { file_examples_internal_proto_examplepb_enum_with_single_value_proto_init() } func file_examples_internal_proto_examplepb_enum_with_single_value_proto_init() { if File_examples_internal_proto_examplepb_enum_with_single_value_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_examplepb_enum_with_single_value_proto_rawDesc, NumEnums: 1, NumMessages: 2, NumExtensions: 0, NumServices: 1, }, GoTypes: file_examples_internal_proto_examplepb_enum_with_single_value_proto_goTypes, DependencyIndexes: file_examples_internal_proto_examplepb_enum_with_single_value_proto_depIdxs, EnumInfos: file_examples_internal_proto_examplepb_enum_with_single_value_proto_enumTypes, MessageInfos: file_examples_internal_proto_examplepb_enum_with_single_value_proto_msgTypes, }.Build() File_examples_internal_proto_examplepb_enum_with_single_value_proto = out.File file_examples_internal_proto_examplepb_enum_with_single_value_proto_rawDesc = nil file_examples_internal_proto_examplepb_enum_with_single_value_proto_goTypes = nil file_examples_internal_proto_examplepb_enum_with_single_value_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/examplepb/enum_with_single_value.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/proto/examplepb/enum_with_single_value.proto /* Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package examplepb import ( "context" "errors" "io" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) func request_EnumWithSingleValueService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, client EnumWithSingleValueServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq EnumWithSingleValueServiceEchoRequest metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_EnumWithSingleValueService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, server EnumWithSingleValueServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq EnumWithSingleValueServiceEchoRequest metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Echo(ctx, &protoReq) return msg, metadata, err } // RegisterEnumWithSingleValueServiceHandlerServer registers the http handlers for service EnumWithSingleValueService to "mux". // UnaryRPC :call EnumWithSingleValueServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterEnumWithSingleValueServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterEnumWithSingleValueServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server EnumWithSingleValueServiceServer) error { mux.Handle(http.MethodPost, pattern_EnumWithSingleValueService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EnumWithSingleValueService/Echo", runtime.WithHTTPPathPattern("/v1/example/enum-with-single-value/echo")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_EnumWithSingleValueService_Echo_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EnumWithSingleValueService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } // RegisterEnumWithSingleValueServiceHandlerFromEndpoint is same as RegisterEnumWithSingleValueServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterEnumWithSingleValueServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterEnumWithSingleValueServiceHandler(ctx, mux, conn) } // RegisterEnumWithSingleValueServiceHandler registers the http handlers for service EnumWithSingleValueService to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterEnumWithSingleValueServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterEnumWithSingleValueServiceHandlerClient(ctx, mux, NewEnumWithSingleValueServiceClient(conn)) } // RegisterEnumWithSingleValueServiceHandlerClient registers the http handlers for service EnumWithSingleValueService // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "EnumWithSingleValueServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "EnumWithSingleValueServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "EnumWithSingleValueServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterEnumWithSingleValueServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client EnumWithSingleValueServiceClient) error { mux.Handle(http.MethodPost, pattern_EnumWithSingleValueService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.EnumWithSingleValueService/Echo", runtime.WithHTTPPathPattern("/v1/example/enum-with-single-value/echo")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_EnumWithSingleValueService_Echo_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_EnumWithSingleValueService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_EnumWithSingleValueService_Echo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "example", "enum-with-single-value", "echo"}, "")) ) var ( forward_EnumWithSingleValueService_Echo_0 = runtime.ForwardResponseMessage ) ================================================ FILE: examples/internal/proto/examplepb/enum_with_single_value.proto ================================================ syntax = "proto3"; package grpc.gateway.examples.internal.proto.examplepb; import "google/api/annotations.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; service EnumWithSingleValueService { rpc Echo(EnumWithSingleValueServiceEchoRequest) returns (EnumWithSingleValueServiceEchoResponse) { option (google.api.http) = { post: "/v1/example/enum-with-single-value/echo" body: "*" }; } } // EnumWithSingleValue is an enum with a single value. Since it has just a single value // the `enum` field should be omitted in the generated OpenAPI spec for the type when // the omit_enum_default_value option is set to true. enum EnumWithSingleValue { ENUM_WITH_SINGLE_VALUE_UNSPECIFIED = 0; } message EnumWithSingleValueServiceEchoRequest { EnumWithSingleValue value = 1; } message EnumWithSingleValueServiceEchoResponse {} ================================================ FILE: examples/internal/proto/examplepb/enum_with_single_value.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/examplepb/enum_with_single_value.proto", "version": "version not set" }, "tags": [ { "name": "EnumWithSingleValueService" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/v1/example/enum-with-single-value/echo": { "post": { "operationId": "EnumWithSingleValueService_Echo", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbEnumWithSingleValueServiceEchoResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbEnumWithSingleValueServiceEchoRequest" } } ], "tags": [ "EnumWithSingleValueService" ] } } }, "definitions": { "examplepbEnumWithSingleValue": { "type": "string", "description": "EnumWithSingleValue is an enum with a single value. Since it has just a single value\nthe `enum` field should be omitted in the generated OpenAPI spec for the type when\nthe omit_enum_default_value option is set to true." }, "examplepbEnumWithSingleValueServiceEchoRequest": { "type": "object", "properties": { "value": { "$ref": "#/definitions/examplepbEnumWithSingleValue" } } }, "examplepbEnumWithSingleValueServiceEchoResponse": { "type": "object" }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string" } }, "additionalProperties": {} }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } } } } ================================================ FILE: examples/internal/proto/examplepb/enum_with_single_value_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: examples/internal/proto/examplepb/enum_with_single_value.proto package examplepb import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( EnumWithSingleValueService_Echo_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.EnumWithSingleValueService/Echo" ) // EnumWithSingleValueServiceClient is the client API for EnumWithSingleValueService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type EnumWithSingleValueServiceClient interface { Echo(ctx context.Context, in *EnumWithSingleValueServiceEchoRequest, opts ...grpc.CallOption) (*EnumWithSingleValueServiceEchoResponse, error) } type enumWithSingleValueServiceClient struct { cc grpc.ClientConnInterface } func NewEnumWithSingleValueServiceClient(cc grpc.ClientConnInterface) EnumWithSingleValueServiceClient { return &enumWithSingleValueServiceClient{cc} } func (c *enumWithSingleValueServiceClient) Echo(ctx context.Context, in *EnumWithSingleValueServiceEchoRequest, opts ...grpc.CallOption) (*EnumWithSingleValueServiceEchoResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(EnumWithSingleValueServiceEchoResponse) err := c.cc.Invoke(ctx, EnumWithSingleValueService_Echo_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // EnumWithSingleValueServiceServer is the server API for EnumWithSingleValueService service. // All implementations should embed UnimplementedEnumWithSingleValueServiceServer // for forward compatibility. type EnumWithSingleValueServiceServer interface { Echo(context.Context, *EnumWithSingleValueServiceEchoRequest) (*EnumWithSingleValueServiceEchoResponse, error) } // UnimplementedEnumWithSingleValueServiceServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedEnumWithSingleValueServiceServer struct{} func (UnimplementedEnumWithSingleValueServiceServer) Echo(context.Context, *EnumWithSingleValueServiceEchoRequest) (*EnumWithSingleValueServiceEchoResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Echo not implemented") } func (UnimplementedEnumWithSingleValueServiceServer) testEmbeddedByValue() {} // UnsafeEnumWithSingleValueServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to EnumWithSingleValueServiceServer will // result in compilation errors. type UnsafeEnumWithSingleValueServiceServer interface { mustEmbedUnimplementedEnumWithSingleValueServiceServer() } func RegisterEnumWithSingleValueServiceServer(s grpc.ServiceRegistrar, srv EnumWithSingleValueServiceServer) { // If the following call pancis, it indicates UnimplementedEnumWithSingleValueServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&EnumWithSingleValueService_ServiceDesc, srv) } func _EnumWithSingleValueService_Echo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(EnumWithSingleValueServiceEchoRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(EnumWithSingleValueServiceServer).Echo(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: EnumWithSingleValueService_Echo_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(EnumWithSingleValueServiceServer).Echo(ctx, req.(*EnumWithSingleValueServiceEchoRequest)) } return interceptor(ctx, in, info, handler) } // EnumWithSingleValueService_ServiceDesc is the grpc.ServiceDesc for EnumWithSingleValueService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var EnumWithSingleValueService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.EnumWithSingleValueService", HandlerType: (*EnumWithSingleValueServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Echo", Handler: _EnumWithSingleValueService_Echo_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/internal/proto/examplepb/enum_with_single_value.proto", } ================================================ FILE: examples/internal/proto/examplepb/excess_body.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/examplepb/excess_body.proto // Excess Body Service // Used to test server context cancellation with Unary and ServerStream methods // when client sends more data than expected. package examplepb import ( _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) var File_examples_internal_proto_examplepb_excess_body_proto protoreflect.FileDescriptor var file_examples_internal_proto_examplepb_excess_body_proto_rawDesc = []byte{ 0x0a, 0x33, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x65, 0x78, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x62, 0x6f, 0x64, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xb9, 0x03, 0x0a, 0x11, 0x45, 0x78, 0x63, 0x65, 0x73, 0x73, 0x42, 0x6f, 0x64, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x59, 0x0a, 0x09, 0x4e, 0x6f, 0x42, 0x6f, 0x64, 0x79, 0x52, 0x70, 0x63, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x22, 0x14, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x65, 0x78, 0x63, 0x65, 0x73, 0x73, 0x2d, 0x62, 0x6f, 0x64, 0x79, 0x2f, 0x72, 0x70, 0x63, 0x12, 0x67, 0x0a, 0x12, 0x4e, 0x6f, 0x42, 0x6f, 0x64, 0x79, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x1f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x22, 0x17, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x65, 0x78, 0x63, 0x65, 0x73, 0x73, 0x2d, 0x62, 0x6f, 0x64, 0x79, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x30, 0x01, 0x12, 0x68, 0x0a, 0x0b, 0x57, 0x69, 0x74, 0x68, 0x42, 0x6f, 0x64, 0x79, 0x52, 0x70, 0x63, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x29, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x23, 0x3a, 0x01, 0x2a, 0x22, 0x1e, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x65, 0x78, 0x63, 0x65, 0x73, 0x73, 0x2d, 0x62, 0x6f, 0x64, 0x79, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x77, 0x69, 0x74, 0x68, 0x2d, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x76, 0x0a, 0x14, 0x57, 0x69, 0x74, 0x68, 0x42, 0x6f, 0x64, 0x79, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x2c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x26, 0x3a, 0x01, 0x2a, 0x22, 0x21, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x65, 0x78, 0x63, 0x65, 0x73, 0x73, 0x2d, 0x62, 0x6f, 0x64, 0x79, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2f, 0x77, 0x69, 0x74, 0x68, 0x2d, 0x62, 0x6f, 0x64, 0x79, 0x30, 0x01, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var file_examples_internal_proto_examplepb_excess_body_proto_goTypes = []any{ (*emptypb.Empty)(nil), // 0: google.protobuf.Empty } var file_examples_internal_proto_examplepb_excess_body_proto_depIdxs = []int32{ 0, // 0: grpc.gateway.examples.internal.proto.examplepb.ExcessBodyService.NoBodyRpc:input_type -> google.protobuf.Empty 0, // 1: grpc.gateway.examples.internal.proto.examplepb.ExcessBodyService.NoBodyServerStream:input_type -> google.protobuf.Empty 0, // 2: grpc.gateway.examples.internal.proto.examplepb.ExcessBodyService.WithBodyRpc:input_type -> google.protobuf.Empty 0, // 3: grpc.gateway.examples.internal.proto.examplepb.ExcessBodyService.WithBodyServerStream:input_type -> google.protobuf.Empty 0, // 4: grpc.gateway.examples.internal.proto.examplepb.ExcessBodyService.NoBodyRpc:output_type -> google.protobuf.Empty 0, // 5: grpc.gateway.examples.internal.proto.examplepb.ExcessBodyService.NoBodyServerStream:output_type -> google.protobuf.Empty 0, // 6: grpc.gateway.examples.internal.proto.examplepb.ExcessBodyService.WithBodyRpc:output_type -> google.protobuf.Empty 0, // 7: grpc.gateway.examples.internal.proto.examplepb.ExcessBodyService.WithBodyServerStream:output_type -> google.protobuf.Empty 4, // [4:8] is the sub-list for method output_type 0, // [0:4] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name } func init() { file_examples_internal_proto_examplepb_excess_body_proto_init() } func file_examples_internal_proto_examplepb_excess_body_proto_init() { if File_examples_internal_proto_examplepb_excess_body_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_examplepb_excess_body_proto_rawDesc, NumEnums: 0, NumMessages: 0, NumExtensions: 0, NumServices: 1, }, GoTypes: file_examples_internal_proto_examplepb_excess_body_proto_goTypes, DependencyIndexes: file_examples_internal_proto_examplepb_excess_body_proto_depIdxs, }.Build() File_examples_internal_proto_examplepb_excess_body_proto = out.File file_examples_internal_proto_examplepb_excess_body_proto_rawDesc = nil file_examples_internal_proto_examplepb_excess_body_proto_goTypes = nil file_examples_internal_proto_examplepb_excess_body_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/examplepb/excess_body.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/proto/examplepb/excess_body.proto /* Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package examplepb import ( "context" "errors" "io" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/emptypb" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) func request_ExcessBodyService_NoBodyRpc_0(ctx context.Context, marshaler runtime.Marshaler, client ExcessBodyServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq emptypb.Empty metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.NoBodyRpc(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ExcessBodyService_NoBodyRpc_0(ctx context.Context, marshaler runtime.Marshaler, server ExcessBodyServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq emptypb.Empty metadata runtime.ServerMetadata ) msg, err := server.NoBodyRpc(ctx, &protoReq) return msg, metadata, err } func request_ExcessBodyService_NoBodyServerStream_0(ctx context.Context, marshaler runtime.Marshaler, client ExcessBodyServiceClient, req *http.Request, pathParams map[string]string) (ExcessBodyService_NoBodyServerStreamClient, runtime.ServerMetadata, error) { var ( protoReq emptypb.Empty metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } stream, err := client.NoBodyServerStream(ctx, &protoReq) if err != nil { return nil, metadata, err } header, err := stream.Header() if err != nil { return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } func request_ExcessBodyService_WithBodyRpc_0(ctx context.Context, marshaler runtime.Marshaler, client ExcessBodyServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq emptypb.Empty metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.WithBodyRpc(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ExcessBodyService_WithBodyRpc_0(ctx context.Context, marshaler runtime.Marshaler, server ExcessBodyServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq emptypb.Empty metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.WithBodyRpc(ctx, &protoReq) return msg, metadata, err } func request_ExcessBodyService_WithBodyServerStream_0(ctx context.Context, marshaler runtime.Marshaler, client ExcessBodyServiceClient, req *http.Request, pathParams map[string]string) (ExcessBodyService_WithBodyServerStreamClient, runtime.ServerMetadata, error) { var ( protoReq emptypb.Empty metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } stream, err := client.WithBodyServerStream(ctx, &protoReq) if err != nil { return nil, metadata, err } header, err := stream.Header() if err != nil { return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } // RegisterExcessBodyServiceHandlerServer registers the http handlers for service ExcessBodyService to "mux". // UnaryRPC :call ExcessBodyServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterExcessBodyServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterExcessBodyServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ExcessBodyServiceServer) error { mux.Handle(http.MethodPost, pattern_ExcessBodyService_NoBodyRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ExcessBodyService/NoBodyRpc", runtime.WithHTTPPathPattern("/rpc/excess-body/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ExcessBodyService_NoBodyRpc_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ExcessBodyService_NoBodyRpc_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ExcessBodyService_NoBodyServerStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodPost, pattern_ExcessBodyService_WithBodyRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ExcessBodyService/WithBodyRpc", runtime.WithHTTPPathPattern("/rpc/excess-body/rpc/with-body")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ExcessBodyService_WithBodyRpc_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ExcessBodyService_WithBodyRpc_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ExcessBodyService_WithBodyServerStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) return nil } // RegisterExcessBodyServiceHandlerFromEndpoint is same as RegisterExcessBodyServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterExcessBodyServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterExcessBodyServiceHandler(ctx, mux, conn) } // RegisterExcessBodyServiceHandler registers the http handlers for service ExcessBodyService to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterExcessBodyServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterExcessBodyServiceHandlerClient(ctx, mux, NewExcessBodyServiceClient(conn)) } // RegisterExcessBodyServiceHandlerClient registers the http handlers for service ExcessBodyService // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ExcessBodyServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ExcessBodyServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "ExcessBodyServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterExcessBodyServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ExcessBodyServiceClient) error { mux.Handle(http.MethodPost, pattern_ExcessBodyService_NoBodyRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ExcessBodyService/NoBodyRpc", runtime.WithHTTPPathPattern("/rpc/excess-body/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ExcessBodyService_NoBodyRpc_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ExcessBodyService_NoBodyRpc_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ExcessBodyService_NoBodyServerStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ExcessBodyService/NoBodyServerStream", runtime.WithHTTPPathPattern("/rpc/excess-body/stream")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ExcessBodyService_NoBodyServerStream_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ExcessBodyService_NoBodyServerStream_0(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ExcessBodyService_WithBodyRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ExcessBodyService/WithBodyRpc", runtime.WithHTTPPathPattern("/rpc/excess-body/rpc/with-body")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ExcessBodyService_WithBodyRpc_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ExcessBodyService_WithBodyRpc_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ExcessBodyService_WithBodyServerStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ExcessBodyService/WithBodyServerStream", runtime.WithHTTPPathPattern("/rpc/excess-body/stream/with-body")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ExcessBodyService_WithBodyServerStream_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ExcessBodyService_WithBodyServerStream_0(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_ExcessBodyService_NoBodyRpc_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 0}, []string{"rpc", "excess-body"}, "")) pattern_ExcessBodyService_NoBodyServerStream_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"rpc", "excess-body", "stream"}, "")) pattern_ExcessBodyService_WithBodyRpc_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 0, 2, 2}, []string{"rpc", "excess-body", "with-body"}, "")) pattern_ExcessBodyService_WithBodyServerStream_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"rpc", "excess-body", "stream", "with-body"}, "")) ) var ( forward_ExcessBodyService_NoBodyRpc_0 = runtime.ForwardResponseMessage forward_ExcessBodyService_NoBodyServerStream_0 = runtime.ForwardResponseStream forward_ExcessBodyService_WithBodyRpc_0 = runtime.ForwardResponseMessage forward_ExcessBodyService_WithBodyServerStream_0 = runtime.ForwardResponseStream ) ================================================ FILE: examples/internal/proto/examplepb/excess_body.proto ================================================ syntax = "proto3"; // Excess Body Service // Used to test server context cancellation with Unary and ServerStream methods // when client sends more data than expected. package grpc.gateway.examples.internal.proto.examplepb; import "google/api/annotations.proto"; import "google/protobuf/empty.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; service ExcessBodyService { rpc NoBodyRpc(google.protobuf.Empty) returns (google.protobuf.Empty) { option (google.api.http) = {post: "/rpc/excess-body/rpc"}; } rpc NoBodyServerStream(google.protobuf.Empty) returns (stream google.protobuf.Empty) { option (google.api.http) = {post: "/rpc/excess-body/stream"}; } rpc WithBodyRpc(google.protobuf.Empty) returns (google.protobuf.Empty) { option (google.api.http) = { post: "/rpc/excess-body/rpc/with-body" body: "*" }; } rpc WithBodyServerStream(google.protobuf.Empty) returns (stream google.protobuf.Empty) { option (google.api.http) = { post: "/rpc/excess-body/stream/with-body" body: "*" }; } } ================================================ FILE: examples/internal/proto/examplepb/excess_body.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/examplepb/excess_body.proto", "description": "Excess Body Service\nUsed to test server context cancellation with Unary and ServerStream methods\nwhen client sends more data than expected.", "version": "version not set" }, "tags": [ { "name": "ExcessBodyService" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/rpc/excess-body/rpc": { "post": { "operationId": "ExcessBodyService_NoBodyRpc", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "tags": [ "ExcessBodyService" ] } }, "/rpc/excess-body/rpc/with-body": { "post": { "operationId": "ExcessBodyService_WithBodyRpc", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "type": "object", "properties": {} } } ], "tags": [ "ExcessBodyService" ] } }, "/rpc/excess-body/stream": { "post": { "operationId": "ExcessBodyService_NoBodyServerStream", "responses": { "200": { "description": "A successful response.(streaming responses)", "schema": { "type": "object", "properties": { "result": {}, "error": { "$ref": "#/definitions/googleRpcStatus" } }, "title": "Stream result of googleProtobufEmpty" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "tags": [ "ExcessBodyService" ] } }, "/rpc/excess-body/stream/with-body": { "post": { "operationId": "ExcessBodyService_WithBodyServerStream", "responses": { "200": { "description": "A successful response.(streaming responses)", "schema": { "type": "object", "properties": { "result": {}, "error": { "$ref": "#/definitions/googleRpcStatus" } }, "title": "Stream result of googleProtobufEmpty" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "type": "object", "properties": {} } } ], "tags": [ "ExcessBodyService" ] } } }, "definitions": { "googleRpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32", "description": "The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]." }, "message": { "type": "string", "description": "A developer-facing error message, which should be in English. Any\nuser-facing error message should be localized and sent in the\n[google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client." }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" }, "description": "A list of messages that carry the error details. There is a common set of\nmessage types for APIs to use." } }, "description": "The `Status` type defines a logical error model that is suitable for\ndifferent programming environments, including REST APIs and RPC APIs. It is\nused by [gRPC](https://github.com/grpc). Each `Status` message contains\nthree pieces of data: error code, error message, and error details.\n\nYou can find out more about this error model and how to work with it in the\n[API Design Guide](https://cloud.google.com/apis/design/errors)." }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string", "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics." } }, "additionalProperties": {}, "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }" } } } ================================================ FILE: examples/internal/proto/examplepb/excess_body_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: examples/internal/proto/examplepb/excess_body.proto // Excess Body Service // Used to test server context cancellation with Unary and ServerStream methods // when client sends more data than expected. package examplepb import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" emptypb "google.golang.org/protobuf/types/known/emptypb" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( ExcessBodyService_NoBodyRpc_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ExcessBodyService/NoBodyRpc" ExcessBodyService_NoBodyServerStream_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ExcessBodyService/NoBodyServerStream" ExcessBodyService_WithBodyRpc_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ExcessBodyService/WithBodyRpc" ExcessBodyService_WithBodyServerStream_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ExcessBodyService/WithBodyServerStream" ) // ExcessBodyServiceClient is the client API for ExcessBodyService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type ExcessBodyServiceClient interface { NoBodyRpc(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) NoBodyServerStream(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (grpc.ServerStreamingClient[emptypb.Empty], error) WithBodyRpc(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) WithBodyServerStream(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (grpc.ServerStreamingClient[emptypb.Empty], error) } type excessBodyServiceClient struct { cc grpc.ClientConnInterface } func NewExcessBodyServiceClient(cc grpc.ClientConnInterface) ExcessBodyServiceClient { return &excessBodyServiceClient{cc} } func (c *excessBodyServiceClient) NoBodyRpc(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) err := c.cc.Invoke(ctx, ExcessBodyService_NoBodyRpc_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *excessBodyServiceClient) NoBodyServerStream(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (grpc.ServerStreamingClient[emptypb.Empty], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &ExcessBodyService_ServiceDesc.Streams[0], ExcessBodyService_NoBodyServerStream_FullMethodName, cOpts...) if err != nil { return nil, err } x := &grpc.GenericClientStream[emptypb.Empty, emptypb.Empty]{ClientStream: stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } if err := x.ClientStream.CloseSend(); err != nil { return nil, err } return x, nil } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type ExcessBodyService_NoBodyServerStreamClient = grpc.ServerStreamingClient[emptypb.Empty] func (c *excessBodyServiceClient) WithBodyRpc(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) err := c.cc.Invoke(ctx, ExcessBodyService_WithBodyRpc_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *excessBodyServiceClient) WithBodyServerStream(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (grpc.ServerStreamingClient[emptypb.Empty], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &ExcessBodyService_ServiceDesc.Streams[1], ExcessBodyService_WithBodyServerStream_FullMethodName, cOpts...) if err != nil { return nil, err } x := &grpc.GenericClientStream[emptypb.Empty, emptypb.Empty]{ClientStream: stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } if err := x.ClientStream.CloseSend(); err != nil { return nil, err } return x, nil } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type ExcessBodyService_WithBodyServerStreamClient = grpc.ServerStreamingClient[emptypb.Empty] // ExcessBodyServiceServer is the server API for ExcessBodyService service. // All implementations should embed UnimplementedExcessBodyServiceServer // for forward compatibility. type ExcessBodyServiceServer interface { NoBodyRpc(context.Context, *emptypb.Empty) (*emptypb.Empty, error) NoBodyServerStream(*emptypb.Empty, grpc.ServerStreamingServer[emptypb.Empty]) error WithBodyRpc(context.Context, *emptypb.Empty) (*emptypb.Empty, error) WithBodyServerStream(*emptypb.Empty, grpc.ServerStreamingServer[emptypb.Empty]) error } // UnimplementedExcessBodyServiceServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedExcessBodyServiceServer struct{} func (UnimplementedExcessBodyServiceServer) NoBodyRpc(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method NoBodyRpc not implemented") } func (UnimplementedExcessBodyServiceServer) NoBodyServerStream(*emptypb.Empty, grpc.ServerStreamingServer[emptypb.Empty]) error { return status.Errorf(codes.Unimplemented, "method NoBodyServerStream not implemented") } func (UnimplementedExcessBodyServiceServer) WithBodyRpc(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method WithBodyRpc not implemented") } func (UnimplementedExcessBodyServiceServer) WithBodyServerStream(*emptypb.Empty, grpc.ServerStreamingServer[emptypb.Empty]) error { return status.Errorf(codes.Unimplemented, "method WithBodyServerStream not implemented") } func (UnimplementedExcessBodyServiceServer) testEmbeddedByValue() {} // UnsafeExcessBodyServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to ExcessBodyServiceServer will // result in compilation errors. type UnsafeExcessBodyServiceServer interface { mustEmbedUnimplementedExcessBodyServiceServer() } func RegisterExcessBodyServiceServer(s grpc.ServiceRegistrar, srv ExcessBodyServiceServer) { // If the following call pancis, it indicates UnimplementedExcessBodyServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&ExcessBodyService_ServiceDesc, srv) } func _ExcessBodyService_NoBodyRpc_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(emptypb.Empty) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ExcessBodyServiceServer).NoBodyRpc(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ExcessBodyService_NoBodyRpc_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ExcessBodyServiceServer).NoBodyRpc(ctx, req.(*emptypb.Empty)) } return interceptor(ctx, in, info, handler) } func _ExcessBodyService_NoBodyServerStream_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(emptypb.Empty) if err := stream.RecvMsg(m); err != nil { return err } return srv.(ExcessBodyServiceServer).NoBodyServerStream(m, &grpc.GenericServerStream[emptypb.Empty, emptypb.Empty]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type ExcessBodyService_NoBodyServerStreamServer = grpc.ServerStreamingServer[emptypb.Empty] func _ExcessBodyService_WithBodyRpc_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(emptypb.Empty) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ExcessBodyServiceServer).WithBodyRpc(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ExcessBodyService_WithBodyRpc_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ExcessBodyServiceServer).WithBodyRpc(ctx, req.(*emptypb.Empty)) } return interceptor(ctx, in, info, handler) } func _ExcessBodyService_WithBodyServerStream_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(emptypb.Empty) if err := stream.RecvMsg(m); err != nil { return err } return srv.(ExcessBodyServiceServer).WithBodyServerStream(m, &grpc.GenericServerStream[emptypb.Empty, emptypb.Empty]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type ExcessBodyService_WithBodyServerStreamServer = grpc.ServerStreamingServer[emptypb.Empty] // ExcessBodyService_ServiceDesc is the grpc.ServiceDesc for ExcessBodyService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var ExcessBodyService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.ExcessBodyService", HandlerType: (*ExcessBodyServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "NoBodyRpc", Handler: _ExcessBodyService_NoBodyRpc_Handler, }, { MethodName: "WithBodyRpc", Handler: _ExcessBodyService_WithBodyRpc_Handler, }, }, Streams: []grpc.StreamDesc{ { StreamName: "NoBodyServerStream", Handler: _ExcessBodyService_NoBodyServerStream_Handler, ServerStreams: true, }, { StreamName: "WithBodyServerStream", Handler: _ExcessBodyService_WithBodyServerStream_Handler, ServerStreams: true, }, }, Metadata: "examples/internal/proto/examplepb/excess_body.proto", } ================================================ FILE: examples/internal/proto/examplepb/flow_combination.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/examplepb/flow_combination.proto package examplepb import ( _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) type EmptyProto struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields } func (x *EmptyProto) Reset() { *x = EmptyProto{} mi := &file_examples_internal_proto_examplepb_flow_combination_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *EmptyProto) String() string { return protoimpl.X.MessageStringOf(x) } func (*EmptyProto) ProtoMessage() {} func (x *EmptyProto) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_flow_combination_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use EmptyProto.ProtoReflect.Descriptor instead. func (*EmptyProto) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_flow_combination_proto_rawDescGZIP(), []int{0} } type NonEmptyProto struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields A string `protobuf:"bytes,1,opt,name=a,proto3" json:"a,omitempty"` B string `protobuf:"bytes,2,opt,name=b,proto3" json:"b,omitempty"` C string `protobuf:"bytes,3,opt,name=c,proto3" json:"c,omitempty"` } func (x *NonEmptyProto) Reset() { *x = NonEmptyProto{} mi := &file_examples_internal_proto_examplepb_flow_combination_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NonEmptyProto) String() string { return protoimpl.X.MessageStringOf(x) } func (*NonEmptyProto) ProtoMessage() {} func (x *NonEmptyProto) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_flow_combination_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NonEmptyProto.ProtoReflect.Descriptor instead. func (*NonEmptyProto) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_flow_combination_proto_rawDescGZIP(), []int{1} } func (x *NonEmptyProto) GetA() string { if x != nil { return x.A } return "" } func (x *NonEmptyProto) GetB() string { if x != nil { return x.B } return "" } func (x *NonEmptyProto) GetC() string { if x != nil { return x.C } return "" } type UnaryProto struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Str string `protobuf:"bytes,1,opt,name=str,proto3" json:"str,omitempty"` } func (x *UnaryProto) Reset() { *x = UnaryProto{} mi := &file_examples_internal_proto_examplepb_flow_combination_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *UnaryProto) String() string { return protoimpl.X.MessageStringOf(x) } func (*UnaryProto) ProtoMessage() {} func (x *UnaryProto) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_flow_combination_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use UnaryProto.ProtoReflect.Descriptor instead. func (*UnaryProto) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_flow_combination_proto_rawDescGZIP(), []int{2} } func (x *UnaryProto) GetStr() string { if x != nil { return x.Str } return "" } type NestedProto struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields A *UnaryProto `protobuf:"bytes,1,opt,name=a,proto3" json:"a,omitempty"` B string `protobuf:"bytes,2,opt,name=b,proto3" json:"b,omitempty"` C string `protobuf:"bytes,3,opt,name=c,proto3" json:"c,omitempty"` } func (x *NestedProto) Reset() { *x = NestedProto{} mi := &file_examples_internal_proto_examplepb_flow_combination_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NestedProto) String() string { return protoimpl.X.MessageStringOf(x) } func (*NestedProto) ProtoMessage() {} func (x *NestedProto) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_flow_combination_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NestedProto.ProtoReflect.Descriptor instead. func (*NestedProto) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_flow_combination_proto_rawDescGZIP(), []int{3} } func (x *NestedProto) GetA() *UnaryProto { if x != nil { return x.A } return nil } func (x *NestedProto) GetB() string { if x != nil { return x.B } return "" } func (x *NestedProto) GetC() string { if x != nil { return x.C } return "" } type SingleNestedProto struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields A *UnaryProto `protobuf:"bytes,1,opt,name=a,proto3" json:"a,omitempty"` } func (x *SingleNestedProto) Reset() { *x = SingleNestedProto{} mi := &file_examples_internal_proto_examplepb_flow_combination_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *SingleNestedProto) String() string { return protoimpl.X.MessageStringOf(x) } func (*SingleNestedProto) ProtoMessage() {} func (x *SingleNestedProto) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_flow_combination_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use SingleNestedProto.ProtoReflect.Descriptor instead. func (*SingleNestedProto) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_flow_combination_proto_rawDescGZIP(), []int{4} } func (x *SingleNestedProto) GetA() *UnaryProto { if x != nil { return x.A } return nil } var File_examples_internal_proto_examplepb_flow_combination_proto protoreflect.FileDescriptor var file_examples_internal_proto_examplepb_flow_combination_proto_rawDesc = []byte{ 0x0a, 0x38, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x66, 0x6c, 0x6f, 0x77, 0x5f, 0x63, 0x6f, 0x6d, 0x62, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x0c, 0x0a, 0x0a, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x39, 0x0a, 0x0d, 0x4e, 0x6f, 0x6e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x0a, 0x01, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x01, 0x61, 0x12, 0x0c, 0x0a, 0x01, 0x62, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x01, 0x62, 0x12, 0x0c, 0x0a, 0x01, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x01, 0x63, 0x22, 0x1e, 0x0a, 0x0a, 0x55, 0x6e, 0x61, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x74, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x74, 0x72, 0x22, 0x73, 0x0a, 0x0b, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x48, 0x0a, 0x01, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x3a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x55, 0x6e, 0x61, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x52, 0x01, 0x61, 0x12, 0x0c, 0x0a, 0x01, 0x62, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x01, 0x62, 0x12, 0x0c, 0x0a, 0x01, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x01, 0x63, 0x22, 0x5d, 0x0a, 0x11, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x48, 0x0a, 0x01, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x3a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x55, 0x6e, 0x61, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x52, 0x01, 0x61, 0x32, 0xfd, 0x11, 0x0a, 0x0f, 0x46, 0x6c, 0x6f, 0x77, 0x43, 0x6f, 0x6d, 0x62, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x9d, 0x01, 0x0a, 0x0b, 0x52, 0x70, 0x63, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x70, 0x63, 0x12, 0x3a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x3a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x22, 0x0e, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2f, 0x72, 0x70, 0x63, 0x12, 0xa5, 0x01, 0x0a, 0x0e, 0x52, 0x70, 0x63, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x3a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x3a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x22, 0x11, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x30, 0x01, 0x12, 0xa5, 0x01, 0x0a, 0x0e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x70, 0x63, 0x12, 0x3a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x3a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x22, 0x11, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2f, 0x72, 0x70, 0x63, 0x28, 0x01, 0x12, 0xad, 0x01, 0x0a, 0x11, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x3a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x3a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x22, 0x14, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x28, 0x01, 0x30, 0x01, 0x12, 0xcb, 0x02, 0x0a, 0x0a, 0x52, 0x70, 0x63, 0x42, 0x6f, 0x64, 0x79, 0x52, 0x70, 0x63, 0x12, 0x3d, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x3a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc1, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0xba, 0x01, 0x3a, 0x01, 0x2a, 0x5a, 0x1b, 0x22, 0x19, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x2f, 0x7b, 0x61, 0x7d, 0x2f, 0x7b, 0x62, 0x7d, 0x2f, 0x7b, 0x63, 0x7d, 0x2f, 0x72, 0x70, 0x63, 0x5a, 0x10, 0x22, 0x0e, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x72, 0x70, 0x63, 0x5a, 0x1f, 0x3a, 0x01, 0x63, 0x22, 0x1a, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x2f, 0x7b, 0x61, 0x7d, 0x2f, 0x7b, 0x62, 0x7d, 0x2f, 0x72, 0x70, 0x63, 0x5a, 0x18, 0x3a, 0x01, 0x63, 0x22, 0x13, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x72, 0x70, 0x63, 0x5a, 0x21, 0x3a, 0x01, 0x63, 0x22, 0x1c, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x2f, 0x7b, 0x61, 0x7d, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x72, 0x70, 0x63, 0x5a, 0x19, 0x22, 0x17, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x2f, 0x7b, 0x61, 0x7d, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x72, 0x70, 0x63, 0x22, 0x0d, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x2f, 0x72, 0x70, 0x63, 0x12, 0xbd, 0x01, 0x0a, 0x16, 0x52, 0x70, 0x63, 0x50, 0x61, 0x74, 0x68, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x70, 0x63, 0x12, 0x41, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x3a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x24, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x22, 0x1c, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x2d, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x2f, 0x7b, 0x61, 0x2e, 0x73, 0x74, 0x72, 0x7d, 0x2f, 0x72, 0x70, 0x63, 0x12, 0xfd, 0x01, 0x0a, 0x10, 0x52, 0x70, 0x63, 0x50, 0x61, 0x74, 0x68, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x70, 0x63, 0x12, 0x3b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x3a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x70, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x6a, 0x3a, 0x01, 0x63, 0x5a, 0x1f, 0x22, 0x1d, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x2d, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x31, 0x2f, 0x7b, 0x61, 0x2e, 0x73, 0x74, 0x72, 0x7d, 0x2f, 0x72, 0x70, 0x63, 0x5a, 0x22, 0x3a, 0x01, 0x63, 0x22, 0x1d, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x2d, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x32, 0x2f, 0x7b, 0x61, 0x2e, 0x73, 0x74, 0x72, 0x7d, 0x2f, 0x72, 0x70, 0x63, 0x22, 0x20, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x2d, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x2f, 0x7b, 0x61, 0x2e, 0x73, 0x74, 0x72, 0x7d, 0x2f, 0x7b, 0x62, 0x7d, 0x2f, 0x72, 0x70, 0x63, 0x12, 0xe5, 0x02, 0x0a, 0x0d, 0x52, 0x70, 0x63, 0x42, 0x6f, 0x64, 0x79, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x3d, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x3a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd6, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0xcf, 0x01, 0x3a, 0x01, 0x2a, 0x5a, 0x1e, 0x22, 0x1c, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x2f, 0x7b, 0x61, 0x7d, 0x2f, 0x7b, 0x62, 0x7d, 0x2f, 0x7b, 0x63, 0x7d, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x5a, 0x13, 0x22, 0x11, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x5a, 0x22, 0x3a, 0x01, 0x63, 0x22, 0x1d, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x2f, 0x7b, 0x61, 0x7d, 0x2f, 0x7b, 0x62, 0x7d, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x5a, 0x1b, 0x3a, 0x01, 0x63, 0x22, 0x16, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x5a, 0x24, 0x3a, 0x01, 0x63, 0x22, 0x1f, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x2f, 0x7b, 0x61, 0x7d, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x5a, 0x1c, 0x22, 0x1a, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x2f, 0x7b, 0x61, 0x7d, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x22, 0x10, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x30, 0x01, 0x12, 0xc5, 0x01, 0x0a, 0x19, 0x52, 0x70, 0x63, 0x50, 0x61, 0x74, 0x68, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x41, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x3a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x27, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x21, 0x22, 0x1f, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x2d, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x2f, 0x7b, 0x61, 0x2e, 0x73, 0x74, 0x72, 0x7d, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x30, 0x01, 0x12, 0x8b, 0x02, 0x0a, 0x13, 0x52, 0x70, 0x63, 0x50, 0x61, 0x74, 0x68, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x3b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x3a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x79, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x73, 0x3a, 0x01, 0x63, 0x5a, 0x22, 0x22, 0x20, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x2d, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x31, 0x2f, 0x7b, 0x61, 0x2e, 0x73, 0x74, 0x72, 0x7d, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x5a, 0x25, 0x3a, 0x01, 0x63, 0x22, 0x20, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x2d, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x32, 0x2f, 0x7b, 0x61, 0x2e, 0x73, 0x74, 0x72, 0x7d, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x22, 0x23, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x2d, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x2f, 0x7b, 0x61, 0x2e, 0x73, 0x74, 0x72, 0x7d, 0x2f, 0x7b, 0x62, 0x7d, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x30, 0x01, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_examplepb_flow_combination_proto_rawDescOnce sync.Once file_examples_internal_proto_examplepb_flow_combination_proto_rawDescData = file_examples_internal_proto_examplepb_flow_combination_proto_rawDesc ) func file_examples_internal_proto_examplepb_flow_combination_proto_rawDescGZIP() []byte { file_examples_internal_proto_examplepb_flow_combination_proto_rawDescOnce.Do(func() { file_examples_internal_proto_examplepb_flow_combination_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_examplepb_flow_combination_proto_rawDescData) }) return file_examples_internal_proto_examplepb_flow_combination_proto_rawDescData } var file_examples_internal_proto_examplepb_flow_combination_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_examples_internal_proto_examplepb_flow_combination_proto_goTypes = []any{ (*EmptyProto)(nil), // 0: grpc.gateway.examples.internal.proto.examplepb.EmptyProto (*NonEmptyProto)(nil), // 1: grpc.gateway.examples.internal.proto.examplepb.NonEmptyProto (*UnaryProto)(nil), // 2: grpc.gateway.examples.internal.proto.examplepb.UnaryProto (*NestedProto)(nil), // 3: grpc.gateway.examples.internal.proto.examplepb.NestedProto (*SingleNestedProto)(nil), // 4: grpc.gateway.examples.internal.proto.examplepb.SingleNestedProto } var file_examples_internal_proto_examplepb_flow_combination_proto_depIdxs = []int32{ 2, // 0: grpc.gateway.examples.internal.proto.examplepb.NestedProto.a:type_name -> grpc.gateway.examples.internal.proto.examplepb.UnaryProto 2, // 1: grpc.gateway.examples.internal.proto.examplepb.SingleNestedProto.a:type_name -> grpc.gateway.examples.internal.proto.examplepb.UnaryProto 0, // 2: grpc.gateway.examples.internal.proto.examplepb.FlowCombination.RpcEmptyRpc:input_type -> grpc.gateway.examples.internal.proto.examplepb.EmptyProto 0, // 3: grpc.gateway.examples.internal.proto.examplepb.FlowCombination.RpcEmptyStream:input_type -> grpc.gateway.examples.internal.proto.examplepb.EmptyProto 0, // 4: grpc.gateway.examples.internal.proto.examplepb.FlowCombination.StreamEmptyRpc:input_type -> grpc.gateway.examples.internal.proto.examplepb.EmptyProto 0, // 5: grpc.gateway.examples.internal.proto.examplepb.FlowCombination.StreamEmptyStream:input_type -> grpc.gateway.examples.internal.proto.examplepb.EmptyProto 1, // 6: grpc.gateway.examples.internal.proto.examplepb.FlowCombination.RpcBodyRpc:input_type -> grpc.gateway.examples.internal.proto.examplepb.NonEmptyProto 4, // 7: grpc.gateway.examples.internal.proto.examplepb.FlowCombination.RpcPathSingleNestedRpc:input_type -> grpc.gateway.examples.internal.proto.examplepb.SingleNestedProto 3, // 8: grpc.gateway.examples.internal.proto.examplepb.FlowCombination.RpcPathNestedRpc:input_type -> grpc.gateway.examples.internal.proto.examplepb.NestedProto 1, // 9: grpc.gateway.examples.internal.proto.examplepb.FlowCombination.RpcBodyStream:input_type -> grpc.gateway.examples.internal.proto.examplepb.NonEmptyProto 4, // 10: grpc.gateway.examples.internal.proto.examplepb.FlowCombination.RpcPathSingleNestedStream:input_type -> grpc.gateway.examples.internal.proto.examplepb.SingleNestedProto 3, // 11: grpc.gateway.examples.internal.proto.examplepb.FlowCombination.RpcPathNestedStream:input_type -> grpc.gateway.examples.internal.proto.examplepb.NestedProto 0, // 12: grpc.gateway.examples.internal.proto.examplepb.FlowCombination.RpcEmptyRpc:output_type -> grpc.gateway.examples.internal.proto.examplepb.EmptyProto 0, // 13: grpc.gateway.examples.internal.proto.examplepb.FlowCombination.RpcEmptyStream:output_type -> grpc.gateway.examples.internal.proto.examplepb.EmptyProto 0, // 14: grpc.gateway.examples.internal.proto.examplepb.FlowCombination.StreamEmptyRpc:output_type -> grpc.gateway.examples.internal.proto.examplepb.EmptyProto 0, // 15: grpc.gateway.examples.internal.proto.examplepb.FlowCombination.StreamEmptyStream:output_type -> grpc.gateway.examples.internal.proto.examplepb.EmptyProto 0, // 16: grpc.gateway.examples.internal.proto.examplepb.FlowCombination.RpcBodyRpc:output_type -> grpc.gateway.examples.internal.proto.examplepb.EmptyProto 0, // 17: grpc.gateway.examples.internal.proto.examplepb.FlowCombination.RpcPathSingleNestedRpc:output_type -> grpc.gateway.examples.internal.proto.examplepb.EmptyProto 0, // 18: grpc.gateway.examples.internal.proto.examplepb.FlowCombination.RpcPathNestedRpc:output_type -> grpc.gateway.examples.internal.proto.examplepb.EmptyProto 0, // 19: grpc.gateway.examples.internal.proto.examplepb.FlowCombination.RpcBodyStream:output_type -> grpc.gateway.examples.internal.proto.examplepb.EmptyProto 0, // 20: grpc.gateway.examples.internal.proto.examplepb.FlowCombination.RpcPathSingleNestedStream:output_type -> grpc.gateway.examples.internal.proto.examplepb.EmptyProto 0, // 21: grpc.gateway.examples.internal.proto.examplepb.FlowCombination.RpcPathNestedStream:output_type -> grpc.gateway.examples.internal.proto.examplepb.EmptyProto 12, // [12:22] is the sub-list for method output_type 2, // [2:12] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name 2, // [2:2] is the sub-list for extension extendee 0, // [0:2] is the sub-list for field type_name } func init() { file_examples_internal_proto_examplepb_flow_combination_proto_init() } func file_examples_internal_proto_examplepb_flow_combination_proto_init() { if File_examples_internal_proto_examplepb_flow_combination_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_examplepb_flow_combination_proto_rawDesc, NumEnums: 0, NumMessages: 5, NumExtensions: 0, NumServices: 1, }, GoTypes: file_examples_internal_proto_examplepb_flow_combination_proto_goTypes, DependencyIndexes: file_examples_internal_proto_examplepb_flow_combination_proto_depIdxs, MessageInfos: file_examples_internal_proto_examplepb_flow_combination_proto_msgTypes, }.Build() File_examples_internal_proto_examplepb_flow_combination_proto = out.File file_examples_internal_proto_examplepb_flow_combination_proto_rawDesc = nil file_examples_internal_proto_examplepb_flow_combination_proto_goTypes = nil file_examples_internal_proto_examplepb_flow_combination_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/examplepb/flow_combination.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/proto/examplepb/flow_combination.proto /* Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package examplepb import ( "context" "errors" "io" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) func request_FlowCombination_RpcEmptyRpc_0(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq EmptyProto metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.RpcEmptyRpc(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_FlowCombination_RpcEmptyRpc_0(ctx context.Context, marshaler runtime.Marshaler, server FlowCombinationServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq EmptyProto metadata runtime.ServerMetadata ) msg, err := server.RpcEmptyRpc(ctx, &protoReq) return msg, metadata, err } func request_FlowCombination_RpcEmptyStream_0(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcEmptyStreamClient, runtime.ServerMetadata, error) { var ( protoReq EmptyProto metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } stream, err := client.RpcEmptyStream(ctx, &protoReq) if err != nil { return nil, metadata, err } header, err := stream.Header() if err != nil { return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } func request_FlowCombination_StreamEmptyRpc_0(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var metadata runtime.ServerMetadata stream, err := client.StreamEmptyRpc(ctx) if err != nil { grpclog.Errorf("Failed to start streaming: %v", err) return nil, metadata, err } dec := marshaler.NewDecoder(req.Body) for { var protoReq EmptyProto err = dec.Decode(&protoReq) if errors.Is(err, io.EOF) { break } if err != nil { grpclog.Errorf("Failed to decode request: %v", err) return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err = stream.Send(&protoReq); err != nil { if errors.Is(err, io.EOF) { break } grpclog.Errorf("Failed to send request: %v", err) return nil, metadata, err } } if err := stream.CloseSend(); err != nil { grpclog.Errorf("Failed to terminate client stream: %v", err) return nil, metadata, err } header, err := stream.Header() if err != nil { grpclog.Errorf("Failed to get header from client: %v", err) return nil, metadata, err } metadata.HeaderMD = header msg, err := stream.CloseAndRecv() metadata.TrailerMD = stream.Trailer() return msg, metadata, err } func request_FlowCombination_StreamEmptyStream_0(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_StreamEmptyStreamClient, runtime.ServerMetadata, error) { var metadata runtime.ServerMetadata stream, err := client.StreamEmptyStream(ctx) if err != nil { grpclog.Errorf("Failed to start streaming: %v", err) return nil, metadata, err } dec := marshaler.NewDecoder(req.Body) handleSend := func() error { var protoReq EmptyProto err := dec.Decode(&protoReq) if errors.Is(err, io.EOF) { return err } if err != nil { grpclog.Errorf("Failed to decode request: %v", err) return status.Errorf(codes.InvalidArgument, "Failed to decode request: %v", err) } if err := stream.Send(&protoReq); err != nil { grpclog.Errorf("Failed to send request: %v", err) return err } return nil } go func() { for { if err := handleSend(); err != nil { break } } if err := stream.CloseSend(); err != nil { grpclog.Errorf("Failed to terminate client stream: %v", err) } }() header, err := stream.Header() if err != nil { grpclog.Errorf("Failed to get header from client: %v", err) return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } func request_FlowCombination_RpcBodyRpc_0(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NonEmptyProto metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.RpcBodyRpc(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_FlowCombination_RpcBodyRpc_0(ctx context.Context, marshaler runtime.Marshaler, server FlowCombinationServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NonEmptyProto metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.RpcBodyRpc(ctx, &protoReq) return msg, metadata, err } func request_FlowCombination_RpcBodyRpc_1(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NonEmptyProto metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["a"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a") } protoReq.A, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a", err) } val, ok = pathParams["b"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "b") } protoReq.B, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "b", err) } val, ok = pathParams["c"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "c") } protoReq.C, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "c", err) } msg, err := client.RpcBodyRpc(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_FlowCombination_RpcBodyRpc_1(ctx context.Context, marshaler runtime.Marshaler, server FlowCombinationServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NonEmptyProto metadata runtime.ServerMetadata err error ) val, ok := pathParams["a"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a") } protoReq.A, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a", err) } val, ok = pathParams["b"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "b") } protoReq.B, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "b", err) } val, ok = pathParams["c"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "c") } protoReq.C, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "c", err) } msg, err := server.RpcBodyRpc(ctx, &protoReq) return msg, metadata, err } var filter_FlowCombination_RpcBodyRpc_2 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_FlowCombination_RpcBodyRpc_2(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NonEmptyProto metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcBodyRpc_2); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.RpcBodyRpc(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_FlowCombination_RpcBodyRpc_2(ctx context.Context, marshaler runtime.Marshaler, server FlowCombinationServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NonEmptyProto metadata runtime.ServerMetadata ) if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcBodyRpc_2); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.RpcBodyRpc(ctx, &protoReq) return msg, metadata, err } func request_FlowCombination_RpcBodyRpc_3(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NonEmptyProto metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.C); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["a"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a") } protoReq.A, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a", err) } val, ok = pathParams["b"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "b") } protoReq.B, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "b", err) } msg, err := client.RpcBodyRpc(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_FlowCombination_RpcBodyRpc_3(ctx context.Context, marshaler runtime.Marshaler, server FlowCombinationServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NonEmptyProto metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.C); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["a"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a") } protoReq.A, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a", err) } val, ok = pathParams["b"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "b") } protoReq.B, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "b", err) } msg, err := server.RpcBodyRpc(ctx, &protoReq) return msg, metadata, err } var filter_FlowCombination_RpcBodyRpc_4 = &utilities.DoubleArray{Encoding: map[string]int{"c": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_FlowCombination_RpcBodyRpc_4(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NonEmptyProto metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.C); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcBodyRpc_4); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.RpcBodyRpc(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_FlowCombination_RpcBodyRpc_4(ctx context.Context, marshaler runtime.Marshaler, server FlowCombinationServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NonEmptyProto metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.C); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcBodyRpc_4); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.RpcBodyRpc(ctx, &protoReq) return msg, metadata, err } var filter_FlowCombination_RpcBodyRpc_5 = &utilities.DoubleArray{Encoding: map[string]int{"c": 0, "a": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} func request_FlowCombination_RpcBodyRpc_5(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NonEmptyProto metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.C); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["a"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a") } protoReq.A, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcBodyRpc_5); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.RpcBodyRpc(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_FlowCombination_RpcBodyRpc_5(ctx context.Context, marshaler runtime.Marshaler, server FlowCombinationServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NonEmptyProto metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.C); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["a"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a") } protoReq.A, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcBodyRpc_5); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.RpcBodyRpc(ctx, &protoReq) return msg, metadata, err } var filter_FlowCombination_RpcBodyRpc_6 = &utilities.DoubleArray{Encoding: map[string]int{"a": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_FlowCombination_RpcBodyRpc_6(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NonEmptyProto metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["a"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a") } protoReq.A, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcBodyRpc_6); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.RpcBodyRpc(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_FlowCombination_RpcBodyRpc_6(ctx context.Context, marshaler runtime.Marshaler, server FlowCombinationServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NonEmptyProto metadata runtime.ServerMetadata err error ) val, ok := pathParams["a"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a") } protoReq.A, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcBodyRpc_6); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.RpcBodyRpc(ctx, &protoReq) return msg, metadata, err } var filter_FlowCombination_RpcPathSingleNestedRpc_0 = &utilities.DoubleArray{Encoding: map[string]int{"a": 0, "str": 1}, Base: []int{1, 1, 1, 0}, Check: []int{0, 1, 2, 3}} func request_FlowCombination_RpcPathSingleNestedRpc_0(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SingleNestedProto metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["a.str"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") } err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a.str", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcPathSingleNestedRpc_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.RpcPathSingleNestedRpc(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_FlowCombination_RpcPathSingleNestedRpc_0(ctx context.Context, marshaler runtime.Marshaler, server FlowCombinationServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq SingleNestedProto metadata runtime.ServerMetadata err error ) val, ok := pathParams["a.str"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") } err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a.str", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcPathSingleNestedRpc_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.RpcPathSingleNestedRpc(ctx, &protoReq) return msg, metadata, err } var filter_FlowCombination_RpcPathNestedRpc_0 = &utilities.DoubleArray{Encoding: map[string]int{"c": 0, "a": 1, "str": 2, "b": 3}, Base: []int{1, 1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 1, 3, 1, 2, 4, 5}} func request_FlowCombination_RpcPathNestedRpc_0(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NestedProto metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.C); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["a.str"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") } err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a.str", err) } val, ok = pathParams["b"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "b") } protoReq.B, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "b", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcPathNestedRpc_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.RpcPathNestedRpc(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_FlowCombination_RpcPathNestedRpc_0(ctx context.Context, marshaler runtime.Marshaler, server FlowCombinationServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NestedProto metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.C); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["a.str"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") } err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a.str", err) } val, ok = pathParams["b"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "b") } protoReq.B, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "b", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcPathNestedRpc_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.RpcPathNestedRpc(ctx, &protoReq) return msg, metadata, err } var filter_FlowCombination_RpcPathNestedRpc_1 = &utilities.DoubleArray{Encoding: map[string]int{"a": 0, "str": 1}, Base: []int{1, 1, 1, 0}, Check: []int{0, 1, 2, 3}} func request_FlowCombination_RpcPathNestedRpc_1(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NestedProto metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["a.str"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") } err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a.str", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcPathNestedRpc_1); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.RpcPathNestedRpc(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_FlowCombination_RpcPathNestedRpc_1(ctx context.Context, marshaler runtime.Marshaler, server FlowCombinationServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NestedProto metadata runtime.ServerMetadata err error ) val, ok := pathParams["a.str"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") } err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a.str", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcPathNestedRpc_1); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.RpcPathNestedRpc(ctx, &protoReq) return msg, metadata, err } var filter_FlowCombination_RpcPathNestedRpc_2 = &utilities.DoubleArray{Encoding: map[string]int{"c": 0, "a": 1, "str": 2}, Base: []int{1, 1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 3, 2, 4}} func request_FlowCombination_RpcPathNestedRpc_2(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NestedProto metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.C); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["a.str"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") } err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a.str", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcPathNestedRpc_2); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.RpcPathNestedRpc(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_FlowCombination_RpcPathNestedRpc_2(ctx context.Context, marshaler runtime.Marshaler, server FlowCombinationServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NestedProto metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.C); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["a.str"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") } err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a.str", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcPathNestedRpc_2); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.RpcPathNestedRpc(ctx, &protoReq) return msg, metadata, err } func request_FlowCombination_RpcBodyStream_0(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcBodyStreamClient, runtime.ServerMetadata, error) { var ( protoReq NonEmptyProto metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } stream, err := client.RpcBodyStream(ctx, &protoReq) if err != nil { return nil, metadata, err } header, err := stream.Header() if err != nil { return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } func request_FlowCombination_RpcBodyStream_1(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcBodyStreamClient, runtime.ServerMetadata, error) { var ( protoReq NonEmptyProto metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["a"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a") } protoReq.A, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a", err) } val, ok = pathParams["b"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "b") } protoReq.B, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "b", err) } val, ok = pathParams["c"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "c") } protoReq.C, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "c", err) } stream, err := client.RpcBodyStream(ctx, &protoReq) if err != nil { return nil, metadata, err } header, err := stream.Header() if err != nil { return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } var filter_FlowCombination_RpcBodyStream_2 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_FlowCombination_RpcBodyStream_2(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcBodyStreamClient, runtime.ServerMetadata, error) { var ( protoReq NonEmptyProto metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcBodyStream_2); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } stream, err := client.RpcBodyStream(ctx, &protoReq) if err != nil { return nil, metadata, err } header, err := stream.Header() if err != nil { return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } func request_FlowCombination_RpcBodyStream_3(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcBodyStreamClient, runtime.ServerMetadata, error) { var ( protoReq NonEmptyProto metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.C); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["a"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a") } protoReq.A, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a", err) } val, ok = pathParams["b"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "b") } protoReq.B, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "b", err) } stream, err := client.RpcBodyStream(ctx, &protoReq) if err != nil { return nil, metadata, err } header, err := stream.Header() if err != nil { return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } var filter_FlowCombination_RpcBodyStream_4 = &utilities.DoubleArray{Encoding: map[string]int{"c": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_FlowCombination_RpcBodyStream_4(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcBodyStreamClient, runtime.ServerMetadata, error) { var ( protoReq NonEmptyProto metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.C); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcBodyStream_4); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } stream, err := client.RpcBodyStream(ctx, &protoReq) if err != nil { return nil, metadata, err } header, err := stream.Header() if err != nil { return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } var filter_FlowCombination_RpcBodyStream_5 = &utilities.DoubleArray{Encoding: map[string]int{"c": 0, "a": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} func request_FlowCombination_RpcBodyStream_5(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcBodyStreamClient, runtime.ServerMetadata, error) { var ( protoReq NonEmptyProto metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.C); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["a"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a") } protoReq.A, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcBodyStream_5); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } stream, err := client.RpcBodyStream(ctx, &protoReq) if err != nil { return nil, metadata, err } header, err := stream.Header() if err != nil { return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } var filter_FlowCombination_RpcBodyStream_6 = &utilities.DoubleArray{Encoding: map[string]int{"a": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_FlowCombination_RpcBodyStream_6(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcBodyStreamClient, runtime.ServerMetadata, error) { var ( protoReq NonEmptyProto metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["a"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a") } protoReq.A, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcBodyStream_6); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } stream, err := client.RpcBodyStream(ctx, &protoReq) if err != nil { return nil, metadata, err } header, err := stream.Header() if err != nil { return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } var filter_FlowCombination_RpcPathSingleNestedStream_0 = &utilities.DoubleArray{Encoding: map[string]int{"a": 0, "str": 1}, Base: []int{1, 1, 1, 0}, Check: []int{0, 1, 2, 3}} func request_FlowCombination_RpcPathSingleNestedStream_0(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcPathSingleNestedStreamClient, runtime.ServerMetadata, error) { var ( protoReq SingleNestedProto metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["a.str"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") } err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a.str", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcPathSingleNestedStream_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } stream, err := client.RpcPathSingleNestedStream(ctx, &protoReq) if err != nil { return nil, metadata, err } header, err := stream.Header() if err != nil { return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } var filter_FlowCombination_RpcPathNestedStream_0 = &utilities.DoubleArray{Encoding: map[string]int{"c": 0, "a": 1, "str": 2, "b": 3}, Base: []int{1, 1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 1, 3, 1, 2, 4, 5}} func request_FlowCombination_RpcPathNestedStream_0(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcPathNestedStreamClient, runtime.ServerMetadata, error) { var ( protoReq NestedProto metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.C); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["a.str"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") } err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a.str", err) } val, ok = pathParams["b"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "b") } protoReq.B, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "b", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcPathNestedStream_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } stream, err := client.RpcPathNestedStream(ctx, &protoReq) if err != nil { return nil, metadata, err } header, err := stream.Header() if err != nil { return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } var filter_FlowCombination_RpcPathNestedStream_1 = &utilities.DoubleArray{Encoding: map[string]int{"a": 0, "str": 1}, Base: []int{1, 1, 1, 0}, Check: []int{0, 1, 2, 3}} func request_FlowCombination_RpcPathNestedStream_1(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcPathNestedStreamClient, runtime.ServerMetadata, error) { var ( protoReq NestedProto metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["a.str"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") } err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a.str", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcPathNestedStream_1); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } stream, err := client.RpcPathNestedStream(ctx, &protoReq) if err != nil { return nil, metadata, err } header, err := stream.Header() if err != nil { return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } var filter_FlowCombination_RpcPathNestedStream_2 = &utilities.DoubleArray{Encoding: map[string]int{"c": 0, "a": 1, "str": 2}, Base: []int{1, 1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 3, 2, 4}} func request_FlowCombination_RpcPathNestedStream_2(ctx context.Context, marshaler runtime.Marshaler, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcPathNestedStreamClient, runtime.ServerMetadata, error) { var ( protoReq NestedProto metadata runtime.ServerMetadata err error ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.C); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["a.str"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") } err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "a.str", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_FlowCombination_RpcPathNestedStream_2); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } stream, err := client.RpcPathNestedStream(ctx, &protoReq) if err != nil { return nil, metadata, err } header, err := stream.Header() if err != nil { return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } // RegisterFlowCombinationHandlerServer registers the http handlers for service FlowCombination to "mux". // UnaryRPC :call FlowCombinationServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterFlowCombinationHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterFlowCombinationHandlerServer(ctx context.Context, mux *runtime.ServeMux, server FlowCombinationServer) error { mux.Handle(http.MethodPost, pattern_FlowCombination_RpcEmptyRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcEmptyRpc", runtime.WithHTTPPathPattern("/rpc/empty/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_FlowCombination_RpcEmptyRpc_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcEmptyRpc_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcEmptyStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodPost, pattern_FlowCombination_StreamEmptyRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodPost, pattern_FlowCombination_StreamEmptyStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyRpc", runtime.WithHTTPPathPattern("/rpc/body/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_FlowCombination_RpcBodyRpc_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcBodyRpc_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyRpc_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyRpc", runtime.WithHTTPPathPattern("/rpc/path/{a}/{b}/{c}/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_FlowCombination_RpcBodyRpc_1(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcBodyRpc_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyRpc_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyRpc", runtime.WithHTTPPathPattern("/rpc/query/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_FlowCombination_RpcBodyRpc_2(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcBodyRpc_2(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyRpc_3, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyRpc", runtime.WithHTTPPathPattern("/rpc/body/path/{a}/{b}/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_FlowCombination_RpcBodyRpc_3(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcBodyRpc_3(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyRpc_4, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyRpc", runtime.WithHTTPPathPattern("/rpc/body/query/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_FlowCombination_RpcBodyRpc_4(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcBodyRpc_4(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyRpc_5, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyRpc", runtime.WithHTTPPathPattern("/rpc/body/path/{a}/query/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_FlowCombination_RpcBodyRpc_5(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcBodyRpc_5(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyRpc_6, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyRpc", runtime.WithHTTPPathPattern("/rpc/path/{a}/query/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_FlowCombination_RpcBodyRpc_6(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcBodyRpc_6(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcPathSingleNestedRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcPathSingleNestedRpc", runtime.WithHTTPPathPattern("/rpc/path-nested/{a.str}/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_FlowCombination_RpcPathSingleNestedRpc_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcPathSingleNestedRpc_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcPathNestedRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcPathNestedRpc", runtime.WithHTTPPathPattern("/rpc/path-nested/{a.str}/{b}/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_FlowCombination_RpcPathNestedRpc_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcPathNestedRpc_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcPathNestedRpc_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcPathNestedRpc", runtime.WithHTTPPathPattern("/rpc/path-nested1/{a.str}/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_FlowCombination_RpcPathNestedRpc_1(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcPathNestedRpc_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcPathNestedRpc_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcPathNestedRpc", runtime.WithHTTPPathPattern("/rpc/path-nested2/{a.str}/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_FlowCombination_RpcPathNestedRpc_2(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcPathNestedRpc_2(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyStream_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyStream_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyStream_3, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyStream_4, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyStream_5, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyStream_6, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcPathSingleNestedStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcPathNestedStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcPathNestedStream_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcPathNestedStream_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) return nil } // RegisterFlowCombinationHandlerFromEndpoint is same as RegisterFlowCombinationHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterFlowCombinationHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterFlowCombinationHandler(ctx, mux, conn) } // RegisterFlowCombinationHandler registers the http handlers for service FlowCombination to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterFlowCombinationHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterFlowCombinationHandlerClient(ctx, mux, NewFlowCombinationClient(conn)) } // RegisterFlowCombinationHandlerClient registers the http handlers for service FlowCombination // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "FlowCombinationClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "FlowCombinationClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "FlowCombinationClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterFlowCombinationHandlerClient(ctx context.Context, mux *runtime.ServeMux, client FlowCombinationClient) error { mux.Handle(http.MethodPost, pattern_FlowCombination_RpcEmptyRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcEmptyRpc", runtime.WithHTTPPathPattern("/rpc/empty/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcEmptyRpc_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcEmptyRpc_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcEmptyStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcEmptyStream", runtime.WithHTTPPathPattern("/rpc/empty/stream")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcEmptyStream_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcEmptyStream_0(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_StreamEmptyRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/StreamEmptyRpc", runtime.WithHTTPPathPattern("/stream/empty/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_StreamEmptyRpc_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_StreamEmptyRpc_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_StreamEmptyStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/StreamEmptyStream", runtime.WithHTTPPathPattern("/stream/empty/stream")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_StreamEmptyStream_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_StreamEmptyStream_0(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyRpc", runtime.WithHTTPPathPattern("/rpc/body/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcBodyRpc_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcBodyRpc_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyRpc_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyRpc", runtime.WithHTTPPathPattern("/rpc/path/{a}/{b}/{c}/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcBodyRpc_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcBodyRpc_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyRpc_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyRpc", runtime.WithHTTPPathPattern("/rpc/query/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcBodyRpc_2(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcBodyRpc_2(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyRpc_3, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyRpc", runtime.WithHTTPPathPattern("/rpc/body/path/{a}/{b}/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcBodyRpc_3(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcBodyRpc_3(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyRpc_4, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyRpc", runtime.WithHTTPPathPattern("/rpc/body/query/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcBodyRpc_4(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcBodyRpc_4(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyRpc_5, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyRpc", runtime.WithHTTPPathPattern("/rpc/body/path/{a}/query/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcBodyRpc_5(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcBodyRpc_5(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyRpc_6, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyRpc", runtime.WithHTTPPathPattern("/rpc/path/{a}/query/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcBodyRpc_6(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcBodyRpc_6(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcPathSingleNestedRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcPathSingleNestedRpc", runtime.WithHTTPPathPattern("/rpc/path-nested/{a.str}/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcPathSingleNestedRpc_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcPathSingleNestedRpc_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcPathNestedRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcPathNestedRpc", runtime.WithHTTPPathPattern("/rpc/path-nested/{a.str}/{b}/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcPathNestedRpc_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcPathNestedRpc_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcPathNestedRpc_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcPathNestedRpc", runtime.WithHTTPPathPattern("/rpc/path-nested1/{a.str}/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcPathNestedRpc_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcPathNestedRpc_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcPathNestedRpc_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcPathNestedRpc", runtime.WithHTTPPathPattern("/rpc/path-nested2/{a.str}/rpc")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcPathNestedRpc_2(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcPathNestedRpc_2(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyStream", runtime.WithHTTPPathPattern("/rpc/body/stream")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcBodyStream_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcBodyStream_0(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyStream_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyStream", runtime.WithHTTPPathPattern("/rpc/path/{a}/{b}/{c}/stream")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcBodyStream_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcBodyStream_1(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyStream_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyStream", runtime.WithHTTPPathPattern("/rpc/query/stream")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcBodyStream_2(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcBodyStream_2(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyStream_3, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyStream", runtime.WithHTTPPathPattern("/rpc/body/path/{a}/{b}/stream")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcBodyStream_3(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcBodyStream_3(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyStream_4, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyStream", runtime.WithHTTPPathPattern("/rpc/body/query/stream")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcBodyStream_4(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcBodyStream_4(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyStream_5, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyStream", runtime.WithHTTPPathPattern("/rpc/body/path/{a}/query/stream")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcBodyStream_5(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcBodyStream_5(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcBodyStream_6, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyStream", runtime.WithHTTPPathPattern("/rpc/path/{a}/query/stream")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcBodyStream_6(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcBodyStream_6(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcPathSingleNestedStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcPathSingleNestedStream", runtime.WithHTTPPathPattern("/rpc/path-nested/{a.str}/stream")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcPathSingleNestedStream_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcPathSingleNestedStream_0(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcPathNestedStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcPathNestedStream", runtime.WithHTTPPathPattern("/rpc/path-nested/{a.str}/{b}/stream")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcPathNestedStream_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcPathNestedStream_0(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcPathNestedStream_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcPathNestedStream", runtime.WithHTTPPathPattern("/rpc/path-nested1/{a.str}/stream")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcPathNestedStream_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcPathNestedStream_1(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_FlowCombination_RpcPathNestedStream_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcPathNestedStream", runtime.WithHTTPPathPattern("/rpc/path-nested2/{a.str}/stream")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FlowCombination_RpcPathNestedStream_2(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FlowCombination_RpcPathNestedStream_2(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_FlowCombination_RpcEmptyRpc_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 0}, []string{"rpc", "empty"}, "")) pattern_FlowCombination_RpcEmptyStream_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"rpc", "empty", "stream"}, "")) pattern_FlowCombination_StreamEmptyRpc_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"stream", "empty", "rpc"}, "")) pattern_FlowCombination_StreamEmptyStream_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 0}, []string{"stream", "empty"}, "")) pattern_FlowCombination_RpcBodyRpc_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 0}, []string{"rpc", "body"}, "")) pattern_FlowCombination_RpcBodyRpc_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 2, 0}, []string{"rpc", "path", "a", "b", "c"}, "")) pattern_FlowCombination_RpcBodyRpc_2 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 0}, []string{"rpc", "query"}, "")) pattern_FlowCombination_RpcBodyRpc_3 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 2, 0}, []string{"rpc", "body", "path", "a", "b"}, "")) pattern_FlowCombination_RpcBodyRpc_4 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 0}, []string{"rpc", "body", "query"}, "")) pattern_FlowCombination_RpcBodyRpc_5 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 2, 0}, []string{"rpc", "body", "path", "a", "query"}, "")) pattern_FlowCombination_RpcBodyRpc_6 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 2, 0}, []string{"rpc", "path", "a", "query"}, "")) pattern_FlowCombination_RpcPathSingleNestedRpc_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 0}, []string{"rpc", "path-nested", "a.str"}, "")) pattern_FlowCombination_RpcPathNestedRpc_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 1, 0, 4, 1, 5, 3, 2, 0}, []string{"rpc", "path-nested", "a.str", "b"}, "")) pattern_FlowCombination_RpcPathNestedRpc_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 0}, []string{"rpc", "path-nested1", "a.str"}, "")) pattern_FlowCombination_RpcPathNestedRpc_2 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 0}, []string{"rpc", "path-nested2", "a.str"}, "")) pattern_FlowCombination_RpcBodyStream_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"rpc", "body", "stream"}, "")) pattern_FlowCombination_RpcBodyStream_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"rpc", "path", "a", "b", "c", "stream"}, "")) pattern_FlowCombination_RpcBodyStream_2 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"rpc", "query", "stream"}, "")) pattern_FlowCombination_RpcBodyStream_3 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"rpc", "body", "path", "a", "b", "stream"}, "")) pattern_FlowCombination_RpcBodyStream_4 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"rpc", "body", "query", "stream"}, "")) pattern_FlowCombination_RpcBodyStream_5 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 2, 5}, []string{"rpc", "body", "path", "a", "query", "stream"}, "")) pattern_FlowCombination_RpcBodyStream_6 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 2, 4}, []string{"rpc", "path", "a", "query", "stream"}, "")) pattern_FlowCombination_RpcPathSingleNestedStream_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"rpc", "path-nested", "a.str", "stream"}, "")) pattern_FlowCombination_RpcPathNestedStream_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"rpc", "path-nested", "a.str", "b", "stream"}, "")) pattern_FlowCombination_RpcPathNestedStream_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"rpc", "path-nested1", "a.str", "stream"}, "")) pattern_FlowCombination_RpcPathNestedStream_2 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"rpc", "path-nested2", "a.str", "stream"}, "")) ) var ( forward_FlowCombination_RpcEmptyRpc_0 = runtime.ForwardResponseMessage forward_FlowCombination_RpcEmptyStream_0 = runtime.ForwardResponseStream forward_FlowCombination_StreamEmptyRpc_0 = runtime.ForwardResponseMessage forward_FlowCombination_StreamEmptyStream_0 = runtime.ForwardResponseStream forward_FlowCombination_RpcBodyRpc_0 = runtime.ForwardResponseMessage forward_FlowCombination_RpcBodyRpc_1 = runtime.ForwardResponseMessage forward_FlowCombination_RpcBodyRpc_2 = runtime.ForwardResponseMessage forward_FlowCombination_RpcBodyRpc_3 = runtime.ForwardResponseMessage forward_FlowCombination_RpcBodyRpc_4 = runtime.ForwardResponseMessage forward_FlowCombination_RpcBodyRpc_5 = runtime.ForwardResponseMessage forward_FlowCombination_RpcBodyRpc_6 = runtime.ForwardResponseMessage forward_FlowCombination_RpcPathSingleNestedRpc_0 = runtime.ForwardResponseMessage forward_FlowCombination_RpcPathNestedRpc_0 = runtime.ForwardResponseMessage forward_FlowCombination_RpcPathNestedRpc_1 = runtime.ForwardResponseMessage forward_FlowCombination_RpcPathNestedRpc_2 = runtime.ForwardResponseMessage forward_FlowCombination_RpcBodyStream_0 = runtime.ForwardResponseStream forward_FlowCombination_RpcBodyStream_1 = runtime.ForwardResponseStream forward_FlowCombination_RpcBodyStream_2 = runtime.ForwardResponseStream forward_FlowCombination_RpcBodyStream_3 = runtime.ForwardResponseStream forward_FlowCombination_RpcBodyStream_4 = runtime.ForwardResponseStream forward_FlowCombination_RpcBodyStream_5 = runtime.ForwardResponseStream forward_FlowCombination_RpcBodyStream_6 = runtime.ForwardResponseStream forward_FlowCombination_RpcPathSingleNestedStream_0 = runtime.ForwardResponseStream forward_FlowCombination_RpcPathNestedStream_0 = runtime.ForwardResponseStream forward_FlowCombination_RpcPathNestedStream_1 = runtime.ForwardResponseStream forward_FlowCombination_RpcPathNestedStream_2 = runtime.ForwardResponseStream ) ================================================ FILE: examples/internal/proto/examplepb/flow_combination.proto ================================================ syntax = "proto3"; package grpc.gateway.examples.internal.proto.examplepb; import "google/api/annotations.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; message EmptyProto {} message NonEmptyProto { string a = 1; string b = 2; string c = 3; } message UnaryProto { string str = 1; } message NestedProto { UnaryProto a = 1; string b = 2; string c = 3; } message SingleNestedProto { UnaryProto a = 1; } service FlowCombination { rpc RpcEmptyRpc(EmptyProto) returns (EmptyProto) { option (google.api.http) = {post: "/rpc/empty/rpc"}; } rpc RpcEmptyStream(EmptyProto) returns (stream EmptyProto) { option (google.api.http) = {post: "/rpc/empty/stream"}; } rpc StreamEmptyRpc(stream EmptyProto) returns (EmptyProto) { option (google.api.http) = {post: "/stream/empty/rpc"}; } rpc StreamEmptyStream(stream EmptyProto) returns (stream EmptyProto) { option (google.api.http) = {post: "/stream/empty/stream"}; } rpc RpcBodyRpc(NonEmptyProto) returns (EmptyProto) { option (google.api.http) = { // w/ body; w/o path; w/o query post: "/rpc/body/rpc" body: "*" // w/o body; w/ path; w/o query additional_bindings: {post: "/rpc/path/{a}/{b}/{c}/rpc"} // w/o body; w/o path; w/ query additional_bindings: {post: "/rpc/query/rpc"} // w/ body; w/ path; w/o query additional_bindings: { post: "/rpc/body/path/{a}/{b}/rpc" body: "c" } // w/ body; w/o path; w/ query additional_bindings: { post: "/rpc/body/query/rpc" body: "c" } // w/ body; w/ path; w/ query additional_bindings: { post: "/rpc/body/path/{a}/query/rpc" body: "c" } // w/o body; w/ path; w/ query additional_bindings: {post: "/rpc/path/{a}/query/rpc"} }; } rpc RpcPathSingleNestedRpc(SingleNestedProto) returns (EmptyProto) { option (google.api.http) = { // w/o body; w/ path (IsNestedProto3); w/o query post: "/rpc/path-nested/{a.str}/rpc" }; } rpc RpcPathNestedRpc(NestedProto) returns (EmptyProto) { option (google.api.http) = { // w/ body; w/ path (IsNestedProto3); w/o query post: "/rpc/path-nested/{a.str}/{b}/rpc" body: "c" // w/o body; w/ path (IsNestedProto3); w/ query additional_bindings: {post: "/rpc/path-nested1/{a.str}/rpc"} // w/ body; w/ path (IsNestedProto3); w/ query additional_bindings: { post: "/rpc/path-nested2/{a.str}/rpc" body: "c" } }; } rpc RpcBodyStream(NonEmptyProto) returns (stream EmptyProto) { option (google.api.http) = { // w/ body; w/o path; w/o query post: "/rpc/body/stream" body: "*" // w/o body; w/ path; w/o query additional_bindings: {post: "/rpc/path/{a}/{b}/{c}/stream"} // w/o body; w/o path; w/ query additional_bindings: {post: "/rpc/query/stream"} // w/ body; w/ path; w/o query additional_bindings: { post: "/rpc/body/path/{a}/{b}/stream" body: "c" } // w/ body; w/o path; w/ query additional_bindings: { post: "/rpc/body/query/stream" body: "c" } // w/ body; w/ path; w/ query additional_bindings: { post: "/rpc/body/path/{a}/query/stream" body: "c" } // w/o body; w/ path; w/ query additional_bindings: {post: "/rpc/path/{a}/query/stream"} }; } rpc RpcPathSingleNestedStream(SingleNestedProto) returns (stream EmptyProto) { option (google.api.http) = { // w/o body; w/ path (IsNestedProto3); w/o query post: "/rpc/path-nested/{a.str}/stream" }; } rpc RpcPathNestedStream(NestedProto) returns (stream EmptyProto) { option (google.api.http) = { // w/ body; w/ path (IsNestedProto3); w/o query post: "/rpc/path-nested/{a.str}/{b}/stream" body: "c" // w/o body; w/ path (IsNestedProto3); w/ query additional_bindings: {post: "/rpc/path-nested1/{a.str}/stream"} // w/ body; w/ path (IsNestedProto3); w/ query additional_bindings: { post: "/rpc/path-nested2/{a.str}/stream" body: "c" } }; } } ================================================ FILE: examples/internal/proto/examplepb/flow_combination.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/examplepb/flow_combination.proto", "version": "version not set" }, "tags": [ { "name": "FlowCombination" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/rpc/body/path/{a}/query/rpc": { "post": { "operationId": "FlowCombination_RpcBodyRpc6", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "a", "in": "path", "required": true, "type": "string" }, { "name": "c", "in": "body", "required": true, "schema": { "type": "string" } }, { "name": "b", "in": "query", "required": false, "type": "string" } ], "tags": [ "FlowCombination" ] } }, "/rpc/body/path/{a}/query/stream": { "post": { "operationId": "FlowCombination_RpcBodyStream6", "responses": { "200": { "description": "A successful response.(streaming responses)", "schema": { "type": "object", "properties": { "result": { "$ref": "#/definitions/examplepbEmptyProto" }, "error": { "$ref": "#/definitions/googleRpcStatus" } }, "title": "Stream result of examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "a", "in": "path", "required": true, "type": "string" }, { "name": "c", "in": "body", "required": true, "schema": { "type": "string" } }, { "name": "b", "in": "query", "required": false, "type": "string" } ], "tags": [ "FlowCombination" ] } }, "/rpc/body/path/{a}/{b}/rpc": { "post": { "operationId": "FlowCombination_RpcBodyRpc4", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "a", "in": "path", "required": true, "type": "string" }, { "name": "b", "in": "path", "required": true, "type": "string" }, { "name": "c", "in": "body", "required": true, "schema": { "type": "string" } } ], "tags": [ "FlowCombination" ] } }, "/rpc/body/path/{a}/{b}/stream": { "post": { "operationId": "FlowCombination_RpcBodyStream4", "responses": { "200": { "description": "A successful response.(streaming responses)", "schema": { "type": "object", "properties": { "result": { "$ref": "#/definitions/examplepbEmptyProto" }, "error": { "$ref": "#/definitions/googleRpcStatus" } }, "title": "Stream result of examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "a", "in": "path", "required": true, "type": "string" }, { "name": "b", "in": "path", "required": true, "type": "string" }, { "name": "c", "in": "body", "required": true, "schema": { "type": "string" } } ], "tags": [ "FlowCombination" ] } }, "/rpc/body/query/rpc": { "post": { "operationId": "FlowCombination_RpcBodyRpc5", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "c", "in": "body", "required": true, "schema": { "type": "string" } }, { "name": "a", "in": "query", "required": false, "type": "string" }, { "name": "b", "in": "query", "required": false, "type": "string" } ], "tags": [ "FlowCombination" ] } }, "/rpc/body/query/stream": { "post": { "operationId": "FlowCombination_RpcBodyStream5", "responses": { "200": { "description": "A successful response.(streaming responses)", "schema": { "type": "object", "properties": { "result": { "$ref": "#/definitions/examplepbEmptyProto" }, "error": { "$ref": "#/definitions/googleRpcStatus" } }, "title": "Stream result of examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "c", "in": "body", "required": true, "schema": { "type": "string" } }, { "name": "a", "in": "query", "required": false, "type": "string" }, { "name": "b", "in": "query", "required": false, "type": "string" } ], "tags": [ "FlowCombination" ] } }, "/rpc/body/rpc": { "post": { "operationId": "FlowCombination_RpcBodyRpc", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbNonEmptyProto" } } ], "tags": [ "FlowCombination" ] } }, "/rpc/body/stream": { "post": { "operationId": "FlowCombination_RpcBodyStream", "responses": { "200": { "description": "A successful response.(streaming responses)", "schema": { "type": "object", "properties": { "result": { "$ref": "#/definitions/examplepbEmptyProto" }, "error": { "$ref": "#/definitions/googleRpcStatus" } }, "title": "Stream result of examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbNonEmptyProto" } } ], "tags": [ "FlowCombination" ] } }, "/rpc/empty/rpc": { "post": { "operationId": "FlowCombination_RpcEmptyRpc", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "tags": [ "FlowCombination" ] } }, "/rpc/empty/stream": { "post": { "operationId": "FlowCombination_RpcEmptyStream", "responses": { "200": { "description": "A successful response.(streaming responses)", "schema": { "type": "object", "properties": { "result": { "$ref": "#/definitions/examplepbEmptyProto" }, "error": { "$ref": "#/definitions/googleRpcStatus" } }, "title": "Stream result of examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "tags": [ "FlowCombination" ] } }, "/rpc/path-nested/{a.str}/rpc": { "post": { "operationId": "FlowCombination_RpcPathSingleNestedRpc", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "a.str", "in": "path", "required": true, "type": "string" } ], "tags": [ "FlowCombination" ] } }, "/rpc/path-nested/{a.str}/stream": { "post": { "operationId": "FlowCombination_RpcPathSingleNestedStream", "responses": { "200": { "description": "A successful response.(streaming responses)", "schema": { "type": "object", "properties": { "result": { "$ref": "#/definitions/examplepbEmptyProto" }, "error": { "$ref": "#/definitions/googleRpcStatus" } }, "title": "Stream result of examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "a.str", "in": "path", "required": true, "type": "string" } ], "tags": [ "FlowCombination" ] } }, "/rpc/path-nested/{a.str}/{b}/rpc": { "post": { "operationId": "FlowCombination_RpcPathNestedRpc", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "a.str", "in": "path", "required": true, "type": "string" }, { "name": "b", "in": "path", "required": true, "type": "string" }, { "name": "c", "in": "body", "required": true, "schema": { "type": "string" } } ], "tags": [ "FlowCombination" ] } }, "/rpc/path-nested/{a.str}/{b}/stream": { "post": { "operationId": "FlowCombination_RpcPathNestedStream", "responses": { "200": { "description": "A successful response.(streaming responses)", "schema": { "type": "object", "properties": { "result": { "$ref": "#/definitions/examplepbEmptyProto" }, "error": { "$ref": "#/definitions/googleRpcStatus" } }, "title": "Stream result of examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "a.str", "in": "path", "required": true, "type": "string" }, { "name": "b", "in": "path", "required": true, "type": "string" }, { "name": "c", "in": "body", "required": true, "schema": { "type": "string" } } ], "tags": [ "FlowCombination" ] } }, "/rpc/path-nested1/{a.str}/rpc": { "post": { "operationId": "FlowCombination_RpcPathNestedRpc2", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "a.str", "in": "path", "required": true, "type": "string" }, { "name": "b", "in": "query", "required": false, "type": "string" }, { "name": "c", "in": "query", "required": false, "type": "string" } ], "tags": [ "FlowCombination" ] } }, "/rpc/path-nested1/{a.str}/stream": { "post": { "operationId": "FlowCombination_RpcPathNestedStream2", "responses": { "200": { "description": "A successful response.(streaming responses)", "schema": { "type": "object", "properties": { "result": { "$ref": "#/definitions/examplepbEmptyProto" }, "error": { "$ref": "#/definitions/googleRpcStatus" } }, "title": "Stream result of examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "a.str", "in": "path", "required": true, "type": "string" }, { "name": "b", "in": "query", "required": false, "type": "string" }, { "name": "c", "in": "query", "required": false, "type": "string" } ], "tags": [ "FlowCombination" ] } }, "/rpc/path-nested2/{a.str}/rpc": { "post": { "operationId": "FlowCombination_RpcPathNestedRpc3", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "a.str", "in": "path", "required": true, "type": "string" }, { "name": "c", "in": "body", "required": true, "schema": { "type": "string" } }, { "name": "b", "in": "query", "required": false, "type": "string" } ], "tags": [ "FlowCombination" ] } }, "/rpc/path-nested2/{a.str}/stream": { "post": { "operationId": "FlowCombination_RpcPathNestedStream3", "responses": { "200": { "description": "A successful response.(streaming responses)", "schema": { "type": "object", "properties": { "result": { "$ref": "#/definitions/examplepbEmptyProto" }, "error": { "$ref": "#/definitions/googleRpcStatus" } }, "title": "Stream result of examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "a.str", "in": "path", "required": true, "type": "string" }, { "name": "c", "in": "body", "required": true, "schema": { "type": "string" } }, { "name": "b", "in": "query", "required": false, "type": "string" } ], "tags": [ "FlowCombination" ] } }, "/rpc/path/{a}/query/rpc": { "post": { "operationId": "FlowCombination_RpcBodyRpc7", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "a", "in": "path", "required": true, "type": "string" }, { "name": "b", "in": "query", "required": false, "type": "string" }, { "name": "c", "in": "query", "required": false, "type": "string" } ], "tags": [ "FlowCombination" ] } }, "/rpc/path/{a}/query/stream": { "post": { "operationId": "FlowCombination_RpcBodyStream7", "responses": { "200": { "description": "A successful response.(streaming responses)", "schema": { "type": "object", "properties": { "result": { "$ref": "#/definitions/examplepbEmptyProto" }, "error": { "$ref": "#/definitions/googleRpcStatus" } }, "title": "Stream result of examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "a", "in": "path", "required": true, "type": "string" }, { "name": "b", "in": "query", "required": false, "type": "string" }, { "name": "c", "in": "query", "required": false, "type": "string" } ], "tags": [ "FlowCombination" ] } }, "/rpc/path/{a}/{b}/{c}/rpc": { "post": { "operationId": "FlowCombination_RpcBodyRpc2", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "a", "in": "path", "required": true, "type": "string" }, { "name": "b", "in": "path", "required": true, "type": "string" }, { "name": "c", "in": "path", "required": true, "type": "string" } ], "tags": [ "FlowCombination" ] } }, "/rpc/path/{a}/{b}/{c}/stream": { "post": { "operationId": "FlowCombination_RpcBodyStream2", "responses": { "200": { "description": "A successful response.(streaming responses)", "schema": { "type": "object", "properties": { "result": { "$ref": "#/definitions/examplepbEmptyProto" }, "error": { "$ref": "#/definitions/googleRpcStatus" } }, "title": "Stream result of examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "a", "in": "path", "required": true, "type": "string" }, { "name": "b", "in": "path", "required": true, "type": "string" }, { "name": "c", "in": "path", "required": true, "type": "string" } ], "tags": [ "FlowCombination" ] } }, "/rpc/query/rpc": { "post": { "operationId": "FlowCombination_RpcBodyRpc3", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "a", "in": "query", "required": false, "type": "string" }, { "name": "b", "in": "query", "required": false, "type": "string" }, { "name": "c", "in": "query", "required": false, "type": "string" } ], "tags": [ "FlowCombination" ] } }, "/rpc/query/stream": { "post": { "operationId": "FlowCombination_RpcBodyStream3", "responses": { "200": { "description": "A successful response.(streaming responses)", "schema": { "type": "object", "properties": { "result": { "$ref": "#/definitions/examplepbEmptyProto" }, "error": { "$ref": "#/definitions/googleRpcStatus" } }, "title": "Stream result of examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "a", "in": "query", "required": false, "type": "string" }, { "name": "b", "in": "query", "required": false, "type": "string" }, { "name": "c", "in": "query", "required": false, "type": "string" } ], "tags": [ "FlowCombination" ] } }, "/stream/empty/rpc": { "post": { "operationId": "FlowCombination_StreamEmptyRpc", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "tags": [ "FlowCombination" ] } }, "/stream/empty/stream": { "post": { "operationId": "FlowCombination_StreamEmptyStream", "responses": { "200": { "description": "A successful response.(streaming responses)", "schema": { "type": "object", "properties": { "result": { "$ref": "#/definitions/examplepbEmptyProto" }, "error": { "$ref": "#/definitions/googleRpcStatus" } }, "title": "Stream result of examplepbEmptyProto" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "tags": [ "FlowCombination" ] } } }, "definitions": { "examplepbEmptyProto": { "type": "object" }, "examplepbNonEmptyProto": { "type": "object", "properties": { "a": { "type": "string" }, "b": { "type": "string" }, "c": { "type": "string" } } }, "examplepbUnaryProto": { "type": "object", "properties": { "str": { "type": "string" } } }, "googleRpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32", "description": "The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]." }, "message": { "type": "string", "description": "A developer-facing error message, which should be in English. Any\nuser-facing error message should be localized and sent in the\n[google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client." }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" }, "description": "A list of messages that carry the error details. There is a common set of\nmessage types for APIs to use." } }, "description": "The `Status` type defines a logical error model that is suitable for\ndifferent programming environments, including REST APIs and RPC APIs. It is\nused by [gRPC](https://github.com/grpc). Each `Status` message contains\nthree pieces of data: error code, error message, and error details.\n\nYou can find out more about this error model and how to work with it in the\n[API Design Guide](https://cloud.google.com/apis/design/errors)." }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string", "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics." } }, "additionalProperties": {}, "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }" } } } ================================================ FILE: examples/internal/proto/examplepb/flow_combination_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: examples/internal/proto/examplepb/flow_combination.proto package examplepb import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( FlowCombination_RpcEmptyRpc_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcEmptyRpc" FlowCombination_RpcEmptyStream_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcEmptyStream" FlowCombination_StreamEmptyRpc_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/StreamEmptyRpc" FlowCombination_StreamEmptyStream_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/StreamEmptyStream" FlowCombination_RpcBodyRpc_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyRpc" FlowCombination_RpcPathSingleNestedRpc_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcPathSingleNestedRpc" FlowCombination_RpcPathNestedRpc_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcPathNestedRpc" FlowCombination_RpcBodyStream_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcBodyStream" FlowCombination_RpcPathSingleNestedStream_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcPathSingleNestedStream" FlowCombination_RpcPathNestedStream_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.FlowCombination/RpcPathNestedStream" ) // FlowCombinationClient is the client API for FlowCombination service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type FlowCombinationClient interface { RpcEmptyRpc(ctx context.Context, in *EmptyProto, opts ...grpc.CallOption) (*EmptyProto, error) RpcEmptyStream(ctx context.Context, in *EmptyProto, opts ...grpc.CallOption) (grpc.ServerStreamingClient[EmptyProto], error) StreamEmptyRpc(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[EmptyProto, EmptyProto], error) StreamEmptyStream(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[EmptyProto, EmptyProto], error) RpcBodyRpc(ctx context.Context, in *NonEmptyProto, opts ...grpc.CallOption) (*EmptyProto, error) RpcPathSingleNestedRpc(ctx context.Context, in *SingleNestedProto, opts ...grpc.CallOption) (*EmptyProto, error) RpcPathNestedRpc(ctx context.Context, in *NestedProto, opts ...grpc.CallOption) (*EmptyProto, error) RpcBodyStream(ctx context.Context, in *NonEmptyProto, opts ...grpc.CallOption) (grpc.ServerStreamingClient[EmptyProto], error) RpcPathSingleNestedStream(ctx context.Context, in *SingleNestedProto, opts ...grpc.CallOption) (grpc.ServerStreamingClient[EmptyProto], error) RpcPathNestedStream(ctx context.Context, in *NestedProto, opts ...grpc.CallOption) (grpc.ServerStreamingClient[EmptyProto], error) } type flowCombinationClient struct { cc grpc.ClientConnInterface } func NewFlowCombinationClient(cc grpc.ClientConnInterface) FlowCombinationClient { return &flowCombinationClient{cc} } func (c *flowCombinationClient) RpcEmptyRpc(ctx context.Context, in *EmptyProto, opts ...grpc.CallOption) (*EmptyProto, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(EmptyProto) err := c.cc.Invoke(ctx, FlowCombination_RpcEmptyRpc_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *flowCombinationClient) RpcEmptyStream(ctx context.Context, in *EmptyProto, opts ...grpc.CallOption) (grpc.ServerStreamingClient[EmptyProto], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &FlowCombination_ServiceDesc.Streams[0], FlowCombination_RpcEmptyStream_FullMethodName, cOpts...) if err != nil { return nil, err } x := &grpc.GenericClientStream[EmptyProto, EmptyProto]{ClientStream: stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } if err := x.ClientStream.CloseSend(); err != nil { return nil, err } return x, nil } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type FlowCombination_RpcEmptyStreamClient = grpc.ServerStreamingClient[EmptyProto] func (c *flowCombinationClient) StreamEmptyRpc(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[EmptyProto, EmptyProto], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &FlowCombination_ServiceDesc.Streams[1], FlowCombination_StreamEmptyRpc_FullMethodName, cOpts...) if err != nil { return nil, err } x := &grpc.GenericClientStream[EmptyProto, EmptyProto]{ClientStream: stream} return x, nil } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type FlowCombination_StreamEmptyRpcClient = grpc.ClientStreamingClient[EmptyProto, EmptyProto] func (c *flowCombinationClient) StreamEmptyStream(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[EmptyProto, EmptyProto], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &FlowCombination_ServiceDesc.Streams[2], FlowCombination_StreamEmptyStream_FullMethodName, cOpts...) if err != nil { return nil, err } x := &grpc.GenericClientStream[EmptyProto, EmptyProto]{ClientStream: stream} return x, nil } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type FlowCombination_StreamEmptyStreamClient = grpc.BidiStreamingClient[EmptyProto, EmptyProto] func (c *flowCombinationClient) RpcBodyRpc(ctx context.Context, in *NonEmptyProto, opts ...grpc.CallOption) (*EmptyProto, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(EmptyProto) err := c.cc.Invoke(ctx, FlowCombination_RpcBodyRpc_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *flowCombinationClient) RpcPathSingleNestedRpc(ctx context.Context, in *SingleNestedProto, opts ...grpc.CallOption) (*EmptyProto, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(EmptyProto) err := c.cc.Invoke(ctx, FlowCombination_RpcPathSingleNestedRpc_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *flowCombinationClient) RpcPathNestedRpc(ctx context.Context, in *NestedProto, opts ...grpc.CallOption) (*EmptyProto, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(EmptyProto) err := c.cc.Invoke(ctx, FlowCombination_RpcPathNestedRpc_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *flowCombinationClient) RpcBodyStream(ctx context.Context, in *NonEmptyProto, opts ...grpc.CallOption) (grpc.ServerStreamingClient[EmptyProto], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &FlowCombination_ServiceDesc.Streams[3], FlowCombination_RpcBodyStream_FullMethodName, cOpts...) if err != nil { return nil, err } x := &grpc.GenericClientStream[NonEmptyProto, EmptyProto]{ClientStream: stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } if err := x.ClientStream.CloseSend(); err != nil { return nil, err } return x, nil } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type FlowCombination_RpcBodyStreamClient = grpc.ServerStreamingClient[EmptyProto] func (c *flowCombinationClient) RpcPathSingleNestedStream(ctx context.Context, in *SingleNestedProto, opts ...grpc.CallOption) (grpc.ServerStreamingClient[EmptyProto], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &FlowCombination_ServiceDesc.Streams[4], FlowCombination_RpcPathSingleNestedStream_FullMethodName, cOpts...) if err != nil { return nil, err } x := &grpc.GenericClientStream[SingleNestedProto, EmptyProto]{ClientStream: stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } if err := x.ClientStream.CloseSend(); err != nil { return nil, err } return x, nil } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type FlowCombination_RpcPathSingleNestedStreamClient = grpc.ServerStreamingClient[EmptyProto] func (c *flowCombinationClient) RpcPathNestedStream(ctx context.Context, in *NestedProto, opts ...grpc.CallOption) (grpc.ServerStreamingClient[EmptyProto], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &FlowCombination_ServiceDesc.Streams[5], FlowCombination_RpcPathNestedStream_FullMethodName, cOpts...) if err != nil { return nil, err } x := &grpc.GenericClientStream[NestedProto, EmptyProto]{ClientStream: stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } if err := x.ClientStream.CloseSend(); err != nil { return nil, err } return x, nil } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type FlowCombination_RpcPathNestedStreamClient = grpc.ServerStreamingClient[EmptyProto] // FlowCombinationServer is the server API for FlowCombination service. // All implementations should embed UnimplementedFlowCombinationServer // for forward compatibility. type FlowCombinationServer interface { RpcEmptyRpc(context.Context, *EmptyProto) (*EmptyProto, error) RpcEmptyStream(*EmptyProto, grpc.ServerStreamingServer[EmptyProto]) error StreamEmptyRpc(grpc.ClientStreamingServer[EmptyProto, EmptyProto]) error StreamEmptyStream(grpc.BidiStreamingServer[EmptyProto, EmptyProto]) error RpcBodyRpc(context.Context, *NonEmptyProto) (*EmptyProto, error) RpcPathSingleNestedRpc(context.Context, *SingleNestedProto) (*EmptyProto, error) RpcPathNestedRpc(context.Context, *NestedProto) (*EmptyProto, error) RpcBodyStream(*NonEmptyProto, grpc.ServerStreamingServer[EmptyProto]) error RpcPathSingleNestedStream(*SingleNestedProto, grpc.ServerStreamingServer[EmptyProto]) error RpcPathNestedStream(*NestedProto, grpc.ServerStreamingServer[EmptyProto]) error } // UnimplementedFlowCombinationServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedFlowCombinationServer struct{} func (UnimplementedFlowCombinationServer) RpcEmptyRpc(context.Context, *EmptyProto) (*EmptyProto, error) { return nil, status.Errorf(codes.Unimplemented, "method RpcEmptyRpc not implemented") } func (UnimplementedFlowCombinationServer) RpcEmptyStream(*EmptyProto, grpc.ServerStreamingServer[EmptyProto]) error { return status.Errorf(codes.Unimplemented, "method RpcEmptyStream not implemented") } func (UnimplementedFlowCombinationServer) StreamEmptyRpc(grpc.ClientStreamingServer[EmptyProto, EmptyProto]) error { return status.Errorf(codes.Unimplemented, "method StreamEmptyRpc not implemented") } func (UnimplementedFlowCombinationServer) StreamEmptyStream(grpc.BidiStreamingServer[EmptyProto, EmptyProto]) error { return status.Errorf(codes.Unimplemented, "method StreamEmptyStream not implemented") } func (UnimplementedFlowCombinationServer) RpcBodyRpc(context.Context, *NonEmptyProto) (*EmptyProto, error) { return nil, status.Errorf(codes.Unimplemented, "method RpcBodyRpc not implemented") } func (UnimplementedFlowCombinationServer) RpcPathSingleNestedRpc(context.Context, *SingleNestedProto) (*EmptyProto, error) { return nil, status.Errorf(codes.Unimplemented, "method RpcPathSingleNestedRpc not implemented") } func (UnimplementedFlowCombinationServer) RpcPathNestedRpc(context.Context, *NestedProto) (*EmptyProto, error) { return nil, status.Errorf(codes.Unimplemented, "method RpcPathNestedRpc not implemented") } func (UnimplementedFlowCombinationServer) RpcBodyStream(*NonEmptyProto, grpc.ServerStreamingServer[EmptyProto]) error { return status.Errorf(codes.Unimplemented, "method RpcBodyStream not implemented") } func (UnimplementedFlowCombinationServer) RpcPathSingleNestedStream(*SingleNestedProto, grpc.ServerStreamingServer[EmptyProto]) error { return status.Errorf(codes.Unimplemented, "method RpcPathSingleNestedStream not implemented") } func (UnimplementedFlowCombinationServer) RpcPathNestedStream(*NestedProto, grpc.ServerStreamingServer[EmptyProto]) error { return status.Errorf(codes.Unimplemented, "method RpcPathNestedStream not implemented") } func (UnimplementedFlowCombinationServer) testEmbeddedByValue() {} // UnsafeFlowCombinationServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to FlowCombinationServer will // result in compilation errors. type UnsafeFlowCombinationServer interface { mustEmbedUnimplementedFlowCombinationServer() } func RegisterFlowCombinationServer(s grpc.ServiceRegistrar, srv FlowCombinationServer) { // If the following call pancis, it indicates UnimplementedFlowCombinationServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&FlowCombination_ServiceDesc, srv) } func _FlowCombination_RpcEmptyRpc_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(EmptyProto) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(FlowCombinationServer).RpcEmptyRpc(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: FlowCombination_RpcEmptyRpc_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(FlowCombinationServer).RpcEmptyRpc(ctx, req.(*EmptyProto)) } return interceptor(ctx, in, info, handler) } func _FlowCombination_RpcEmptyStream_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(EmptyProto) if err := stream.RecvMsg(m); err != nil { return err } return srv.(FlowCombinationServer).RpcEmptyStream(m, &grpc.GenericServerStream[EmptyProto, EmptyProto]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type FlowCombination_RpcEmptyStreamServer = grpc.ServerStreamingServer[EmptyProto] func _FlowCombination_StreamEmptyRpc_Handler(srv interface{}, stream grpc.ServerStream) error { return srv.(FlowCombinationServer).StreamEmptyRpc(&grpc.GenericServerStream[EmptyProto, EmptyProto]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type FlowCombination_StreamEmptyRpcServer = grpc.ClientStreamingServer[EmptyProto, EmptyProto] func _FlowCombination_StreamEmptyStream_Handler(srv interface{}, stream grpc.ServerStream) error { return srv.(FlowCombinationServer).StreamEmptyStream(&grpc.GenericServerStream[EmptyProto, EmptyProto]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type FlowCombination_StreamEmptyStreamServer = grpc.BidiStreamingServer[EmptyProto, EmptyProto] func _FlowCombination_RpcBodyRpc_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(NonEmptyProto) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(FlowCombinationServer).RpcBodyRpc(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: FlowCombination_RpcBodyRpc_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(FlowCombinationServer).RpcBodyRpc(ctx, req.(*NonEmptyProto)) } return interceptor(ctx, in, info, handler) } func _FlowCombination_RpcPathSingleNestedRpc_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SingleNestedProto) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(FlowCombinationServer).RpcPathSingleNestedRpc(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: FlowCombination_RpcPathSingleNestedRpc_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(FlowCombinationServer).RpcPathSingleNestedRpc(ctx, req.(*SingleNestedProto)) } return interceptor(ctx, in, info, handler) } func _FlowCombination_RpcPathNestedRpc_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(NestedProto) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(FlowCombinationServer).RpcPathNestedRpc(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: FlowCombination_RpcPathNestedRpc_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(FlowCombinationServer).RpcPathNestedRpc(ctx, req.(*NestedProto)) } return interceptor(ctx, in, info, handler) } func _FlowCombination_RpcBodyStream_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(NonEmptyProto) if err := stream.RecvMsg(m); err != nil { return err } return srv.(FlowCombinationServer).RpcBodyStream(m, &grpc.GenericServerStream[NonEmptyProto, EmptyProto]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type FlowCombination_RpcBodyStreamServer = grpc.ServerStreamingServer[EmptyProto] func _FlowCombination_RpcPathSingleNestedStream_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(SingleNestedProto) if err := stream.RecvMsg(m); err != nil { return err } return srv.(FlowCombinationServer).RpcPathSingleNestedStream(m, &grpc.GenericServerStream[SingleNestedProto, EmptyProto]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type FlowCombination_RpcPathSingleNestedStreamServer = grpc.ServerStreamingServer[EmptyProto] func _FlowCombination_RpcPathNestedStream_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(NestedProto) if err := stream.RecvMsg(m); err != nil { return err } return srv.(FlowCombinationServer).RpcPathNestedStream(m, &grpc.GenericServerStream[NestedProto, EmptyProto]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type FlowCombination_RpcPathNestedStreamServer = grpc.ServerStreamingServer[EmptyProto] // FlowCombination_ServiceDesc is the grpc.ServiceDesc for FlowCombination service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var FlowCombination_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.FlowCombination", HandlerType: (*FlowCombinationServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "RpcEmptyRpc", Handler: _FlowCombination_RpcEmptyRpc_Handler, }, { MethodName: "RpcBodyRpc", Handler: _FlowCombination_RpcBodyRpc_Handler, }, { MethodName: "RpcPathSingleNestedRpc", Handler: _FlowCombination_RpcPathSingleNestedRpc_Handler, }, { MethodName: "RpcPathNestedRpc", Handler: _FlowCombination_RpcPathNestedRpc_Handler, }, }, Streams: []grpc.StreamDesc{ { StreamName: "RpcEmptyStream", Handler: _FlowCombination_RpcEmptyStream_Handler, ServerStreams: true, }, { StreamName: "StreamEmptyRpc", Handler: _FlowCombination_StreamEmptyRpc_Handler, ClientStreams: true, }, { StreamName: "StreamEmptyStream", Handler: _FlowCombination_StreamEmptyStream_Handler, ServerStreams: true, ClientStreams: true, }, { StreamName: "RpcBodyStream", Handler: _FlowCombination_RpcBodyStream_Handler, ServerStreams: true, }, { StreamName: "RpcPathSingleNestedStream", Handler: _FlowCombination_RpcPathSingleNestedStream_Handler, ServerStreams: true, }, { StreamName: "RpcPathNestedStream", Handler: _FlowCombination_RpcPathNestedStream_Handler, ServerStreams: true, }, }, Metadata: "examples/internal/proto/examplepb/flow_combination.proto", } ================================================ FILE: examples/internal/proto/examplepb/generate_unbound_methods.buf.gen.yaml ================================================ version: v1 plugins: - plugin: grpc-gateway out: . opt: - paths=source_relative - generate_unbound_methods=true - plugin: openapiv2 out: . opt: - generate_unbound_methods=true ================================================ FILE: examples/internal/proto/examplepb/generate_unbound_methods.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/examplepb/generate_unbound_methods.proto // Generate Unannotated Methods Echo Service // Similar to echo_service.proto but without annotations and without external configuration. // // Generate Unannotated Methods Echo Service API consists of a single service which returns // a message. package examplepb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" durationpb "google.golang.org/protobuf/types/known/durationpb" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) // GenerateUnboundMethodsSimpleMessage represents a simple message sent to the unannotated GenerateUnboundMethodsEchoService service. type GenerateUnboundMethodsSimpleMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Id represents the message identifier. Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Num int64 `protobuf:"varint,2,opt,name=num,proto3" json:"num,omitempty"` Duration *durationpb.Duration `protobuf:"bytes,3,opt,name=duration,proto3" json:"duration,omitempty"` } func (x *GenerateUnboundMethodsSimpleMessage) Reset() { *x = GenerateUnboundMethodsSimpleMessage{} mi := &file_examples_internal_proto_examplepb_generate_unbound_methods_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *GenerateUnboundMethodsSimpleMessage) String() string { return protoimpl.X.MessageStringOf(x) } func (*GenerateUnboundMethodsSimpleMessage) ProtoMessage() {} func (x *GenerateUnboundMethodsSimpleMessage) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_generate_unbound_methods_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use GenerateUnboundMethodsSimpleMessage.ProtoReflect.Descriptor instead. func (*GenerateUnboundMethodsSimpleMessage) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_generate_unbound_methods_proto_rawDescGZIP(), []int{0} } func (x *GenerateUnboundMethodsSimpleMessage) GetId() string { if x != nil { return x.Id } return "" } func (x *GenerateUnboundMethodsSimpleMessage) GetNum() int64 { if x != nil { return x.Num } return 0 } func (x *GenerateUnboundMethodsSimpleMessage) GetDuration() *durationpb.Duration { if x != nil { return x.Duration } return nil } var File_examples_internal_proto_examplepb_generate_unbound_methods_proto protoreflect.FileDescriptor var file_examples_internal_proto_examplepb_generate_unbound_methods_proto_rawDesc = []byte{ 0x0a, 0x40, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x5f, 0x75, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x7e, 0x0a, 0x23, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x55, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6e, 0x75, 0x6d, 0x12, 0x35, 0x0a, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0xc6, 0x04, 0x0a, 0x21, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x55, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x45, 0x63, 0x68, 0x6f, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xb0, 0x01, 0x0a, 0x04, 0x45, 0x63, 0x68, 0x6f, 0x12, 0x53, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x55, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x53, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x55, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0xb4, 0x01, 0x0a, 0x08, 0x45, 0x63, 0x68, 0x6f, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x53, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x55, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x53, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x55, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0xb6, 0x01, 0x0a, 0x0a, 0x45, 0x63, 0x68, 0x6f, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x53, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x55, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x53, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x55, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_examplepb_generate_unbound_methods_proto_rawDescOnce sync.Once file_examples_internal_proto_examplepb_generate_unbound_methods_proto_rawDescData = file_examples_internal_proto_examplepb_generate_unbound_methods_proto_rawDesc ) func file_examples_internal_proto_examplepb_generate_unbound_methods_proto_rawDescGZIP() []byte { file_examples_internal_proto_examplepb_generate_unbound_methods_proto_rawDescOnce.Do(func() { file_examples_internal_proto_examplepb_generate_unbound_methods_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_examplepb_generate_unbound_methods_proto_rawDescData) }) return file_examples_internal_proto_examplepb_generate_unbound_methods_proto_rawDescData } var file_examples_internal_proto_examplepb_generate_unbound_methods_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_examples_internal_proto_examplepb_generate_unbound_methods_proto_goTypes = []any{ (*GenerateUnboundMethodsSimpleMessage)(nil), // 0: grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsSimpleMessage (*durationpb.Duration)(nil), // 1: google.protobuf.Duration } var file_examples_internal_proto_examplepb_generate_unbound_methods_proto_depIdxs = []int32{ 1, // 0: grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsSimpleMessage.duration:type_name -> google.protobuf.Duration 0, // 1: grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService.Echo:input_type -> grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsSimpleMessage 0, // 2: grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService.EchoBody:input_type -> grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsSimpleMessage 0, // 3: grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService.EchoDelete:input_type -> grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsSimpleMessage 0, // 4: grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService.Echo:output_type -> grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsSimpleMessage 0, // 5: grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService.EchoBody:output_type -> grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsSimpleMessage 0, // 6: grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService.EchoDelete:output_type -> grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsSimpleMessage 4, // [4:7] is the sub-list for method output_type 1, // [1:4] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension extendee 0, // [0:1] is the sub-list for field type_name } func init() { file_examples_internal_proto_examplepb_generate_unbound_methods_proto_init() } func file_examples_internal_proto_examplepb_generate_unbound_methods_proto_init() { if File_examples_internal_proto_examplepb_generate_unbound_methods_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_examplepb_generate_unbound_methods_proto_rawDesc, NumEnums: 0, NumMessages: 1, NumExtensions: 0, NumServices: 1, }, GoTypes: file_examples_internal_proto_examplepb_generate_unbound_methods_proto_goTypes, DependencyIndexes: file_examples_internal_proto_examplepb_generate_unbound_methods_proto_depIdxs, MessageInfos: file_examples_internal_proto_examplepb_generate_unbound_methods_proto_msgTypes, }.Build() File_examples_internal_proto_examplepb_generate_unbound_methods_proto = out.File file_examples_internal_proto_examplepb_generate_unbound_methods_proto_rawDesc = nil file_examples_internal_proto_examplepb_generate_unbound_methods_proto_goTypes = nil file_examples_internal_proto_examplepb_generate_unbound_methods_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/examplepb/generate_unbound_methods.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/proto/examplepb/generate_unbound_methods.proto /* Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package examplepb import ( "context" "errors" "io" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) func request_GenerateUnboundMethodsEchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, client GenerateUnboundMethodsEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq GenerateUnboundMethodsSimpleMessage metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_GenerateUnboundMethodsEchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, server GenerateUnboundMethodsEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq GenerateUnboundMethodsSimpleMessage metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Echo(ctx, &protoReq) return msg, metadata, err } func request_GenerateUnboundMethodsEchoService_EchoBody_0(ctx context.Context, marshaler runtime.Marshaler, client GenerateUnboundMethodsEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq GenerateUnboundMethodsSimpleMessage metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.EchoBody(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_GenerateUnboundMethodsEchoService_EchoBody_0(ctx context.Context, marshaler runtime.Marshaler, server GenerateUnboundMethodsEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq GenerateUnboundMethodsSimpleMessage metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.EchoBody(ctx, &protoReq) return msg, metadata, err } func request_GenerateUnboundMethodsEchoService_EchoDelete_0(ctx context.Context, marshaler runtime.Marshaler, client GenerateUnboundMethodsEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq GenerateUnboundMethodsSimpleMessage metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.EchoDelete(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_GenerateUnboundMethodsEchoService_EchoDelete_0(ctx context.Context, marshaler runtime.Marshaler, server GenerateUnboundMethodsEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq GenerateUnboundMethodsSimpleMessage metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.EchoDelete(ctx, &protoReq) return msg, metadata, err } // RegisterGenerateUnboundMethodsEchoServiceHandlerServer registers the http handlers for service GenerateUnboundMethodsEchoService to "mux". // UnaryRPC :call GenerateUnboundMethodsEchoServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterGenerateUnboundMethodsEchoServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterGenerateUnboundMethodsEchoServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server GenerateUnboundMethodsEchoServiceServer) error { mux.Handle(http.MethodPost, pattern_GenerateUnboundMethodsEchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/Echo", runtime.WithHTTPPathPattern("/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/Echo")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_GenerateUnboundMethodsEchoService_Echo_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_GenerateUnboundMethodsEchoService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_GenerateUnboundMethodsEchoService_EchoBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoBody", runtime.WithHTTPPathPattern("/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoBody")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_GenerateUnboundMethodsEchoService_EchoBody_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_GenerateUnboundMethodsEchoService_EchoBody_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_GenerateUnboundMethodsEchoService_EchoDelete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoDelete", runtime.WithHTTPPathPattern("/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoDelete")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_GenerateUnboundMethodsEchoService_EchoDelete_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_GenerateUnboundMethodsEchoService_EchoDelete_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } // RegisterGenerateUnboundMethodsEchoServiceHandlerFromEndpoint is same as RegisterGenerateUnboundMethodsEchoServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterGenerateUnboundMethodsEchoServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterGenerateUnboundMethodsEchoServiceHandler(ctx, mux, conn) } // RegisterGenerateUnboundMethodsEchoServiceHandler registers the http handlers for service GenerateUnboundMethodsEchoService to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterGenerateUnboundMethodsEchoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterGenerateUnboundMethodsEchoServiceHandlerClient(ctx, mux, NewGenerateUnboundMethodsEchoServiceClient(conn)) } // RegisterGenerateUnboundMethodsEchoServiceHandlerClient registers the http handlers for service GenerateUnboundMethodsEchoService // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "GenerateUnboundMethodsEchoServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "GenerateUnboundMethodsEchoServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "GenerateUnboundMethodsEchoServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterGenerateUnboundMethodsEchoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client GenerateUnboundMethodsEchoServiceClient) error { mux.Handle(http.MethodPost, pattern_GenerateUnboundMethodsEchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/Echo", runtime.WithHTTPPathPattern("/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/Echo")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_GenerateUnboundMethodsEchoService_Echo_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_GenerateUnboundMethodsEchoService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_GenerateUnboundMethodsEchoService_EchoBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoBody", runtime.WithHTTPPathPattern("/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoBody")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_GenerateUnboundMethodsEchoService_EchoBody_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_GenerateUnboundMethodsEchoService_EchoBody_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_GenerateUnboundMethodsEchoService_EchoDelete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoDelete", runtime.WithHTTPPathPattern("/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoDelete")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_GenerateUnboundMethodsEchoService_EchoDelete_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_GenerateUnboundMethodsEchoService_EchoDelete_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_GenerateUnboundMethodsEchoService_Echo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService", "Echo"}, "")) pattern_GenerateUnboundMethodsEchoService_EchoBody_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService", "EchoBody"}, "")) pattern_GenerateUnboundMethodsEchoService_EchoDelete_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService", "EchoDelete"}, "")) ) var ( forward_GenerateUnboundMethodsEchoService_Echo_0 = runtime.ForwardResponseMessage forward_GenerateUnboundMethodsEchoService_EchoBody_0 = runtime.ForwardResponseMessage forward_GenerateUnboundMethodsEchoService_EchoDelete_0 = runtime.ForwardResponseMessage ) ================================================ FILE: examples/internal/proto/examplepb/generate_unbound_methods.proto ================================================ syntax = "proto3"; // Generate Unannotated Methods Echo Service // Similar to echo_service.proto but without annotations and without external configuration. // // Generate Unannotated Methods Echo Service API consists of a single service which returns // a message. package grpc.gateway.examples.internal.proto.examplepb; // Do not need annotations.proto, can still use well known types as usual import "google/protobuf/duration.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; // GenerateUnboundMethodsSimpleMessage represents a simple message sent to the unannotated GenerateUnboundMethodsEchoService service. message GenerateUnboundMethodsSimpleMessage { // Id represents the message identifier. string id = 1; int64 num = 2; google.protobuf.Duration duration = 3; } // GenerateUnboundMethodsEchoService service responds to incoming echo requests. service GenerateUnboundMethodsEchoService { // Echo method receives a simple message and returns it. // // The message posted as the id parameter will also be // returned. rpc Echo(GenerateUnboundMethodsSimpleMessage) returns (GenerateUnboundMethodsSimpleMessage); // EchoBody method receives a simple message and returns it. rpc EchoBody(GenerateUnboundMethodsSimpleMessage) returns (GenerateUnboundMethodsSimpleMessage); // EchoDelete method receives a simple message and returns it. rpc EchoDelete(GenerateUnboundMethodsSimpleMessage) returns (GenerateUnboundMethodsSimpleMessage); } ================================================ FILE: examples/internal/proto/examplepb/generate_unbound_methods.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/examplepb/generate_unbound_methods.proto", "description": "Generate Unannotated Methods Echo Service\nSimilar to echo_service.proto but without annotations and without external configuration.\n\nGenerate Unannotated Methods Echo Service API consists of a single service which returns\na message.", "version": "version not set" }, "tags": [ { "name": "GenerateUnboundMethodsEchoService" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/Echo": { "post": { "summary": "Echo method receives a simple message and returns it.", "description": "The message posted as the id parameter will also be\nreturned.", "operationId": "GenerateUnboundMethodsEchoService_Echo", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "body", "description": "GenerateUnboundMethodsSimpleMessage represents a simple message sent to the unannotated GenerateUnboundMethodsEchoService service.", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage" } } ], "tags": [ "GenerateUnboundMethodsEchoService" ] } }, "/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoBody": { "post": { "summary": "EchoBody method receives a simple message and returns it.", "operationId": "GenerateUnboundMethodsEchoService_EchoBody", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "body", "description": "GenerateUnboundMethodsSimpleMessage represents a simple message sent to the unannotated GenerateUnboundMethodsEchoService service.", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage" } } ], "tags": [ "GenerateUnboundMethodsEchoService" ] } }, "/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoDelete": { "post": { "summary": "EchoDelete method receives a simple message and returns it.", "operationId": "GenerateUnboundMethodsEchoService_EchoDelete", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "body", "description": "GenerateUnboundMethodsSimpleMessage represents a simple message sent to the unannotated GenerateUnboundMethodsEchoService service.", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbGenerateUnboundMethodsSimpleMessage" } } ], "tags": [ "GenerateUnboundMethodsEchoService" ] } } }, "definitions": { "examplepbGenerateUnboundMethodsSimpleMessage": { "type": "object", "properties": { "id": { "type": "string", "description": "Id represents the message identifier." }, "num": { "type": "string", "format": "int64" }, "duration": { "type": "string" } }, "description": "GenerateUnboundMethodsSimpleMessage represents a simple message sent to the unannotated GenerateUnboundMethodsEchoService service." }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string" } }, "additionalProperties": {} }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } } } } ================================================ FILE: examples/internal/proto/examplepb/generate_unbound_methods_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: examples/internal/proto/examplepb/generate_unbound_methods.proto // Generate Unannotated Methods Echo Service // Similar to echo_service.proto but without annotations and without external configuration. // // Generate Unannotated Methods Echo Service API consists of a single service which returns // a message. package examplepb import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( GenerateUnboundMethodsEchoService_Echo_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/Echo" GenerateUnboundMethodsEchoService_EchoBody_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoBody" GenerateUnboundMethodsEchoService_EchoDelete_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService/EchoDelete" ) // GenerateUnboundMethodsEchoServiceClient is the client API for GenerateUnboundMethodsEchoService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // // GenerateUnboundMethodsEchoService service responds to incoming echo requests. type GenerateUnboundMethodsEchoServiceClient interface { // Echo method receives a simple message and returns it. // // The message posted as the id parameter will also be // returned. Echo(ctx context.Context, in *GenerateUnboundMethodsSimpleMessage, opts ...grpc.CallOption) (*GenerateUnboundMethodsSimpleMessage, error) // EchoBody method receives a simple message and returns it. EchoBody(ctx context.Context, in *GenerateUnboundMethodsSimpleMessage, opts ...grpc.CallOption) (*GenerateUnboundMethodsSimpleMessage, error) // EchoDelete method receives a simple message and returns it. EchoDelete(ctx context.Context, in *GenerateUnboundMethodsSimpleMessage, opts ...grpc.CallOption) (*GenerateUnboundMethodsSimpleMessage, error) } type generateUnboundMethodsEchoServiceClient struct { cc grpc.ClientConnInterface } func NewGenerateUnboundMethodsEchoServiceClient(cc grpc.ClientConnInterface) GenerateUnboundMethodsEchoServiceClient { return &generateUnboundMethodsEchoServiceClient{cc} } func (c *generateUnboundMethodsEchoServiceClient) Echo(ctx context.Context, in *GenerateUnboundMethodsSimpleMessage, opts ...grpc.CallOption) (*GenerateUnboundMethodsSimpleMessage, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(GenerateUnboundMethodsSimpleMessage) err := c.cc.Invoke(ctx, GenerateUnboundMethodsEchoService_Echo_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *generateUnboundMethodsEchoServiceClient) EchoBody(ctx context.Context, in *GenerateUnboundMethodsSimpleMessage, opts ...grpc.CallOption) (*GenerateUnboundMethodsSimpleMessage, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(GenerateUnboundMethodsSimpleMessage) err := c.cc.Invoke(ctx, GenerateUnboundMethodsEchoService_EchoBody_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *generateUnboundMethodsEchoServiceClient) EchoDelete(ctx context.Context, in *GenerateUnboundMethodsSimpleMessage, opts ...grpc.CallOption) (*GenerateUnboundMethodsSimpleMessage, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(GenerateUnboundMethodsSimpleMessage) err := c.cc.Invoke(ctx, GenerateUnboundMethodsEchoService_EchoDelete_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // GenerateUnboundMethodsEchoServiceServer is the server API for GenerateUnboundMethodsEchoService service. // All implementations should embed UnimplementedGenerateUnboundMethodsEchoServiceServer // for forward compatibility. // // GenerateUnboundMethodsEchoService service responds to incoming echo requests. type GenerateUnboundMethodsEchoServiceServer interface { // Echo method receives a simple message and returns it. // // The message posted as the id parameter will also be // returned. Echo(context.Context, *GenerateUnboundMethodsSimpleMessage) (*GenerateUnboundMethodsSimpleMessage, error) // EchoBody method receives a simple message and returns it. EchoBody(context.Context, *GenerateUnboundMethodsSimpleMessage) (*GenerateUnboundMethodsSimpleMessage, error) // EchoDelete method receives a simple message and returns it. EchoDelete(context.Context, *GenerateUnboundMethodsSimpleMessage) (*GenerateUnboundMethodsSimpleMessage, error) } // UnimplementedGenerateUnboundMethodsEchoServiceServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedGenerateUnboundMethodsEchoServiceServer struct{} func (UnimplementedGenerateUnboundMethodsEchoServiceServer) Echo(context.Context, *GenerateUnboundMethodsSimpleMessage) (*GenerateUnboundMethodsSimpleMessage, error) { return nil, status.Errorf(codes.Unimplemented, "method Echo not implemented") } func (UnimplementedGenerateUnboundMethodsEchoServiceServer) EchoBody(context.Context, *GenerateUnboundMethodsSimpleMessage) (*GenerateUnboundMethodsSimpleMessage, error) { return nil, status.Errorf(codes.Unimplemented, "method EchoBody not implemented") } func (UnimplementedGenerateUnboundMethodsEchoServiceServer) EchoDelete(context.Context, *GenerateUnboundMethodsSimpleMessage) (*GenerateUnboundMethodsSimpleMessage, error) { return nil, status.Errorf(codes.Unimplemented, "method EchoDelete not implemented") } func (UnimplementedGenerateUnboundMethodsEchoServiceServer) testEmbeddedByValue() {} // UnsafeGenerateUnboundMethodsEchoServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to GenerateUnboundMethodsEchoServiceServer will // result in compilation errors. type UnsafeGenerateUnboundMethodsEchoServiceServer interface { mustEmbedUnimplementedGenerateUnboundMethodsEchoServiceServer() } func RegisterGenerateUnboundMethodsEchoServiceServer(s grpc.ServiceRegistrar, srv GenerateUnboundMethodsEchoServiceServer) { // If the following call pancis, it indicates UnimplementedGenerateUnboundMethodsEchoServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&GenerateUnboundMethodsEchoService_ServiceDesc, srv) } func _GenerateUnboundMethodsEchoService_Echo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GenerateUnboundMethodsSimpleMessage) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(GenerateUnboundMethodsEchoServiceServer).Echo(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: GenerateUnboundMethodsEchoService_Echo_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(GenerateUnboundMethodsEchoServiceServer).Echo(ctx, req.(*GenerateUnboundMethodsSimpleMessage)) } return interceptor(ctx, in, info, handler) } func _GenerateUnboundMethodsEchoService_EchoBody_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GenerateUnboundMethodsSimpleMessage) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(GenerateUnboundMethodsEchoServiceServer).EchoBody(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: GenerateUnboundMethodsEchoService_EchoBody_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(GenerateUnboundMethodsEchoServiceServer).EchoBody(ctx, req.(*GenerateUnboundMethodsSimpleMessage)) } return interceptor(ctx, in, info, handler) } func _GenerateUnboundMethodsEchoService_EchoDelete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GenerateUnboundMethodsSimpleMessage) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(GenerateUnboundMethodsEchoServiceServer).EchoDelete(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: GenerateUnboundMethodsEchoService_EchoDelete_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(GenerateUnboundMethodsEchoServiceServer).EchoDelete(ctx, req.(*GenerateUnboundMethodsSimpleMessage)) } return interceptor(ctx, in, info, handler) } // GenerateUnboundMethodsEchoService_ServiceDesc is the grpc.ServiceDesc for GenerateUnboundMethodsEchoService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var GenerateUnboundMethodsEchoService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.GenerateUnboundMethodsEchoService", HandlerType: (*GenerateUnboundMethodsEchoServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Echo", Handler: _GenerateUnboundMethodsEchoService_Echo_Handler, }, { MethodName: "EchoBody", Handler: _GenerateUnboundMethodsEchoService_EchoBody_Handler, }, { MethodName: "EchoDelete", Handler: _GenerateUnboundMethodsEchoService_EchoDelete_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/internal/proto/examplepb/generate_unbound_methods.proto", } ================================================ FILE: examples/internal/proto/examplepb/generated_input.proto ================================================ syntax = "proto3"; package grpc.gateway.examples.internal.proto.examplepb; import "examples/internal/proto/examplepb/a_bit_of_everything.proto"; import "google/api/annotations.proto"; import "google/protobuf/empty.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; // This file is run through a genrule. // Defines some more operations to be added to ABitOfEverythingService service GeneratedService { rpc Create(ABitOfEverything) returns (google.protobuf.Empty) { option (google.api.http) = { post: "/v1/example/a_bit_of_everything/generated_create" body: "*" }; } } ================================================ FILE: examples/internal/proto/examplepb/generated_input.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/examplepb/generated_input.proto", "version": "version not set" }, "tags": [ { "name": "GeneratedService" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/v1/example/a_bit_of_everything/generated_create": { "post": { "operationId": "GeneratedService_Create", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "description": "Intentionally complicated message type to cover many features of Protobuf.", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbABitOfEverything" } } ], "tags": [ "GeneratedService" ] } } }, "definitions": { "ABitOfEverythingNested": { "type": "object", "example": { "ok": "TRUE" }, "properties": { "name": { "type": "string", "description": "name is nested field." }, "amount": { "type": "integer", "format": "int64" }, "ok": { "$ref": "#/definitions/NestedDeepEnum", "description": "DeepEnum description." } }, "description": "Nested is nested type." }, "MessagePathEnumNestedPathEnum": { "type": "string", "enum": [ "GHI", "JKL" ], "default": "GHI" }, "NestedDeepEnum": { "type": "string", "enum": [ "FALSE", "TRUE" ], "default": "FALSE", "description": "DeepEnum is one or zero.\n\n - FALSE: FALSE is false.\n - TRUE: TRUE is true." }, "examplepbABitOfEverything": { "type": "object", "example": { "int64_value": 12, "double_value": 12.3 }, "properties": { "singleNested": { "$ref": "#/definitions/ABitOfEverythingNested" }, "uuid": { "type": "string", "format": "uuid", "minLength": 1, "pattern": "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}", "x-internal": true }, "nested": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/ABitOfEverythingNested" } }, "floatValue": { "type": "number", "format": "float", "default": "0.2", "description": "Float value field" }, "doubleValue": { "type": "number", "format": "double" }, "int64Value": { "type": "string", "format": "int64" }, "uint64Value": { "type": "string", "format": "uint64" }, "int32Value": { "type": "integer", "format": "int32" }, "fixed64Value": { "type": "string", "format": "uint64" }, "fixed32Value": { "type": "integer", "format": "int64" }, "boolValue": { "type": "boolean" }, "stringValue": { "type": "string" }, "bytesValue": { "type": "string", "format": "byte" }, "uint32Value": { "type": "integer", "format": "int64" }, "enumValue": { "$ref": "#/definitions/examplepbNumericEnum" }, "pathEnumValue": { "$ref": "#/definitions/pathenumPathEnum" }, "nestedPathEnumValue": { "$ref": "#/definitions/MessagePathEnumNestedPathEnum" }, "sfixed32Value": { "type": "integer", "format": "int32" }, "sfixed64Value": { "type": "string", "format": "int64" }, "sint32Value": { "type": "integer", "format": "int32" }, "sint64Value": { "type": "string", "format": "int64" }, "repeatedStringValue": { "type": "array", "items": { "type": "string" } }, "oneofEmpty": { "type": "object", "properties": {} }, "oneofString": { "type": "string" }, "mapValue": { "type": "object", "additionalProperties": { "$ref": "#/definitions/examplepbNumericEnum" }, "title": "map of numeric enum" }, "mappedStringValue": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Map of string description.", "title": "Map of string title" }, "mappedNestedValue": { "type": "object", "additionalProperties": { "$ref": "#/definitions/ABitOfEverythingNested" } }, "nonConventionalNameValue": { "type": "string" }, "timestampValue": { "type": "string", "format": "date-time" }, "repeatedEnumValue": { "type": "array", "items": { "$ref": "#/definitions/examplepbNumericEnum" }, "title": "repeated enum value. it is comma-separated in query" }, "repeatedEnumAnnotation": { "type": "array", "items": { "$ref": "#/definitions/examplepbNumericEnum" }, "description": "Repeated numeric enum description.", "title": "Repeated numeric enum title" }, "enumValueAnnotation": { "$ref": "#/definitions/examplepbNumericEnum", "description": "Numeric enum description.", "title": "Numeric enum title" }, "repeatedStringAnnotation": { "type": "array", "items": { "type": "string" }, "description": "Repeated string description.", "title": "Repeated string title" }, "repeatedNestedAnnotation": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/ABitOfEverythingNested" }, "description": "Repeated nested object description.", "title": "Repeated nested object title" }, "nestedAnnotation": { "$ref": "#/definitions/ABitOfEverythingNested", "description": "Nested object description.", "title": "Nested object title" }, "int64OverrideType": { "type": "integer", "format": "int64" }, "requiredStringViaFieldBehaviorAnnotation": { "type": "string", "title": "mark a field as required in Open API definition" }, "outputOnlyStringViaFieldBehaviorAnnotation": { "type": "string", "title": "mark a field as readonly in Open API definition", "readOnly": true }, "optionalStringValue": { "type": "string" }, "productId": { "type": "array", "items": { "type": "string", "maxLength": 19, "minLength": 1, "pattern": "^[0-9]+$" }, "description": "Only digits are allowed.", "title": "Test openapiv2 generation of repeated fields" }, "optionalStringField": { "type": "string", "title": "Test openapiv2 generation of required fields with annotation and jsonschema to reproduce" }, "requiredStringField1": { "type": "string" }, "requiredStringField2": { "type": "string" }, "required_field_behavior_json_name_custom": { "type": "string", "title": "Test openapiv2 handling of required json_name fields" }, "required_field_schema_json_name_custom": { "type": "string" }, "trailingOnly": { "type": "string", "title": "Trailing only" }, "trailingOnlyDot": { "type": "string", "description": "Trailing only dot." }, "trailingBoth": { "type": "string", "description": "Trailing both.", "title": "Leading both" }, "trailingMultiline": { "type": "string", "description": "This is an example of a multi-line comment.\n\nTrailing multiline.", "title": "Leading multiline" }, "uuids": { "type": "array", "items": { "type": "string", "format": "uuid" }, "title": "Specify a custom format of repeated field items" } }, "description": "Intentionally complicated message type to cover many features of Protobuf.", "title": "A bit of everything", "externalDocs": { "description": "Find out more about ABitOfEverything", "url": "https://github.com/grpc-ecosystem/grpc-gateway" }, "required": [ "uuid", "int64Value", "doubleValue", "required_field_schema_json_name_custom", "floatValue", "requiredStringViaFieldBehaviorAnnotation", "requiredStringField1", "requiredStringField2", "required_field_behavior_json_name_custom" ], "x-a-bit-of-everything-foo": "bar" }, "examplepbNumericEnum": { "type": "string", "example": "ZERO", "enum": [ "ZERO", "ONE" ], "default": "ZERO", "description": "NumericEnum is one or zero.", "title": "NumericEnum", "externalDocs": { "description": "Find out more about ABitOfEverything", "url": "https://github.com/grpc-ecosystem/grpc-gateway" }, "x-a-bit-of-everything-foo": "bar" }, "googleRpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32", "description": "The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]." }, "message": { "type": "string", "description": "A developer-facing error message, which should be in English. Any\nuser-facing error message should be localized and sent in the\n[google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client." }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" }, "description": "A list of messages that carry the error details. There is a common set of\nmessage types for APIs to use." } }, "description": "The `Status` type defines a logical error model that is suitable for\ndifferent programming environments, including REST APIs and RPC APIs. It is\nused by [gRPC](https://github.com/grpc). Each `Status` message contains\nthree pieces of data: error code, error message, and error details.\n\nYou can find out more about this error model and how to work with it in the\n[API Design Guide](https://cloud.google.com/apis/design/errors)." }, "pathenumPathEnum": { "type": "string", "enum": [ "ABC", "DEF" ], "default": "ABC" }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string", "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics." } }, "additionalProperties": {}, "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }" } } } ================================================ FILE: examples/internal/proto/examplepb/ignore_comment.buf.gen.yaml ================================================ version: v2 plugins: - local: protoc-gen-openapiv2 out: . opt: - ignore_comments=true ================================================ FILE: examples/internal/proto/examplepb/ignore_comment.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/examplepb/ignore_comment.proto package examplepb import ( _ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) // This comment should be excluded from OpenAPI output type FooRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // This comment should be excluded from OpenAPI output Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` // This comment should be excluded from OpenAPI output Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` } func (x *FooRequest) Reset() { *x = FooRequest{} mi := &file_examples_internal_proto_examplepb_ignore_comment_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *FooRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*FooRequest) ProtoMessage() {} func (x *FooRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_ignore_comment_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use FooRequest.ProtoReflect.Descriptor instead. func (*FooRequest) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_ignore_comment_proto_rawDescGZIP(), []int{0} } func (x *FooRequest) GetUsername() string { if x != nil { return x.Username } return "" } func (x *FooRequest) GetPassword() string { if x != nil { return x.Password } return "" } // This comment should be excluded from OpenAPI output type FooReply struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields } func (x *FooReply) Reset() { *x = FooReply{} mi := &file_examples_internal_proto_examplepb_ignore_comment_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *FooReply) String() string { return protoimpl.X.MessageStringOf(x) } func (*FooReply) ProtoMessage() {} func (x *FooReply) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_ignore_comment_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use FooReply.ProtoReflect.Descriptor instead. func (*FooReply) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_ignore_comment_proto_rawDescGZIP(), []int{1} } var File_examples_internal_proto_examplepb_ignore_comment_proto protoreflect.FileDescriptor var file_examples_internal_proto_examplepb_ignore_comment_proto_rawDesc = []byte{ 0x0a, 0x36, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x98, 0x01, 0x0a, 0x0a, 0x46, 0x6f, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x44, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x28, 0x92, 0x41, 0x25, 0x32, 0x23, 0x54, 0x68, 0x69, 0x73, 0x20, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x62, 0x65, 0x20, 0x70, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x44, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x28, 0x92, 0x41, 0x25, 0x2a, 0x23, 0x54, 0x68, 0x69, 0x73, 0x20, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x62, 0x65, 0x20, 0x70, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x0a, 0x0a, 0x08, 0x46, 0x6f, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x32, 0xa6, 0x01, 0x0a, 0x0a, 0x46, 0x6f, 0x6f, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x97, 0x01, 0x0a, 0x03, 0x46, 0x6f, 0x6f, 0x12, 0x3a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x46, 0x6f, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x38, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x46, 0x6f, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x3a, 0x01, 0x2a, 0x22, 0x0f, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x66, 0x6f, 0x6f, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_examplepb_ignore_comment_proto_rawDescOnce sync.Once file_examples_internal_proto_examplepb_ignore_comment_proto_rawDescData = file_examples_internal_proto_examplepb_ignore_comment_proto_rawDesc ) func file_examples_internal_proto_examplepb_ignore_comment_proto_rawDescGZIP() []byte { file_examples_internal_proto_examplepb_ignore_comment_proto_rawDescOnce.Do(func() { file_examples_internal_proto_examplepb_ignore_comment_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_examplepb_ignore_comment_proto_rawDescData) }) return file_examples_internal_proto_examplepb_ignore_comment_proto_rawDescData } var file_examples_internal_proto_examplepb_ignore_comment_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_examples_internal_proto_examplepb_ignore_comment_proto_goTypes = []any{ (*FooRequest)(nil), // 0: grpc.gateway.examples.internal.proto.examplepb.FooRequest (*FooReply)(nil), // 1: grpc.gateway.examples.internal.proto.examplepb.FooReply } var file_examples_internal_proto_examplepb_ignore_comment_proto_depIdxs = []int32{ 0, // 0: grpc.gateway.examples.internal.proto.examplepb.FooService.Foo:input_type -> grpc.gateway.examples.internal.proto.examplepb.FooRequest 1, // 1: grpc.gateway.examples.internal.proto.examplepb.FooService.Foo:output_type -> grpc.gateway.examples.internal.proto.examplepb.FooReply 1, // [1:2] is the sub-list for method output_type 0, // [0:1] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name } func init() { file_examples_internal_proto_examplepb_ignore_comment_proto_init() } func file_examples_internal_proto_examplepb_ignore_comment_proto_init() { if File_examples_internal_proto_examplepb_ignore_comment_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_examplepb_ignore_comment_proto_rawDesc, NumEnums: 0, NumMessages: 2, NumExtensions: 0, NumServices: 1, }, GoTypes: file_examples_internal_proto_examplepb_ignore_comment_proto_goTypes, DependencyIndexes: file_examples_internal_proto_examplepb_ignore_comment_proto_depIdxs, MessageInfos: file_examples_internal_proto_examplepb_ignore_comment_proto_msgTypes, }.Build() File_examples_internal_proto_examplepb_ignore_comment_proto = out.File file_examples_internal_proto_examplepb_ignore_comment_proto_rawDesc = nil file_examples_internal_proto_examplepb_ignore_comment_proto_goTypes = nil file_examples_internal_proto_examplepb_ignore_comment_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/examplepb/ignore_comment.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/proto/examplepb/ignore_comment.proto /* Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package examplepb import ( "context" "errors" "io" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) func request_FooService_Foo_0(ctx context.Context, marshaler runtime.Marshaler, client FooServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq FooRequest metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.Foo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_FooService_Foo_0(ctx context.Context, marshaler runtime.Marshaler, server FooServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq FooRequest metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Foo(ctx, &protoReq) return msg, metadata, err } // RegisterFooServiceHandlerServer registers the http handlers for service FooService to "mux". // UnaryRPC :call FooServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterFooServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterFooServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server FooServiceServer) error { mux.Handle(http.MethodPost, pattern_FooService_Foo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FooService/Foo", runtime.WithHTTPPathPattern("/v1/example/foo")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_FooService_Foo_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FooService_Foo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } // RegisterFooServiceHandlerFromEndpoint is same as RegisterFooServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterFooServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterFooServiceHandler(ctx, mux, conn) } // RegisterFooServiceHandler registers the http handlers for service FooService to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterFooServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterFooServiceHandlerClient(ctx, mux, NewFooServiceClient(conn)) } // RegisterFooServiceHandlerClient registers the http handlers for service FooService // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "FooServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "FooServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "FooServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterFooServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client FooServiceClient) error { mux.Handle(http.MethodPost, pattern_FooService_Foo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.FooService/Foo", runtime.WithHTTPPathPattern("/v1/example/foo")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_FooService_Foo_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_FooService_Foo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_FooService_Foo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "foo"}, "")) ) var ( forward_FooService_Foo_0 = runtime.ForwardResponseMessage ) ================================================ FILE: examples/internal/proto/examplepb/ignore_comment.proto ================================================ syntax = "proto3"; package grpc.gateway.examples.internal.proto.examplepb; import "google/api/annotations.proto"; import "protoc-gen-openapiv2/options/annotations.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; // This comment should be excluded from OpenAPI output service FooService { // This comment should be excluded from OpenAPI output rpc Foo(FooRequest) returns (FooReply) { option (google.api.http) = { post: "/v1/example/foo" body: "*" }; } } // This comment should be excluded from OpenAPI output message FooRequest { // This comment should be excluded from OpenAPI output string username = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "This annotation should be preserved"}]; // This comment should be excluded from OpenAPI output string password = 2 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {title: "This annotation should be preserved"}]; } // This comment should be excluded from OpenAPI output message FooReply {} ================================================ FILE: examples/internal/proto/examplepb/ignore_comment.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/examplepb/ignore_comment.proto", "version": "version not set" }, "tags": [ { "name": "FooService" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/v1/example/foo": { "post": { "operationId": "FooService_Foo", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbFooReply" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbFooRequest" } } ], "tags": [ "FooService" ] } } }, "definitions": { "examplepbFooReply": { "type": "object" }, "examplepbFooRequest": { "type": "object", "properties": { "username": { "type": "string", "description": "This annotation should be preserved" }, "password": { "type": "string", "title": "This annotation should be preserved" } } }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string" } }, "additionalProperties": {} }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } } } } ================================================ FILE: examples/internal/proto/examplepb/ignore_comment_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: examples/internal/proto/examplepb/ignore_comment.proto package examplepb import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( FooService_Foo_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.FooService/Foo" ) // FooServiceClient is the client API for FooService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // // This comment should be excluded from OpenAPI output type FooServiceClient interface { // This comment should be excluded from OpenAPI output Foo(ctx context.Context, in *FooRequest, opts ...grpc.CallOption) (*FooReply, error) } type fooServiceClient struct { cc grpc.ClientConnInterface } func NewFooServiceClient(cc grpc.ClientConnInterface) FooServiceClient { return &fooServiceClient{cc} } func (c *fooServiceClient) Foo(ctx context.Context, in *FooRequest, opts ...grpc.CallOption) (*FooReply, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(FooReply) err := c.cc.Invoke(ctx, FooService_Foo_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // FooServiceServer is the server API for FooService service. // All implementations should embed UnimplementedFooServiceServer // for forward compatibility. // // This comment should be excluded from OpenAPI output type FooServiceServer interface { // This comment should be excluded from OpenAPI output Foo(context.Context, *FooRequest) (*FooReply, error) } // UnimplementedFooServiceServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedFooServiceServer struct{} func (UnimplementedFooServiceServer) Foo(context.Context, *FooRequest) (*FooReply, error) { return nil, status.Errorf(codes.Unimplemented, "method Foo not implemented") } func (UnimplementedFooServiceServer) testEmbeddedByValue() {} // UnsafeFooServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to FooServiceServer will // result in compilation errors. type UnsafeFooServiceServer interface { mustEmbedUnimplementedFooServiceServer() } func RegisterFooServiceServer(s grpc.ServiceRegistrar, srv FooServiceServer) { // If the following call pancis, it indicates UnimplementedFooServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&FooService_ServiceDesc, srv) } func _FooService_Foo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(FooRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(FooServiceServer).Foo(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: FooService_Foo_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(FooServiceServer).Foo(ctx, req.(*FooRequest)) } return interceptor(ctx, in, info, handler) } // FooService_ServiceDesc is the grpc.ServiceDesc for FooService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var FooService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.FooService", HandlerType: (*FooServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Foo", Handler: _FooService_Foo_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/internal/proto/examplepb/ignore_comment.proto", } ================================================ FILE: examples/internal/proto/examplepb/non_standard_names.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/examplepb/non_standard_names.proto package examplepb import ( _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) // NonStandardMessage has oddly named fields. type NonStandardMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Id represents the message identifier. Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Num int64 `protobuf:"varint,2,opt,name=Num,proto3" json:"Num,omitempty"` LineNum int64 `protobuf:"varint,3,opt,name=line_num,json=lineNum,proto3" json:"line_num,omitempty"` LangIdent string `protobuf:"bytes,4,opt,name=langIdent,proto3" json:"langIdent,omitempty"` STATUS string `protobuf:"bytes,5,opt,name=STATUS,proto3" json:"STATUS,omitempty"` En_GB int64 `protobuf:"varint,6,opt,name=en_GB,json=enGB,proto3" json:"en_GB,omitempty"` No string `protobuf:"bytes,7,opt,name=no,proto3" json:"no,omitempty"` Thing *NonStandardMessage_Thing `protobuf:"bytes,8,opt,name=thing,proto3" json:"thing,omitempty"` } func (x *NonStandardMessage) Reset() { *x = NonStandardMessage{} mi := &file_examples_internal_proto_examplepb_non_standard_names_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NonStandardMessage) String() string { return protoimpl.X.MessageStringOf(x) } func (*NonStandardMessage) ProtoMessage() {} func (x *NonStandardMessage) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_non_standard_names_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NonStandardMessage.ProtoReflect.Descriptor instead. func (*NonStandardMessage) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_non_standard_names_proto_rawDescGZIP(), []int{0} } func (x *NonStandardMessage) GetId() string { if x != nil { return x.Id } return "" } func (x *NonStandardMessage) GetNum() int64 { if x != nil { return x.Num } return 0 } func (x *NonStandardMessage) GetLineNum() int64 { if x != nil { return x.LineNum } return 0 } func (x *NonStandardMessage) GetLangIdent() string { if x != nil { return x.LangIdent } return "" } func (x *NonStandardMessage) GetSTATUS() string { if x != nil { return x.STATUS } return "" } func (x *NonStandardMessage) GetEn_GB() int64 { if x != nil { return x.En_GB } return 0 } func (x *NonStandardMessage) GetNo() string { if x != nil { return x.No } return "" } func (x *NonStandardMessage) GetThing() *NonStandardMessage_Thing { if x != nil { return x.Thing } return nil } type NonStandardUpdateRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Body *NonStandardMessage `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"` UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,2,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"` } func (x *NonStandardUpdateRequest) Reset() { *x = NonStandardUpdateRequest{} mi := &file_examples_internal_proto_examplepb_non_standard_names_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NonStandardUpdateRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*NonStandardUpdateRequest) ProtoMessage() {} func (x *NonStandardUpdateRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_non_standard_names_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NonStandardUpdateRequest.ProtoReflect.Descriptor instead. func (*NonStandardUpdateRequest) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_non_standard_names_proto_rawDescGZIP(), []int{1} } func (x *NonStandardUpdateRequest) GetBody() *NonStandardMessage { if x != nil { return x.Body } return nil } func (x *NonStandardUpdateRequest) GetUpdateMask() *fieldmaskpb.FieldMask { if x != nil { return x.UpdateMask } return nil } // NonStandardMessageWithJSONNames maps odd field names to odd JSON names for maximum confusion. type NonStandardMessageWithJSONNames struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Id represents the message identifier. Id string `protobuf:"bytes,1,opt,name=id,json=ID,proto3" json:"id,omitempty"` Num int64 `protobuf:"varint,2,opt,name=Num,proto3" json:"Num,omitempty"` LineNum int64 `protobuf:"varint,3,opt,name=line_num,json=LineNum,proto3" json:"line_num,omitempty"` LangIdent string `protobuf:"bytes,4,opt,name=langIdent,proto3" json:"langIdent,omitempty"` STATUS string `protobuf:"bytes,5,opt,name=STATUS,json=status,proto3" json:"STATUS,omitempty"` En_GB int64 `protobuf:"varint,6,opt,name=en_GB,json=En_GB,proto3" json:"en_GB,omitempty"` No string `protobuf:"bytes,7,opt,name=no,json=yes,proto3" json:"no,omitempty"` Thing *NonStandardMessageWithJSONNames_Thing `protobuf:"bytes,8,opt,name=thing,json=Thingy,proto3" json:"thing,omitempty"` } func (x *NonStandardMessageWithJSONNames) Reset() { *x = NonStandardMessageWithJSONNames{} mi := &file_examples_internal_proto_examplepb_non_standard_names_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NonStandardMessageWithJSONNames) String() string { return protoimpl.X.MessageStringOf(x) } func (*NonStandardMessageWithJSONNames) ProtoMessage() {} func (x *NonStandardMessageWithJSONNames) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_non_standard_names_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NonStandardMessageWithJSONNames.ProtoReflect.Descriptor instead. func (*NonStandardMessageWithJSONNames) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_non_standard_names_proto_rawDescGZIP(), []int{2} } func (x *NonStandardMessageWithJSONNames) GetId() string { if x != nil { return x.Id } return "" } func (x *NonStandardMessageWithJSONNames) GetNum() int64 { if x != nil { return x.Num } return 0 } func (x *NonStandardMessageWithJSONNames) GetLineNum() int64 { if x != nil { return x.LineNum } return 0 } func (x *NonStandardMessageWithJSONNames) GetLangIdent() string { if x != nil { return x.LangIdent } return "" } func (x *NonStandardMessageWithJSONNames) GetSTATUS() string { if x != nil { return x.STATUS } return "" } func (x *NonStandardMessageWithJSONNames) GetEn_GB() int64 { if x != nil { return x.En_GB } return 0 } func (x *NonStandardMessageWithJSONNames) GetNo() string { if x != nil { return x.No } return "" } func (x *NonStandardMessageWithJSONNames) GetThing() *NonStandardMessageWithJSONNames_Thing { if x != nil { return x.Thing } return nil } type NonStandardWithJSONNamesUpdateRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Body *NonStandardMessageWithJSONNames `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"` UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,2,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"` } func (x *NonStandardWithJSONNamesUpdateRequest) Reset() { *x = NonStandardWithJSONNamesUpdateRequest{} mi := &file_examples_internal_proto_examplepb_non_standard_names_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NonStandardWithJSONNamesUpdateRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*NonStandardWithJSONNamesUpdateRequest) ProtoMessage() {} func (x *NonStandardWithJSONNamesUpdateRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_non_standard_names_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NonStandardWithJSONNamesUpdateRequest.ProtoReflect.Descriptor instead. func (*NonStandardWithJSONNamesUpdateRequest) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_non_standard_names_proto_rawDescGZIP(), []int{3} } func (x *NonStandardWithJSONNamesUpdateRequest) GetBody() *NonStandardMessageWithJSONNames { if x != nil { return x.Body } return nil } func (x *NonStandardWithJSONNamesUpdateRequest) GetUpdateMask() *fieldmaskpb.FieldMask { if x != nil { return x.UpdateMask } return nil } type NonStandardMessage_Thing struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields SubThing *NonStandardMessage_Thing_SubThing `protobuf:"bytes,1,opt,name=subThing,proto3" json:"subThing,omitempty"` } func (x *NonStandardMessage_Thing) Reset() { *x = NonStandardMessage_Thing{} mi := &file_examples_internal_proto_examplepb_non_standard_names_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NonStandardMessage_Thing) String() string { return protoimpl.X.MessageStringOf(x) } func (*NonStandardMessage_Thing) ProtoMessage() {} func (x *NonStandardMessage_Thing) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_non_standard_names_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NonStandardMessage_Thing.ProtoReflect.Descriptor instead. func (*NonStandardMessage_Thing) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_non_standard_names_proto_rawDescGZIP(), []int{0, 0} } func (x *NonStandardMessage_Thing) GetSubThing() *NonStandardMessage_Thing_SubThing { if x != nil { return x.SubThing } return nil } type NonStandardMessage_Thing_SubThing struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields SubValue string `protobuf:"bytes,1,opt,name=sub_value,json=subValue,proto3" json:"sub_value,omitempty"` } func (x *NonStandardMessage_Thing_SubThing) Reset() { *x = NonStandardMessage_Thing_SubThing{} mi := &file_examples_internal_proto_examplepb_non_standard_names_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NonStandardMessage_Thing_SubThing) String() string { return protoimpl.X.MessageStringOf(x) } func (*NonStandardMessage_Thing_SubThing) ProtoMessage() {} func (x *NonStandardMessage_Thing_SubThing) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_non_standard_names_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NonStandardMessage_Thing_SubThing.ProtoReflect.Descriptor instead. func (*NonStandardMessage_Thing_SubThing) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_non_standard_names_proto_rawDescGZIP(), []int{0, 0, 0} } func (x *NonStandardMessage_Thing_SubThing) GetSubValue() string { if x != nil { return x.SubValue } return "" } type NonStandardMessageWithJSONNames_Thing struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields SubThing *NonStandardMessageWithJSONNames_Thing_SubThing `protobuf:"bytes,1,opt,name=subThing,json=SubThing,proto3" json:"subThing,omitempty"` } func (x *NonStandardMessageWithJSONNames_Thing) Reset() { *x = NonStandardMessageWithJSONNames_Thing{} mi := &file_examples_internal_proto_examplepb_non_standard_names_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NonStandardMessageWithJSONNames_Thing) String() string { return protoimpl.X.MessageStringOf(x) } func (*NonStandardMessageWithJSONNames_Thing) ProtoMessage() {} func (x *NonStandardMessageWithJSONNames_Thing) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_non_standard_names_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NonStandardMessageWithJSONNames_Thing.ProtoReflect.Descriptor instead. func (*NonStandardMessageWithJSONNames_Thing) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_non_standard_names_proto_rawDescGZIP(), []int{2, 0} } func (x *NonStandardMessageWithJSONNames_Thing) GetSubThing() *NonStandardMessageWithJSONNames_Thing_SubThing { if x != nil { return x.SubThing } return nil } type NonStandardMessageWithJSONNames_Thing_SubThing struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields SubValue string `protobuf:"bytes,1,opt,name=sub_value,json=sub_Value,proto3" json:"sub_value,omitempty"` } func (x *NonStandardMessageWithJSONNames_Thing_SubThing) Reset() { *x = NonStandardMessageWithJSONNames_Thing_SubThing{} mi := &file_examples_internal_proto_examplepb_non_standard_names_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NonStandardMessageWithJSONNames_Thing_SubThing) String() string { return protoimpl.X.MessageStringOf(x) } func (*NonStandardMessageWithJSONNames_Thing_SubThing) ProtoMessage() {} func (x *NonStandardMessageWithJSONNames_Thing_SubThing) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_non_standard_names_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NonStandardMessageWithJSONNames_Thing_SubThing.ProtoReflect.Descriptor instead. func (*NonStandardMessageWithJSONNames_Thing_SubThing) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_non_standard_names_proto_rawDescGZIP(), []int{2, 0, 0} } func (x *NonStandardMessageWithJSONNames_Thing_SubThing) GetSubValue() string { if x != nil { return x.SubValue } return "" } var File_examples_internal_proto_examplepb_non_standard_names_proto protoreflect.FileDescriptor var file_examples_internal_proto_examplepb_non_standard_names_proto_rawDesc = []byte{ 0x0a, 0x3a, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x6e, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xae, 0x03, 0x0a, 0x12, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x4e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x4e, 0x75, 0x6d, 0x12, 0x19, 0x0a, 0x08, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x6c, 0x69, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x6c, 0x61, 0x6e, 0x67, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6c, 0x61, 0x6e, 0x67, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x12, 0x13, 0x0a, 0x05, 0x65, 0x6e, 0x5f, 0x47, 0x42, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x65, 0x6e, 0x47, 0x42, 0x12, 0x0e, 0x0a, 0x02, 0x6e, 0x6f, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x6e, 0x6f, 0x12, 0x5e, 0x0a, 0x05, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x48, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x9f, 0x01, 0x0a, 0x05, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x6d, 0x0a, 0x08, 0x73, 0x75, 0x62, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x51, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x53, 0x75, 0x62, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x52, 0x08, 0x73, 0x75, 0x62, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x27, 0x0a, 0x08, 0x53, 0x75, 0x62, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x75, 0x62, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x75, 0x62, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xaf, 0x01, 0x0a, 0x18, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x56, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x42, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x3b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x6b, 0x22, 0xd9, 0x03, 0x0a, 0x1f, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x57, 0x69, 0x74, 0x68, 0x4a, 0x53, 0x4f, 0x4e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x44, 0x12, 0x10, 0x0a, 0x03, 0x4e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x4e, 0x75, 0x6d, 0x12, 0x19, 0x0a, 0x08, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x4c, 0x69, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x6c, 0x61, 0x6e, 0x67, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6c, 0x61, 0x6e, 0x67, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6e, 0x5f, 0x47, 0x42, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x45, 0x6e, 0x5f, 0x47, 0x42, 0x12, 0x0f, 0x0a, 0x02, 0x6e, 0x6f, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x79, 0x65, 0x73, 0x12, 0x6c, 0x0a, 0x05, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x55, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x57, 0x69, 0x74, 0x68, 0x4a, 0x53, 0x4f, 0x4e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x79, 0x1a, 0xad, 0x01, 0x0a, 0x05, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x7a, 0x0a, 0x08, 0x73, 0x75, 0x62, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x5e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x57, 0x69, 0x74, 0x68, 0x4a, 0x53, 0x4f, 0x4e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x53, 0x75, 0x62, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x52, 0x08, 0x53, 0x75, 0x62, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x28, 0x0a, 0x08, 0x53, 0x75, 0x62, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x75, 0x62, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x75, 0x62, 0x5f, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xc9, 0x01, 0x0a, 0x25, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x57, 0x69, 0x74, 0x68, 0x4a, 0x53, 0x4f, 0x4e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x63, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x4f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x57, 0x69, 0x74, 0x68, 0x4a, 0x53, 0x4f, 0x4e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x3b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x6b, 0x32, 0xdb, 0x03, 0x0a, 0x12, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xc5, 0x01, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x48, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x42, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x2d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x27, 0x3a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x32, 0x1f, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x6e, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0xfc, 0x01, 0x0a, 0x13, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x69, 0x74, 0x68, 0x4a, 0x53, 0x4f, 0x4e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x55, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x57, 0x69, 0x74, 0x68, 0x4a, 0x53, 0x4f, 0x4e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x4f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x57, 0x69, 0x74, 0x68, 0x4a, 0x53, 0x4f, 0x4e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x22, 0x3d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x37, 0x3a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x32, 0x2f, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x6e, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_examplepb_non_standard_names_proto_rawDescOnce sync.Once file_examples_internal_proto_examplepb_non_standard_names_proto_rawDescData = file_examples_internal_proto_examplepb_non_standard_names_proto_rawDesc ) func file_examples_internal_proto_examplepb_non_standard_names_proto_rawDescGZIP() []byte { file_examples_internal_proto_examplepb_non_standard_names_proto_rawDescOnce.Do(func() { file_examples_internal_proto_examplepb_non_standard_names_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_examplepb_non_standard_names_proto_rawDescData) }) return file_examples_internal_proto_examplepb_non_standard_names_proto_rawDescData } var file_examples_internal_proto_examplepb_non_standard_names_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_examples_internal_proto_examplepb_non_standard_names_proto_goTypes = []any{ (*NonStandardMessage)(nil), // 0: grpc.gateway.examples.internal.proto.examplepb.NonStandardMessage (*NonStandardUpdateRequest)(nil), // 1: grpc.gateway.examples.internal.proto.examplepb.NonStandardUpdateRequest (*NonStandardMessageWithJSONNames)(nil), // 2: grpc.gateway.examples.internal.proto.examplepb.NonStandardMessageWithJSONNames (*NonStandardWithJSONNamesUpdateRequest)(nil), // 3: grpc.gateway.examples.internal.proto.examplepb.NonStandardWithJSONNamesUpdateRequest (*NonStandardMessage_Thing)(nil), // 4: grpc.gateway.examples.internal.proto.examplepb.NonStandardMessage.Thing (*NonStandardMessage_Thing_SubThing)(nil), // 5: grpc.gateway.examples.internal.proto.examplepb.NonStandardMessage.Thing.SubThing (*NonStandardMessageWithJSONNames_Thing)(nil), // 6: grpc.gateway.examples.internal.proto.examplepb.NonStandardMessageWithJSONNames.Thing (*NonStandardMessageWithJSONNames_Thing_SubThing)(nil), // 7: grpc.gateway.examples.internal.proto.examplepb.NonStandardMessageWithJSONNames.Thing.SubThing (*fieldmaskpb.FieldMask)(nil), // 8: google.protobuf.FieldMask } var file_examples_internal_proto_examplepb_non_standard_names_proto_depIdxs = []int32{ 4, // 0: grpc.gateway.examples.internal.proto.examplepb.NonStandardMessage.thing:type_name -> grpc.gateway.examples.internal.proto.examplepb.NonStandardMessage.Thing 0, // 1: grpc.gateway.examples.internal.proto.examplepb.NonStandardUpdateRequest.body:type_name -> grpc.gateway.examples.internal.proto.examplepb.NonStandardMessage 8, // 2: grpc.gateway.examples.internal.proto.examplepb.NonStandardUpdateRequest.update_mask:type_name -> google.protobuf.FieldMask 6, // 3: grpc.gateway.examples.internal.proto.examplepb.NonStandardMessageWithJSONNames.thing:type_name -> grpc.gateway.examples.internal.proto.examplepb.NonStandardMessageWithJSONNames.Thing 2, // 4: grpc.gateway.examples.internal.proto.examplepb.NonStandardWithJSONNamesUpdateRequest.body:type_name -> grpc.gateway.examples.internal.proto.examplepb.NonStandardMessageWithJSONNames 8, // 5: grpc.gateway.examples.internal.proto.examplepb.NonStandardWithJSONNamesUpdateRequest.update_mask:type_name -> google.protobuf.FieldMask 5, // 6: grpc.gateway.examples.internal.proto.examplepb.NonStandardMessage.Thing.subThing:type_name -> grpc.gateway.examples.internal.proto.examplepb.NonStandardMessage.Thing.SubThing 7, // 7: grpc.gateway.examples.internal.proto.examplepb.NonStandardMessageWithJSONNames.Thing.subThing:type_name -> grpc.gateway.examples.internal.proto.examplepb.NonStandardMessageWithJSONNames.Thing.SubThing 1, // 8: grpc.gateway.examples.internal.proto.examplepb.NonStandardService.Update:input_type -> grpc.gateway.examples.internal.proto.examplepb.NonStandardUpdateRequest 3, // 9: grpc.gateway.examples.internal.proto.examplepb.NonStandardService.UpdateWithJSONNames:input_type -> grpc.gateway.examples.internal.proto.examplepb.NonStandardWithJSONNamesUpdateRequest 0, // 10: grpc.gateway.examples.internal.proto.examplepb.NonStandardService.Update:output_type -> grpc.gateway.examples.internal.proto.examplepb.NonStandardMessage 2, // 11: grpc.gateway.examples.internal.proto.examplepb.NonStandardService.UpdateWithJSONNames:output_type -> grpc.gateway.examples.internal.proto.examplepb.NonStandardMessageWithJSONNames 10, // [10:12] is the sub-list for method output_type 8, // [8:10] is the sub-list for method input_type 8, // [8:8] is the sub-list for extension type_name 8, // [8:8] is the sub-list for extension extendee 0, // [0:8] is the sub-list for field type_name } func init() { file_examples_internal_proto_examplepb_non_standard_names_proto_init() } func file_examples_internal_proto_examplepb_non_standard_names_proto_init() { if File_examples_internal_proto_examplepb_non_standard_names_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_examplepb_non_standard_names_proto_rawDesc, NumEnums: 0, NumMessages: 8, NumExtensions: 0, NumServices: 1, }, GoTypes: file_examples_internal_proto_examplepb_non_standard_names_proto_goTypes, DependencyIndexes: file_examples_internal_proto_examplepb_non_standard_names_proto_depIdxs, MessageInfos: file_examples_internal_proto_examplepb_non_standard_names_proto_msgTypes, }.Build() File_examples_internal_proto_examplepb_non_standard_names_proto = out.File file_examples_internal_proto_examplepb_non_standard_names_proto_rawDesc = nil file_examples_internal_proto_examplepb_non_standard_names_proto_goTypes = nil file_examples_internal_proto_examplepb_non_standard_names_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/examplepb/non_standard_names.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/proto/examplepb/non_standard_names.proto /* Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package examplepb import ( "context" "errors" "io" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) var filter_NonStandardService_Update_0 = &utilities.DoubleArray{Encoding: map[string]int{"body": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_NonStandardService_Update_0(ctx context.Context, marshaler runtime.Marshaler, client NonStandardServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NonStandardUpdateRequest metadata runtime.ServerMetadata ) newReader, berr := utilities.IOReaderFactory(req.Body) if berr != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) } if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Body); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Body); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } else { protoReq.UpdateMask = fieldMask } } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_NonStandardService_Update_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Update(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_NonStandardService_Update_0(ctx context.Context, marshaler runtime.Marshaler, server NonStandardServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NonStandardUpdateRequest metadata runtime.ServerMetadata ) newReader, berr := utilities.IOReaderFactory(req.Body) if berr != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) } if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Body); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Body); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } else { protoReq.UpdateMask = fieldMask } } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_NonStandardService_Update_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Update(ctx, &protoReq) return msg, metadata, err } var filter_NonStandardService_UpdateWithJSONNames_0 = &utilities.DoubleArray{Encoding: map[string]int{"body": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_NonStandardService_UpdateWithJSONNames_0(ctx context.Context, marshaler runtime.Marshaler, client NonStandardServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NonStandardWithJSONNamesUpdateRequest metadata runtime.ServerMetadata ) newReader, berr := utilities.IOReaderFactory(req.Body) if berr != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) } if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Body); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Body); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } else { protoReq.UpdateMask = fieldMask } } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_NonStandardService_UpdateWithJSONNames_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.UpdateWithJSONNames(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_NonStandardService_UpdateWithJSONNames_0(ctx context.Context, marshaler runtime.Marshaler, server NonStandardServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq NonStandardWithJSONNamesUpdateRequest metadata runtime.ServerMetadata ) newReader, berr := utilities.IOReaderFactory(req.Body) if berr != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) } if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Body); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Body); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } else { protoReq.UpdateMask = fieldMask } } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_NonStandardService_UpdateWithJSONNames_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.UpdateWithJSONNames(ctx, &protoReq) return msg, metadata, err } // RegisterNonStandardServiceHandlerServer registers the http handlers for service NonStandardService to "mux". // UnaryRPC :call NonStandardServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterNonStandardServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterNonStandardServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server NonStandardServiceServer) error { mux.Handle(http.MethodPatch, pattern_NonStandardService_Update_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.NonStandardService/Update", runtime.WithHTTPPathPattern("/v1/example/non_standard/update")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_NonStandardService_Update_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_NonStandardService_Update_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPatch, pattern_NonStandardService_UpdateWithJSONNames_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.NonStandardService/UpdateWithJSONNames", runtime.WithHTTPPathPattern("/v1/example/non_standard/update_with_json_names")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_NonStandardService_UpdateWithJSONNames_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_NonStandardService_UpdateWithJSONNames_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } // RegisterNonStandardServiceHandlerFromEndpoint is same as RegisterNonStandardServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterNonStandardServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterNonStandardServiceHandler(ctx, mux, conn) } // RegisterNonStandardServiceHandler registers the http handlers for service NonStandardService to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterNonStandardServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterNonStandardServiceHandlerClient(ctx, mux, NewNonStandardServiceClient(conn)) } // RegisterNonStandardServiceHandlerClient registers the http handlers for service NonStandardService // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "NonStandardServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "NonStandardServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "NonStandardServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterNonStandardServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client NonStandardServiceClient) error { mux.Handle(http.MethodPatch, pattern_NonStandardService_Update_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.NonStandardService/Update", runtime.WithHTTPPathPattern("/v1/example/non_standard/update")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_NonStandardService_Update_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_NonStandardService_Update_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPatch, pattern_NonStandardService_UpdateWithJSONNames_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.NonStandardService/UpdateWithJSONNames", runtime.WithHTTPPathPattern("/v1/example/non_standard/update_with_json_names")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_NonStandardService_UpdateWithJSONNames_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_NonStandardService_UpdateWithJSONNames_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_NonStandardService_Update_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "example", "non_standard", "update"}, "")) pattern_NonStandardService_UpdateWithJSONNames_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "example", "non_standard", "update_with_json_names"}, "")) ) var ( forward_NonStandardService_Update_0 = runtime.ForwardResponseMessage forward_NonStandardService_UpdateWithJSONNames_0 = runtime.ForwardResponseMessage ) ================================================ FILE: examples/internal/proto/examplepb/non_standard_names.proto ================================================ syntax = "proto3"; package grpc.gateway.examples.internal.proto.examplepb; import "google/api/annotations.proto"; import "google/protobuf/field_mask.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; // NonStandardMessage has oddly named fields. message NonStandardMessage { // Id represents the message identifier. string id = 1; int64 Num = 2; int64 line_num = 3; string langIdent = 4; string STATUS = 5; int64 en_GB = 6; string no = 7; message Thing { message SubThing { string sub_value = 1; } SubThing subThing = 1; } Thing thing = 8; } message NonStandardUpdateRequest { NonStandardMessage body = 1; google.protobuf.FieldMask update_mask = 2; } // NonStandardMessageWithJSONNames maps odd field names to odd JSON names for maximum confusion. message NonStandardMessageWithJSONNames { // Id represents the message identifier. string id = 1 [json_name = "ID"]; int64 Num = 2 [json_name = "Num"]; int64 line_num = 3 [json_name = "LineNum"]; string langIdent = 4 [json_name = "langIdent"]; string STATUS = 5 [json_name = "status"]; int64 en_GB = 6 [json_name = "En_GB"]; string no = 7 [json_name = "yes"]; message Thing { message SubThing { string sub_value = 1 [json_name = "sub_Value"]; } SubThing subThing = 1 [json_name = "SubThing"]; } Thing thing = 8 [json_name = "Thingy"]; } message NonStandardWithJSONNamesUpdateRequest { NonStandardMessageWithJSONNames body = 1; google.protobuf.FieldMask update_mask = 2; } // NonStandardService responds to incoming messages, applies a field mask and returns the masked response. service NonStandardService { // Apply field mask to empty NonStandardMessage and return result. rpc Update(NonStandardUpdateRequest) returns (NonStandardMessage) { option (google.api.http) = { patch: "/v1/example/non_standard/update" body: "body" }; } // Apply field mask to empty NonStandardMessageWithJSONNames and return result. rpc UpdateWithJSONNames(NonStandardWithJSONNamesUpdateRequest) returns (NonStandardMessageWithJSONNames) { option (google.api.http) = { patch: "/v1/example/non_standard/update_with_json_names" body: "body" }; } } ================================================ FILE: examples/internal/proto/examplepb/non_standard_names.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/examplepb/non_standard_names.proto", "version": "version not set" }, "tags": [ { "name": "NonStandardService" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/v1/example/non_standard/update": { "patch": { "summary": "Apply field mask to empty NonStandardMessage and return result.", "operationId": "NonStandardService_Update", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbNonStandardMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbNonStandardMessage" } } ], "tags": [ "NonStandardService" ] } }, "/v1/example/non_standard/update_with_json_names": { "patch": { "summary": "Apply field mask to empty NonStandardMessageWithJSONNames and return result.", "operationId": "NonStandardService_UpdateWithJSONNames", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbNonStandardMessageWithJSONNames" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbNonStandardMessageWithJSONNames" } } ], "tags": [ "NonStandardService" ] } } }, "definitions": { "examplepbNonStandardMessage": { "type": "object", "properties": { "id": { "type": "string", "description": "Id represents the message identifier." }, "Num": { "type": "string", "format": "int64" }, "lineNum": { "type": "string", "format": "int64" }, "langIdent": { "type": "string" }, "STATUS": { "type": "string" }, "enGB": { "type": "string", "format": "int64" }, "no": { "type": "string" }, "thing": { "$ref": "#/definitions/examplepbNonStandardMessageThing" } }, "description": "NonStandardMessage has oddly named fields." }, "examplepbNonStandardMessageThing": { "type": "object", "properties": { "subThing": { "$ref": "#/definitions/examplepbNonStandardMessageThingSubThing" } } }, "examplepbNonStandardMessageThingSubThing": { "type": "object", "properties": { "subValue": { "type": "string" } } }, "examplepbNonStandardMessageWithJSONNames": { "type": "object", "properties": { "ID": { "type": "string", "description": "Id represents the message identifier." }, "Num": { "type": "string", "format": "int64" }, "LineNum": { "type": "string", "format": "int64" }, "langIdent": { "type": "string" }, "status": { "type": "string" }, "En_GB": { "type": "string", "format": "int64" }, "yes": { "type": "string" }, "Thingy": { "$ref": "#/definitions/examplepbNonStandardMessageWithJSONNamesThing" } }, "description": "NonStandardMessageWithJSONNames maps odd field names to odd JSON names for maximum confusion." }, "examplepbNonStandardMessageWithJSONNamesThing": { "type": "object", "properties": { "SubThing": { "$ref": "#/definitions/examplepbNonStandardMessageWithJSONNamesThingSubThing" } } }, "examplepbNonStandardMessageWithJSONNamesThingSubThing": { "type": "object", "properties": { "sub_Value": { "type": "string" } } }, "googleRpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32", "description": "The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]." }, "message": { "type": "string", "description": "A developer-facing error message, which should be in English. Any\nuser-facing error message should be localized and sent in the\n[google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client." }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" }, "description": "A list of messages that carry the error details. There is a common set of\nmessage types for APIs to use." } }, "description": "The `Status` type defines a logical error model that is suitable for\ndifferent programming environments, including REST APIs and RPC APIs. It is\nused by [gRPC](https://github.com/grpc). Each `Status` message contains\nthree pieces of data: error code, error message, and error details.\n\nYou can find out more about this error model and how to work with it in the\n[API Design Guide](https://cloud.google.com/apis/design/errors)." }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string", "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics." } }, "additionalProperties": {}, "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }" } } } ================================================ FILE: examples/internal/proto/examplepb/non_standard_names_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: examples/internal/proto/examplepb/non_standard_names.proto package examplepb import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( NonStandardService_Update_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.NonStandardService/Update" NonStandardService_UpdateWithJSONNames_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.NonStandardService/UpdateWithJSONNames" ) // NonStandardServiceClient is the client API for NonStandardService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // // NonStandardService responds to incoming messages, applies a field mask and returns the masked response. type NonStandardServiceClient interface { // Apply field mask to empty NonStandardMessage and return result. Update(ctx context.Context, in *NonStandardUpdateRequest, opts ...grpc.CallOption) (*NonStandardMessage, error) // Apply field mask to empty NonStandardMessageWithJSONNames and return result. UpdateWithJSONNames(ctx context.Context, in *NonStandardWithJSONNamesUpdateRequest, opts ...grpc.CallOption) (*NonStandardMessageWithJSONNames, error) } type nonStandardServiceClient struct { cc grpc.ClientConnInterface } func NewNonStandardServiceClient(cc grpc.ClientConnInterface) NonStandardServiceClient { return &nonStandardServiceClient{cc} } func (c *nonStandardServiceClient) Update(ctx context.Context, in *NonStandardUpdateRequest, opts ...grpc.CallOption) (*NonStandardMessage, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(NonStandardMessage) err := c.cc.Invoke(ctx, NonStandardService_Update_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *nonStandardServiceClient) UpdateWithJSONNames(ctx context.Context, in *NonStandardWithJSONNamesUpdateRequest, opts ...grpc.CallOption) (*NonStandardMessageWithJSONNames, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(NonStandardMessageWithJSONNames) err := c.cc.Invoke(ctx, NonStandardService_UpdateWithJSONNames_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // NonStandardServiceServer is the server API for NonStandardService service. // All implementations should embed UnimplementedNonStandardServiceServer // for forward compatibility. // // NonStandardService responds to incoming messages, applies a field mask and returns the masked response. type NonStandardServiceServer interface { // Apply field mask to empty NonStandardMessage and return result. Update(context.Context, *NonStandardUpdateRequest) (*NonStandardMessage, error) // Apply field mask to empty NonStandardMessageWithJSONNames and return result. UpdateWithJSONNames(context.Context, *NonStandardWithJSONNamesUpdateRequest) (*NonStandardMessageWithJSONNames, error) } // UnimplementedNonStandardServiceServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedNonStandardServiceServer struct{} func (UnimplementedNonStandardServiceServer) Update(context.Context, *NonStandardUpdateRequest) (*NonStandardMessage, error) { return nil, status.Errorf(codes.Unimplemented, "method Update not implemented") } func (UnimplementedNonStandardServiceServer) UpdateWithJSONNames(context.Context, *NonStandardWithJSONNamesUpdateRequest) (*NonStandardMessageWithJSONNames, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateWithJSONNames not implemented") } func (UnimplementedNonStandardServiceServer) testEmbeddedByValue() {} // UnsafeNonStandardServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to NonStandardServiceServer will // result in compilation errors. type UnsafeNonStandardServiceServer interface { mustEmbedUnimplementedNonStandardServiceServer() } func RegisterNonStandardServiceServer(s grpc.ServiceRegistrar, srv NonStandardServiceServer) { // If the following call pancis, it indicates UnimplementedNonStandardServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&NonStandardService_ServiceDesc, srv) } func _NonStandardService_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(NonStandardUpdateRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(NonStandardServiceServer).Update(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: NonStandardService_Update_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(NonStandardServiceServer).Update(ctx, req.(*NonStandardUpdateRequest)) } return interceptor(ctx, in, info, handler) } func _NonStandardService_UpdateWithJSONNames_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(NonStandardWithJSONNamesUpdateRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(NonStandardServiceServer).UpdateWithJSONNames(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: NonStandardService_UpdateWithJSONNames_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(NonStandardServiceServer).UpdateWithJSONNames(ctx, req.(*NonStandardWithJSONNamesUpdateRequest)) } return interceptor(ctx, in, info, handler) } // NonStandardService_ServiceDesc is the grpc.ServiceDesc for NonStandardService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var NonStandardService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.NonStandardService", HandlerType: (*NonStandardServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Update", Handler: _NonStandardService_Update_Handler, }, { MethodName: "UpdateWithJSONNames", Handler: _NonStandardService_UpdateWithJSONNames_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/internal/proto/examplepb/non_standard_names.proto", } ================================================ FILE: examples/internal/proto/examplepb/opaque.buf.gen.yaml ================================================ version: v2 plugins: - remote: buf.build/protocolbuffers/go:v1.36.6 out: . opt: - paths=source_relative - default_api_level=API_OPAQUE - remote: buf.build/grpc/go:v1.5.1 out: . opt: - paths=source_relative - require_unimplemented_servers=false - local: protoc-gen-grpc-gateway out: . opt: - paths=source_relative - use_opaque_api=true ================================================ FILE: examples/internal/proto/examplepb/opaque.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.6 // protoc (unknown) // source: examples/internal/proto/examplepb/opaque.proto package examplepb import ( sub "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" durationpb "google.golang.org/protobuf/types/known/durationpb" fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" timestamppb "google.golang.org/protobuf/types/known/timestamppb" wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" reflect "reflect" unsafe "unsafe" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) type OpaqueSearchProductsRequest_OpaqueSortOrder int32 const ( OpaqueSearchProductsRequest_OPAQUE_SORT_ORDER_UNSPECIFIED OpaqueSearchProductsRequest_OpaqueSortOrder = 0 OpaqueSearchProductsRequest_OPAQUE_SORT_ORDER_RELEVANCE OpaqueSearchProductsRequest_OpaqueSortOrder = 1 OpaqueSearchProductsRequest_OPAQUE_SORT_ORDER_PRICE_LOW_TO_HIGH OpaqueSearchProductsRequest_OpaqueSortOrder = 2 OpaqueSearchProductsRequest_OPAQUE_SORT_ORDER_PRICE_HIGH_TO_LOW OpaqueSearchProductsRequest_OpaqueSortOrder = 3 OpaqueSearchProductsRequest_OPAQUE_SORT_ORDER_NEWEST_FIRST OpaqueSearchProductsRequest_OpaqueSortOrder = 4 OpaqueSearchProductsRequest_OPAQUE_SORT_ORDER_RATING OpaqueSearchProductsRequest_OpaqueSortOrder = 5 OpaqueSearchProductsRequest_OPAQUE_SORT_ORDER_POPULARITY OpaqueSearchProductsRequest_OpaqueSortOrder = 6 ) // Enum value maps for OpaqueSearchProductsRequest_OpaqueSortOrder. var ( OpaqueSearchProductsRequest_OpaqueSortOrder_name = map[int32]string{ 0: "OPAQUE_SORT_ORDER_UNSPECIFIED", 1: "OPAQUE_SORT_ORDER_RELEVANCE", 2: "OPAQUE_SORT_ORDER_PRICE_LOW_TO_HIGH", 3: "OPAQUE_SORT_ORDER_PRICE_HIGH_TO_LOW", 4: "OPAQUE_SORT_ORDER_NEWEST_FIRST", 5: "OPAQUE_SORT_ORDER_RATING", 6: "OPAQUE_SORT_ORDER_POPULARITY", } OpaqueSearchProductsRequest_OpaqueSortOrder_value = map[string]int32{ "OPAQUE_SORT_ORDER_UNSPECIFIED": 0, "OPAQUE_SORT_ORDER_RELEVANCE": 1, "OPAQUE_SORT_ORDER_PRICE_LOW_TO_HIGH": 2, "OPAQUE_SORT_ORDER_PRICE_HIGH_TO_LOW": 3, "OPAQUE_SORT_ORDER_NEWEST_FIRST": 4, "OPAQUE_SORT_ORDER_RATING": 5, "OPAQUE_SORT_ORDER_POPULARITY": 6, } ) func (x OpaqueSearchProductsRequest_OpaqueSortOrder) Enum() *OpaqueSearchProductsRequest_OpaqueSortOrder { p := new(OpaqueSearchProductsRequest_OpaqueSortOrder) *p = x return p } func (x OpaqueSearchProductsRequest_OpaqueSortOrder) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (OpaqueSearchProductsRequest_OpaqueSortOrder) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_examplepb_opaque_proto_enumTypes[0].Descriptor() } func (OpaqueSearchProductsRequest_OpaqueSortOrder) Type() protoreflect.EnumType { return &file_examples_internal_proto_examplepb_opaque_proto_enumTypes[0] } func (x OpaqueSearchProductsRequest_OpaqueSortOrder) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } type OpaqueAddress_OpaqueAddressType int32 const ( OpaqueAddress_OPAQUE_ADDRESS_TYPE_UNSPECIFIED OpaqueAddress_OpaqueAddressType = 0 OpaqueAddress_OPAQUE_ADDRESS_TYPE_RESIDENTIAL OpaqueAddress_OpaqueAddressType = 1 OpaqueAddress_OPAQUE_ADDRESS_TYPE_BUSINESS OpaqueAddress_OpaqueAddressType = 2 OpaqueAddress_OPAQUE_ADDRESS_TYPE_SHIPPING OpaqueAddress_OpaqueAddressType = 3 OpaqueAddress_OPAQUE_ADDRESS_TYPE_BILLING OpaqueAddress_OpaqueAddressType = 4 ) // Enum value maps for OpaqueAddress_OpaqueAddressType. var ( OpaqueAddress_OpaqueAddressType_name = map[int32]string{ 0: "OPAQUE_ADDRESS_TYPE_UNSPECIFIED", 1: "OPAQUE_ADDRESS_TYPE_RESIDENTIAL", 2: "OPAQUE_ADDRESS_TYPE_BUSINESS", 3: "OPAQUE_ADDRESS_TYPE_SHIPPING", 4: "OPAQUE_ADDRESS_TYPE_BILLING", } OpaqueAddress_OpaqueAddressType_value = map[string]int32{ "OPAQUE_ADDRESS_TYPE_UNSPECIFIED": 0, "OPAQUE_ADDRESS_TYPE_RESIDENTIAL": 1, "OPAQUE_ADDRESS_TYPE_BUSINESS": 2, "OPAQUE_ADDRESS_TYPE_SHIPPING": 3, "OPAQUE_ADDRESS_TYPE_BILLING": 4, } ) func (x OpaqueAddress_OpaqueAddressType) Enum() *OpaqueAddress_OpaqueAddressType { p := new(OpaqueAddress_OpaqueAddressType) *p = x return p } func (x OpaqueAddress_OpaqueAddressType) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (OpaqueAddress_OpaqueAddressType) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_examplepb_opaque_proto_enumTypes[1].Descriptor() } func (OpaqueAddress_OpaqueAddressType) Type() protoreflect.EnumType { return &file_examples_internal_proto_examplepb_opaque_proto_enumTypes[1] } func (x OpaqueAddress_OpaqueAddressType) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } type OpaqueProduct_OpaqueProductStatus int32 const ( OpaqueProduct_OPAQUE_PRODUCT_STATUS_UNSPECIFIED OpaqueProduct_OpaqueProductStatus = 0 OpaqueProduct_OPAQUE_PRODUCT_STATUS_DRAFT OpaqueProduct_OpaqueProductStatus = 1 OpaqueProduct_OPAQUE_PRODUCT_STATUS_ACTIVE OpaqueProduct_OpaqueProductStatus = 2 OpaqueProduct_OPAQUE_PRODUCT_STATUS_OUT_OF_STOCK OpaqueProduct_OpaqueProductStatus = 3 OpaqueProduct_OPAQUE_PRODUCT_STATUS_DISCONTINUED OpaqueProduct_OpaqueProductStatus = 4 ) // Enum value maps for OpaqueProduct_OpaqueProductStatus. var ( OpaqueProduct_OpaqueProductStatus_name = map[int32]string{ 0: "OPAQUE_PRODUCT_STATUS_UNSPECIFIED", 1: "OPAQUE_PRODUCT_STATUS_DRAFT", 2: "OPAQUE_PRODUCT_STATUS_ACTIVE", 3: "OPAQUE_PRODUCT_STATUS_OUT_OF_STOCK", 4: "OPAQUE_PRODUCT_STATUS_DISCONTINUED", } OpaqueProduct_OpaqueProductStatus_value = map[string]int32{ "OPAQUE_PRODUCT_STATUS_UNSPECIFIED": 0, "OPAQUE_PRODUCT_STATUS_DRAFT": 1, "OPAQUE_PRODUCT_STATUS_ACTIVE": 2, "OPAQUE_PRODUCT_STATUS_OUT_OF_STOCK": 3, "OPAQUE_PRODUCT_STATUS_DISCONTINUED": 4, } ) func (x OpaqueProduct_OpaqueProductStatus) Enum() *OpaqueProduct_OpaqueProductStatus { p := new(OpaqueProduct_OpaqueProductStatus) *p = x return p } func (x OpaqueProduct_OpaqueProductStatus) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (OpaqueProduct_OpaqueProductStatus) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_examplepb_opaque_proto_enumTypes[2].Descriptor() } func (OpaqueProduct_OpaqueProductStatus) Type() protoreflect.EnumType { return &file_examples_internal_proto_examplepb_opaque_proto_enumTypes[2] } func (x OpaqueProduct_OpaqueProductStatus) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } type OpaqueProduct_OpaqueProductDimensions_OpaqueUnit int32 const ( OpaqueProduct_OpaqueProductDimensions_OPAQUE_UNIT_UNSPECIFIED OpaqueProduct_OpaqueProductDimensions_OpaqueUnit = 0 OpaqueProduct_OpaqueProductDimensions_OPAQUE_UNIT_METRIC OpaqueProduct_OpaqueProductDimensions_OpaqueUnit = 1 OpaqueProduct_OpaqueProductDimensions_OPAQUE_UNIT_IMPERIAL OpaqueProduct_OpaqueProductDimensions_OpaqueUnit = 2 ) // Enum value maps for OpaqueProduct_OpaqueProductDimensions_OpaqueUnit. var ( OpaqueProduct_OpaqueProductDimensions_OpaqueUnit_name = map[int32]string{ 0: "OPAQUE_UNIT_UNSPECIFIED", 1: "OPAQUE_UNIT_METRIC", 2: "OPAQUE_UNIT_IMPERIAL", } OpaqueProduct_OpaqueProductDimensions_OpaqueUnit_value = map[string]int32{ "OPAQUE_UNIT_UNSPECIFIED": 0, "OPAQUE_UNIT_METRIC": 1, "OPAQUE_UNIT_IMPERIAL": 2, } ) func (x OpaqueProduct_OpaqueProductDimensions_OpaqueUnit) Enum() *OpaqueProduct_OpaqueProductDimensions_OpaqueUnit { p := new(OpaqueProduct_OpaqueProductDimensions_OpaqueUnit) *p = x return p } func (x OpaqueProduct_OpaqueProductDimensions_OpaqueUnit) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (OpaqueProduct_OpaqueProductDimensions_OpaqueUnit) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_examplepb_opaque_proto_enumTypes[3].Descriptor() } func (OpaqueProduct_OpaqueProductDimensions_OpaqueUnit) Type() protoreflect.EnumType { return &file_examples_internal_proto_examplepb_opaque_proto_enumTypes[3] } func (x OpaqueProduct_OpaqueProductDimensions_OpaqueUnit) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } type OpaqueCustomer_OpaqueCustomerStatus int32 const ( OpaqueCustomer_OPAQUE_CUSTOMER_STATUS_UNSPECIFIED OpaqueCustomer_OpaqueCustomerStatus = 0 OpaqueCustomer_OPAQUE_CUSTOMER_STATUS_ACTIVE OpaqueCustomer_OpaqueCustomerStatus = 1 OpaqueCustomer_OPAQUE_CUSTOMER_STATUS_INACTIVE OpaqueCustomer_OpaqueCustomerStatus = 2 OpaqueCustomer_OPAQUE_CUSTOMER_STATUS_SUSPENDED OpaqueCustomer_OpaqueCustomerStatus = 3 OpaqueCustomer_OPAQUE_CUSTOMER_STATUS_DELETED OpaqueCustomer_OpaqueCustomerStatus = 4 ) // Enum value maps for OpaqueCustomer_OpaqueCustomerStatus. var ( OpaqueCustomer_OpaqueCustomerStatus_name = map[int32]string{ 0: "OPAQUE_CUSTOMER_STATUS_UNSPECIFIED", 1: "OPAQUE_CUSTOMER_STATUS_ACTIVE", 2: "OPAQUE_CUSTOMER_STATUS_INACTIVE", 3: "OPAQUE_CUSTOMER_STATUS_SUSPENDED", 4: "OPAQUE_CUSTOMER_STATUS_DELETED", } OpaqueCustomer_OpaqueCustomerStatus_value = map[string]int32{ "OPAQUE_CUSTOMER_STATUS_UNSPECIFIED": 0, "OPAQUE_CUSTOMER_STATUS_ACTIVE": 1, "OPAQUE_CUSTOMER_STATUS_INACTIVE": 2, "OPAQUE_CUSTOMER_STATUS_SUSPENDED": 3, "OPAQUE_CUSTOMER_STATUS_DELETED": 4, } ) func (x OpaqueCustomer_OpaqueCustomerStatus) Enum() *OpaqueCustomer_OpaqueCustomerStatus { p := new(OpaqueCustomer_OpaqueCustomerStatus) *p = x return p } func (x OpaqueCustomer_OpaqueCustomerStatus) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (OpaqueCustomer_OpaqueCustomerStatus) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_examplepb_opaque_proto_enumTypes[4].Descriptor() } func (OpaqueCustomer_OpaqueCustomerStatus) Type() protoreflect.EnumType { return &file_examples_internal_proto_examplepb_opaque_proto_enumTypes[4] } func (x OpaqueCustomer_OpaqueCustomerStatus) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } type OpaqueOrder_OpaqueOrderStatus int32 const ( OpaqueOrder_OPAQUE_ORDER_STATUS_UNSPECIFIED OpaqueOrder_OpaqueOrderStatus = 0 OpaqueOrder_OPAQUE_ORDER_STATUS_PENDING OpaqueOrder_OpaqueOrderStatus = 1 OpaqueOrder_OPAQUE_ORDER_STATUS_PROCESSING OpaqueOrder_OpaqueOrderStatus = 2 OpaqueOrder_OPAQUE_ORDER_STATUS_SHIPPED OpaqueOrder_OpaqueOrderStatus = 3 OpaqueOrder_OPAQUE_ORDER_STATUS_DELIVERED OpaqueOrder_OpaqueOrderStatus = 4 OpaqueOrder_OPAQUE_ORDER_STATUS_CANCELLED OpaqueOrder_OpaqueOrderStatus = 5 OpaqueOrder_OPAQUE_ORDER_STATUS_RETURNED OpaqueOrder_OpaqueOrderStatus = 6 ) // Enum value maps for OpaqueOrder_OpaqueOrderStatus. var ( OpaqueOrder_OpaqueOrderStatus_name = map[int32]string{ 0: "OPAQUE_ORDER_STATUS_UNSPECIFIED", 1: "OPAQUE_ORDER_STATUS_PENDING", 2: "OPAQUE_ORDER_STATUS_PROCESSING", 3: "OPAQUE_ORDER_STATUS_SHIPPED", 4: "OPAQUE_ORDER_STATUS_DELIVERED", 5: "OPAQUE_ORDER_STATUS_CANCELLED", 6: "OPAQUE_ORDER_STATUS_RETURNED", } OpaqueOrder_OpaqueOrderStatus_value = map[string]int32{ "OPAQUE_ORDER_STATUS_UNSPECIFIED": 0, "OPAQUE_ORDER_STATUS_PENDING": 1, "OPAQUE_ORDER_STATUS_PROCESSING": 2, "OPAQUE_ORDER_STATUS_SHIPPED": 3, "OPAQUE_ORDER_STATUS_DELIVERED": 4, "OPAQUE_ORDER_STATUS_CANCELLED": 5, "OPAQUE_ORDER_STATUS_RETURNED": 6, } ) func (x OpaqueOrder_OpaqueOrderStatus) Enum() *OpaqueOrder_OpaqueOrderStatus { p := new(OpaqueOrder_OpaqueOrderStatus) *p = x return p } func (x OpaqueOrder_OpaqueOrderStatus) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (OpaqueOrder_OpaqueOrderStatus) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_examplepb_opaque_proto_enumTypes[5].Descriptor() } func (OpaqueOrder_OpaqueOrderStatus) Type() protoreflect.EnumType { return &file_examples_internal_proto_examplepb_opaque_proto_enumTypes[5] } func (x OpaqueOrder_OpaqueOrderStatus) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } type OpaqueCustomerEvent_OpaqueEventType int32 const ( OpaqueCustomerEvent_OPAQUE_EVENT_TYPE_UNSPECIFIED OpaqueCustomerEvent_OpaqueEventType = 0 OpaqueCustomerEvent_OPAQUE_EVENT_TYPE_PAGE_VIEW OpaqueCustomerEvent_OpaqueEventType = 1 OpaqueCustomerEvent_OPAQUE_EVENT_TYPE_PRODUCT_VIEW OpaqueCustomerEvent_OpaqueEventType = 2 OpaqueCustomerEvent_OPAQUE_EVENT_TYPE_ADD_TO_CART OpaqueCustomerEvent_OpaqueEventType = 3 OpaqueCustomerEvent_OPAQUE_EVENT_TYPE_REMOVE_FROM_CART OpaqueCustomerEvent_OpaqueEventType = 4 OpaqueCustomerEvent_OPAQUE_EVENT_TYPE_CHECKOUT_START OpaqueCustomerEvent_OpaqueEventType = 5 OpaqueCustomerEvent_OPAQUE_EVENT_TYPE_CHECKOUT_COMPLETE OpaqueCustomerEvent_OpaqueEventType = 6 OpaqueCustomerEvent_OPAQUE_EVENT_TYPE_SEARCH OpaqueCustomerEvent_OpaqueEventType = 7 OpaqueCustomerEvent_OPAQUE_EVENT_TYPE_ACCOUNT_UPDATE OpaqueCustomerEvent_OpaqueEventType = 8 ) // Enum value maps for OpaqueCustomerEvent_OpaqueEventType. var ( OpaqueCustomerEvent_OpaqueEventType_name = map[int32]string{ 0: "OPAQUE_EVENT_TYPE_UNSPECIFIED", 1: "OPAQUE_EVENT_TYPE_PAGE_VIEW", 2: "OPAQUE_EVENT_TYPE_PRODUCT_VIEW", 3: "OPAQUE_EVENT_TYPE_ADD_TO_CART", 4: "OPAQUE_EVENT_TYPE_REMOVE_FROM_CART", 5: "OPAQUE_EVENT_TYPE_CHECKOUT_START", 6: "OPAQUE_EVENT_TYPE_CHECKOUT_COMPLETE", 7: "OPAQUE_EVENT_TYPE_SEARCH", 8: "OPAQUE_EVENT_TYPE_ACCOUNT_UPDATE", } OpaqueCustomerEvent_OpaqueEventType_value = map[string]int32{ "OPAQUE_EVENT_TYPE_UNSPECIFIED": 0, "OPAQUE_EVENT_TYPE_PAGE_VIEW": 1, "OPAQUE_EVENT_TYPE_PRODUCT_VIEW": 2, "OPAQUE_EVENT_TYPE_ADD_TO_CART": 3, "OPAQUE_EVENT_TYPE_REMOVE_FROM_CART": 4, "OPAQUE_EVENT_TYPE_CHECKOUT_START": 5, "OPAQUE_EVENT_TYPE_CHECKOUT_COMPLETE": 6, "OPAQUE_EVENT_TYPE_SEARCH": 7, "OPAQUE_EVENT_TYPE_ACCOUNT_UPDATE": 8, } ) func (x OpaqueCustomerEvent_OpaqueEventType) Enum() *OpaqueCustomerEvent_OpaqueEventType { p := new(OpaqueCustomerEvent_OpaqueEventType) *p = x return p } func (x OpaqueCustomerEvent_OpaqueEventType) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (OpaqueCustomerEvent_OpaqueEventType) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_examplepb_opaque_proto_enumTypes[6].Descriptor() } func (OpaqueCustomerEvent_OpaqueEventType) Type() protoreflect.EnumType { return &file_examples_internal_proto_examplepb_opaque_proto_enumTypes[6] } func (x OpaqueCustomerEvent_OpaqueEventType) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } type OpaqueActivityUpdate_OpaqueUpdateType int32 const ( OpaqueActivityUpdate_OPAQUE_UPDATE_TYPE_UNSPECIFIED OpaqueActivityUpdate_OpaqueUpdateType = 0 OpaqueActivityUpdate_OPAQUE_UPDATE_TYPE_RECOMMENDATION OpaqueActivityUpdate_OpaqueUpdateType = 1 OpaqueActivityUpdate_OPAQUE_UPDATE_TYPE_NOTIFICATION OpaqueActivityUpdate_OpaqueUpdateType = 2 OpaqueActivityUpdate_OPAQUE_UPDATE_TYPE_OFFER OpaqueActivityUpdate_OpaqueUpdateType = 3 OpaqueActivityUpdate_OPAQUE_UPDATE_TYPE_INVENTORY_UPDATE OpaqueActivityUpdate_OpaqueUpdateType = 4 OpaqueActivityUpdate_OPAQUE_UPDATE_TYPE_PRICE_CHANGE OpaqueActivityUpdate_OpaqueUpdateType = 5 OpaqueActivityUpdate_OPAQUE_UPDATE_TYPE_CART_REMINDER OpaqueActivityUpdate_OpaqueUpdateType = 6 ) // Enum value maps for OpaqueActivityUpdate_OpaqueUpdateType. var ( OpaqueActivityUpdate_OpaqueUpdateType_name = map[int32]string{ 0: "OPAQUE_UPDATE_TYPE_UNSPECIFIED", 1: "OPAQUE_UPDATE_TYPE_RECOMMENDATION", 2: "OPAQUE_UPDATE_TYPE_NOTIFICATION", 3: "OPAQUE_UPDATE_TYPE_OFFER", 4: "OPAQUE_UPDATE_TYPE_INVENTORY_UPDATE", 5: "OPAQUE_UPDATE_TYPE_PRICE_CHANGE", 6: "OPAQUE_UPDATE_TYPE_CART_REMINDER", } OpaqueActivityUpdate_OpaqueUpdateType_value = map[string]int32{ "OPAQUE_UPDATE_TYPE_UNSPECIFIED": 0, "OPAQUE_UPDATE_TYPE_RECOMMENDATION": 1, "OPAQUE_UPDATE_TYPE_NOTIFICATION": 2, "OPAQUE_UPDATE_TYPE_OFFER": 3, "OPAQUE_UPDATE_TYPE_INVENTORY_UPDATE": 4, "OPAQUE_UPDATE_TYPE_PRICE_CHANGE": 5, "OPAQUE_UPDATE_TYPE_CART_REMINDER": 6, } ) func (x OpaqueActivityUpdate_OpaqueUpdateType) Enum() *OpaqueActivityUpdate_OpaqueUpdateType { p := new(OpaqueActivityUpdate_OpaqueUpdateType) *p = x return p } func (x OpaqueActivityUpdate_OpaqueUpdateType) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (OpaqueActivityUpdate_OpaqueUpdateType) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_examplepb_opaque_proto_enumTypes[7].Descriptor() } func (OpaqueActivityUpdate_OpaqueUpdateType) Type() protoreflect.EnumType { return &file_examples_internal_proto_examplepb_opaque_proto_enumTypes[7] } func (x OpaqueActivityUpdate_OpaqueUpdateType) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // OpaqueUpdateProductRequest represents a request to update a product type OpaqueUpdateProductRequest struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Product *OpaqueProduct `protobuf:"bytes,1,opt,name=product"` xxx_hidden_UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,2,opt,name=update_mask,json=updateMask"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueUpdateProductRequest) Reset() { *x = OpaqueUpdateProductRequest{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueUpdateProductRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueUpdateProductRequest) ProtoMessage() {} func (x *OpaqueUpdateProductRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueUpdateProductRequest) GetProduct() *OpaqueProduct { if x != nil { return x.xxx_hidden_Product } return nil } func (x *OpaqueUpdateProductRequest) GetUpdateMask() *fieldmaskpb.FieldMask { if x != nil { return x.xxx_hidden_UpdateMask } return nil } func (x *OpaqueUpdateProductRequest) SetProduct(v *OpaqueProduct) { x.xxx_hidden_Product = v } func (x *OpaqueUpdateProductRequest) SetUpdateMask(v *fieldmaskpb.FieldMask) { x.xxx_hidden_UpdateMask = v } func (x *OpaqueUpdateProductRequest) HasProduct() bool { if x == nil { return false } return x.xxx_hidden_Product != nil } func (x *OpaqueUpdateProductRequest) HasUpdateMask() bool { if x == nil { return false } return x.xxx_hidden_UpdateMask != nil } func (x *OpaqueUpdateProductRequest) ClearProduct() { x.xxx_hidden_Product = nil } func (x *OpaqueUpdateProductRequest) ClearUpdateMask() { x.xxx_hidden_UpdateMask = nil } type OpaqueUpdateProductRequest_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Product *OpaqueProduct UpdateMask *fieldmaskpb.FieldMask } func (b0 OpaqueUpdateProductRequest_builder) Build() *OpaqueUpdateProductRequest { m0 := &OpaqueUpdateProductRequest{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Product = b.Product x.xxx_hidden_UpdateMask = b.UpdateMask return m0 } // OpaqueUpdateProductResponse represents the response for OpaqueUpdateProduct type OpaqueUpdateProductResponse struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Product *OpaqueProduct `protobuf:"bytes,1,opt,name=product"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueUpdateProductResponse) Reset() { *x = OpaqueUpdateProductResponse{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueUpdateProductResponse) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueUpdateProductResponse) ProtoMessage() {} func (x *OpaqueUpdateProductResponse) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueUpdateProductResponse) GetProduct() *OpaqueProduct { if x != nil { return x.xxx_hidden_Product } return nil } func (x *OpaqueUpdateProductResponse) SetProduct(v *OpaqueProduct) { x.xxx_hidden_Product = v } func (x *OpaqueUpdateProductResponse) HasProduct() bool { if x == nil { return false } return x.xxx_hidden_Product != nil } func (x *OpaqueUpdateProductResponse) ClearProduct() { x.xxx_hidden_Product = nil } type OpaqueUpdateProductResponse_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Product *OpaqueProduct } func (b0 OpaqueUpdateProductResponse_builder) Build() *OpaqueUpdateProductResponse { m0 := &OpaqueUpdateProductResponse{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Product = b.Product return m0 } // OpaqueGetProductRequest represents a request for product information type OpaqueGetProductRequest struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_ProductId *string `protobuf:"bytes,1,opt,name=product_id,json=productId"` xxx_hidden_IncludeVariants bool `protobuf:"varint,2,opt,name=include_variants,json=includeVariants"` xxx_hidden_IncludeRelatedProducts bool `protobuf:"varint,3,opt,name=include_related_products,json=includeRelatedProducts"` xxx_hidden_LanguageCode *string `protobuf:"bytes,4,opt,name=language_code,json=languageCode"` xxx_hidden_CurrencyCode *string `protobuf:"bytes,5,opt,name=currency_code,json=currencyCode"` XXX_raceDetectHookData protoimpl.RaceDetectHookData XXX_presence [1]uint32 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueGetProductRequest) Reset() { *x = OpaqueGetProductRequest{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueGetProductRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueGetProductRequest) ProtoMessage() {} func (x *OpaqueGetProductRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueGetProductRequest) GetProductId() string { if x != nil { if x.xxx_hidden_ProductId != nil { return *x.xxx_hidden_ProductId } return "" } return "" } func (x *OpaqueGetProductRequest) GetIncludeVariants() bool { if x != nil { return x.xxx_hidden_IncludeVariants } return false } func (x *OpaqueGetProductRequest) GetIncludeRelatedProducts() bool { if x != nil { return x.xxx_hidden_IncludeRelatedProducts } return false } func (x *OpaqueGetProductRequest) GetLanguageCode() string { if x != nil { if x.xxx_hidden_LanguageCode != nil { return *x.xxx_hidden_LanguageCode } return "" } return "" } func (x *OpaqueGetProductRequest) GetCurrencyCode() string { if x != nil { if x.xxx_hidden_CurrencyCode != nil { return *x.xxx_hidden_CurrencyCode } return "" } return "" } func (x *OpaqueGetProductRequest) SetProductId(v string) { x.xxx_hidden_ProductId = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 5) } func (x *OpaqueGetProductRequest) SetIncludeVariants(v bool) { x.xxx_hidden_IncludeVariants = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 5) } func (x *OpaqueGetProductRequest) SetIncludeRelatedProducts(v bool) { x.xxx_hidden_IncludeRelatedProducts = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 2, 5) } func (x *OpaqueGetProductRequest) SetLanguageCode(v string) { x.xxx_hidden_LanguageCode = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 3, 5) } func (x *OpaqueGetProductRequest) SetCurrencyCode(v string) { x.xxx_hidden_CurrencyCode = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 4, 5) } func (x *OpaqueGetProductRequest) HasProductId() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 0) } func (x *OpaqueGetProductRequest) HasIncludeVariants() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 1) } func (x *OpaqueGetProductRequest) HasIncludeRelatedProducts() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 2) } func (x *OpaqueGetProductRequest) HasLanguageCode() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 3) } func (x *OpaqueGetProductRequest) HasCurrencyCode() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 4) } func (x *OpaqueGetProductRequest) ClearProductId() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) x.xxx_hidden_ProductId = nil } func (x *OpaqueGetProductRequest) ClearIncludeVariants() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) x.xxx_hidden_IncludeVariants = false } func (x *OpaqueGetProductRequest) ClearIncludeRelatedProducts() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 2) x.xxx_hidden_IncludeRelatedProducts = false } func (x *OpaqueGetProductRequest) ClearLanguageCode() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 3) x.xxx_hidden_LanguageCode = nil } func (x *OpaqueGetProductRequest) ClearCurrencyCode() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 4) x.xxx_hidden_CurrencyCode = nil } type OpaqueGetProductRequest_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. ProductId *string IncludeVariants *bool IncludeRelatedProducts *bool LanguageCode *string CurrencyCode *string } func (b0 OpaqueGetProductRequest_builder) Build() *OpaqueGetProductRequest { m0 := &OpaqueGetProductRequest{} b, x := &b0, m0 _, _ = b, x if b.ProductId != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 5) x.xxx_hidden_ProductId = b.ProductId } if b.IncludeVariants != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 5) x.xxx_hidden_IncludeVariants = *b.IncludeVariants } if b.IncludeRelatedProducts != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 2, 5) x.xxx_hidden_IncludeRelatedProducts = *b.IncludeRelatedProducts } if b.LanguageCode != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 3, 5) x.xxx_hidden_LanguageCode = b.LanguageCode } if b.CurrencyCode != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 4, 5) x.xxx_hidden_CurrencyCode = b.CurrencyCode } return m0 } // OpaqueGetProductResponse represents a response with product information type OpaqueGetProductResponse struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Product *OpaqueProduct `protobuf:"bytes,1,opt,name=product"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueGetProductResponse) Reset() { *x = OpaqueGetProductResponse{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueGetProductResponse) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueGetProductResponse) ProtoMessage() {} func (x *OpaqueGetProductResponse) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueGetProductResponse) GetProduct() *OpaqueProduct { if x != nil { return x.xxx_hidden_Product } return nil } func (x *OpaqueGetProductResponse) SetProduct(v *OpaqueProduct) { x.xxx_hidden_Product = v } func (x *OpaqueGetProductResponse) HasProduct() bool { if x == nil { return false } return x.xxx_hidden_Product != nil } func (x *OpaqueGetProductResponse) ClearProduct() { x.xxx_hidden_Product = nil } type OpaqueGetProductResponse_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Product *OpaqueProduct } func (b0 OpaqueGetProductResponse_builder) Build() *OpaqueGetProductResponse { m0 := &OpaqueGetProductResponse{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Product = b.Product return m0 } // OpaqueSearchProductsRequest represents a product search request type OpaqueSearchProductsRequest struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Query *string `protobuf:"bytes,1,opt,name=query"` xxx_hidden_CategoryIds []string `protobuf:"bytes,2,rep,name=category_ids,json=categoryIds"` xxx_hidden_Brands []string `protobuf:"bytes,3,rep,name=brands"` xxx_hidden_MinPrice *OpaquePrice `protobuf:"bytes,4,opt,name=min_price,json=minPrice"` xxx_hidden_MaxPrice *OpaquePrice `protobuf:"bytes,5,opt,name=max_price,json=maxPrice"` xxx_hidden_Tags []string `protobuf:"bytes,6,rep,name=tags"` xxx_hidden_SortBy OpaqueSearchProductsRequest_OpaqueSortOrder `protobuf:"varint,7,opt,name=sort_by,json=sortBy,enum=grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchProductsRequest_OpaqueSortOrder"` xxx_hidden_Page int32 `protobuf:"varint,8,opt,name=page"` xxx_hidden_PageSize int32 `protobuf:"varint,9,opt,name=page_size,json=pageSize"` xxx_hidden_LanguageCode *string `protobuf:"bytes,10,opt,name=language_code,json=languageCode"` xxx_hidden_CurrencyCode *string `protobuf:"bytes,11,opt,name=currency_code,json=currencyCode"` xxx_hidden_FieldMask *fieldmaskpb.FieldMask `protobuf:"bytes,12,opt,name=field_mask,json=fieldMask"` xxx_hidden_Filters map[string]string `protobuf:"bytes,13,rep,name=filters" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` XXX_raceDetectHookData protoimpl.RaceDetectHookData XXX_presence [1]uint32 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueSearchProductsRequest) Reset() { *x = OpaqueSearchProductsRequest{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueSearchProductsRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueSearchProductsRequest) ProtoMessage() {} func (x *OpaqueSearchProductsRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueSearchProductsRequest) GetQuery() string { if x != nil { if x.xxx_hidden_Query != nil { return *x.xxx_hidden_Query } return "" } return "" } func (x *OpaqueSearchProductsRequest) GetCategoryIds() []string { if x != nil { return x.xxx_hidden_CategoryIds } return nil } func (x *OpaqueSearchProductsRequest) GetBrands() []string { if x != nil { return x.xxx_hidden_Brands } return nil } func (x *OpaqueSearchProductsRequest) GetMinPrice() *OpaquePrice { if x != nil { return x.xxx_hidden_MinPrice } return nil } func (x *OpaqueSearchProductsRequest) GetMaxPrice() *OpaquePrice { if x != nil { return x.xxx_hidden_MaxPrice } return nil } func (x *OpaqueSearchProductsRequest) GetTags() []string { if x != nil { return x.xxx_hidden_Tags } return nil } func (x *OpaqueSearchProductsRequest) GetSortBy() OpaqueSearchProductsRequest_OpaqueSortOrder { if x != nil { if protoimpl.X.Present(&(x.XXX_presence[0]), 6) { return x.xxx_hidden_SortBy } } return OpaqueSearchProductsRequest_OPAQUE_SORT_ORDER_UNSPECIFIED } func (x *OpaqueSearchProductsRequest) GetPage() int32 { if x != nil { return x.xxx_hidden_Page } return 0 } func (x *OpaqueSearchProductsRequest) GetPageSize() int32 { if x != nil { return x.xxx_hidden_PageSize } return 0 } func (x *OpaqueSearchProductsRequest) GetLanguageCode() string { if x != nil { if x.xxx_hidden_LanguageCode != nil { return *x.xxx_hidden_LanguageCode } return "" } return "" } func (x *OpaqueSearchProductsRequest) GetCurrencyCode() string { if x != nil { if x.xxx_hidden_CurrencyCode != nil { return *x.xxx_hidden_CurrencyCode } return "" } return "" } func (x *OpaqueSearchProductsRequest) GetFieldMask() *fieldmaskpb.FieldMask { if x != nil { return x.xxx_hidden_FieldMask } return nil } func (x *OpaqueSearchProductsRequest) GetFilters() map[string]string { if x != nil { return x.xxx_hidden_Filters } return nil } func (x *OpaqueSearchProductsRequest) SetQuery(v string) { x.xxx_hidden_Query = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 13) } func (x *OpaqueSearchProductsRequest) SetCategoryIds(v []string) { x.xxx_hidden_CategoryIds = v } func (x *OpaqueSearchProductsRequest) SetBrands(v []string) { x.xxx_hidden_Brands = v } func (x *OpaqueSearchProductsRequest) SetMinPrice(v *OpaquePrice) { x.xxx_hidden_MinPrice = v } func (x *OpaqueSearchProductsRequest) SetMaxPrice(v *OpaquePrice) { x.xxx_hidden_MaxPrice = v } func (x *OpaqueSearchProductsRequest) SetTags(v []string) { x.xxx_hidden_Tags = v } func (x *OpaqueSearchProductsRequest) SetSortBy(v OpaqueSearchProductsRequest_OpaqueSortOrder) { x.xxx_hidden_SortBy = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 6, 13) } func (x *OpaqueSearchProductsRequest) SetPage(v int32) { x.xxx_hidden_Page = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 7, 13) } func (x *OpaqueSearchProductsRequest) SetPageSize(v int32) { x.xxx_hidden_PageSize = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 8, 13) } func (x *OpaqueSearchProductsRequest) SetLanguageCode(v string) { x.xxx_hidden_LanguageCode = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 9, 13) } func (x *OpaqueSearchProductsRequest) SetCurrencyCode(v string) { x.xxx_hidden_CurrencyCode = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 10, 13) } func (x *OpaqueSearchProductsRequest) SetFieldMask(v *fieldmaskpb.FieldMask) { x.xxx_hidden_FieldMask = v } func (x *OpaqueSearchProductsRequest) SetFilters(v map[string]string) { x.xxx_hidden_Filters = v } func (x *OpaqueSearchProductsRequest) HasQuery() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 0) } func (x *OpaqueSearchProductsRequest) HasMinPrice() bool { if x == nil { return false } return x.xxx_hidden_MinPrice != nil } func (x *OpaqueSearchProductsRequest) HasMaxPrice() bool { if x == nil { return false } return x.xxx_hidden_MaxPrice != nil } func (x *OpaqueSearchProductsRequest) HasSortBy() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 6) } func (x *OpaqueSearchProductsRequest) HasPage() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 7) } func (x *OpaqueSearchProductsRequest) HasPageSize() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 8) } func (x *OpaqueSearchProductsRequest) HasLanguageCode() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 9) } func (x *OpaqueSearchProductsRequest) HasCurrencyCode() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 10) } func (x *OpaqueSearchProductsRequest) HasFieldMask() bool { if x == nil { return false } return x.xxx_hidden_FieldMask != nil } func (x *OpaqueSearchProductsRequest) ClearQuery() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) x.xxx_hidden_Query = nil } func (x *OpaqueSearchProductsRequest) ClearMinPrice() { x.xxx_hidden_MinPrice = nil } func (x *OpaqueSearchProductsRequest) ClearMaxPrice() { x.xxx_hidden_MaxPrice = nil } func (x *OpaqueSearchProductsRequest) ClearSortBy() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 6) x.xxx_hidden_SortBy = OpaqueSearchProductsRequest_OPAQUE_SORT_ORDER_UNSPECIFIED } func (x *OpaqueSearchProductsRequest) ClearPage() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 7) x.xxx_hidden_Page = 0 } func (x *OpaqueSearchProductsRequest) ClearPageSize() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 8) x.xxx_hidden_PageSize = 0 } func (x *OpaqueSearchProductsRequest) ClearLanguageCode() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 9) x.xxx_hidden_LanguageCode = nil } func (x *OpaqueSearchProductsRequest) ClearCurrencyCode() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 10) x.xxx_hidden_CurrencyCode = nil } func (x *OpaqueSearchProductsRequest) ClearFieldMask() { x.xxx_hidden_FieldMask = nil } type OpaqueSearchProductsRequest_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Query *string CategoryIds []string Brands []string MinPrice *OpaquePrice MaxPrice *OpaquePrice Tags []string SortBy *OpaqueSearchProductsRequest_OpaqueSortOrder Page *int32 PageSize *int32 LanguageCode *string CurrencyCode *string FieldMask *fieldmaskpb.FieldMask Filters map[string]string } func (b0 OpaqueSearchProductsRequest_builder) Build() *OpaqueSearchProductsRequest { m0 := &OpaqueSearchProductsRequest{} b, x := &b0, m0 _, _ = b, x if b.Query != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 13) x.xxx_hidden_Query = b.Query } x.xxx_hidden_CategoryIds = b.CategoryIds x.xxx_hidden_Brands = b.Brands x.xxx_hidden_MinPrice = b.MinPrice x.xxx_hidden_MaxPrice = b.MaxPrice x.xxx_hidden_Tags = b.Tags if b.SortBy != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 6, 13) x.xxx_hidden_SortBy = *b.SortBy } if b.Page != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 7, 13) x.xxx_hidden_Page = *b.Page } if b.PageSize != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 8, 13) x.xxx_hidden_PageSize = *b.PageSize } if b.LanguageCode != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 9, 13) x.xxx_hidden_LanguageCode = b.LanguageCode } if b.CurrencyCode != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 10, 13) x.xxx_hidden_CurrencyCode = b.CurrencyCode } x.xxx_hidden_FieldMask = b.FieldMask x.xxx_hidden_Filters = b.Filters return m0 } // OpaqueSearchProductsResponse represents a single product in search results type OpaqueSearchProductsResponse struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Product *OpaqueProduct `protobuf:"bytes,1,opt,name=product"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueSearchProductsResponse) Reset() { *x = OpaqueSearchProductsResponse{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueSearchProductsResponse) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueSearchProductsResponse) ProtoMessage() {} func (x *OpaqueSearchProductsResponse) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueSearchProductsResponse) GetProduct() *OpaqueProduct { if x != nil { return x.xxx_hidden_Product } return nil } func (x *OpaqueSearchProductsResponse) SetProduct(v *OpaqueProduct) { x.xxx_hidden_Product = v } func (x *OpaqueSearchProductsResponse) HasProduct() bool { if x == nil { return false } return x.xxx_hidden_Product != nil } func (x *OpaqueSearchProductsResponse) ClearProduct() { x.xxx_hidden_Product = nil } type OpaqueSearchProductsResponse_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Product *OpaqueProduct } func (b0 OpaqueSearchProductsResponse_builder) Build() *OpaqueSearchProductsResponse { m0 := &OpaqueSearchProductsResponse{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Product = b.Product return m0 } // OpaqueCreateProductRequest represents a request to create a product type OpaqueCreateProductRequest struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_ProductId *string `protobuf:"bytes,1,opt,name=product_id,json=productId"` xxx_hidden_Product *OpaqueProduct `protobuf:"bytes,2,opt,name=product"` XXX_raceDetectHookData protoimpl.RaceDetectHookData XXX_presence [1]uint32 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueCreateProductRequest) Reset() { *x = OpaqueCreateProductRequest{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueCreateProductRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueCreateProductRequest) ProtoMessage() {} func (x *OpaqueCreateProductRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueCreateProductRequest) GetProductId() string { if x != nil { if x.xxx_hidden_ProductId != nil { return *x.xxx_hidden_ProductId } return "" } return "" } func (x *OpaqueCreateProductRequest) GetProduct() *OpaqueProduct { if x != nil { return x.xxx_hidden_Product } return nil } func (x *OpaqueCreateProductRequest) SetProductId(v string) { x.xxx_hidden_ProductId = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 2) } func (x *OpaqueCreateProductRequest) SetProduct(v *OpaqueProduct) { x.xxx_hidden_Product = v } func (x *OpaqueCreateProductRequest) HasProductId() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 0) } func (x *OpaqueCreateProductRequest) HasProduct() bool { if x == nil { return false } return x.xxx_hidden_Product != nil } func (x *OpaqueCreateProductRequest) ClearProductId() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) x.xxx_hidden_ProductId = nil } func (x *OpaqueCreateProductRequest) ClearProduct() { x.xxx_hidden_Product = nil } type OpaqueCreateProductRequest_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. ProductId *string Product *OpaqueProduct } func (b0 OpaqueCreateProductRequest_builder) Build() *OpaqueCreateProductRequest { m0 := &OpaqueCreateProductRequest{} b, x := &b0, m0 _, _ = b, x if b.ProductId != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 2) x.xxx_hidden_ProductId = b.ProductId } x.xxx_hidden_Product = b.Product return m0 } // OpaqueCreateProductResponse represents the created product type OpaqueCreateProductResponse struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Product *OpaqueProduct `protobuf:"bytes,1,opt,name=product"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueCreateProductResponse) Reset() { *x = OpaqueCreateProductResponse{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueCreateProductResponse) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueCreateProductResponse) ProtoMessage() {} func (x *OpaqueCreateProductResponse) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueCreateProductResponse) GetProduct() *OpaqueProduct { if x != nil { return x.xxx_hidden_Product } return nil } func (x *OpaqueCreateProductResponse) SetProduct(v *OpaqueProduct) { x.xxx_hidden_Product = v } func (x *OpaqueCreateProductResponse) HasProduct() bool { if x == nil { return false } return x.xxx_hidden_Product != nil } func (x *OpaqueCreateProductResponse) ClearProduct() { x.xxx_hidden_Product = nil } type OpaqueCreateProductResponse_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Product *OpaqueProduct } func (b0 OpaqueCreateProductResponse_builder) Build() *OpaqueCreateProductResponse { m0 := &OpaqueCreateProductResponse{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Product = b.Product return m0 } // OpaqueCreateProductFieldRequest represents a request to create a product type OpaqueCreateProductFieldRequest struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_ProductId *string `protobuf:"bytes,1,opt,name=product_id,json=productId"` xxx_hidden_Product *OpaqueProduct `protobuf:"bytes,2,opt,name=product"` XXX_raceDetectHookData protoimpl.RaceDetectHookData XXX_presence [1]uint32 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueCreateProductFieldRequest) Reset() { *x = OpaqueCreateProductFieldRequest{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueCreateProductFieldRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueCreateProductFieldRequest) ProtoMessage() {} func (x *OpaqueCreateProductFieldRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueCreateProductFieldRequest) GetProductId() string { if x != nil { if x.xxx_hidden_ProductId != nil { return *x.xxx_hidden_ProductId } return "" } return "" } func (x *OpaqueCreateProductFieldRequest) GetProduct() *OpaqueProduct { if x != nil { return x.xxx_hidden_Product } return nil } func (x *OpaqueCreateProductFieldRequest) SetProductId(v string) { x.xxx_hidden_ProductId = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 2) } func (x *OpaqueCreateProductFieldRequest) SetProduct(v *OpaqueProduct) { x.xxx_hidden_Product = v } func (x *OpaqueCreateProductFieldRequest) HasProductId() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 0) } func (x *OpaqueCreateProductFieldRequest) HasProduct() bool { if x == nil { return false } return x.xxx_hidden_Product != nil } func (x *OpaqueCreateProductFieldRequest) ClearProductId() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) x.xxx_hidden_ProductId = nil } func (x *OpaqueCreateProductFieldRequest) ClearProduct() { x.xxx_hidden_Product = nil } type OpaqueCreateProductFieldRequest_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. ProductId *string Product *OpaqueProduct } func (b0 OpaqueCreateProductFieldRequest_builder) Build() *OpaqueCreateProductFieldRequest { m0 := &OpaqueCreateProductFieldRequest{} b, x := &b0, m0 _, _ = b, x if b.ProductId != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 2) x.xxx_hidden_ProductId = b.ProductId } x.xxx_hidden_Product = b.Product return m0 } // OpaqueCreateProductFieldResponse represents the created product type OpaqueCreateProductFieldResponse struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Product *OpaqueProduct `protobuf:"bytes,1,opt,name=product"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueCreateProductFieldResponse) Reset() { *x = OpaqueCreateProductFieldResponse{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueCreateProductFieldResponse) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueCreateProductFieldResponse) ProtoMessage() {} func (x *OpaqueCreateProductFieldResponse) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueCreateProductFieldResponse) GetProduct() *OpaqueProduct { if x != nil { return x.xxx_hidden_Product } return nil } func (x *OpaqueCreateProductFieldResponse) SetProduct(v *OpaqueProduct) { x.xxx_hidden_Product = v } func (x *OpaqueCreateProductFieldResponse) HasProduct() bool { if x == nil { return false } return x.xxx_hidden_Product != nil } func (x *OpaqueCreateProductFieldResponse) ClearProduct() { x.xxx_hidden_Product = nil } type OpaqueCreateProductFieldResponse_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Product *OpaqueProduct } func (b0 OpaqueCreateProductFieldResponse_builder) Build() *OpaqueCreateProductFieldResponse { m0 := &OpaqueCreateProductFieldResponse{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Product = b.Product return m0 } // OpaqueProcessOrdersRequest represents a request to process order type OpaqueProcessOrdersRequest struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Order *OpaqueOrder `protobuf:"bytes,1,opt,name=order"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueProcessOrdersRequest) Reset() { *x = OpaqueProcessOrdersRequest{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueProcessOrdersRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueProcessOrdersRequest) ProtoMessage() {} func (x *OpaqueProcessOrdersRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueProcessOrdersRequest) GetOrder() *OpaqueOrder { if x != nil { return x.xxx_hidden_Order } return nil } func (x *OpaqueProcessOrdersRequest) SetOrder(v *OpaqueOrder) { x.xxx_hidden_Order = v } func (x *OpaqueProcessOrdersRequest) HasOrder() bool { if x == nil { return false } return x.xxx_hidden_Order != nil } func (x *OpaqueProcessOrdersRequest) ClearOrder() { x.xxx_hidden_Order = nil } type OpaqueProcessOrdersRequest_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Order *OpaqueOrder } func (b0 OpaqueProcessOrdersRequest_builder) Build() *OpaqueProcessOrdersRequest { m0 := &OpaqueProcessOrdersRequest{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Order = b.Order return m0 } // OpaqueProcessOrdersResponse represents orders processing result type OpaqueProcessOrdersResponse struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Summary *OpaqueOrderSummary `protobuf:"bytes,1,opt,name=summary"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueProcessOrdersResponse) Reset() { *x = OpaqueProcessOrdersResponse{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueProcessOrdersResponse) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueProcessOrdersResponse) ProtoMessage() {} func (x *OpaqueProcessOrdersResponse) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueProcessOrdersResponse) GetSummary() *OpaqueOrderSummary { if x != nil { return x.xxx_hidden_Summary } return nil } func (x *OpaqueProcessOrdersResponse) SetSummary(v *OpaqueOrderSummary) { x.xxx_hidden_Summary = v } func (x *OpaqueProcessOrdersResponse) HasSummary() bool { if x == nil { return false } return x.xxx_hidden_Summary != nil } func (x *OpaqueProcessOrdersResponse) ClearSummary() { x.xxx_hidden_Summary = nil } type OpaqueProcessOrdersResponse_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Summary *OpaqueOrderSummary } func (b0 OpaqueProcessOrdersResponse_builder) Build() *OpaqueProcessOrdersResponse { m0 := &OpaqueProcessOrdersResponse{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Summary = b.Summary return m0 } // OpaqueStreamCustomerActivityRequest represents a report of user activity type OpaqueStreamCustomerActivityRequest struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Event *OpaqueCustomerEvent `protobuf:"bytes,1,opt,name=event"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueStreamCustomerActivityRequest) Reset() { *x = OpaqueStreamCustomerActivityRequest{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueStreamCustomerActivityRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueStreamCustomerActivityRequest) ProtoMessage() {} func (x *OpaqueStreamCustomerActivityRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueStreamCustomerActivityRequest) GetEvent() *OpaqueCustomerEvent { if x != nil { return x.xxx_hidden_Event } return nil } func (x *OpaqueStreamCustomerActivityRequest) SetEvent(v *OpaqueCustomerEvent) { x.xxx_hidden_Event = v } func (x *OpaqueStreamCustomerActivityRequest) HasEvent() bool { if x == nil { return false } return x.xxx_hidden_Event != nil } func (x *OpaqueStreamCustomerActivityRequest) ClearEvent() { x.xxx_hidden_Event = nil } type OpaqueStreamCustomerActivityRequest_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Event *OpaqueCustomerEvent } func (b0 OpaqueStreamCustomerActivityRequest_builder) Build() *OpaqueStreamCustomerActivityRequest { m0 := &OpaqueStreamCustomerActivityRequest{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Event = b.Event return m0 } // OpaqueStreamCustomerActivityRequest represents a report of server activity type OpaqueStreamCustomerActivityResponse struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Event *OpaqueActivityUpdate `protobuf:"bytes,2,opt,name=event"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueStreamCustomerActivityResponse) Reset() { *x = OpaqueStreamCustomerActivityResponse{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueStreamCustomerActivityResponse) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueStreamCustomerActivityResponse) ProtoMessage() {} func (x *OpaqueStreamCustomerActivityResponse) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueStreamCustomerActivityResponse) GetEvent() *OpaqueActivityUpdate { if x != nil { return x.xxx_hidden_Event } return nil } func (x *OpaqueStreamCustomerActivityResponse) SetEvent(v *OpaqueActivityUpdate) { x.xxx_hidden_Event = v } func (x *OpaqueStreamCustomerActivityResponse) HasEvent() bool { if x == nil { return false } return x.xxx_hidden_Event != nil } func (x *OpaqueStreamCustomerActivityResponse) ClearEvent() { x.xxx_hidden_Event = nil } type OpaqueStreamCustomerActivityResponse_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Event *OpaqueActivityUpdate } func (b0 OpaqueStreamCustomerActivityResponse_builder) Build() *OpaqueStreamCustomerActivityResponse { m0 := &OpaqueStreamCustomerActivityResponse{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Event = b.Event return m0 } // OpaqueSearchOrdersRequest represents queryable information to find orders type OpaqueSearchOrdersRequest struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Order *OpaqueOrder `protobuf:"bytes,1,opt,name=order"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueSearchOrdersRequest) Reset() { *x = OpaqueSearchOrdersRequest{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueSearchOrdersRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueSearchOrdersRequest) ProtoMessage() {} func (x *OpaqueSearchOrdersRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueSearchOrdersRequest) GetOrder() *OpaqueOrder { if x != nil { return x.xxx_hidden_Order } return nil } func (x *OpaqueSearchOrdersRequest) SetOrder(v *OpaqueOrder) { x.xxx_hidden_Order = v } func (x *OpaqueSearchOrdersRequest) HasOrder() bool { if x == nil { return false } return x.xxx_hidden_Order != nil } func (x *OpaqueSearchOrdersRequest) ClearOrder() { x.xxx_hidden_Order = nil } type OpaqueSearchOrdersRequest_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Order *OpaqueOrder } func (b0 OpaqueSearchOrdersRequest_builder) Build() *OpaqueSearchOrdersRequest { m0 := &OpaqueSearchOrdersRequest{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Order = b.Order return m0 } // OpaqueSearchOrdersResponse represents a list of orders found type OpaqueSearchOrdersResponse struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Orders *[]*OpaqueOrder `protobuf:"bytes,1,rep,name=orders"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueSearchOrdersResponse) Reset() { *x = OpaqueSearchOrdersResponse{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueSearchOrdersResponse) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueSearchOrdersResponse) ProtoMessage() {} func (x *OpaqueSearchOrdersResponse) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueSearchOrdersResponse) GetOrders() []*OpaqueOrder { if x != nil { if x.xxx_hidden_Orders != nil { return *x.xxx_hidden_Orders } } return nil } func (x *OpaqueSearchOrdersResponse) SetOrders(v []*OpaqueOrder) { x.xxx_hidden_Orders = &v } type OpaqueSearchOrdersResponse_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Orders []*OpaqueOrder } func (b0 OpaqueSearchOrdersResponse_builder) Build() *OpaqueSearchOrdersResponse { m0 := &OpaqueSearchOrdersResponse{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Orders = &b.Orders return m0 } // OpaqueEchoNoteRequest demonstrates an opaque body that maps to a foreign message. type OpaqueEchoNoteRequest struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Note *sub.StringMessage `protobuf:"bytes,1,opt,name=note"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueEchoNoteRequest) Reset() { *x = OpaqueEchoNoteRequest{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueEchoNoteRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueEchoNoteRequest) ProtoMessage() {} func (x *OpaqueEchoNoteRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueEchoNoteRequest) GetNote() *sub.StringMessage { if x != nil { return x.xxx_hidden_Note } return nil } func (x *OpaqueEchoNoteRequest) SetNote(v *sub.StringMessage) { x.xxx_hidden_Note = v } func (x *OpaqueEchoNoteRequest) HasNote() bool { if x == nil { return false } return x.xxx_hidden_Note != nil } func (x *OpaqueEchoNoteRequest) ClearNote() { x.xxx_hidden_Note = nil } type OpaqueEchoNoteRequest_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Note *sub.StringMessage } func (b0 OpaqueEchoNoteRequest_builder) Build() *OpaqueEchoNoteRequest { m0 := &OpaqueEchoNoteRequest{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Note = b.Note return m0 } // OpaqueEchoNoteResponse mirrors the request payload for simplicity. type OpaqueEchoNoteResponse struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Note *sub.StringMessage `protobuf:"bytes,1,opt,name=note"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueEchoNoteResponse) Reset() { *x = OpaqueEchoNoteResponse{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueEchoNoteResponse) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueEchoNoteResponse) ProtoMessage() {} func (x *OpaqueEchoNoteResponse) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueEchoNoteResponse) GetNote() *sub.StringMessage { if x != nil { return x.xxx_hidden_Note } return nil } func (x *OpaqueEchoNoteResponse) SetNote(v *sub.StringMessage) { x.xxx_hidden_Note = v } func (x *OpaqueEchoNoteResponse) HasNote() bool { if x == nil { return false } return x.xxx_hidden_Note != nil } func (x *OpaqueEchoNoteResponse) ClearNote() { x.xxx_hidden_Note = nil } type OpaqueEchoNoteResponse_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Note *sub.StringMessage } func (b0 OpaqueEchoNoteResponse_builder) Build() *OpaqueEchoNoteResponse { m0 := &OpaqueEchoNoteResponse{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Note = b.Note return m0 } // OpaqueAddress represents a physical address type OpaqueAddress struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_StreetLine1 *string `protobuf:"bytes,1,opt,name=street_line1,json=streetLine1"` xxx_hidden_StreetLine2 *string `protobuf:"bytes,2,opt,name=street_line2,json=streetLine2"` xxx_hidden_City *string `protobuf:"bytes,3,opt,name=city"` xxx_hidden_State *string `protobuf:"bytes,4,opt,name=state"` xxx_hidden_Country *string `protobuf:"bytes,5,opt,name=country"` xxx_hidden_PostalCode *string `protobuf:"bytes,6,opt,name=postal_code,json=postalCode"` xxx_hidden_AddressType OpaqueAddress_OpaqueAddressType `protobuf:"varint,7,opt,name=address_type,json=addressType,enum=grpc.gateway.examples.internal.proto.examplepb.OpaqueAddress_OpaqueAddressType"` xxx_hidden_IsDefault *wrapperspb.BoolValue `protobuf:"bytes,8,opt,name=is_default,json=isDefault"` xxx_hidden_Metadata map[string]string `protobuf:"bytes,9,rep,name=metadata" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` XXX_raceDetectHookData protoimpl.RaceDetectHookData XXX_presence [1]uint32 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueAddress) Reset() { *x = OpaqueAddress{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueAddress) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueAddress) ProtoMessage() {} func (x *OpaqueAddress) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueAddress) GetStreetLine1() string { if x != nil { if x.xxx_hidden_StreetLine1 != nil { return *x.xxx_hidden_StreetLine1 } return "" } return "" } func (x *OpaqueAddress) GetStreetLine2() string { if x != nil { if x.xxx_hidden_StreetLine2 != nil { return *x.xxx_hidden_StreetLine2 } return "" } return "" } func (x *OpaqueAddress) GetCity() string { if x != nil { if x.xxx_hidden_City != nil { return *x.xxx_hidden_City } return "" } return "" } func (x *OpaqueAddress) GetState() string { if x != nil { if x.xxx_hidden_State != nil { return *x.xxx_hidden_State } return "" } return "" } func (x *OpaqueAddress) GetCountry() string { if x != nil { if x.xxx_hidden_Country != nil { return *x.xxx_hidden_Country } return "" } return "" } func (x *OpaqueAddress) GetPostalCode() string { if x != nil { if x.xxx_hidden_PostalCode != nil { return *x.xxx_hidden_PostalCode } return "" } return "" } func (x *OpaqueAddress) GetAddressType() OpaqueAddress_OpaqueAddressType { if x != nil { if protoimpl.X.Present(&(x.XXX_presence[0]), 6) { return x.xxx_hidden_AddressType } } return OpaqueAddress_OPAQUE_ADDRESS_TYPE_UNSPECIFIED } func (x *OpaqueAddress) GetIsDefault() *wrapperspb.BoolValue { if x != nil { return x.xxx_hidden_IsDefault } return nil } func (x *OpaqueAddress) GetMetadata() map[string]string { if x != nil { return x.xxx_hidden_Metadata } return nil } func (x *OpaqueAddress) SetStreetLine1(v string) { x.xxx_hidden_StreetLine1 = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 9) } func (x *OpaqueAddress) SetStreetLine2(v string) { x.xxx_hidden_StreetLine2 = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 9) } func (x *OpaqueAddress) SetCity(v string) { x.xxx_hidden_City = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 2, 9) } func (x *OpaqueAddress) SetState(v string) { x.xxx_hidden_State = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 3, 9) } func (x *OpaqueAddress) SetCountry(v string) { x.xxx_hidden_Country = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 4, 9) } func (x *OpaqueAddress) SetPostalCode(v string) { x.xxx_hidden_PostalCode = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 5, 9) } func (x *OpaqueAddress) SetAddressType(v OpaqueAddress_OpaqueAddressType) { x.xxx_hidden_AddressType = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 6, 9) } func (x *OpaqueAddress) SetIsDefault(v *wrapperspb.BoolValue) { x.xxx_hidden_IsDefault = v } func (x *OpaqueAddress) SetMetadata(v map[string]string) { x.xxx_hidden_Metadata = v } func (x *OpaqueAddress) HasStreetLine1() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 0) } func (x *OpaqueAddress) HasStreetLine2() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 1) } func (x *OpaqueAddress) HasCity() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 2) } func (x *OpaqueAddress) HasState() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 3) } func (x *OpaqueAddress) HasCountry() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 4) } func (x *OpaqueAddress) HasPostalCode() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 5) } func (x *OpaqueAddress) HasAddressType() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 6) } func (x *OpaqueAddress) HasIsDefault() bool { if x == nil { return false } return x.xxx_hidden_IsDefault != nil } func (x *OpaqueAddress) ClearStreetLine1() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) x.xxx_hidden_StreetLine1 = nil } func (x *OpaqueAddress) ClearStreetLine2() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) x.xxx_hidden_StreetLine2 = nil } func (x *OpaqueAddress) ClearCity() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 2) x.xxx_hidden_City = nil } func (x *OpaqueAddress) ClearState() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 3) x.xxx_hidden_State = nil } func (x *OpaqueAddress) ClearCountry() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 4) x.xxx_hidden_Country = nil } func (x *OpaqueAddress) ClearPostalCode() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 5) x.xxx_hidden_PostalCode = nil } func (x *OpaqueAddress) ClearAddressType() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 6) x.xxx_hidden_AddressType = OpaqueAddress_OPAQUE_ADDRESS_TYPE_UNSPECIFIED } func (x *OpaqueAddress) ClearIsDefault() { x.xxx_hidden_IsDefault = nil } type OpaqueAddress_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. StreetLine1 *string StreetLine2 *string City *string State *string Country *string PostalCode *string AddressType *OpaqueAddress_OpaqueAddressType IsDefault *wrapperspb.BoolValue Metadata map[string]string } func (b0 OpaqueAddress_builder) Build() *OpaqueAddress { m0 := &OpaqueAddress{} b, x := &b0, m0 _, _ = b, x if b.StreetLine1 != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 9) x.xxx_hidden_StreetLine1 = b.StreetLine1 } if b.StreetLine2 != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 9) x.xxx_hidden_StreetLine2 = b.StreetLine2 } if b.City != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 2, 9) x.xxx_hidden_City = b.City } if b.State != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 3, 9) x.xxx_hidden_State = b.State } if b.Country != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 4, 9) x.xxx_hidden_Country = b.Country } if b.PostalCode != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 5, 9) x.xxx_hidden_PostalCode = b.PostalCode } if b.AddressType != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 6, 9) x.xxx_hidden_AddressType = *b.AddressType } x.xxx_hidden_IsDefault = b.IsDefault x.xxx_hidden_Metadata = b.Metadata return m0 } // OpaquePrice represents a monetary value with currency type OpaquePrice struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Amount float64 `protobuf:"fixed64,1,opt,name=amount"` xxx_hidden_CurrencyCode *string `protobuf:"bytes,2,opt,name=currency_code,json=currencyCode"` xxx_hidden_IsDiscounted bool `protobuf:"varint,3,opt,name=is_discounted,json=isDiscounted"` xxx_hidden_OriginalAmount *wrapperspb.DoubleValue `protobuf:"bytes,4,opt,name=original_amount,json=originalAmount"` xxx_hidden_PriceValidUntil *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=price_valid_until,json=priceValidUntil"` XXX_raceDetectHookData protoimpl.RaceDetectHookData XXX_presence [1]uint32 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaquePrice) Reset() { *x = OpaquePrice{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaquePrice) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaquePrice) ProtoMessage() {} func (x *OpaquePrice) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaquePrice) GetAmount() float64 { if x != nil { return x.xxx_hidden_Amount } return 0 } func (x *OpaquePrice) GetCurrencyCode() string { if x != nil { if x.xxx_hidden_CurrencyCode != nil { return *x.xxx_hidden_CurrencyCode } return "" } return "" } func (x *OpaquePrice) GetIsDiscounted() bool { if x != nil { return x.xxx_hidden_IsDiscounted } return false } func (x *OpaquePrice) GetOriginalAmount() *wrapperspb.DoubleValue { if x != nil { return x.xxx_hidden_OriginalAmount } return nil } func (x *OpaquePrice) GetPriceValidUntil() *timestamppb.Timestamp { if x != nil { return x.xxx_hidden_PriceValidUntil } return nil } func (x *OpaquePrice) SetAmount(v float64) { x.xxx_hidden_Amount = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 5) } func (x *OpaquePrice) SetCurrencyCode(v string) { x.xxx_hidden_CurrencyCode = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 5) } func (x *OpaquePrice) SetIsDiscounted(v bool) { x.xxx_hidden_IsDiscounted = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 2, 5) } func (x *OpaquePrice) SetOriginalAmount(v *wrapperspb.DoubleValue) { x.xxx_hidden_OriginalAmount = v } func (x *OpaquePrice) SetPriceValidUntil(v *timestamppb.Timestamp) { x.xxx_hidden_PriceValidUntil = v } func (x *OpaquePrice) HasAmount() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 0) } func (x *OpaquePrice) HasCurrencyCode() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 1) } func (x *OpaquePrice) HasIsDiscounted() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 2) } func (x *OpaquePrice) HasOriginalAmount() bool { if x == nil { return false } return x.xxx_hidden_OriginalAmount != nil } func (x *OpaquePrice) HasPriceValidUntil() bool { if x == nil { return false } return x.xxx_hidden_PriceValidUntil != nil } func (x *OpaquePrice) ClearAmount() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) x.xxx_hidden_Amount = 0 } func (x *OpaquePrice) ClearCurrencyCode() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) x.xxx_hidden_CurrencyCode = nil } func (x *OpaquePrice) ClearIsDiscounted() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 2) x.xxx_hidden_IsDiscounted = false } func (x *OpaquePrice) ClearOriginalAmount() { x.xxx_hidden_OriginalAmount = nil } func (x *OpaquePrice) ClearPriceValidUntil() { x.xxx_hidden_PriceValidUntil = nil } type OpaquePrice_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Amount *float64 CurrencyCode *string IsDiscounted *bool OriginalAmount *wrapperspb.DoubleValue PriceValidUntil *timestamppb.Timestamp } func (b0 OpaquePrice_builder) Build() *OpaquePrice { m0 := &OpaquePrice{} b, x := &b0, m0 _, _ = b, x if b.Amount != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 5) x.xxx_hidden_Amount = *b.Amount } if b.CurrencyCode != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 5) x.xxx_hidden_CurrencyCode = b.CurrencyCode } if b.IsDiscounted != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 2, 5) x.xxx_hidden_IsDiscounted = *b.IsDiscounted } x.xxx_hidden_OriginalAmount = b.OriginalAmount x.xxx_hidden_PriceValidUntil = b.PriceValidUntil return m0 } // OpaqueProductCategory represents a product category type OpaqueProductCategory struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_CategoryId *string `protobuf:"bytes,1,opt,name=category_id,json=categoryId"` xxx_hidden_Name *string `protobuf:"bytes,2,opt,name=name"` xxx_hidden_Description *string `protobuf:"bytes,3,opt,name=description"` xxx_hidden_ParentCategory *OpaqueProductCategory `protobuf:"bytes,4,opt,name=parent_category,json=parentCategory"` xxx_hidden_Tags []string `protobuf:"bytes,5,rep,name=tags"` xxx_hidden_CreatedAt *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=created_at,json=createdAt"` xxx_hidden_UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=updated_at,json=updatedAt"` XXX_raceDetectHookData protoimpl.RaceDetectHookData XXX_presence [1]uint32 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueProductCategory) Reset() { *x = OpaqueProductCategory{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueProductCategory) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueProductCategory) ProtoMessage() {} func (x *OpaqueProductCategory) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[20] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueProductCategory) GetCategoryId() string { if x != nil { if x.xxx_hidden_CategoryId != nil { return *x.xxx_hidden_CategoryId } return "" } return "" } func (x *OpaqueProductCategory) GetName() string { if x != nil { if x.xxx_hidden_Name != nil { return *x.xxx_hidden_Name } return "" } return "" } func (x *OpaqueProductCategory) GetDescription() string { if x != nil { if x.xxx_hidden_Description != nil { return *x.xxx_hidden_Description } return "" } return "" } func (x *OpaqueProductCategory) GetParentCategory() *OpaqueProductCategory { if x != nil { return x.xxx_hidden_ParentCategory } return nil } func (x *OpaqueProductCategory) GetTags() []string { if x != nil { return x.xxx_hidden_Tags } return nil } func (x *OpaqueProductCategory) GetCreatedAt() *timestamppb.Timestamp { if x != nil { return x.xxx_hidden_CreatedAt } return nil } func (x *OpaqueProductCategory) GetUpdatedAt() *timestamppb.Timestamp { if x != nil { return x.xxx_hidden_UpdatedAt } return nil } func (x *OpaqueProductCategory) SetCategoryId(v string) { x.xxx_hidden_CategoryId = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 7) } func (x *OpaqueProductCategory) SetName(v string) { x.xxx_hidden_Name = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 7) } func (x *OpaqueProductCategory) SetDescription(v string) { x.xxx_hidden_Description = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 2, 7) } func (x *OpaqueProductCategory) SetParentCategory(v *OpaqueProductCategory) { x.xxx_hidden_ParentCategory = v } func (x *OpaqueProductCategory) SetTags(v []string) { x.xxx_hidden_Tags = v } func (x *OpaqueProductCategory) SetCreatedAt(v *timestamppb.Timestamp) { x.xxx_hidden_CreatedAt = v } func (x *OpaqueProductCategory) SetUpdatedAt(v *timestamppb.Timestamp) { x.xxx_hidden_UpdatedAt = v } func (x *OpaqueProductCategory) HasCategoryId() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 0) } func (x *OpaqueProductCategory) HasName() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 1) } func (x *OpaqueProductCategory) HasDescription() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 2) } func (x *OpaqueProductCategory) HasParentCategory() bool { if x == nil { return false } return x.xxx_hidden_ParentCategory != nil } func (x *OpaqueProductCategory) HasCreatedAt() bool { if x == nil { return false } return x.xxx_hidden_CreatedAt != nil } func (x *OpaqueProductCategory) HasUpdatedAt() bool { if x == nil { return false } return x.xxx_hidden_UpdatedAt != nil } func (x *OpaqueProductCategory) ClearCategoryId() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) x.xxx_hidden_CategoryId = nil } func (x *OpaqueProductCategory) ClearName() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) x.xxx_hidden_Name = nil } func (x *OpaqueProductCategory) ClearDescription() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 2) x.xxx_hidden_Description = nil } func (x *OpaqueProductCategory) ClearParentCategory() { x.xxx_hidden_ParentCategory = nil } func (x *OpaqueProductCategory) ClearCreatedAt() { x.xxx_hidden_CreatedAt = nil } func (x *OpaqueProductCategory) ClearUpdatedAt() { x.xxx_hidden_UpdatedAt = nil } type OpaqueProductCategory_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. CategoryId *string Name *string Description *string ParentCategory *OpaqueProductCategory Tags []string CreatedAt *timestamppb.Timestamp UpdatedAt *timestamppb.Timestamp } func (b0 OpaqueProductCategory_builder) Build() *OpaqueProductCategory { m0 := &OpaqueProductCategory{} b, x := &b0, m0 _, _ = b, x if b.CategoryId != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 7) x.xxx_hidden_CategoryId = b.CategoryId } if b.Name != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 7) x.xxx_hidden_Name = b.Name } if b.Description != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 2, 7) x.xxx_hidden_Description = b.Description } x.xxx_hidden_ParentCategory = b.ParentCategory x.xxx_hidden_Tags = b.Tags x.xxx_hidden_CreatedAt = b.CreatedAt x.xxx_hidden_UpdatedAt = b.UpdatedAt return m0 } // OpaqueProductVariant represents a specific variant of a product type OpaqueProductVariant struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_VariantId *string `protobuf:"bytes,1,opt,name=variant_id,json=variantId"` xxx_hidden_Sku *string `protobuf:"bytes,2,opt,name=sku"` xxx_hidden_Name *string `protobuf:"bytes,3,opt,name=name"` xxx_hidden_Price *OpaquePrice `protobuf:"bytes,4,opt,name=price"` xxx_hidden_InventoryCount int32 `protobuf:"varint,5,opt,name=inventory_count,json=inventoryCount"` xxx_hidden_Attributes map[string]string `protobuf:"bytes,6,rep,name=attributes" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` xxx_hidden_ImageData []byte `protobuf:"bytes,7,opt,name=image_data,json=imageData"` xxx_hidden_ImageUrls []string `protobuf:"bytes,8,rep,name=image_urls,json=imageUrls"` xxx_hidden_IsAvailable *wrapperspb.BoolValue `protobuf:"bytes,9,opt,name=is_available,json=isAvailable"` xxx_hidden_DiscountInfo isOpaqueProductVariant_DiscountInfo `protobuf_oneof:"discount_info"` XXX_raceDetectHookData protoimpl.RaceDetectHookData XXX_presence [1]uint32 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueProductVariant) Reset() { *x = OpaqueProductVariant{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueProductVariant) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueProductVariant) ProtoMessage() {} func (x *OpaqueProductVariant) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[21] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueProductVariant) GetVariantId() string { if x != nil { if x.xxx_hidden_VariantId != nil { return *x.xxx_hidden_VariantId } return "" } return "" } func (x *OpaqueProductVariant) GetSku() string { if x != nil { if x.xxx_hidden_Sku != nil { return *x.xxx_hidden_Sku } return "" } return "" } func (x *OpaqueProductVariant) GetName() string { if x != nil { if x.xxx_hidden_Name != nil { return *x.xxx_hidden_Name } return "" } return "" } func (x *OpaqueProductVariant) GetPrice() *OpaquePrice { if x != nil { return x.xxx_hidden_Price } return nil } func (x *OpaqueProductVariant) GetInventoryCount() int32 { if x != nil { return x.xxx_hidden_InventoryCount } return 0 } func (x *OpaqueProductVariant) GetAttributes() map[string]string { if x != nil { return x.xxx_hidden_Attributes } return nil } func (x *OpaqueProductVariant) GetImageData() []byte { if x != nil { return x.xxx_hidden_ImageData } return nil } func (x *OpaqueProductVariant) GetImageUrls() []string { if x != nil { return x.xxx_hidden_ImageUrls } return nil } func (x *OpaqueProductVariant) GetIsAvailable() *wrapperspb.BoolValue { if x != nil { return x.xxx_hidden_IsAvailable } return nil } func (x *OpaqueProductVariant) GetPercentageOff() float64 { if x != nil { if x, ok := x.xxx_hidden_DiscountInfo.(*opaqueProductVariant_PercentageOff); ok { return x.PercentageOff } } return 0 } func (x *OpaqueProductVariant) GetFixedAmountOff() float64 { if x != nil { if x, ok := x.xxx_hidden_DiscountInfo.(*opaqueProductVariant_FixedAmountOff); ok { return x.FixedAmountOff } } return 0 } func (x *OpaqueProductVariant) SetVariantId(v string) { x.xxx_hidden_VariantId = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 10) } func (x *OpaqueProductVariant) SetSku(v string) { x.xxx_hidden_Sku = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 10) } func (x *OpaqueProductVariant) SetName(v string) { x.xxx_hidden_Name = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 2, 10) } func (x *OpaqueProductVariant) SetPrice(v *OpaquePrice) { x.xxx_hidden_Price = v } func (x *OpaqueProductVariant) SetInventoryCount(v int32) { x.xxx_hidden_InventoryCount = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 4, 10) } func (x *OpaqueProductVariant) SetAttributes(v map[string]string) { x.xxx_hidden_Attributes = v } func (x *OpaqueProductVariant) SetImageData(v []byte) { if v == nil { v = []byte{} } x.xxx_hidden_ImageData = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 6, 10) } func (x *OpaqueProductVariant) SetImageUrls(v []string) { x.xxx_hidden_ImageUrls = v } func (x *OpaqueProductVariant) SetIsAvailable(v *wrapperspb.BoolValue) { x.xxx_hidden_IsAvailable = v } func (x *OpaqueProductVariant) SetPercentageOff(v float64) { x.xxx_hidden_DiscountInfo = &opaqueProductVariant_PercentageOff{v} } func (x *OpaqueProductVariant) SetFixedAmountOff(v float64) { x.xxx_hidden_DiscountInfo = &opaqueProductVariant_FixedAmountOff{v} } func (x *OpaqueProductVariant) HasVariantId() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 0) } func (x *OpaqueProductVariant) HasSku() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 1) } func (x *OpaqueProductVariant) HasName() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 2) } func (x *OpaqueProductVariant) HasPrice() bool { if x == nil { return false } return x.xxx_hidden_Price != nil } func (x *OpaqueProductVariant) HasInventoryCount() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 4) } func (x *OpaqueProductVariant) HasImageData() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 6) } func (x *OpaqueProductVariant) HasIsAvailable() bool { if x == nil { return false } return x.xxx_hidden_IsAvailable != nil } func (x *OpaqueProductVariant) HasDiscountInfo() bool { if x == nil { return false } return x.xxx_hidden_DiscountInfo != nil } func (x *OpaqueProductVariant) HasPercentageOff() bool { if x == nil { return false } _, ok := x.xxx_hidden_DiscountInfo.(*opaqueProductVariant_PercentageOff) return ok } func (x *OpaqueProductVariant) HasFixedAmountOff() bool { if x == nil { return false } _, ok := x.xxx_hidden_DiscountInfo.(*opaqueProductVariant_FixedAmountOff) return ok } func (x *OpaqueProductVariant) ClearVariantId() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) x.xxx_hidden_VariantId = nil } func (x *OpaqueProductVariant) ClearSku() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) x.xxx_hidden_Sku = nil } func (x *OpaqueProductVariant) ClearName() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 2) x.xxx_hidden_Name = nil } func (x *OpaqueProductVariant) ClearPrice() { x.xxx_hidden_Price = nil } func (x *OpaqueProductVariant) ClearInventoryCount() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 4) x.xxx_hidden_InventoryCount = 0 } func (x *OpaqueProductVariant) ClearImageData() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 6) x.xxx_hidden_ImageData = nil } func (x *OpaqueProductVariant) ClearIsAvailable() { x.xxx_hidden_IsAvailable = nil } func (x *OpaqueProductVariant) ClearDiscountInfo() { x.xxx_hidden_DiscountInfo = nil } func (x *OpaqueProductVariant) ClearPercentageOff() { if _, ok := x.xxx_hidden_DiscountInfo.(*opaqueProductVariant_PercentageOff); ok { x.xxx_hidden_DiscountInfo = nil } } func (x *OpaqueProductVariant) ClearFixedAmountOff() { if _, ok := x.xxx_hidden_DiscountInfo.(*opaqueProductVariant_FixedAmountOff); ok { x.xxx_hidden_DiscountInfo = nil } } const OpaqueProductVariant_DiscountInfo_not_set_case case_OpaqueProductVariant_DiscountInfo = 0 const OpaqueProductVariant_PercentageOff_case case_OpaqueProductVariant_DiscountInfo = 10 const OpaqueProductVariant_FixedAmountOff_case case_OpaqueProductVariant_DiscountInfo = 11 func (x *OpaqueProductVariant) WhichDiscountInfo() case_OpaqueProductVariant_DiscountInfo { if x == nil { return OpaqueProductVariant_DiscountInfo_not_set_case } switch x.xxx_hidden_DiscountInfo.(type) { case *opaqueProductVariant_PercentageOff: return OpaqueProductVariant_PercentageOff_case case *opaqueProductVariant_FixedAmountOff: return OpaqueProductVariant_FixedAmountOff_case default: return OpaqueProductVariant_DiscountInfo_not_set_case } } type OpaqueProductVariant_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. VariantId *string Sku *string Name *string Price *OpaquePrice InventoryCount *int32 Attributes map[string]string ImageData []byte ImageUrls []string IsAvailable *wrapperspb.BoolValue // Fields of oneof xxx_hidden_DiscountInfo: PercentageOff *float64 FixedAmountOff *float64 // -- end of xxx_hidden_DiscountInfo } func (b0 OpaqueProductVariant_builder) Build() *OpaqueProductVariant { m0 := &OpaqueProductVariant{} b, x := &b0, m0 _, _ = b, x if b.VariantId != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 10) x.xxx_hidden_VariantId = b.VariantId } if b.Sku != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 10) x.xxx_hidden_Sku = b.Sku } if b.Name != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 2, 10) x.xxx_hidden_Name = b.Name } x.xxx_hidden_Price = b.Price if b.InventoryCount != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 4, 10) x.xxx_hidden_InventoryCount = *b.InventoryCount } x.xxx_hidden_Attributes = b.Attributes if b.ImageData != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 6, 10) x.xxx_hidden_ImageData = b.ImageData } x.xxx_hidden_ImageUrls = b.ImageUrls x.xxx_hidden_IsAvailable = b.IsAvailable if b.PercentageOff != nil { x.xxx_hidden_DiscountInfo = &opaqueProductVariant_PercentageOff{*b.PercentageOff} } if b.FixedAmountOff != nil { x.xxx_hidden_DiscountInfo = &opaqueProductVariant_FixedAmountOff{*b.FixedAmountOff} } return m0 } type case_OpaqueProductVariant_DiscountInfo protoreflect.FieldNumber func (x case_OpaqueProductVariant_DiscountInfo) String() string { md := file_examples_internal_proto_examplepb_opaque_proto_msgTypes[21].Descriptor() if x == 0 { return "not set" } return protoimpl.X.MessageFieldStringOf(md, protoreflect.FieldNumber(x)) } type isOpaqueProductVariant_DiscountInfo interface { isOpaqueProductVariant_DiscountInfo() } type opaqueProductVariant_PercentageOff struct { PercentageOff float64 `protobuf:"fixed64,10,opt,name=percentage_off,json=percentageOff,oneof"` } type opaqueProductVariant_FixedAmountOff struct { FixedAmountOff float64 `protobuf:"fixed64,11,opt,name=fixed_amount_off,json=fixedAmountOff,oneof"` } func (*opaqueProductVariant_PercentageOff) isOpaqueProductVariant_DiscountInfo() {} func (*opaqueProductVariant_FixedAmountOff) isOpaqueProductVariant_DiscountInfo() {} // OpaqueProduct represents a product in the e-commerce system type OpaqueProduct struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_ProductId *string `protobuf:"bytes,1,opt,name=product_id,json=productId"` xxx_hidden_Name *string `protobuf:"bytes,2,opt,name=name"` xxx_hidden_Description *string `protobuf:"bytes,3,opt,name=description"` xxx_hidden_Brand *string `protobuf:"bytes,4,opt,name=brand"` xxx_hidden_BasePrice *OpaquePrice `protobuf:"bytes,5,opt,name=base_price,json=basePrice"` xxx_hidden_Category *OpaqueProductCategory `protobuf:"bytes,6,opt,name=category"` xxx_hidden_Variants *[]*OpaqueProductVariant `protobuf:"bytes,7,rep,name=variants"` xxx_hidden_Tags []string `protobuf:"bytes,8,rep,name=tags"` xxx_hidden_AverageRating float64 `protobuf:"fixed64,9,opt,name=average_rating,json=averageRating"` xxx_hidden_ReviewCount int32 `protobuf:"varint,10,opt,name=review_count,json=reviewCount"` xxx_hidden_IsFeatured *wrapperspb.BoolValue `protobuf:"bytes,11,opt,name=is_featured,json=isFeatured"` xxx_hidden_CreatedAt *timestamppb.Timestamp `protobuf:"bytes,12,opt,name=created_at,json=createdAt"` xxx_hidden_UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,13,opt,name=updated_at,json=updatedAt"` xxx_hidden_AverageShippingTime *durationpb.Duration `protobuf:"bytes,14,opt,name=average_shipping_time,json=averageShippingTime"` xxx_hidden_Status OpaqueProduct_OpaqueProductStatus `protobuf:"varint,15,opt,name=status,enum=grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct_OpaqueProductStatus"` xxx_hidden_Metadata map[string]string `protobuf:"bytes,16,rep,name=metadata" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` xxx_hidden_RegionalPrices map[string]*OpaquePrice `protobuf:"bytes,17,rep,name=regional_prices,json=regionalPrices" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` xxx_hidden_Dimensions *OpaqueProduct_OpaqueProductDimensions `protobuf:"bytes,18,opt,name=dimensions"` xxx_hidden_TaxInfo isOpaqueProduct_TaxInfo `protobuf_oneof:"tax_info"` XXX_raceDetectHookData protoimpl.RaceDetectHookData XXX_presence [1]uint32 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueProduct) Reset() { *x = OpaqueProduct{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueProduct) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueProduct) ProtoMessage() {} func (x *OpaqueProduct) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[22] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueProduct) GetProductId() string { if x != nil { if x.xxx_hidden_ProductId != nil { return *x.xxx_hidden_ProductId } return "" } return "" } func (x *OpaqueProduct) GetName() string { if x != nil { if x.xxx_hidden_Name != nil { return *x.xxx_hidden_Name } return "" } return "" } func (x *OpaqueProduct) GetDescription() string { if x != nil { if x.xxx_hidden_Description != nil { return *x.xxx_hidden_Description } return "" } return "" } func (x *OpaqueProduct) GetBrand() string { if x != nil { if x.xxx_hidden_Brand != nil { return *x.xxx_hidden_Brand } return "" } return "" } func (x *OpaqueProduct) GetBasePrice() *OpaquePrice { if x != nil { return x.xxx_hidden_BasePrice } return nil } func (x *OpaqueProduct) GetCategory() *OpaqueProductCategory { if x != nil { return x.xxx_hidden_Category } return nil } func (x *OpaqueProduct) GetVariants() []*OpaqueProductVariant { if x != nil { if x.xxx_hidden_Variants != nil { return *x.xxx_hidden_Variants } } return nil } func (x *OpaqueProduct) GetTags() []string { if x != nil { return x.xxx_hidden_Tags } return nil } func (x *OpaqueProduct) GetAverageRating() float64 { if x != nil { return x.xxx_hidden_AverageRating } return 0 } func (x *OpaqueProduct) GetReviewCount() int32 { if x != nil { return x.xxx_hidden_ReviewCount } return 0 } func (x *OpaqueProduct) GetIsFeatured() *wrapperspb.BoolValue { if x != nil { return x.xxx_hidden_IsFeatured } return nil } func (x *OpaqueProduct) GetCreatedAt() *timestamppb.Timestamp { if x != nil { return x.xxx_hidden_CreatedAt } return nil } func (x *OpaqueProduct) GetUpdatedAt() *timestamppb.Timestamp { if x != nil { return x.xxx_hidden_UpdatedAt } return nil } func (x *OpaqueProduct) GetAverageShippingTime() *durationpb.Duration { if x != nil { return x.xxx_hidden_AverageShippingTime } return nil } func (x *OpaqueProduct) GetStatus() OpaqueProduct_OpaqueProductStatus { if x != nil { if protoimpl.X.Present(&(x.XXX_presence[0]), 14) { return x.xxx_hidden_Status } } return OpaqueProduct_OPAQUE_PRODUCT_STATUS_UNSPECIFIED } func (x *OpaqueProduct) GetMetadata() map[string]string { if x != nil { return x.xxx_hidden_Metadata } return nil } func (x *OpaqueProduct) GetRegionalPrices() map[string]*OpaquePrice { if x != nil { return x.xxx_hidden_RegionalPrices } return nil } func (x *OpaqueProduct) GetDimensions() *OpaqueProduct_OpaqueProductDimensions { if x != nil { return x.xxx_hidden_Dimensions } return nil } func (x *OpaqueProduct) GetTaxPercentage() float64 { if x != nil { if x, ok := x.xxx_hidden_TaxInfo.(*opaqueProduct_TaxPercentage); ok { return x.TaxPercentage } } return 0 } func (x *OpaqueProduct) GetTaxExempt() bool { if x != nil { if x, ok := x.xxx_hidden_TaxInfo.(*opaqueProduct_TaxExempt); ok { return x.TaxExempt } } return false } func (x *OpaqueProduct) SetProductId(v string) { x.xxx_hidden_ProductId = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 19) } func (x *OpaqueProduct) SetName(v string) { x.xxx_hidden_Name = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 19) } func (x *OpaqueProduct) SetDescription(v string) { x.xxx_hidden_Description = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 2, 19) } func (x *OpaqueProduct) SetBrand(v string) { x.xxx_hidden_Brand = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 3, 19) } func (x *OpaqueProduct) SetBasePrice(v *OpaquePrice) { x.xxx_hidden_BasePrice = v } func (x *OpaqueProduct) SetCategory(v *OpaqueProductCategory) { x.xxx_hidden_Category = v } func (x *OpaqueProduct) SetVariants(v []*OpaqueProductVariant) { x.xxx_hidden_Variants = &v } func (x *OpaqueProduct) SetTags(v []string) { x.xxx_hidden_Tags = v } func (x *OpaqueProduct) SetAverageRating(v float64) { x.xxx_hidden_AverageRating = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 8, 19) } func (x *OpaqueProduct) SetReviewCount(v int32) { x.xxx_hidden_ReviewCount = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 9, 19) } func (x *OpaqueProduct) SetIsFeatured(v *wrapperspb.BoolValue) { x.xxx_hidden_IsFeatured = v } func (x *OpaqueProduct) SetCreatedAt(v *timestamppb.Timestamp) { x.xxx_hidden_CreatedAt = v } func (x *OpaqueProduct) SetUpdatedAt(v *timestamppb.Timestamp) { x.xxx_hidden_UpdatedAt = v } func (x *OpaqueProduct) SetAverageShippingTime(v *durationpb.Duration) { x.xxx_hidden_AverageShippingTime = v } func (x *OpaqueProduct) SetStatus(v OpaqueProduct_OpaqueProductStatus) { x.xxx_hidden_Status = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 14, 19) } func (x *OpaqueProduct) SetMetadata(v map[string]string) { x.xxx_hidden_Metadata = v } func (x *OpaqueProduct) SetRegionalPrices(v map[string]*OpaquePrice) { x.xxx_hidden_RegionalPrices = v } func (x *OpaqueProduct) SetDimensions(v *OpaqueProduct_OpaqueProductDimensions) { x.xxx_hidden_Dimensions = v } func (x *OpaqueProduct) SetTaxPercentage(v float64) { x.xxx_hidden_TaxInfo = &opaqueProduct_TaxPercentage{v} } func (x *OpaqueProduct) SetTaxExempt(v bool) { x.xxx_hidden_TaxInfo = &opaqueProduct_TaxExempt{v} } func (x *OpaqueProduct) HasProductId() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 0) } func (x *OpaqueProduct) HasName() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 1) } func (x *OpaqueProduct) HasDescription() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 2) } func (x *OpaqueProduct) HasBrand() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 3) } func (x *OpaqueProduct) HasBasePrice() bool { if x == nil { return false } return x.xxx_hidden_BasePrice != nil } func (x *OpaqueProduct) HasCategory() bool { if x == nil { return false } return x.xxx_hidden_Category != nil } func (x *OpaqueProduct) HasAverageRating() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 8) } func (x *OpaqueProduct) HasReviewCount() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 9) } func (x *OpaqueProduct) HasIsFeatured() bool { if x == nil { return false } return x.xxx_hidden_IsFeatured != nil } func (x *OpaqueProduct) HasCreatedAt() bool { if x == nil { return false } return x.xxx_hidden_CreatedAt != nil } func (x *OpaqueProduct) HasUpdatedAt() bool { if x == nil { return false } return x.xxx_hidden_UpdatedAt != nil } func (x *OpaqueProduct) HasAverageShippingTime() bool { if x == nil { return false } return x.xxx_hidden_AverageShippingTime != nil } func (x *OpaqueProduct) HasStatus() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 14) } func (x *OpaqueProduct) HasDimensions() bool { if x == nil { return false } return x.xxx_hidden_Dimensions != nil } func (x *OpaqueProduct) HasTaxInfo() bool { if x == nil { return false } return x.xxx_hidden_TaxInfo != nil } func (x *OpaqueProduct) HasTaxPercentage() bool { if x == nil { return false } _, ok := x.xxx_hidden_TaxInfo.(*opaqueProduct_TaxPercentage) return ok } func (x *OpaqueProduct) HasTaxExempt() bool { if x == nil { return false } _, ok := x.xxx_hidden_TaxInfo.(*opaqueProduct_TaxExempt) return ok } func (x *OpaqueProduct) ClearProductId() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) x.xxx_hidden_ProductId = nil } func (x *OpaqueProduct) ClearName() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) x.xxx_hidden_Name = nil } func (x *OpaqueProduct) ClearDescription() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 2) x.xxx_hidden_Description = nil } func (x *OpaqueProduct) ClearBrand() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 3) x.xxx_hidden_Brand = nil } func (x *OpaqueProduct) ClearBasePrice() { x.xxx_hidden_BasePrice = nil } func (x *OpaqueProduct) ClearCategory() { x.xxx_hidden_Category = nil } func (x *OpaqueProduct) ClearAverageRating() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 8) x.xxx_hidden_AverageRating = 0 } func (x *OpaqueProduct) ClearReviewCount() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 9) x.xxx_hidden_ReviewCount = 0 } func (x *OpaqueProduct) ClearIsFeatured() { x.xxx_hidden_IsFeatured = nil } func (x *OpaqueProduct) ClearCreatedAt() { x.xxx_hidden_CreatedAt = nil } func (x *OpaqueProduct) ClearUpdatedAt() { x.xxx_hidden_UpdatedAt = nil } func (x *OpaqueProduct) ClearAverageShippingTime() { x.xxx_hidden_AverageShippingTime = nil } func (x *OpaqueProduct) ClearStatus() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 14) x.xxx_hidden_Status = OpaqueProduct_OPAQUE_PRODUCT_STATUS_UNSPECIFIED } func (x *OpaqueProduct) ClearDimensions() { x.xxx_hidden_Dimensions = nil } func (x *OpaqueProduct) ClearTaxInfo() { x.xxx_hidden_TaxInfo = nil } func (x *OpaqueProduct) ClearTaxPercentage() { if _, ok := x.xxx_hidden_TaxInfo.(*opaqueProduct_TaxPercentage); ok { x.xxx_hidden_TaxInfo = nil } } func (x *OpaqueProduct) ClearTaxExempt() { if _, ok := x.xxx_hidden_TaxInfo.(*opaqueProduct_TaxExempt); ok { x.xxx_hidden_TaxInfo = nil } } const OpaqueProduct_TaxInfo_not_set_case case_OpaqueProduct_TaxInfo = 0 const OpaqueProduct_TaxPercentage_case case_OpaqueProduct_TaxInfo = 19 const OpaqueProduct_TaxExempt_case case_OpaqueProduct_TaxInfo = 20 func (x *OpaqueProduct) WhichTaxInfo() case_OpaqueProduct_TaxInfo { if x == nil { return OpaqueProduct_TaxInfo_not_set_case } switch x.xxx_hidden_TaxInfo.(type) { case *opaqueProduct_TaxPercentage: return OpaqueProduct_TaxPercentage_case case *opaqueProduct_TaxExempt: return OpaqueProduct_TaxExempt_case default: return OpaqueProduct_TaxInfo_not_set_case } } type OpaqueProduct_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. ProductId *string Name *string Description *string Brand *string BasePrice *OpaquePrice Category *OpaqueProductCategory Variants []*OpaqueProductVariant Tags []string AverageRating *float64 ReviewCount *int32 IsFeatured *wrapperspb.BoolValue CreatedAt *timestamppb.Timestamp UpdatedAt *timestamppb.Timestamp AverageShippingTime *durationpb.Duration Status *OpaqueProduct_OpaqueProductStatus Metadata map[string]string RegionalPrices map[string]*OpaquePrice Dimensions *OpaqueProduct_OpaqueProductDimensions // Fields of oneof xxx_hidden_TaxInfo: TaxPercentage *float64 TaxExempt *bool // -- end of xxx_hidden_TaxInfo } func (b0 OpaqueProduct_builder) Build() *OpaqueProduct { m0 := &OpaqueProduct{} b, x := &b0, m0 _, _ = b, x if b.ProductId != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 19) x.xxx_hidden_ProductId = b.ProductId } if b.Name != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 19) x.xxx_hidden_Name = b.Name } if b.Description != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 2, 19) x.xxx_hidden_Description = b.Description } if b.Brand != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 3, 19) x.xxx_hidden_Brand = b.Brand } x.xxx_hidden_BasePrice = b.BasePrice x.xxx_hidden_Category = b.Category x.xxx_hidden_Variants = &b.Variants x.xxx_hidden_Tags = b.Tags if b.AverageRating != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 8, 19) x.xxx_hidden_AverageRating = *b.AverageRating } if b.ReviewCount != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 9, 19) x.xxx_hidden_ReviewCount = *b.ReviewCount } x.xxx_hidden_IsFeatured = b.IsFeatured x.xxx_hidden_CreatedAt = b.CreatedAt x.xxx_hidden_UpdatedAt = b.UpdatedAt x.xxx_hidden_AverageShippingTime = b.AverageShippingTime if b.Status != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 14, 19) x.xxx_hidden_Status = *b.Status } x.xxx_hidden_Metadata = b.Metadata x.xxx_hidden_RegionalPrices = b.RegionalPrices x.xxx_hidden_Dimensions = b.Dimensions if b.TaxPercentage != nil { x.xxx_hidden_TaxInfo = &opaqueProduct_TaxPercentage{*b.TaxPercentage} } if b.TaxExempt != nil { x.xxx_hidden_TaxInfo = &opaqueProduct_TaxExempt{*b.TaxExempt} } return m0 } type case_OpaqueProduct_TaxInfo protoreflect.FieldNumber func (x case_OpaqueProduct_TaxInfo) String() string { md := file_examples_internal_proto_examplepb_opaque_proto_msgTypes[22].Descriptor() if x == 0 { return "not set" } return protoimpl.X.MessageFieldStringOf(md, protoreflect.FieldNumber(x)) } type isOpaqueProduct_TaxInfo interface { isOpaqueProduct_TaxInfo() } type opaqueProduct_TaxPercentage struct { TaxPercentage float64 `protobuf:"fixed64,19,opt,name=tax_percentage,json=taxPercentage,oneof"` } type opaqueProduct_TaxExempt struct { TaxExempt bool `protobuf:"varint,20,opt,name=tax_exempt,json=taxExempt,oneof"` } func (*opaqueProduct_TaxPercentage) isOpaqueProduct_TaxInfo() {} func (*opaqueProduct_TaxExempt) isOpaqueProduct_TaxInfo() {} // OpaqueCustomer represents a customer in the e-commerce system type OpaqueCustomer struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_CustomerId *string `protobuf:"bytes,1,opt,name=customer_id,json=customerId"` xxx_hidden_Email *string `protobuf:"bytes,2,opt,name=email"` xxx_hidden_FirstName *string `protobuf:"bytes,3,opt,name=first_name,json=firstName"` xxx_hidden_LastName *string `protobuf:"bytes,4,opt,name=last_name,json=lastName"` xxx_hidden_PhoneNumber *string `protobuf:"bytes,5,opt,name=phone_number,json=phoneNumber"` xxx_hidden_Addresses *[]*OpaqueAddress `protobuf:"bytes,6,rep,name=addresses"` xxx_hidden_CreatedAt *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=created_at,json=createdAt"` xxx_hidden_LastLogin *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=last_login,json=lastLogin"` xxx_hidden_Status OpaqueCustomer_OpaqueCustomerStatus `protobuf:"varint,9,opt,name=status,enum=grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer_OpaqueCustomerStatus"` xxx_hidden_LoyaltyInfo *OpaqueCustomer_OpaqueLoyaltyInfo `protobuf:"bytes,10,opt,name=loyalty_info,json=loyaltyInfo"` xxx_hidden_Preferences map[string]string `protobuf:"bytes,11,rep,name=preferences" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` xxx_hidden_PaymentMethods *[]*OpaqueCustomer_OpaquePaymentMethod `protobuf:"bytes,12,rep,name=payment_methods,json=paymentMethods"` XXX_raceDetectHookData protoimpl.RaceDetectHookData XXX_presence [1]uint32 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueCustomer) Reset() { *x = OpaqueCustomer{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueCustomer) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueCustomer) ProtoMessage() {} func (x *OpaqueCustomer) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[23] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueCustomer) GetCustomerId() string { if x != nil { if x.xxx_hidden_CustomerId != nil { return *x.xxx_hidden_CustomerId } return "" } return "" } func (x *OpaqueCustomer) GetEmail() string { if x != nil { if x.xxx_hidden_Email != nil { return *x.xxx_hidden_Email } return "" } return "" } func (x *OpaqueCustomer) GetFirstName() string { if x != nil { if x.xxx_hidden_FirstName != nil { return *x.xxx_hidden_FirstName } return "" } return "" } func (x *OpaqueCustomer) GetLastName() string { if x != nil { if x.xxx_hidden_LastName != nil { return *x.xxx_hidden_LastName } return "" } return "" } func (x *OpaqueCustomer) GetPhoneNumber() string { if x != nil { if x.xxx_hidden_PhoneNumber != nil { return *x.xxx_hidden_PhoneNumber } return "" } return "" } func (x *OpaqueCustomer) GetAddresses() []*OpaqueAddress { if x != nil { if x.xxx_hidden_Addresses != nil { return *x.xxx_hidden_Addresses } } return nil } func (x *OpaqueCustomer) GetCreatedAt() *timestamppb.Timestamp { if x != nil { return x.xxx_hidden_CreatedAt } return nil } func (x *OpaqueCustomer) GetLastLogin() *timestamppb.Timestamp { if x != nil { return x.xxx_hidden_LastLogin } return nil } func (x *OpaqueCustomer) GetStatus() OpaqueCustomer_OpaqueCustomerStatus { if x != nil { if protoimpl.X.Present(&(x.XXX_presence[0]), 8) { return x.xxx_hidden_Status } } return OpaqueCustomer_OPAQUE_CUSTOMER_STATUS_UNSPECIFIED } func (x *OpaqueCustomer) GetLoyaltyInfo() *OpaqueCustomer_OpaqueLoyaltyInfo { if x != nil { return x.xxx_hidden_LoyaltyInfo } return nil } func (x *OpaqueCustomer) GetPreferences() map[string]string { if x != nil { return x.xxx_hidden_Preferences } return nil } func (x *OpaqueCustomer) GetPaymentMethods() []*OpaqueCustomer_OpaquePaymentMethod { if x != nil { if x.xxx_hidden_PaymentMethods != nil { return *x.xxx_hidden_PaymentMethods } } return nil } func (x *OpaqueCustomer) SetCustomerId(v string) { x.xxx_hidden_CustomerId = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 12) } func (x *OpaqueCustomer) SetEmail(v string) { x.xxx_hidden_Email = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 12) } func (x *OpaqueCustomer) SetFirstName(v string) { x.xxx_hidden_FirstName = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 2, 12) } func (x *OpaqueCustomer) SetLastName(v string) { x.xxx_hidden_LastName = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 3, 12) } func (x *OpaqueCustomer) SetPhoneNumber(v string) { x.xxx_hidden_PhoneNumber = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 4, 12) } func (x *OpaqueCustomer) SetAddresses(v []*OpaqueAddress) { x.xxx_hidden_Addresses = &v } func (x *OpaqueCustomer) SetCreatedAt(v *timestamppb.Timestamp) { x.xxx_hidden_CreatedAt = v } func (x *OpaqueCustomer) SetLastLogin(v *timestamppb.Timestamp) { x.xxx_hidden_LastLogin = v } func (x *OpaqueCustomer) SetStatus(v OpaqueCustomer_OpaqueCustomerStatus) { x.xxx_hidden_Status = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 8, 12) } func (x *OpaqueCustomer) SetLoyaltyInfo(v *OpaqueCustomer_OpaqueLoyaltyInfo) { x.xxx_hidden_LoyaltyInfo = v } func (x *OpaqueCustomer) SetPreferences(v map[string]string) { x.xxx_hidden_Preferences = v } func (x *OpaqueCustomer) SetPaymentMethods(v []*OpaqueCustomer_OpaquePaymentMethod) { x.xxx_hidden_PaymentMethods = &v } func (x *OpaqueCustomer) HasCustomerId() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 0) } func (x *OpaqueCustomer) HasEmail() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 1) } func (x *OpaqueCustomer) HasFirstName() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 2) } func (x *OpaqueCustomer) HasLastName() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 3) } func (x *OpaqueCustomer) HasPhoneNumber() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 4) } func (x *OpaqueCustomer) HasCreatedAt() bool { if x == nil { return false } return x.xxx_hidden_CreatedAt != nil } func (x *OpaqueCustomer) HasLastLogin() bool { if x == nil { return false } return x.xxx_hidden_LastLogin != nil } func (x *OpaqueCustomer) HasStatus() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 8) } func (x *OpaqueCustomer) HasLoyaltyInfo() bool { if x == nil { return false } return x.xxx_hidden_LoyaltyInfo != nil } func (x *OpaqueCustomer) ClearCustomerId() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) x.xxx_hidden_CustomerId = nil } func (x *OpaqueCustomer) ClearEmail() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) x.xxx_hidden_Email = nil } func (x *OpaqueCustomer) ClearFirstName() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 2) x.xxx_hidden_FirstName = nil } func (x *OpaqueCustomer) ClearLastName() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 3) x.xxx_hidden_LastName = nil } func (x *OpaqueCustomer) ClearPhoneNumber() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 4) x.xxx_hidden_PhoneNumber = nil } func (x *OpaqueCustomer) ClearCreatedAt() { x.xxx_hidden_CreatedAt = nil } func (x *OpaqueCustomer) ClearLastLogin() { x.xxx_hidden_LastLogin = nil } func (x *OpaqueCustomer) ClearStatus() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 8) x.xxx_hidden_Status = OpaqueCustomer_OPAQUE_CUSTOMER_STATUS_UNSPECIFIED } func (x *OpaqueCustomer) ClearLoyaltyInfo() { x.xxx_hidden_LoyaltyInfo = nil } type OpaqueCustomer_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. CustomerId *string Email *string FirstName *string LastName *string PhoneNumber *string Addresses []*OpaqueAddress CreatedAt *timestamppb.Timestamp LastLogin *timestamppb.Timestamp Status *OpaqueCustomer_OpaqueCustomerStatus LoyaltyInfo *OpaqueCustomer_OpaqueLoyaltyInfo Preferences map[string]string PaymentMethods []*OpaqueCustomer_OpaquePaymentMethod } func (b0 OpaqueCustomer_builder) Build() *OpaqueCustomer { m0 := &OpaqueCustomer{} b, x := &b0, m0 _, _ = b, x if b.CustomerId != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 12) x.xxx_hidden_CustomerId = b.CustomerId } if b.Email != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 12) x.xxx_hidden_Email = b.Email } if b.FirstName != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 2, 12) x.xxx_hidden_FirstName = b.FirstName } if b.LastName != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 3, 12) x.xxx_hidden_LastName = b.LastName } if b.PhoneNumber != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 4, 12) x.xxx_hidden_PhoneNumber = b.PhoneNumber } x.xxx_hidden_Addresses = &b.Addresses x.xxx_hidden_CreatedAt = b.CreatedAt x.xxx_hidden_LastLogin = b.LastLogin if b.Status != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 8, 12) x.xxx_hidden_Status = *b.Status } x.xxx_hidden_LoyaltyInfo = b.LoyaltyInfo x.xxx_hidden_Preferences = b.Preferences x.xxx_hidden_PaymentMethods = &b.PaymentMethods return m0 } // OpaqueOrderItem represents an item in an order type OpaqueOrderItem struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_ProductId *string `protobuf:"bytes,1,opt,name=product_id,json=productId"` xxx_hidden_VariantId *string `protobuf:"bytes,2,opt,name=variant_id,json=variantId"` xxx_hidden_ProductName *string `protobuf:"bytes,3,opt,name=product_name,json=productName"` xxx_hidden_Quantity int32 `protobuf:"varint,4,opt,name=quantity"` xxx_hidden_UnitPrice *OpaquePrice `protobuf:"bytes,5,opt,name=unit_price,json=unitPrice"` xxx_hidden_TotalPrice *OpaquePrice `protobuf:"bytes,6,opt,name=total_price,json=totalPrice"` xxx_hidden_SelectedAttributes map[string]string `protobuf:"bytes,7,rep,name=selected_attributes,json=selectedAttributes" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` xxx_hidden_GiftWrapped *wrapperspb.BoolValue `protobuf:"bytes,8,opt,name=gift_wrapped,json=giftWrapped"` xxx_hidden_GiftMessage *string `protobuf:"bytes,9,opt,name=gift_message,json=giftMessage"` XXX_raceDetectHookData protoimpl.RaceDetectHookData XXX_presence [1]uint32 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueOrderItem) Reset() { *x = OpaqueOrderItem{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueOrderItem) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueOrderItem) ProtoMessage() {} func (x *OpaqueOrderItem) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[24] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueOrderItem) GetProductId() string { if x != nil { if x.xxx_hidden_ProductId != nil { return *x.xxx_hidden_ProductId } return "" } return "" } func (x *OpaqueOrderItem) GetVariantId() string { if x != nil { if x.xxx_hidden_VariantId != nil { return *x.xxx_hidden_VariantId } return "" } return "" } func (x *OpaqueOrderItem) GetProductName() string { if x != nil { if x.xxx_hidden_ProductName != nil { return *x.xxx_hidden_ProductName } return "" } return "" } func (x *OpaqueOrderItem) GetQuantity() int32 { if x != nil { return x.xxx_hidden_Quantity } return 0 } func (x *OpaqueOrderItem) GetUnitPrice() *OpaquePrice { if x != nil { return x.xxx_hidden_UnitPrice } return nil } func (x *OpaqueOrderItem) GetTotalPrice() *OpaquePrice { if x != nil { return x.xxx_hidden_TotalPrice } return nil } func (x *OpaqueOrderItem) GetSelectedAttributes() map[string]string { if x != nil { return x.xxx_hidden_SelectedAttributes } return nil } func (x *OpaqueOrderItem) GetGiftWrapped() *wrapperspb.BoolValue { if x != nil { return x.xxx_hidden_GiftWrapped } return nil } func (x *OpaqueOrderItem) GetGiftMessage() string { if x != nil { if x.xxx_hidden_GiftMessage != nil { return *x.xxx_hidden_GiftMessage } return "" } return "" } func (x *OpaqueOrderItem) SetProductId(v string) { x.xxx_hidden_ProductId = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 9) } func (x *OpaqueOrderItem) SetVariantId(v string) { x.xxx_hidden_VariantId = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 9) } func (x *OpaqueOrderItem) SetProductName(v string) { x.xxx_hidden_ProductName = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 2, 9) } func (x *OpaqueOrderItem) SetQuantity(v int32) { x.xxx_hidden_Quantity = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 3, 9) } func (x *OpaqueOrderItem) SetUnitPrice(v *OpaquePrice) { x.xxx_hidden_UnitPrice = v } func (x *OpaqueOrderItem) SetTotalPrice(v *OpaquePrice) { x.xxx_hidden_TotalPrice = v } func (x *OpaqueOrderItem) SetSelectedAttributes(v map[string]string) { x.xxx_hidden_SelectedAttributes = v } func (x *OpaqueOrderItem) SetGiftWrapped(v *wrapperspb.BoolValue) { x.xxx_hidden_GiftWrapped = v } func (x *OpaqueOrderItem) SetGiftMessage(v string) { x.xxx_hidden_GiftMessage = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 8, 9) } func (x *OpaqueOrderItem) HasProductId() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 0) } func (x *OpaqueOrderItem) HasVariantId() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 1) } func (x *OpaqueOrderItem) HasProductName() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 2) } func (x *OpaqueOrderItem) HasQuantity() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 3) } func (x *OpaqueOrderItem) HasUnitPrice() bool { if x == nil { return false } return x.xxx_hidden_UnitPrice != nil } func (x *OpaqueOrderItem) HasTotalPrice() bool { if x == nil { return false } return x.xxx_hidden_TotalPrice != nil } func (x *OpaqueOrderItem) HasGiftWrapped() bool { if x == nil { return false } return x.xxx_hidden_GiftWrapped != nil } func (x *OpaqueOrderItem) HasGiftMessage() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 8) } func (x *OpaqueOrderItem) ClearProductId() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) x.xxx_hidden_ProductId = nil } func (x *OpaqueOrderItem) ClearVariantId() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) x.xxx_hidden_VariantId = nil } func (x *OpaqueOrderItem) ClearProductName() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 2) x.xxx_hidden_ProductName = nil } func (x *OpaqueOrderItem) ClearQuantity() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 3) x.xxx_hidden_Quantity = 0 } func (x *OpaqueOrderItem) ClearUnitPrice() { x.xxx_hidden_UnitPrice = nil } func (x *OpaqueOrderItem) ClearTotalPrice() { x.xxx_hidden_TotalPrice = nil } func (x *OpaqueOrderItem) ClearGiftWrapped() { x.xxx_hidden_GiftWrapped = nil } func (x *OpaqueOrderItem) ClearGiftMessage() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 8) x.xxx_hidden_GiftMessage = nil } type OpaqueOrderItem_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. ProductId *string VariantId *string ProductName *string Quantity *int32 UnitPrice *OpaquePrice TotalPrice *OpaquePrice SelectedAttributes map[string]string GiftWrapped *wrapperspb.BoolValue GiftMessage *string } func (b0 OpaqueOrderItem_builder) Build() *OpaqueOrderItem { m0 := &OpaqueOrderItem{} b, x := &b0, m0 _, _ = b, x if b.ProductId != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 9) x.xxx_hidden_ProductId = b.ProductId } if b.VariantId != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 9) x.xxx_hidden_VariantId = b.VariantId } if b.ProductName != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 2, 9) x.xxx_hidden_ProductName = b.ProductName } if b.Quantity != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 3, 9) x.xxx_hidden_Quantity = *b.Quantity } x.xxx_hidden_UnitPrice = b.UnitPrice x.xxx_hidden_TotalPrice = b.TotalPrice x.xxx_hidden_SelectedAttributes = b.SelectedAttributes x.xxx_hidden_GiftWrapped = b.GiftWrapped if b.GiftMessage != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 8, 9) x.xxx_hidden_GiftMessage = b.GiftMessage } return m0 } // OpaqueOrder represents a customer order type OpaqueOrder struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_OrderId *string `protobuf:"bytes,1,opt,name=order_id,json=orderId"` xxx_hidden_CustomerId *string `protobuf:"bytes,2,opt,name=customer_id,json=customerId"` xxx_hidden_Items *[]*OpaqueOrderItem `protobuf:"bytes,3,rep,name=items"` xxx_hidden_Subtotal *OpaquePrice `protobuf:"bytes,4,opt,name=subtotal"` xxx_hidden_Tax *OpaquePrice `protobuf:"bytes,5,opt,name=tax"` xxx_hidden_Shipping *OpaquePrice `protobuf:"bytes,6,opt,name=shipping"` xxx_hidden_Total *OpaquePrice `protobuf:"bytes,7,opt,name=total"` xxx_hidden_ShippingAddress *OpaqueAddress `protobuf:"bytes,8,opt,name=shipping_address,json=shippingAddress"` xxx_hidden_BillingAddress *OpaqueAddress `protobuf:"bytes,9,opt,name=billing_address,json=billingAddress"` xxx_hidden_Status OpaqueOrder_OpaqueOrderStatus `protobuf:"varint,10,opt,name=status,enum=grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder_OpaqueOrderStatus"` xxx_hidden_PaymentMethodId *string `protobuf:"bytes,11,opt,name=payment_method_id,json=paymentMethodId"` xxx_hidden_TrackingNumber *string `protobuf:"bytes,12,opt,name=tracking_number,json=trackingNumber"` xxx_hidden_CreatedAt *timestamppb.Timestamp `protobuf:"bytes,13,opt,name=created_at,json=createdAt"` xxx_hidden_UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,14,opt,name=updated_at,json=updatedAt"` xxx_hidden_ShippedAt *timestamppb.Timestamp `protobuf:"bytes,15,opt,name=shipped_at,json=shippedAt"` xxx_hidden_DeliveredAt *timestamppb.Timestamp `protobuf:"bytes,16,opt,name=delivered_at,json=deliveredAt"` xxx_hidden_ShippingInfo *OpaqueOrder_OpaqueShippingInfo `protobuf:"bytes,17,opt,name=shipping_info,json=shippingInfo"` xxx_hidden_Metadata map[string]string `protobuf:"bytes,18,rep,name=metadata" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` xxx_hidden_DiscountApplied isOpaqueOrder_DiscountApplied `protobuf_oneof:"discount_applied"` XXX_raceDetectHookData protoimpl.RaceDetectHookData XXX_presence [1]uint32 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueOrder) Reset() { *x = OpaqueOrder{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueOrder) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueOrder) ProtoMessage() {} func (x *OpaqueOrder) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[25] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueOrder) GetOrderId() string { if x != nil { if x.xxx_hidden_OrderId != nil { return *x.xxx_hidden_OrderId } return "" } return "" } func (x *OpaqueOrder) GetCustomerId() string { if x != nil { if x.xxx_hidden_CustomerId != nil { return *x.xxx_hidden_CustomerId } return "" } return "" } func (x *OpaqueOrder) GetItems() []*OpaqueOrderItem { if x != nil { if x.xxx_hidden_Items != nil { return *x.xxx_hidden_Items } } return nil } func (x *OpaqueOrder) GetSubtotal() *OpaquePrice { if x != nil { return x.xxx_hidden_Subtotal } return nil } func (x *OpaqueOrder) GetTax() *OpaquePrice { if x != nil { return x.xxx_hidden_Tax } return nil } func (x *OpaqueOrder) GetShipping() *OpaquePrice { if x != nil { return x.xxx_hidden_Shipping } return nil } func (x *OpaqueOrder) GetTotal() *OpaquePrice { if x != nil { return x.xxx_hidden_Total } return nil } func (x *OpaqueOrder) GetShippingAddress() *OpaqueAddress { if x != nil { return x.xxx_hidden_ShippingAddress } return nil } func (x *OpaqueOrder) GetBillingAddress() *OpaqueAddress { if x != nil { return x.xxx_hidden_BillingAddress } return nil } func (x *OpaqueOrder) GetStatus() OpaqueOrder_OpaqueOrderStatus { if x != nil { if protoimpl.X.Present(&(x.XXX_presence[0]), 9) { return x.xxx_hidden_Status } } return OpaqueOrder_OPAQUE_ORDER_STATUS_UNSPECIFIED } func (x *OpaqueOrder) GetPaymentMethodId() string { if x != nil { if x.xxx_hidden_PaymentMethodId != nil { return *x.xxx_hidden_PaymentMethodId } return "" } return "" } func (x *OpaqueOrder) GetTrackingNumber() string { if x != nil { if x.xxx_hidden_TrackingNumber != nil { return *x.xxx_hidden_TrackingNumber } return "" } return "" } func (x *OpaqueOrder) GetCreatedAt() *timestamppb.Timestamp { if x != nil { return x.xxx_hidden_CreatedAt } return nil } func (x *OpaqueOrder) GetUpdatedAt() *timestamppb.Timestamp { if x != nil { return x.xxx_hidden_UpdatedAt } return nil } func (x *OpaqueOrder) GetShippedAt() *timestamppb.Timestamp { if x != nil { return x.xxx_hidden_ShippedAt } return nil } func (x *OpaqueOrder) GetDeliveredAt() *timestamppb.Timestamp { if x != nil { return x.xxx_hidden_DeliveredAt } return nil } func (x *OpaqueOrder) GetShippingInfo() *OpaqueOrder_OpaqueShippingInfo { if x != nil { return x.xxx_hidden_ShippingInfo } return nil } func (x *OpaqueOrder) GetMetadata() map[string]string { if x != nil { return x.xxx_hidden_Metadata } return nil } func (x *OpaqueOrder) GetCouponCode() string { if x != nil { if x, ok := x.xxx_hidden_DiscountApplied.(*opaqueOrder_CouponCode); ok { return x.CouponCode } } return "" } func (x *OpaqueOrder) GetPromotionId() string { if x != nil { if x, ok := x.xxx_hidden_DiscountApplied.(*opaqueOrder_PromotionId); ok { return x.PromotionId } } return "" } func (x *OpaqueOrder) SetOrderId(v string) { x.xxx_hidden_OrderId = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 19) } func (x *OpaqueOrder) SetCustomerId(v string) { x.xxx_hidden_CustomerId = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 19) } func (x *OpaqueOrder) SetItems(v []*OpaqueOrderItem) { x.xxx_hidden_Items = &v } func (x *OpaqueOrder) SetSubtotal(v *OpaquePrice) { x.xxx_hidden_Subtotal = v } func (x *OpaqueOrder) SetTax(v *OpaquePrice) { x.xxx_hidden_Tax = v } func (x *OpaqueOrder) SetShipping(v *OpaquePrice) { x.xxx_hidden_Shipping = v } func (x *OpaqueOrder) SetTotal(v *OpaquePrice) { x.xxx_hidden_Total = v } func (x *OpaqueOrder) SetShippingAddress(v *OpaqueAddress) { x.xxx_hidden_ShippingAddress = v } func (x *OpaqueOrder) SetBillingAddress(v *OpaqueAddress) { x.xxx_hidden_BillingAddress = v } func (x *OpaqueOrder) SetStatus(v OpaqueOrder_OpaqueOrderStatus) { x.xxx_hidden_Status = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 9, 19) } func (x *OpaqueOrder) SetPaymentMethodId(v string) { x.xxx_hidden_PaymentMethodId = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 10, 19) } func (x *OpaqueOrder) SetTrackingNumber(v string) { x.xxx_hidden_TrackingNumber = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 11, 19) } func (x *OpaqueOrder) SetCreatedAt(v *timestamppb.Timestamp) { x.xxx_hidden_CreatedAt = v } func (x *OpaqueOrder) SetUpdatedAt(v *timestamppb.Timestamp) { x.xxx_hidden_UpdatedAt = v } func (x *OpaqueOrder) SetShippedAt(v *timestamppb.Timestamp) { x.xxx_hidden_ShippedAt = v } func (x *OpaqueOrder) SetDeliveredAt(v *timestamppb.Timestamp) { x.xxx_hidden_DeliveredAt = v } func (x *OpaqueOrder) SetShippingInfo(v *OpaqueOrder_OpaqueShippingInfo) { x.xxx_hidden_ShippingInfo = v } func (x *OpaqueOrder) SetMetadata(v map[string]string) { x.xxx_hidden_Metadata = v } func (x *OpaqueOrder) SetCouponCode(v string) { x.xxx_hidden_DiscountApplied = &opaqueOrder_CouponCode{v} } func (x *OpaqueOrder) SetPromotionId(v string) { x.xxx_hidden_DiscountApplied = &opaqueOrder_PromotionId{v} } func (x *OpaqueOrder) HasOrderId() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 0) } func (x *OpaqueOrder) HasCustomerId() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 1) } func (x *OpaqueOrder) HasSubtotal() bool { if x == nil { return false } return x.xxx_hidden_Subtotal != nil } func (x *OpaqueOrder) HasTax() bool { if x == nil { return false } return x.xxx_hidden_Tax != nil } func (x *OpaqueOrder) HasShipping() bool { if x == nil { return false } return x.xxx_hidden_Shipping != nil } func (x *OpaqueOrder) HasTotal() bool { if x == nil { return false } return x.xxx_hidden_Total != nil } func (x *OpaqueOrder) HasShippingAddress() bool { if x == nil { return false } return x.xxx_hidden_ShippingAddress != nil } func (x *OpaqueOrder) HasBillingAddress() bool { if x == nil { return false } return x.xxx_hidden_BillingAddress != nil } func (x *OpaqueOrder) HasStatus() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 9) } func (x *OpaqueOrder) HasPaymentMethodId() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 10) } func (x *OpaqueOrder) HasTrackingNumber() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 11) } func (x *OpaqueOrder) HasCreatedAt() bool { if x == nil { return false } return x.xxx_hidden_CreatedAt != nil } func (x *OpaqueOrder) HasUpdatedAt() bool { if x == nil { return false } return x.xxx_hidden_UpdatedAt != nil } func (x *OpaqueOrder) HasShippedAt() bool { if x == nil { return false } return x.xxx_hidden_ShippedAt != nil } func (x *OpaqueOrder) HasDeliveredAt() bool { if x == nil { return false } return x.xxx_hidden_DeliveredAt != nil } func (x *OpaqueOrder) HasShippingInfo() bool { if x == nil { return false } return x.xxx_hidden_ShippingInfo != nil } func (x *OpaqueOrder) HasDiscountApplied() bool { if x == nil { return false } return x.xxx_hidden_DiscountApplied != nil } func (x *OpaqueOrder) HasCouponCode() bool { if x == nil { return false } _, ok := x.xxx_hidden_DiscountApplied.(*opaqueOrder_CouponCode) return ok } func (x *OpaqueOrder) HasPromotionId() bool { if x == nil { return false } _, ok := x.xxx_hidden_DiscountApplied.(*opaqueOrder_PromotionId) return ok } func (x *OpaqueOrder) ClearOrderId() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) x.xxx_hidden_OrderId = nil } func (x *OpaqueOrder) ClearCustomerId() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) x.xxx_hidden_CustomerId = nil } func (x *OpaqueOrder) ClearSubtotal() { x.xxx_hidden_Subtotal = nil } func (x *OpaqueOrder) ClearTax() { x.xxx_hidden_Tax = nil } func (x *OpaqueOrder) ClearShipping() { x.xxx_hidden_Shipping = nil } func (x *OpaqueOrder) ClearTotal() { x.xxx_hidden_Total = nil } func (x *OpaqueOrder) ClearShippingAddress() { x.xxx_hidden_ShippingAddress = nil } func (x *OpaqueOrder) ClearBillingAddress() { x.xxx_hidden_BillingAddress = nil } func (x *OpaqueOrder) ClearStatus() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 9) x.xxx_hidden_Status = OpaqueOrder_OPAQUE_ORDER_STATUS_UNSPECIFIED } func (x *OpaqueOrder) ClearPaymentMethodId() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 10) x.xxx_hidden_PaymentMethodId = nil } func (x *OpaqueOrder) ClearTrackingNumber() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 11) x.xxx_hidden_TrackingNumber = nil } func (x *OpaqueOrder) ClearCreatedAt() { x.xxx_hidden_CreatedAt = nil } func (x *OpaqueOrder) ClearUpdatedAt() { x.xxx_hidden_UpdatedAt = nil } func (x *OpaqueOrder) ClearShippedAt() { x.xxx_hidden_ShippedAt = nil } func (x *OpaqueOrder) ClearDeliveredAt() { x.xxx_hidden_DeliveredAt = nil } func (x *OpaqueOrder) ClearShippingInfo() { x.xxx_hidden_ShippingInfo = nil } func (x *OpaqueOrder) ClearDiscountApplied() { x.xxx_hidden_DiscountApplied = nil } func (x *OpaqueOrder) ClearCouponCode() { if _, ok := x.xxx_hidden_DiscountApplied.(*opaqueOrder_CouponCode); ok { x.xxx_hidden_DiscountApplied = nil } } func (x *OpaqueOrder) ClearPromotionId() { if _, ok := x.xxx_hidden_DiscountApplied.(*opaqueOrder_PromotionId); ok { x.xxx_hidden_DiscountApplied = nil } } const OpaqueOrder_DiscountApplied_not_set_case case_OpaqueOrder_DiscountApplied = 0 const OpaqueOrder_CouponCode_case case_OpaqueOrder_DiscountApplied = 19 const OpaqueOrder_PromotionId_case case_OpaqueOrder_DiscountApplied = 20 func (x *OpaqueOrder) WhichDiscountApplied() case_OpaqueOrder_DiscountApplied { if x == nil { return OpaqueOrder_DiscountApplied_not_set_case } switch x.xxx_hidden_DiscountApplied.(type) { case *opaqueOrder_CouponCode: return OpaqueOrder_CouponCode_case case *opaqueOrder_PromotionId: return OpaqueOrder_PromotionId_case default: return OpaqueOrder_DiscountApplied_not_set_case } } type OpaqueOrder_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. OrderId *string CustomerId *string Items []*OpaqueOrderItem Subtotal *OpaquePrice Tax *OpaquePrice Shipping *OpaquePrice Total *OpaquePrice ShippingAddress *OpaqueAddress BillingAddress *OpaqueAddress Status *OpaqueOrder_OpaqueOrderStatus PaymentMethodId *string TrackingNumber *string CreatedAt *timestamppb.Timestamp UpdatedAt *timestamppb.Timestamp ShippedAt *timestamppb.Timestamp DeliveredAt *timestamppb.Timestamp ShippingInfo *OpaqueOrder_OpaqueShippingInfo Metadata map[string]string // Fields of oneof xxx_hidden_DiscountApplied: CouponCode *string PromotionId *string // -- end of xxx_hidden_DiscountApplied } func (b0 OpaqueOrder_builder) Build() *OpaqueOrder { m0 := &OpaqueOrder{} b, x := &b0, m0 _, _ = b, x if b.OrderId != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 19) x.xxx_hidden_OrderId = b.OrderId } if b.CustomerId != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 19) x.xxx_hidden_CustomerId = b.CustomerId } x.xxx_hidden_Items = &b.Items x.xxx_hidden_Subtotal = b.Subtotal x.xxx_hidden_Tax = b.Tax x.xxx_hidden_Shipping = b.Shipping x.xxx_hidden_Total = b.Total x.xxx_hidden_ShippingAddress = b.ShippingAddress x.xxx_hidden_BillingAddress = b.BillingAddress if b.Status != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 9, 19) x.xxx_hidden_Status = *b.Status } if b.PaymentMethodId != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 10, 19) x.xxx_hidden_PaymentMethodId = b.PaymentMethodId } if b.TrackingNumber != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 11, 19) x.xxx_hidden_TrackingNumber = b.TrackingNumber } x.xxx_hidden_CreatedAt = b.CreatedAt x.xxx_hidden_UpdatedAt = b.UpdatedAt x.xxx_hidden_ShippedAt = b.ShippedAt x.xxx_hidden_DeliveredAt = b.DeliveredAt x.xxx_hidden_ShippingInfo = b.ShippingInfo x.xxx_hidden_Metadata = b.Metadata if b.CouponCode != nil { x.xxx_hidden_DiscountApplied = &opaqueOrder_CouponCode{*b.CouponCode} } if b.PromotionId != nil { x.xxx_hidden_DiscountApplied = &opaqueOrder_PromotionId{*b.PromotionId} } return m0 } type case_OpaqueOrder_DiscountApplied protoreflect.FieldNumber func (x case_OpaqueOrder_DiscountApplied) String() string { md := file_examples_internal_proto_examplepb_opaque_proto_msgTypes[25].Descriptor() if x == 0 { return "not set" } return protoimpl.X.MessageFieldStringOf(md, protoreflect.FieldNumber(x)) } type isOpaqueOrder_DiscountApplied interface { isOpaqueOrder_DiscountApplied() } type opaqueOrder_CouponCode struct { CouponCode string `protobuf:"bytes,19,opt,name=coupon_code,json=couponCode,oneof"` } type opaqueOrder_PromotionId struct { PromotionId string `protobuf:"bytes,20,opt,name=promotion_id,json=promotionId,oneof"` } func (*opaqueOrder_CouponCode) isOpaqueOrder_DiscountApplied() {} func (*opaqueOrder_PromotionId) isOpaqueOrder_DiscountApplied() {} // OpaqueOrderSummary represents a summary of processed orders type OpaqueOrderSummary struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_TotalOrdersProcessed int32 `protobuf:"varint,1,opt,name=total_orders_processed,json=totalOrdersProcessed"` xxx_hidden_SuccessfulOrders int32 `protobuf:"varint,2,opt,name=successful_orders,json=successfulOrders"` xxx_hidden_FailedOrders int32 `protobuf:"varint,3,opt,name=failed_orders,json=failedOrders"` xxx_hidden_TotalValue *OpaquePrice `protobuf:"bytes,4,opt,name=total_value,json=totalValue"` xxx_hidden_OrderIds []string `protobuf:"bytes,5,rep,name=order_ids,json=orderIds"` xxx_hidden_ErrorDetails map[string]string `protobuf:"bytes,6,rep,name=error_details,json=errorDetails" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` xxx_hidden_ProcessingTime *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=processing_time,json=processingTime"` xxx_hidden_Errors *[]*OpaqueOrderSummary_OpaqueOrderError `protobuf:"bytes,8,rep,name=errors"` XXX_raceDetectHookData protoimpl.RaceDetectHookData XXX_presence [1]uint32 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueOrderSummary) Reset() { *x = OpaqueOrderSummary{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueOrderSummary) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueOrderSummary) ProtoMessage() {} func (x *OpaqueOrderSummary) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[26] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueOrderSummary) GetTotalOrdersProcessed() int32 { if x != nil { return x.xxx_hidden_TotalOrdersProcessed } return 0 } func (x *OpaqueOrderSummary) GetSuccessfulOrders() int32 { if x != nil { return x.xxx_hidden_SuccessfulOrders } return 0 } func (x *OpaqueOrderSummary) GetFailedOrders() int32 { if x != nil { return x.xxx_hidden_FailedOrders } return 0 } func (x *OpaqueOrderSummary) GetTotalValue() *OpaquePrice { if x != nil { return x.xxx_hidden_TotalValue } return nil } func (x *OpaqueOrderSummary) GetOrderIds() []string { if x != nil { return x.xxx_hidden_OrderIds } return nil } func (x *OpaqueOrderSummary) GetErrorDetails() map[string]string { if x != nil { return x.xxx_hidden_ErrorDetails } return nil } func (x *OpaqueOrderSummary) GetProcessingTime() *timestamppb.Timestamp { if x != nil { return x.xxx_hidden_ProcessingTime } return nil } func (x *OpaqueOrderSummary) GetErrors() []*OpaqueOrderSummary_OpaqueOrderError { if x != nil { if x.xxx_hidden_Errors != nil { return *x.xxx_hidden_Errors } } return nil } func (x *OpaqueOrderSummary) SetTotalOrdersProcessed(v int32) { x.xxx_hidden_TotalOrdersProcessed = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 8) } func (x *OpaqueOrderSummary) SetSuccessfulOrders(v int32) { x.xxx_hidden_SuccessfulOrders = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 8) } func (x *OpaqueOrderSummary) SetFailedOrders(v int32) { x.xxx_hidden_FailedOrders = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 2, 8) } func (x *OpaqueOrderSummary) SetTotalValue(v *OpaquePrice) { x.xxx_hidden_TotalValue = v } func (x *OpaqueOrderSummary) SetOrderIds(v []string) { x.xxx_hidden_OrderIds = v } func (x *OpaqueOrderSummary) SetErrorDetails(v map[string]string) { x.xxx_hidden_ErrorDetails = v } func (x *OpaqueOrderSummary) SetProcessingTime(v *timestamppb.Timestamp) { x.xxx_hidden_ProcessingTime = v } func (x *OpaqueOrderSummary) SetErrors(v []*OpaqueOrderSummary_OpaqueOrderError) { x.xxx_hidden_Errors = &v } func (x *OpaqueOrderSummary) HasTotalOrdersProcessed() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 0) } func (x *OpaqueOrderSummary) HasSuccessfulOrders() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 1) } func (x *OpaqueOrderSummary) HasFailedOrders() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 2) } func (x *OpaqueOrderSummary) HasTotalValue() bool { if x == nil { return false } return x.xxx_hidden_TotalValue != nil } func (x *OpaqueOrderSummary) HasProcessingTime() bool { if x == nil { return false } return x.xxx_hidden_ProcessingTime != nil } func (x *OpaqueOrderSummary) ClearTotalOrdersProcessed() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) x.xxx_hidden_TotalOrdersProcessed = 0 } func (x *OpaqueOrderSummary) ClearSuccessfulOrders() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) x.xxx_hidden_SuccessfulOrders = 0 } func (x *OpaqueOrderSummary) ClearFailedOrders() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 2) x.xxx_hidden_FailedOrders = 0 } func (x *OpaqueOrderSummary) ClearTotalValue() { x.xxx_hidden_TotalValue = nil } func (x *OpaqueOrderSummary) ClearProcessingTime() { x.xxx_hidden_ProcessingTime = nil } type OpaqueOrderSummary_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. TotalOrdersProcessed *int32 SuccessfulOrders *int32 FailedOrders *int32 TotalValue *OpaquePrice OrderIds []string ErrorDetails map[string]string ProcessingTime *timestamppb.Timestamp Errors []*OpaqueOrderSummary_OpaqueOrderError } func (b0 OpaqueOrderSummary_builder) Build() *OpaqueOrderSummary { m0 := &OpaqueOrderSummary{} b, x := &b0, m0 _, _ = b, x if b.TotalOrdersProcessed != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 8) x.xxx_hidden_TotalOrdersProcessed = *b.TotalOrdersProcessed } if b.SuccessfulOrders != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 8) x.xxx_hidden_SuccessfulOrders = *b.SuccessfulOrders } if b.FailedOrders != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 2, 8) x.xxx_hidden_FailedOrders = *b.FailedOrders } x.xxx_hidden_TotalValue = b.TotalValue x.xxx_hidden_OrderIds = b.OrderIds x.xxx_hidden_ErrorDetails = b.ErrorDetails x.xxx_hidden_ProcessingTime = b.ProcessingTime x.xxx_hidden_Errors = &b.Errors return m0 } // OpaqueCustomerEvent represents a customer activity event type OpaqueCustomerEvent struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_CustomerId *string `protobuf:"bytes,1,opt,name=customer_id,json=customerId"` xxx_hidden_SessionId *string `protobuf:"bytes,2,opt,name=session_id,json=sessionId"` xxx_hidden_EventType OpaqueCustomerEvent_OpaqueEventType `protobuf:"varint,3,opt,name=event_type,json=eventType,enum=grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomerEvent_OpaqueEventType"` xxx_hidden_Timestamp *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=timestamp"` xxx_hidden_ProductId *string `protobuf:"bytes,5,opt,name=product_id,json=productId"` xxx_hidden_CategoryId *string `protobuf:"bytes,6,opt,name=category_id,json=categoryId"` xxx_hidden_SearchQuery *string `protobuf:"bytes,7,opt,name=search_query,json=searchQuery"` xxx_hidden_PageUrl *string `protobuf:"bytes,8,opt,name=page_url,json=pageUrl"` xxx_hidden_Value int32 `protobuf:"varint,9,opt,name=value"` xxx_hidden_EventData map[string]string `protobuf:"bytes,10,rep,name=event_data,json=eventData" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` xxx_hidden_DeviceType *string `protobuf:"bytes,11,opt,name=device_type,json=deviceType"` xxx_hidden_IpAddress *string `protobuf:"bytes,12,opt,name=ip_address,json=ipAddress"` xxx_hidden_UserAgent *string `protobuf:"bytes,13,opt,name=user_agent,json=userAgent"` XXX_raceDetectHookData protoimpl.RaceDetectHookData XXX_presence [1]uint32 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueCustomerEvent) Reset() { *x = OpaqueCustomerEvent{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueCustomerEvent) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueCustomerEvent) ProtoMessage() {} func (x *OpaqueCustomerEvent) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[27] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueCustomerEvent) GetCustomerId() string { if x != nil { if x.xxx_hidden_CustomerId != nil { return *x.xxx_hidden_CustomerId } return "" } return "" } func (x *OpaqueCustomerEvent) GetSessionId() string { if x != nil { if x.xxx_hidden_SessionId != nil { return *x.xxx_hidden_SessionId } return "" } return "" } func (x *OpaqueCustomerEvent) GetEventType() OpaqueCustomerEvent_OpaqueEventType { if x != nil { if protoimpl.X.Present(&(x.XXX_presence[0]), 2) { return x.xxx_hidden_EventType } } return OpaqueCustomerEvent_OPAQUE_EVENT_TYPE_UNSPECIFIED } func (x *OpaqueCustomerEvent) GetTimestamp() *timestamppb.Timestamp { if x != nil { return x.xxx_hidden_Timestamp } return nil } func (x *OpaqueCustomerEvent) GetProductId() string { if x != nil { if x.xxx_hidden_ProductId != nil { return *x.xxx_hidden_ProductId } return "" } return "" } func (x *OpaqueCustomerEvent) GetCategoryId() string { if x != nil { if x.xxx_hidden_CategoryId != nil { return *x.xxx_hidden_CategoryId } return "" } return "" } func (x *OpaqueCustomerEvent) GetSearchQuery() string { if x != nil { if x.xxx_hidden_SearchQuery != nil { return *x.xxx_hidden_SearchQuery } return "" } return "" } func (x *OpaqueCustomerEvent) GetPageUrl() string { if x != nil { if x.xxx_hidden_PageUrl != nil { return *x.xxx_hidden_PageUrl } return "" } return "" } func (x *OpaqueCustomerEvent) GetValue() int32 { if x != nil { return x.xxx_hidden_Value } return 0 } func (x *OpaqueCustomerEvent) GetEventData() map[string]string { if x != nil { return x.xxx_hidden_EventData } return nil } func (x *OpaqueCustomerEvent) GetDeviceType() string { if x != nil { if x.xxx_hidden_DeviceType != nil { return *x.xxx_hidden_DeviceType } return "" } return "" } func (x *OpaqueCustomerEvent) GetIpAddress() string { if x != nil { if x.xxx_hidden_IpAddress != nil { return *x.xxx_hidden_IpAddress } return "" } return "" } func (x *OpaqueCustomerEvent) GetUserAgent() string { if x != nil { if x.xxx_hidden_UserAgent != nil { return *x.xxx_hidden_UserAgent } return "" } return "" } func (x *OpaqueCustomerEvent) SetCustomerId(v string) { x.xxx_hidden_CustomerId = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 13) } func (x *OpaqueCustomerEvent) SetSessionId(v string) { x.xxx_hidden_SessionId = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 13) } func (x *OpaqueCustomerEvent) SetEventType(v OpaqueCustomerEvent_OpaqueEventType) { x.xxx_hidden_EventType = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 2, 13) } func (x *OpaqueCustomerEvent) SetTimestamp(v *timestamppb.Timestamp) { x.xxx_hidden_Timestamp = v } func (x *OpaqueCustomerEvent) SetProductId(v string) { x.xxx_hidden_ProductId = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 4, 13) } func (x *OpaqueCustomerEvent) SetCategoryId(v string) { x.xxx_hidden_CategoryId = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 5, 13) } func (x *OpaqueCustomerEvent) SetSearchQuery(v string) { x.xxx_hidden_SearchQuery = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 6, 13) } func (x *OpaqueCustomerEvent) SetPageUrl(v string) { x.xxx_hidden_PageUrl = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 7, 13) } func (x *OpaqueCustomerEvent) SetValue(v int32) { x.xxx_hidden_Value = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 8, 13) } func (x *OpaqueCustomerEvent) SetEventData(v map[string]string) { x.xxx_hidden_EventData = v } func (x *OpaqueCustomerEvent) SetDeviceType(v string) { x.xxx_hidden_DeviceType = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 10, 13) } func (x *OpaqueCustomerEvent) SetIpAddress(v string) { x.xxx_hidden_IpAddress = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 11, 13) } func (x *OpaqueCustomerEvent) SetUserAgent(v string) { x.xxx_hidden_UserAgent = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 12, 13) } func (x *OpaqueCustomerEvent) HasCustomerId() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 0) } func (x *OpaqueCustomerEvent) HasSessionId() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 1) } func (x *OpaqueCustomerEvent) HasEventType() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 2) } func (x *OpaqueCustomerEvent) HasTimestamp() bool { if x == nil { return false } return x.xxx_hidden_Timestamp != nil } func (x *OpaqueCustomerEvent) HasProductId() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 4) } func (x *OpaqueCustomerEvent) HasCategoryId() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 5) } func (x *OpaqueCustomerEvent) HasSearchQuery() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 6) } func (x *OpaqueCustomerEvent) HasPageUrl() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 7) } func (x *OpaqueCustomerEvent) HasValue() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 8) } func (x *OpaqueCustomerEvent) HasDeviceType() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 10) } func (x *OpaqueCustomerEvent) HasIpAddress() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 11) } func (x *OpaqueCustomerEvent) HasUserAgent() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 12) } func (x *OpaqueCustomerEvent) ClearCustomerId() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) x.xxx_hidden_CustomerId = nil } func (x *OpaqueCustomerEvent) ClearSessionId() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) x.xxx_hidden_SessionId = nil } func (x *OpaqueCustomerEvent) ClearEventType() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 2) x.xxx_hidden_EventType = OpaqueCustomerEvent_OPAQUE_EVENT_TYPE_UNSPECIFIED } func (x *OpaqueCustomerEvent) ClearTimestamp() { x.xxx_hidden_Timestamp = nil } func (x *OpaqueCustomerEvent) ClearProductId() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 4) x.xxx_hidden_ProductId = nil } func (x *OpaqueCustomerEvent) ClearCategoryId() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 5) x.xxx_hidden_CategoryId = nil } func (x *OpaqueCustomerEvent) ClearSearchQuery() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 6) x.xxx_hidden_SearchQuery = nil } func (x *OpaqueCustomerEvent) ClearPageUrl() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 7) x.xxx_hidden_PageUrl = nil } func (x *OpaqueCustomerEvent) ClearValue() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 8) x.xxx_hidden_Value = 0 } func (x *OpaqueCustomerEvent) ClearDeviceType() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 10) x.xxx_hidden_DeviceType = nil } func (x *OpaqueCustomerEvent) ClearIpAddress() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 11) x.xxx_hidden_IpAddress = nil } func (x *OpaqueCustomerEvent) ClearUserAgent() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 12) x.xxx_hidden_UserAgent = nil } type OpaqueCustomerEvent_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. CustomerId *string SessionId *string EventType *OpaqueCustomerEvent_OpaqueEventType Timestamp *timestamppb.Timestamp ProductId *string CategoryId *string SearchQuery *string PageUrl *string Value *int32 EventData map[string]string DeviceType *string IpAddress *string UserAgent *string } func (b0 OpaqueCustomerEvent_builder) Build() *OpaqueCustomerEvent { m0 := &OpaqueCustomerEvent{} b, x := &b0, m0 _, _ = b, x if b.CustomerId != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 13) x.xxx_hidden_CustomerId = b.CustomerId } if b.SessionId != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 13) x.xxx_hidden_SessionId = b.SessionId } if b.EventType != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 2, 13) x.xxx_hidden_EventType = *b.EventType } x.xxx_hidden_Timestamp = b.Timestamp if b.ProductId != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 4, 13) x.xxx_hidden_ProductId = b.ProductId } if b.CategoryId != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 5, 13) x.xxx_hidden_CategoryId = b.CategoryId } if b.SearchQuery != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 6, 13) x.xxx_hidden_SearchQuery = b.SearchQuery } if b.PageUrl != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 7, 13) x.xxx_hidden_PageUrl = b.PageUrl } if b.Value != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 8, 13) x.xxx_hidden_Value = *b.Value } x.xxx_hidden_EventData = b.EventData if b.DeviceType != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 10, 13) x.xxx_hidden_DeviceType = b.DeviceType } if b.IpAddress != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 11, 13) x.xxx_hidden_IpAddress = b.IpAddress } if b.UserAgent != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 12, 13) x.xxx_hidden_UserAgent = b.UserAgent } return m0 } // OpaqueActivityUpdate represents a server response to customer activity type OpaqueActivityUpdate struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_CustomerId *string `protobuf:"bytes,1,opt,name=customer_id,json=customerId"` xxx_hidden_SessionId *string `protobuf:"bytes,2,opt,name=session_id,json=sessionId"` xxx_hidden_UpdateType OpaqueActivityUpdate_OpaqueUpdateType `protobuf:"varint,3,opt,name=update_type,json=updateType,enum=grpc.gateway.examples.internal.proto.examplepb.OpaqueActivityUpdate_OpaqueUpdateType"` xxx_hidden_Timestamp *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=timestamp"` xxx_hidden_Message *string `protobuf:"bytes,5,opt,name=message"` xxx_hidden_ProductIds []string `protobuf:"bytes,6,rep,name=product_ids,json=productIds"` xxx_hidden_PriceUpdate *OpaquePrice `protobuf:"bytes,7,opt,name=price_update,json=priceUpdate"` xxx_hidden_InventoryCount int32 `protobuf:"varint,8,opt,name=inventory_count,json=inventoryCount"` xxx_hidden_OfferCode *string `protobuf:"bytes,9,opt,name=offer_code,json=offerCode"` xxx_hidden_OfferExpiry *durationpb.Duration `protobuf:"bytes,10,opt,name=offer_expiry,json=offerExpiry"` xxx_hidden_DiscountPercentage float64 `protobuf:"fixed64,11,opt,name=discount_percentage,json=discountPercentage"` xxx_hidden_UpdateData map[string]string `protobuf:"bytes,12,rep,name=update_data,json=updateData" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` xxx_hidden_Priority int32 `protobuf:"varint,13,opt,name=priority"` xxx_hidden_ActionData isOpaqueActivityUpdate_ActionData `protobuf_oneof:"action_data"` XXX_raceDetectHookData protoimpl.RaceDetectHookData XXX_presence [1]uint32 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueActivityUpdate) Reset() { *x = OpaqueActivityUpdate{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueActivityUpdate) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueActivityUpdate) ProtoMessage() {} func (x *OpaqueActivityUpdate) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[28] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueActivityUpdate) GetCustomerId() string { if x != nil { if x.xxx_hidden_CustomerId != nil { return *x.xxx_hidden_CustomerId } return "" } return "" } func (x *OpaqueActivityUpdate) GetSessionId() string { if x != nil { if x.xxx_hidden_SessionId != nil { return *x.xxx_hidden_SessionId } return "" } return "" } func (x *OpaqueActivityUpdate) GetUpdateType() OpaqueActivityUpdate_OpaqueUpdateType { if x != nil { if protoimpl.X.Present(&(x.XXX_presence[0]), 2) { return x.xxx_hidden_UpdateType } } return OpaqueActivityUpdate_OPAQUE_UPDATE_TYPE_UNSPECIFIED } func (x *OpaqueActivityUpdate) GetTimestamp() *timestamppb.Timestamp { if x != nil { return x.xxx_hidden_Timestamp } return nil } func (x *OpaqueActivityUpdate) GetMessage() string { if x != nil { if x.xxx_hidden_Message != nil { return *x.xxx_hidden_Message } return "" } return "" } func (x *OpaqueActivityUpdate) GetProductIds() []string { if x != nil { return x.xxx_hidden_ProductIds } return nil } func (x *OpaqueActivityUpdate) GetPriceUpdate() *OpaquePrice { if x != nil { return x.xxx_hidden_PriceUpdate } return nil } func (x *OpaqueActivityUpdate) GetInventoryCount() int32 { if x != nil { return x.xxx_hidden_InventoryCount } return 0 } func (x *OpaqueActivityUpdate) GetOfferCode() string { if x != nil { if x.xxx_hidden_OfferCode != nil { return *x.xxx_hidden_OfferCode } return "" } return "" } func (x *OpaqueActivityUpdate) GetOfferExpiry() *durationpb.Duration { if x != nil { return x.xxx_hidden_OfferExpiry } return nil } func (x *OpaqueActivityUpdate) GetDiscountPercentage() float64 { if x != nil { return x.xxx_hidden_DiscountPercentage } return 0 } func (x *OpaqueActivityUpdate) GetUpdateData() map[string]string { if x != nil { return x.xxx_hidden_UpdateData } return nil } func (x *OpaqueActivityUpdate) GetPriority() int32 { if x != nil { return x.xxx_hidden_Priority } return 0 } func (x *OpaqueActivityUpdate) GetRedirectUrl() string { if x != nil { if x, ok := x.xxx_hidden_ActionData.(*opaqueActivityUpdate_RedirectUrl); ok { return x.RedirectUrl } } return "" } func (x *OpaqueActivityUpdate) GetNotificationId() string { if x != nil { if x, ok := x.xxx_hidden_ActionData.(*opaqueActivityUpdate_NotificationId); ok { return x.NotificationId } } return "" } func (x *OpaqueActivityUpdate) SetCustomerId(v string) { x.xxx_hidden_CustomerId = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 14) } func (x *OpaqueActivityUpdate) SetSessionId(v string) { x.xxx_hidden_SessionId = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 14) } func (x *OpaqueActivityUpdate) SetUpdateType(v OpaqueActivityUpdate_OpaqueUpdateType) { x.xxx_hidden_UpdateType = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 2, 14) } func (x *OpaqueActivityUpdate) SetTimestamp(v *timestamppb.Timestamp) { x.xxx_hidden_Timestamp = v } func (x *OpaqueActivityUpdate) SetMessage(v string) { x.xxx_hidden_Message = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 4, 14) } func (x *OpaqueActivityUpdate) SetProductIds(v []string) { x.xxx_hidden_ProductIds = v } func (x *OpaqueActivityUpdate) SetPriceUpdate(v *OpaquePrice) { x.xxx_hidden_PriceUpdate = v } func (x *OpaqueActivityUpdate) SetInventoryCount(v int32) { x.xxx_hidden_InventoryCount = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 7, 14) } func (x *OpaqueActivityUpdate) SetOfferCode(v string) { x.xxx_hidden_OfferCode = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 8, 14) } func (x *OpaqueActivityUpdate) SetOfferExpiry(v *durationpb.Duration) { x.xxx_hidden_OfferExpiry = v } func (x *OpaqueActivityUpdate) SetDiscountPercentage(v float64) { x.xxx_hidden_DiscountPercentage = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 10, 14) } func (x *OpaqueActivityUpdate) SetUpdateData(v map[string]string) { x.xxx_hidden_UpdateData = v } func (x *OpaqueActivityUpdate) SetPriority(v int32) { x.xxx_hidden_Priority = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 12, 14) } func (x *OpaqueActivityUpdate) SetRedirectUrl(v string) { x.xxx_hidden_ActionData = &opaqueActivityUpdate_RedirectUrl{v} } func (x *OpaqueActivityUpdate) SetNotificationId(v string) { x.xxx_hidden_ActionData = &opaqueActivityUpdate_NotificationId{v} } func (x *OpaqueActivityUpdate) HasCustomerId() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 0) } func (x *OpaqueActivityUpdate) HasSessionId() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 1) } func (x *OpaqueActivityUpdate) HasUpdateType() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 2) } func (x *OpaqueActivityUpdate) HasTimestamp() bool { if x == nil { return false } return x.xxx_hidden_Timestamp != nil } func (x *OpaqueActivityUpdate) HasMessage() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 4) } func (x *OpaqueActivityUpdate) HasPriceUpdate() bool { if x == nil { return false } return x.xxx_hidden_PriceUpdate != nil } func (x *OpaqueActivityUpdate) HasInventoryCount() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 7) } func (x *OpaqueActivityUpdate) HasOfferCode() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 8) } func (x *OpaqueActivityUpdate) HasOfferExpiry() bool { if x == nil { return false } return x.xxx_hidden_OfferExpiry != nil } func (x *OpaqueActivityUpdate) HasDiscountPercentage() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 10) } func (x *OpaqueActivityUpdate) HasPriority() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 12) } func (x *OpaqueActivityUpdate) HasActionData() bool { if x == nil { return false } return x.xxx_hidden_ActionData != nil } func (x *OpaqueActivityUpdate) HasRedirectUrl() bool { if x == nil { return false } _, ok := x.xxx_hidden_ActionData.(*opaqueActivityUpdate_RedirectUrl) return ok } func (x *OpaqueActivityUpdate) HasNotificationId() bool { if x == nil { return false } _, ok := x.xxx_hidden_ActionData.(*opaqueActivityUpdate_NotificationId) return ok } func (x *OpaqueActivityUpdate) ClearCustomerId() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) x.xxx_hidden_CustomerId = nil } func (x *OpaqueActivityUpdate) ClearSessionId() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) x.xxx_hidden_SessionId = nil } func (x *OpaqueActivityUpdate) ClearUpdateType() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 2) x.xxx_hidden_UpdateType = OpaqueActivityUpdate_OPAQUE_UPDATE_TYPE_UNSPECIFIED } func (x *OpaqueActivityUpdate) ClearTimestamp() { x.xxx_hidden_Timestamp = nil } func (x *OpaqueActivityUpdate) ClearMessage() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 4) x.xxx_hidden_Message = nil } func (x *OpaqueActivityUpdate) ClearPriceUpdate() { x.xxx_hidden_PriceUpdate = nil } func (x *OpaqueActivityUpdate) ClearInventoryCount() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 7) x.xxx_hidden_InventoryCount = 0 } func (x *OpaqueActivityUpdate) ClearOfferCode() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 8) x.xxx_hidden_OfferCode = nil } func (x *OpaqueActivityUpdate) ClearOfferExpiry() { x.xxx_hidden_OfferExpiry = nil } func (x *OpaqueActivityUpdate) ClearDiscountPercentage() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 10) x.xxx_hidden_DiscountPercentage = 0 } func (x *OpaqueActivityUpdate) ClearPriority() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 12) x.xxx_hidden_Priority = 0 } func (x *OpaqueActivityUpdate) ClearActionData() { x.xxx_hidden_ActionData = nil } func (x *OpaqueActivityUpdate) ClearRedirectUrl() { if _, ok := x.xxx_hidden_ActionData.(*opaqueActivityUpdate_RedirectUrl); ok { x.xxx_hidden_ActionData = nil } } func (x *OpaqueActivityUpdate) ClearNotificationId() { if _, ok := x.xxx_hidden_ActionData.(*opaqueActivityUpdate_NotificationId); ok { x.xxx_hidden_ActionData = nil } } const OpaqueActivityUpdate_ActionData_not_set_case case_OpaqueActivityUpdate_ActionData = 0 const OpaqueActivityUpdate_RedirectUrl_case case_OpaqueActivityUpdate_ActionData = 14 const OpaqueActivityUpdate_NotificationId_case case_OpaqueActivityUpdate_ActionData = 15 func (x *OpaqueActivityUpdate) WhichActionData() case_OpaqueActivityUpdate_ActionData { if x == nil { return OpaqueActivityUpdate_ActionData_not_set_case } switch x.xxx_hidden_ActionData.(type) { case *opaqueActivityUpdate_RedirectUrl: return OpaqueActivityUpdate_RedirectUrl_case case *opaqueActivityUpdate_NotificationId: return OpaqueActivityUpdate_NotificationId_case default: return OpaqueActivityUpdate_ActionData_not_set_case } } type OpaqueActivityUpdate_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. CustomerId *string SessionId *string UpdateType *OpaqueActivityUpdate_OpaqueUpdateType Timestamp *timestamppb.Timestamp Message *string ProductIds []string PriceUpdate *OpaquePrice InventoryCount *int32 OfferCode *string OfferExpiry *durationpb.Duration DiscountPercentage *float64 UpdateData map[string]string Priority *int32 // Fields of oneof xxx_hidden_ActionData: RedirectUrl *string NotificationId *string // -- end of xxx_hidden_ActionData } func (b0 OpaqueActivityUpdate_builder) Build() *OpaqueActivityUpdate { m0 := &OpaqueActivityUpdate{} b, x := &b0, m0 _, _ = b, x if b.CustomerId != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 14) x.xxx_hidden_CustomerId = b.CustomerId } if b.SessionId != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 14) x.xxx_hidden_SessionId = b.SessionId } if b.UpdateType != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 2, 14) x.xxx_hidden_UpdateType = *b.UpdateType } x.xxx_hidden_Timestamp = b.Timestamp if b.Message != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 4, 14) x.xxx_hidden_Message = b.Message } x.xxx_hidden_ProductIds = b.ProductIds x.xxx_hidden_PriceUpdate = b.PriceUpdate if b.InventoryCount != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 7, 14) x.xxx_hidden_InventoryCount = *b.InventoryCount } if b.OfferCode != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 8, 14) x.xxx_hidden_OfferCode = b.OfferCode } x.xxx_hidden_OfferExpiry = b.OfferExpiry if b.DiscountPercentage != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 10, 14) x.xxx_hidden_DiscountPercentage = *b.DiscountPercentage } x.xxx_hidden_UpdateData = b.UpdateData if b.Priority != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 12, 14) x.xxx_hidden_Priority = *b.Priority } if b.RedirectUrl != nil { x.xxx_hidden_ActionData = &opaqueActivityUpdate_RedirectUrl{*b.RedirectUrl} } if b.NotificationId != nil { x.xxx_hidden_ActionData = &opaqueActivityUpdate_NotificationId{*b.NotificationId} } return m0 } type case_OpaqueActivityUpdate_ActionData protoreflect.FieldNumber func (x case_OpaqueActivityUpdate_ActionData) String() string { md := file_examples_internal_proto_examplepb_opaque_proto_msgTypes[28].Descriptor() if x == 0 { return "not set" } return protoimpl.X.MessageFieldStringOf(md, protoreflect.FieldNumber(x)) } type isOpaqueActivityUpdate_ActionData interface { isOpaqueActivityUpdate_ActionData() } type opaqueActivityUpdate_RedirectUrl struct { RedirectUrl string `protobuf:"bytes,14,opt,name=redirect_url,json=redirectUrl,oneof"` } type opaqueActivityUpdate_NotificationId struct { NotificationId string `protobuf:"bytes,15,opt,name=notification_id,json=notificationId,oneof"` } func (*opaqueActivityUpdate_RedirectUrl) isOpaqueActivityUpdate_ActionData() {} func (*opaqueActivityUpdate_NotificationId) isOpaqueActivityUpdate_ActionData() {} type OpaqueProduct_OpaqueProductDimensions struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Length float64 `protobuf:"fixed64,1,opt,name=length"` xxx_hidden_Width float64 `protobuf:"fixed64,2,opt,name=width"` xxx_hidden_Height float64 `protobuf:"fixed64,3,opt,name=height"` xxx_hidden_Weight float64 `protobuf:"fixed64,4,opt,name=weight"` xxx_hidden_Unit OpaqueProduct_OpaqueProductDimensions_OpaqueUnit `protobuf:"varint,5,opt,name=unit,enum=grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct_OpaqueProductDimensions_OpaqueUnit"` XXX_raceDetectHookData protoimpl.RaceDetectHookData XXX_presence [1]uint32 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueProduct_OpaqueProductDimensions) Reset() { *x = OpaqueProduct_OpaqueProductDimensions{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[34] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueProduct_OpaqueProductDimensions) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueProduct_OpaqueProductDimensions) ProtoMessage() {} func (x *OpaqueProduct_OpaqueProductDimensions) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[34] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueProduct_OpaqueProductDimensions) GetLength() float64 { if x != nil { return x.xxx_hidden_Length } return 0 } func (x *OpaqueProduct_OpaqueProductDimensions) GetWidth() float64 { if x != nil { return x.xxx_hidden_Width } return 0 } func (x *OpaqueProduct_OpaqueProductDimensions) GetHeight() float64 { if x != nil { return x.xxx_hidden_Height } return 0 } func (x *OpaqueProduct_OpaqueProductDimensions) GetWeight() float64 { if x != nil { return x.xxx_hidden_Weight } return 0 } func (x *OpaqueProduct_OpaqueProductDimensions) GetUnit() OpaqueProduct_OpaqueProductDimensions_OpaqueUnit { if x != nil { if protoimpl.X.Present(&(x.XXX_presence[0]), 4) { return x.xxx_hidden_Unit } } return OpaqueProduct_OpaqueProductDimensions_OPAQUE_UNIT_UNSPECIFIED } func (x *OpaqueProduct_OpaqueProductDimensions) SetLength(v float64) { x.xxx_hidden_Length = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 5) } func (x *OpaqueProduct_OpaqueProductDimensions) SetWidth(v float64) { x.xxx_hidden_Width = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 5) } func (x *OpaqueProduct_OpaqueProductDimensions) SetHeight(v float64) { x.xxx_hidden_Height = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 2, 5) } func (x *OpaqueProduct_OpaqueProductDimensions) SetWeight(v float64) { x.xxx_hidden_Weight = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 3, 5) } func (x *OpaqueProduct_OpaqueProductDimensions) SetUnit(v OpaqueProduct_OpaqueProductDimensions_OpaqueUnit) { x.xxx_hidden_Unit = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 4, 5) } func (x *OpaqueProduct_OpaqueProductDimensions) HasLength() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 0) } func (x *OpaqueProduct_OpaqueProductDimensions) HasWidth() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 1) } func (x *OpaqueProduct_OpaqueProductDimensions) HasHeight() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 2) } func (x *OpaqueProduct_OpaqueProductDimensions) HasWeight() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 3) } func (x *OpaqueProduct_OpaqueProductDimensions) HasUnit() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 4) } func (x *OpaqueProduct_OpaqueProductDimensions) ClearLength() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) x.xxx_hidden_Length = 0 } func (x *OpaqueProduct_OpaqueProductDimensions) ClearWidth() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) x.xxx_hidden_Width = 0 } func (x *OpaqueProduct_OpaqueProductDimensions) ClearHeight() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 2) x.xxx_hidden_Height = 0 } func (x *OpaqueProduct_OpaqueProductDimensions) ClearWeight() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 3) x.xxx_hidden_Weight = 0 } func (x *OpaqueProduct_OpaqueProductDimensions) ClearUnit() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 4) x.xxx_hidden_Unit = OpaqueProduct_OpaqueProductDimensions_OPAQUE_UNIT_UNSPECIFIED } type OpaqueProduct_OpaqueProductDimensions_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Length *float64 Width *float64 Height *float64 Weight *float64 Unit *OpaqueProduct_OpaqueProductDimensions_OpaqueUnit } func (b0 OpaqueProduct_OpaqueProductDimensions_builder) Build() *OpaqueProduct_OpaqueProductDimensions { m0 := &OpaqueProduct_OpaqueProductDimensions{} b, x := &b0, m0 _, _ = b, x if b.Length != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 5) x.xxx_hidden_Length = *b.Length } if b.Width != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 5) x.xxx_hidden_Width = *b.Width } if b.Height != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 2, 5) x.xxx_hidden_Height = *b.Height } if b.Weight != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 3, 5) x.xxx_hidden_Weight = *b.Weight } if b.Unit != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 4, 5) x.xxx_hidden_Unit = *b.Unit } return m0 } type OpaqueCustomer_OpaqueLoyaltyInfo struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Tier *string `protobuf:"bytes,1,opt,name=tier"` xxx_hidden_Points int32 `protobuf:"varint,2,opt,name=points"` xxx_hidden_TierExpiry *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=tier_expiry,json=tierExpiry"` xxx_hidden_Rewards []string `protobuf:"bytes,4,rep,name=rewards"` XXX_raceDetectHookData protoimpl.RaceDetectHookData XXX_presence [1]uint32 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueCustomer_OpaqueLoyaltyInfo) Reset() { *x = OpaqueCustomer_OpaqueLoyaltyInfo{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[35] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueCustomer_OpaqueLoyaltyInfo) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueCustomer_OpaqueLoyaltyInfo) ProtoMessage() {} func (x *OpaqueCustomer_OpaqueLoyaltyInfo) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[35] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueCustomer_OpaqueLoyaltyInfo) GetTier() string { if x != nil { if x.xxx_hidden_Tier != nil { return *x.xxx_hidden_Tier } return "" } return "" } func (x *OpaqueCustomer_OpaqueLoyaltyInfo) GetPoints() int32 { if x != nil { return x.xxx_hidden_Points } return 0 } func (x *OpaqueCustomer_OpaqueLoyaltyInfo) GetTierExpiry() *timestamppb.Timestamp { if x != nil { return x.xxx_hidden_TierExpiry } return nil } func (x *OpaqueCustomer_OpaqueLoyaltyInfo) GetRewards() []string { if x != nil { return x.xxx_hidden_Rewards } return nil } func (x *OpaqueCustomer_OpaqueLoyaltyInfo) SetTier(v string) { x.xxx_hidden_Tier = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 4) } func (x *OpaqueCustomer_OpaqueLoyaltyInfo) SetPoints(v int32) { x.xxx_hidden_Points = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 4) } func (x *OpaqueCustomer_OpaqueLoyaltyInfo) SetTierExpiry(v *timestamppb.Timestamp) { x.xxx_hidden_TierExpiry = v } func (x *OpaqueCustomer_OpaqueLoyaltyInfo) SetRewards(v []string) { x.xxx_hidden_Rewards = v } func (x *OpaqueCustomer_OpaqueLoyaltyInfo) HasTier() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 0) } func (x *OpaqueCustomer_OpaqueLoyaltyInfo) HasPoints() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 1) } func (x *OpaqueCustomer_OpaqueLoyaltyInfo) HasTierExpiry() bool { if x == nil { return false } return x.xxx_hidden_TierExpiry != nil } func (x *OpaqueCustomer_OpaqueLoyaltyInfo) ClearTier() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) x.xxx_hidden_Tier = nil } func (x *OpaqueCustomer_OpaqueLoyaltyInfo) ClearPoints() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) x.xxx_hidden_Points = 0 } func (x *OpaqueCustomer_OpaqueLoyaltyInfo) ClearTierExpiry() { x.xxx_hidden_TierExpiry = nil } type OpaqueCustomer_OpaqueLoyaltyInfo_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Tier *string Points *int32 TierExpiry *timestamppb.Timestamp Rewards []string } func (b0 OpaqueCustomer_OpaqueLoyaltyInfo_builder) Build() *OpaqueCustomer_OpaqueLoyaltyInfo { m0 := &OpaqueCustomer_OpaqueLoyaltyInfo{} b, x := &b0, m0 _, _ = b, x if b.Tier != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 4) x.xxx_hidden_Tier = b.Tier } if b.Points != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 4) x.xxx_hidden_Points = *b.Points } x.xxx_hidden_TierExpiry = b.TierExpiry x.xxx_hidden_Rewards = b.Rewards return m0 } type OpaqueCustomer_OpaquePaymentMethod struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_PaymentId *string `protobuf:"bytes,1,opt,name=payment_id,json=paymentId"` xxx_hidden_Type *string `protobuf:"bytes,2,opt,name=type"` xxx_hidden_LastFour *string `protobuf:"bytes,3,opt,name=last_four,json=lastFour"` xxx_hidden_Provider *string `protobuf:"bytes,4,opt,name=provider"` xxx_hidden_ExpiresAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=expires_at,json=expiresAt"` xxx_hidden_IsDefault bool `protobuf:"varint,6,opt,name=is_default,json=isDefault"` XXX_raceDetectHookData protoimpl.RaceDetectHookData XXX_presence [1]uint32 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueCustomer_OpaquePaymentMethod) Reset() { *x = OpaqueCustomer_OpaquePaymentMethod{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[37] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueCustomer_OpaquePaymentMethod) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueCustomer_OpaquePaymentMethod) ProtoMessage() {} func (x *OpaqueCustomer_OpaquePaymentMethod) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[37] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueCustomer_OpaquePaymentMethod) GetPaymentId() string { if x != nil { if x.xxx_hidden_PaymentId != nil { return *x.xxx_hidden_PaymentId } return "" } return "" } func (x *OpaqueCustomer_OpaquePaymentMethod) GetType() string { if x != nil { if x.xxx_hidden_Type != nil { return *x.xxx_hidden_Type } return "" } return "" } func (x *OpaqueCustomer_OpaquePaymentMethod) GetLastFour() string { if x != nil { if x.xxx_hidden_LastFour != nil { return *x.xxx_hidden_LastFour } return "" } return "" } func (x *OpaqueCustomer_OpaquePaymentMethod) GetProvider() string { if x != nil { if x.xxx_hidden_Provider != nil { return *x.xxx_hidden_Provider } return "" } return "" } func (x *OpaqueCustomer_OpaquePaymentMethod) GetExpiresAt() *timestamppb.Timestamp { if x != nil { return x.xxx_hidden_ExpiresAt } return nil } func (x *OpaqueCustomer_OpaquePaymentMethod) GetIsDefault() bool { if x != nil { return x.xxx_hidden_IsDefault } return false } func (x *OpaqueCustomer_OpaquePaymentMethod) SetPaymentId(v string) { x.xxx_hidden_PaymentId = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 6) } func (x *OpaqueCustomer_OpaquePaymentMethod) SetType(v string) { x.xxx_hidden_Type = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 6) } func (x *OpaqueCustomer_OpaquePaymentMethod) SetLastFour(v string) { x.xxx_hidden_LastFour = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 2, 6) } func (x *OpaqueCustomer_OpaquePaymentMethod) SetProvider(v string) { x.xxx_hidden_Provider = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 3, 6) } func (x *OpaqueCustomer_OpaquePaymentMethod) SetExpiresAt(v *timestamppb.Timestamp) { x.xxx_hidden_ExpiresAt = v } func (x *OpaqueCustomer_OpaquePaymentMethod) SetIsDefault(v bool) { x.xxx_hidden_IsDefault = v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 5, 6) } func (x *OpaqueCustomer_OpaquePaymentMethod) HasPaymentId() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 0) } func (x *OpaqueCustomer_OpaquePaymentMethod) HasType() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 1) } func (x *OpaqueCustomer_OpaquePaymentMethod) HasLastFour() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 2) } func (x *OpaqueCustomer_OpaquePaymentMethod) HasProvider() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 3) } func (x *OpaqueCustomer_OpaquePaymentMethod) HasExpiresAt() bool { if x == nil { return false } return x.xxx_hidden_ExpiresAt != nil } func (x *OpaqueCustomer_OpaquePaymentMethod) HasIsDefault() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 5) } func (x *OpaqueCustomer_OpaquePaymentMethod) ClearPaymentId() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) x.xxx_hidden_PaymentId = nil } func (x *OpaqueCustomer_OpaquePaymentMethod) ClearType() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) x.xxx_hidden_Type = nil } func (x *OpaqueCustomer_OpaquePaymentMethod) ClearLastFour() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 2) x.xxx_hidden_LastFour = nil } func (x *OpaqueCustomer_OpaquePaymentMethod) ClearProvider() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 3) x.xxx_hidden_Provider = nil } func (x *OpaqueCustomer_OpaquePaymentMethod) ClearExpiresAt() { x.xxx_hidden_ExpiresAt = nil } func (x *OpaqueCustomer_OpaquePaymentMethod) ClearIsDefault() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 5) x.xxx_hidden_IsDefault = false } type OpaqueCustomer_OpaquePaymentMethod_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. PaymentId *string Type *string LastFour *string Provider *string ExpiresAt *timestamppb.Timestamp IsDefault *bool } func (b0 OpaqueCustomer_OpaquePaymentMethod_builder) Build() *OpaqueCustomer_OpaquePaymentMethod { m0 := &OpaqueCustomer_OpaquePaymentMethod{} b, x := &b0, m0 _, _ = b, x if b.PaymentId != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 6) x.xxx_hidden_PaymentId = b.PaymentId } if b.Type != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 6) x.xxx_hidden_Type = b.Type } if b.LastFour != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 2, 6) x.xxx_hidden_LastFour = b.LastFour } if b.Provider != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 3, 6) x.xxx_hidden_Provider = b.Provider } x.xxx_hidden_ExpiresAt = b.ExpiresAt if b.IsDefault != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 5, 6) x.xxx_hidden_IsDefault = *b.IsDefault } return m0 } type OpaqueOrder_OpaqueShippingInfo struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Carrier *string `protobuf:"bytes,1,opt,name=carrier"` xxx_hidden_Method *string `protobuf:"bytes,2,opt,name=method"` xxx_hidden_EstimatedDeliveryTime *durationpb.Duration `protobuf:"bytes,3,opt,name=estimated_delivery_time,json=estimatedDeliveryTime"` xxx_hidden_TrackingUrls []string `protobuf:"bytes,4,rep,name=tracking_urls,json=trackingUrls"` XXX_raceDetectHookData protoimpl.RaceDetectHookData XXX_presence [1]uint32 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueOrder_OpaqueShippingInfo) Reset() { *x = OpaqueOrder_OpaqueShippingInfo{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[39] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueOrder_OpaqueShippingInfo) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueOrder_OpaqueShippingInfo) ProtoMessage() {} func (x *OpaqueOrder_OpaqueShippingInfo) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[39] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueOrder_OpaqueShippingInfo) GetCarrier() string { if x != nil { if x.xxx_hidden_Carrier != nil { return *x.xxx_hidden_Carrier } return "" } return "" } func (x *OpaqueOrder_OpaqueShippingInfo) GetMethod() string { if x != nil { if x.xxx_hidden_Method != nil { return *x.xxx_hidden_Method } return "" } return "" } func (x *OpaqueOrder_OpaqueShippingInfo) GetEstimatedDeliveryTime() *durationpb.Duration { if x != nil { return x.xxx_hidden_EstimatedDeliveryTime } return nil } func (x *OpaqueOrder_OpaqueShippingInfo) GetTrackingUrls() []string { if x != nil { return x.xxx_hidden_TrackingUrls } return nil } func (x *OpaqueOrder_OpaqueShippingInfo) SetCarrier(v string) { x.xxx_hidden_Carrier = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 4) } func (x *OpaqueOrder_OpaqueShippingInfo) SetMethod(v string) { x.xxx_hidden_Method = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 4) } func (x *OpaqueOrder_OpaqueShippingInfo) SetEstimatedDeliveryTime(v *durationpb.Duration) { x.xxx_hidden_EstimatedDeliveryTime = v } func (x *OpaqueOrder_OpaqueShippingInfo) SetTrackingUrls(v []string) { x.xxx_hidden_TrackingUrls = v } func (x *OpaqueOrder_OpaqueShippingInfo) HasCarrier() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 0) } func (x *OpaqueOrder_OpaqueShippingInfo) HasMethod() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 1) } func (x *OpaqueOrder_OpaqueShippingInfo) HasEstimatedDeliveryTime() bool { if x == nil { return false } return x.xxx_hidden_EstimatedDeliveryTime != nil } func (x *OpaqueOrder_OpaqueShippingInfo) ClearCarrier() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) x.xxx_hidden_Carrier = nil } func (x *OpaqueOrder_OpaqueShippingInfo) ClearMethod() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) x.xxx_hidden_Method = nil } func (x *OpaqueOrder_OpaqueShippingInfo) ClearEstimatedDeliveryTime() { x.xxx_hidden_EstimatedDeliveryTime = nil } type OpaqueOrder_OpaqueShippingInfo_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Carrier *string Method *string EstimatedDeliveryTime *durationpb.Duration TrackingUrls []string } func (b0 OpaqueOrder_OpaqueShippingInfo_builder) Build() *OpaqueOrder_OpaqueShippingInfo { m0 := &OpaqueOrder_OpaqueShippingInfo{} b, x := &b0, m0 _, _ = b, x if b.Carrier != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 4) x.xxx_hidden_Carrier = b.Carrier } if b.Method != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 4) x.xxx_hidden_Method = b.Method } x.xxx_hidden_EstimatedDeliveryTime = b.EstimatedDeliveryTime x.xxx_hidden_TrackingUrls = b.TrackingUrls return m0 } type OpaqueOrderSummary_OpaqueOrderError struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_OrderId *string `protobuf:"bytes,1,opt,name=order_id,json=orderId"` xxx_hidden_ErrorCode *string `protobuf:"bytes,2,opt,name=error_code,json=errorCode"` xxx_hidden_ErrorMessage *string `protobuf:"bytes,3,opt,name=error_message,json=errorMessage"` XXX_raceDetectHookData protoimpl.RaceDetectHookData XXX_presence [1]uint32 unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *OpaqueOrderSummary_OpaqueOrderError) Reset() { *x = OpaqueOrderSummary_OpaqueOrderError{} mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[42] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpaqueOrderSummary_OpaqueOrderError) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpaqueOrderSummary_OpaqueOrderError) ProtoMessage() {} func (x *OpaqueOrderSummary_OpaqueOrderError) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_opaque_proto_msgTypes[42] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *OpaqueOrderSummary_OpaqueOrderError) GetOrderId() string { if x != nil { if x.xxx_hidden_OrderId != nil { return *x.xxx_hidden_OrderId } return "" } return "" } func (x *OpaqueOrderSummary_OpaqueOrderError) GetErrorCode() string { if x != nil { if x.xxx_hidden_ErrorCode != nil { return *x.xxx_hidden_ErrorCode } return "" } return "" } func (x *OpaqueOrderSummary_OpaqueOrderError) GetErrorMessage() string { if x != nil { if x.xxx_hidden_ErrorMessage != nil { return *x.xxx_hidden_ErrorMessage } return "" } return "" } func (x *OpaqueOrderSummary_OpaqueOrderError) SetOrderId(v string) { x.xxx_hidden_OrderId = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 3) } func (x *OpaqueOrderSummary_OpaqueOrderError) SetErrorCode(v string) { x.xxx_hidden_ErrorCode = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 3) } func (x *OpaqueOrderSummary_OpaqueOrderError) SetErrorMessage(v string) { x.xxx_hidden_ErrorMessage = &v protoimpl.X.SetPresent(&(x.XXX_presence[0]), 2, 3) } func (x *OpaqueOrderSummary_OpaqueOrderError) HasOrderId() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 0) } func (x *OpaqueOrderSummary_OpaqueOrderError) HasErrorCode() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 1) } func (x *OpaqueOrderSummary_OpaqueOrderError) HasErrorMessage() bool { if x == nil { return false } return protoimpl.X.Present(&(x.XXX_presence[0]), 2) } func (x *OpaqueOrderSummary_OpaqueOrderError) ClearOrderId() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0) x.xxx_hidden_OrderId = nil } func (x *OpaqueOrderSummary_OpaqueOrderError) ClearErrorCode() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1) x.xxx_hidden_ErrorCode = nil } func (x *OpaqueOrderSummary_OpaqueOrderError) ClearErrorMessage() { protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 2) x.xxx_hidden_ErrorMessage = nil } type OpaqueOrderSummary_OpaqueOrderError_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. OrderId *string ErrorCode *string ErrorMessage *string } func (b0 OpaqueOrderSummary_OpaqueOrderError_builder) Build() *OpaqueOrderSummary_OpaqueOrderError { m0 := &OpaqueOrderSummary_OpaqueOrderError{} b, x := &b0, m0 _, _ = b, x if b.OrderId != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 3) x.xxx_hidden_OrderId = b.OrderId } if b.ErrorCode != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 3) x.xxx_hidden_ErrorCode = b.ErrorCode } if b.ErrorMessage != nil { protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 2, 3) x.xxx_hidden_ErrorMessage = b.ErrorMessage } return m0 } var File_examples_internal_proto_examplepb_opaque_proto protoreflect.FileDescriptor const file_examples_internal_proto_examplepb_opaque_proto_rawDesc = "" + "\n" + ".examples/internal/proto/examplepb/opaque.proto\x12.grpc.gateway.examples.internal.proto.examplepb\x1a)examples/internal/proto/sub/message.proto\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1egoogle/protobuf/duration.proto\x1a google/protobuf/field_mask.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1egoogle/protobuf/wrappers.proto\"\xb2\x01\n" + "\x1aOpaqueUpdateProductRequest\x12W\n" + "\aproduct\x18\x01 \x01(\v2=.grpc.gateway.examples.internal.proto.examplepb.OpaqueProductR\aproduct\x12;\n" + "\vupdate_mask\x18\x02 \x01(\v2\x1a.google.protobuf.FieldMaskR\n" + "updateMask\"v\n" + "\x1bOpaqueUpdateProductResponse\x12W\n" + "\aproduct\x18\x01 \x01(\v2=.grpc.gateway.examples.internal.proto.examplepb.OpaqueProductR\aproduct\"\xe7\x01\n" + "\x17OpaqueGetProductRequest\x12\x1d\n" + "\n" + "product_id\x18\x01 \x01(\tR\tproductId\x12)\n" + "\x10include_variants\x18\x02 \x01(\bR\x0fincludeVariants\x128\n" + "\x18include_related_products\x18\x03 \x01(\bR\x16includeRelatedProducts\x12#\n" + "\rlanguage_code\x18\x04 \x01(\tR\flanguageCode\x12#\n" + "\rcurrency_code\x18\x05 \x01(\tR\fcurrencyCode\"s\n" + "\x18OpaqueGetProductResponse\x12W\n" + "\aproduct\x18\x01 \x01(\v2=.grpc.gateway.examples.internal.proto.examplepb.OpaqueProductR\aproduct\"\xa0\b\n" + "\x1bOpaqueSearchProductsRequest\x12\x14\n" + "\x05query\x18\x01 \x01(\tR\x05query\x12!\n" + "\fcategory_ids\x18\x02 \x03(\tR\vcategoryIds\x12\x16\n" + "\x06brands\x18\x03 \x03(\tR\x06brands\x12X\n" + "\tmin_price\x18\x04 \x01(\v2;.grpc.gateway.examples.internal.proto.examplepb.OpaquePriceR\bminPrice\x12X\n" + "\tmax_price\x18\x05 \x01(\v2;.grpc.gateway.examples.internal.proto.examplepb.OpaquePriceR\bmaxPrice\x12\x12\n" + "\x04tags\x18\x06 \x03(\tR\x04tags\x12t\n" + "\asort_by\x18\a \x01(\x0e2[.grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchProductsRequest.OpaqueSortOrderR\x06sortBy\x12\x12\n" + "\x04page\x18\b \x01(\x05R\x04page\x12\x1b\n" + "\tpage_size\x18\t \x01(\x05R\bpageSize\x12#\n" + "\rlanguage_code\x18\n" + " \x01(\tR\flanguageCode\x12#\n" + "\rcurrency_code\x18\v \x01(\tR\fcurrencyCode\x129\n" + "\n" + "field_mask\x18\f \x01(\v2\x1a.google.protobuf.FieldMaskR\tfieldMask\x12r\n" + "\afilters\x18\r \x03(\v2X.grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchProductsRequest.FiltersEntryR\afilters\x1a:\n" + "\fFiltersEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\x8b\x02\n" + "\x0fOpaqueSortOrder\x12!\n" + "\x1dOPAQUE_SORT_ORDER_UNSPECIFIED\x10\x00\x12\x1f\n" + "\x1bOPAQUE_SORT_ORDER_RELEVANCE\x10\x01\x12'\n" + "#OPAQUE_SORT_ORDER_PRICE_LOW_TO_HIGH\x10\x02\x12'\n" + "#OPAQUE_SORT_ORDER_PRICE_HIGH_TO_LOW\x10\x03\x12\"\n" + "\x1eOPAQUE_SORT_ORDER_NEWEST_FIRST\x10\x04\x12\x1c\n" + "\x18OPAQUE_SORT_ORDER_RATING\x10\x05\x12 \n" + "\x1cOPAQUE_SORT_ORDER_POPULARITY\x10\x06\"w\n" + "\x1cOpaqueSearchProductsResponse\x12W\n" + "\aproduct\x18\x01 \x01(\v2=.grpc.gateway.examples.internal.proto.examplepb.OpaqueProductR\aproduct\"\x94\x01\n" + "\x1aOpaqueCreateProductRequest\x12\x1d\n" + "\n" + "product_id\x18\x01 \x01(\tR\tproductId\x12W\n" + "\aproduct\x18\x02 \x01(\v2=.grpc.gateway.examples.internal.proto.examplepb.OpaqueProductR\aproduct\"v\n" + "\x1bOpaqueCreateProductResponse\x12W\n" + "\aproduct\x18\x01 \x01(\v2=.grpc.gateway.examples.internal.proto.examplepb.OpaqueProductR\aproduct\"\x99\x01\n" + "\x1fOpaqueCreateProductFieldRequest\x12\x1d\n" + "\n" + "product_id\x18\x01 \x01(\tR\tproductId\x12W\n" + "\aproduct\x18\x02 \x01(\v2=.grpc.gateway.examples.internal.proto.examplepb.OpaqueProductR\aproduct\"{\n" + " OpaqueCreateProductFieldResponse\x12W\n" + "\aproduct\x18\x01 \x01(\v2=.grpc.gateway.examples.internal.proto.examplepb.OpaqueProductR\aproduct\"o\n" + "\x1aOpaqueProcessOrdersRequest\x12Q\n" + "\x05order\x18\x01 \x01(\v2;.grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderR\x05order\"{\n" + "\x1bOpaqueProcessOrdersResponse\x12\\\n" + "\asummary\x18\x01 \x01(\v2B.grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderSummaryR\asummary\"\x80\x01\n" + "#OpaqueStreamCustomerActivityRequest\x12Y\n" + "\x05event\x18\x01 \x01(\v2C.grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomerEventR\x05event\"\x82\x01\n" + "$OpaqueStreamCustomerActivityResponse\x12Z\n" + "\x05event\x18\x02 \x01(\v2D.grpc.gateway.examples.internal.proto.examplepb.OpaqueActivityUpdateR\x05event\"n\n" + "\x19OpaqueSearchOrdersRequest\x12Q\n" + "\x05order\x18\x01 \x01(\v2;.grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderR\x05order\"q\n" + "\x1aOpaqueSearchOrdersResponse\x12S\n" + "\x06orders\x18\x01 \x03(\v2;.grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderR\x06orders\"d\n" + "\x15OpaqueEchoNoteRequest\x12K\n" + "\x04note\x18\x01 \x01(\v27.grpc.gateway.examples.internal.proto.sub.StringMessageR\x04note\"e\n" + "\x16OpaqueEchoNoteResponse\x12K\n" + "\x04note\x18\x01 \x01(\v27.grpc.gateway.examples.internal.proto.sub.StringMessageR\x04note\"\xd4\x05\n" + "\rOpaqueAddress\x12!\n" + "\fstreet_line1\x18\x01 \x01(\tR\vstreetLine1\x12!\n" + "\fstreet_line2\x18\x02 \x01(\tR\vstreetLine2\x12\x12\n" + "\x04city\x18\x03 \x01(\tR\x04city\x12\x14\n" + "\x05state\x18\x04 \x01(\tR\x05state\x12\x18\n" + "\acountry\x18\x05 \x01(\tR\acountry\x12\x1f\n" + "\vpostal_code\x18\x06 \x01(\tR\n" + "postalCode\x12r\n" + "\faddress_type\x18\a \x01(\x0e2O.grpc.gateway.examples.internal.proto.examplepb.OpaqueAddress.OpaqueAddressTypeR\vaddressType\x129\n" + "\n" + "is_default\x18\b \x01(\v2\x1a.google.protobuf.BoolValueR\tisDefault\x12g\n" + "\bmetadata\x18\t \x03(\v2K.grpc.gateway.examples.internal.proto.examplepb.OpaqueAddress.MetadataEntryR\bmetadata\x1a;\n" + "\rMetadataEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xc2\x01\n" + "\x11OpaqueAddressType\x12#\n" + "\x1fOPAQUE_ADDRESS_TYPE_UNSPECIFIED\x10\x00\x12#\n" + "\x1fOPAQUE_ADDRESS_TYPE_RESIDENTIAL\x10\x01\x12 \n" + "\x1cOPAQUE_ADDRESS_TYPE_BUSINESS\x10\x02\x12 \n" + "\x1cOPAQUE_ADDRESS_TYPE_SHIPPING\x10\x03\x12\x1f\n" + "\x1bOPAQUE_ADDRESS_TYPE_BILLING\x10\x04\"\xfe\x01\n" + "\vOpaquePrice\x12\x16\n" + "\x06amount\x18\x01 \x01(\x01R\x06amount\x12#\n" + "\rcurrency_code\x18\x02 \x01(\tR\fcurrencyCode\x12#\n" + "\ris_discounted\x18\x03 \x01(\bR\fisDiscounted\x12E\n" + "\x0foriginal_amount\x18\x04 \x01(\v2\x1c.google.protobuf.DoubleValueR\x0eoriginalAmount\x12F\n" + "\x11price_valid_until\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\x0fpriceValidUntil\"\xe8\x02\n" + "\x15OpaqueProductCategory\x12\x1f\n" + "\vcategory_id\x18\x01 \x01(\tR\n" + "categoryId\x12\x12\n" + "\x04name\x18\x02 \x01(\tR\x04name\x12 \n" + "\vdescription\x18\x03 \x01(\tR\vdescription\x12n\n" + "\x0fparent_category\x18\x04 \x01(\v2E.grpc.gateway.examples.internal.proto.examplepb.OpaqueProductCategoryR\x0eparentCategory\x12\x12\n" + "\x04tags\x18\x05 \x03(\tR\x04tags\x129\n" + "\n" + "created_at\x18\x06 \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x129\n" + "\n" + "updated_at\x18\a \x01(\v2\x1a.google.protobuf.TimestampR\tupdatedAt\"\xef\x04\n" + "\x14OpaqueProductVariant\x12\x1d\n" + "\n" + "variant_id\x18\x01 \x01(\tR\tvariantId\x12\x10\n" + "\x03sku\x18\x02 \x01(\tR\x03sku\x12\x12\n" + "\x04name\x18\x03 \x01(\tR\x04name\x12Q\n" + "\x05price\x18\x04 \x01(\v2;.grpc.gateway.examples.internal.proto.examplepb.OpaquePriceR\x05price\x12'\n" + "\x0finventory_count\x18\x05 \x01(\x05R\x0einventoryCount\x12t\n" + "\n" + "attributes\x18\x06 \x03(\v2T.grpc.gateway.examples.internal.proto.examplepb.OpaqueProductVariant.AttributesEntryR\n" + "attributes\x12\x1d\n" + "\n" + "image_data\x18\a \x01(\fR\timageData\x12\x1d\n" + "\n" + "image_urls\x18\b \x03(\tR\timageUrls\x12=\n" + "\fis_available\x18\t \x01(\v2\x1a.google.protobuf.BoolValueR\visAvailable\x12'\n" + "\x0epercentage_off\x18\n" + " \x01(\x01H\x00R\rpercentageOff\x12*\n" + "\x10fixed_amount_off\x18\v \x01(\x01H\x00R\x0efixedAmountOff\x1a=\n" + "\x0fAttributesEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01B\x0f\n" + "\rdiscount_info\"\xf4\x0f\n" + "\rOpaqueProduct\x12\x1d\n" + "\n" + "product_id\x18\x01 \x01(\tR\tproductId\x12\x12\n" + "\x04name\x18\x02 \x01(\tR\x04name\x12 \n" + "\vdescription\x18\x03 \x01(\tR\vdescription\x12\x14\n" + "\x05brand\x18\x04 \x01(\tR\x05brand\x12Z\n" + "\n" + "base_price\x18\x05 \x01(\v2;.grpc.gateway.examples.internal.proto.examplepb.OpaquePriceR\tbasePrice\x12a\n" + "\bcategory\x18\x06 \x01(\v2E.grpc.gateway.examples.internal.proto.examplepb.OpaqueProductCategoryR\bcategory\x12`\n" + "\bvariants\x18\a \x03(\v2D.grpc.gateway.examples.internal.proto.examplepb.OpaqueProductVariantR\bvariants\x12\x12\n" + "\x04tags\x18\b \x03(\tR\x04tags\x12%\n" + "\x0eaverage_rating\x18\t \x01(\x01R\raverageRating\x12!\n" + "\freview_count\x18\n" + " \x01(\x05R\vreviewCount\x12;\n" + "\vis_featured\x18\v \x01(\v2\x1a.google.protobuf.BoolValueR\n" + "isFeatured\x129\n" + "\n" + "created_at\x18\f \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x129\n" + "\n" + "updated_at\x18\r \x01(\v2\x1a.google.protobuf.TimestampR\tupdatedAt\x12M\n" + "\x15average_shipping_time\x18\x0e \x01(\v2\x19.google.protobuf.DurationR\x13averageShippingTime\x12i\n" + "\x06status\x18\x0f \x01(\x0e2Q.grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.OpaqueProductStatusR\x06status\x12g\n" + "\bmetadata\x18\x10 \x03(\v2K.grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.MetadataEntryR\bmetadata\x12z\n" + "\x0fregional_prices\x18\x11 \x03(\v2Q.grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.RegionalPricesEntryR\x0eregionalPrices\x12u\n" + "\n" + "dimensions\x18\x12 \x01(\v2U.grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.OpaqueProductDimensionsR\n" + "dimensions\x12'\n" + "\x0etax_percentage\x18\x13 \x01(\x01H\x00R\rtaxPercentage\x12\x1f\n" + "\n" + "tax_exempt\x18\x14 \x01(\bH\x00R\ttaxExempt\x1a;\n" + "\rMetadataEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\x1a~\n" + "\x13RegionalPricesEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12Q\n" + "\x05value\x18\x02 \x01(\v2;.grpc.gateway.examples.internal.proto.examplepb.OpaquePriceR\x05value:\x028\x01\x1a\xca\x02\n" + "\x17OpaqueProductDimensions\x12\x16\n" + "\x06length\x18\x01 \x01(\x01R\x06length\x12\x14\n" + "\x05width\x18\x02 \x01(\x01R\x05width\x12\x16\n" + "\x06height\x18\x03 \x01(\x01R\x06height\x12\x16\n" + "\x06weight\x18\x04 \x01(\x01R\x06weight\x12t\n" + "\x04unit\x18\x05 \x01(\x0e2`.grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.OpaqueProductDimensions.OpaqueUnitR\x04unit\"[\n" + "\n" + "OpaqueUnit\x12\x1b\n" + "\x17OPAQUE_UNIT_UNSPECIFIED\x10\x00\x12\x16\n" + "\x12OPAQUE_UNIT_METRIC\x10\x01\x12\x18\n" + "\x14OPAQUE_UNIT_IMPERIAL\x10\x02\"\xcf\x01\n" + "\x13OpaqueProductStatus\x12%\n" + "!OPAQUE_PRODUCT_STATUS_UNSPECIFIED\x10\x00\x12\x1f\n" + "\x1bOPAQUE_PRODUCT_STATUS_DRAFT\x10\x01\x12 \n" + "\x1cOPAQUE_PRODUCT_STATUS_ACTIVE\x10\x02\x12&\n" + "\"OPAQUE_PRODUCT_STATUS_OUT_OF_STOCK\x10\x03\x12&\n" + "\"OPAQUE_PRODUCT_STATUS_DISCONTINUED\x10\x04B\n" + "\n" + "\btax_info\"\xd5\v\n" + "\x0eOpaqueCustomer\x12\x1f\n" + "\vcustomer_id\x18\x01 \x01(\tR\n" + "customerId\x12\x14\n" + "\x05email\x18\x02 \x01(\tR\x05email\x12\x1d\n" + "\n" + "first_name\x18\x03 \x01(\tR\tfirstName\x12\x1b\n" + "\tlast_name\x18\x04 \x01(\tR\blastName\x12!\n" + "\fphone_number\x18\x05 \x01(\tR\vphoneNumber\x12[\n" + "\taddresses\x18\x06 \x03(\v2=.grpc.gateway.examples.internal.proto.examplepb.OpaqueAddressR\taddresses\x129\n" + "\n" + "created_at\x18\a \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x129\n" + "\n" + "last_login\x18\b \x01(\v2\x1a.google.protobuf.TimestampR\tlastLogin\x12k\n" + "\x06status\x18\t \x01(\x0e2S.grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer.OpaqueCustomerStatusR\x06status\x12s\n" + "\floyalty_info\x18\n" + " \x01(\v2P.grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer.OpaqueLoyaltyInfoR\vloyaltyInfo\x12q\n" + "\vpreferences\x18\v \x03(\v2O.grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer.PreferencesEntryR\vpreferences\x12{\n" + "\x0fpayment_methods\x18\f \x03(\v2R.grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer.OpaquePaymentMethodR\x0epaymentMethods\x1a\x96\x01\n" + "\x11OpaqueLoyaltyInfo\x12\x12\n" + "\x04tier\x18\x01 \x01(\tR\x04tier\x12\x16\n" + "\x06points\x18\x02 \x01(\x05R\x06points\x12;\n" + "\vtier_expiry\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\n" + "tierExpiry\x12\x18\n" + "\arewards\x18\x04 \x03(\tR\arewards\x1a>\n" + "\x10PreferencesEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\x1a\xdb\x01\n" + "\x13OpaquePaymentMethod\x12\x1d\n" + "\n" + "payment_id\x18\x01 \x01(\tR\tpaymentId\x12\x12\n" + "\x04type\x18\x02 \x01(\tR\x04type\x12\x1b\n" + "\tlast_four\x18\x03 \x01(\tR\blastFour\x12\x1a\n" + "\bprovider\x18\x04 \x01(\tR\bprovider\x129\n" + "\n" + "expires_at\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\texpiresAt\x12\x1d\n" + "\n" + "is_default\x18\x06 \x01(\bR\tisDefault\"\xd0\x01\n" + "\x14OpaqueCustomerStatus\x12&\n" + "\"OPAQUE_CUSTOMER_STATUS_UNSPECIFIED\x10\x00\x12!\n" + "\x1dOPAQUE_CUSTOMER_STATUS_ACTIVE\x10\x01\x12#\n" + "\x1fOPAQUE_CUSTOMER_STATUS_INACTIVE\x10\x02\x12$\n" + " OPAQUE_CUSTOMER_STATUS_SUSPENDED\x10\x03\x12\"\n" + "\x1eOPAQUE_CUSTOMER_STATUS_DELETED\x10\x04\"\xfc\x04\n" + "\x0fOpaqueOrderItem\x12\x1d\n" + "\n" + "product_id\x18\x01 \x01(\tR\tproductId\x12\x1d\n" + "\n" + "variant_id\x18\x02 \x01(\tR\tvariantId\x12!\n" + "\fproduct_name\x18\x03 \x01(\tR\vproductName\x12\x1a\n" + "\bquantity\x18\x04 \x01(\x05R\bquantity\x12Z\n" + "\n" + "unit_price\x18\x05 \x01(\v2;.grpc.gateway.examples.internal.proto.examplepb.OpaquePriceR\tunitPrice\x12\\\n" + "\vtotal_price\x18\x06 \x01(\v2;.grpc.gateway.examples.internal.proto.examplepb.OpaquePriceR\n" + "totalPrice\x12\x88\x01\n" + "\x13selected_attributes\x18\a \x03(\v2W.grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderItem.SelectedAttributesEntryR\x12selectedAttributes\x12=\n" + "\fgift_wrapped\x18\b \x01(\v2\x1a.google.protobuf.BoolValueR\vgiftWrapped\x12!\n" + "\fgift_message\x18\t \x01(\tR\vgiftMessage\x1aE\n" + "\x17SelectedAttributesEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xb1\x0f\n" + "\vOpaqueOrder\x12\x19\n" + "\border_id\x18\x01 \x01(\tR\aorderId\x12\x1f\n" + "\vcustomer_id\x18\x02 \x01(\tR\n" + "customerId\x12U\n" + "\x05items\x18\x03 \x03(\v2?.grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderItemR\x05items\x12W\n" + "\bsubtotal\x18\x04 \x01(\v2;.grpc.gateway.examples.internal.proto.examplepb.OpaquePriceR\bsubtotal\x12M\n" + "\x03tax\x18\x05 \x01(\v2;.grpc.gateway.examples.internal.proto.examplepb.OpaquePriceR\x03tax\x12W\n" + "\bshipping\x18\x06 \x01(\v2;.grpc.gateway.examples.internal.proto.examplepb.OpaquePriceR\bshipping\x12Q\n" + "\x05total\x18\a \x01(\v2;.grpc.gateway.examples.internal.proto.examplepb.OpaquePriceR\x05total\x12h\n" + "\x10shipping_address\x18\b \x01(\v2=.grpc.gateway.examples.internal.proto.examplepb.OpaqueAddressR\x0fshippingAddress\x12f\n" + "\x0fbilling_address\x18\t \x01(\v2=.grpc.gateway.examples.internal.proto.examplepb.OpaqueAddressR\x0ebillingAddress\x12e\n" + "\x06status\x18\n" + " \x01(\x0e2M.grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.OpaqueOrderStatusR\x06status\x12*\n" + "\x11payment_method_id\x18\v \x01(\tR\x0fpaymentMethodId\x12'\n" + "\x0ftracking_number\x18\f \x01(\tR\x0etrackingNumber\x129\n" + "\n" + "created_at\x18\r \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x129\n" + "\n" + "updated_at\x18\x0e \x01(\v2\x1a.google.protobuf.TimestampR\tupdatedAt\x129\n" + "\n" + "shipped_at\x18\x0f \x01(\v2\x1a.google.protobuf.TimestampR\tshippedAt\x12=\n" + "\fdelivered_at\x18\x10 \x01(\v2\x1a.google.protobuf.TimestampR\vdeliveredAt\x12s\n" + "\rshipping_info\x18\x11 \x01(\v2N.grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.OpaqueShippingInfoR\fshippingInfo\x12e\n" + "\bmetadata\x18\x12 \x03(\v2I.grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.MetadataEntryR\bmetadata\x12!\n" + "\vcoupon_code\x18\x13 \x01(\tH\x00R\n" + "couponCode\x12#\n" + "\fpromotion_id\x18\x14 \x01(\tH\x00R\vpromotionId\x1a\xbe\x01\n" + "\x12OpaqueShippingInfo\x12\x18\n" + "\acarrier\x18\x01 \x01(\tR\acarrier\x12\x16\n" + "\x06method\x18\x02 \x01(\tR\x06method\x12Q\n" + "\x17estimated_delivery_time\x18\x03 \x01(\v2\x19.google.protobuf.DurationR\x15estimatedDeliveryTime\x12#\n" + "\rtracking_urls\x18\x04 \x03(\tR\ftrackingUrls\x1a;\n" + "\rMetadataEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\x86\x02\n" + "\x11OpaqueOrderStatus\x12#\n" + "\x1fOPAQUE_ORDER_STATUS_UNSPECIFIED\x10\x00\x12\x1f\n" + "\x1bOPAQUE_ORDER_STATUS_PENDING\x10\x01\x12\"\n" + "\x1eOPAQUE_ORDER_STATUS_PROCESSING\x10\x02\x12\x1f\n" + "\x1bOPAQUE_ORDER_STATUS_SHIPPED\x10\x03\x12!\n" + "\x1dOPAQUE_ORDER_STATUS_DELIVERED\x10\x04\x12!\n" + "\x1dOPAQUE_ORDER_STATUS_CANCELLED\x10\x05\x12 \n" + "\x1cOPAQUE_ORDER_STATUS_RETURNED\x10\x06B\x12\n" + "\x10discount_applied\"\xf8\x05\n" + "\x12OpaqueOrderSummary\x124\n" + "\x16total_orders_processed\x18\x01 \x01(\x05R\x14totalOrdersProcessed\x12+\n" + "\x11successful_orders\x18\x02 \x01(\x05R\x10successfulOrders\x12#\n" + "\rfailed_orders\x18\x03 \x01(\x05R\ffailedOrders\x12\\\n" + "\vtotal_value\x18\x04 \x01(\v2;.grpc.gateway.examples.internal.proto.examplepb.OpaquePriceR\n" + "totalValue\x12\x1b\n" + "\torder_ids\x18\x05 \x03(\tR\borderIds\x12y\n" + "\rerror_details\x18\x06 \x03(\v2T.grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderSummary.ErrorDetailsEntryR\ferrorDetails\x12C\n" + "\x0fprocessing_time\x18\a \x01(\v2\x1a.google.protobuf.TimestampR\x0eprocessingTime\x12k\n" + "\x06errors\x18\b \x03(\v2S.grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderSummary.OpaqueOrderErrorR\x06errors\x1a?\n" + "\x11ErrorDetailsEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\x1aq\n" + "\x10OpaqueOrderError\x12\x19\n" + "\border_id\x18\x01 \x01(\tR\aorderId\x12\x1d\n" + "\n" + "error_code\x18\x02 \x01(\tR\terrorCode\x12#\n" + "\rerror_message\x18\x03 \x01(\tR\ferrorMessage\"\x81\b\n" + "\x13OpaqueCustomerEvent\x12\x1f\n" + "\vcustomer_id\x18\x01 \x01(\tR\n" + "customerId\x12\x1d\n" + "\n" + "session_id\x18\x02 \x01(\tR\tsessionId\x12r\n" + "\n" + "event_type\x18\x03 \x01(\x0e2S.grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomerEvent.OpaqueEventTypeR\teventType\x128\n" + "\ttimestamp\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\ttimestamp\x12\x1d\n" + "\n" + "product_id\x18\x05 \x01(\tR\tproductId\x12\x1f\n" + "\vcategory_id\x18\x06 \x01(\tR\n" + "categoryId\x12!\n" + "\fsearch_query\x18\a \x01(\tR\vsearchQuery\x12\x19\n" + "\bpage_url\x18\b \x01(\tR\apageUrl\x12\x14\n" + "\x05value\x18\t \x01(\x05R\x05value\x12q\n" + "\n" + "event_data\x18\n" + " \x03(\v2R.grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomerEvent.EventDataEntryR\teventData\x12\x1f\n" + "\vdevice_type\x18\v \x01(\tR\n" + "deviceType\x12\x1d\n" + "\n" + "ip_address\x18\f \x01(\tR\tipAddress\x12\x1d\n" + "\n" + "user_agent\x18\r \x01(\tR\tuserAgent\x1a<\n" + "\x0eEventDataEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xd7\x02\n" + "\x0fOpaqueEventType\x12!\n" + "\x1dOPAQUE_EVENT_TYPE_UNSPECIFIED\x10\x00\x12\x1f\n" + "\x1bOPAQUE_EVENT_TYPE_PAGE_VIEW\x10\x01\x12\"\n" + "\x1eOPAQUE_EVENT_TYPE_PRODUCT_VIEW\x10\x02\x12!\n" + "\x1dOPAQUE_EVENT_TYPE_ADD_TO_CART\x10\x03\x12&\n" + "\"OPAQUE_EVENT_TYPE_REMOVE_FROM_CART\x10\x04\x12$\n" + " OPAQUE_EVENT_TYPE_CHECKOUT_START\x10\x05\x12'\n" + "#OPAQUE_EVENT_TYPE_CHECKOUT_COMPLETE\x10\x06\x12\x1c\n" + "\x18OPAQUE_EVENT_TYPE_SEARCH\x10\a\x12$\n" + " OPAQUE_EVENT_TYPE_ACCOUNT_UPDATE\x10\b\"\xa2\t\n" + "\x14OpaqueActivityUpdate\x12\x1f\n" + "\vcustomer_id\x18\x01 \x01(\tR\n" + "customerId\x12\x1d\n" + "\n" + "session_id\x18\x02 \x01(\tR\tsessionId\x12v\n" + "\vupdate_type\x18\x03 \x01(\x0e2U.grpc.gateway.examples.internal.proto.examplepb.OpaqueActivityUpdate.OpaqueUpdateTypeR\n" + "updateType\x128\n" + "\ttimestamp\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\ttimestamp\x12\x18\n" + "\amessage\x18\x05 \x01(\tR\amessage\x12\x1f\n" + "\vproduct_ids\x18\x06 \x03(\tR\n" + "productIds\x12^\n" + "\fprice_update\x18\a \x01(\v2;.grpc.gateway.examples.internal.proto.examplepb.OpaquePriceR\vpriceUpdate\x12'\n" + "\x0finventory_count\x18\b \x01(\x05R\x0einventoryCount\x12\x1d\n" + "\n" + "offer_code\x18\t \x01(\tR\tofferCode\x12<\n" + "\foffer_expiry\x18\n" + " \x01(\v2\x19.google.protobuf.DurationR\vofferExpiry\x12/\n" + "\x13discount_percentage\x18\v \x01(\x01R\x12discountPercentage\x12u\n" + "\vupdate_data\x18\f \x03(\v2T.grpc.gateway.examples.internal.proto.examplepb.OpaqueActivityUpdate.UpdateDataEntryR\n" + "updateData\x12\x1a\n" + "\bpriority\x18\r \x01(\x05R\bpriority\x12#\n" + "\fredirect_url\x18\x0e \x01(\tH\x00R\vredirectUrl\x12)\n" + "\x0fnotification_id\x18\x0f \x01(\tH\x00R\x0enotificationId\x1a=\n" + "\x0fUpdateDataEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\x94\x02\n" + "\x10OpaqueUpdateType\x12\"\n" + "\x1eOPAQUE_UPDATE_TYPE_UNSPECIFIED\x10\x00\x12%\n" + "!OPAQUE_UPDATE_TYPE_RECOMMENDATION\x10\x01\x12#\n" + "\x1fOPAQUE_UPDATE_TYPE_NOTIFICATION\x10\x02\x12\x1c\n" + "\x18OPAQUE_UPDATE_TYPE_OFFER\x10\x03\x12'\n" + "#OPAQUE_UPDATE_TYPE_INVENTORY_UPDATE\x10\x04\x12#\n" + "\x1fOPAQUE_UPDATE_TYPE_PRICE_CHANGE\x10\x05\x12$\n" + " OPAQUE_UPDATE_TYPE_CART_REMINDER\x10\x06B\r\n" + "\vaction_data2\xf1\x0f\n" + "\x16OpaqueEcommerceService\x12\xc8\x01\n" + "\x10OpaqueGetProduct\x12G.grpc.gateway.examples.internal.proto.examplepb.OpaqueGetProductRequest\x1aH.grpc.gateway.examples.internal.proto.examplepb.OpaqueGetProductResponse\"!\x82\xd3\xe4\x93\x02\x1b\x12\x19/v1/products/{product_id}\x12\xd0\x01\n" + "\x14OpaqueSearchProducts\x12K.grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchProductsRequest\x1aL.grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchProductsResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/v1/products/search0\x01\x12\xc7\x01\n" + "\x13OpaqueCreateProduct\x12J.grpc.gateway.examples.internal.proto.examplepb.OpaqueCreateProductRequest\x1aK.grpc.gateway.examples.internal.proto.examplepb.OpaqueCreateProductResponse\"\x17\x82\xd3\xe4\x93\x02\x11:\x01*\"\f/v1/products\x12\xe1\x01\n" + "\x18OpaqueCreateProductField\x12O.grpc.gateway.examples.internal.proto.examplepb.OpaqueCreateProductFieldRequest\x1aP.grpc.gateway.examples.internal.proto.examplepb.OpaqueCreateProductFieldResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\aproduct\"\x11/v1/productsField\x12\xcf\x01\n" + "\x13OpaqueProcessOrders\x12J.grpc.gateway.examples.internal.proto.examplepb.OpaqueProcessOrdersRequest\x1aK.grpc.gateway.examples.internal.proto.examplepb.OpaqueProcessOrdersResponse\"\x1d\x82\xd3\xe4\x93\x02\x17:\x01*\"\x12/v1/orders/process(\x01\x12\xef\x01\n" + "\x1cOpaqueStreamCustomerActivity\x12S.grpc.gateway.examples.internal.proto.examplepb.OpaqueStreamCustomerActivityRequest\x1aT.grpc.gateway.examples.internal.proto.examplepb.OpaqueStreamCustomerActivityResponse\" \x82\xd3\xe4\x93\x02\x1a:\x01*\"\x15/v1/customer/activity(\x010\x01\x12\xf8\x01\n" + "\x13OpaqueUpdateProduct\x12J.grpc.gateway.examples.internal.proto.examplepb.OpaqueUpdateProductRequest\x1aK.grpc.gateway.examples.internal.proto.examplepb.OpaqueUpdateProductResponse\"H\xdaA\x13product,update_mask\x82\xd3\xe4\x93\x02,:\aproduct2!/v1/products/{product.product_id}\x12\x8b\x02\n" + "\x12OpaqueSearchOrders\x12I.grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchOrdersRequest\x1aJ.grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchOrdersResponse\"^\x82\xd3\xe4\x93\x02X\x12V/v1/orders/search/{order.status}/shipAddressType/{order.shipping_address.address_type}\x12\xbd\x01\n" + "\x0eOpaqueEchoNote\x12E.grpc.gateway.examples.internal.proto.examplepb.OpaqueEchoNoteRequest\x1aF.grpc.gateway.examples.internal.proto.examplepb.OpaqueEchoNoteResponse\"\x1c\x82\xd3\xe4\x93\x02\x16:\x04note\"\x0e/v1/notes:echoBMZKgithub.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepbb\beditionsp\xe8\a" var file_examples_internal_proto_examplepb_opaque_proto_enumTypes = make([]protoimpl.EnumInfo, 8) var file_examples_internal_proto_examplepb_opaque_proto_msgTypes = make([]protoimpl.MessageInfo, 45) var file_examples_internal_proto_examplepb_opaque_proto_goTypes = []any{ (OpaqueSearchProductsRequest_OpaqueSortOrder)(0), // 0: grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchProductsRequest.OpaqueSortOrder (OpaqueAddress_OpaqueAddressType)(0), // 1: grpc.gateway.examples.internal.proto.examplepb.OpaqueAddress.OpaqueAddressType (OpaqueProduct_OpaqueProductStatus)(0), // 2: grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.OpaqueProductStatus (OpaqueProduct_OpaqueProductDimensions_OpaqueUnit)(0), // 3: grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.OpaqueProductDimensions.OpaqueUnit (OpaqueCustomer_OpaqueCustomerStatus)(0), // 4: grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer.OpaqueCustomerStatus (OpaqueOrder_OpaqueOrderStatus)(0), // 5: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.OpaqueOrderStatus (OpaqueCustomerEvent_OpaqueEventType)(0), // 6: grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomerEvent.OpaqueEventType (OpaqueActivityUpdate_OpaqueUpdateType)(0), // 7: grpc.gateway.examples.internal.proto.examplepb.OpaqueActivityUpdate.OpaqueUpdateType (*OpaqueUpdateProductRequest)(nil), // 8: grpc.gateway.examples.internal.proto.examplepb.OpaqueUpdateProductRequest (*OpaqueUpdateProductResponse)(nil), // 9: grpc.gateway.examples.internal.proto.examplepb.OpaqueUpdateProductResponse (*OpaqueGetProductRequest)(nil), // 10: grpc.gateway.examples.internal.proto.examplepb.OpaqueGetProductRequest (*OpaqueGetProductResponse)(nil), // 11: grpc.gateway.examples.internal.proto.examplepb.OpaqueGetProductResponse (*OpaqueSearchProductsRequest)(nil), // 12: grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchProductsRequest (*OpaqueSearchProductsResponse)(nil), // 13: grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchProductsResponse (*OpaqueCreateProductRequest)(nil), // 14: grpc.gateway.examples.internal.proto.examplepb.OpaqueCreateProductRequest (*OpaqueCreateProductResponse)(nil), // 15: grpc.gateway.examples.internal.proto.examplepb.OpaqueCreateProductResponse (*OpaqueCreateProductFieldRequest)(nil), // 16: grpc.gateway.examples.internal.proto.examplepb.OpaqueCreateProductFieldRequest (*OpaqueCreateProductFieldResponse)(nil), // 17: grpc.gateway.examples.internal.proto.examplepb.OpaqueCreateProductFieldResponse (*OpaqueProcessOrdersRequest)(nil), // 18: grpc.gateway.examples.internal.proto.examplepb.OpaqueProcessOrdersRequest (*OpaqueProcessOrdersResponse)(nil), // 19: grpc.gateway.examples.internal.proto.examplepb.OpaqueProcessOrdersResponse (*OpaqueStreamCustomerActivityRequest)(nil), // 20: grpc.gateway.examples.internal.proto.examplepb.OpaqueStreamCustomerActivityRequest (*OpaqueStreamCustomerActivityResponse)(nil), // 21: grpc.gateway.examples.internal.proto.examplepb.OpaqueStreamCustomerActivityResponse (*OpaqueSearchOrdersRequest)(nil), // 22: grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchOrdersRequest (*OpaqueSearchOrdersResponse)(nil), // 23: grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchOrdersResponse (*OpaqueEchoNoteRequest)(nil), // 24: grpc.gateway.examples.internal.proto.examplepb.OpaqueEchoNoteRequest (*OpaqueEchoNoteResponse)(nil), // 25: grpc.gateway.examples.internal.proto.examplepb.OpaqueEchoNoteResponse (*OpaqueAddress)(nil), // 26: grpc.gateway.examples.internal.proto.examplepb.OpaqueAddress (*OpaquePrice)(nil), // 27: grpc.gateway.examples.internal.proto.examplepb.OpaquePrice (*OpaqueProductCategory)(nil), // 28: grpc.gateway.examples.internal.proto.examplepb.OpaqueProductCategory (*OpaqueProductVariant)(nil), // 29: grpc.gateway.examples.internal.proto.examplepb.OpaqueProductVariant (*OpaqueProduct)(nil), // 30: grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct (*OpaqueCustomer)(nil), // 31: grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer (*OpaqueOrderItem)(nil), // 32: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderItem (*OpaqueOrder)(nil), // 33: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder (*OpaqueOrderSummary)(nil), // 34: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderSummary (*OpaqueCustomerEvent)(nil), // 35: grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomerEvent (*OpaqueActivityUpdate)(nil), // 36: grpc.gateway.examples.internal.proto.examplepb.OpaqueActivityUpdate nil, // 37: grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchProductsRequest.FiltersEntry nil, // 38: grpc.gateway.examples.internal.proto.examplepb.OpaqueAddress.MetadataEntry nil, // 39: grpc.gateway.examples.internal.proto.examplepb.OpaqueProductVariant.AttributesEntry nil, // 40: grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.MetadataEntry nil, // 41: grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.RegionalPricesEntry (*OpaqueProduct_OpaqueProductDimensions)(nil), // 42: grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.OpaqueProductDimensions (*OpaqueCustomer_OpaqueLoyaltyInfo)(nil), // 43: grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer.OpaqueLoyaltyInfo nil, // 44: grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer.PreferencesEntry (*OpaqueCustomer_OpaquePaymentMethod)(nil), // 45: grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer.OpaquePaymentMethod nil, // 46: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderItem.SelectedAttributesEntry (*OpaqueOrder_OpaqueShippingInfo)(nil), // 47: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.OpaqueShippingInfo nil, // 48: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.MetadataEntry nil, // 49: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderSummary.ErrorDetailsEntry (*OpaqueOrderSummary_OpaqueOrderError)(nil), // 50: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderSummary.OpaqueOrderError nil, // 51: grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomerEvent.EventDataEntry nil, // 52: grpc.gateway.examples.internal.proto.examplepb.OpaqueActivityUpdate.UpdateDataEntry (*fieldmaskpb.FieldMask)(nil), // 53: google.protobuf.FieldMask (*sub.StringMessage)(nil), // 54: grpc.gateway.examples.internal.proto.sub.StringMessage (*wrapperspb.BoolValue)(nil), // 55: google.protobuf.BoolValue (*wrapperspb.DoubleValue)(nil), // 56: google.protobuf.DoubleValue (*timestamppb.Timestamp)(nil), // 57: google.protobuf.Timestamp (*durationpb.Duration)(nil), // 58: google.protobuf.Duration } var file_examples_internal_proto_examplepb_opaque_proto_depIdxs = []int32{ 30, // 0: grpc.gateway.examples.internal.proto.examplepb.OpaqueUpdateProductRequest.product:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct 53, // 1: grpc.gateway.examples.internal.proto.examplepb.OpaqueUpdateProductRequest.update_mask:type_name -> google.protobuf.FieldMask 30, // 2: grpc.gateway.examples.internal.proto.examplepb.OpaqueUpdateProductResponse.product:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct 30, // 3: grpc.gateway.examples.internal.proto.examplepb.OpaqueGetProductResponse.product:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct 27, // 4: grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchProductsRequest.min_price:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaquePrice 27, // 5: grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchProductsRequest.max_price:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaquePrice 0, // 6: grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchProductsRequest.sort_by:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchProductsRequest.OpaqueSortOrder 53, // 7: grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchProductsRequest.field_mask:type_name -> google.protobuf.FieldMask 37, // 8: grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchProductsRequest.filters:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchProductsRequest.FiltersEntry 30, // 9: grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchProductsResponse.product:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct 30, // 10: grpc.gateway.examples.internal.proto.examplepb.OpaqueCreateProductRequest.product:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct 30, // 11: grpc.gateway.examples.internal.proto.examplepb.OpaqueCreateProductResponse.product:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct 30, // 12: grpc.gateway.examples.internal.proto.examplepb.OpaqueCreateProductFieldRequest.product:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct 30, // 13: grpc.gateway.examples.internal.proto.examplepb.OpaqueCreateProductFieldResponse.product:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct 33, // 14: grpc.gateway.examples.internal.proto.examplepb.OpaqueProcessOrdersRequest.order:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder 34, // 15: grpc.gateway.examples.internal.proto.examplepb.OpaqueProcessOrdersResponse.summary:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderSummary 35, // 16: grpc.gateway.examples.internal.proto.examplepb.OpaqueStreamCustomerActivityRequest.event:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomerEvent 36, // 17: grpc.gateway.examples.internal.proto.examplepb.OpaqueStreamCustomerActivityResponse.event:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueActivityUpdate 33, // 18: grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchOrdersRequest.order:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder 33, // 19: grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchOrdersResponse.orders:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder 54, // 20: grpc.gateway.examples.internal.proto.examplepb.OpaqueEchoNoteRequest.note:type_name -> grpc.gateway.examples.internal.proto.sub.StringMessage 54, // 21: grpc.gateway.examples.internal.proto.examplepb.OpaqueEchoNoteResponse.note:type_name -> grpc.gateway.examples.internal.proto.sub.StringMessage 1, // 22: grpc.gateway.examples.internal.proto.examplepb.OpaqueAddress.address_type:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueAddress.OpaqueAddressType 55, // 23: grpc.gateway.examples.internal.proto.examplepb.OpaqueAddress.is_default:type_name -> google.protobuf.BoolValue 38, // 24: grpc.gateway.examples.internal.proto.examplepb.OpaqueAddress.metadata:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueAddress.MetadataEntry 56, // 25: grpc.gateway.examples.internal.proto.examplepb.OpaquePrice.original_amount:type_name -> google.protobuf.DoubleValue 57, // 26: grpc.gateway.examples.internal.proto.examplepb.OpaquePrice.price_valid_until:type_name -> google.protobuf.Timestamp 28, // 27: grpc.gateway.examples.internal.proto.examplepb.OpaqueProductCategory.parent_category:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueProductCategory 57, // 28: grpc.gateway.examples.internal.proto.examplepb.OpaqueProductCategory.created_at:type_name -> google.protobuf.Timestamp 57, // 29: grpc.gateway.examples.internal.proto.examplepb.OpaqueProductCategory.updated_at:type_name -> google.protobuf.Timestamp 27, // 30: grpc.gateway.examples.internal.proto.examplepb.OpaqueProductVariant.price:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaquePrice 39, // 31: grpc.gateway.examples.internal.proto.examplepb.OpaqueProductVariant.attributes:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueProductVariant.AttributesEntry 55, // 32: grpc.gateway.examples.internal.proto.examplepb.OpaqueProductVariant.is_available:type_name -> google.protobuf.BoolValue 27, // 33: grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.base_price:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaquePrice 28, // 34: grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.category:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueProductCategory 29, // 35: grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.variants:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueProductVariant 55, // 36: grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.is_featured:type_name -> google.protobuf.BoolValue 57, // 37: grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.created_at:type_name -> google.protobuf.Timestamp 57, // 38: grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.updated_at:type_name -> google.protobuf.Timestamp 58, // 39: grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.average_shipping_time:type_name -> google.protobuf.Duration 2, // 40: grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.status:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.OpaqueProductStatus 40, // 41: grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.metadata:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.MetadataEntry 41, // 42: grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.regional_prices:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.RegionalPricesEntry 42, // 43: grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.dimensions:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.OpaqueProductDimensions 26, // 44: grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer.addresses:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueAddress 57, // 45: grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer.created_at:type_name -> google.protobuf.Timestamp 57, // 46: grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer.last_login:type_name -> google.protobuf.Timestamp 4, // 47: grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer.status:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer.OpaqueCustomerStatus 43, // 48: grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer.loyalty_info:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer.OpaqueLoyaltyInfo 44, // 49: grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer.preferences:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer.PreferencesEntry 45, // 50: grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer.payment_methods:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer.OpaquePaymentMethod 27, // 51: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderItem.unit_price:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaquePrice 27, // 52: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderItem.total_price:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaquePrice 46, // 53: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderItem.selected_attributes:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderItem.SelectedAttributesEntry 55, // 54: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderItem.gift_wrapped:type_name -> google.protobuf.BoolValue 32, // 55: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.items:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderItem 27, // 56: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.subtotal:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaquePrice 27, // 57: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.tax:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaquePrice 27, // 58: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.shipping:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaquePrice 27, // 59: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.total:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaquePrice 26, // 60: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.shipping_address:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueAddress 26, // 61: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.billing_address:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueAddress 5, // 62: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.status:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.OpaqueOrderStatus 57, // 63: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.created_at:type_name -> google.protobuf.Timestamp 57, // 64: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.updated_at:type_name -> google.protobuf.Timestamp 57, // 65: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.shipped_at:type_name -> google.protobuf.Timestamp 57, // 66: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.delivered_at:type_name -> google.protobuf.Timestamp 47, // 67: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.shipping_info:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.OpaqueShippingInfo 48, // 68: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.metadata:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.MetadataEntry 27, // 69: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderSummary.total_value:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaquePrice 49, // 70: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderSummary.error_details:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderSummary.ErrorDetailsEntry 57, // 71: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderSummary.processing_time:type_name -> google.protobuf.Timestamp 50, // 72: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderSummary.errors:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueOrderSummary.OpaqueOrderError 6, // 73: grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomerEvent.event_type:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomerEvent.OpaqueEventType 57, // 74: grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomerEvent.timestamp:type_name -> google.protobuf.Timestamp 51, // 75: grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomerEvent.event_data:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomerEvent.EventDataEntry 7, // 76: grpc.gateway.examples.internal.proto.examplepb.OpaqueActivityUpdate.update_type:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueActivityUpdate.OpaqueUpdateType 57, // 77: grpc.gateway.examples.internal.proto.examplepb.OpaqueActivityUpdate.timestamp:type_name -> google.protobuf.Timestamp 27, // 78: grpc.gateway.examples.internal.proto.examplepb.OpaqueActivityUpdate.price_update:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaquePrice 58, // 79: grpc.gateway.examples.internal.proto.examplepb.OpaqueActivityUpdate.offer_expiry:type_name -> google.protobuf.Duration 52, // 80: grpc.gateway.examples.internal.proto.examplepb.OpaqueActivityUpdate.update_data:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueActivityUpdate.UpdateDataEntry 27, // 81: grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.RegionalPricesEntry.value:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaquePrice 3, // 82: grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.OpaqueProductDimensions.unit:type_name -> grpc.gateway.examples.internal.proto.examplepb.OpaqueProduct.OpaqueProductDimensions.OpaqueUnit 57, // 83: grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer.OpaqueLoyaltyInfo.tier_expiry:type_name -> google.protobuf.Timestamp 57, // 84: grpc.gateway.examples.internal.proto.examplepb.OpaqueCustomer.OpaquePaymentMethod.expires_at:type_name -> google.protobuf.Timestamp 58, // 85: grpc.gateway.examples.internal.proto.examplepb.OpaqueOrder.OpaqueShippingInfo.estimated_delivery_time:type_name -> google.protobuf.Duration 10, // 86: grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService.OpaqueGetProduct:input_type -> grpc.gateway.examples.internal.proto.examplepb.OpaqueGetProductRequest 12, // 87: grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService.OpaqueSearchProducts:input_type -> grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchProductsRequest 14, // 88: grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService.OpaqueCreateProduct:input_type -> grpc.gateway.examples.internal.proto.examplepb.OpaqueCreateProductRequest 16, // 89: grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService.OpaqueCreateProductField:input_type -> grpc.gateway.examples.internal.proto.examplepb.OpaqueCreateProductFieldRequest 18, // 90: grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService.OpaqueProcessOrders:input_type -> grpc.gateway.examples.internal.proto.examplepb.OpaqueProcessOrdersRequest 20, // 91: grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService.OpaqueStreamCustomerActivity:input_type -> grpc.gateway.examples.internal.proto.examplepb.OpaqueStreamCustomerActivityRequest 8, // 92: grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService.OpaqueUpdateProduct:input_type -> grpc.gateway.examples.internal.proto.examplepb.OpaqueUpdateProductRequest 22, // 93: grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService.OpaqueSearchOrders:input_type -> grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchOrdersRequest 24, // 94: grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService.OpaqueEchoNote:input_type -> grpc.gateway.examples.internal.proto.examplepb.OpaqueEchoNoteRequest 11, // 95: grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService.OpaqueGetProduct:output_type -> grpc.gateway.examples.internal.proto.examplepb.OpaqueGetProductResponse 13, // 96: grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService.OpaqueSearchProducts:output_type -> grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchProductsResponse 15, // 97: grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService.OpaqueCreateProduct:output_type -> grpc.gateway.examples.internal.proto.examplepb.OpaqueCreateProductResponse 17, // 98: grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService.OpaqueCreateProductField:output_type -> grpc.gateway.examples.internal.proto.examplepb.OpaqueCreateProductFieldResponse 19, // 99: grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService.OpaqueProcessOrders:output_type -> grpc.gateway.examples.internal.proto.examplepb.OpaqueProcessOrdersResponse 21, // 100: grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService.OpaqueStreamCustomerActivity:output_type -> grpc.gateway.examples.internal.proto.examplepb.OpaqueStreamCustomerActivityResponse 9, // 101: grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService.OpaqueUpdateProduct:output_type -> grpc.gateway.examples.internal.proto.examplepb.OpaqueUpdateProductResponse 23, // 102: grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService.OpaqueSearchOrders:output_type -> grpc.gateway.examples.internal.proto.examplepb.OpaqueSearchOrdersResponse 25, // 103: grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService.OpaqueEchoNote:output_type -> grpc.gateway.examples.internal.proto.examplepb.OpaqueEchoNoteResponse 95, // [95:104] is the sub-list for method output_type 86, // [86:95] is the sub-list for method input_type 86, // [86:86] is the sub-list for extension type_name 86, // [86:86] is the sub-list for extension extendee 0, // [0:86] is the sub-list for field type_name } func init() { file_examples_internal_proto_examplepb_opaque_proto_init() } func file_examples_internal_proto_examplepb_opaque_proto_init() { if File_examples_internal_proto_examplepb_opaque_proto != nil { return } file_examples_internal_proto_examplepb_opaque_proto_msgTypes[21].OneofWrappers = []any{ (*opaqueProductVariant_PercentageOff)(nil), (*opaqueProductVariant_FixedAmountOff)(nil), } file_examples_internal_proto_examplepb_opaque_proto_msgTypes[22].OneofWrappers = []any{ (*opaqueProduct_TaxPercentage)(nil), (*opaqueProduct_TaxExempt)(nil), } file_examples_internal_proto_examplepb_opaque_proto_msgTypes[25].OneofWrappers = []any{ (*opaqueOrder_CouponCode)(nil), (*opaqueOrder_PromotionId)(nil), } file_examples_internal_proto_examplepb_opaque_proto_msgTypes[28].OneofWrappers = []any{ (*opaqueActivityUpdate_RedirectUrl)(nil), (*opaqueActivityUpdate_NotificationId)(nil), } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_examples_internal_proto_examplepb_opaque_proto_rawDesc), len(file_examples_internal_proto_examplepb_opaque_proto_rawDesc)), NumEnums: 8, NumMessages: 45, NumExtensions: 0, NumServices: 1, }, GoTypes: file_examples_internal_proto_examplepb_opaque_proto_goTypes, DependencyIndexes: file_examples_internal_proto_examplepb_opaque_proto_depIdxs, EnumInfos: file_examples_internal_proto_examplepb_opaque_proto_enumTypes, MessageInfos: file_examples_internal_proto_examplepb_opaque_proto_msgTypes, }.Build() File_examples_internal_proto_examplepb_opaque_proto = out.File file_examples_internal_proto_examplepb_opaque_proto_goTypes = nil file_examples_internal_proto_examplepb_opaque_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/examplepb/opaque.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/proto/examplepb/opaque.proto /* Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package examplepb import ( "context" "errors" "io" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) var filter_OpaqueEcommerceService_OpaqueGetProduct_0 = &utilities.DoubleArray{Encoding: map[string]int{"product_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_OpaqueEcommerceService_OpaqueGetProduct_0(ctx context.Context, marshaler runtime.Marshaler, client OpaqueEcommerceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq OpaqueGetProductRequest metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["product_id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "product_id") } convertedProductId, err := runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "product_id", err) } protoReq.SetProductId(convertedProductId) if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_OpaqueEcommerceService_OpaqueGetProduct_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.OpaqueGetProduct(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_OpaqueEcommerceService_OpaqueGetProduct_0(ctx context.Context, marshaler runtime.Marshaler, server OpaqueEcommerceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq OpaqueGetProductRequest metadata runtime.ServerMetadata err error ) val, ok := pathParams["product_id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "product_id") } convertedProductId, err := runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "product_id", err) } protoReq.SetProductId(convertedProductId) if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_OpaqueEcommerceService_OpaqueGetProduct_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.OpaqueGetProduct(ctx, &protoReq) return msg, metadata, err } var filter_OpaqueEcommerceService_OpaqueSearchProducts_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_OpaqueEcommerceService_OpaqueSearchProducts_0(ctx context.Context, marshaler runtime.Marshaler, client OpaqueEcommerceServiceClient, req *http.Request, pathParams map[string]string) (OpaqueEcommerceService_OpaqueSearchProductsClient, runtime.ServerMetadata, error) { var ( protoReq OpaqueSearchProductsRequest metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_OpaqueEcommerceService_OpaqueSearchProducts_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } stream, err := client.OpaqueSearchProducts(ctx, &protoReq) if err != nil { return nil, metadata, err } header, err := stream.Header() if err != nil { return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } func request_OpaqueEcommerceService_OpaqueCreateProduct_0(ctx context.Context, marshaler runtime.Marshaler, client OpaqueEcommerceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq OpaqueCreateProductRequest metadata runtime.ServerMetadata ) var bodyData OpaqueCreateProductRequest if err := marshaler.NewDecoder(req.Body).Decode(&bodyData); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } proto.Merge(&protoReq, &bodyData) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.OpaqueCreateProduct(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_OpaqueEcommerceService_OpaqueCreateProduct_0(ctx context.Context, marshaler runtime.Marshaler, server OpaqueEcommerceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq OpaqueCreateProductRequest metadata runtime.ServerMetadata ) var bodyData OpaqueCreateProductRequest if err := marshaler.NewDecoder(req.Body).Decode(&bodyData); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } proto.Merge(&protoReq, &bodyData) msg, err := server.OpaqueCreateProduct(ctx, &protoReq) return msg, metadata, err } var filter_OpaqueEcommerceService_OpaqueCreateProductField_0 = &utilities.DoubleArray{Encoding: map[string]int{"product": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_OpaqueEcommerceService_OpaqueCreateProductField_0(ctx context.Context, marshaler runtime.Marshaler, client OpaqueEcommerceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq OpaqueCreateProductFieldRequest metadata runtime.ServerMetadata ) bodyData := &OpaqueProduct{} if err := marshaler.NewDecoder(req.Body).Decode(bodyData); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } protoReq.SetProduct(bodyData) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_OpaqueEcommerceService_OpaqueCreateProductField_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.OpaqueCreateProductField(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_OpaqueEcommerceService_OpaqueCreateProductField_0(ctx context.Context, marshaler runtime.Marshaler, server OpaqueEcommerceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq OpaqueCreateProductFieldRequest metadata runtime.ServerMetadata ) bodyData := &OpaqueProduct{} if err := marshaler.NewDecoder(req.Body).Decode(bodyData); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } protoReq.SetProduct(bodyData) if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_OpaqueEcommerceService_OpaqueCreateProductField_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.OpaqueCreateProductField(ctx, &protoReq) return msg, metadata, err } func request_OpaqueEcommerceService_OpaqueProcessOrders_0(ctx context.Context, marshaler runtime.Marshaler, client OpaqueEcommerceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var metadata runtime.ServerMetadata stream, err := client.OpaqueProcessOrders(ctx) if err != nil { grpclog.Errorf("Failed to start streaming: %v", err) return nil, metadata, err } dec := marshaler.NewDecoder(req.Body) for { var protoReq OpaqueProcessOrdersRequest err = dec.Decode(&protoReq) if errors.Is(err, io.EOF) { break } if err != nil { grpclog.Errorf("Failed to decode request: %v", err) return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err = stream.Send(&protoReq); err != nil { if errors.Is(err, io.EOF) { break } grpclog.Errorf("Failed to send request: %v", err) return nil, metadata, err } } if err := stream.CloseSend(); err != nil { grpclog.Errorf("Failed to terminate client stream: %v", err) return nil, metadata, err } header, err := stream.Header() if err != nil { grpclog.Errorf("Failed to get header from client: %v", err) return nil, metadata, err } metadata.HeaderMD = header msg, err := stream.CloseAndRecv() metadata.TrailerMD = stream.Trailer() return msg, metadata, err } func request_OpaqueEcommerceService_OpaqueStreamCustomerActivity_0(ctx context.Context, marshaler runtime.Marshaler, client OpaqueEcommerceServiceClient, req *http.Request, pathParams map[string]string) (OpaqueEcommerceService_OpaqueStreamCustomerActivityClient, runtime.ServerMetadata, error) { var metadata runtime.ServerMetadata stream, err := client.OpaqueStreamCustomerActivity(ctx) if err != nil { grpclog.Errorf("Failed to start streaming: %v", err) return nil, metadata, err } dec := marshaler.NewDecoder(req.Body) handleSend := func() error { var protoReq OpaqueStreamCustomerActivityRequest err := dec.Decode(&protoReq) if errors.Is(err, io.EOF) { return err } if err != nil { grpclog.Errorf("Failed to decode request: %v", err) return status.Errorf(codes.InvalidArgument, "Failed to decode request: %v", err) } if err := stream.Send(&protoReq); err != nil { grpclog.Errorf("Failed to send request: %v", err) return err } return nil } go func() { for { if err := handleSend(); err != nil { break } } if err := stream.CloseSend(); err != nil { grpclog.Errorf("Failed to terminate client stream: %v", err) } }() header, err := stream.Header() if err != nil { grpclog.Errorf("Failed to get header from client: %v", err) return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } var filter_OpaqueEcommerceService_OpaqueUpdateProduct_0 = &utilities.DoubleArray{Encoding: map[string]int{"product": 0, "product_id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} func request_OpaqueEcommerceService_OpaqueUpdateProduct_0(ctx context.Context, marshaler runtime.Marshaler, client OpaqueEcommerceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq OpaqueUpdateProductRequest metadata runtime.ServerMetadata err error ) newReader, berr := utilities.IOReaderFactory(req.Body) if berr != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) } bodyData := &OpaqueProduct{} if err := marshaler.NewDecoder(newReader()).Decode(bodyData); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } protoReq.SetProduct(bodyData) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if !protoReq.HasUpdateMask() || len(protoReq.GetUpdateMask().GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.GetProduct()); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } else { protoReq.SetUpdateMask(fieldMask) } } val, ok := pathParams["product.product_id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "product.product_id") } err = runtime.PopulateFieldFromPath(&protoReq, "product.product_id", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "product.product_id", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_OpaqueEcommerceService_OpaqueUpdateProduct_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.OpaqueUpdateProduct(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_OpaqueEcommerceService_OpaqueUpdateProduct_0(ctx context.Context, marshaler runtime.Marshaler, server OpaqueEcommerceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq OpaqueUpdateProductRequest metadata runtime.ServerMetadata err error ) newReader, berr := utilities.IOReaderFactory(req.Body) if berr != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) } bodyData := &OpaqueProduct{} if err := marshaler.NewDecoder(newReader()).Decode(bodyData); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } protoReq.SetProduct(bodyData) if !protoReq.HasUpdateMask() || len(protoReq.GetUpdateMask().GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.GetProduct()); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } else { protoReq.SetUpdateMask(fieldMask) } } val, ok := pathParams["product.product_id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "product.product_id") } err = runtime.PopulateFieldFromPath(&protoReq, "product.product_id", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "product.product_id", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_OpaqueEcommerceService_OpaqueUpdateProduct_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.OpaqueUpdateProduct(ctx, &protoReq) return msg, metadata, err } var filter_OpaqueEcommerceService_OpaqueSearchOrders_0 = &utilities.DoubleArray{Encoding: map[string]int{"order": 0, "status": 1, "shipping_address": 2, "address_type": 3}, Base: []int{1, 1, 1, 1, 2, 0, 0}, Check: []int{0, 1, 2, 2, 4, 3, 5}} func request_OpaqueEcommerceService_OpaqueSearchOrders_0(ctx context.Context, marshaler runtime.Marshaler, client OpaqueEcommerceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq OpaqueSearchOrdersRequest metadata runtime.ServerMetadata e int32 err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["order.status"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "order.status") } err = runtime.PopulateFieldFromPath(&protoReq, "order.status", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "order.status", err) } e, err = runtime.Enum(val, OpaqueOrder_OpaqueOrderStatus_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "could not parse path as enum value, parameter: %s, error: %v", "order.status", err) } protoReq.GetOrder().SetStatus(OpaqueOrder_OpaqueOrderStatus(e)) val, ok = pathParams["order.shipping_address.address_type"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "order.shipping_address.address_type") } err = runtime.PopulateFieldFromPath(&protoReq, "order.shipping_address.address_type", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "order.shipping_address.address_type", err) } e, err = runtime.Enum(val, OpaqueAddress_OpaqueAddressType_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "could not parse path as enum value, parameter: %s, error: %v", "order.shipping_address.address_type", err) } protoReq.GetOrder().GetShippingAddress().SetAddressType(OpaqueAddress_OpaqueAddressType(e)) if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_OpaqueEcommerceService_OpaqueSearchOrders_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.OpaqueSearchOrders(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_OpaqueEcommerceService_OpaqueSearchOrders_0(ctx context.Context, marshaler runtime.Marshaler, server OpaqueEcommerceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq OpaqueSearchOrdersRequest metadata runtime.ServerMetadata e int32 err error ) val, ok := pathParams["order.status"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "order.status") } err = runtime.PopulateFieldFromPath(&protoReq, "order.status", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "order.status", err) } e, err = runtime.Enum(val, OpaqueOrder_OpaqueOrderStatus_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "could not parse path as enum value, parameter: %s, error: %v", "order.status", err) } protoReq.GetOrder().SetStatus(OpaqueOrder_OpaqueOrderStatus(e)) val, ok = pathParams["order.shipping_address.address_type"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "order.shipping_address.address_type") } err = runtime.PopulateFieldFromPath(&protoReq, "order.shipping_address.address_type", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "order.shipping_address.address_type", err) } e, err = runtime.Enum(val, OpaqueAddress_OpaqueAddressType_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "could not parse path as enum value, parameter: %s, error: %v", "order.shipping_address.address_type", err) } protoReq.GetOrder().GetShippingAddress().SetAddressType(OpaqueAddress_OpaqueAddressType(e)) if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_OpaqueEcommerceService_OpaqueSearchOrders_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.OpaqueSearchOrders(ctx, &protoReq) return msg, metadata, err } func request_OpaqueEcommerceService_OpaqueEchoNote_0(ctx context.Context, marshaler runtime.Marshaler, client OpaqueEcommerceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq OpaqueEchoNoteRequest metadata runtime.ServerMetadata ) bodyData := &sub.StringMessage{} if err := marshaler.NewDecoder(req.Body).Decode(bodyData); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } protoReq.SetNote(bodyData) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.OpaqueEchoNote(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_OpaqueEcommerceService_OpaqueEchoNote_0(ctx context.Context, marshaler runtime.Marshaler, server OpaqueEcommerceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq OpaqueEchoNoteRequest metadata runtime.ServerMetadata ) bodyData := &sub.StringMessage{} if err := marshaler.NewDecoder(req.Body).Decode(bodyData); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } protoReq.SetNote(bodyData) msg, err := server.OpaqueEchoNote(ctx, &protoReq) return msg, metadata, err } // RegisterOpaqueEcommerceServiceHandlerServer registers the http handlers for service OpaqueEcommerceService to "mux". // UnaryRPC :call OpaqueEcommerceServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterOpaqueEcommerceServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterOpaqueEcommerceServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server OpaqueEcommerceServiceServer) error { mux.Handle(http.MethodGet, pattern_OpaqueEcommerceService_OpaqueGetProduct_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueGetProduct", runtime.WithHTTPPathPattern("/v1/products/{product_id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_OpaqueEcommerceService_OpaqueGetProduct_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_OpaqueEcommerceService_OpaqueGetProduct_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_OpaqueEcommerceService_OpaqueSearchProducts_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodPost, pattern_OpaqueEcommerceService_OpaqueCreateProduct_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueCreateProduct", runtime.WithHTTPPathPattern("/v1/products")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_OpaqueEcommerceService_OpaqueCreateProduct_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_OpaqueEcommerceService_OpaqueCreateProduct_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_OpaqueEcommerceService_OpaqueCreateProductField_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueCreateProductField", runtime.WithHTTPPathPattern("/v1/productsField")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_OpaqueEcommerceService_OpaqueCreateProductField_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_OpaqueEcommerceService_OpaqueCreateProductField_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_OpaqueEcommerceService_OpaqueProcessOrders_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodPost, pattern_OpaqueEcommerceService_OpaqueStreamCustomerActivity_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodPatch, pattern_OpaqueEcommerceService_OpaqueUpdateProduct_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueUpdateProduct", runtime.WithHTTPPathPattern("/v1/products/{product.product_id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_OpaqueEcommerceService_OpaqueUpdateProduct_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_OpaqueEcommerceService_OpaqueUpdateProduct_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_OpaqueEcommerceService_OpaqueSearchOrders_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueSearchOrders", runtime.WithHTTPPathPattern("/v1/orders/search/{order.status}/shipAddressType/{order.shipping_address.address_type}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_OpaqueEcommerceService_OpaqueSearchOrders_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_OpaqueEcommerceService_OpaqueSearchOrders_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_OpaqueEcommerceService_OpaqueEchoNote_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueEchoNote", runtime.WithHTTPPathPattern("/v1/notes:echo")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_OpaqueEcommerceService_OpaqueEchoNote_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_OpaqueEcommerceService_OpaqueEchoNote_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } // RegisterOpaqueEcommerceServiceHandlerFromEndpoint is same as RegisterOpaqueEcommerceServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterOpaqueEcommerceServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterOpaqueEcommerceServiceHandler(ctx, mux, conn) } // RegisterOpaqueEcommerceServiceHandler registers the http handlers for service OpaqueEcommerceService to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterOpaqueEcommerceServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterOpaqueEcommerceServiceHandlerClient(ctx, mux, NewOpaqueEcommerceServiceClient(conn)) } // RegisterOpaqueEcommerceServiceHandlerClient registers the http handlers for service OpaqueEcommerceService // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "OpaqueEcommerceServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "OpaqueEcommerceServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "OpaqueEcommerceServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterOpaqueEcommerceServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client OpaqueEcommerceServiceClient) error { mux.Handle(http.MethodGet, pattern_OpaqueEcommerceService_OpaqueGetProduct_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueGetProduct", runtime.WithHTTPPathPattern("/v1/products/{product_id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_OpaqueEcommerceService_OpaqueGetProduct_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_OpaqueEcommerceService_OpaqueGetProduct_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_OpaqueEcommerceService_OpaqueSearchProducts_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueSearchProducts", runtime.WithHTTPPathPattern("/v1/products/search")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_OpaqueEcommerceService_OpaqueSearchProducts_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_OpaqueEcommerceService_OpaqueSearchProducts_0(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_OpaqueEcommerceService_OpaqueCreateProduct_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueCreateProduct", runtime.WithHTTPPathPattern("/v1/products")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_OpaqueEcommerceService_OpaqueCreateProduct_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_OpaqueEcommerceService_OpaqueCreateProduct_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_OpaqueEcommerceService_OpaqueCreateProductField_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueCreateProductField", runtime.WithHTTPPathPattern("/v1/productsField")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_OpaqueEcommerceService_OpaqueCreateProductField_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_OpaqueEcommerceService_OpaqueCreateProductField_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_OpaqueEcommerceService_OpaqueProcessOrders_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueProcessOrders", runtime.WithHTTPPathPattern("/v1/orders/process")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_OpaqueEcommerceService_OpaqueProcessOrders_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_OpaqueEcommerceService_OpaqueProcessOrders_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_OpaqueEcommerceService_OpaqueStreamCustomerActivity_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueStreamCustomerActivity", runtime.WithHTTPPathPattern("/v1/customer/activity")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_OpaqueEcommerceService_OpaqueStreamCustomerActivity_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_OpaqueEcommerceService_OpaqueStreamCustomerActivity_0(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPatch, pattern_OpaqueEcommerceService_OpaqueUpdateProduct_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueUpdateProduct", runtime.WithHTTPPathPattern("/v1/products/{product.product_id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_OpaqueEcommerceService_OpaqueUpdateProduct_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_OpaqueEcommerceService_OpaqueUpdateProduct_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_OpaqueEcommerceService_OpaqueSearchOrders_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueSearchOrders", runtime.WithHTTPPathPattern("/v1/orders/search/{order.status}/shipAddressType/{order.shipping_address.address_type}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_OpaqueEcommerceService_OpaqueSearchOrders_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_OpaqueEcommerceService_OpaqueSearchOrders_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_OpaqueEcommerceService_OpaqueEchoNote_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueEchoNote", runtime.WithHTTPPathPattern("/v1/notes:echo")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_OpaqueEcommerceService_OpaqueEchoNote_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_OpaqueEcommerceService_OpaqueEchoNote_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_OpaqueEcommerceService_OpaqueGetProduct_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "products", "product_id"}, "")) pattern_OpaqueEcommerceService_OpaqueSearchProducts_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "products", "search"}, "")) pattern_OpaqueEcommerceService_OpaqueCreateProduct_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "products"}, "")) pattern_OpaqueEcommerceService_OpaqueCreateProductField_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "productsField"}, "")) pattern_OpaqueEcommerceService_OpaqueProcessOrders_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "orders", "process"}, "")) pattern_OpaqueEcommerceService_OpaqueStreamCustomerActivity_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "customer", "activity"}, "")) pattern_OpaqueEcommerceService_OpaqueUpdateProduct_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "products", "product.product_id"}, "")) pattern_OpaqueEcommerceService_OpaqueSearchOrders_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"v1", "orders", "search", "order.status", "shipAddressType", "order.shipping_address.address_type"}, "")) pattern_OpaqueEcommerceService_OpaqueEchoNote_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "notes"}, "echo")) ) var ( forward_OpaqueEcommerceService_OpaqueGetProduct_0 = runtime.ForwardResponseMessage forward_OpaqueEcommerceService_OpaqueSearchProducts_0 = runtime.ForwardResponseStream forward_OpaqueEcommerceService_OpaqueCreateProduct_0 = runtime.ForwardResponseMessage forward_OpaqueEcommerceService_OpaqueCreateProductField_0 = runtime.ForwardResponseMessage forward_OpaqueEcommerceService_OpaqueProcessOrders_0 = runtime.ForwardResponseMessage forward_OpaqueEcommerceService_OpaqueStreamCustomerActivity_0 = runtime.ForwardResponseStream forward_OpaqueEcommerceService_OpaqueUpdateProduct_0 = runtime.ForwardResponseMessage forward_OpaqueEcommerceService_OpaqueSearchOrders_0 = runtime.ForwardResponseMessage forward_OpaqueEcommerceService_OpaqueEchoNote_0 = runtime.ForwardResponseMessage ) ================================================ FILE: examples/internal/proto/examplepb/opaque.proto ================================================ edition = "2023"; package grpc.gateway.examples.internal.proto.examplepb; import "examples/internal/proto/sub/message.proto"; import "google/api/annotations.proto"; import "google/api/client.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/field_mask.proto"; import "google/protobuf/timestamp.proto"; import "google/protobuf/wrappers.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; // OpaqueEcommerceService provides a comprehensive e-commerce API with various request/response patterns service OpaqueEcommerceService { // OpaqueGetProduct - Unary request, unary response // Retrieves detailed information about a specific product rpc OpaqueGetProduct(OpaqueGetProductRequest) returns (OpaqueGetProductResponse) { option (google.api.http) = {get: "/v1/products/{product_id}"}; } // OpaqueSearchProducts - Unary request, stream response // Searches for products based on criteria and streams results back rpc OpaqueSearchProducts(OpaqueSearchProductsRequest) returns (stream OpaqueSearchProductsResponse) { option (google.api.http) = {get: "/v1/products/search"}; } // OpaqueCreateProduct - Unary request with body field, unary response // Creates a new product with the product details in the body rpc OpaqueCreateProduct(OpaqueCreateProductRequest) returns (OpaqueCreateProductResponse) { option (google.api.http) = { post: "/v1/products" body: "*" }; } // OpaqueCreateProductField - same as above, but with body field mapping. rpc OpaqueCreateProductField(OpaqueCreateProductFieldRequest) returns (OpaqueCreateProductFieldResponse) { option (google.api.http) = { post: "/v1/productsField" body: "product" }; } // OpaqueProcessOrders - Stream request, unary response // Processes multiple orders in a batch and returns a summary rpc OpaqueProcessOrders(stream OpaqueProcessOrdersRequest) returns (OpaqueProcessOrdersResponse) { option (google.api.http) = { post: "/v1/orders/process" body: "*" }; } // OpaqueStreamCustomerActivity - Stream request, stream response // Bidirectional streaming for real-time customer activity monitoring rpc OpaqueStreamCustomerActivity(stream OpaqueStreamCustomerActivityRequest) returns (stream OpaqueStreamCustomerActivityResponse) { option (google.api.http) = { post: "/v1/customer/activity" body: "*" }; } // OpaqueUpdateProduct - PATCH request with FieldMask and body field mapping // to reproduce the compilation issue with bodyData as a value type. rpc OpaqueUpdateProduct(OpaqueUpdateProductRequest) returns (OpaqueUpdateProductResponse) { option (google.api.http) = { patch: "/v1/products/{product.product_id}" body: "product" }; option (google.api.method_signature) = "product,update_mask"; } // OpaqueSearchOrders - Unary request, unary response // Uses enum params (both top level and nested) to populate fields to test opaque get chain rpc OpaqueSearchOrders(OpaqueSearchOrdersRequest) returns (OpaqueSearchOrdersResponse) { option (google.api.http) = {get: "/v1/orders/search/{order.status}/shipAddressType/{order.shipping_address.address_type}"}; } // OpaqueEchoNote - Unary request with nested body field from another package. // Exercises the opaque body import path by referencing grpc.gateway.examples.internal.proto.sub.StringMessage. rpc OpaqueEchoNote(OpaqueEchoNoteRequest) returns (OpaqueEchoNoteResponse) { option (google.api.http) = { post: "/v1/notes:echo" body: "note" }; } } // OpaqueUpdateProductRequest represents a request to update a product message OpaqueUpdateProductRequest { OpaqueProduct product = 1; google.protobuf.FieldMask update_mask = 2; } // OpaqueUpdateProductResponse represents the response for OpaqueUpdateProduct message OpaqueUpdateProductResponse { OpaqueProduct product = 1; } // OpaqueGetProductRequest represents a request for product information message OpaqueGetProductRequest { string product_id = 1; bool include_variants = 2; bool include_related_products = 3; string language_code = 4; string currency_code = 5; } // OpaqueGetProductResponse represents a response with product information message OpaqueGetProductResponse { OpaqueProduct product = 1; } // OpaqueSearchProductsRequest represents a product search request message OpaqueSearchProductsRequest { string query = 1; repeated string category_ids = 2; repeated string brands = 3; OpaquePrice min_price = 4; OpaquePrice max_price = 5; repeated string tags = 6; enum OpaqueSortOrder { OPAQUE_SORT_ORDER_UNSPECIFIED = 0; OPAQUE_SORT_ORDER_RELEVANCE = 1; OPAQUE_SORT_ORDER_PRICE_LOW_TO_HIGH = 2; OPAQUE_SORT_ORDER_PRICE_HIGH_TO_LOW = 3; OPAQUE_SORT_ORDER_NEWEST_FIRST = 4; OPAQUE_SORT_ORDER_RATING = 5; OPAQUE_SORT_ORDER_POPULARITY = 6; } OpaqueSortOrder sort_by = 7; int32 page = 8; int32 page_size = 9; string language_code = 10; string currency_code = 11; google.protobuf.FieldMask field_mask = 12; map filters = 13; } // OpaqueSearchProductsResponse represents a single product in search results message OpaqueSearchProductsResponse { OpaqueProduct product = 1; } // OpaqueCreateProductRequest represents a request to create a product message OpaqueCreateProductRequest { string product_id = 1; OpaqueProduct product = 2; } // OpaqueCreateProductResponse represents the created product message OpaqueCreateProductResponse { OpaqueProduct product = 1; } // OpaqueCreateProductFieldRequest represents a request to create a product message OpaqueCreateProductFieldRequest { string product_id = 1; OpaqueProduct product = 2; } // OpaqueCreateProductFieldResponse represents the created product message OpaqueCreateProductFieldResponse { OpaqueProduct product = 1; } // OpaqueProcessOrdersRequest represents a request to process order message OpaqueProcessOrdersRequest { OpaqueOrder order = 1; } // OpaqueProcessOrdersResponse represents orders processing result message OpaqueProcessOrdersResponse { OpaqueOrderSummary summary = 1; } // OpaqueStreamCustomerActivityRequest represents a report of user activity message OpaqueStreamCustomerActivityRequest { OpaqueCustomerEvent event = 1; } // OpaqueStreamCustomerActivityRequest represents a report of server activity message OpaqueStreamCustomerActivityResponse { OpaqueActivityUpdate event = 2; } // OpaqueSearchOrdersRequest represents queryable information to find orders message OpaqueSearchOrdersRequest { OpaqueOrder order = 1; } // OpaqueSearchOrdersResponse represents a list of orders found message OpaqueSearchOrdersResponse { repeated OpaqueOrder orders = 1; } // OpaqueEchoNoteRequest demonstrates an opaque body that maps to a foreign message. message OpaqueEchoNoteRequest { grpc.gateway.examples.internal.proto.sub.StringMessage note = 1; } // OpaqueEchoNoteResponse mirrors the request payload for simplicity. message OpaqueEchoNoteResponse { grpc.gateway.examples.internal.proto.sub.StringMessage note = 1; } // OpaqueAddress represents a physical address message OpaqueAddress { string street_line1 = 1; string street_line2 = 2; string city = 3; string state = 4; string country = 5; string postal_code = 6; enum OpaqueAddressType { OPAQUE_ADDRESS_TYPE_UNSPECIFIED = 0; OPAQUE_ADDRESS_TYPE_RESIDENTIAL = 1; OPAQUE_ADDRESS_TYPE_BUSINESS = 2; OPAQUE_ADDRESS_TYPE_SHIPPING = 3; OPAQUE_ADDRESS_TYPE_BILLING = 4; } OpaqueAddressType address_type = 7; google.protobuf.BoolValue is_default = 8; map metadata = 9; } // OpaquePrice represents a monetary value with currency message OpaquePrice { double amount = 1; string currency_code = 2; bool is_discounted = 3; google.protobuf.DoubleValue original_amount = 4; google.protobuf.Timestamp price_valid_until = 5; } // OpaqueProductCategory represents a product category message OpaqueProductCategory { string category_id = 1; string name = 2; string description = 3; OpaqueProductCategory parent_category = 4; repeated string tags = 5; google.protobuf.Timestamp created_at = 6; google.protobuf.Timestamp updated_at = 7; } // OpaqueProductVariant represents a specific variant of a product message OpaqueProductVariant { string variant_id = 1; string sku = 2; string name = 3; OpaquePrice price = 4; int32 inventory_count = 5; map attributes = 6; bytes image_data = 7; repeated string image_urls = 8; google.protobuf.BoolValue is_available = 9; oneof discount_info { double percentage_off = 10; double fixed_amount_off = 11; } } // OpaqueProduct represents a product in the e-commerce system message OpaqueProduct { string product_id = 1; string name = 2; string description = 3; string brand = 4; OpaquePrice base_price = 5; OpaqueProductCategory category = 6; repeated OpaqueProductVariant variants = 7; repeated string tags = 8; double average_rating = 9; int32 review_count = 10; google.protobuf.BoolValue is_featured = 11; google.protobuf.Timestamp created_at = 12; google.protobuf.Timestamp updated_at = 13; google.protobuf.Duration average_shipping_time = 14; enum OpaqueProductStatus { OPAQUE_PRODUCT_STATUS_UNSPECIFIED = 0; OPAQUE_PRODUCT_STATUS_DRAFT = 1; OPAQUE_PRODUCT_STATUS_ACTIVE = 2; OPAQUE_PRODUCT_STATUS_OUT_OF_STOCK = 3; OPAQUE_PRODUCT_STATUS_DISCONTINUED = 4; } OpaqueProductStatus status = 15; map metadata = 16; map regional_prices = 17; message OpaqueProductDimensions { double length = 1; double width = 2; double height = 3; double weight = 4; enum OpaqueUnit { OPAQUE_UNIT_UNSPECIFIED = 0; OPAQUE_UNIT_METRIC = 1; OPAQUE_UNIT_IMPERIAL = 2; } OpaqueUnit unit = 5; } OpaqueProductDimensions dimensions = 18; oneof tax_info { double tax_percentage = 19; bool tax_exempt = 20; } } // OpaqueCustomer represents a customer in the e-commerce system message OpaqueCustomer { string customer_id = 1; string email = 2; string first_name = 3; string last_name = 4; string phone_number = 5; repeated OpaqueAddress addresses = 6; google.protobuf.Timestamp created_at = 7; google.protobuf.Timestamp last_login = 8; enum OpaqueCustomerStatus { OPAQUE_CUSTOMER_STATUS_UNSPECIFIED = 0; OPAQUE_CUSTOMER_STATUS_ACTIVE = 1; OPAQUE_CUSTOMER_STATUS_INACTIVE = 2; OPAQUE_CUSTOMER_STATUS_SUSPENDED = 3; OPAQUE_CUSTOMER_STATUS_DELETED = 4; } OpaqueCustomerStatus status = 9; message OpaqueLoyaltyInfo { string tier = 1; int32 points = 2; google.protobuf.Timestamp tier_expiry = 3; repeated string rewards = 4; } OpaqueLoyaltyInfo loyalty_info = 10; map preferences = 11; message OpaquePaymentMethod { string payment_id = 1; string type = 2; string last_four = 3; string provider = 4; google.protobuf.Timestamp expires_at = 5; bool is_default = 6; } repeated OpaquePaymentMethod payment_methods = 12; } // OpaqueOrderItem represents an item in an order message OpaqueOrderItem { string product_id = 1; string variant_id = 2; string product_name = 3; int32 quantity = 4; OpaquePrice unit_price = 5; OpaquePrice total_price = 6; map selected_attributes = 7; google.protobuf.BoolValue gift_wrapped = 8; string gift_message = 9; } // OpaqueOrder represents a customer order message OpaqueOrder { string order_id = 1; string customer_id = 2; repeated OpaqueOrderItem items = 3; OpaquePrice subtotal = 4; OpaquePrice tax = 5; OpaquePrice shipping = 6; OpaquePrice total = 7; OpaqueAddress shipping_address = 8; OpaqueAddress billing_address = 9; enum OpaqueOrderStatus { OPAQUE_ORDER_STATUS_UNSPECIFIED = 0; OPAQUE_ORDER_STATUS_PENDING = 1; OPAQUE_ORDER_STATUS_PROCESSING = 2; OPAQUE_ORDER_STATUS_SHIPPED = 3; OPAQUE_ORDER_STATUS_DELIVERED = 4; OPAQUE_ORDER_STATUS_CANCELLED = 5; OPAQUE_ORDER_STATUS_RETURNED = 6; } OpaqueOrderStatus status = 10; string payment_method_id = 11; string tracking_number = 12; google.protobuf.Timestamp created_at = 13; google.protobuf.Timestamp updated_at = 14; google.protobuf.Timestamp shipped_at = 15; google.protobuf.Timestamp delivered_at = 16; message OpaqueShippingInfo { string carrier = 1; string method = 2; google.protobuf.Duration estimated_delivery_time = 3; repeated string tracking_urls = 4; } OpaqueShippingInfo shipping_info = 17; map metadata = 18; oneof discount_applied { string coupon_code = 19; string promotion_id = 20; } } // OpaqueOrderSummary represents a summary of processed orders message OpaqueOrderSummary { int32 total_orders_processed = 1; int32 successful_orders = 2; int32 failed_orders = 3; OpaquePrice total_value = 4; repeated string order_ids = 5; map error_details = 6; google.protobuf.Timestamp processing_time = 7; message OpaqueOrderError { string order_id = 1; string error_code = 2; string error_message = 3; } repeated OpaqueOrderError errors = 8; } // OpaqueCustomerEvent represents a customer activity event message OpaqueCustomerEvent { string customer_id = 1; string session_id = 2; enum OpaqueEventType { OPAQUE_EVENT_TYPE_UNSPECIFIED = 0; OPAQUE_EVENT_TYPE_PAGE_VIEW = 1; OPAQUE_EVENT_TYPE_PRODUCT_VIEW = 2; OPAQUE_EVENT_TYPE_ADD_TO_CART = 3; OPAQUE_EVENT_TYPE_REMOVE_FROM_CART = 4; OPAQUE_EVENT_TYPE_CHECKOUT_START = 5; OPAQUE_EVENT_TYPE_CHECKOUT_COMPLETE = 6; OPAQUE_EVENT_TYPE_SEARCH = 7; OPAQUE_EVENT_TYPE_ACCOUNT_UPDATE = 8; } OpaqueEventType event_type = 3; google.protobuf.Timestamp timestamp = 4; string product_id = 5; string category_id = 6; string search_query = 7; string page_url = 8; int32 value = 9; map event_data = 10; string device_type = 11; string ip_address = 12; string user_agent = 13; } // OpaqueActivityUpdate represents a server response to customer activity message OpaqueActivityUpdate { string customer_id = 1; string session_id = 2; enum OpaqueUpdateType { OPAQUE_UPDATE_TYPE_UNSPECIFIED = 0; OPAQUE_UPDATE_TYPE_RECOMMENDATION = 1; OPAQUE_UPDATE_TYPE_NOTIFICATION = 2; OPAQUE_UPDATE_TYPE_OFFER = 3; OPAQUE_UPDATE_TYPE_INVENTORY_UPDATE = 4; OPAQUE_UPDATE_TYPE_PRICE_CHANGE = 5; OPAQUE_UPDATE_TYPE_CART_REMINDER = 6; } OpaqueUpdateType update_type = 3; google.protobuf.Timestamp timestamp = 4; string message = 5; repeated string product_ids = 6; OpaquePrice price_update = 7; int32 inventory_count = 8; string offer_code = 9; google.protobuf.Duration offer_expiry = 10; double discount_percentage = 11; map update_data = 12; int32 priority = 13; oneof action_data { string redirect_url = 14; string notification_id = 15; } } ================================================ FILE: examples/internal/proto/examplepb/opaque.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/examplepb/opaque.proto", "version": "version not set" }, "tags": [ { "name": "OpaqueEcommerceService" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/v1/customer/activity": { "post": { "summary": "OpaqueStreamCustomerActivity - Stream request, stream response\nBidirectional streaming for real-time customer activity monitoring", "operationId": "OpaqueEcommerceService_OpaqueStreamCustomerActivity", "responses": { "200": { "description": "A successful response.(streaming responses)", "schema": { "type": "object", "properties": { "result": { "$ref": "#/definitions/examplepbOpaqueStreamCustomerActivityResponse" }, "error": { "$ref": "#/definitions/googleRpcStatus" } }, "title": "Stream result of examplepbOpaqueStreamCustomerActivityResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "description": " (streaming inputs)", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbOpaqueStreamCustomerActivityRequest" } } ], "tags": [ "OpaqueEcommerceService" ] } }, "/v1/notes:echo": { "post": { "summary": "OpaqueEchoNote - Unary request with nested body field from another package.\nExercises the opaque body import path by referencing grpc.gateway.examples.internal.proto.sub.StringMessage.", "operationId": "OpaqueEcommerceService_OpaqueEchoNote", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbOpaqueEchoNoteResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "note", "in": "body", "required": true, "schema": { "$ref": "#/definitions/subStringMessage" } } ], "tags": [ "OpaqueEcommerceService" ] } }, "/v1/orders/process": { "post": { "summary": "OpaqueProcessOrders - Stream request, unary response\nProcesses multiple orders in a batch and returns a summary", "operationId": "OpaqueEcommerceService_OpaqueProcessOrders", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbOpaqueProcessOrdersResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "description": " (streaming inputs)", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbOpaqueProcessOrdersRequest" } } ], "tags": [ "OpaqueEcommerceService" ] } }, "/v1/orders/search/{order.status}/shipAddressType/{order.shippingAddress.addressType}": { "get": { "summary": "OpaqueSearchOrders - Unary request, unary response\nUses enum params (both top level and nested) to populate fields to test opaque get chain", "operationId": "OpaqueEcommerceService_OpaqueSearchOrders", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbOpaqueSearchOrdersResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "order.status", "in": "path", "required": true, "type": "string", "enum": [ "OPAQUE_ORDER_STATUS_UNSPECIFIED", "OPAQUE_ORDER_STATUS_PENDING", "OPAQUE_ORDER_STATUS_PROCESSING", "OPAQUE_ORDER_STATUS_SHIPPED", "OPAQUE_ORDER_STATUS_DELIVERED", "OPAQUE_ORDER_STATUS_CANCELLED", "OPAQUE_ORDER_STATUS_RETURNED" ] }, { "name": "order.shippingAddress.addressType", "in": "path", "required": true, "type": "string", "enum": [ "OPAQUE_ADDRESS_TYPE_UNSPECIFIED", "OPAQUE_ADDRESS_TYPE_RESIDENTIAL", "OPAQUE_ADDRESS_TYPE_BUSINESS", "OPAQUE_ADDRESS_TYPE_SHIPPING", "OPAQUE_ADDRESS_TYPE_BILLING" ] }, { "name": "order.orderId", "in": "query", "required": false, "type": "string" }, { "name": "order.customerId", "in": "query", "required": false, "type": "string" }, { "name": "order.subtotal.amount", "in": "query", "required": false, "type": "number", "format": "double" }, { "name": "order.subtotal.currencyCode", "in": "query", "required": false, "type": "string" }, { "name": "order.subtotal.isDiscounted", "in": "query", "required": false, "type": "boolean" }, { "name": "order.subtotal.originalAmount", "in": "query", "required": false, "type": "number", "format": "double" }, { "name": "order.subtotal.priceValidUntil", "in": "query", "required": false, "type": "string", "format": "date-time" }, { "name": "order.tax.amount", "in": "query", "required": false, "type": "number", "format": "double" }, { "name": "order.tax.currencyCode", "in": "query", "required": false, "type": "string" }, { "name": "order.tax.isDiscounted", "in": "query", "required": false, "type": "boolean" }, { "name": "order.tax.originalAmount", "in": "query", "required": false, "type": "number", "format": "double" }, { "name": "order.tax.priceValidUntil", "in": "query", "required": false, "type": "string", "format": "date-time" }, { "name": "order.shipping.amount", "in": "query", "required": false, "type": "number", "format": "double" }, { "name": "order.shipping.currencyCode", "in": "query", "required": false, "type": "string" }, { "name": "order.shipping.isDiscounted", "in": "query", "required": false, "type": "boolean" }, { "name": "order.shipping.originalAmount", "in": "query", "required": false, "type": "number", "format": "double" }, { "name": "order.shipping.priceValidUntil", "in": "query", "required": false, "type": "string", "format": "date-time" }, { "name": "order.total.amount", "in": "query", "required": false, "type": "number", "format": "double" }, { "name": "order.total.currencyCode", "in": "query", "required": false, "type": "string" }, { "name": "order.total.isDiscounted", "in": "query", "required": false, "type": "boolean" }, { "name": "order.total.originalAmount", "in": "query", "required": false, "type": "number", "format": "double" }, { "name": "order.total.priceValidUntil", "in": "query", "required": false, "type": "string", "format": "date-time" }, { "name": "order.shippingAddress.streetLine1", "in": "query", "required": false, "type": "string" }, { "name": "order.shippingAddress.streetLine2", "in": "query", "required": false, "type": "string" }, { "name": "order.shippingAddress.city", "in": "query", "required": false, "type": "string" }, { "name": "order.shippingAddress.state", "in": "query", "required": false, "type": "string" }, { "name": "order.shippingAddress.country", "in": "query", "required": false, "type": "string" }, { "name": "order.shippingAddress.postalCode", "in": "query", "required": false, "type": "string" }, { "name": "order.shippingAddress.isDefault", "in": "query", "required": false, "type": "boolean" }, { "name": "order.shippingAddress.metadata", "in": "query", "required": false, "type": "string" }, { "name": "order.billingAddress.streetLine1", "in": "query", "required": false, "type": "string" }, { "name": "order.billingAddress.streetLine2", "in": "query", "required": false, "type": "string" }, { "name": "order.billingAddress.city", "in": "query", "required": false, "type": "string" }, { "name": "order.billingAddress.state", "in": "query", "required": false, "type": "string" }, { "name": "order.billingAddress.country", "in": "query", "required": false, "type": "string" }, { "name": "order.billingAddress.postalCode", "in": "query", "required": false, "type": "string" }, { "name": "order.billingAddress.isDefault", "in": "query", "required": false, "type": "boolean" }, { "name": "order.billingAddress.metadata", "in": "query", "required": false, "type": "string" }, { "name": "order.paymentMethodId", "in": "query", "required": false, "type": "string" }, { "name": "order.trackingNumber", "in": "query", "required": false, "type": "string" }, { "name": "order.createdAt", "in": "query", "required": false, "type": "string", "format": "date-time" }, { "name": "order.updatedAt", "in": "query", "required": false, "type": "string", "format": "date-time" }, { "name": "order.shippedAt", "in": "query", "required": false, "type": "string", "format": "date-time" }, { "name": "order.deliveredAt", "in": "query", "required": false, "type": "string", "format": "date-time" }, { "name": "order.shippingInfo.carrier", "in": "query", "required": false, "type": "string" }, { "name": "order.shippingInfo.method", "in": "query", "required": false, "type": "string" }, { "name": "order.shippingInfo.estimatedDeliveryTime", "in": "query", "required": false, "type": "string" }, { "name": "order.shippingInfo.trackingUrls", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "order.metadata", "in": "query", "required": false, "type": "string" }, { "name": "order.couponCode", "in": "query", "required": false, "type": "string" }, { "name": "order.promotionId", "in": "query", "required": false, "type": "string" } ], "tags": [ "OpaqueEcommerceService" ] } }, "/v1/products": { "post": { "summary": "OpaqueCreateProduct - Unary request with body field, unary response\nCreates a new product with the product details in the body", "operationId": "OpaqueEcommerceService_OpaqueCreateProduct", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbOpaqueCreateProductResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbOpaqueCreateProductRequest" } } ], "tags": [ "OpaqueEcommerceService" ] } }, "/v1/products/search": { "get": { "summary": "OpaqueSearchProducts - Unary request, stream response\nSearches for products based on criteria and streams results back", "operationId": "OpaqueEcommerceService_OpaqueSearchProducts", "responses": { "200": { "description": "A successful response.(streaming responses)", "schema": { "type": "object", "properties": { "result": { "$ref": "#/definitions/examplepbOpaqueSearchProductsResponse" }, "error": { "$ref": "#/definitions/googleRpcStatus" } }, "title": "Stream result of examplepbOpaqueSearchProductsResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "query", "in": "query", "required": false, "type": "string" }, { "name": "categoryIds", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "brands", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "minPrice.amount", "in": "query", "required": false, "type": "number", "format": "double" }, { "name": "minPrice.currencyCode", "in": "query", "required": false, "type": "string" }, { "name": "minPrice.isDiscounted", "in": "query", "required": false, "type": "boolean" }, { "name": "minPrice.originalAmount", "in": "query", "required": false, "type": "number", "format": "double" }, { "name": "minPrice.priceValidUntil", "in": "query", "required": false, "type": "string", "format": "date-time" }, { "name": "maxPrice.amount", "in": "query", "required": false, "type": "number", "format": "double" }, { "name": "maxPrice.currencyCode", "in": "query", "required": false, "type": "string" }, { "name": "maxPrice.isDiscounted", "in": "query", "required": false, "type": "boolean" }, { "name": "maxPrice.originalAmount", "in": "query", "required": false, "type": "number", "format": "double" }, { "name": "maxPrice.priceValidUntil", "in": "query", "required": false, "type": "string", "format": "date-time" }, { "name": "tags", "in": "query", "required": false, "type": "array", "items": { "type": "string" }, "collectionFormat": "multi" }, { "name": "sortBy", "in": "query", "required": false, "type": "string", "enum": [ "OPAQUE_SORT_ORDER_UNSPECIFIED", "OPAQUE_SORT_ORDER_RELEVANCE", "OPAQUE_SORT_ORDER_PRICE_LOW_TO_HIGH", "OPAQUE_SORT_ORDER_PRICE_HIGH_TO_LOW", "OPAQUE_SORT_ORDER_NEWEST_FIRST", "OPAQUE_SORT_ORDER_RATING", "OPAQUE_SORT_ORDER_POPULARITY" ], "default": "OPAQUE_SORT_ORDER_UNSPECIFIED" }, { "name": "page", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "pageSize", "in": "query", "required": false, "type": "integer", "format": "int32" }, { "name": "languageCode", "in": "query", "required": false, "type": "string" }, { "name": "currencyCode", "in": "query", "required": false, "type": "string" }, { "name": "fieldMask", "in": "query", "required": false, "type": "string" }, { "name": "filters", "in": "query", "required": false, "type": "string" } ], "tags": [ "OpaqueEcommerceService" ] } }, "/v1/products/{product.productId}": { "patch": { "summary": "OpaqueUpdateProduct - PATCH request with FieldMask and body field mapping\nto reproduce the compilation issue with bodyData as a value type.", "operationId": "OpaqueEcommerceService_OpaqueUpdateProduct", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbOpaqueUpdateProductResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "product.productId", "in": "path", "required": true, "type": "string" }, { "name": "product", "description": "OpaqueProduct represents a product in the e-commerce system", "in": "body", "required": true, "schema": { "type": "object", "properties": { "name": { "type": "string" }, "description": { "type": "string" }, "brand": { "type": "string" }, "basePrice": { "$ref": "#/definitions/examplepbOpaquePrice" }, "category": { "$ref": "#/definitions/examplepbOpaqueProductCategory" }, "variants": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/examplepbOpaqueProductVariant" } }, "tags": { "type": "array", "items": { "type": "string" } }, "averageRating": { "type": "number", "format": "double" }, "reviewCount": { "type": "integer", "format": "int32" }, "isFeatured": { "type": "boolean" }, "createdAt": { "type": "string", "format": "date-time" }, "updatedAt": { "type": "string", "format": "date-time" }, "averageShippingTime": { "type": "string" }, "status": { "$ref": "#/definitions/OpaqueProductOpaqueProductStatus" }, "metadata": { "type": "object", "additionalProperties": { "type": "string" } }, "regionalPrices": { "type": "object", "additionalProperties": { "$ref": "#/definitions/examplepbOpaquePrice" } }, "dimensions": { "$ref": "#/definitions/OpaqueProductOpaqueProductDimensions" }, "taxPercentage": { "type": "number", "format": "double" }, "taxExempt": { "type": "boolean" } }, "title": "OpaqueProduct represents a product in the e-commerce system" } } ], "tags": [ "OpaqueEcommerceService" ] } }, "/v1/products/{productId}": { "get": { "summary": "OpaqueGetProduct - Unary request, unary response\nRetrieves detailed information about a specific product", "operationId": "OpaqueEcommerceService_OpaqueGetProduct", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbOpaqueGetProductResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "productId", "in": "path", "required": true, "type": "string" }, { "name": "includeVariants", "in": "query", "required": false, "type": "boolean" }, { "name": "includeRelatedProducts", "in": "query", "required": false, "type": "boolean" }, { "name": "languageCode", "in": "query", "required": false, "type": "string" }, { "name": "currencyCode", "in": "query", "required": false, "type": "string" } ], "tags": [ "OpaqueEcommerceService" ] } }, "/v1/productsField": { "post": { "summary": "OpaqueCreateProductField - same as above, but with body field mapping.", "operationId": "OpaqueEcommerceService_OpaqueCreateProductField", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbOpaqueCreateProductFieldResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "product", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbOpaqueProduct" } }, { "name": "productId", "in": "query", "required": false, "type": "string" } ], "tags": [ "OpaqueEcommerceService" ] } } }, "definitions": { "OpaqueActivityUpdateOpaqueUpdateType": { "type": "string", "enum": [ "OPAQUE_UPDATE_TYPE_UNSPECIFIED", "OPAQUE_UPDATE_TYPE_RECOMMENDATION", "OPAQUE_UPDATE_TYPE_NOTIFICATION", "OPAQUE_UPDATE_TYPE_OFFER", "OPAQUE_UPDATE_TYPE_INVENTORY_UPDATE", "OPAQUE_UPDATE_TYPE_PRICE_CHANGE", "OPAQUE_UPDATE_TYPE_CART_REMINDER" ], "default": "OPAQUE_UPDATE_TYPE_UNSPECIFIED" }, "OpaqueAddressOpaqueAddressType": { "type": "string", "enum": [ "OPAQUE_ADDRESS_TYPE_UNSPECIFIED", "OPAQUE_ADDRESS_TYPE_RESIDENTIAL", "OPAQUE_ADDRESS_TYPE_BUSINESS", "OPAQUE_ADDRESS_TYPE_SHIPPING", "OPAQUE_ADDRESS_TYPE_BILLING" ], "default": "OPAQUE_ADDRESS_TYPE_UNSPECIFIED" }, "OpaqueCustomerEventOpaqueEventType": { "type": "string", "enum": [ "OPAQUE_EVENT_TYPE_UNSPECIFIED", "OPAQUE_EVENT_TYPE_PAGE_VIEW", "OPAQUE_EVENT_TYPE_PRODUCT_VIEW", "OPAQUE_EVENT_TYPE_ADD_TO_CART", "OPAQUE_EVENT_TYPE_REMOVE_FROM_CART", "OPAQUE_EVENT_TYPE_CHECKOUT_START", "OPAQUE_EVENT_TYPE_CHECKOUT_COMPLETE", "OPAQUE_EVENT_TYPE_SEARCH", "OPAQUE_EVENT_TYPE_ACCOUNT_UPDATE" ], "default": "OPAQUE_EVENT_TYPE_UNSPECIFIED" }, "OpaqueOrderOpaqueOrderStatus": { "type": "string", "enum": [ "OPAQUE_ORDER_STATUS_UNSPECIFIED", "OPAQUE_ORDER_STATUS_PENDING", "OPAQUE_ORDER_STATUS_PROCESSING", "OPAQUE_ORDER_STATUS_SHIPPED", "OPAQUE_ORDER_STATUS_DELIVERED", "OPAQUE_ORDER_STATUS_CANCELLED", "OPAQUE_ORDER_STATUS_RETURNED" ], "default": "OPAQUE_ORDER_STATUS_UNSPECIFIED" }, "OpaqueOrderOpaqueShippingInfo": { "type": "object", "properties": { "carrier": { "type": "string" }, "method": { "type": "string" }, "estimatedDeliveryTime": { "type": "string" }, "trackingUrls": { "type": "array", "items": { "type": "string" } } } }, "OpaqueOrderSummaryOpaqueOrderError": { "type": "object", "properties": { "orderId": { "type": "string" }, "errorCode": { "type": "string" }, "errorMessage": { "type": "string" } } }, "OpaqueProductDimensionsOpaqueUnit": { "type": "string", "enum": [ "OPAQUE_UNIT_UNSPECIFIED", "OPAQUE_UNIT_METRIC", "OPAQUE_UNIT_IMPERIAL" ], "default": "OPAQUE_UNIT_UNSPECIFIED" }, "OpaqueProductOpaqueProductDimensions": { "type": "object", "properties": { "length": { "type": "number", "format": "double" }, "width": { "type": "number", "format": "double" }, "height": { "type": "number", "format": "double" }, "weight": { "type": "number", "format": "double" }, "unit": { "$ref": "#/definitions/OpaqueProductDimensionsOpaqueUnit" } } }, "OpaqueProductOpaqueProductStatus": { "type": "string", "enum": [ "OPAQUE_PRODUCT_STATUS_UNSPECIFIED", "OPAQUE_PRODUCT_STATUS_DRAFT", "OPAQUE_PRODUCT_STATUS_ACTIVE", "OPAQUE_PRODUCT_STATUS_OUT_OF_STOCK", "OPAQUE_PRODUCT_STATUS_DISCONTINUED" ], "default": "OPAQUE_PRODUCT_STATUS_UNSPECIFIED" }, "OpaqueSearchProductsRequestOpaqueSortOrder": { "type": "string", "enum": [ "OPAQUE_SORT_ORDER_UNSPECIFIED", "OPAQUE_SORT_ORDER_RELEVANCE", "OPAQUE_SORT_ORDER_PRICE_LOW_TO_HIGH", "OPAQUE_SORT_ORDER_PRICE_HIGH_TO_LOW", "OPAQUE_SORT_ORDER_NEWEST_FIRST", "OPAQUE_SORT_ORDER_RATING", "OPAQUE_SORT_ORDER_POPULARITY" ], "default": "OPAQUE_SORT_ORDER_UNSPECIFIED" }, "examplepbOpaqueActivityUpdate": { "type": "object", "properties": { "customerId": { "type": "string" }, "sessionId": { "type": "string" }, "updateType": { "$ref": "#/definitions/OpaqueActivityUpdateOpaqueUpdateType" }, "timestamp": { "type": "string", "format": "date-time" }, "message": { "type": "string" }, "productIds": { "type": "array", "items": { "type": "string" } }, "priceUpdate": { "$ref": "#/definitions/examplepbOpaquePrice" }, "inventoryCount": { "type": "integer", "format": "int32" }, "offerCode": { "type": "string" }, "offerExpiry": { "type": "string" }, "discountPercentage": { "type": "number", "format": "double" }, "updateData": { "type": "object", "additionalProperties": { "type": "string" } }, "priority": { "type": "integer", "format": "int32" }, "redirectUrl": { "type": "string" }, "notificationId": { "type": "string" } }, "title": "OpaqueActivityUpdate represents a server response to customer activity" }, "examplepbOpaqueAddress": { "type": "object", "properties": { "streetLine1": { "type": "string" }, "streetLine2": { "type": "string" }, "city": { "type": "string" }, "state": { "type": "string" }, "country": { "type": "string" }, "postalCode": { "type": "string" }, "addressType": { "$ref": "#/definitions/OpaqueAddressOpaqueAddressType" }, "isDefault": { "type": "boolean" }, "metadata": { "type": "object", "additionalProperties": { "type": "string" } } }, "title": "OpaqueAddress represents a physical address" }, "examplepbOpaqueCreateProductFieldResponse": { "type": "object", "properties": { "product": { "$ref": "#/definitions/examplepbOpaqueProduct" } }, "title": "OpaqueCreateProductFieldResponse represents the created product" }, "examplepbOpaqueCreateProductRequest": { "type": "object", "properties": { "productId": { "type": "string" }, "product": { "$ref": "#/definitions/examplepbOpaqueProduct" } }, "title": "OpaqueCreateProductRequest represents a request to create a product" }, "examplepbOpaqueCreateProductResponse": { "type": "object", "properties": { "product": { "$ref": "#/definitions/examplepbOpaqueProduct" } }, "title": "OpaqueCreateProductResponse represents the created product" }, "examplepbOpaqueCustomerEvent": { "type": "object", "properties": { "customerId": { "type": "string" }, "sessionId": { "type": "string" }, "eventType": { "$ref": "#/definitions/OpaqueCustomerEventOpaqueEventType" }, "timestamp": { "type": "string", "format": "date-time" }, "productId": { "type": "string" }, "categoryId": { "type": "string" }, "searchQuery": { "type": "string" }, "pageUrl": { "type": "string" }, "value": { "type": "integer", "format": "int32" }, "eventData": { "type": "object", "additionalProperties": { "type": "string" } }, "deviceType": { "type": "string" }, "ipAddress": { "type": "string" }, "userAgent": { "type": "string" } }, "title": "OpaqueCustomerEvent represents a customer activity event" }, "examplepbOpaqueEchoNoteResponse": { "type": "object", "properties": { "note": { "$ref": "#/definitions/subStringMessage" } }, "description": "OpaqueEchoNoteResponse mirrors the request payload for simplicity." }, "examplepbOpaqueGetProductResponse": { "type": "object", "properties": { "product": { "$ref": "#/definitions/examplepbOpaqueProduct" } }, "title": "OpaqueGetProductResponse represents a response with product information" }, "examplepbOpaqueOrder": { "type": "object", "properties": { "orderId": { "type": "string" }, "customerId": { "type": "string" }, "items": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/examplepbOpaqueOrderItem" } }, "subtotal": { "$ref": "#/definitions/examplepbOpaquePrice" }, "tax": { "$ref": "#/definitions/examplepbOpaquePrice" }, "shipping": { "$ref": "#/definitions/examplepbOpaquePrice" }, "total": { "$ref": "#/definitions/examplepbOpaquePrice" }, "shippingAddress": { "$ref": "#/definitions/examplepbOpaqueAddress" }, "billingAddress": { "$ref": "#/definitions/examplepbOpaqueAddress" }, "status": { "$ref": "#/definitions/OpaqueOrderOpaqueOrderStatus" }, "paymentMethodId": { "type": "string" }, "trackingNumber": { "type": "string" }, "createdAt": { "type": "string", "format": "date-time" }, "updatedAt": { "type": "string", "format": "date-time" }, "shippedAt": { "type": "string", "format": "date-time" }, "deliveredAt": { "type": "string", "format": "date-time" }, "shippingInfo": { "$ref": "#/definitions/OpaqueOrderOpaqueShippingInfo" }, "metadata": { "type": "object", "additionalProperties": { "type": "string" } }, "couponCode": { "type": "string" }, "promotionId": { "type": "string" } }, "title": "OpaqueOrder represents a customer order" }, "examplepbOpaqueOrderItem": { "type": "object", "properties": { "productId": { "type": "string" }, "variantId": { "type": "string" }, "productName": { "type": "string" }, "quantity": { "type": "integer", "format": "int32" }, "unitPrice": { "$ref": "#/definitions/examplepbOpaquePrice" }, "totalPrice": { "$ref": "#/definitions/examplepbOpaquePrice" }, "selectedAttributes": { "type": "object", "additionalProperties": { "type": "string" } }, "giftWrapped": { "type": "boolean" }, "giftMessage": { "type": "string" } }, "title": "OpaqueOrderItem represents an item in an order" }, "examplepbOpaqueOrderSummary": { "type": "object", "properties": { "totalOrdersProcessed": { "type": "integer", "format": "int32" }, "successfulOrders": { "type": "integer", "format": "int32" }, "failedOrders": { "type": "integer", "format": "int32" }, "totalValue": { "$ref": "#/definitions/examplepbOpaquePrice" }, "orderIds": { "type": "array", "items": { "type": "string" } }, "errorDetails": { "type": "object", "additionalProperties": { "type": "string" } }, "processingTime": { "type": "string", "format": "date-time" }, "errors": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/OpaqueOrderSummaryOpaqueOrderError" } } }, "title": "OpaqueOrderSummary represents a summary of processed orders" }, "examplepbOpaquePrice": { "type": "object", "properties": { "amount": { "type": "number", "format": "double" }, "currencyCode": { "type": "string" }, "isDiscounted": { "type": "boolean" }, "originalAmount": { "type": "number", "format": "double" }, "priceValidUntil": { "type": "string", "format": "date-time" } }, "title": "OpaquePrice represents a monetary value with currency" }, "examplepbOpaqueProcessOrdersRequest": { "type": "object", "properties": { "order": { "$ref": "#/definitions/examplepbOpaqueOrder" } }, "title": "OpaqueProcessOrdersRequest represents a request to process order" }, "examplepbOpaqueProcessOrdersResponse": { "type": "object", "properties": { "summary": { "$ref": "#/definitions/examplepbOpaqueOrderSummary" } }, "title": "OpaqueProcessOrdersResponse represents orders processing result" }, "examplepbOpaqueProduct": { "type": "object", "properties": { "productId": { "type": "string" }, "name": { "type": "string" }, "description": { "type": "string" }, "brand": { "type": "string" }, "basePrice": { "$ref": "#/definitions/examplepbOpaquePrice" }, "category": { "$ref": "#/definitions/examplepbOpaqueProductCategory" }, "variants": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/examplepbOpaqueProductVariant" } }, "tags": { "type": "array", "items": { "type": "string" } }, "averageRating": { "type": "number", "format": "double" }, "reviewCount": { "type": "integer", "format": "int32" }, "isFeatured": { "type": "boolean" }, "createdAt": { "type": "string", "format": "date-time" }, "updatedAt": { "type": "string", "format": "date-time" }, "averageShippingTime": { "type": "string" }, "status": { "$ref": "#/definitions/OpaqueProductOpaqueProductStatus" }, "metadata": { "type": "object", "additionalProperties": { "type": "string" } }, "regionalPrices": { "type": "object", "additionalProperties": { "$ref": "#/definitions/examplepbOpaquePrice" } }, "dimensions": { "$ref": "#/definitions/OpaqueProductOpaqueProductDimensions" }, "taxPercentage": { "type": "number", "format": "double" }, "taxExempt": { "type": "boolean" } }, "title": "OpaqueProduct represents a product in the e-commerce system" }, "examplepbOpaqueProductCategory": { "type": "object", "properties": { "categoryId": { "type": "string" }, "name": { "type": "string" }, "description": { "type": "string" }, "parentCategory": { "$ref": "#/definitions/examplepbOpaqueProductCategory" }, "tags": { "type": "array", "items": { "type": "string" } }, "createdAt": { "type": "string", "format": "date-time" }, "updatedAt": { "type": "string", "format": "date-time" } }, "title": "OpaqueProductCategory represents a product category" }, "examplepbOpaqueProductVariant": { "type": "object", "properties": { "variantId": { "type": "string" }, "sku": { "type": "string" }, "name": { "type": "string" }, "price": { "$ref": "#/definitions/examplepbOpaquePrice" }, "inventoryCount": { "type": "integer", "format": "int32" }, "attributes": { "type": "object", "additionalProperties": { "type": "string" } }, "imageData": { "type": "string", "format": "byte" }, "imageUrls": { "type": "array", "items": { "type": "string" } }, "isAvailable": { "type": "boolean" }, "percentageOff": { "type": "number", "format": "double" }, "fixedAmountOff": { "type": "number", "format": "double" } }, "title": "OpaqueProductVariant represents a specific variant of a product" }, "examplepbOpaqueSearchOrdersResponse": { "type": "object", "properties": { "orders": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/examplepbOpaqueOrder" } } }, "title": "OpaqueSearchOrdersResponse represents a list of orders found" }, "examplepbOpaqueSearchProductsResponse": { "type": "object", "properties": { "product": { "$ref": "#/definitions/examplepbOpaqueProduct" } }, "title": "OpaqueSearchProductsResponse represents a single product in search results" }, "examplepbOpaqueStreamCustomerActivityRequest": { "type": "object", "properties": { "event": { "$ref": "#/definitions/examplepbOpaqueCustomerEvent" } }, "title": "OpaqueStreamCustomerActivityRequest represents a report of user activity" }, "examplepbOpaqueStreamCustomerActivityResponse": { "type": "object", "properties": { "event": { "$ref": "#/definitions/examplepbOpaqueActivityUpdate" } }, "title": "OpaqueStreamCustomerActivityRequest represents a report of server activity" }, "examplepbOpaqueUpdateProductResponse": { "type": "object", "properties": { "product": { "$ref": "#/definitions/examplepbOpaqueProduct" } }, "title": "OpaqueUpdateProductResponse represents the response for OpaqueUpdateProduct" }, "googleRpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32", "description": "The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]." }, "message": { "type": "string", "description": "A developer-facing error message, which should be in English. Any\nuser-facing error message should be localized and sent in the\n[google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client." }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" }, "description": "A list of messages that carry the error details. There is a common set of\nmessage types for APIs to use." } }, "description": "The `Status` type defines a logical error model that is suitable for\ndifferent programming environments, including REST APIs and RPC APIs. It is\nused by [gRPC](https://github.com/grpc). Each `Status` message contains\nthree pieces of data: error code, error message, and error details.\n\nYou can find out more about this error model and how to work with it in the\n[API Design Guide](https://cloud.google.com/apis/design/errors)." }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string", "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics." } }, "additionalProperties": {}, "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }" }, "subStringMessage": { "type": "object", "properties": { "value": { "type": "string" } } } } } ================================================ FILE: examples/internal/proto/examplepb/opaque_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: examples/internal/proto/examplepb/opaque.proto package examplepb import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( OpaqueEcommerceService_OpaqueGetProduct_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueGetProduct" OpaqueEcommerceService_OpaqueSearchProducts_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueSearchProducts" OpaqueEcommerceService_OpaqueCreateProduct_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueCreateProduct" OpaqueEcommerceService_OpaqueCreateProductField_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueCreateProductField" OpaqueEcommerceService_OpaqueProcessOrders_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueProcessOrders" OpaqueEcommerceService_OpaqueStreamCustomerActivity_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueStreamCustomerActivity" OpaqueEcommerceService_OpaqueUpdateProduct_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueUpdateProduct" OpaqueEcommerceService_OpaqueSearchOrders_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueSearchOrders" OpaqueEcommerceService_OpaqueEchoNote_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService/OpaqueEchoNote" ) // OpaqueEcommerceServiceClient is the client API for OpaqueEcommerceService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // // OpaqueEcommerceService provides a comprehensive e-commerce API with various request/response patterns type OpaqueEcommerceServiceClient interface { // OpaqueGetProduct - Unary request, unary response // Retrieves detailed information about a specific product OpaqueGetProduct(ctx context.Context, in *OpaqueGetProductRequest, opts ...grpc.CallOption) (*OpaqueGetProductResponse, error) // OpaqueSearchProducts - Unary request, stream response // Searches for products based on criteria and streams results back OpaqueSearchProducts(ctx context.Context, in *OpaqueSearchProductsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[OpaqueSearchProductsResponse], error) // OpaqueCreateProduct - Unary request with body field, unary response // Creates a new product with the product details in the body OpaqueCreateProduct(ctx context.Context, in *OpaqueCreateProductRequest, opts ...grpc.CallOption) (*OpaqueCreateProductResponse, error) // OpaqueCreateProductField - same as above, but with body field mapping. OpaqueCreateProductField(ctx context.Context, in *OpaqueCreateProductFieldRequest, opts ...grpc.CallOption) (*OpaqueCreateProductFieldResponse, error) // OpaqueProcessOrders - Stream request, unary response // Processes multiple orders in a batch and returns a summary OpaqueProcessOrders(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[OpaqueProcessOrdersRequest, OpaqueProcessOrdersResponse], error) // OpaqueStreamCustomerActivity - Stream request, stream response // Bidirectional streaming for real-time customer activity monitoring OpaqueStreamCustomerActivity(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[OpaqueStreamCustomerActivityRequest, OpaqueStreamCustomerActivityResponse], error) // OpaqueUpdateProduct - PATCH request with FieldMask and body field mapping // to reproduce the compilation issue with bodyData as a value type. OpaqueUpdateProduct(ctx context.Context, in *OpaqueUpdateProductRequest, opts ...grpc.CallOption) (*OpaqueUpdateProductResponse, error) // OpaqueSearchOrders - Unary request, unary response // Uses enum params (both top level and nested) to populate fields to test opaque get chain OpaqueSearchOrders(ctx context.Context, in *OpaqueSearchOrdersRequest, opts ...grpc.CallOption) (*OpaqueSearchOrdersResponse, error) // OpaqueEchoNote - Unary request with nested body field from another package. // Exercises the opaque body import path by referencing grpc.gateway.examples.internal.proto.sub.StringMessage. OpaqueEchoNote(ctx context.Context, in *OpaqueEchoNoteRequest, opts ...grpc.CallOption) (*OpaqueEchoNoteResponse, error) } type opaqueEcommerceServiceClient struct { cc grpc.ClientConnInterface } func NewOpaqueEcommerceServiceClient(cc grpc.ClientConnInterface) OpaqueEcommerceServiceClient { return &opaqueEcommerceServiceClient{cc} } func (c *opaqueEcommerceServiceClient) OpaqueGetProduct(ctx context.Context, in *OpaqueGetProductRequest, opts ...grpc.CallOption) (*OpaqueGetProductResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(OpaqueGetProductResponse) err := c.cc.Invoke(ctx, OpaqueEcommerceService_OpaqueGetProduct_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *opaqueEcommerceServiceClient) OpaqueSearchProducts(ctx context.Context, in *OpaqueSearchProductsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[OpaqueSearchProductsResponse], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &OpaqueEcommerceService_ServiceDesc.Streams[0], OpaqueEcommerceService_OpaqueSearchProducts_FullMethodName, cOpts...) if err != nil { return nil, err } x := &grpc.GenericClientStream[OpaqueSearchProductsRequest, OpaqueSearchProductsResponse]{ClientStream: stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } if err := x.ClientStream.CloseSend(); err != nil { return nil, err } return x, nil } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type OpaqueEcommerceService_OpaqueSearchProductsClient = grpc.ServerStreamingClient[OpaqueSearchProductsResponse] func (c *opaqueEcommerceServiceClient) OpaqueCreateProduct(ctx context.Context, in *OpaqueCreateProductRequest, opts ...grpc.CallOption) (*OpaqueCreateProductResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(OpaqueCreateProductResponse) err := c.cc.Invoke(ctx, OpaqueEcommerceService_OpaqueCreateProduct_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *opaqueEcommerceServiceClient) OpaqueCreateProductField(ctx context.Context, in *OpaqueCreateProductFieldRequest, opts ...grpc.CallOption) (*OpaqueCreateProductFieldResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(OpaqueCreateProductFieldResponse) err := c.cc.Invoke(ctx, OpaqueEcommerceService_OpaqueCreateProductField_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *opaqueEcommerceServiceClient) OpaqueProcessOrders(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[OpaqueProcessOrdersRequest, OpaqueProcessOrdersResponse], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &OpaqueEcommerceService_ServiceDesc.Streams[1], OpaqueEcommerceService_OpaqueProcessOrders_FullMethodName, cOpts...) if err != nil { return nil, err } x := &grpc.GenericClientStream[OpaqueProcessOrdersRequest, OpaqueProcessOrdersResponse]{ClientStream: stream} return x, nil } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type OpaqueEcommerceService_OpaqueProcessOrdersClient = grpc.ClientStreamingClient[OpaqueProcessOrdersRequest, OpaqueProcessOrdersResponse] func (c *opaqueEcommerceServiceClient) OpaqueStreamCustomerActivity(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[OpaqueStreamCustomerActivityRequest, OpaqueStreamCustomerActivityResponse], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &OpaqueEcommerceService_ServiceDesc.Streams[2], OpaqueEcommerceService_OpaqueStreamCustomerActivity_FullMethodName, cOpts...) if err != nil { return nil, err } x := &grpc.GenericClientStream[OpaqueStreamCustomerActivityRequest, OpaqueStreamCustomerActivityResponse]{ClientStream: stream} return x, nil } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type OpaqueEcommerceService_OpaqueStreamCustomerActivityClient = grpc.BidiStreamingClient[OpaqueStreamCustomerActivityRequest, OpaqueStreamCustomerActivityResponse] func (c *opaqueEcommerceServiceClient) OpaqueUpdateProduct(ctx context.Context, in *OpaqueUpdateProductRequest, opts ...grpc.CallOption) (*OpaqueUpdateProductResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(OpaqueUpdateProductResponse) err := c.cc.Invoke(ctx, OpaqueEcommerceService_OpaqueUpdateProduct_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *opaqueEcommerceServiceClient) OpaqueSearchOrders(ctx context.Context, in *OpaqueSearchOrdersRequest, opts ...grpc.CallOption) (*OpaqueSearchOrdersResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(OpaqueSearchOrdersResponse) err := c.cc.Invoke(ctx, OpaqueEcommerceService_OpaqueSearchOrders_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *opaqueEcommerceServiceClient) OpaqueEchoNote(ctx context.Context, in *OpaqueEchoNoteRequest, opts ...grpc.CallOption) (*OpaqueEchoNoteResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(OpaqueEchoNoteResponse) err := c.cc.Invoke(ctx, OpaqueEcommerceService_OpaqueEchoNote_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // OpaqueEcommerceServiceServer is the server API for OpaqueEcommerceService service. // All implementations should embed UnimplementedOpaqueEcommerceServiceServer // for forward compatibility. // // OpaqueEcommerceService provides a comprehensive e-commerce API with various request/response patterns type OpaqueEcommerceServiceServer interface { // OpaqueGetProduct - Unary request, unary response // Retrieves detailed information about a specific product OpaqueGetProduct(context.Context, *OpaqueGetProductRequest) (*OpaqueGetProductResponse, error) // OpaqueSearchProducts - Unary request, stream response // Searches for products based on criteria and streams results back OpaqueSearchProducts(*OpaqueSearchProductsRequest, grpc.ServerStreamingServer[OpaqueSearchProductsResponse]) error // OpaqueCreateProduct - Unary request with body field, unary response // Creates a new product with the product details in the body OpaqueCreateProduct(context.Context, *OpaqueCreateProductRequest) (*OpaqueCreateProductResponse, error) // OpaqueCreateProductField - same as above, but with body field mapping. OpaqueCreateProductField(context.Context, *OpaqueCreateProductFieldRequest) (*OpaqueCreateProductFieldResponse, error) // OpaqueProcessOrders - Stream request, unary response // Processes multiple orders in a batch and returns a summary OpaqueProcessOrders(grpc.ClientStreamingServer[OpaqueProcessOrdersRequest, OpaqueProcessOrdersResponse]) error // OpaqueStreamCustomerActivity - Stream request, stream response // Bidirectional streaming for real-time customer activity monitoring OpaqueStreamCustomerActivity(grpc.BidiStreamingServer[OpaqueStreamCustomerActivityRequest, OpaqueStreamCustomerActivityResponse]) error // OpaqueUpdateProduct - PATCH request with FieldMask and body field mapping // to reproduce the compilation issue with bodyData as a value type. OpaqueUpdateProduct(context.Context, *OpaqueUpdateProductRequest) (*OpaqueUpdateProductResponse, error) // OpaqueSearchOrders - Unary request, unary response // Uses enum params (both top level and nested) to populate fields to test opaque get chain OpaqueSearchOrders(context.Context, *OpaqueSearchOrdersRequest) (*OpaqueSearchOrdersResponse, error) // OpaqueEchoNote - Unary request with nested body field from another package. // Exercises the opaque body import path by referencing grpc.gateway.examples.internal.proto.sub.StringMessage. OpaqueEchoNote(context.Context, *OpaqueEchoNoteRequest) (*OpaqueEchoNoteResponse, error) } // UnimplementedOpaqueEcommerceServiceServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedOpaqueEcommerceServiceServer struct{} func (UnimplementedOpaqueEcommerceServiceServer) OpaqueGetProduct(context.Context, *OpaqueGetProductRequest) (*OpaqueGetProductResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method OpaqueGetProduct not implemented") } func (UnimplementedOpaqueEcommerceServiceServer) OpaqueSearchProducts(*OpaqueSearchProductsRequest, grpc.ServerStreamingServer[OpaqueSearchProductsResponse]) error { return status.Errorf(codes.Unimplemented, "method OpaqueSearchProducts not implemented") } func (UnimplementedOpaqueEcommerceServiceServer) OpaqueCreateProduct(context.Context, *OpaqueCreateProductRequest) (*OpaqueCreateProductResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method OpaqueCreateProduct not implemented") } func (UnimplementedOpaqueEcommerceServiceServer) OpaqueCreateProductField(context.Context, *OpaqueCreateProductFieldRequest) (*OpaqueCreateProductFieldResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method OpaqueCreateProductField not implemented") } func (UnimplementedOpaqueEcommerceServiceServer) OpaqueProcessOrders(grpc.ClientStreamingServer[OpaqueProcessOrdersRequest, OpaqueProcessOrdersResponse]) error { return status.Errorf(codes.Unimplemented, "method OpaqueProcessOrders not implemented") } func (UnimplementedOpaqueEcommerceServiceServer) OpaqueStreamCustomerActivity(grpc.BidiStreamingServer[OpaqueStreamCustomerActivityRequest, OpaqueStreamCustomerActivityResponse]) error { return status.Errorf(codes.Unimplemented, "method OpaqueStreamCustomerActivity not implemented") } func (UnimplementedOpaqueEcommerceServiceServer) OpaqueUpdateProduct(context.Context, *OpaqueUpdateProductRequest) (*OpaqueUpdateProductResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method OpaqueUpdateProduct not implemented") } func (UnimplementedOpaqueEcommerceServiceServer) OpaqueSearchOrders(context.Context, *OpaqueSearchOrdersRequest) (*OpaqueSearchOrdersResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method OpaqueSearchOrders not implemented") } func (UnimplementedOpaqueEcommerceServiceServer) OpaqueEchoNote(context.Context, *OpaqueEchoNoteRequest) (*OpaqueEchoNoteResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method OpaqueEchoNote not implemented") } func (UnimplementedOpaqueEcommerceServiceServer) testEmbeddedByValue() {} // UnsafeOpaqueEcommerceServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to OpaqueEcommerceServiceServer will // result in compilation errors. type UnsafeOpaqueEcommerceServiceServer interface { mustEmbedUnimplementedOpaqueEcommerceServiceServer() } func RegisterOpaqueEcommerceServiceServer(s grpc.ServiceRegistrar, srv OpaqueEcommerceServiceServer) { // If the following call pancis, it indicates UnimplementedOpaqueEcommerceServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&OpaqueEcommerceService_ServiceDesc, srv) } func _OpaqueEcommerceService_OpaqueGetProduct_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(OpaqueGetProductRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(OpaqueEcommerceServiceServer).OpaqueGetProduct(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: OpaqueEcommerceService_OpaqueGetProduct_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(OpaqueEcommerceServiceServer).OpaqueGetProduct(ctx, req.(*OpaqueGetProductRequest)) } return interceptor(ctx, in, info, handler) } func _OpaqueEcommerceService_OpaqueSearchProducts_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(OpaqueSearchProductsRequest) if err := stream.RecvMsg(m); err != nil { return err } return srv.(OpaqueEcommerceServiceServer).OpaqueSearchProducts(m, &grpc.GenericServerStream[OpaqueSearchProductsRequest, OpaqueSearchProductsResponse]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type OpaqueEcommerceService_OpaqueSearchProductsServer = grpc.ServerStreamingServer[OpaqueSearchProductsResponse] func _OpaqueEcommerceService_OpaqueCreateProduct_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(OpaqueCreateProductRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(OpaqueEcommerceServiceServer).OpaqueCreateProduct(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: OpaqueEcommerceService_OpaqueCreateProduct_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(OpaqueEcommerceServiceServer).OpaqueCreateProduct(ctx, req.(*OpaqueCreateProductRequest)) } return interceptor(ctx, in, info, handler) } func _OpaqueEcommerceService_OpaqueCreateProductField_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(OpaqueCreateProductFieldRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(OpaqueEcommerceServiceServer).OpaqueCreateProductField(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: OpaqueEcommerceService_OpaqueCreateProductField_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(OpaqueEcommerceServiceServer).OpaqueCreateProductField(ctx, req.(*OpaqueCreateProductFieldRequest)) } return interceptor(ctx, in, info, handler) } func _OpaqueEcommerceService_OpaqueProcessOrders_Handler(srv interface{}, stream grpc.ServerStream) error { return srv.(OpaqueEcommerceServiceServer).OpaqueProcessOrders(&grpc.GenericServerStream[OpaqueProcessOrdersRequest, OpaqueProcessOrdersResponse]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type OpaqueEcommerceService_OpaqueProcessOrdersServer = grpc.ClientStreamingServer[OpaqueProcessOrdersRequest, OpaqueProcessOrdersResponse] func _OpaqueEcommerceService_OpaqueStreamCustomerActivity_Handler(srv interface{}, stream grpc.ServerStream) error { return srv.(OpaqueEcommerceServiceServer).OpaqueStreamCustomerActivity(&grpc.GenericServerStream[OpaqueStreamCustomerActivityRequest, OpaqueStreamCustomerActivityResponse]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type OpaqueEcommerceService_OpaqueStreamCustomerActivityServer = grpc.BidiStreamingServer[OpaqueStreamCustomerActivityRequest, OpaqueStreamCustomerActivityResponse] func _OpaqueEcommerceService_OpaqueUpdateProduct_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(OpaqueUpdateProductRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(OpaqueEcommerceServiceServer).OpaqueUpdateProduct(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: OpaqueEcommerceService_OpaqueUpdateProduct_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(OpaqueEcommerceServiceServer).OpaqueUpdateProduct(ctx, req.(*OpaqueUpdateProductRequest)) } return interceptor(ctx, in, info, handler) } func _OpaqueEcommerceService_OpaqueSearchOrders_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(OpaqueSearchOrdersRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(OpaqueEcommerceServiceServer).OpaqueSearchOrders(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: OpaqueEcommerceService_OpaqueSearchOrders_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(OpaqueEcommerceServiceServer).OpaqueSearchOrders(ctx, req.(*OpaqueSearchOrdersRequest)) } return interceptor(ctx, in, info, handler) } func _OpaqueEcommerceService_OpaqueEchoNote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(OpaqueEchoNoteRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(OpaqueEcommerceServiceServer).OpaqueEchoNote(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: OpaqueEcommerceService_OpaqueEchoNote_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(OpaqueEcommerceServiceServer).OpaqueEchoNote(ctx, req.(*OpaqueEchoNoteRequest)) } return interceptor(ctx, in, info, handler) } // OpaqueEcommerceService_ServiceDesc is the grpc.ServiceDesc for OpaqueEcommerceService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var OpaqueEcommerceService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.OpaqueEcommerceService", HandlerType: (*OpaqueEcommerceServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "OpaqueGetProduct", Handler: _OpaqueEcommerceService_OpaqueGetProduct_Handler, }, { MethodName: "OpaqueCreateProduct", Handler: _OpaqueEcommerceService_OpaqueCreateProduct_Handler, }, { MethodName: "OpaqueCreateProductField", Handler: _OpaqueEcommerceService_OpaqueCreateProductField_Handler, }, { MethodName: "OpaqueUpdateProduct", Handler: _OpaqueEcommerceService_OpaqueUpdateProduct_Handler, }, { MethodName: "OpaqueSearchOrders", Handler: _OpaqueEcommerceService_OpaqueSearchOrders_Handler, }, { MethodName: "OpaqueEchoNote", Handler: _OpaqueEcommerceService_OpaqueEchoNote_Handler, }, }, Streams: []grpc.StreamDesc{ { StreamName: "OpaqueSearchProducts", Handler: _OpaqueEcommerceService_OpaqueSearchProducts_Handler, ServerStreams: true, }, { StreamName: "OpaqueProcessOrders", Handler: _OpaqueEcommerceService_OpaqueProcessOrders_Handler, ClientStreams: true, }, { StreamName: "OpaqueStreamCustomerActivity", Handler: _OpaqueEcommerceService_OpaqueStreamCustomerActivity_Handler, ServerStreams: true, ClientStreams: true, }, }, Metadata: "examples/internal/proto/examplepb/opaque.proto", } ================================================ FILE: examples/internal/proto/examplepb/openapi_merge.buf.gen.yaml ================================================ version: v2 plugins: - local: protoc-gen-openapiv2 out: . opt: - allow_merge=true - merge_file_name=examples/internal/proto/examplepb/openapi_merge ================================================ FILE: examples/internal/proto/examplepb/openapi_merge.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "Merging Services", "description": "This is an example of merging two proto files.", "version": "version not set" }, "tags": [ { "name": "ServiceA" }, { "name": "ServiceC" }, { "name": "ServiceB" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/v1/example/a/1": { "post": { "summary": "ServiceA.MethodOne receives InMessageA and returns OutMessageA", "description": "Here is the detail explanation about ServiceA.MethodOne.", "operationId": "ServiceA_MethodOne", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbOutMessageA" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "body", "description": "InMessageA represents a message to ServiceA and ServiceC.", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbInMessageA" } } ], "tags": [ "ServiceA" ] } }, "/v1/example/a/2": { "post": { "summary": "ServiceA.MethodTwo receives OutMessageA and returns InMessageA", "description": "Here is the detail explanation about ServiceA.MethodTwo.", "operationId": "ServiceA_MethodTwo", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbInMessageA" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "body", "description": "OutMessageA represents a message returned from ServiceA.", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbOutMessageA" } } ], "tags": [ "ServiceA" ] } }, "/v1/example/b/1": { "post": { "summary": "ServiceB.MethodOne receives InMessageB and returns OutMessageB", "description": "Here is the detail explanation about ServiceB.MethodOne.", "operationId": "ServiceB_MethodOne", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbOutMessageB" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "body", "description": "InMessageB represents a message to ServiceB.", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbInMessageB" } } ], "tags": [ "ServiceB" ] } }, "/v1/example/b/2": { "post": { "summary": "ServiceB.MethodTwo receives OutMessageB and returns InMessageB", "description": "Here is the detail explanation about ServiceB.MethodTwo.", "operationId": "ServiceB_MethodTwo", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbInMessageB" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "body", "description": "OutMessageB represents a message returned from ServiceB.", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbOutMessageB" } } ], "tags": [ "ServiceB" ] } }, "/v1/example/c/1": { "post": { "summary": "ServiceC.MethodOne receives InMessageA and returns OutMessageC", "description": "Here is the detail explanation about ServiceC.MethodOne.", "operationId": "ServiceC_MethodOne", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbOutMessageC" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "body", "description": "InMessageA represents a message to ServiceA and ServiceC.", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbInMessageA" } } ], "tags": [ "ServiceC" ] } }, "/v1/example/c/2": { "post": { "summary": "ServiceC.MethodTwo receives OutMessageA and returns InMessageA", "description": "Here is the detail explanation about ServiceC.MethodTwo.", "operationId": "ServiceC_MethodTwo", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbInMessageA" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "body", "description": "OutMessageA represents a message returned from ServiceA.", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbOutMessageA" } } ], "tags": [ "ServiceC" ] } } }, "definitions": { "examplepbInMessageA": { "type": "object", "properties": { "values": { "type": "array", "items": { "type": "string" }, "title": "Here is the explanation about InMessageA.values" } }, "description": "InMessageA represents a message to ServiceA and ServiceC." }, "examplepbInMessageB": { "type": "object", "properties": { "value": { "type": "string", "title": "Here is the explanation about InMessageB.values" } }, "description": "InMessageB represents a message to ServiceB." }, "examplepbOutMessageA": { "type": "object", "properties": { "value": { "type": "string", "title": "Here is the explanation about OutMessageA.value" } }, "description": "OutMessageA represents a message returned from ServiceA." }, "examplepbOutMessageB": { "type": "object", "properties": { "values": { "type": "array", "items": { "type": "string" }, "title": "Here is the explanation about OutMessageB.value" } }, "description": "OutMessageB represents a message returned from ServiceB." }, "examplepbOutMessageC": { "type": "object", "properties": { "value": { "type": "string", "title": "Here is the explanation about OutMessageC.value" } }, "description": "OutMessageC represents a message returned from ServiceC." }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string" } }, "additionalProperties": {} }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } } } } ================================================ FILE: examples/internal/proto/examplepb/openapi_merge_a.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/examplepb/openapi_merge_a.proto // Merging Services // // This is an example of merging two proto files. package examplepb import ( _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) // InMessageA represents a message to ServiceA and ServiceC. type InMessageA struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Here is the explanation about InMessageA.values Values []string `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` } func (x *InMessageA) Reset() { *x = InMessageA{} mi := &file_examples_internal_proto_examplepb_openapi_merge_a_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *InMessageA) String() string { return protoimpl.X.MessageStringOf(x) } func (*InMessageA) ProtoMessage() {} func (x *InMessageA) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_openapi_merge_a_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use InMessageA.ProtoReflect.Descriptor instead. func (*InMessageA) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_openapi_merge_a_proto_rawDescGZIP(), []int{0} } func (x *InMessageA) GetValues() []string { if x != nil { return x.Values } return nil } // OutMessageA represents a message returned from ServiceA. type OutMessageA struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Here is the explanation about OutMessageA.value Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` } func (x *OutMessageA) Reset() { *x = OutMessageA{} mi := &file_examples_internal_proto_examplepb_openapi_merge_a_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OutMessageA) String() string { return protoimpl.X.MessageStringOf(x) } func (*OutMessageA) ProtoMessage() {} func (x *OutMessageA) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_openapi_merge_a_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use OutMessageA.ProtoReflect.Descriptor instead. func (*OutMessageA) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_openapi_merge_a_proto_rawDescGZIP(), []int{1} } func (x *OutMessageA) GetValue() string { if x != nil { return x.Value } return "" } // OutMessageC represents a message returned from ServiceC. type OutMessageC struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Here is the explanation about OutMessageC.value Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` } func (x *OutMessageC) Reset() { *x = OutMessageC{} mi := &file_examples_internal_proto_examplepb_openapi_merge_a_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OutMessageC) String() string { return protoimpl.X.MessageStringOf(x) } func (*OutMessageC) ProtoMessage() {} func (x *OutMessageC) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_openapi_merge_a_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use OutMessageC.ProtoReflect.Descriptor instead. func (*OutMessageC) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_openapi_merge_a_proto_rawDescGZIP(), []int{2} } func (x *OutMessageC) GetValue() string { if x != nil { return x.Value } return "" } var File_examples_internal_proto_examplepb_openapi_merge_a_proto protoreflect.FileDescriptor var file_examples_internal_proto_examplepb_openapi_merge_a_proto_rawDesc = []byte{ 0x0a, 0x37, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x5f, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x5f, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x28, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x24, 0x0a, 0x0a, 0x49, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, 0x23, 0x0a, 0x0b, 0x4f, 0x75, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x23, 0x0a, 0x0b, 0x4f, 0x75, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x43, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x32, 0xb8, 0x02, 0x0a, 0x08, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x41, 0x12, 0x94, 0x01, 0x0a, 0x09, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x6e, 0x65, 0x12, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x49, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41, 0x1a, 0x35, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4f, 0x75, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x3a, 0x01, 0x2a, 0x22, 0x0f, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x2f, 0x31, 0x12, 0x94, 0x01, 0x0a, 0x09, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x54, 0x77, 0x6f, 0x12, 0x35, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4f, 0x75, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41, 0x1a, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x49, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x3a, 0x01, 0x2a, 0x22, 0x0f, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x2f, 0x32, 0x32, 0xb8, 0x02, 0x0a, 0x08, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x12, 0x94, 0x01, 0x0a, 0x09, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x6e, 0x65, 0x12, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x49, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41, 0x1a, 0x35, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4f, 0x75, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x43, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x3a, 0x01, 0x2a, 0x22, 0x0f, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x63, 0x2f, 0x31, 0x12, 0x94, 0x01, 0x0a, 0x09, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x54, 0x77, 0x6f, 0x12, 0x35, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4f, 0x75, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41, 0x1a, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x49, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x3a, 0x01, 0x2a, 0x22, 0x0f, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x63, 0x2f, 0x32, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_examplepb_openapi_merge_a_proto_rawDescOnce sync.Once file_examples_internal_proto_examplepb_openapi_merge_a_proto_rawDescData = file_examples_internal_proto_examplepb_openapi_merge_a_proto_rawDesc ) func file_examples_internal_proto_examplepb_openapi_merge_a_proto_rawDescGZIP() []byte { file_examples_internal_proto_examplepb_openapi_merge_a_proto_rawDescOnce.Do(func() { file_examples_internal_proto_examplepb_openapi_merge_a_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_examplepb_openapi_merge_a_proto_rawDescData) }) return file_examples_internal_proto_examplepb_openapi_merge_a_proto_rawDescData } var file_examples_internal_proto_examplepb_openapi_merge_a_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_examples_internal_proto_examplepb_openapi_merge_a_proto_goTypes = []any{ (*InMessageA)(nil), // 0: grpc.gateway.examples.internal.examplepb.InMessageA (*OutMessageA)(nil), // 1: grpc.gateway.examples.internal.examplepb.OutMessageA (*OutMessageC)(nil), // 2: grpc.gateway.examples.internal.examplepb.OutMessageC } var file_examples_internal_proto_examplepb_openapi_merge_a_proto_depIdxs = []int32{ 0, // 0: grpc.gateway.examples.internal.examplepb.ServiceA.MethodOne:input_type -> grpc.gateway.examples.internal.examplepb.InMessageA 1, // 1: grpc.gateway.examples.internal.examplepb.ServiceA.MethodTwo:input_type -> grpc.gateway.examples.internal.examplepb.OutMessageA 0, // 2: grpc.gateway.examples.internal.examplepb.ServiceC.MethodOne:input_type -> grpc.gateway.examples.internal.examplepb.InMessageA 1, // 3: grpc.gateway.examples.internal.examplepb.ServiceC.MethodTwo:input_type -> grpc.gateway.examples.internal.examplepb.OutMessageA 1, // 4: grpc.gateway.examples.internal.examplepb.ServiceA.MethodOne:output_type -> grpc.gateway.examples.internal.examplepb.OutMessageA 0, // 5: grpc.gateway.examples.internal.examplepb.ServiceA.MethodTwo:output_type -> grpc.gateway.examples.internal.examplepb.InMessageA 2, // 6: grpc.gateway.examples.internal.examplepb.ServiceC.MethodOne:output_type -> grpc.gateway.examples.internal.examplepb.OutMessageC 0, // 7: grpc.gateway.examples.internal.examplepb.ServiceC.MethodTwo:output_type -> grpc.gateway.examples.internal.examplepb.InMessageA 4, // [4:8] is the sub-list for method output_type 0, // [0:4] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name } func init() { file_examples_internal_proto_examplepb_openapi_merge_a_proto_init() } func file_examples_internal_proto_examplepb_openapi_merge_a_proto_init() { if File_examples_internal_proto_examplepb_openapi_merge_a_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_examplepb_openapi_merge_a_proto_rawDesc, NumEnums: 0, NumMessages: 3, NumExtensions: 0, NumServices: 2, }, GoTypes: file_examples_internal_proto_examplepb_openapi_merge_a_proto_goTypes, DependencyIndexes: file_examples_internal_proto_examplepb_openapi_merge_a_proto_depIdxs, MessageInfos: file_examples_internal_proto_examplepb_openapi_merge_a_proto_msgTypes, }.Build() File_examples_internal_proto_examplepb_openapi_merge_a_proto = out.File file_examples_internal_proto_examplepb_openapi_merge_a_proto_rawDesc = nil file_examples_internal_proto_examplepb_openapi_merge_a_proto_goTypes = nil file_examples_internal_proto_examplepb_openapi_merge_a_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/examplepb/openapi_merge_a.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/proto/examplepb/openapi_merge_a.proto /* Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package examplepb import ( "context" "errors" "io" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) func request_ServiceA_MethodOne_0(ctx context.Context, marshaler runtime.Marshaler, client ServiceAClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq InMessageA metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.MethodOne(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ServiceA_MethodOne_0(ctx context.Context, marshaler runtime.Marshaler, server ServiceAServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq InMessageA metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.MethodOne(ctx, &protoReq) return msg, metadata, err } func request_ServiceA_MethodTwo_0(ctx context.Context, marshaler runtime.Marshaler, client ServiceAClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq OutMessageA metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.MethodTwo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ServiceA_MethodTwo_0(ctx context.Context, marshaler runtime.Marshaler, server ServiceAServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq OutMessageA metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.MethodTwo(ctx, &protoReq) return msg, metadata, err } func request_ServiceC_MethodOne_0(ctx context.Context, marshaler runtime.Marshaler, client ServiceCClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq InMessageA metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.MethodOne(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ServiceC_MethodOne_0(ctx context.Context, marshaler runtime.Marshaler, server ServiceCServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq InMessageA metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.MethodOne(ctx, &protoReq) return msg, metadata, err } func request_ServiceC_MethodTwo_0(ctx context.Context, marshaler runtime.Marshaler, client ServiceCClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq OutMessageA metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.MethodTwo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ServiceC_MethodTwo_0(ctx context.Context, marshaler runtime.Marshaler, server ServiceCServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq OutMessageA metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.MethodTwo(ctx, &protoReq) return msg, metadata, err } // RegisterServiceAHandlerServer registers the http handlers for service ServiceA to "mux". // UnaryRPC :call ServiceAServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterServiceAHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterServiceAHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ServiceAServer) error { mux.Handle(http.MethodPost, pattern_ServiceA_MethodOne_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.examplepb.ServiceA/MethodOne", runtime.WithHTTPPathPattern("/v1/example/a/1")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ServiceA_MethodOne_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ServiceA_MethodOne_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ServiceA_MethodTwo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.examplepb.ServiceA/MethodTwo", runtime.WithHTTPPathPattern("/v1/example/a/2")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ServiceA_MethodTwo_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ServiceA_MethodTwo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } // RegisterServiceCHandlerServer registers the http handlers for service ServiceC to "mux". // UnaryRPC :call ServiceCServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterServiceCHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterServiceCHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ServiceCServer) error { mux.Handle(http.MethodPost, pattern_ServiceC_MethodOne_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.examplepb.ServiceC/MethodOne", runtime.WithHTTPPathPattern("/v1/example/c/1")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ServiceC_MethodOne_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ServiceC_MethodOne_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ServiceC_MethodTwo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.examplepb.ServiceC/MethodTwo", runtime.WithHTTPPathPattern("/v1/example/c/2")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ServiceC_MethodTwo_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ServiceC_MethodTwo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } // RegisterServiceAHandlerFromEndpoint is same as RegisterServiceAHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterServiceAHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterServiceAHandler(ctx, mux, conn) } // RegisterServiceAHandler registers the http handlers for service ServiceA to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterServiceAHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterServiceAHandlerClient(ctx, mux, NewServiceAClient(conn)) } // RegisterServiceAHandlerClient registers the http handlers for service ServiceA // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ServiceAClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ServiceAClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "ServiceAClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterServiceAHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ServiceAClient) error { mux.Handle(http.MethodPost, pattern_ServiceA_MethodOne_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.examplepb.ServiceA/MethodOne", runtime.WithHTTPPathPattern("/v1/example/a/1")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ServiceA_MethodOne_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ServiceA_MethodOne_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ServiceA_MethodTwo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.examplepb.ServiceA/MethodTwo", runtime.WithHTTPPathPattern("/v1/example/a/2")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ServiceA_MethodTwo_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ServiceA_MethodTwo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_ServiceA_MethodOne_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "example", "a", "1"}, "")) pattern_ServiceA_MethodTwo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "example", "a", "2"}, "")) ) var ( forward_ServiceA_MethodOne_0 = runtime.ForwardResponseMessage forward_ServiceA_MethodTwo_0 = runtime.ForwardResponseMessage ) // RegisterServiceCHandlerFromEndpoint is same as RegisterServiceCHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterServiceCHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterServiceCHandler(ctx, mux, conn) } // RegisterServiceCHandler registers the http handlers for service ServiceC to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterServiceCHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterServiceCHandlerClient(ctx, mux, NewServiceCClient(conn)) } // RegisterServiceCHandlerClient registers the http handlers for service ServiceC // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ServiceCClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ServiceCClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "ServiceCClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterServiceCHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ServiceCClient) error { mux.Handle(http.MethodPost, pattern_ServiceC_MethodOne_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.examplepb.ServiceC/MethodOne", runtime.WithHTTPPathPattern("/v1/example/c/1")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ServiceC_MethodOne_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ServiceC_MethodOne_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ServiceC_MethodTwo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.examplepb.ServiceC/MethodTwo", runtime.WithHTTPPathPattern("/v1/example/c/2")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ServiceC_MethodTwo_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ServiceC_MethodTwo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_ServiceC_MethodOne_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "example", "c", "1"}, "")) pattern_ServiceC_MethodTwo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "example", "c", "2"}, "")) ) var ( forward_ServiceC_MethodOne_0 = runtime.ForwardResponseMessage forward_ServiceC_MethodTwo_0 = runtime.ForwardResponseMessage ) ================================================ FILE: examples/internal/proto/examplepb/openapi_merge_a.proto ================================================ syntax = "proto3"; // Merging Services // // This is an example of merging two proto files. package grpc.gateway.examples.internal.examplepb; import "google/api/annotations.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; // InMessageA represents a message to ServiceA and ServiceC. message InMessageA { // Here is the explanation about InMessageA.values repeated string values = 1; } // OutMessageA represents a message returned from ServiceA. message OutMessageA { // Here is the explanation about OutMessageA.value string value = 1; } // OutMessageC represents a message returned from ServiceC. message OutMessageC { // Here is the explanation about OutMessageC.value string value = 1; } // ServiceA provides MethodOne and MethodTwo service ServiceA { // ServiceA.MethodOne receives InMessageA and returns OutMessageA // // Here is the detail explanation about ServiceA.MethodOne. rpc MethodOne(InMessageA) returns (OutMessageA) { option (google.api.http) = { post: "/v1/example/a/1" body: "*" }; } // ServiceA.MethodTwo receives OutMessageA and returns InMessageA // // Here is the detail explanation about ServiceA.MethodTwo. rpc MethodTwo(OutMessageA) returns (InMessageA) { option (google.api.http) = { post: "/v1/example/a/2" body: "*" }; } } // ServiceC service responds to incoming merge requests. service ServiceC { // ServiceC.MethodOne receives InMessageA and returns OutMessageC // // Here is the detail explanation about ServiceC.MethodOne. rpc MethodOne(InMessageA) returns (OutMessageC) { option (google.api.http) = { post: "/v1/example/c/1" body: "*" }; } // ServiceC.MethodTwo receives OutMessageA and returns InMessageA // // Here is the detail explanation about ServiceC.MethodTwo. rpc MethodTwo(OutMessageA) returns (InMessageA) { option (google.api.http) = { post: "/v1/example/c/2" body: "*" }; } } ================================================ FILE: examples/internal/proto/examplepb/openapi_merge_a.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "Merging Services", "description": "This is an example of merging two proto files.", "version": "version not set" }, "tags": [ { "name": "ServiceA" }, { "name": "ServiceC" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/v1/example/a/1": { "post": { "summary": "ServiceA.MethodOne receives InMessageA and returns OutMessageA", "description": "Here is the detail explanation about ServiceA.MethodOne.", "operationId": "ServiceA_MethodOne", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbOutMessageA" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "description": "InMessageA represents a message to ServiceA and ServiceC.", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbInMessageA" } } ], "tags": [ "ServiceA" ] } }, "/v1/example/a/2": { "post": { "summary": "ServiceA.MethodTwo receives OutMessageA and returns InMessageA", "description": "Here is the detail explanation about ServiceA.MethodTwo.", "operationId": "ServiceA_MethodTwo", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbInMessageA" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "description": "OutMessageA represents a message returned from ServiceA.", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbOutMessageA" } } ], "tags": [ "ServiceA" ] } }, "/v1/example/c/1": { "post": { "summary": "ServiceC.MethodOne receives InMessageA and returns OutMessageC", "description": "Here is the detail explanation about ServiceC.MethodOne.", "operationId": "ServiceC_MethodOne", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbOutMessageC" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "description": "InMessageA represents a message to ServiceA and ServiceC.", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbInMessageA" } } ], "tags": [ "ServiceC" ] } }, "/v1/example/c/2": { "post": { "summary": "ServiceC.MethodTwo receives OutMessageA and returns InMessageA", "description": "Here is the detail explanation about ServiceC.MethodTwo.", "operationId": "ServiceC_MethodTwo", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbInMessageA" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "description": "OutMessageA represents a message returned from ServiceA.", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbOutMessageA" } } ], "tags": [ "ServiceC" ] } } }, "definitions": { "examplepbInMessageA": { "type": "object", "properties": { "values": { "type": "array", "items": { "type": "string" }, "title": "Here is the explanation about InMessageA.values" } }, "description": "InMessageA represents a message to ServiceA and ServiceC." }, "examplepbOutMessageA": { "type": "object", "properties": { "value": { "type": "string", "title": "Here is the explanation about OutMessageA.value" } }, "description": "OutMessageA represents a message returned from ServiceA." }, "examplepbOutMessageC": { "type": "object", "properties": { "value": { "type": "string", "title": "Here is the explanation about OutMessageC.value" } }, "description": "OutMessageC represents a message returned from ServiceC." }, "googleRpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32", "description": "The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]." }, "message": { "type": "string", "description": "A developer-facing error message, which should be in English. Any\nuser-facing error message should be localized and sent in the\n[google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client." }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" }, "description": "A list of messages that carry the error details. There is a common set of\nmessage types for APIs to use." } }, "description": "The `Status` type defines a logical error model that is suitable for\ndifferent programming environments, including REST APIs and RPC APIs. It is\nused by [gRPC](https://github.com/grpc). Each `Status` message contains\nthree pieces of data: error code, error message, and error details.\n\nYou can find out more about this error model and how to work with it in the\n[API Design Guide](https://cloud.google.com/apis/design/errors)." }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string", "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics." } }, "additionalProperties": {}, "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }" } } } ================================================ FILE: examples/internal/proto/examplepb/openapi_merge_a_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: examples/internal/proto/examplepb/openapi_merge_a.proto // Merging Services // // This is an example of merging two proto files. package examplepb import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( ServiceA_MethodOne_FullMethodName = "/grpc.gateway.examples.internal.examplepb.ServiceA/MethodOne" ServiceA_MethodTwo_FullMethodName = "/grpc.gateway.examples.internal.examplepb.ServiceA/MethodTwo" ) // ServiceAClient is the client API for ServiceA service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // // ServiceA provides MethodOne and MethodTwo type ServiceAClient interface { // ServiceA.MethodOne receives InMessageA and returns OutMessageA // // Here is the detail explanation about ServiceA.MethodOne. MethodOne(ctx context.Context, in *InMessageA, opts ...grpc.CallOption) (*OutMessageA, error) // ServiceA.MethodTwo receives OutMessageA and returns InMessageA // // Here is the detail explanation about ServiceA.MethodTwo. MethodTwo(ctx context.Context, in *OutMessageA, opts ...grpc.CallOption) (*InMessageA, error) } type serviceAClient struct { cc grpc.ClientConnInterface } func NewServiceAClient(cc grpc.ClientConnInterface) ServiceAClient { return &serviceAClient{cc} } func (c *serviceAClient) MethodOne(ctx context.Context, in *InMessageA, opts ...grpc.CallOption) (*OutMessageA, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(OutMessageA) err := c.cc.Invoke(ctx, ServiceA_MethodOne_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *serviceAClient) MethodTwo(ctx context.Context, in *OutMessageA, opts ...grpc.CallOption) (*InMessageA, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(InMessageA) err := c.cc.Invoke(ctx, ServiceA_MethodTwo_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // ServiceAServer is the server API for ServiceA service. // All implementations should embed UnimplementedServiceAServer // for forward compatibility. // // ServiceA provides MethodOne and MethodTwo type ServiceAServer interface { // ServiceA.MethodOne receives InMessageA and returns OutMessageA // // Here is the detail explanation about ServiceA.MethodOne. MethodOne(context.Context, *InMessageA) (*OutMessageA, error) // ServiceA.MethodTwo receives OutMessageA and returns InMessageA // // Here is the detail explanation about ServiceA.MethodTwo. MethodTwo(context.Context, *OutMessageA) (*InMessageA, error) } // UnimplementedServiceAServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedServiceAServer struct{} func (UnimplementedServiceAServer) MethodOne(context.Context, *InMessageA) (*OutMessageA, error) { return nil, status.Errorf(codes.Unimplemented, "method MethodOne not implemented") } func (UnimplementedServiceAServer) MethodTwo(context.Context, *OutMessageA) (*InMessageA, error) { return nil, status.Errorf(codes.Unimplemented, "method MethodTwo not implemented") } func (UnimplementedServiceAServer) testEmbeddedByValue() {} // UnsafeServiceAServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to ServiceAServer will // result in compilation errors. type UnsafeServiceAServer interface { mustEmbedUnimplementedServiceAServer() } func RegisterServiceAServer(s grpc.ServiceRegistrar, srv ServiceAServer) { // If the following call pancis, it indicates UnimplementedServiceAServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&ServiceA_ServiceDesc, srv) } func _ServiceA_MethodOne_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(InMessageA) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ServiceAServer).MethodOne(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ServiceA_MethodOne_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ServiceAServer).MethodOne(ctx, req.(*InMessageA)) } return interceptor(ctx, in, info, handler) } func _ServiceA_MethodTwo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(OutMessageA) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ServiceAServer).MethodTwo(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ServiceA_MethodTwo_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ServiceAServer).MethodTwo(ctx, req.(*OutMessageA)) } return interceptor(ctx, in, info, handler) } // ServiceA_ServiceDesc is the grpc.ServiceDesc for ServiceA service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var ServiceA_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.examplepb.ServiceA", HandlerType: (*ServiceAServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "MethodOne", Handler: _ServiceA_MethodOne_Handler, }, { MethodName: "MethodTwo", Handler: _ServiceA_MethodTwo_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/internal/proto/examplepb/openapi_merge_a.proto", } const ( ServiceC_MethodOne_FullMethodName = "/grpc.gateway.examples.internal.examplepb.ServiceC/MethodOne" ServiceC_MethodTwo_FullMethodName = "/grpc.gateway.examples.internal.examplepb.ServiceC/MethodTwo" ) // ServiceCClient is the client API for ServiceC service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // // ServiceC service responds to incoming merge requests. type ServiceCClient interface { // ServiceC.MethodOne receives InMessageA and returns OutMessageC // // Here is the detail explanation about ServiceC.MethodOne. MethodOne(ctx context.Context, in *InMessageA, opts ...grpc.CallOption) (*OutMessageC, error) // ServiceC.MethodTwo receives OutMessageA and returns InMessageA // // Here is the detail explanation about ServiceC.MethodTwo. MethodTwo(ctx context.Context, in *OutMessageA, opts ...grpc.CallOption) (*InMessageA, error) } type serviceCClient struct { cc grpc.ClientConnInterface } func NewServiceCClient(cc grpc.ClientConnInterface) ServiceCClient { return &serviceCClient{cc} } func (c *serviceCClient) MethodOne(ctx context.Context, in *InMessageA, opts ...grpc.CallOption) (*OutMessageC, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(OutMessageC) err := c.cc.Invoke(ctx, ServiceC_MethodOne_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *serviceCClient) MethodTwo(ctx context.Context, in *OutMessageA, opts ...grpc.CallOption) (*InMessageA, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(InMessageA) err := c.cc.Invoke(ctx, ServiceC_MethodTwo_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // ServiceCServer is the server API for ServiceC service. // All implementations should embed UnimplementedServiceCServer // for forward compatibility. // // ServiceC service responds to incoming merge requests. type ServiceCServer interface { // ServiceC.MethodOne receives InMessageA and returns OutMessageC // // Here is the detail explanation about ServiceC.MethodOne. MethodOne(context.Context, *InMessageA) (*OutMessageC, error) // ServiceC.MethodTwo receives OutMessageA and returns InMessageA // // Here is the detail explanation about ServiceC.MethodTwo. MethodTwo(context.Context, *OutMessageA) (*InMessageA, error) } // UnimplementedServiceCServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedServiceCServer struct{} func (UnimplementedServiceCServer) MethodOne(context.Context, *InMessageA) (*OutMessageC, error) { return nil, status.Errorf(codes.Unimplemented, "method MethodOne not implemented") } func (UnimplementedServiceCServer) MethodTwo(context.Context, *OutMessageA) (*InMessageA, error) { return nil, status.Errorf(codes.Unimplemented, "method MethodTwo not implemented") } func (UnimplementedServiceCServer) testEmbeddedByValue() {} // UnsafeServiceCServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to ServiceCServer will // result in compilation errors. type UnsafeServiceCServer interface { mustEmbedUnimplementedServiceCServer() } func RegisterServiceCServer(s grpc.ServiceRegistrar, srv ServiceCServer) { // If the following call pancis, it indicates UnimplementedServiceCServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&ServiceC_ServiceDesc, srv) } func _ServiceC_MethodOne_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(InMessageA) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ServiceCServer).MethodOne(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ServiceC_MethodOne_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ServiceCServer).MethodOne(ctx, req.(*InMessageA)) } return interceptor(ctx, in, info, handler) } func _ServiceC_MethodTwo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(OutMessageA) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ServiceCServer).MethodTwo(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ServiceC_MethodTwo_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ServiceCServer).MethodTwo(ctx, req.(*OutMessageA)) } return interceptor(ctx, in, info, handler) } // ServiceC_ServiceDesc is the grpc.ServiceDesc for ServiceC service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var ServiceC_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.examplepb.ServiceC", HandlerType: (*ServiceCServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "MethodOne", Handler: _ServiceC_MethodOne_Handler, }, { MethodName: "MethodTwo", Handler: _ServiceC_MethodTwo_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/internal/proto/examplepb/openapi_merge_a.proto", } ================================================ FILE: examples/internal/proto/examplepb/openapi_merge_b.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/examplepb/openapi_merge_b.proto // Merging Services // // This is an example of merging two proto files. package examplepb import ( _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) // InMessageB represents a message to ServiceB. type InMessageB struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Here is the explanation about InMessageB.values Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` } func (x *InMessageB) Reset() { *x = InMessageB{} mi := &file_examples_internal_proto_examplepb_openapi_merge_b_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *InMessageB) String() string { return protoimpl.X.MessageStringOf(x) } func (*InMessageB) ProtoMessage() {} func (x *InMessageB) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_openapi_merge_b_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use InMessageB.ProtoReflect.Descriptor instead. func (*InMessageB) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_openapi_merge_b_proto_rawDescGZIP(), []int{0} } func (x *InMessageB) GetValue() string { if x != nil { return x.Value } return "" } // OutMessageB represents a message returned from ServiceB. type OutMessageB struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Here is the explanation about OutMessageB.value Values []string `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` } func (x *OutMessageB) Reset() { *x = OutMessageB{} mi := &file_examples_internal_proto_examplepb_openapi_merge_b_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OutMessageB) String() string { return protoimpl.X.MessageStringOf(x) } func (*OutMessageB) ProtoMessage() {} func (x *OutMessageB) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_openapi_merge_b_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use OutMessageB.ProtoReflect.Descriptor instead. func (*OutMessageB) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_openapi_merge_b_proto_rawDescGZIP(), []int{1} } func (x *OutMessageB) GetValues() []string { if x != nil { return x.Values } return nil } var File_examples_internal_proto_examplepb_openapi_merge_b_proto protoreflect.FileDescriptor var file_examples_internal_proto_examplepb_openapi_merge_b_proto_rawDesc = []byte{ 0x0a, 0x37, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x5f, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x5f, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x28, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x22, 0x0a, 0x0a, 0x49, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x25, 0x0a, 0x0b, 0x4f, 0x75, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x32, 0xb8, 0x02, 0x0a, 0x08, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x12, 0x94, 0x01, 0x0a, 0x09, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x6e, 0x65, 0x12, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x49, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x1a, 0x35, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4f, 0x75, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x3a, 0x01, 0x2a, 0x22, 0x0f, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x62, 0x2f, 0x31, 0x12, 0x94, 0x01, 0x0a, 0x09, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x54, 0x77, 0x6f, 0x12, 0x35, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4f, 0x75, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x1a, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x49, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x3a, 0x01, 0x2a, 0x22, 0x0f, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x62, 0x2f, 0x32, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_examplepb_openapi_merge_b_proto_rawDescOnce sync.Once file_examples_internal_proto_examplepb_openapi_merge_b_proto_rawDescData = file_examples_internal_proto_examplepb_openapi_merge_b_proto_rawDesc ) func file_examples_internal_proto_examplepb_openapi_merge_b_proto_rawDescGZIP() []byte { file_examples_internal_proto_examplepb_openapi_merge_b_proto_rawDescOnce.Do(func() { file_examples_internal_proto_examplepb_openapi_merge_b_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_examplepb_openapi_merge_b_proto_rawDescData) }) return file_examples_internal_proto_examplepb_openapi_merge_b_proto_rawDescData } var file_examples_internal_proto_examplepb_openapi_merge_b_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_examples_internal_proto_examplepb_openapi_merge_b_proto_goTypes = []any{ (*InMessageB)(nil), // 0: grpc.gateway.examples.internal.examplepb.InMessageB (*OutMessageB)(nil), // 1: grpc.gateway.examples.internal.examplepb.OutMessageB } var file_examples_internal_proto_examplepb_openapi_merge_b_proto_depIdxs = []int32{ 0, // 0: grpc.gateway.examples.internal.examplepb.ServiceB.MethodOne:input_type -> grpc.gateway.examples.internal.examplepb.InMessageB 1, // 1: grpc.gateway.examples.internal.examplepb.ServiceB.MethodTwo:input_type -> grpc.gateway.examples.internal.examplepb.OutMessageB 1, // 2: grpc.gateway.examples.internal.examplepb.ServiceB.MethodOne:output_type -> grpc.gateway.examples.internal.examplepb.OutMessageB 0, // 3: grpc.gateway.examples.internal.examplepb.ServiceB.MethodTwo:output_type -> grpc.gateway.examples.internal.examplepb.InMessageB 2, // [2:4] is the sub-list for method output_type 0, // [0:2] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name } func init() { file_examples_internal_proto_examplepb_openapi_merge_b_proto_init() } func file_examples_internal_proto_examplepb_openapi_merge_b_proto_init() { if File_examples_internal_proto_examplepb_openapi_merge_b_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_examplepb_openapi_merge_b_proto_rawDesc, NumEnums: 0, NumMessages: 2, NumExtensions: 0, NumServices: 1, }, GoTypes: file_examples_internal_proto_examplepb_openapi_merge_b_proto_goTypes, DependencyIndexes: file_examples_internal_proto_examplepb_openapi_merge_b_proto_depIdxs, MessageInfos: file_examples_internal_proto_examplepb_openapi_merge_b_proto_msgTypes, }.Build() File_examples_internal_proto_examplepb_openapi_merge_b_proto = out.File file_examples_internal_proto_examplepb_openapi_merge_b_proto_rawDesc = nil file_examples_internal_proto_examplepb_openapi_merge_b_proto_goTypes = nil file_examples_internal_proto_examplepb_openapi_merge_b_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/examplepb/openapi_merge_b.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/proto/examplepb/openapi_merge_b.proto /* Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package examplepb import ( "context" "errors" "io" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) func request_ServiceB_MethodOne_0(ctx context.Context, marshaler runtime.Marshaler, client ServiceBClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq InMessageB metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.MethodOne(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ServiceB_MethodOne_0(ctx context.Context, marshaler runtime.Marshaler, server ServiceBServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq InMessageB metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.MethodOne(ctx, &protoReq) return msg, metadata, err } func request_ServiceB_MethodTwo_0(ctx context.Context, marshaler runtime.Marshaler, client ServiceBClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq OutMessageB metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.MethodTwo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ServiceB_MethodTwo_0(ctx context.Context, marshaler runtime.Marshaler, server ServiceBServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq OutMessageB metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.MethodTwo(ctx, &protoReq) return msg, metadata, err } // RegisterServiceBHandlerServer registers the http handlers for service ServiceB to "mux". // UnaryRPC :call ServiceBServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterServiceBHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterServiceBHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ServiceBServer) error { mux.Handle(http.MethodPost, pattern_ServiceB_MethodOne_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.examplepb.ServiceB/MethodOne", runtime.WithHTTPPathPattern("/v1/example/b/1")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ServiceB_MethodOne_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ServiceB_MethodOne_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ServiceB_MethodTwo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.examplepb.ServiceB/MethodTwo", runtime.WithHTTPPathPattern("/v1/example/b/2")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ServiceB_MethodTwo_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ServiceB_MethodTwo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } // RegisterServiceBHandlerFromEndpoint is same as RegisterServiceBHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterServiceBHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterServiceBHandler(ctx, mux, conn) } // RegisterServiceBHandler registers the http handlers for service ServiceB to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterServiceBHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterServiceBHandlerClient(ctx, mux, NewServiceBClient(conn)) } // RegisterServiceBHandlerClient registers the http handlers for service ServiceB // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ServiceBClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ServiceBClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "ServiceBClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterServiceBHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ServiceBClient) error { mux.Handle(http.MethodPost, pattern_ServiceB_MethodOne_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.examplepb.ServiceB/MethodOne", runtime.WithHTTPPathPattern("/v1/example/b/1")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ServiceB_MethodOne_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ServiceB_MethodOne_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_ServiceB_MethodTwo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.examplepb.ServiceB/MethodTwo", runtime.WithHTTPPathPattern("/v1/example/b/2")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ServiceB_MethodTwo_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ServiceB_MethodTwo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_ServiceB_MethodOne_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "example", "b", "1"}, "")) pattern_ServiceB_MethodTwo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "example", "b", "2"}, "")) ) var ( forward_ServiceB_MethodOne_0 = runtime.ForwardResponseMessage forward_ServiceB_MethodTwo_0 = runtime.ForwardResponseMessage ) ================================================ FILE: examples/internal/proto/examplepb/openapi_merge_b.proto ================================================ syntax = "proto3"; // Merging Services // // This is an example of merging two proto files. package grpc.gateway.examples.internal.examplepb; import "google/api/annotations.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; // InMessageB represents a message to ServiceB. message InMessageB { // Here is the explanation about InMessageB.values string value = 1; } // OutMessageB represents a message returned from ServiceB. message OutMessageB { // Here is the explanation about OutMessageB.value repeated string values = 1; } // ServiceB service responds to incoming merge requests. service ServiceB { // ServiceB.MethodOne receives InMessageB and returns OutMessageB // // Here is the detail explanation about ServiceB.MethodOne. rpc MethodOne(InMessageB) returns (OutMessageB) { option (google.api.http) = { post: "/v1/example/b/1" body: "*" }; } // ServiceB.MethodTwo receives OutMessageB and returns InMessageB // // Here is the detail explanation about ServiceB.MethodTwo. rpc MethodTwo(OutMessageB) returns (InMessageB) { option (google.api.http) = { post: "/v1/example/b/2" body: "*" }; } } ================================================ FILE: examples/internal/proto/examplepb/openapi_merge_b.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "Merging Services", "description": "This is an example of merging two proto files.", "version": "version not set" }, "tags": [ { "name": "ServiceB" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/v1/example/b/1": { "post": { "summary": "ServiceB.MethodOne receives InMessageB and returns OutMessageB", "description": "Here is the detail explanation about ServiceB.MethodOne.", "operationId": "ServiceB_MethodOne", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbOutMessageB" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "description": "InMessageB represents a message to ServiceB.", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbInMessageB" } } ], "tags": [ "ServiceB" ] } }, "/v1/example/b/2": { "post": { "summary": "ServiceB.MethodTwo receives OutMessageB and returns InMessageB", "description": "Here is the detail explanation about ServiceB.MethodTwo.", "operationId": "ServiceB_MethodTwo", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbInMessageB" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "description": "OutMessageB represents a message returned from ServiceB.", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbOutMessageB" } } ], "tags": [ "ServiceB" ] } } }, "definitions": { "examplepbInMessageB": { "type": "object", "properties": { "value": { "type": "string", "title": "Here is the explanation about InMessageB.values" } }, "description": "InMessageB represents a message to ServiceB." }, "examplepbOutMessageB": { "type": "object", "properties": { "values": { "type": "array", "items": { "type": "string" }, "title": "Here is the explanation about OutMessageB.value" } }, "description": "OutMessageB represents a message returned from ServiceB." }, "googleRpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32", "description": "The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]." }, "message": { "type": "string", "description": "A developer-facing error message, which should be in English. Any\nuser-facing error message should be localized and sent in the\n[google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client." }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" }, "description": "A list of messages that carry the error details. There is a common set of\nmessage types for APIs to use." } }, "description": "The `Status` type defines a logical error model that is suitable for\ndifferent programming environments, including REST APIs and RPC APIs. It is\nused by [gRPC](https://github.com/grpc). Each `Status` message contains\nthree pieces of data: error code, error message, and error details.\n\nYou can find out more about this error model and how to work with it in the\n[API Design Guide](https://cloud.google.com/apis/design/errors)." }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string", "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics." } }, "additionalProperties": {}, "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }" } } } ================================================ FILE: examples/internal/proto/examplepb/openapi_merge_b_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: examples/internal/proto/examplepb/openapi_merge_b.proto // Merging Services // // This is an example of merging two proto files. package examplepb import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( ServiceB_MethodOne_FullMethodName = "/grpc.gateway.examples.internal.examplepb.ServiceB/MethodOne" ServiceB_MethodTwo_FullMethodName = "/grpc.gateway.examples.internal.examplepb.ServiceB/MethodTwo" ) // ServiceBClient is the client API for ServiceB service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // // ServiceB service responds to incoming merge requests. type ServiceBClient interface { // ServiceB.MethodOne receives InMessageB and returns OutMessageB // // Here is the detail explanation about ServiceB.MethodOne. MethodOne(ctx context.Context, in *InMessageB, opts ...grpc.CallOption) (*OutMessageB, error) // ServiceB.MethodTwo receives OutMessageB and returns InMessageB // // Here is the detail explanation about ServiceB.MethodTwo. MethodTwo(ctx context.Context, in *OutMessageB, opts ...grpc.CallOption) (*InMessageB, error) } type serviceBClient struct { cc grpc.ClientConnInterface } func NewServiceBClient(cc grpc.ClientConnInterface) ServiceBClient { return &serviceBClient{cc} } func (c *serviceBClient) MethodOne(ctx context.Context, in *InMessageB, opts ...grpc.CallOption) (*OutMessageB, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(OutMessageB) err := c.cc.Invoke(ctx, ServiceB_MethodOne_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *serviceBClient) MethodTwo(ctx context.Context, in *OutMessageB, opts ...grpc.CallOption) (*InMessageB, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(InMessageB) err := c.cc.Invoke(ctx, ServiceB_MethodTwo_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // ServiceBServer is the server API for ServiceB service. // All implementations should embed UnimplementedServiceBServer // for forward compatibility. // // ServiceB service responds to incoming merge requests. type ServiceBServer interface { // ServiceB.MethodOne receives InMessageB and returns OutMessageB // // Here is the detail explanation about ServiceB.MethodOne. MethodOne(context.Context, *InMessageB) (*OutMessageB, error) // ServiceB.MethodTwo receives OutMessageB and returns InMessageB // // Here is the detail explanation about ServiceB.MethodTwo. MethodTwo(context.Context, *OutMessageB) (*InMessageB, error) } // UnimplementedServiceBServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedServiceBServer struct{} func (UnimplementedServiceBServer) MethodOne(context.Context, *InMessageB) (*OutMessageB, error) { return nil, status.Errorf(codes.Unimplemented, "method MethodOne not implemented") } func (UnimplementedServiceBServer) MethodTwo(context.Context, *OutMessageB) (*InMessageB, error) { return nil, status.Errorf(codes.Unimplemented, "method MethodTwo not implemented") } func (UnimplementedServiceBServer) testEmbeddedByValue() {} // UnsafeServiceBServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to ServiceBServer will // result in compilation errors. type UnsafeServiceBServer interface { mustEmbedUnimplementedServiceBServer() } func RegisterServiceBServer(s grpc.ServiceRegistrar, srv ServiceBServer) { // If the following call pancis, it indicates UnimplementedServiceBServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&ServiceB_ServiceDesc, srv) } func _ServiceB_MethodOne_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(InMessageB) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ServiceBServer).MethodOne(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ServiceB_MethodOne_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ServiceBServer).MethodOne(ctx, req.(*InMessageB)) } return interceptor(ctx, in, info, handler) } func _ServiceB_MethodTwo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(OutMessageB) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ServiceBServer).MethodTwo(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ServiceB_MethodTwo_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ServiceBServer).MethodTwo(ctx, req.(*OutMessageB)) } return interceptor(ctx, in, info, handler) } // ServiceB_ServiceDesc is the grpc.ServiceDesc for ServiceB service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var ServiceB_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.examplepb.ServiceB", HandlerType: (*ServiceBServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "MethodOne", Handler: _ServiceB_MethodOne_Handler, }, { MethodName: "MethodTwo", Handler: _ServiceB_MethodTwo_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/internal/proto/examplepb/openapi_merge_b.proto", } ================================================ FILE: examples/internal/proto/examplepb/proto3_field_semantics.buf.gen.yaml ================================================ version: v2 plugins: - local: protoc-gen-openapiv2 out: . opt: - use_proto3_field_semantics=true ================================================ FILE: examples/internal/proto/examplepb/proto3_field_semantics.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/examplepb/proto3_field_semantics.proto package examplepb import ( _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) type GetFilterRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` } func (x *GetFilterRequest) Reset() { *x = GetFilterRequest{} mi := &file_examples_internal_proto_examplepb_proto3_field_semantics_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *GetFilterRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*GetFilterRequest) ProtoMessage() {} func (x *GetFilterRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_proto3_field_semantics_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use GetFilterRequest.ProtoReflect.Descriptor instead. func (*GetFilterRequest) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_proto3_field_semantics_proto_rawDescGZIP(), []int{0} } func (x *GetFilterRequest) GetName() string { if x != nil { return x.Name } return "" } type GetFilterResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Filter *Filter `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"` } func (x *GetFilterResponse) Reset() { *x = GetFilterResponse{} mi := &file_examples_internal_proto_examplepb_proto3_field_semantics_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *GetFilterResponse) String() string { return protoimpl.X.MessageStringOf(x) } func (*GetFilterResponse) ProtoMessage() {} func (x *GetFilterResponse) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_proto3_field_semantics_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use GetFilterResponse.ProtoReflect.Descriptor instead. func (*GetFilterResponse) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_proto3_field_semantics_proto_rawDescGZIP(), []int{1} } func (x *GetFilterResponse) GetFilter() *Filter { if x != nil { return x.Filter } return nil } type Filter struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // Types that are assignable to FilterUnion: // // *Filter_Condition // *Filter_Group FilterUnion isFilter_FilterUnion `protobuf_oneof:"filter_union"` } func (x *Filter) Reset() { *x = Filter{} mi := &file_examples_internal_proto_examplepb_proto3_field_semantics_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Filter) String() string { return protoimpl.X.MessageStringOf(x) } func (*Filter) ProtoMessage() {} func (x *Filter) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_proto3_field_semantics_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Filter.ProtoReflect.Descriptor instead. func (*Filter) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_proto3_field_semantics_proto_rawDescGZIP(), []int{2} } func (x *Filter) GetName() string { if x != nil { return x.Name } return "" } func (m *Filter) GetFilterUnion() isFilter_FilterUnion { if m != nil { return m.FilterUnion } return nil } func (x *Filter) GetCondition() *FilterCondition { if x, ok := x.GetFilterUnion().(*Filter_Condition); ok { return x.Condition } return nil } func (x *Filter) GetGroup() *FilterGroup { if x, ok := x.GetFilterUnion().(*Filter_Group); ok { return x.Group } return nil } type isFilter_FilterUnion interface { isFilter_FilterUnion() } type Filter_Condition struct { Condition *FilterCondition `protobuf:"bytes,2,opt,name=condition,proto3,oneof"` } type Filter_Group struct { Group *FilterGroup `protobuf:"bytes,3,opt,name=group,proto3,oneof"` } func (*Filter_Condition) isFilter_FilterUnion() {} func (*Filter_Group) isFilter_FilterUnion() {} type FilterCondition struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Field string `protobuf:"bytes,1,opt,name=field,proto3" json:"field,omitempty"` Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` } func (x *FilterCondition) Reset() { *x = FilterCondition{} mi := &file_examples_internal_proto_examplepb_proto3_field_semantics_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *FilterCondition) String() string { return protoimpl.X.MessageStringOf(x) } func (*FilterCondition) ProtoMessage() {} func (x *FilterCondition) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_proto3_field_semantics_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use FilterCondition.ProtoReflect.Descriptor instead. func (*FilterCondition) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_proto3_field_semantics_proto_rawDescGZIP(), []int{3} } func (x *FilterCondition) GetField() string { if x != nil { return x.Field } return "" } func (x *FilterCondition) GetValue() string { if x != nil { return x.Value } return "" } type FilterGroup struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Filters []*Filter `protobuf:"bytes,1,rep,name=filters,proto3" json:"filters,omitempty"` Operator string `protobuf:"bytes,2,opt,name=operator,proto3" json:"operator,omitempty"` } func (x *FilterGroup) Reset() { *x = FilterGroup{} mi := &file_examples_internal_proto_examplepb_proto3_field_semantics_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *FilterGroup) String() string { return protoimpl.X.MessageStringOf(x) } func (*FilterGroup) ProtoMessage() {} func (x *FilterGroup) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_proto3_field_semantics_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use FilterGroup.ProtoReflect.Descriptor instead. func (*FilterGroup) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_proto3_field_semantics_proto_rawDescGZIP(), []int{4} } func (x *FilterGroup) GetFilters() []*Filter { if x != nil { return x.Filters } return nil } func (x *FilterGroup) GetOperator() string { if x != nil { return x.Operator } return "" } var File_examples_internal_proto_examplepb_proto3_field_semantics_proto protoreflect.FileDescriptor var file_examples_internal_proto_examplepb_proto3_field_semantics_proto_rawDesc = []byte{ 0x0a, 0x3e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x73, 0x65, 0x6d, 0x61, 0x6e, 0x74, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x26, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x63, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4e, 0x0a, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x22, 0xe2, 0x01, 0x0a, 0x06, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x5f, 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x3f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x09, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x53, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x3b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x48, 0x00, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x42, 0x0e, 0x0a, 0x0c, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x5f, 0x75, 0x6e, 0x69, 0x6f, 0x6e, 0x22, 0x3d, 0x0a, 0x0f, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x7b, 0x0a, 0x0b, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x50, 0x0a, 0x07, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x07, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x32, 0xc4, 0x01, 0x0a, 0x1b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x53, 0x65, 0x6d, 0x61, 0x6e, 0x74, 0x69, 0x63, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xa4, 0x01, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x41, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x47, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x12, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0c, 0x12, 0x0a, 0x2f, 0x76, 0x31, 0x2f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_examplepb_proto3_field_semantics_proto_rawDescOnce sync.Once file_examples_internal_proto_examplepb_proto3_field_semantics_proto_rawDescData = file_examples_internal_proto_examplepb_proto3_field_semantics_proto_rawDesc ) func file_examples_internal_proto_examplepb_proto3_field_semantics_proto_rawDescGZIP() []byte { file_examples_internal_proto_examplepb_proto3_field_semantics_proto_rawDescOnce.Do(func() { file_examples_internal_proto_examplepb_proto3_field_semantics_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_examplepb_proto3_field_semantics_proto_rawDescData) }) return file_examples_internal_proto_examplepb_proto3_field_semantics_proto_rawDescData } var file_examples_internal_proto_examplepb_proto3_field_semantics_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_examples_internal_proto_examplepb_proto3_field_semantics_proto_goTypes = []any{ (*GetFilterRequest)(nil), // 0: grpc.gateway.examples.internal.proto.examplepb.GetFilterRequest (*GetFilterResponse)(nil), // 1: grpc.gateway.examples.internal.proto.examplepb.GetFilterResponse (*Filter)(nil), // 2: grpc.gateway.examples.internal.proto.examplepb.Filter (*FilterCondition)(nil), // 3: grpc.gateway.examples.internal.proto.examplepb.FilterCondition (*FilterGroup)(nil), // 4: grpc.gateway.examples.internal.proto.examplepb.FilterGroup } var file_examples_internal_proto_examplepb_proto3_field_semantics_proto_depIdxs = []int32{ 2, // 0: grpc.gateway.examples.internal.proto.examplepb.GetFilterResponse.filter:type_name -> grpc.gateway.examples.internal.proto.examplepb.Filter 3, // 1: grpc.gateway.examples.internal.proto.examplepb.Filter.condition:type_name -> grpc.gateway.examples.internal.proto.examplepb.FilterCondition 4, // 2: grpc.gateway.examples.internal.proto.examplepb.Filter.group:type_name -> grpc.gateway.examples.internal.proto.examplepb.FilterGroup 2, // 3: grpc.gateway.examples.internal.proto.examplepb.FilterGroup.filters:type_name -> grpc.gateway.examples.internal.proto.examplepb.Filter 0, // 4: grpc.gateway.examples.internal.proto.examplepb.Proto3FieldSemanticsService.GetFilter:input_type -> grpc.gateway.examples.internal.proto.examplepb.GetFilterRequest 1, // 5: grpc.gateway.examples.internal.proto.examplepb.Proto3FieldSemanticsService.GetFilter:output_type -> grpc.gateway.examples.internal.proto.examplepb.GetFilterResponse 5, // [5:6] is the sub-list for method output_type 4, // [4:5] is the sub-list for method input_type 4, // [4:4] is the sub-list for extension type_name 4, // [4:4] is the sub-list for extension extendee 0, // [0:4] is the sub-list for field type_name } func init() { file_examples_internal_proto_examplepb_proto3_field_semantics_proto_init() } func file_examples_internal_proto_examplepb_proto3_field_semantics_proto_init() { if File_examples_internal_proto_examplepb_proto3_field_semantics_proto != nil { return } file_examples_internal_proto_examplepb_proto3_field_semantics_proto_msgTypes[2].OneofWrappers = []any{ (*Filter_Condition)(nil), (*Filter_Group)(nil), } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_examplepb_proto3_field_semantics_proto_rawDesc, NumEnums: 0, NumMessages: 5, NumExtensions: 0, NumServices: 1, }, GoTypes: file_examples_internal_proto_examplepb_proto3_field_semantics_proto_goTypes, DependencyIndexes: file_examples_internal_proto_examplepb_proto3_field_semantics_proto_depIdxs, MessageInfos: file_examples_internal_proto_examplepb_proto3_field_semantics_proto_msgTypes, }.Build() File_examples_internal_proto_examplepb_proto3_field_semantics_proto = out.File file_examples_internal_proto_examplepb_proto3_field_semantics_proto_rawDesc = nil file_examples_internal_proto_examplepb_proto3_field_semantics_proto_goTypes = nil file_examples_internal_proto_examplepb_proto3_field_semantics_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/examplepb/proto3_field_semantics.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/proto/examplepb/proto3_field_semantics.proto /* Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package examplepb import ( "context" "errors" "io" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) var filter_Proto3FieldSemanticsService_GetFilter_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_Proto3FieldSemanticsService_GetFilter_0(ctx context.Context, marshaler runtime.Marshaler, client Proto3FieldSemanticsServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq GetFilterRequest metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Proto3FieldSemanticsService_GetFilter_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.GetFilter(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_Proto3FieldSemanticsService_GetFilter_0(ctx context.Context, marshaler runtime.Marshaler, server Proto3FieldSemanticsServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq GetFilterRequest metadata runtime.ServerMetadata ) if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Proto3FieldSemanticsService_GetFilter_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.GetFilter(ctx, &protoReq) return msg, metadata, err } // RegisterProto3FieldSemanticsServiceHandlerServer registers the http handlers for service Proto3FieldSemanticsService to "mux". // UnaryRPC :call Proto3FieldSemanticsServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterProto3FieldSemanticsServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterProto3FieldSemanticsServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server Proto3FieldSemanticsServiceServer) error { mux.Handle(http.MethodGet, pattern_Proto3FieldSemanticsService_GetFilter_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.Proto3FieldSemanticsService/GetFilter", runtime.WithHTTPPathPattern("/v1/filter")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_Proto3FieldSemanticsService_GetFilter_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Proto3FieldSemanticsService_GetFilter_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } // RegisterProto3FieldSemanticsServiceHandlerFromEndpoint is same as RegisterProto3FieldSemanticsServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterProto3FieldSemanticsServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterProto3FieldSemanticsServiceHandler(ctx, mux, conn) } // RegisterProto3FieldSemanticsServiceHandler registers the http handlers for service Proto3FieldSemanticsService to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterProto3FieldSemanticsServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterProto3FieldSemanticsServiceHandlerClient(ctx, mux, NewProto3FieldSemanticsServiceClient(conn)) } // RegisterProto3FieldSemanticsServiceHandlerClient registers the http handlers for service Proto3FieldSemanticsService // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "Proto3FieldSemanticsServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "Proto3FieldSemanticsServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "Proto3FieldSemanticsServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterProto3FieldSemanticsServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client Proto3FieldSemanticsServiceClient) error { mux.Handle(http.MethodGet, pattern_Proto3FieldSemanticsService_GetFilter_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.Proto3FieldSemanticsService/GetFilter", runtime.WithHTTPPathPattern("/v1/filter")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_Proto3FieldSemanticsService_GetFilter_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Proto3FieldSemanticsService_GetFilter_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_Proto3FieldSemanticsService_GetFilter_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "filter"}, "")) ) var ( forward_Proto3FieldSemanticsService_GetFilter_0 = runtime.ForwardResponseMessage ) ================================================ FILE: examples/internal/proto/examplepb/proto3_field_semantics.proto ================================================ syntax = "proto3"; package grpc.gateway.examples.internal.proto.examplepb; import "google/api/annotations.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; service Proto3FieldSemanticsService { rpc GetFilter(GetFilterRequest) returns (GetFilterResponse) { option (google.api.http) = {get: "/v1/filter"}; } } message GetFilterRequest { string name = 1; } message GetFilterResponse { Filter filter = 1; } message Filter { string name = 1; oneof filter_union { FilterCondition condition = 2; FilterGroup group = 3; } } message FilterCondition { string field = 1; string value = 2; } message FilterGroup { repeated Filter filters = 1; string operator = 2; } ================================================ FILE: examples/internal/proto/examplepb/proto3_field_semantics.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/examplepb/proto3_field_semantics.proto", "version": "version not set" }, "tags": [ { "name": "Proto3FieldSemanticsService" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/v1/filter": { "get": { "operationId": "Proto3FieldSemanticsService_GetFilter", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbGetFilterResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "name", "in": "query", "required": true, "type": "string" } ], "tags": [ "Proto3FieldSemanticsService" ] } } }, "definitions": { "examplepbFilter": { "type": "object", "properties": { "name": { "type": "string" }, "condition": { "$ref": "#/definitions/examplepbFilterCondition" }, "group": { "$ref": "#/definitions/examplepbFilterGroup" } }, "required": [ "name" ] }, "examplepbFilterCondition": { "type": "object", "properties": { "field": { "type": "string" }, "value": { "type": "string" } }, "required": [ "field", "value" ] }, "examplepbFilterGroup": { "type": "object", "properties": { "filters": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/examplepbFilter" } }, "operator": { "type": "string" } }, "required": [ "filters", "operator" ] }, "examplepbGetFilterResponse": { "type": "object", "properties": { "filter": { "$ref": "#/definitions/examplepbFilter" } }, "required": [ "filter" ] }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string" } }, "additionalProperties": {}, "required": [ "typeUrl", "value" ] }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } }, "required": [ "code", "message", "details" ] } } } ================================================ FILE: examples/internal/proto/examplepb/proto3_field_semantics_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: examples/internal/proto/examplepb/proto3_field_semantics.proto package examplepb import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( Proto3FieldSemanticsService_GetFilter_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.Proto3FieldSemanticsService/GetFilter" ) // Proto3FieldSemanticsServiceClient is the client API for Proto3FieldSemanticsService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type Proto3FieldSemanticsServiceClient interface { GetFilter(ctx context.Context, in *GetFilterRequest, opts ...grpc.CallOption) (*GetFilterResponse, error) } type proto3FieldSemanticsServiceClient struct { cc grpc.ClientConnInterface } func NewProto3FieldSemanticsServiceClient(cc grpc.ClientConnInterface) Proto3FieldSemanticsServiceClient { return &proto3FieldSemanticsServiceClient{cc} } func (c *proto3FieldSemanticsServiceClient) GetFilter(ctx context.Context, in *GetFilterRequest, opts ...grpc.CallOption) (*GetFilterResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(GetFilterResponse) err := c.cc.Invoke(ctx, Proto3FieldSemanticsService_GetFilter_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // Proto3FieldSemanticsServiceServer is the server API for Proto3FieldSemanticsService service. // All implementations should embed UnimplementedProto3FieldSemanticsServiceServer // for forward compatibility. type Proto3FieldSemanticsServiceServer interface { GetFilter(context.Context, *GetFilterRequest) (*GetFilterResponse, error) } // UnimplementedProto3FieldSemanticsServiceServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedProto3FieldSemanticsServiceServer struct{} func (UnimplementedProto3FieldSemanticsServiceServer) GetFilter(context.Context, *GetFilterRequest) (*GetFilterResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetFilter not implemented") } func (UnimplementedProto3FieldSemanticsServiceServer) testEmbeddedByValue() {} // UnsafeProto3FieldSemanticsServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to Proto3FieldSemanticsServiceServer will // result in compilation errors. type UnsafeProto3FieldSemanticsServiceServer interface { mustEmbedUnimplementedProto3FieldSemanticsServiceServer() } func RegisterProto3FieldSemanticsServiceServer(s grpc.ServiceRegistrar, srv Proto3FieldSemanticsServiceServer) { // If the following call pancis, it indicates UnimplementedProto3FieldSemanticsServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&Proto3FieldSemanticsService_ServiceDesc, srv) } func _Proto3FieldSemanticsService_GetFilter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GetFilterRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(Proto3FieldSemanticsServiceServer).GetFilter(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: Proto3FieldSemanticsService_GetFilter_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(Proto3FieldSemanticsServiceServer).GetFilter(ctx, req.(*GetFilterRequest)) } return interceptor(ctx, in, info, handler) } // Proto3FieldSemanticsService_ServiceDesc is the grpc.ServiceDesc for Proto3FieldSemanticsService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var Proto3FieldSemanticsService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.Proto3FieldSemanticsService", HandlerType: (*Proto3FieldSemanticsServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "GetFilter", Handler: _Proto3FieldSemanticsService_GetFilter_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/internal/proto/examplepb/proto3_field_semantics.proto", } ================================================ FILE: examples/internal/proto/examplepb/remove_internal_comment.buf.gen.yaml ================================================ version: v2 plugins: - local: protoc-gen-openapiv2 out: . opt: - remove_internal_comments=true ================================================ FILE: examples/internal/proto/examplepb/remove_internal_comment.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/examplepb/remove_internal_comment.proto package examplepb import ( _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) // Foo2Request (-- This comment should be excluded from OpenAPI output --) type Foo2Request struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Username. // (-- This comment should be excluded // from OpenAPI output --) // Same row, single line break doesn't count on markdown. Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` // Password. // (-- This comment should be excluded // from OpenAPI output --) // // New row. Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` } func (x *Foo2Request) Reset() { *x = Foo2Request{} mi := &file_examples_internal_proto_examplepb_remove_internal_comment_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Foo2Request) String() string { return protoimpl.X.MessageStringOf(x) } func (*Foo2Request) ProtoMessage() {} func (x *Foo2Request) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_remove_internal_comment_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Foo2Request.ProtoReflect.Descriptor instead. func (*Foo2Request) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_remove_internal_comment_proto_rawDescGZIP(), []int{0} } func (x *Foo2Request) GetUsername() string { if x != nil { return x.Username } return "" } func (x *Foo2Request) GetPassword() string { if x != nil { return x.Password } return "" } // (-- This comment should be excluded from OpenAPI output --) type Foo2Reply struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields } func (x *Foo2Reply) Reset() { *x = Foo2Reply{} mi := &file_examples_internal_proto_examplepb_remove_internal_comment_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Foo2Reply) String() string { return protoimpl.X.MessageStringOf(x) } func (*Foo2Reply) ProtoMessage() {} func (x *Foo2Reply) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_remove_internal_comment_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Foo2Reply.ProtoReflect.Descriptor instead. func (*Foo2Reply) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_remove_internal_comment_proto_rawDescGZIP(), []int{1} } var File_examples_internal_proto_examplepb_remove_internal_comment_proto protoreflect.FileDescriptor var file_examples_internal_proto_examplepb_remove_internal_comment_proto_rawDesc = []byte{ 0x0a, 0x3f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x45, 0x0a, 0x0b, 0x46, 0x6f, 0x6f, 0x32, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x0b, 0x0a, 0x09, 0x46, 0x6f, 0x6f, 0x32, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x32, 0xaa, 0x01, 0x0a, 0x0b, 0x46, 0x6f, 0x6f, 0x32, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x9a, 0x01, 0x0a, 0x04, 0x46, 0x6f, 0x6f, 0x32, 0x12, 0x3b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x46, 0x6f, 0x6f, 0x32, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x39, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x46, 0x6f, 0x6f, 0x32, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x3a, 0x01, 0x2a, 0x22, 0x0f, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x66, 0x6f, 0x6f, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_examplepb_remove_internal_comment_proto_rawDescOnce sync.Once file_examples_internal_proto_examplepb_remove_internal_comment_proto_rawDescData = file_examples_internal_proto_examplepb_remove_internal_comment_proto_rawDesc ) func file_examples_internal_proto_examplepb_remove_internal_comment_proto_rawDescGZIP() []byte { file_examples_internal_proto_examplepb_remove_internal_comment_proto_rawDescOnce.Do(func() { file_examples_internal_proto_examplepb_remove_internal_comment_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_examplepb_remove_internal_comment_proto_rawDescData) }) return file_examples_internal_proto_examplepb_remove_internal_comment_proto_rawDescData } var file_examples_internal_proto_examplepb_remove_internal_comment_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_examples_internal_proto_examplepb_remove_internal_comment_proto_goTypes = []any{ (*Foo2Request)(nil), // 0: grpc.gateway.examples.internal.proto.examplepb.Foo2Request (*Foo2Reply)(nil), // 1: grpc.gateway.examples.internal.proto.examplepb.Foo2Reply } var file_examples_internal_proto_examplepb_remove_internal_comment_proto_depIdxs = []int32{ 0, // 0: grpc.gateway.examples.internal.proto.examplepb.Foo2Service.Foo2:input_type -> grpc.gateway.examples.internal.proto.examplepb.Foo2Request 1, // 1: grpc.gateway.examples.internal.proto.examplepb.Foo2Service.Foo2:output_type -> grpc.gateway.examples.internal.proto.examplepb.Foo2Reply 1, // [1:2] is the sub-list for method output_type 0, // [0:1] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name } func init() { file_examples_internal_proto_examplepb_remove_internal_comment_proto_init() } func file_examples_internal_proto_examplepb_remove_internal_comment_proto_init() { if File_examples_internal_proto_examplepb_remove_internal_comment_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_examplepb_remove_internal_comment_proto_rawDesc, NumEnums: 0, NumMessages: 2, NumExtensions: 0, NumServices: 1, }, GoTypes: file_examples_internal_proto_examplepb_remove_internal_comment_proto_goTypes, DependencyIndexes: file_examples_internal_proto_examplepb_remove_internal_comment_proto_depIdxs, MessageInfos: file_examples_internal_proto_examplepb_remove_internal_comment_proto_msgTypes, }.Build() File_examples_internal_proto_examplepb_remove_internal_comment_proto = out.File file_examples_internal_proto_examplepb_remove_internal_comment_proto_rawDesc = nil file_examples_internal_proto_examplepb_remove_internal_comment_proto_goTypes = nil file_examples_internal_proto_examplepb_remove_internal_comment_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/examplepb/remove_internal_comment.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/proto/examplepb/remove_internal_comment.proto /* Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package examplepb import ( "context" "errors" "io" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) func request_Foo2Service_Foo2_0(ctx context.Context, marshaler runtime.Marshaler, client Foo2ServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq Foo2Request metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.Foo2(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_Foo2Service_Foo2_0(ctx context.Context, marshaler runtime.Marshaler, server Foo2ServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq Foo2Request metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Foo2(ctx, &protoReq) return msg, metadata, err } // RegisterFoo2ServiceHandlerServer registers the http handlers for service Foo2Service to "mux". // UnaryRPC :call Foo2ServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterFoo2ServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterFoo2ServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server Foo2ServiceServer) error { mux.Handle(http.MethodPost, pattern_Foo2Service_Foo2_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.Foo2Service/Foo2", runtime.WithHTTPPathPattern("/v1/example/foo")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_Foo2Service_Foo2_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Foo2Service_Foo2_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } // RegisterFoo2ServiceHandlerFromEndpoint is same as RegisterFoo2ServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterFoo2ServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterFoo2ServiceHandler(ctx, mux, conn) } // RegisterFoo2ServiceHandler registers the http handlers for service Foo2Service to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterFoo2ServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterFoo2ServiceHandlerClient(ctx, mux, NewFoo2ServiceClient(conn)) } // RegisterFoo2ServiceHandlerClient registers the http handlers for service Foo2Service // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "Foo2ServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "Foo2ServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "Foo2ServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterFoo2ServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client Foo2ServiceClient) error { mux.Handle(http.MethodPost, pattern_Foo2Service_Foo2_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.Foo2Service/Foo2", runtime.WithHTTPPathPattern("/v1/example/foo")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_Foo2Service_Foo2_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_Foo2Service_Foo2_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_Foo2Service_Foo2_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "foo"}, "")) ) var ( forward_Foo2Service_Foo2_0 = runtime.ForwardResponseMessage ) ================================================ FILE: examples/internal/proto/examplepb/remove_internal_comment.proto ================================================ syntax = "proto3"; package grpc.gateway.examples.internal.proto.examplepb; import "google/api/annotations.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; // Foo2Service (-- This comment should be excluded from OpenAPI output --) service Foo2Service { // Foo Summary (-- This comment should be excluded from OpenAPI output --) // // (-- This comment should be excluded from OpenAPI output --) // Description rpc Foo2(Foo2Request) returns (Foo2Reply) { option (google.api.http) = { post: "/v1/example/foo" body: "*" }; } } // Foo2Request (-- This comment should be excluded from OpenAPI output --) message Foo2Request { // Username. // (-- This comment should be excluded // from OpenAPI output --) // Same row, single line break doesn't count on markdown. string username = 1; // Password. // (-- This comment should be excluded // from OpenAPI output --) // // New row. string password = 2; } // (-- This comment should be excluded from OpenAPI output --) message Foo2Reply {} ================================================ FILE: examples/internal/proto/examplepb/remove_internal_comment.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/examplepb/remove_internal_comment.proto", "version": "version not set" }, "tags": [ { "name": "Foo2Service" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/v1/example/foo": { "post": { "summary": "Foo Summary", "description": "Description", "operationId": "Foo2Service_Foo2", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbFoo2Reply" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbFoo2Request" } } ], "tags": [ "Foo2Service" ] } } }, "definitions": { "examplepbFoo2Reply": { "type": "object" }, "examplepbFoo2Request": { "type": "object", "properties": { "username": { "type": "string", "description": "Username.\nSame row, single line break doesn't count on markdown." }, "password": { "type": "string", "description": "Password.\n\nNew row." } }, "title": "Foo2Request" }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string" } }, "additionalProperties": {} }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } } } } ================================================ FILE: examples/internal/proto/examplepb/remove_internal_comment_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: examples/internal/proto/examplepb/remove_internal_comment.proto package examplepb import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( Foo2Service_Foo2_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.Foo2Service/Foo2" ) // Foo2ServiceClient is the client API for Foo2Service service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // // Foo2Service (-- This comment should be excluded from OpenAPI output --) type Foo2ServiceClient interface { // Foo Summary (-- This comment should be excluded from OpenAPI output --) // // (-- This comment should be excluded from OpenAPI output --) // Description Foo2(ctx context.Context, in *Foo2Request, opts ...grpc.CallOption) (*Foo2Reply, error) } type foo2ServiceClient struct { cc grpc.ClientConnInterface } func NewFoo2ServiceClient(cc grpc.ClientConnInterface) Foo2ServiceClient { return &foo2ServiceClient{cc} } func (c *foo2ServiceClient) Foo2(ctx context.Context, in *Foo2Request, opts ...grpc.CallOption) (*Foo2Reply, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Foo2Reply) err := c.cc.Invoke(ctx, Foo2Service_Foo2_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // Foo2ServiceServer is the server API for Foo2Service service. // All implementations should embed UnimplementedFoo2ServiceServer // for forward compatibility. // // Foo2Service (-- This comment should be excluded from OpenAPI output --) type Foo2ServiceServer interface { // Foo Summary (-- This comment should be excluded from OpenAPI output --) // // (-- This comment should be excluded from OpenAPI output --) // Description Foo2(context.Context, *Foo2Request) (*Foo2Reply, error) } // UnimplementedFoo2ServiceServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedFoo2ServiceServer struct{} func (UnimplementedFoo2ServiceServer) Foo2(context.Context, *Foo2Request) (*Foo2Reply, error) { return nil, status.Errorf(codes.Unimplemented, "method Foo2 not implemented") } func (UnimplementedFoo2ServiceServer) testEmbeddedByValue() {} // UnsafeFoo2ServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to Foo2ServiceServer will // result in compilation errors. type UnsafeFoo2ServiceServer interface { mustEmbedUnimplementedFoo2ServiceServer() } func RegisterFoo2ServiceServer(s grpc.ServiceRegistrar, srv Foo2ServiceServer) { // If the following call pancis, it indicates UnimplementedFoo2ServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&Foo2Service_ServiceDesc, srv) } func _Foo2Service_Foo2_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(Foo2Request) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(Foo2ServiceServer).Foo2(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: Foo2Service_Foo2_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(Foo2ServiceServer).Foo2(ctx, req.(*Foo2Request)) } return interceptor(ctx, in, info, handler) } // Foo2Service_ServiceDesc is the grpc.ServiceDesc for Foo2Service service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var Foo2Service_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.Foo2Service", HandlerType: (*Foo2ServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Foo2", Handler: _Foo2Service_Foo2_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/internal/proto/examplepb/remove_internal_comment.proto", } ================================================ FILE: examples/internal/proto/examplepb/response_body_service.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/examplepb/response_body_service.proto package examplepb import ( _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) type RepeatedResponseBodyOut_Response_ResponseType int32 const ( // UNKNOWN RepeatedResponseBodyOut_Response_UNKNOWN RepeatedResponseBodyOut_Response_ResponseType = 0 // A is 1 RepeatedResponseBodyOut_Response_A RepeatedResponseBodyOut_Response_ResponseType = 1 // B is 2 RepeatedResponseBodyOut_Response_B RepeatedResponseBodyOut_Response_ResponseType = 2 ) // Enum value maps for RepeatedResponseBodyOut_Response_ResponseType. var ( RepeatedResponseBodyOut_Response_ResponseType_name = map[int32]string{ 0: "UNKNOWN", 1: "A", 2: "B", } RepeatedResponseBodyOut_Response_ResponseType_value = map[string]int32{ "UNKNOWN": 0, "A": 1, "B": 2, } ) func (x RepeatedResponseBodyOut_Response_ResponseType) Enum() *RepeatedResponseBodyOut_Response_ResponseType { p := new(RepeatedResponseBodyOut_Response_ResponseType) *p = x return p } func (x RepeatedResponseBodyOut_Response_ResponseType) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (RepeatedResponseBodyOut_Response_ResponseType) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_examplepb_response_body_service_proto_enumTypes[0].Descriptor() } func (RepeatedResponseBodyOut_Response_ResponseType) Type() protoreflect.EnumType { return &file_examples_internal_proto_examplepb_response_body_service_proto_enumTypes[0] } func (x RepeatedResponseBodyOut_Response_ResponseType) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use RepeatedResponseBodyOut_Response_ResponseType.Descriptor instead. func (RepeatedResponseBodyOut_Response_ResponseType) EnumDescriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_response_body_service_proto_rawDescGZIP(), []int{2, 0, 0} } type ResponseBodyIn struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Data string `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` } func (x *ResponseBodyIn) Reset() { *x = ResponseBodyIn{} mi := &file_examples_internal_proto_examplepb_response_body_service_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *ResponseBodyIn) String() string { return protoimpl.X.MessageStringOf(x) } func (*ResponseBodyIn) ProtoMessage() {} func (x *ResponseBodyIn) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_response_body_service_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use ResponseBodyIn.ProtoReflect.Descriptor instead. func (*ResponseBodyIn) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_response_body_service_proto_rawDescGZIP(), []int{0} } func (x *ResponseBodyIn) GetData() string { if x != nil { return x.Data } return "" } type ResponseBodyOut struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Response *ResponseBodyOut_Response `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"` } func (x *ResponseBodyOut) Reset() { *x = ResponseBodyOut{} mi := &file_examples_internal_proto_examplepb_response_body_service_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *ResponseBodyOut) String() string { return protoimpl.X.MessageStringOf(x) } func (*ResponseBodyOut) ProtoMessage() {} func (x *ResponseBodyOut) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_response_body_service_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use ResponseBodyOut.ProtoReflect.Descriptor instead. func (*ResponseBodyOut) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_response_body_service_proto_rawDescGZIP(), []int{1} } func (x *ResponseBodyOut) GetResponse() *ResponseBodyOut_Response { if x != nil { return x.Response } return nil } type RepeatedResponseBodyOut struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Response []*RepeatedResponseBodyOut_Response `protobuf:"bytes,2,rep,name=response,proto3" json:"response,omitempty"` } func (x *RepeatedResponseBodyOut) Reset() { *x = RepeatedResponseBodyOut{} mi := &file_examples_internal_proto_examplepb_response_body_service_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *RepeatedResponseBodyOut) String() string { return protoimpl.X.MessageStringOf(x) } func (*RepeatedResponseBodyOut) ProtoMessage() {} func (x *RepeatedResponseBodyOut) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_response_body_service_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use RepeatedResponseBodyOut.ProtoReflect.Descriptor instead. func (*RepeatedResponseBodyOut) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_response_body_service_proto_rawDescGZIP(), []int{2} } func (x *RepeatedResponseBodyOut) GetResponse() []*RepeatedResponseBodyOut_Response { if x != nil { return x.Response } return nil } type RepeatedResponseStrings struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Values []string `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"` } func (x *RepeatedResponseStrings) Reset() { *x = RepeatedResponseStrings{} mi := &file_examples_internal_proto_examplepb_response_body_service_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *RepeatedResponseStrings) String() string { return protoimpl.X.MessageStringOf(x) } func (*RepeatedResponseStrings) ProtoMessage() {} func (x *RepeatedResponseStrings) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_response_body_service_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use RepeatedResponseStrings.ProtoReflect.Descriptor instead. func (*RepeatedResponseStrings) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_response_body_service_proto_rawDescGZIP(), []int{3} } func (x *RepeatedResponseStrings) GetValues() []string { if x != nil { return x.Values } return nil } type ResponseBodyValue struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields ResponseBodyValue string `protobuf:"bytes,1,opt,name=response_body_value,json=responseBodyValue,proto3" json:"response_body_value,omitempty"` } func (x *ResponseBodyValue) Reset() { *x = ResponseBodyValue{} mi := &file_examples_internal_proto_examplepb_response_body_service_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *ResponseBodyValue) String() string { return protoimpl.X.MessageStringOf(x) } func (*ResponseBodyValue) ProtoMessage() {} func (x *ResponseBodyValue) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_response_body_service_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use ResponseBodyValue.ProtoReflect.Descriptor instead. func (*ResponseBodyValue) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_response_body_service_proto_rawDescGZIP(), []int{4} } func (x *ResponseBodyValue) GetResponseBodyValue() string { if x != nil { return x.ResponseBodyValue } return "" } type ResponseBodyOut_Response struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Data string `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` } func (x *ResponseBodyOut_Response) Reset() { *x = ResponseBodyOut_Response{} mi := &file_examples_internal_proto_examplepb_response_body_service_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *ResponseBodyOut_Response) String() string { return protoimpl.X.MessageStringOf(x) } func (*ResponseBodyOut_Response) ProtoMessage() {} func (x *ResponseBodyOut_Response) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_response_body_service_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use ResponseBodyOut_Response.ProtoReflect.Descriptor instead. func (*ResponseBodyOut_Response) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_response_body_service_proto_rawDescGZIP(), []int{1, 0} } func (x *ResponseBodyOut_Response) GetData() string { if x != nil { return x.Data } return "" } type RepeatedResponseBodyOut_Response struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Data string `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` Type RepeatedResponseBodyOut_Response_ResponseType `protobuf:"varint,3,opt,name=type,proto3,enum=grpc.gateway.examples.internal.proto.examplepb.RepeatedResponseBodyOut_Response_ResponseType" json:"type,omitempty"` } func (x *RepeatedResponseBodyOut_Response) Reset() { *x = RepeatedResponseBodyOut_Response{} mi := &file_examples_internal_proto_examplepb_response_body_service_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *RepeatedResponseBodyOut_Response) String() string { return protoimpl.X.MessageStringOf(x) } func (*RepeatedResponseBodyOut_Response) ProtoMessage() {} func (x *RepeatedResponseBodyOut_Response) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_response_body_service_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use RepeatedResponseBodyOut_Response.ProtoReflect.Descriptor instead. func (*RepeatedResponseBodyOut_Response) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_response_body_service_proto_rawDescGZIP(), []int{2, 0} } func (x *RepeatedResponseBodyOut_Response) GetData() string { if x != nil { return x.Data } return "" } func (x *RepeatedResponseBodyOut_Response) GetType() RepeatedResponseBodyOut_Response_ResponseType { if x != nil { return x.Type } return RepeatedResponseBodyOut_Response_UNKNOWN } var File_examples_internal_proto_examplepb_response_body_service_proto protoreflect.FileDescriptor var file_examples_internal_proto_examplepb_response_body_service_proto_rawDesc = []byte{ 0x0a, 0x3d, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x62, 0x6f, 0x64, 0x79, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x24, 0x0a, 0x0e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x49, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x97, 0x01, 0x0a, 0x0f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x4f, 0x75, 0x74, 0x12, 0x64, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x48, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x4f, 0x75, 0x74, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x1e, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xc6, 0x02, 0x0a, 0x17, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x4f, 0x75, 0x74, 0x12, 0x6c, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x50, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x4f, 0x75, 0x74, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0xbc, 0x01, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x71, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x5d, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x4f, 0x75, 0x74, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x29, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x05, 0x0a, 0x01, 0x41, 0x10, 0x01, 0x12, 0x05, 0x0a, 0x01, 0x42, 0x10, 0x02, 0x22, 0x31, 0x0a, 0x17, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, 0x43, 0x0a, 0x11, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x2e, 0x0a, 0x13, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x62, 0x6f, 0x64, 0x79, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x32, 0x8d, 0x08, 0x0a, 0x13, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xba, 0x01, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x3e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x49, 0x6e, 0x1a, 0x3f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x4f, 0x75, 0x74, 0x22, 0x26, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x20, 0x62, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x2f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x62, 0x6f, 0x64, 0x79, 0x2f, 0x7b, 0x64, 0x61, 0x74, 0x61, 0x7d, 0x12, 0xc7, 0x01, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x69, 0x65, 0x73, 0x12, 0x3e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x49, 0x6e, 0x1a, 0x47, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x4f, 0x75, 0x74, 0x22, 0x28, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x22, 0x62, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x2f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x62, 0x6f, 0x64, 0x69, 0x65, 0x73, 0x2f, 0x7b, 0x64, 0x61, 0x74, 0x61, 0x7d, 0x12, 0xc7, 0x01, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x3e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x49, 0x6e, 0x1a, 0x47, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x27, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x21, 0x62, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x17, 0x2f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x73, 0x2f, 0x7b, 0x64, 0x61, 0x74, 0x61, 0x7d, 0x12, 0xc9, 0x01, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x3e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x49, 0x6e, 0x1a, 0x3f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x4f, 0x75, 0x74, 0x22, 0x2d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x27, 0x62, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x2f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x62, 0x6f, 0x64, 0x79, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2f, 0x7b, 0x64, 0x61, 0x74, 0x61, 0x7d, 0x30, 0x01, 0x12, 0xd8, 0x01, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x53, 0x61, 0x6d, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x3e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x49, 0x6e, 0x1a, 0x41, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x3a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x34, 0x62, 0x13, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x62, 0x6f, 0x64, 0x79, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1d, 0x2f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x62, 0x6f, 0x64, 0x79, 0x2f, 0x73, 0x61, 0x6d, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x2f, 0x7b, 0x64, 0x61, 0x74, 0x61, 0x7d, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_examplepb_response_body_service_proto_rawDescOnce sync.Once file_examples_internal_proto_examplepb_response_body_service_proto_rawDescData = file_examples_internal_proto_examplepb_response_body_service_proto_rawDesc ) func file_examples_internal_proto_examplepb_response_body_service_proto_rawDescGZIP() []byte { file_examples_internal_proto_examplepb_response_body_service_proto_rawDescOnce.Do(func() { file_examples_internal_proto_examplepb_response_body_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_examplepb_response_body_service_proto_rawDescData) }) return file_examples_internal_proto_examplepb_response_body_service_proto_rawDescData } var file_examples_internal_proto_examplepb_response_body_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_examples_internal_proto_examplepb_response_body_service_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_examples_internal_proto_examplepb_response_body_service_proto_goTypes = []any{ (RepeatedResponseBodyOut_Response_ResponseType)(0), // 0: grpc.gateway.examples.internal.proto.examplepb.RepeatedResponseBodyOut.Response.ResponseType (*ResponseBodyIn)(nil), // 1: grpc.gateway.examples.internal.proto.examplepb.ResponseBodyIn (*ResponseBodyOut)(nil), // 2: grpc.gateway.examples.internal.proto.examplepb.ResponseBodyOut (*RepeatedResponseBodyOut)(nil), // 3: grpc.gateway.examples.internal.proto.examplepb.RepeatedResponseBodyOut (*RepeatedResponseStrings)(nil), // 4: grpc.gateway.examples.internal.proto.examplepb.RepeatedResponseStrings (*ResponseBodyValue)(nil), // 5: grpc.gateway.examples.internal.proto.examplepb.ResponseBodyValue (*ResponseBodyOut_Response)(nil), // 6: grpc.gateway.examples.internal.proto.examplepb.ResponseBodyOut.Response (*RepeatedResponseBodyOut_Response)(nil), // 7: grpc.gateway.examples.internal.proto.examplepb.RepeatedResponseBodyOut.Response } var file_examples_internal_proto_examplepb_response_body_service_proto_depIdxs = []int32{ 6, // 0: grpc.gateway.examples.internal.proto.examplepb.ResponseBodyOut.response:type_name -> grpc.gateway.examples.internal.proto.examplepb.ResponseBodyOut.Response 7, // 1: grpc.gateway.examples.internal.proto.examplepb.RepeatedResponseBodyOut.response:type_name -> grpc.gateway.examples.internal.proto.examplepb.RepeatedResponseBodyOut.Response 0, // 2: grpc.gateway.examples.internal.proto.examplepb.RepeatedResponseBodyOut.Response.type:type_name -> grpc.gateway.examples.internal.proto.examplepb.RepeatedResponseBodyOut.Response.ResponseType 1, // 3: grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService.GetResponseBody:input_type -> grpc.gateway.examples.internal.proto.examplepb.ResponseBodyIn 1, // 4: grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService.ListResponseBodies:input_type -> grpc.gateway.examples.internal.proto.examplepb.ResponseBodyIn 1, // 5: grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService.ListResponseStrings:input_type -> grpc.gateway.examples.internal.proto.examplepb.ResponseBodyIn 1, // 6: grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService.GetResponseBodyStream:input_type -> grpc.gateway.examples.internal.proto.examplepb.ResponseBodyIn 1, // 7: grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService.GetResponseBodySameName:input_type -> grpc.gateway.examples.internal.proto.examplepb.ResponseBodyIn 2, // 8: grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService.GetResponseBody:output_type -> grpc.gateway.examples.internal.proto.examplepb.ResponseBodyOut 3, // 9: grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService.ListResponseBodies:output_type -> grpc.gateway.examples.internal.proto.examplepb.RepeatedResponseBodyOut 4, // 10: grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService.ListResponseStrings:output_type -> grpc.gateway.examples.internal.proto.examplepb.RepeatedResponseStrings 2, // 11: grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService.GetResponseBodyStream:output_type -> grpc.gateway.examples.internal.proto.examplepb.ResponseBodyOut 5, // 12: grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService.GetResponseBodySameName:output_type -> grpc.gateway.examples.internal.proto.examplepb.ResponseBodyValue 8, // [8:13] is the sub-list for method output_type 3, // [3:8] is the sub-list for method input_type 3, // [3:3] is the sub-list for extension type_name 3, // [3:3] is the sub-list for extension extendee 0, // [0:3] is the sub-list for field type_name } func init() { file_examples_internal_proto_examplepb_response_body_service_proto_init() } func file_examples_internal_proto_examplepb_response_body_service_proto_init() { if File_examples_internal_proto_examplepb_response_body_service_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_examplepb_response_body_service_proto_rawDesc, NumEnums: 1, NumMessages: 7, NumExtensions: 0, NumServices: 1, }, GoTypes: file_examples_internal_proto_examplepb_response_body_service_proto_goTypes, DependencyIndexes: file_examples_internal_proto_examplepb_response_body_service_proto_depIdxs, EnumInfos: file_examples_internal_proto_examplepb_response_body_service_proto_enumTypes, MessageInfos: file_examples_internal_proto_examplepb_response_body_service_proto_msgTypes, }.Build() File_examples_internal_proto_examplepb_response_body_service_proto = out.File file_examples_internal_proto_examplepb_response_body_service_proto_rawDesc = nil file_examples_internal_proto_examplepb_response_body_service_proto_goTypes = nil file_examples_internal_proto_examplepb_response_body_service_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/examplepb/response_body_service.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/proto/examplepb/response_body_service.proto /* Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package examplepb import ( "context" "errors" "io" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) func request_ResponseBodyService_GetResponseBody_0(ctx context.Context, marshaler runtime.Marshaler, client ResponseBodyServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ResponseBodyIn metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["data"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "data") } protoReq.Data, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "data", err) } msg, err := client.GetResponseBody(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ResponseBodyService_GetResponseBody_0(ctx context.Context, marshaler runtime.Marshaler, server ResponseBodyServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ResponseBodyIn metadata runtime.ServerMetadata err error ) val, ok := pathParams["data"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "data") } protoReq.Data, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "data", err) } msg, err := server.GetResponseBody(ctx, &protoReq) return msg, metadata, err } func request_ResponseBodyService_ListResponseBodies_0(ctx context.Context, marshaler runtime.Marshaler, client ResponseBodyServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ResponseBodyIn metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["data"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "data") } protoReq.Data, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "data", err) } msg, err := client.ListResponseBodies(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ResponseBodyService_ListResponseBodies_0(ctx context.Context, marshaler runtime.Marshaler, server ResponseBodyServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ResponseBodyIn metadata runtime.ServerMetadata err error ) val, ok := pathParams["data"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "data") } protoReq.Data, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "data", err) } msg, err := server.ListResponseBodies(ctx, &protoReq) return msg, metadata, err } func request_ResponseBodyService_ListResponseStrings_0(ctx context.Context, marshaler runtime.Marshaler, client ResponseBodyServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ResponseBodyIn metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["data"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "data") } protoReq.Data, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "data", err) } msg, err := client.ListResponseStrings(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ResponseBodyService_ListResponseStrings_0(ctx context.Context, marshaler runtime.Marshaler, server ResponseBodyServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ResponseBodyIn metadata runtime.ServerMetadata err error ) val, ok := pathParams["data"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "data") } protoReq.Data, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "data", err) } msg, err := server.ListResponseStrings(ctx, &protoReq) return msg, metadata, err } func request_ResponseBodyService_GetResponseBodyStream_0(ctx context.Context, marshaler runtime.Marshaler, client ResponseBodyServiceClient, req *http.Request, pathParams map[string]string) (ResponseBodyService_GetResponseBodyStreamClient, runtime.ServerMetadata, error) { var ( protoReq ResponseBodyIn metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["data"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "data") } protoReq.Data, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "data", err) } stream, err := client.GetResponseBodyStream(ctx, &protoReq) if err != nil { return nil, metadata, err } header, err := stream.Header() if err != nil { return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } func request_ResponseBodyService_GetResponseBodySameName_0(ctx context.Context, marshaler runtime.Marshaler, client ResponseBodyServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ResponseBodyIn metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["data"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "data") } protoReq.Data, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "data", err) } msg, err := client.GetResponseBodySameName(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_ResponseBodyService_GetResponseBodySameName_0(ctx context.Context, marshaler runtime.Marshaler, server ResponseBodyServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ResponseBodyIn metadata runtime.ServerMetadata err error ) val, ok := pathParams["data"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "data") } protoReq.Data, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "data", err) } msg, err := server.GetResponseBodySameName(ctx, &protoReq) return msg, metadata, err } // RegisterResponseBodyServiceHandlerServer registers the http handlers for service ResponseBodyService to "mux". // UnaryRPC :call ResponseBodyServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterResponseBodyServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterResponseBodyServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ResponseBodyServiceServer) error { mux.Handle(http.MethodGet, pattern_ResponseBodyService_GetResponseBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService/GetResponseBody", runtime.WithHTTPPathPattern("/responsebody/{data}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ResponseBodyService_GetResponseBody_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ResponseBodyService_GetResponseBody_0(annotatedContext, mux, outboundMarshaler, w, req, response_ResponseBodyService_GetResponseBody_0{resp.(*ResponseBodyOut)}, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ResponseBodyService_ListResponseBodies_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService/ListResponseBodies", runtime.WithHTTPPathPattern("/responsebodies/{data}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ResponseBodyService_ListResponseBodies_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ResponseBodyService_ListResponseBodies_0(annotatedContext, mux, outboundMarshaler, w, req, response_ResponseBodyService_ListResponseBodies_0{resp.(*RepeatedResponseBodyOut)}, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ResponseBodyService_ListResponseStrings_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService/ListResponseStrings", runtime.WithHTTPPathPattern("/responsestrings/{data}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ResponseBodyService_ListResponseStrings_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ResponseBodyService_ListResponseStrings_0(annotatedContext, mux, outboundMarshaler, w, req, response_ResponseBodyService_ListResponseStrings_0{resp.(*RepeatedResponseStrings)}, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ResponseBodyService_GetResponseBodyStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodGet, pattern_ResponseBodyService_GetResponseBodySameName_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService/GetResponseBodySameName", runtime.WithHTTPPathPattern("/responsebody/samename/{data}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_ResponseBodyService_GetResponseBodySameName_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ResponseBodyService_GetResponseBodySameName_0(annotatedContext, mux, outboundMarshaler, w, req, response_ResponseBodyService_GetResponseBodySameName_0{resp.(*ResponseBodyValue)}, mux.GetForwardResponseOptions()...) }) return nil } // RegisterResponseBodyServiceHandlerFromEndpoint is same as RegisterResponseBodyServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterResponseBodyServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterResponseBodyServiceHandler(ctx, mux, conn) } // RegisterResponseBodyServiceHandler registers the http handlers for service ResponseBodyService to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterResponseBodyServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterResponseBodyServiceHandlerClient(ctx, mux, NewResponseBodyServiceClient(conn)) } // RegisterResponseBodyServiceHandlerClient registers the http handlers for service ResponseBodyService // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ResponseBodyServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ResponseBodyServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "ResponseBodyServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterResponseBodyServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ResponseBodyServiceClient) error { mux.Handle(http.MethodGet, pattern_ResponseBodyService_GetResponseBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService/GetResponseBody", runtime.WithHTTPPathPattern("/responsebody/{data}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ResponseBodyService_GetResponseBody_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ResponseBodyService_GetResponseBody_0(annotatedContext, mux, outboundMarshaler, w, req, response_ResponseBodyService_GetResponseBody_0{resp.(*ResponseBodyOut)}, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ResponseBodyService_ListResponseBodies_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService/ListResponseBodies", runtime.WithHTTPPathPattern("/responsebodies/{data}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ResponseBodyService_ListResponseBodies_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ResponseBodyService_ListResponseBodies_0(annotatedContext, mux, outboundMarshaler, w, req, response_ResponseBodyService_ListResponseBodies_0{resp.(*RepeatedResponseBodyOut)}, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ResponseBodyService_ListResponseStrings_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService/ListResponseStrings", runtime.WithHTTPPathPattern("/responsestrings/{data}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ResponseBodyService_ListResponseStrings_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ResponseBodyService_ListResponseStrings_0(annotatedContext, mux, outboundMarshaler, w, req, response_ResponseBodyService_ListResponseStrings_0{resp.(*RepeatedResponseStrings)}, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ResponseBodyService_GetResponseBodyStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService/GetResponseBodyStream", runtime.WithHTTPPathPattern("/responsebody/stream/{data}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ResponseBodyService_GetResponseBodyStream_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ResponseBodyService_GetResponseBodyStream_0(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { res, err := resp.Recv() return response_ResponseBodyService_GetResponseBodyStream_0{res}, err }, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_ResponseBodyService_GetResponseBodySameName_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService/GetResponseBodySameName", runtime.WithHTTPPathPattern("/responsebody/samename/{data}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_ResponseBodyService_GetResponseBodySameName_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_ResponseBodyService_GetResponseBodySameName_0(annotatedContext, mux, outboundMarshaler, w, req, response_ResponseBodyService_GetResponseBodySameName_0{resp.(*ResponseBodyValue)}, mux.GetForwardResponseOptions()...) }) return nil } type response_ResponseBodyService_GetResponseBody_0 struct { *ResponseBodyOut } func (m response_ResponseBodyService_GetResponseBody_0) XXX_ResponseBody() interface{} { response := m.ResponseBodyOut return response.Response } type response_ResponseBodyService_ListResponseBodies_0 struct { *RepeatedResponseBodyOut } func (m response_ResponseBodyService_ListResponseBodies_0) XXX_ResponseBody() interface{} { response := m.RepeatedResponseBodyOut return response.Response } type response_ResponseBodyService_ListResponseStrings_0 struct { *RepeatedResponseStrings } func (m response_ResponseBodyService_ListResponseStrings_0) XXX_ResponseBody() interface{} { response := m.RepeatedResponseStrings return response.Values } type response_ResponseBodyService_GetResponseBodyStream_0 struct { *ResponseBodyOut } func (m response_ResponseBodyService_GetResponseBodyStream_0) XXX_ResponseBody() interface{} { response := m.ResponseBodyOut return response.Response } type response_ResponseBodyService_GetResponseBodySameName_0 struct { *ResponseBodyValue } func (m response_ResponseBodyService_GetResponseBodySameName_0) XXX_ResponseBody() interface{} { response := m.ResponseBodyValue return response.ResponseBodyValue } var ( pattern_ResponseBodyService_GetResponseBody_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"responsebody", "data"}, "")) pattern_ResponseBodyService_ListResponseBodies_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"responsebodies", "data"}, "")) pattern_ResponseBodyService_ListResponseStrings_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"responsestrings", "data"}, "")) pattern_ResponseBodyService_GetResponseBodyStream_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"responsebody", "stream", "data"}, "")) pattern_ResponseBodyService_GetResponseBodySameName_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"responsebody", "samename", "data"}, "")) ) var ( forward_ResponseBodyService_GetResponseBody_0 = runtime.ForwardResponseMessage forward_ResponseBodyService_ListResponseBodies_0 = runtime.ForwardResponseMessage forward_ResponseBodyService_ListResponseStrings_0 = runtime.ForwardResponseMessage forward_ResponseBodyService_GetResponseBodyStream_0 = runtime.ForwardResponseStream forward_ResponseBodyService_GetResponseBodySameName_0 = runtime.ForwardResponseMessage ) ================================================ FILE: examples/internal/proto/examplepb/response_body_service.proto ================================================ syntax = "proto3"; package grpc.gateway.examples.internal.proto.examplepb; import "google/api/annotations.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; message ResponseBodyIn { string data = 1; } message ResponseBodyOut { message Response { string data = 1; } Response response = 2; } message RepeatedResponseBodyOut { message Response { string data = 1; enum ResponseType { // UNKNOWN UNKNOWN = 0; // A is 1 A = 1; // B is 2 B = 2; } ResponseType type = 3; } repeated Response response = 2; } message RepeatedResponseStrings { repeated string values = 1; } message ResponseBodyValue { string response_body_value = 1; } service ResponseBodyService { rpc GetResponseBody(ResponseBodyIn) returns (ResponseBodyOut) { option (google.api.http) = { get: "/responsebody/{data}" response_body: "response" }; } rpc ListResponseBodies(ResponseBodyIn) returns (RepeatedResponseBodyOut) { option (google.api.http) = { get: "/responsebodies/{data}" response_body: "response" }; } rpc ListResponseStrings(ResponseBodyIn) returns (RepeatedResponseStrings) { option (google.api.http) = { get: "/responsestrings/{data}" response_body: "values" }; } rpc GetResponseBodyStream(ResponseBodyIn) returns (stream ResponseBodyOut) { option (google.api.http) = { get: "/responsebody/stream/{data}" response_body: "response" }; } rpc GetResponseBodySameName(ResponseBodyIn) returns (ResponseBodyValue) { option (google.api.http) = { get: "/responsebody/samename/{data}" response_body: "response_body_value" }; } } ================================================ FILE: examples/internal/proto/examplepb/response_body_service.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/examplepb/response_body_service.proto", "version": "version not set" }, "tags": [ { "name": "ResponseBodyService" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/responsebodies/{data}": { "get": { "operationId": "ResponseBodyService_ListResponseBodies", "responses": { "200": { "description": "", "schema": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/examplepbRepeatedResponseBodyOutResponse" } } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "data", "in": "path", "required": true, "type": "string" } ], "tags": [ "ResponseBodyService" ] } }, "/responsebody/samename/{data}": { "get": { "operationId": "ResponseBodyService_GetResponseBodySameName", "responses": { "200": { "description": "", "schema": { "type": "string" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "data", "in": "path", "required": true, "type": "string" } ], "tags": [ "ResponseBodyService" ] } }, "/responsebody/stream/{data}": { "get": { "operationId": "ResponseBodyService_GetResponseBodyStream", "responses": { "200": { "description": "(streaming responses)", "schema": { "type": "object", "properties": { "result": { "$ref": "#/definitions/examplepbResponseBodyOutResponse" }, "error": { "$ref": "#/definitions/googleRpcStatus" } }, "title": "Stream result of examplepbResponseBodyOut" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "data", "in": "path", "required": true, "type": "string" } ], "tags": [ "ResponseBodyService" ] } }, "/responsebody/{data}": { "get": { "operationId": "ResponseBodyService_GetResponseBody", "responses": { "200": { "description": "", "schema": { "$ref": "#/definitions/examplepbResponseBodyOutResponse" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "data", "in": "path", "required": true, "type": "string" } ], "tags": [ "ResponseBodyService" ] } }, "/responsestrings/{data}": { "get": { "operationId": "ResponseBodyService_ListResponseStrings", "responses": { "200": { "description": "", "schema": { "type": "array", "items": { "type": "string" } } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "data", "in": "path", "required": true, "type": "string" } ], "tags": [ "ResponseBodyService" ] } } }, "definitions": { "ResponseResponseType": { "type": "string", "enum": [ "UNKNOWN", "A", "B" ], "default": "UNKNOWN", "title": "- UNKNOWN: UNKNOWN\n - A: A is 1\n - B: B is 2" }, "examplepbRepeatedResponseBodyOut": { "type": "object", "properties": { "response": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/examplepbRepeatedResponseBodyOutResponse" } } } }, "examplepbRepeatedResponseBodyOutResponse": { "type": "object", "properties": { "data": { "type": "string" }, "type": { "$ref": "#/definitions/ResponseResponseType" } } }, "examplepbRepeatedResponseStrings": { "type": "object", "properties": { "values": { "type": "array", "items": { "type": "string" } } } }, "examplepbResponseBodyOut": { "type": "object", "properties": { "response": { "$ref": "#/definitions/examplepbResponseBodyOutResponse" } } }, "examplepbResponseBodyOutResponse": { "type": "object", "properties": { "data": { "type": "string" } } }, "examplepbResponseBodyValue": { "type": "object", "properties": { "responseBodyValue": { "type": "string" } } }, "googleRpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32", "description": "The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]." }, "message": { "type": "string", "description": "A developer-facing error message, which should be in English. Any\nuser-facing error message should be localized and sent in the\n[google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client." }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" }, "description": "A list of messages that carry the error details. There is a common set of\nmessage types for APIs to use." } }, "description": "The `Status` type defines a logical error model that is suitable for\ndifferent programming environments, including REST APIs and RPC APIs. It is\nused by [gRPC](https://github.com/grpc). Each `Status` message contains\nthree pieces of data: error code, error message, and error details.\n\nYou can find out more about this error model and how to work with it in the\n[API Design Guide](https://cloud.google.com/apis/design/errors)." }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string", "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics." } }, "additionalProperties": {}, "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }" } } } ================================================ FILE: examples/internal/proto/examplepb/response_body_service_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: examples/internal/proto/examplepb/response_body_service.proto package examplepb import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( ResponseBodyService_GetResponseBody_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService/GetResponseBody" ResponseBodyService_ListResponseBodies_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService/ListResponseBodies" ResponseBodyService_ListResponseStrings_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService/ListResponseStrings" ResponseBodyService_GetResponseBodyStream_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService/GetResponseBodyStream" ResponseBodyService_GetResponseBodySameName_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService/GetResponseBodySameName" ) // ResponseBodyServiceClient is the client API for ResponseBodyService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type ResponseBodyServiceClient interface { GetResponseBody(ctx context.Context, in *ResponseBodyIn, opts ...grpc.CallOption) (*ResponseBodyOut, error) ListResponseBodies(ctx context.Context, in *ResponseBodyIn, opts ...grpc.CallOption) (*RepeatedResponseBodyOut, error) ListResponseStrings(ctx context.Context, in *ResponseBodyIn, opts ...grpc.CallOption) (*RepeatedResponseStrings, error) GetResponseBodyStream(ctx context.Context, in *ResponseBodyIn, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ResponseBodyOut], error) GetResponseBodySameName(ctx context.Context, in *ResponseBodyIn, opts ...grpc.CallOption) (*ResponseBodyValue, error) } type responseBodyServiceClient struct { cc grpc.ClientConnInterface } func NewResponseBodyServiceClient(cc grpc.ClientConnInterface) ResponseBodyServiceClient { return &responseBodyServiceClient{cc} } func (c *responseBodyServiceClient) GetResponseBody(ctx context.Context, in *ResponseBodyIn, opts ...grpc.CallOption) (*ResponseBodyOut, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ResponseBodyOut) err := c.cc.Invoke(ctx, ResponseBodyService_GetResponseBody_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *responseBodyServiceClient) ListResponseBodies(ctx context.Context, in *ResponseBodyIn, opts ...grpc.CallOption) (*RepeatedResponseBodyOut, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(RepeatedResponseBodyOut) err := c.cc.Invoke(ctx, ResponseBodyService_ListResponseBodies_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *responseBodyServiceClient) ListResponseStrings(ctx context.Context, in *ResponseBodyIn, opts ...grpc.CallOption) (*RepeatedResponseStrings, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(RepeatedResponseStrings) err := c.cc.Invoke(ctx, ResponseBodyService_ListResponseStrings_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *responseBodyServiceClient) GetResponseBodyStream(ctx context.Context, in *ResponseBodyIn, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ResponseBodyOut], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &ResponseBodyService_ServiceDesc.Streams[0], ResponseBodyService_GetResponseBodyStream_FullMethodName, cOpts...) if err != nil { return nil, err } x := &grpc.GenericClientStream[ResponseBodyIn, ResponseBodyOut]{ClientStream: stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } if err := x.ClientStream.CloseSend(); err != nil { return nil, err } return x, nil } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type ResponseBodyService_GetResponseBodyStreamClient = grpc.ServerStreamingClient[ResponseBodyOut] func (c *responseBodyServiceClient) GetResponseBodySameName(ctx context.Context, in *ResponseBodyIn, opts ...grpc.CallOption) (*ResponseBodyValue, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ResponseBodyValue) err := c.cc.Invoke(ctx, ResponseBodyService_GetResponseBodySameName_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // ResponseBodyServiceServer is the server API for ResponseBodyService service. // All implementations should embed UnimplementedResponseBodyServiceServer // for forward compatibility. type ResponseBodyServiceServer interface { GetResponseBody(context.Context, *ResponseBodyIn) (*ResponseBodyOut, error) ListResponseBodies(context.Context, *ResponseBodyIn) (*RepeatedResponseBodyOut, error) ListResponseStrings(context.Context, *ResponseBodyIn) (*RepeatedResponseStrings, error) GetResponseBodyStream(*ResponseBodyIn, grpc.ServerStreamingServer[ResponseBodyOut]) error GetResponseBodySameName(context.Context, *ResponseBodyIn) (*ResponseBodyValue, error) } // UnimplementedResponseBodyServiceServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedResponseBodyServiceServer struct{} func (UnimplementedResponseBodyServiceServer) GetResponseBody(context.Context, *ResponseBodyIn) (*ResponseBodyOut, error) { return nil, status.Errorf(codes.Unimplemented, "method GetResponseBody not implemented") } func (UnimplementedResponseBodyServiceServer) ListResponseBodies(context.Context, *ResponseBodyIn) (*RepeatedResponseBodyOut, error) { return nil, status.Errorf(codes.Unimplemented, "method ListResponseBodies not implemented") } func (UnimplementedResponseBodyServiceServer) ListResponseStrings(context.Context, *ResponseBodyIn) (*RepeatedResponseStrings, error) { return nil, status.Errorf(codes.Unimplemented, "method ListResponseStrings not implemented") } func (UnimplementedResponseBodyServiceServer) GetResponseBodyStream(*ResponseBodyIn, grpc.ServerStreamingServer[ResponseBodyOut]) error { return status.Errorf(codes.Unimplemented, "method GetResponseBodyStream not implemented") } func (UnimplementedResponseBodyServiceServer) GetResponseBodySameName(context.Context, *ResponseBodyIn) (*ResponseBodyValue, error) { return nil, status.Errorf(codes.Unimplemented, "method GetResponseBodySameName not implemented") } func (UnimplementedResponseBodyServiceServer) testEmbeddedByValue() {} // UnsafeResponseBodyServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to ResponseBodyServiceServer will // result in compilation errors. type UnsafeResponseBodyServiceServer interface { mustEmbedUnimplementedResponseBodyServiceServer() } func RegisterResponseBodyServiceServer(s grpc.ServiceRegistrar, srv ResponseBodyServiceServer) { // If the following call pancis, it indicates UnimplementedResponseBodyServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&ResponseBodyService_ServiceDesc, srv) } func _ResponseBodyService_GetResponseBody_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ResponseBodyIn) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ResponseBodyServiceServer).GetResponseBody(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ResponseBodyService_GetResponseBody_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ResponseBodyServiceServer).GetResponseBody(ctx, req.(*ResponseBodyIn)) } return interceptor(ctx, in, info, handler) } func _ResponseBodyService_ListResponseBodies_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ResponseBodyIn) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ResponseBodyServiceServer).ListResponseBodies(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ResponseBodyService_ListResponseBodies_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ResponseBodyServiceServer).ListResponseBodies(ctx, req.(*ResponseBodyIn)) } return interceptor(ctx, in, info, handler) } func _ResponseBodyService_ListResponseStrings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ResponseBodyIn) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ResponseBodyServiceServer).ListResponseStrings(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ResponseBodyService_ListResponseStrings_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ResponseBodyServiceServer).ListResponseStrings(ctx, req.(*ResponseBodyIn)) } return interceptor(ctx, in, info, handler) } func _ResponseBodyService_GetResponseBodyStream_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(ResponseBodyIn) if err := stream.RecvMsg(m); err != nil { return err } return srv.(ResponseBodyServiceServer).GetResponseBodyStream(m, &grpc.GenericServerStream[ResponseBodyIn, ResponseBodyOut]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type ResponseBodyService_GetResponseBodyStreamServer = grpc.ServerStreamingServer[ResponseBodyOut] func _ResponseBodyService_GetResponseBodySameName_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ResponseBodyIn) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(ResponseBodyServiceServer).GetResponseBodySameName(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: ResponseBodyService_GetResponseBodySameName_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ResponseBodyServiceServer).GetResponseBodySameName(ctx, req.(*ResponseBodyIn)) } return interceptor(ctx, in, info, handler) } // ResponseBodyService_ServiceDesc is the grpc.ServiceDesc for ResponseBodyService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var ResponseBodyService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.ResponseBodyService", HandlerType: (*ResponseBodyServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "GetResponseBody", Handler: _ResponseBodyService_GetResponseBody_Handler, }, { MethodName: "ListResponseBodies", Handler: _ResponseBodyService_ListResponseBodies_Handler, }, { MethodName: "ListResponseStrings", Handler: _ResponseBodyService_ListResponseStrings_Handler, }, { MethodName: "GetResponseBodySameName", Handler: _ResponseBodyService_GetResponseBodySameName_Handler, }, }, Streams: []grpc.StreamDesc{ { StreamName: "GetResponseBodyStream", Handler: _ResponseBodyService_GetResponseBodyStream_Handler, ServerStreams: true, }, }, Metadata: "examples/internal/proto/examplepb/response_body_service.proto", } ================================================ FILE: examples/internal/proto/examplepb/standalone_echo_service.buf.gen.yaml ================================================ version: v1 plugins: - plugin: grpc-gateway out: . opt: - paths=source_relative - standalone=true - grpc_api_configuration=examples/internal/proto/examplepb/standalone_echo_service.yaml ================================================ FILE: examples/internal/proto/examplepb/standalone_echo_service.yaml ================================================ type: google.api.Service config_version: 3 http: rules: - selector: grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService.Echo post: "/v2/example/echo/{id}" additional_bindings: - get: "/v2/example/echo/{id}/{num}" - get: "/v2/example/echo/{id}/{num}/{lang}" - get: "/v2/example/echo1/{id}/{line_num}/{status.note}" - get: "/v2/example/echo2/{no.note}" - selector: grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService.EchoBody post: "/v2/example/echo_body" body: "*" - selector: grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService.EchoDelete delete: "/v2/example/echo_delete" - selector: grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService.EchoNested put: "/v1/example/echo_nested" body: "*" response_body: "n_id" ================================================ FILE: examples/internal/proto/examplepb/stream.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/examplepb/stream.proto package examplepb import ( sub "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub" _ "google.golang.org/genproto/googleapis/api/annotations" httpbody "google.golang.org/genproto/googleapis/api/httpbody" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" durationpb "google.golang.org/protobuf/types/known/durationpb" emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) type Options struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Error bool `protobuf:"varint,1,opt,name=error,proto3" json:"error,omitempty"` } func (x *Options) Reset() { *x = Options{} mi := &file_examples_internal_proto_examplepb_stream_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Options) String() string { return protoimpl.X.MessageStringOf(x) } func (*Options) ProtoMessage() {} func (x *Options) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_stream_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Options.ProtoReflect.Descriptor instead. func (*Options) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_stream_proto_rawDescGZIP(), []int{0} } func (x *Options) GetError() bool { if x != nil { return x.Error } return false } var File_examples_internal_proto_examplepb_stream_proto protoreflect.FileDescriptor var file_examples_internal_proto_examplepb_stream_proto_rawDesc = []byte{ 0x0a, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x3b, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x29, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x75, 0x62, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x62, 0x6f, 0x64, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1f, 0x0a, 0x07, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x32, 0x92, 0x06, 0x0a, 0x0d, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x99, 0x01, 0x0a, 0x0a, 0x42, 0x75, 0x6c, 0x6b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x2f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x29, 0x3a, 0x01, 0x2a, 0x22, 0x24, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x62, 0x75, 0x6c, 0x6b, 0x28, 0x01, 0x12, 0xac, 0x01, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x37, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x22, 0x27, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x21, 0x12, 0x1f, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x30, 0x01, 0x12, 0xb1, 0x01, 0x0a, 0x08, 0x42, 0x75, 0x6c, 0x6b, 0x45, 0x63, 0x68, 0x6f, 0x12, 0x37, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x73, 0x75, 0x62, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x37, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x73, 0x75, 0x62, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x2f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x29, 0x3a, 0x01, 0x2a, 0x22, 0x24, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x28, 0x01, 0x30, 0x01, 0x12, 0x86, 0x01, 0x0a, 0x10, 0x42, 0x75, 0x6c, 0x6b, 0x45, 0x63, 0x68, 0x6f, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x38, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x32, 0x3a, 0x01, 0x2a, 0x22, 0x2d, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x5f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x01, 0x30, 0x01, 0x12, 0x79, 0x0a, 0x08, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x37, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x48, 0x74, 0x74, 0x70, 0x42, 0x6f, 0x64, 0x79, 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x12, 0x14, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x30, 0x01, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_examplepb_stream_proto_rawDescOnce sync.Once file_examples_internal_proto_examplepb_stream_proto_rawDescData = file_examples_internal_proto_examplepb_stream_proto_rawDesc ) func file_examples_internal_proto_examplepb_stream_proto_rawDescGZIP() []byte { file_examples_internal_proto_examplepb_stream_proto_rawDescOnce.Do(func() { file_examples_internal_proto_examplepb_stream_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_examplepb_stream_proto_rawDescData) }) return file_examples_internal_proto_examplepb_stream_proto_rawDescData } var file_examples_internal_proto_examplepb_stream_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_examples_internal_proto_examplepb_stream_proto_goTypes = []any{ (*Options)(nil), // 0: grpc.gateway.examples.internal.proto.examplepb.Options (*ABitOfEverything)(nil), // 1: grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything (*sub.StringMessage)(nil), // 2: grpc.gateway.examples.internal.proto.sub.StringMessage (*durationpb.Duration)(nil), // 3: google.protobuf.Duration (*emptypb.Empty)(nil), // 4: google.protobuf.Empty (*httpbody.HttpBody)(nil), // 5: google.api.HttpBody } var file_examples_internal_proto_examplepb_stream_proto_depIdxs = []int32{ 1, // 0: grpc.gateway.examples.internal.proto.examplepb.StreamService.BulkCreate:input_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 0, // 1: grpc.gateway.examples.internal.proto.examplepb.StreamService.List:input_type -> grpc.gateway.examples.internal.proto.examplepb.Options 2, // 2: grpc.gateway.examples.internal.proto.examplepb.StreamService.BulkEcho:input_type -> grpc.gateway.examples.internal.proto.sub.StringMessage 3, // 3: grpc.gateway.examples.internal.proto.examplepb.StreamService.BulkEchoDuration:input_type -> google.protobuf.Duration 0, // 4: grpc.gateway.examples.internal.proto.examplepb.StreamService.Download:input_type -> grpc.gateway.examples.internal.proto.examplepb.Options 4, // 5: grpc.gateway.examples.internal.proto.examplepb.StreamService.BulkCreate:output_type -> google.protobuf.Empty 1, // 6: grpc.gateway.examples.internal.proto.examplepb.StreamService.List:output_type -> grpc.gateway.examples.internal.proto.examplepb.ABitOfEverything 2, // 7: grpc.gateway.examples.internal.proto.examplepb.StreamService.BulkEcho:output_type -> grpc.gateway.examples.internal.proto.sub.StringMessage 3, // 8: grpc.gateway.examples.internal.proto.examplepb.StreamService.BulkEchoDuration:output_type -> google.protobuf.Duration 5, // 9: grpc.gateway.examples.internal.proto.examplepb.StreamService.Download:output_type -> google.api.HttpBody 5, // [5:10] is the sub-list for method output_type 0, // [0:5] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name } func init() { file_examples_internal_proto_examplepb_stream_proto_init() } func file_examples_internal_proto_examplepb_stream_proto_init() { if File_examples_internal_proto_examplepb_stream_proto != nil { return } file_examples_internal_proto_examplepb_a_bit_of_everything_proto_init() type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_examplepb_stream_proto_rawDesc, NumEnums: 0, NumMessages: 1, NumExtensions: 0, NumServices: 1, }, GoTypes: file_examples_internal_proto_examplepb_stream_proto_goTypes, DependencyIndexes: file_examples_internal_proto_examplepb_stream_proto_depIdxs, MessageInfos: file_examples_internal_proto_examplepb_stream_proto_msgTypes, }.Build() File_examples_internal_proto_examplepb_stream_proto = out.File file_examples_internal_proto_examplepb_stream_proto_rawDesc = nil file_examples_internal_proto_examplepb_stream_proto_goTypes = nil file_examples_internal_proto_examplepb_stream_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/examplepb/stream.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/proto/examplepb/stream.proto /* Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package examplepb import ( "context" "errors" "io" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/durationpb" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) func request_StreamService_BulkCreate_0(ctx context.Context, marshaler runtime.Marshaler, client StreamServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var metadata runtime.ServerMetadata stream, err := client.BulkCreate(ctx) if err != nil { grpclog.Errorf("Failed to start streaming: %v", err) return nil, metadata, err } dec := marshaler.NewDecoder(req.Body) for { var protoReq ABitOfEverything err = dec.Decode(&protoReq) if errors.Is(err, io.EOF) { break } if err != nil { grpclog.Errorf("Failed to decode request: %v", err) return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err = stream.Send(&protoReq); err != nil { if errors.Is(err, io.EOF) { break } grpclog.Errorf("Failed to send request: %v", err) return nil, metadata, err } } if err := stream.CloseSend(); err != nil { grpclog.Errorf("Failed to terminate client stream: %v", err) return nil, metadata, err } header, err := stream.Header() if err != nil { grpclog.Errorf("Failed to get header from client: %v", err) return nil, metadata, err } metadata.HeaderMD = header msg, err := stream.CloseAndRecv() metadata.TrailerMD = stream.Trailer() return msg, metadata, err } var filter_StreamService_List_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_StreamService_List_0(ctx context.Context, marshaler runtime.Marshaler, client StreamServiceClient, req *http.Request, pathParams map[string]string) (StreamService_ListClient, runtime.ServerMetadata, error) { var ( protoReq Options metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_StreamService_List_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } stream, err := client.List(ctx, &protoReq) if err != nil { return nil, metadata, err } header, err := stream.Header() if err != nil { return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } func request_StreamService_BulkEcho_0(ctx context.Context, marshaler runtime.Marshaler, client StreamServiceClient, req *http.Request, pathParams map[string]string) (StreamService_BulkEchoClient, runtime.ServerMetadata, error) { var metadata runtime.ServerMetadata stream, err := client.BulkEcho(ctx) if err != nil { grpclog.Errorf("Failed to start streaming: %v", err) return nil, metadata, err } dec := marshaler.NewDecoder(req.Body) handleSend := func() error { var protoReq sub.StringMessage err := dec.Decode(&protoReq) if errors.Is(err, io.EOF) { return err } if err != nil { grpclog.Errorf("Failed to decode request: %v", err) return status.Errorf(codes.InvalidArgument, "Failed to decode request: %v", err) } if err := stream.Send(&protoReq); err != nil { grpclog.Errorf("Failed to send request: %v", err) return err } return nil } go func() { for { if err := handleSend(); err != nil { break } } if err := stream.CloseSend(); err != nil { grpclog.Errorf("Failed to terminate client stream: %v", err) } }() header, err := stream.Header() if err != nil { grpclog.Errorf("Failed to get header from client: %v", err) return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } func request_StreamService_BulkEchoDuration_0(ctx context.Context, marshaler runtime.Marshaler, client StreamServiceClient, req *http.Request, pathParams map[string]string) (StreamService_BulkEchoDurationClient, runtime.ServerMetadata, error) { var metadata runtime.ServerMetadata stream, err := client.BulkEchoDuration(ctx) if err != nil { grpclog.Errorf("Failed to start streaming: %v", err) return nil, metadata, err } dec := marshaler.NewDecoder(req.Body) handleSend := func() error { var protoReq durationpb.Duration err := dec.Decode(&protoReq) if errors.Is(err, io.EOF) { return err } if err != nil { grpclog.Errorf("Failed to decode request: %v", err) return status.Errorf(codes.InvalidArgument, "Failed to decode request: %v", err) } if err := stream.Send(&protoReq); err != nil { grpclog.Errorf("Failed to send request: %v", err) return err } return nil } go func() { for { if err := handleSend(); err != nil { break } } if err := stream.CloseSend(); err != nil { grpclog.Errorf("Failed to terminate client stream: %v", err) } }() header, err := stream.Header() if err != nil { grpclog.Errorf("Failed to get header from client: %v", err) return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } var filter_StreamService_Download_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_StreamService_Download_0(ctx context.Context, marshaler runtime.Marshaler, client StreamServiceClient, req *http.Request, pathParams map[string]string) (StreamService_DownloadClient, runtime.ServerMetadata, error) { var ( protoReq Options metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_StreamService_Download_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } stream, err := client.Download(ctx, &protoReq) if err != nil { return nil, metadata, err } header, err := stream.Header() if err != nil { return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } // RegisterStreamServiceHandlerServer registers the http handlers for service StreamService to "mux". // UnaryRPC :call StreamServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterStreamServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterStreamServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server StreamServiceServer) error { mux.Handle(http.MethodPost, pattern_StreamService_BulkCreate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodGet, pattern_StreamService_List_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodPost, pattern_StreamService_BulkEcho_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodPost, pattern_StreamService_BulkEchoDuration_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) mux.Handle(http.MethodGet, pattern_StreamService_Download_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) return nil } // RegisterStreamServiceHandlerFromEndpoint is same as RegisterStreamServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterStreamServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterStreamServiceHandler(ctx, mux, conn) } // RegisterStreamServiceHandler registers the http handlers for service StreamService to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterStreamServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterStreamServiceHandlerClient(ctx, mux, NewStreamServiceClient(conn)) } // RegisterStreamServiceHandlerClient registers the http handlers for service StreamService // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "StreamServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "StreamServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "StreamServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterStreamServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client StreamServiceClient) error { mux.Handle(http.MethodPost, pattern_StreamService_BulkCreate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.StreamService/BulkCreate", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/bulk")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_StreamService_BulkCreate_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_StreamService_BulkCreate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_StreamService_List_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.StreamService/List", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_StreamService_List_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_StreamService_List_0(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_StreamService_BulkEcho_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.StreamService/BulkEcho", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/echo")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_StreamService_BulkEcho_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_StreamService_BulkEcho_0(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_StreamService_BulkEchoDuration_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.StreamService/BulkEchoDuration", runtime.WithHTTPPathPattern("/v1/example/a_bit_of_everything/echo_duration")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_StreamService_BulkEchoDuration_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_StreamService_BulkEchoDuration_0(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_StreamService_Download_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.StreamService/Download", runtime.WithHTTPPathPattern("/v1/example/download")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_StreamService_Download_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_StreamService_Download_0(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_StreamService_BulkCreate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "example", "a_bit_of_everything", "bulk"}, "")) pattern_StreamService_List_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "a_bit_of_everything"}, "")) pattern_StreamService_BulkEcho_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "example", "a_bit_of_everything", "echo"}, "")) pattern_StreamService_BulkEchoDuration_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "example", "a_bit_of_everything", "echo_duration"}, "")) pattern_StreamService_Download_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "download"}, "")) ) var ( forward_StreamService_BulkCreate_0 = runtime.ForwardResponseMessage forward_StreamService_List_0 = runtime.ForwardResponseStream forward_StreamService_BulkEcho_0 = runtime.ForwardResponseStream forward_StreamService_BulkEchoDuration_0 = runtime.ForwardResponseStream forward_StreamService_Download_0 = runtime.ForwardResponseStream ) ================================================ FILE: examples/internal/proto/examplepb/stream.proto ================================================ syntax = "proto3"; package grpc.gateway.examples.internal.proto.examplepb; import "examples/internal/proto/examplepb/a_bit_of_everything.proto"; import "examples/internal/proto/sub/message.proto"; import "google/api/annotations.proto"; import "google/api/httpbody.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/empty.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; // Defines some more operations to be added to ABitOfEverythingService service StreamService { rpc BulkCreate(stream ABitOfEverything) returns (google.protobuf.Empty) { option (google.api.http) = { post: "/v1/example/a_bit_of_everything/bulk" body: "*" }; } rpc List(Options) returns (stream ABitOfEverything) { option (google.api.http) = {get: "/v1/example/a_bit_of_everything"}; } rpc BulkEcho(stream grpc.gateway.examples.internal.proto.sub.StringMessage) returns (stream grpc.gateway.examples.internal.proto.sub.StringMessage) { option (google.api.http) = { post: "/v1/example/a_bit_of_everything/echo" body: "*" }; } rpc BulkEchoDuration(stream google.protobuf.Duration) returns (stream google.protobuf.Duration) { option (google.api.http) = { post: "/v1/example/a_bit_of_everything/echo_duration" body: "*" }; } rpc Download(Options) returns (stream google.api.HttpBody) { option (google.api.http) = {get: "/v1/example/download"}; } } message Options { bool error = 1; } ================================================ FILE: examples/internal/proto/examplepb/stream.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/examplepb/stream.proto", "version": "version not set" }, "tags": [ { "name": "StreamService" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/v1/example/a_bit_of_everything": { "get": { "operationId": "StreamService_List", "responses": { "200": { "description": "A successful response.(streaming responses)", "schema": { "type": "object", "properties": { "result": { "$ref": "#/definitions/examplepbABitOfEverything" }, "error": { "$ref": "#/definitions/googleRpcStatus" } }, "title": "Stream result of examplepbABitOfEverything" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "error", "in": "query", "required": false, "type": "boolean" } ], "tags": [ "StreamService" ] } }, "/v1/example/a_bit_of_everything/bulk": { "post": { "operationId": "StreamService_BulkCreate", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "description": "Intentionally complicated message type to cover many features of Protobuf. (streaming inputs)", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbABitOfEverything" } } ], "tags": [ "StreamService" ] } }, "/v1/example/a_bit_of_everything/echo": { "post": { "operationId": "StreamService_BulkEcho", "responses": { "200": { "description": "A successful response.(streaming responses)", "schema": { "type": "object", "properties": { "result": { "$ref": "#/definitions/subStringMessage" }, "error": { "$ref": "#/definitions/googleRpcStatus" } }, "title": "Stream result of subStringMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "description": " (streaming inputs)", "in": "body", "required": true, "schema": { "$ref": "#/definitions/subStringMessage" } } ], "tags": [ "StreamService" ] } }, "/v1/example/a_bit_of_everything/echo_duration": { "post": { "operationId": "StreamService_BulkEchoDuration", "responses": { "200": { "description": "A successful response.(streaming responses)", "schema": { "type": "object", "properties": { "result": {}, "error": { "$ref": "#/definitions/googleRpcStatus" } }, "title": "Stream result of protobufDuration" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "description": " (streaming inputs)", "in": "body", "required": true, "schema": { "type": "string" } } ], "tags": [ "StreamService" ] } }, "/v1/example/download": { "get": { "operationId": "StreamService_Download", "responses": { "200": { "description": "A successful response.(streaming responses)", "schema": { "type": "string", "format": "binary", "properties": {}, "title": "Free form byte stream" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "error", "in": "query", "required": false, "type": "boolean" } ], "tags": [ "StreamService" ] } } }, "definitions": { "ABitOfEverythingNested": { "type": "object", "example": { "ok": "TRUE" }, "properties": { "name": { "type": "string", "description": "name is nested field." }, "amount": { "type": "integer", "format": "int64" }, "ok": { "$ref": "#/definitions/NestedDeepEnum", "description": "DeepEnum description." } }, "description": "Nested is nested type." }, "MessagePathEnumNestedPathEnum": { "type": "string", "enum": [ "GHI", "JKL" ], "default": "GHI" }, "NestedDeepEnum": { "type": "string", "enum": [ "FALSE", "TRUE" ], "default": "FALSE", "description": "DeepEnum is one or zero.\n\n - FALSE: FALSE is false.\n - TRUE: TRUE is true." }, "apiHttpBody": { "type": "object", "properties": { "contentType": { "type": "string", "description": "The HTTP Content-Type header value specifying the content type of the body." }, "data": { "type": "string", "format": "byte", "description": "The HTTP request/response body as raw binary." }, "extensions": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" }, "description": "Application specific response metadata. Must be set in the first response\nfor streaming APIs." } }, "description": "Message that represents an arbitrary HTTP body. It should only be used for\npayload formats that can't be represented as JSON, such as raw binary or\nan HTML page.\n\n\nThis message can be used both in streaming and non-streaming API methods in\nthe request as well as the response.\n\nIt can be used as a top-level request field, which is convenient if one\nwants to extract parameters from either the URL or HTTP template into the\nrequest fields and also want access to the raw HTTP body.\n\nExample:\n\n message GetResourceRequest {\n // A unique request id.\n string request_id = 1;\n\n // The raw HTTP body is bound to this field.\n google.api.HttpBody http_body = 2;\n\n }\n\n service ResourceService {\n rpc GetResource(GetResourceRequest)\n returns (google.api.HttpBody);\n rpc UpdateResource(google.api.HttpBody)\n returns (google.protobuf.Empty);\n\n }\n\nExample with streaming methods:\n\n service CaldavService {\n rpc GetCalendar(stream google.api.HttpBody)\n returns (stream google.api.HttpBody);\n rpc UpdateCalendar(stream google.api.HttpBody)\n returns (stream google.api.HttpBody);\n\n }\n\nUse of this type only changes how the request and response bodies are\nhandled, all other features will continue to work unchanged." }, "examplepbABitOfEverything": { "type": "object", "example": { "int64_value": 12, "double_value": 12.3 }, "properties": { "singleNested": { "$ref": "#/definitions/ABitOfEverythingNested" }, "uuid": { "type": "string", "format": "uuid", "minLength": 1, "pattern": "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}", "x-internal": true }, "nested": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/ABitOfEverythingNested" } }, "floatValue": { "type": "number", "format": "float", "default": "0.2", "description": "Float value field" }, "doubleValue": { "type": "number", "format": "double" }, "int64Value": { "type": "string", "format": "int64" }, "uint64Value": { "type": "string", "format": "uint64" }, "int32Value": { "type": "integer", "format": "int32" }, "fixed64Value": { "type": "string", "format": "uint64" }, "fixed32Value": { "type": "integer", "format": "int64" }, "boolValue": { "type": "boolean" }, "stringValue": { "type": "string" }, "bytesValue": { "type": "string", "format": "byte" }, "uint32Value": { "type": "integer", "format": "int64" }, "enumValue": { "$ref": "#/definitions/examplepbNumericEnum" }, "pathEnumValue": { "$ref": "#/definitions/pathenumPathEnum" }, "nestedPathEnumValue": { "$ref": "#/definitions/MessagePathEnumNestedPathEnum" }, "sfixed32Value": { "type": "integer", "format": "int32" }, "sfixed64Value": { "type": "string", "format": "int64" }, "sint32Value": { "type": "integer", "format": "int32" }, "sint64Value": { "type": "string", "format": "int64" }, "repeatedStringValue": { "type": "array", "items": { "type": "string" } }, "oneofEmpty": { "type": "object", "properties": {} }, "oneofString": { "type": "string" }, "mapValue": { "type": "object", "additionalProperties": { "$ref": "#/definitions/examplepbNumericEnum" }, "title": "map of numeric enum" }, "mappedStringValue": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Map of string description.", "title": "Map of string title" }, "mappedNestedValue": { "type": "object", "additionalProperties": { "$ref": "#/definitions/ABitOfEverythingNested" } }, "nonConventionalNameValue": { "type": "string" }, "timestampValue": { "type": "string", "format": "date-time" }, "repeatedEnumValue": { "type": "array", "items": { "$ref": "#/definitions/examplepbNumericEnum" }, "title": "repeated enum value. it is comma-separated in query" }, "repeatedEnumAnnotation": { "type": "array", "items": { "$ref": "#/definitions/examplepbNumericEnum" }, "description": "Repeated numeric enum description.", "title": "Repeated numeric enum title" }, "enumValueAnnotation": { "$ref": "#/definitions/examplepbNumericEnum", "description": "Numeric enum description.", "title": "Numeric enum title" }, "repeatedStringAnnotation": { "type": "array", "items": { "type": "string" }, "description": "Repeated string description.", "title": "Repeated string title" }, "repeatedNestedAnnotation": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/ABitOfEverythingNested" }, "description": "Repeated nested object description.", "title": "Repeated nested object title" }, "nestedAnnotation": { "$ref": "#/definitions/ABitOfEverythingNested", "description": "Nested object description.", "title": "Nested object title" }, "int64OverrideType": { "type": "integer", "format": "int64" }, "requiredStringViaFieldBehaviorAnnotation": { "type": "string", "title": "mark a field as required in Open API definition" }, "outputOnlyStringViaFieldBehaviorAnnotation": { "type": "string", "title": "mark a field as readonly in Open API definition", "readOnly": true }, "optionalStringValue": { "type": "string" }, "productId": { "type": "array", "items": { "type": "string", "maxLength": 19, "minLength": 1, "pattern": "^[0-9]+$" }, "description": "Only digits are allowed.", "title": "Test openapiv2 generation of repeated fields" }, "optionalStringField": { "type": "string", "title": "Test openapiv2 generation of required fields with annotation and jsonschema to reproduce" }, "requiredStringField1": { "type": "string" }, "requiredStringField2": { "type": "string" }, "required_field_behavior_json_name_custom": { "type": "string", "title": "Test openapiv2 handling of required json_name fields" }, "required_field_schema_json_name_custom": { "type": "string" }, "trailingOnly": { "type": "string", "title": "Trailing only" }, "trailingOnlyDot": { "type": "string", "description": "Trailing only dot." }, "trailingBoth": { "type": "string", "description": "Trailing both.", "title": "Leading both" }, "trailingMultiline": { "type": "string", "description": "This is an example of a multi-line comment.\n\nTrailing multiline.", "title": "Leading multiline" }, "uuids": { "type": "array", "items": { "type": "string", "format": "uuid" }, "title": "Specify a custom format of repeated field items" } }, "description": "Intentionally complicated message type to cover many features of Protobuf.", "title": "A bit of everything", "externalDocs": { "description": "Find out more about ABitOfEverything", "url": "https://github.com/grpc-ecosystem/grpc-gateway" }, "required": [ "uuid", "int64Value", "doubleValue", "required_field_schema_json_name_custom", "floatValue", "requiredStringViaFieldBehaviorAnnotation", "requiredStringField1", "requiredStringField2", "required_field_behavior_json_name_custom" ], "x-a-bit-of-everything-foo": "bar" }, "examplepbNumericEnum": { "type": "string", "example": "ZERO", "enum": [ "ZERO", "ONE" ], "default": "ZERO", "description": "NumericEnum is one or zero.", "title": "NumericEnum", "externalDocs": { "description": "Find out more about ABitOfEverything", "url": "https://github.com/grpc-ecosystem/grpc-gateway" }, "x-a-bit-of-everything-foo": "bar" }, "googleRpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32", "description": "The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]." }, "message": { "type": "string", "description": "A developer-facing error message, which should be in English. Any\nuser-facing error message should be localized and sent in the\n[google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client." }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" }, "description": "A list of messages that carry the error details. There is a common set of\nmessage types for APIs to use." } }, "description": "The `Status` type defines a logical error model that is suitable for\ndifferent programming environments, including REST APIs and RPC APIs. It is\nused by [gRPC](https://github.com/grpc). Each `Status` message contains\nthree pieces of data: error code, error message, and error details.\n\nYou can find out more about this error model and how to work with it in the\n[API Design Guide](https://cloud.google.com/apis/design/errors)." }, "pathenumPathEnum": { "type": "string", "enum": [ "ABC", "DEF" ], "default": "ABC" }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string", "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics." } }, "additionalProperties": {}, "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }" }, "subStringMessage": { "type": "object", "properties": { "value": { "type": "string" } } } } } ================================================ FILE: examples/internal/proto/examplepb/stream_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: examples/internal/proto/examplepb/stream.proto package examplepb import ( context "context" sub "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub" httpbody "google.golang.org/genproto/googleapis/api/httpbody" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" durationpb "google.golang.org/protobuf/types/known/durationpb" emptypb "google.golang.org/protobuf/types/known/emptypb" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( StreamService_BulkCreate_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.StreamService/BulkCreate" StreamService_List_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.StreamService/List" StreamService_BulkEcho_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.StreamService/BulkEcho" StreamService_BulkEchoDuration_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.StreamService/BulkEchoDuration" StreamService_Download_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.StreamService/Download" ) // StreamServiceClient is the client API for StreamService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // // Defines some more operations to be added to ABitOfEverythingService type StreamServiceClient interface { BulkCreate(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[ABitOfEverything, emptypb.Empty], error) List(ctx context.Context, in *Options, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ABitOfEverything], error) BulkEcho(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[sub.StringMessage, sub.StringMessage], error) BulkEchoDuration(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[durationpb.Duration, durationpb.Duration], error) Download(ctx context.Context, in *Options, opts ...grpc.CallOption) (grpc.ServerStreamingClient[httpbody.HttpBody], error) } type streamServiceClient struct { cc grpc.ClientConnInterface } func NewStreamServiceClient(cc grpc.ClientConnInterface) StreamServiceClient { return &streamServiceClient{cc} } func (c *streamServiceClient) BulkCreate(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[ABitOfEverything, emptypb.Empty], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &StreamService_ServiceDesc.Streams[0], StreamService_BulkCreate_FullMethodName, cOpts...) if err != nil { return nil, err } x := &grpc.GenericClientStream[ABitOfEverything, emptypb.Empty]{ClientStream: stream} return x, nil } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type StreamService_BulkCreateClient = grpc.ClientStreamingClient[ABitOfEverything, emptypb.Empty] func (c *streamServiceClient) List(ctx context.Context, in *Options, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ABitOfEverything], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &StreamService_ServiceDesc.Streams[1], StreamService_List_FullMethodName, cOpts...) if err != nil { return nil, err } x := &grpc.GenericClientStream[Options, ABitOfEverything]{ClientStream: stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } if err := x.ClientStream.CloseSend(); err != nil { return nil, err } return x, nil } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type StreamService_ListClient = grpc.ServerStreamingClient[ABitOfEverything] func (c *streamServiceClient) BulkEcho(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[sub.StringMessage, sub.StringMessage], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &StreamService_ServiceDesc.Streams[2], StreamService_BulkEcho_FullMethodName, cOpts...) if err != nil { return nil, err } x := &grpc.GenericClientStream[sub.StringMessage, sub.StringMessage]{ClientStream: stream} return x, nil } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type StreamService_BulkEchoClient = grpc.BidiStreamingClient[sub.StringMessage, sub.StringMessage] func (c *streamServiceClient) BulkEchoDuration(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[durationpb.Duration, durationpb.Duration], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &StreamService_ServiceDesc.Streams[3], StreamService_BulkEchoDuration_FullMethodName, cOpts...) if err != nil { return nil, err } x := &grpc.GenericClientStream[durationpb.Duration, durationpb.Duration]{ClientStream: stream} return x, nil } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type StreamService_BulkEchoDurationClient = grpc.BidiStreamingClient[durationpb.Duration, durationpb.Duration] func (c *streamServiceClient) Download(ctx context.Context, in *Options, opts ...grpc.CallOption) (grpc.ServerStreamingClient[httpbody.HttpBody], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &StreamService_ServiceDesc.Streams[4], StreamService_Download_FullMethodName, cOpts...) if err != nil { return nil, err } x := &grpc.GenericClientStream[Options, httpbody.HttpBody]{ClientStream: stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } if err := x.ClientStream.CloseSend(); err != nil { return nil, err } return x, nil } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type StreamService_DownloadClient = grpc.ServerStreamingClient[httpbody.HttpBody] // StreamServiceServer is the server API for StreamService service. // All implementations should embed UnimplementedStreamServiceServer // for forward compatibility. // // Defines some more operations to be added to ABitOfEverythingService type StreamServiceServer interface { BulkCreate(grpc.ClientStreamingServer[ABitOfEverything, emptypb.Empty]) error List(*Options, grpc.ServerStreamingServer[ABitOfEverything]) error BulkEcho(grpc.BidiStreamingServer[sub.StringMessage, sub.StringMessage]) error BulkEchoDuration(grpc.BidiStreamingServer[durationpb.Duration, durationpb.Duration]) error Download(*Options, grpc.ServerStreamingServer[httpbody.HttpBody]) error } // UnimplementedStreamServiceServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedStreamServiceServer struct{} func (UnimplementedStreamServiceServer) BulkCreate(grpc.ClientStreamingServer[ABitOfEverything, emptypb.Empty]) error { return status.Errorf(codes.Unimplemented, "method BulkCreate not implemented") } func (UnimplementedStreamServiceServer) List(*Options, grpc.ServerStreamingServer[ABitOfEverything]) error { return status.Errorf(codes.Unimplemented, "method List not implemented") } func (UnimplementedStreamServiceServer) BulkEcho(grpc.BidiStreamingServer[sub.StringMessage, sub.StringMessage]) error { return status.Errorf(codes.Unimplemented, "method BulkEcho not implemented") } func (UnimplementedStreamServiceServer) BulkEchoDuration(grpc.BidiStreamingServer[durationpb.Duration, durationpb.Duration]) error { return status.Errorf(codes.Unimplemented, "method BulkEchoDuration not implemented") } func (UnimplementedStreamServiceServer) Download(*Options, grpc.ServerStreamingServer[httpbody.HttpBody]) error { return status.Errorf(codes.Unimplemented, "method Download not implemented") } func (UnimplementedStreamServiceServer) testEmbeddedByValue() {} // UnsafeStreamServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to StreamServiceServer will // result in compilation errors. type UnsafeStreamServiceServer interface { mustEmbedUnimplementedStreamServiceServer() } func RegisterStreamServiceServer(s grpc.ServiceRegistrar, srv StreamServiceServer) { // If the following call pancis, it indicates UnimplementedStreamServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&StreamService_ServiceDesc, srv) } func _StreamService_BulkCreate_Handler(srv interface{}, stream grpc.ServerStream) error { return srv.(StreamServiceServer).BulkCreate(&grpc.GenericServerStream[ABitOfEverything, emptypb.Empty]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type StreamService_BulkCreateServer = grpc.ClientStreamingServer[ABitOfEverything, emptypb.Empty] func _StreamService_List_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(Options) if err := stream.RecvMsg(m); err != nil { return err } return srv.(StreamServiceServer).List(m, &grpc.GenericServerStream[Options, ABitOfEverything]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type StreamService_ListServer = grpc.ServerStreamingServer[ABitOfEverything] func _StreamService_BulkEcho_Handler(srv interface{}, stream grpc.ServerStream) error { return srv.(StreamServiceServer).BulkEcho(&grpc.GenericServerStream[sub.StringMessage, sub.StringMessage]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type StreamService_BulkEchoServer = grpc.BidiStreamingServer[sub.StringMessage, sub.StringMessage] func _StreamService_BulkEchoDuration_Handler(srv interface{}, stream grpc.ServerStream) error { return srv.(StreamServiceServer).BulkEchoDuration(&grpc.GenericServerStream[durationpb.Duration, durationpb.Duration]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type StreamService_BulkEchoDurationServer = grpc.BidiStreamingServer[durationpb.Duration, durationpb.Duration] func _StreamService_Download_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(Options) if err := stream.RecvMsg(m); err != nil { return err } return srv.(StreamServiceServer).Download(m, &grpc.GenericServerStream[Options, httpbody.HttpBody]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type StreamService_DownloadServer = grpc.ServerStreamingServer[httpbody.HttpBody] // StreamService_ServiceDesc is the grpc.ServiceDesc for StreamService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var StreamService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.StreamService", HandlerType: (*StreamServiceServer)(nil), Methods: []grpc.MethodDesc{}, Streams: []grpc.StreamDesc{ { StreamName: "BulkCreate", Handler: _StreamService_BulkCreate_Handler, ClientStreams: true, }, { StreamName: "List", Handler: _StreamService_List_Handler, ServerStreams: true, }, { StreamName: "BulkEcho", Handler: _StreamService_BulkEcho_Handler, ServerStreams: true, ClientStreams: true, }, { StreamName: "BulkEchoDuration", Handler: _StreamService_BulkEchoDuration_Handler, ServerStreams: true, ClientStreams: true, }, { StreamName: "Download", Handler: _StreamService_Download_Handler, ServerStreams: true, }, }, Metadata: "examples/internal/proto/examplepb/stream.proto", } ================================================ FILE: examples/internal/proto/examplepb/unannotated_echo_service.buf.gen.yaml ================================================ version: v1 plugins: - plugin: grpc-gateway out: . opt: - paths=source_relative - grpc_api_configuration=examples/internal/proto/examplepb/unannotated_echo_service.yaml - plugin: openapiv2 out: . opt: - grpc_api_configuration=examples/internal/proto/examplepb/unannotated_echo_service.yaml - openapi_configuration=examples/internal/proto/examplepb/unannotated_echo_service.swagger.yaml - generate_x_go_type=true ================================================ FILE: examples/internal/proto/examplepb/unannotated_echo_service.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/examplepb/unannotated_echo_service.proto // Unannotated Echo Service // Similar to echo_service.proto but without annotations. See // unannotated_echo_service.yaml for the equivalent of the annotations in // gRPC API configuration format. // // Echo Service API consists of a single service which returns // a message. package examplepb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" durationpb "google.golang.org/protobuf/types/known/durationpb" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) // Embedded represents a message embedded in SimpleMessage. type UnannotatedEmbedded struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Types that are assignable to Mark: // // *UnannotatedEmbedded_Progress // *UnannotatedEmbedded_Note Mark isUnannotatedEmbedded_Mark `protobuf_oneof:"mark"` } func (x *UnannotatedEmbedded) Reset() { *x = UnannotatedEmbedded{} mi := &file_examples_internal_proto_examplepb_unannotated_echo_service_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *UnannotatedEmbedded) String() string { return protoimpl.X.MessageStringOf(x) } func (*UnannotatedEmbedded) ProtoMessage() {} func (x *UnannotatedEmbedded) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_unannotated_echo_service_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use UnannotatedEmbedded.ProtoReflect.Descriptor instead. func (*UnannotatedEmbedded) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_unannotated_echo_service_proto_rawDescGZIP(), []int{0} } func (m *UnannotatedEmbedded) GetMark() isUnannotatedEmbedded_Mark { if m != nil { return m.Mark } return nil } func (x *UnannotatedEmbedded) GetProgress() int64 { if x, ok := x.GetMark().(*UnannotatedEmbedded_Progress); ok { return x.Progress } return 0 } func (x *UnannotatedEmbedded) GetNote() string { if x, ok := x.GetMark().(*UnannotatedEmbedded_Note); ok { return x.Note } return "" } type isUnannotatedEmbedded_Mark interface { isUnannotatedEmbedded_Mark() } type UnannotatedEmbedded_Progress struct { Progress int64 `protobuf:"varint,1,opt,name=progress,proto3,oneof"` } type UnannotatedEmbedded_Note struct { Note string `protobuf:"bytes,2,opt,name=note,proto3,oneof"` } func (*UnannotatedEmbedded_Progress) isUnannotatedEmbedded_Mark() {} func (*UnannotatedEmbedded_Note) isUnannotatedEmbedded_Mark() {} type UnannotatedNestedMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields NId string `protobuf:"bytes,1,opt,name=n_id,json=nId,proto3" json:"n_id,omitempty"` Val string `protobuf:"bytes,2,opt,name=val,proto3" json:"val,omitempty"` } func (x *UnannotatedNestedMessage) Reset() { *x = UnannotatedNestedMessage{} mi := &file_examples_internal_proto_examplepb_unannotated_echo_service_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *UnannotatedNestedMessage) String() string { return protoimpl.X.MessageStringOf(x) } func (*UnannotatedNestedMessage) ProtoMessage() {} func (x *UnannotatedNestedMessage) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_unannotated_echo_service_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use UnannotatedNestedMessage.ProtoReflect.Descriptor instead. func (*UnannotatedNestedMessage) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_unannotated_echo_service_proto_rawDescGZIP(), []int{1} } func (x *UnannotatedNestedMessage) GetNId() string { if x != nil { return x.NId } return "" } func (x *UnannotatedNestedMessage) GetVal() string { if x != nil { return x.Val } return "" } // UnannotatedSimpleMessage represents a simple message sent to the unannotated Echo service. type UnannotatedSimpleMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Id represents the message identifier. Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Num int64 `protobuf:"varint,2,opt,name=num,proto3" json:"num,omitempty"` Duration *durationpb.Duration `protobuf:"bytes,3,opt,name=duration,proto3" json:"duration,omitempty"` // Types that are assignable to Code: // // *UnannotatedSimpleMessage_LineNum // *UnannotatedSimpleMessage_Lang Code isUnannotatedSimpleMessage_Code `protobuf_oneof:"code"` Status *UnannotatedEmbedded `protobuf:"bytes,6,opt,name=status,proto3" json:"status,omitempty"` // Types that are assignable to Ext: // // *UnannotatedSimpleMessage_En // *UnannotatedSimpleMessage_No Ext isUnannotatedSimpleMessage_Ext `protobuf_oneof:"ext"` ResourceId string `protobuf:"bytes,9,opt,name=resource_id,json=resourceId,proto3" json:"resource_id,omitempty"` NId *UnannotatedNestedMessage `protobuf:"bytes,10,opt,name=n_id,json=nId,proto3" json:"n_id,omitempty"` } func (x *UnannotatedSimpleMessage) Reset() { *x = UnannotatedSimpleMessage{} mi := &file_examples_internal_proto_examplepb_unannotated_echo_service_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *UnannotatedSimpleMessage) String() string { return protoimpl.X.MessageStringOf(x) } func (*UnannotatedSimpleMessage) ProtoMessage() {} func (x *UnannotatedSimpleMessage) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_unannotated_echo_service_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use UnannotatedSimpleMessage.ProtoReflect.Descriptor instead. func (*UnannotatedSimpleMessage) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_unannotated_echo_service_proto_rawDescGZIP(), []int{2} } func (x *UnannotatedSimpleMessage) GetId() string { if x != nil { return x.Id } return "" } func (x *UnannotatedSimpleMessage) GetNum() int64 { if x != nil { return x.Num } return 0 } func (x *UnannotatedSimpleMessage) GetDuration() *durationpb.Duration { if x != nil { return x.Duration } return nil } func (m *UnannotatedSimpleMessage) GetCode() isUnannotatedSimpleMessage_Code { if m != nil { return m.Code } return nil } func (x *UnannotatedSimpleMessage) GetLineNum() int64 { if x, ok := x.GetCode().(*UnannotatedSimpleMessage_LineNum); ok { return x.LineNum } return 0 } func (x *UnannotatedSimpleMessage) GetLang() string { if x, ok := x.GetCode().(*UnannotatedSimpleMessage_Lang); ok { return x.Lang } return "" } func (x *UnannotatedSimpleMessage) GetStatus() *UnannotatedEmbedded { if x != nil { return x.Status } return nil } func (m *UnannotatedSimpleMessage) GetExt() isUnannotatedSimpleMessage_Ext { if m != nil { return m.Ext } return nil } func (x *UnannotatedSimpleMessage) GetEn() int64 { if x, ok := x.GetExt().(*UnannotatedSimpleMessage_En); ok { return x.En } return 0 } func (x *UnannotatedSimpleMessage) GetNo() *UnannotatedEmbedded { if x, ok := x.GetExt().(*UnannotatedSimpleMessage_No); ok { return x.No } return nil } func (x *UnannotatedSimpleMessage) GetResourceId() string { if x != nil { return x.ResourceId } return "" } func (x *UnannotatedSimpleMessage) GetNId() *UnannotatedNestedMessage { if x != nil { return x.NId } return nil } type isUnannotatedSimpleMessage_Code interface { isUnannotatedSimpleMessage_Code() } type UnannotatedSimpleMessage_LineNum struct { LineNum int64 `protobuf:"varint,4,opt,name=line_num,json=lineNum,proto3,oneof"` } type UnannotatedSimpleMessage_Lang struct { Lang string `protobuf:"bytes,5,opt,name=lang,proto3,oneof"` } func (*UnannotatedSimpleMessage_LineNum) isUnannotatedSimpleMessage_Code() {} func (*UnannotatedSimpleMessage_Lang) isUnannotatedSimpleMessage_Code() {} type isUnannotatedSimpleMessage_Ext interface { isUnannotatedSimpleMessage_Ext() } type UnannotatedSimpleMessage_En struct { En int64 `protobuf:"varint,7,opt,name=en,proto3,oneof"` } type UnannotatedSimpleMessage_No struct { No *UnannotatedEmbedded `protobuf:"bytes,8,opt,name=no,proto3,oneof"` } func (*UnannotatedSimpleMessage_En) isUnannotatedSimpleMessage_Ext() {} func (*UnannotatedSimpleMessage_No) isUnannotatedSimpleMessage_Ext() {} var File_examples_internal_proto_examplepb_unannotated_echo_service_proto protoreflect.FileDescriptor var file_examples_internal_proto_examplepb_unannotated_echo_service_proto_rawDesc = []byte{ 0x0a, 0x40, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x75, 0x6e, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x65, 0x63, 0x68, 0x6f, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x51, 0x0a, 0x13, 0x55, 0x6e, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x64, 0x45, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x12, 0x1c, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x14, 0x0a, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x42, 0x06, 0x0a, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x22, 0x3f, 0x0a, 0x18, 0x55, 0x6e, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x64, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x11, 0x0a, 0x04, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6e, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x22, 0xf9, 0x03, 0x0a, 0x18, 0x55, 0x6e, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x64, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6e, 0x75, 0x6d, 0x12, 0x35, 0x0a, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x08, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00, 0x52, 0x07, 0x6c, 0x69, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x14, 0x0a, 0x04, 0x6c, 0x61, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04, 0x6c, 0x61, 0x6e, 0x67, 0x12, 0x5b, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x43, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x55, 0x6e, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x64, 0x45, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x10, 0x0a, 0x02, 0x65, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x48, 0x01, 0x52, 0x02, 0x65, 0x6e, 0x12, 0x55, 0x0a, 0x02, 0x6e, 0x6f, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x43, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x55, 0x6e, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x64, 0x45, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x48, 0x01, 0x52, 0x02, 0x6e, 0x6f, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x12, 0x5b, 0x0a, 0x04, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x48, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x55, 0x6e, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x64, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x03, 0x6e, 0x49, 0x64, 0x42, 0x06, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x42, 0x05, 0x0a, 0x03, 0x65, 0x78, 0x74, 0x32, 0x9c, 0x05, 0x0a, 0x16, 0x55, 0x6e, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x64, 0x45, 0x63, 0x68, 0x6f, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x9a, 0x01, 0x0a, 0x04, 0x45, 0x63, 0x68, 0x6f, 0x12, 0x48, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x55, 0x6e, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x64, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x48, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x55, 0x6e, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x64, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x9e, 0x01, 0x0a, 0x08, 0x45, 0x63, 0x68, 0x6f, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x48, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x55, 0x6e, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x64, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x48, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x55, 0x6e, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x64, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0xa0, 0x01, 0x0a, 0x0a, 0x45, 0x63, 0x68, 0x6f, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x48, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x55, 0x6e, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x64, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x48, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x55, 0x6e, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x64, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0xa0, 0x01, 0x0a, 0x0a, 0x45, 0x63, 0x68, 0x6f, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x12, 0x48, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x55, 0x6e, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x64, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x48, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x55, 0x6e, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x64, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x57, 0x5a, 0x55, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x3b, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_examplepb_unannotated_echo_service_proto_rawDescOnce sync.Once file_examples_internal_proto_examplepb_unannotated_echo_service_proto_rawDescData = file_examples_internal_proto_examplepb_unannotated_echo_service_proto_rawDesc ) func file_examples_internal_proto_examplepb_unannotated_echo_service_proto_rawDescGZIP() []byte { file_examples_internal_proto_examplepb_unannotated_echo_service_proto_rawDescOnce.Do(func() { file_examples_internal_proto_examplepb_unannotated_echo_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_examplepb_unannotated_echo_service_proto_rawDescData) }) return file_examples_internal_proto_examplepb_unannotated_echo_service_proto_rawDescData } var file_examples_internal_proto_examplepb_unannotated_echo_service_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_examples_internal_proto_examplepb_unannotated_echo_service_proto_goTypes = []any{ (*UnannotatedEmbedded)(nil), // 0: grpc.gateway.examples.internal.proto.examplepb.UnannotatedEmbedded (*UnannotatedNestedMessage)(nil), // 1: grpc.gateway.examples.internal.proto.examplepb.UnannotatedNestedMessage (*UnannotatedSimpleMessage)(nil), // 2: grpc.gateway.examples.internal.proto.examplepb.UnannotatedSimpleMessage (*durationpb.Duration)(nil), // 3: google.protobuf.Duration } var file_examples_internal_proto_examplepb_unannotated_echo_service_proto_depIdxs = []int32{ 3, // 0: grpc.gateway.examples.internal.proto.examplepb.UnannotatedSimpleMessage.duration:type_name -> google.protobuf.Duration 0, // 1: grpc.gateway.examples.internal.proto.examplepb.UnannotatedSimpleMessage.status:type_name -> grpc.gateway.examples.internal.proto.examplepb.UnannotatedEmbedded 0, // 2: grpc.gateway.examples.internal.proto.examplepb.UnannotatedSimpleMessage.no:type_name -> grpc.gateway.examples.internal.proto.examplepb.UnannotatedEmbedded 1, // 3: grpc.gateway.examples.internal.proto.examplepb.UnannotatedSimpleMessage.n_id:type_name -> grpc.gateway.examples.internal.proto.examplepb.UnannotatedNestedMessage 2, // 4: grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService.Echo:input_type -> grpc.gateway.examples.internal.proto.examplepb.UnannotatedSimpleMessage 2, // 5: grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService.EchoBody:input_type -> grpc.gateway.examples.internal.proto.examplepb.UnannotatedSimpleMessage 2, // 6: grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService.EchoDelete:input_type -> grpc.gateway.examples.internal.proto.examplepb.UnannotatedSimpleMessage 2, // 7: grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService.EchoNested:input_type -> grpc.gateway.examples.internal.proto.examplepb.UnannotatedSimpleMessage 2, // 8: grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService.Echo:output_type -> grpc.gateway.examples.internal.proto.examplepb.UnannotatedSimpleMessage 2, // 9: grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService.EchoBody:output_type -> grpc.gateway.examples.internal.proto.examplepb.UnannotatedSimpleMessage 2, // 10: grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService.EchoDelete:output_type -> grpc.gateway.examples.internal.proto.examplepb.UnannotatedSimpleMessage 2, // 11: grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService.EchoNested:output_type -> grpc.gateway.examples.internal.proto.examplepb.UnannotatedSimpleMessage 8, // [8:12] is the sub-list for method output_type 4, // [4:8] is the sub-list for method input_type 4, // [4:4] is the sub-list for extension type_name 4, // [4:4] is the sub-list for extension extendee 0, // [0:4] is the sub-list for field type_name } func init() { file_examples_internal_proto_examplepb_unannotated_echo_service_proto_init() } func file_examples_internal_proto_examplepb_unannotated_echo_service_proto_init() { if File_examples_internal_proto_examplepb_unannotated_echo_service_proto != nil { return } file_examples_internal_proto_examplepb_unannotated_echo_service_proto_msgTypes[0].OneofWrappers = []any{ (*UnannotatedEmbedded_Progress)(nil), (*UnannotatedEmbedded_Note)(nil), } file_examples_internal_proto_examplepb_unannotated_echo_service_proto_msgTypes[2].OneofWrappers = []any{ (*UnannotatedSimpleMessage_LineNum)(nil), (*UnannotatedSimpleMessage_Lang)(nil), (*UnannotatedSimpleMessage_En)(nil), (*UnannotatedSimpleMessage_No)(nil), } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_examplepb_unannotated_echo_service_proto_rawDesc, NumEnums: 0, NumMessages: 3, NumExtensions: 0, NumServices: 1, }, GoTypes: file_examples_internal_proto_examplepb_unannotated_echo_service_proto_goTypes, DependencyIndexes: file_examples_internal_proto_examplepb_unannotated_echo_service_proto_depIdxs, MessageInfos: file_examples_internal_proto_examplepb_unannotated_echo_service_proto_msgTypes, }.Build() File_examples_internal_proto_examplepb_unannotated_echo_service_proto = out.File file_examples_internal_proto_examplepb_unannotated_echo_service_proto_rawDesc = nil file_examples_internal_proto_examplepb_unannotated_echo_service_proto_goTypes = nil file_examples_internal_proto_examplepb_unannotated_echo_service_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/examplepb/unannotated_echo_service.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/proto/examplepb/unannotated_echo_service.proto /* Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package examplepb import ( "context" "errors" "io" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) var filter_UnannotatedEchoService_Echo_0 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_UnannotatedEchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, client UnannotatedEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UnannotatedSimpleMessage metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_Echo_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_UnannotatedEchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, server UnannotatedEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UnannotatedSimpleMessage metadata runtime.ServerMetadata err error ) val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_Echo_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Echo(ctx, &protoReq) return msg, metadata, err } var filter_UnannotatedEchoService_Echo_1 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0, "num": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} func request_UnannotatedEchoService_Echo_1(ctx context.Context, marshaler runtime.Marshaler, client UnannotatedEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UnannotatedSimpleMessage metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } val, ok = pathParams["num"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "num") } protoReq.Num, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "num", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_Echo_1); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_UnannotatedEchoService_Echo_1(ctx context.Context, marshaler runtime.Marshaler, server UnannotatedEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UnannotatedSimpleMessage metadata runtime.ServerMetadata err error ) val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } val, ok = pathParams["num"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "num") } protoReq.Num, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "num", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_Echo_1); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Echo(ctx, &protoReq) return msg, metadata, err } func request_UnannotatedEchoService_EchoBody_0(ctx context.Context, marshaler runtime.Marshaler, client UnannotatedEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UnannotatedSimpleMessage metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.EchoBody(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_UnannotatedEchoService_EchoBody_0(ctx context.Context, marshaler runtime.Marshaler, server UnannotatedEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UnannotatedSimpleMessage metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.EchoBody(ctx, &protoReq) return msg, metadata, err } var filter_UnannotatedEchoService_EchoDelete_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_UnannotatedEchoService_EchoDelete_0(ctx context.Context, marshaler runtime.Marshaler, client UnannotatedEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UnannotatedSimpleMessage metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_EchoDelete_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.EchoDelete(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_UnannotatedEchoService_EchoDelete_0(ctx context.Context, marshaler runtime.Marshaler, server UnannotatedEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UnannotatedSimpleMessage metadata runtime.ServerMetadata ) if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_EchoDelete_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.EchoDelete(ctx, &protoReq) return msg, metadata, err } func request_UnannotatedEchoService_EchoNested_0(ctx context.Context, marshaler runtime.Marshaler, client UnannotatedEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UnannotatedSimpleMessage metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.EchoNested(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_UnannotatedEchoService_EchoNested_0(ctx context.Context, marshaler runtime.Marshaler, server UnannotatedEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UnannotatedSimpleMessage metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.EchoNested(ctx, &protoReq) return msg, metadata, err } // RegisterUnannotatedEchoServiceHandlerServer registers the http handlers for service UnannotatedEchoService to "mux". // UnaryRPC :call UnannotatedEchoServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterUnannotatedEchoServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterUnannotatedEchoServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UnannotatedEchoServiceServer) error { mux.Handle(http.MethodPost, pattern_UnannotatedEchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_UnannotatedEchoService_Echo_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_UnannotatedEchoService_Echo_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo/{id}/{num}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_UnannotatedEchoService_Echo_1(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_Echo_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_UnannotatedEchoService_EchoBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/EchoBody", runtime.WithHTTPPathPattern("/v1/example/echo_body")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_UnannotatedEchoService_EchoBody_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_EchoBody_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodDelete, pattern_UnannotatedEchoService_EchoDelete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/EchoDelete", runtime.WithHTTPPathPattern("/v1/example/echo_delete")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_UnannotatedEchoService_EchoDelete_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_EchoDelete_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPut, pattern_UnannotatedEchoService_EchoNested_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/EchoNested", runtime.WithHTTPPathPattern("/v1/example/echo_nested")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_UnannotatedEchoService_EchoNested_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_EchoNested_0(annotatedContext, mux, outboundMarshaler, w, req, response_UnannotatedEchoService_EchoNested_0{resp.(*UnannotatedSimpleMessage)}, mux.GetForwardResponseOptions()...) }) return nil } // RegisterUnannotatedEchoServiceHandlerFromEndpoint is same as RegisterUnannotatedEchoServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterUnannotatedEchoServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterUnannotatedEchoServiceHandler(ctx, mux, conn) } // RegisterUnannotatedEchoServiceHandler registers the http handlers for service UnannotatedEchoService to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterUnannotatedEchoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterUnannotatedEchoServiceHandlerClient(ctx, mux, NewUnannotatedEchoServiceClient(conn)) } // RegisterUnannotatedEchoServiceHandlerClient registers the http handlers for service UnannotatedEchoService // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "UnannotatedEchoServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "UnannotatedEchoServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "UnannotatedEchoServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterUnannotatedEchoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UnannotatedEchoServiceClient) error { mux.Handle(http.MethodPost, pattern_UnannotatedEchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_UnannotatedEchoService_Echo_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_UnannotatedEchoService_Echo_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo/{id}/{num}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_UnannotatedEchoService_Echo_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_Echo_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_UnannotatedEchoService_EchoBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/EchoBody", runtime.WithHTTPPathPattern("/v1/example/echo_body")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_UnannotatedEchoService_EchoBody_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_EchoBody_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodDelete, pattern_UnannotatedEchoService_EchoDelete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/EchoDelete", runtime.WithHTTPPathPattern("/v1/example/echo_delete")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_UnannotatedEchoService_EchoDelete_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_EchoDelete_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPut, pattern_UnannotatedEchoService_EchoNested_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/EchoNested", runtime.WithHTTPPathPattern("/v1/example/echo_nested")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_UnannotatedEchoService_EchoNested_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_EchoNested_0(annotatedContext, mux, outboundMarshaler, w, req, response_UnannotatedEchoService_EchoNested_0{resp.(*UnannotatedSimpleMessage)}, mux.GetForwardResponseOptions()...) }) return nil } type response_UnannotatedEchoService_EchoNested_0 struct { *UnannotatedSimpleMessage } func (m response_UnannotatedEchoService_EchoNested_0) XXX_ResponseBody() interface{} { response := m.UnannotatedSimpleMessage return response.NId } var ( pattern_UnannotatedEchoService_Echo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "example", "echo", "id"}, "")) pattern_UnannotatedEchoService_Echo_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"v1", "example", "echo", "id", "num"}, "")) pattern_UnannotatedEchoService_EchoBody_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "echo_body"}, "")) pattern_UnannotatedEchoService_EchoDelete_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "echo_delete"}, "")) pattern_UnannotatedEchoService_EchoNested_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "echo_nested"}, "")) ) var ( forward_UnannotatedEchoService_Echo_0 = runtime.ForwardResponseMessage forward_UnannotatedEchoService_Echo_1 = runtime.ForwardResponseMessage forward_UnannotatedEchoService_EchoBody_0 = runtime.ForwardResponseMessage forward_UnannotatedEchoService_EchoDelete_0 = runtime.ForwardResponseMessage forward_UnannotatedEchoService_EchoNested_0 = runtime.ForwardResponseMessage ) ================================================ FILE: examples/internal/proto/examplepb/unannotated_echo_service.proto ================================================ syntax = "proto3"; // Unannotated Echo Service // Similar to echo_service.proto but without annotations. See // unannotated_echo_service.yaml for the equivalent of the annotations in // gRPC API configuration format. // // Echo Service API consists of a single service which returns // a message. package grpc.gateway.examples.internal.proto.examplepb; // Do not need annotations.proto, can still use well known types as usual import "google/protobuf/duration.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb;examplepb"; // Embedded represents a message embedded in SimpleMessage. message UnannotatedEmbedded { oneof mark { int64 progress = 1; string note = 2; } } message UnannotatedNestedMessage { string n_id = 1; string val = 2; } // UnannotatedSimpleMessage represents a simple message sent to the unannotated Echo service. message UnannotatedSimpleMessage { // Id represents the message identifier. string id = 1; int64 num = 2; google.protobuf.Duration duration = 3; oneof code { int64 line_num = 4; string lang = 5; } UnannotatedEmbedded status = 6; oneof ext { int64 en = 7; UnannotatedEmbedded no = 8; } string resource_id = 9; UnannotatedNestedMessage n_id = 10; } // Echo service responds to incoming echo requests. service UnannotatedEchoService { // Echo method receives a simple message and returns it. // // The message posted as the id parameter will also be // returned. rpc Echo(UnannotatedSimpleMessage) returns (UnannotatedSimpleMessage); // EchoBody method receives a simple message and returns it. rpc EchoBody(UnannotatedSimpleMessage) returns (UnannotatedSimpleMessage); // EchoDelete method receives a simple message and returns it. rpc EchoDelete(UnannotatedSimpleMessage) returns (UnannotatedSimpleMessage); // EchoNested method receives a simple message and returns it. rpc EchoNested(UnannotatedSimpleMessage) returns (UnannotatedSimpleMessage); } ================================================ FILE: examples/internal/proto/examplepb/unannotated_echo_service.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "Unannotated Echo", "description": "Unannotated Echo Service\nSimilar to echo_service.proto but without annotations. See\nunannotated_echo_service.yaml for the equivalent of the annotations in\ngRPC API configuration format.\n\nEcho Service API consists of a single service which returns\na message.", "version": "1.0", "contact": { "name": "gRPC-Gateway project", "url": "https://github.com/grpc-ecosystem/grpc-gateway", "email": "none@example.com" }, "license": { "name": "BSD 3-Clause License", "url": "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE" }, "x-something-something": "yadda" }, "tags": [ { "name": "Echo", "description": "Echo description" }, { "name": "Internal", "description": "Internal description", "x-traitTag": true }, { "name": "UnannotatedEchoService", "description": "UnannotatedEchoService description -- which should not be used in place of the documentation comment!", "externalDocs": { "description": "Find out more about UnannotatedEchoService", "url": "https://github.com/grpc-ecosystem/grpc-gateway" } } ], "schemes": [ "http", "https", "wss" ], "consumes": [ "application/json", "application/x-foo-mime" ], "produces": [ "application/json", "application/x-foo-mime" ], "paths": { "/v1/example/echo/{id}": { "post": { "summary": "Summary: Echo rpc", "description": "Description Echo", "operationId": "UnannotatedEchoService_Echo", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbUnannotatedSimpleMessage" }, "examples": { "application/json": { "value": "the input value" } } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "integer", "format": "integer" } }, "503": { "description": "Returned when the resource is temporarily unavailable.", "schema": {}, "x-number": 100 }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "path", "required": true, "type": "string" }, { "name": "num", "description": "Int value field", "in": "query", "required": true, "type": "string", "format": "int64", "default": "42" }, { "name": "duration", "in": "query", "required": false, "type": "string" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "resourceId", "in": "query", "required": false, "type": "string" }, { "name": "nId.nId", "in": "query", "required": false, "type": "string" }, { "name": "nId.val", "in": "query", "required": false, "type": "string" } ], "tags": [ "UnannotatedEchoService" ], "externalDocs": { "description": "Find out more Echo", "url": "https://github.com/grpc-ecosystem/grpc-gateway" } } }, "/v1/example/echo/{id}/{num}": { "get": { "summary": "Summary: Echo rpc", "description": "Description Echo", "operationId": "UnannotatedEchoService_Echo2", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbUnannotatedSimpleMessage" }, "examples": { "application/json": { "value": "the input value" } } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "integer", "format": "integer" } }, "503": { "description": "Returned when the resource is temporarily unavailable.", "schema": {}, "x-number": 100 }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "path", "required": true, "type": "string" }, { "name": "num", "description": "Int value field", "in": "path", "required": true, "type": "string", "format": "int64", "default": "42" }, { "name": "duration", "in": "query", "required": false, "type": "string" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "resourceId", "in": "query", "required": false, "type": "string" }, { "name": "nId.nId", "in": "query", "required": false, "type": "string" }, { "name": "nId.val", "in": "query", "required": false, "type": "string" } ], "tags": [ "UnannotatedEchoService" ], "externalDocs": { "description": "Find out more Echo", "url": "https://github.com/grpc-ecosystem/grpc-gateway" } } }, "/v1/example/echo_body": { "post": { "summary": "EchoBody method receives a simple message and returns it.", "operationId": "UnannotatedEchoService_EchoBody", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbUnannotatedSimpleMessage" } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "body", "description": "A simple message with many types", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbUnannotatedSimpleMessage" } } ], "tags": [ "UnannotatedEchoService" ] } }, "/v1/example/echo_delete": { "delete": { "summary": "EchoDelete method receives a simple message and returns it.", "operationId": "UnannotatedEchoService_EchoDelete", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbUnannotatedSimpleMessage" } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "query", "required": false, "type": "string" }, { "name": "num", "description": "Int value field", "in": "query", "required": true, "type": "string", "format": "int64", "default": "42" }, { "name": "duration", "in": "query", "required": false, "type": "string" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "resourceId", "in": "query", "required": false, "type": "string" }, { "name": "nId.nId", "in": "query", "required": false, "type": "string" }, { "name": "nId.val", "in": "query", "required": false, "type": "string" } ], "tags": [ "UnannotatedEchoService" ] } }, "/v1/example/echo_nested": { "put": { "summary": "EchoNested method receives a simple message and returns it.", "operationId": "UnannotatedEchoService_EchoNested", "responses": { "200": { "description": "", "schema": { "$ref": "#/definitions/examplepbUnannotatedNestedMessage" } }, "403": { "description": "Returned when the user does not have permission to access the resource.", "schema": {} }, "404": { "description": "Returned when the resource does not exist.", "schema": { "type": "string", "format": "string" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "body", "description": "A simple message with many types", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbUnannotatedSimpleMessage" } } ], "tags": [ "UnannotatedEchoService" ] } } }, "definitions": { "examplepbUnannotatedEmbedded": { "type": "object", "properties": { "progress": { "type": "string", "format": "int64" }, "note": { "type": "string" } }, "description": "Embedded represents a message embedded in SimpleMessage.", "x-go-type": { "import": { "package": "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb" }, "type": "UnannotatedEmbedded" } }, "examplepbUnannotatedNestedMessage": { "type": "object", "properties": { "nId": { "type": "string" }, "val": { "type": "string" } }, "x-go-type": { "import": { "package": "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb" }, "type": "UnannotatedNestedMessage" } }, "examplepbUnannotatedSimpleMessage": { "type": "object", "example": { "id": "myid" }, "properties": { "id": { "type": "string", "description": "Id represents the message identifier." }, "num": { "type": "string", "format": "int64", "default": "42", "description": "Int value field" }, "duration": { "type": "string" }, "lineNum": { "type": "string", "format": "int64" }, "lang": { "type": "string" }, "status": { "$ref": "#/definitions/examplepbUnannotatedEmbedded" }, "en": { "type": "string", "format": "int64" }, "no": { "$ref": "#/definitions/examplepbUnannotatedEmbedded" }, "resourceId": { "type": "string" }, "nId": { "$ref": "#/definitions/examplepbUnannotatedNestedMessage" } }, "description": "A simple message with many types", "title": "A bit of everything", "externalDocs": { "description": "Find out more about UnannotatedSimpleMessage", "url": "https://github.com/grpc-ecosystem/grpc-gateway" }, "required": [ "id", "num" ] }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string" } }, "additionalProperties": {}, "x-go-type": { "import": { "package": "google.golang.org/protobuf/types/known/anypb" }, "type": "Any" } }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } }, "x-go-type": { "import": { "package": "google.golang.org/genproto/googleapis/rpc/status" }, "type": "Status" } } }, "securityDefinitions": { "ApiKeyAuth": { "type": "apiKey", "name": "X-API-Key", "in": "header", "x-amazon-apigateway-authorizer": { "authorizerResultTtlInSeconds": 60, "type": "token" }, "x-amazon-apigateway-authtype": "oauth2" }, "BasicAuth": { "type": "basic" } }, "security": [ { "ApiKeyAuth": [], "BasicAuth": [] }, { "ApiKeyAuth": [], "OAuth2": [ "read", "write" ] } ], "externalDocs": { "description": "More about gRPC-Gateway", "url": "https://github.com/grpc-ecosystem/grpc-gateway" }, "x-grpc-gateway-baz-list": [ "one", true ], "x-grpc-gateway-foo": "bar" } ================================================ FILE: examples/internal/proto/examplepb/unannotated_echo_service.swagger.yaml ================================================ openapiOptions: file: # the file name must be the same as one passed to protoc when generating .swagger.json - file: "examples/internal/proto/examplepb/unannotated_echo_service.proto" option: info: title: Unannotated Echo contact: name: gRPC-Gateway project url: https://github.com/grpc-ecosystem/grpc-gateway email: none@example.com license: name: BSD 3-Clause License url: https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE version: "1.0" extensions: x-something-something: yadda tags: - name: Echo description: Echo description - name: Internal description: Internal description extensions: x-traitTag: true schemes: - HTTP - HTTPS - WSS consumes: - application/json - application/x-foo-mime produces: - application/json - application/x-foo-mime responses: "403": description: Returned when the user does not have permission to access the resource. "404": description: Returned when the resource does not exist. schema: jsonSchema: type: - STRING securityDefinitions: security: ApiKeyAuth: type: TYPE_API_KEY name: X-API-Key in: IN_HEADER extensions: x-amazon-apigateway-authorizer: authorizerResultTtlInSeconds: 60 type: token x-amazon-apigateway-authtype: oauth2 BasicAuth: type: TYPE_BASIC security: - securityRequirement: ApiKeyAuth: {} BasicAuth: {} - securityRequirement: ApiKeyAuth: {} OAuth2: scope: - read - write externalDocs: description: More about gRPC-Gateway url: https://github.com/grpc-ecosystem/grpc-gateway extensions: x-grpc-gateway-baz-list: - one - true x-grpc-gateway-foo: bar service: - service: grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService option: description: "UnannotatedEchoService description -- which should not be used in place of the documentation comment!" external_docs: url: "https://github.com/grpc-ecosystem/grpc-gateway" description: "Find out more about UnannotatedEchoService" method: - method: grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService.Echo option: description: "Description Echo" summary: "Summary: Echo rpc" external_docs: url: "https://github.com/grpc-ecosystem/grpc-gateway" description: "Find out more Echo" responses: "200": examples: "application/json": '{"value": "the input value"}' "503": description: Returned when the resource is temporarily unavailable. extensions: x-number: 100 "404": description: Returned when the resource does not exist. schema: jsonSchema: type: [INTEGER] message: - message: grpc.gateway.examples.internal.proto.examplepb.UnannotatedSimpleMessage option: json_schema: title: "A bit of everything" description: "A simple message with many types" required: ["id"] external_docs: url: "https://github.com/grpc-ecosystem/grpc-gateway" description: "Find out more about UnannotatedSimpleMessage" example: '{"id": "myid"}' field: - field: grpc.gateway.examples.internal.proto.examplepb.UnannotatedSimpleMessage.num option: description: "Int value field" default: "42" required: ["num"] ================================================ FILE: examples/internal/proto/examplepb/unannotated_echo_service.yaml ================================================ type: google.api.Service config_version: 3 http: rules: - selector: grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService.Echo post: "/v1/example/echo/{id}" additional_bindings: - get: "/v1/example/echo/{id}/{num}" - selector: grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService.EchoBody post: "/v1/example/echo_body" body: "*" - selector: grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService.EchoDelete delete: "/v1/example/echo_delete" - selector: grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService.EchoNested put: "/v1/example/echo_nested" body: "*" response_body: "n_id" ================================================ FILE: examples/internal/proto/examplepb/unannotated_echo_service_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: examples/internal/proto/examplepb/unannotated_echo_service.proto // Unannotated Echo Service // Similar to echo_service.proto but without annotations. See // unannotated_echo_service.yaml for the equivalent of the annotations in // gRPC API configuration format. // // Echo Service API consists of a single service which returns // a message. package examplepb import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( UnannotatedEchoService_Echo_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/Echo" UnannotatedEchoService_EchoBody_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/EchoBody" UnannotatedEchoService_EchoDelete_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/EchoDelete" UnannotatedEchoService_EchoNested_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/EchoNested" ) // UnannotatedEchoServiceClient is the client API for UnannotatedEchoService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // // Echo service responds to incoming echo requests. type UnannotatedEchoServiceClient interface { // Echo method receives a simple message and returns it. // // The message posted as the id parameter will also be // returned. Echo(ctx context.Context, in *UnannotatedSimpleMessage, opts ...grpc.CallOption) (*UnannotatedSimpleMessage, error) // EchoBody method receives a simple message and returns it. EchoBody(ctx context.Context, in *UnannotatedSimpleMessage, opts ...grpc.CallOption) (*UnannotatedSimpleMessage, error) // EchoDelete method receives a simple message and returns it. EchoDelete(ctx context.Context, in *UnannotatedSimpleMessage, opts ...grpc.CallOption) (*UnannotatedSimpleMessage, error) // EchoNested method receives a simple message and returns it. EchoNested(ctx context.Context, in *UnannotatedSimpleMessage, opts ...grpc.CallOption) (*UnannotatedSimpleMessage, error) } type unannotatedEchoServiceClient struct { cc grpc.ClientConnInterface } func NewUnannotatedEchoServiceClient(cc grpc.ClientConnInterface) UnannotatedEchoServiceClient { return &unannotatedEchoServiceClient{cc} } func (c *unannotatedEchoServiceClient) Echo(ctx context.Context, in *UnannotatedSimpleMessage, opts ...grpc.CallOption) (*UnannotatedSimpleMessage, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(UnannotatedSimpleMessage) err := c.cc.Invoke(ctx, UnannotatedEchoService_Echo_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *unannotatedEchoServiceClient) EchoBody(ctx context.Context, in *UnannotatedSimpleMessage, opts ...grpc.CallOption) (*UnannotatedSimpleMessage, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(UnannotatedSimpleMessage) err := c.cc.Invoke(ctx, UnannotatedEchoService_EchoBody_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *unannotatedEchoServiceClient) EchoDelete(ctx context.Context, in *UnannotatedSimpleMessage, opts ...grpc.CallOption) (*UnannotatedSimpleMessage, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(UnannotatedSimpleMessage) err := c.cc.Invoke(ctx, UnannotatedEchoService_EchoDelete_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *unannotatedEchoServiceClient) EchoNested(ctx context.Context, in *UnannotatedSimpleMessage, opts ...grpc.CallOption) (*UnannotatedSimpleMessage, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(UnannotatedSimpleMessage) err := c.cc.Invoke(ctx, UnannotatedEchoService_EchoNested_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // UnannotatedEchoServiceServer is the server API for UnannotatedEchoService service. // All implementations should embed UnimplementedUnannotatedEchoServiceServer // for forward compatibility. // // Echo service responds to incoming echo requests. type UnannotatedEchoServiceServer interface { // Echo method receives a simple message and returns it. // // The message posted as the id parameter will also be // returned. Echo(context.Context, *UnannotatedSimpleMessage) (*UnannotatedSimpleMessage, error) // EchoBody method receives a simple message and returns it. EchoBody(context.Context, *UnannotatedSimpleMessage) (*UnannotatedSimpleMessage, error) // EchoDelete method receives a simple message and returns it. EchoDelete(context.Context, *UnannotatedSimpleMessage) (*UnannotatedSimpleMessage, error) // EchoNested method receives a simple message and returns it. EchoNested(context.Context, *UnannotatedSimpleMessage) (*UnannotatedSimpleMessage, error) } // UnimplementedUnannotatedEchoServiceServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedUnannotatedEchoServiceServer struct{} func (UnimplementedUnannotatedEchoServiceServer) Echo(context.Context, *UnannotatedSimpleMessage) (*UnannotatedSimpleMessage, error) { return nil, status.Errorf(codes.Unimplemented, "method Echo not implemented") } func (UnimplementedUnannotatedEchoServiceServer) EchoBody(context.Context, *UnannotatedSimpleMessage) (*UnannotatedSimpleMessage, error) { return nil, status.Errorf(codes.Unimplemented, "method EchoBody not implemented") } func (UnimplementedUnannotatedEchoServiceServer) EchoDelete(context.Context, *UnannotatedSimpleMessage) (*UnannotatedSimpleMessage, error) { return nil, status.Errorf(codes.Unimplemented, "method EchoDelete not implemented") } func (UnimplementedUnannotatedEchoServiceServer) EchoNested(context.Context, *UnannotatedSimpleMessage) (*UnannotatedSimpleMessage, error) { return nil, status.Errorf(codes.Unimplemented, "method EchoNested not implemented") } func (UnimplementedUnannotatedEchoServiceServer) testEmbeddedByValue() {} // UnsafeUnannotatedEchoServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to UnannotatedEchoServiceServer will // result in compilation errors. type UnsafeUnannotatedEchoServiceServer interface { mustEmbedUnimplementedUnannotatedEchoServiceServer() } func RegisterUnannotatedEchoServiceServer(s grpc.ServiceRegistrar, srv UnannotatedEchoServiceServer) { // If the following call pancis, it indicates UnimplementedUnannotatedEchoServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&UnannotatedEchoService_ServiceDesc, srv) } func _UnannotatedEchoService_Echo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(UnannotatedSimpleMessage) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(UnannotatedEchoServiceServer).Echo(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: UnannotatedEchoService_Echo_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(UnannotatedEchoServiceServer).Echo(ctx, req.(*UnannotatedSimpleMessage)) } return interceptor(ctx, in, info, handler) } func _UnannotatedEchoService_EchoBody_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(UnannotatedSimpleMessage) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(UnannotatedEchoServiceServer).EchoBody(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: UnannotatedEchoService_EchoBody_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(UnannotatedEchoServiceServer).EchoBody(ctx, req.(*UnannotatedSimpleMessage)) } return interceptor(ctx, in, info, handler) } func _UnannotatedEchoService_EchoDelete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(UnannotatedSimpleMessage) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(UnannotatedEchoServiceServer).EchoDelete(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: UnannotatedEchoService_EchoDelete_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(UnannotatedEchoServiceServer).EchoDelete(ctx, req.(*UnannotatedSimpleMessage)) } return interceptor(ctx, in, info, handler) } func _UnannotatedEchoService_EchoNested_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(UnannotatedSimpleMessage) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(UnannotatedEchoServiceServer).EchoNested(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: UnannotatedEchoService_EchoNested_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(UnannotatedEchoServiceServer).EchoNested(ctx, req.(*UnannotatedSimpleMessage)) } return interceptor(ctx, in, info, handler) } // UnannotatedEchoService_ServiceDesc is the grpc.ServiceDesc for UnannotatedEchoService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var UnannotatedEchoService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService", HandlerType: (*UnannotatedEchoServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Echo", Handler: _UnannotatedEchoService_Echo_Handler, }, { MethodName: "EchoBody", Handler: _UnannotatedEchoService_EchoBody_Handler, }, { MethodName: "EchoDelete", Handler: _UnannotatedEchoService_EchoDelete_Handler, }, { MethodName: "EchoNested", Handler: _UnannotatedEchoService_EchoNested_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/internal/proto/examplepb/unannotated_echo_service.proto", } ================================================ FILE: examples/internal/proto/examplepb/use_go_template.buf.gen.yaml ================================================ version: v2 plugins: - local: protoc-gen-openapiv2 out: . opt: - use_go_templates=true ================================================ FILE: examples/internal/proto/examplepb/use_go_template.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/examplepb/use_go_template.proto package examplepb import ( _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) type LoginRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // The entered username Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` // The entered password Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` } func (x *LoginRequest) Reset() { *x = LoginRequest{} mi := &file_examples_internal_proto_examplepb_use_go_template_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *LoginRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*LoginRequest) ProtoMessage() {} func (x *LoginRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_use_go_template_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead. func (*LoginRequest) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_use_go_template_proto_rawDescGZIP(), []int{0} } func (x *LoginRequest) GetUsername() string { if x != nil { return x.Username } return "" } func (x *LoginRequest) GetPassword() string { if x != nil { return x.Password } return "" } type LoginReply struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` // Whether you have access or not Access bool `protobuf:"varint,2,opt,name=access,proto3" json:"access,omitempty"` } func (x *LoginReply) Reset() { *x = LoginReply{} mi := &file_examples_internal_proto_examplepb_use_go_template_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *LoginReply) String() string { return protoimpl.X.MessageStringOf(x) } func (*LoginReply) ProtoMessage() {} func (x *LoginReply) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_use_go_template_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use LoginReply.ProtoReflect.Descriptor instead. func (*LoginReply) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_use_go_template_proto_rawDescGZIP(), []int{1} } func (x *LoginReply) GetMessage() string { if x != nil { return x.Message } return "" } func (x *LoginReply) GetAccess() bool { if x != nil { return x.Access } return false } type LogoutRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // The time the logout was registered Timeoflogout string `protobuf:"bytes,1,opt,name=timeoflogout,proto3" json:"timeoflogout,omitempty"` // This is the title // // This is the "Description" of field test // you can use as many newlines as you want // // it will still format the same in the table Test int32 `protobuf:"varint,2,opt,name=test,proto3" json:"test,omitempty"` // This is an array // // It displays that using [] in front of the type Stringarray []string `protobuf:"bytes,3,rep,name=stringarray,proto3" json:"stringarray,omitempty"` } func (x *LogoutRequest) Reset() { *x = LogoutRequest{} mi := &file_examples_internal_proto_examplepb_use_go_template_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *LogoutRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*LogoutRequest) ProtoMessage() {} func (x *LogoutRequest) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_use_go_template_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use LogoutRequest.ProtoReflect.Descriptor instead. func (*LogoutRequest) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_use_go_template_proto_rawDescGZIP(), []int{2} } func (x *LogoutRequest) GetTimeoflogout() string { if x != nil { return x.Timeoflogout } return "" } func (x *LogoutRequest) GetTest() int32 { if x != nil { return x.Test } return 0 } func (x *LogoutRequest) GetStringarray() []string { if x != nil { return x.Stringarray } return nil } type LogoutReply struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Message that tells you whether your // logout was successful or not Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` } func (x *LogoutReply) Reset() { *x = LogoutReply{} mi := &file_examples_internal_proto_examplepb_use_go_template_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *LogoutReply) String() string { return protoimpl.X.MessageStringOf(x) } func (*LogoutReply) ProtoMessage() {} func (x *LogoutReply) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_use_go_template_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use LogoutReply.ProtoReflect.Descriptor instead. func (*LogoutReply) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_use_go_template_proto_rawDescGZIP(), []int{3} } func (x *LogoutReply) GetMessage() string { if x != nil { return x.Message } return "" } var File_examples_internal_proto_examplepb_use_go_template_proto protoreflect.FileDescriptor var file_examples_internal_proto_examplepb_use_go_template_proto_rawDesc = []byte{ 0x0a, 0x37, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x75, 0x73, 0x65, 0x5f, 0x67, 0x6f, 0x5f, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x46, 0x0a, 0x0c, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x3e, 0x0a, 0x0a, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x22, 0x69, 0x0a, 0x0d, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x66, 0x6c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x66, 0x6c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x74, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x61, 0x72, 0x72, 0x61, 0x79, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x61, 0x72, 0x72, 0x61, 0x79, 0x22, 0x27, 0x0a, 0x0b, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0xd6, 0x02, 0x0a, 0x0c, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x9f, 0x01, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x3c, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x3a, 0x01, 0x2a, 0x22, 0x11, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0xa3, 0x01, 0x0a, 0x06, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x12, 0x3d, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x1d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x17, 0x3a, 0x01, 0x2a, 0x22, 0x12, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x6c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_examplepb_use_go_template_proto_rawDescOnce sync.Once file_examples_internal_proto_examplepb_use_go_template_proto_rawDescData = file_examples_internal_proto_examplepb_use_go_template_proto_rawDesc ) func file_examples_internal_proto_examplepb_use_go_template_proto_rawDescGZIP() []byte { file_examples_internal_proto_examplepb_use_go_template_proto_rawDescOnce.Do(func() { file_examples_internal_proto_examplepb_use_go_template_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_examplepb_use_go_template_proto_rawDescData) }) return file_examples_internal_proto_examplepb_use_go_template_proto_rawDescData } var file_examples_internal_proto_examplepb_use_go_template_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_examples_internal_proto_examplepb_use_go_template_proto_goTypes = []any{ (*LoginRequest)(nil), // 0: grpc.gateway.examples.internal.proto.examplepb.LoginRequest (*LoginReply)(nil), // 1: grpc.gateway.examples.internal.proto.examplepb.LoginReply (*LogoutRequest)(nil), // 2: grpc.gateway.examples.internal.proto.examplepb.LogoutRequest (*LogoutReply)(nil), // 3: grpc.gateway.examples.internal.proto.examplepb.LogoutReply } var file_examples_internal_proto_examplepb_use_go_template_proto_depIdxs = []int32{ 0, // 0: grpc.gateway.examples.internal.proto.examplepb.LoginService.Login:input_type -> grpc.gateway.examples.internal.proto.examplepb.LoginRequest 2, // 1: grpc.gateway.examples.internal.proto.examplepb.LoginService.Logout:input_type -> grpc.gateway.examples.internal.proto.examplepb.LogoutRequest 1, // 2: grpc.gateway.examples.internal.proto.examplepb.LoginService.Login:output_type -> grpc.gateway.examples.internal.proto.examplepb.LoginReply 3, // 3: grpc.gateway.examples.internal.proto.examplepb.LoginService.Logout:output_type -> grpc.gateway.examples.internal.proto.examplepb.LogoutReply 2, // [2:4] is the sub-list for method output_type 0, // [0:2] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name } func init() { file_examples_internal_proto_examplepb_use_go_template_proto_init() } func file_examples_internal_proto_examplepb_use_go_template_proto_init() { if File_examples_internal_proto_examplepb_use_go_template_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_examplepb_use_go_template_proto_rawDesc, NumEnums: 0, NumMessages: 4, NumExtensions: 0, NumServices: 1, }, GoTypes: file_examples_internal_proto_examplepb_use_go_template_proto_goTypes, DependencyIndexes: file_examples_internal_proto_examplepb_use_go_template_proto_depIdxs, MessageInfos: file_examples_internal_proto_examplepb_use_go_template_proto_msgTypes, }.Build() File_examples_internal_proto_examplepb_use_go_template_proto = out.File file_examples_internal_proto_examplepb_use_go_template_proto_rawDesc = nil file_examples_internal_proto_examplepb_use_go_template_proto_goTypes = nil file_examples_internal_proto_examplepb_use_go_template_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/examplepb/use_go_template.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/proto/examplepb/use_go_template.proto /* Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package examplepb import ( "context" "errors" "io" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) func request_LoginService_Login_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq LoginRequest metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.Login(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_LoginService_Login_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq LoginRequest metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Login(ctx, &protoReq) return msg, metadata, err } func request_LoginService_Logout_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq LogoutRequest metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.Logout(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_LoginService_Logout_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq LogoutRequest metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Logout(ctx, &protoReq) return msg, metadata, err } // RegisterLoginServiceHandlerServer registers the http handlers for service LoginService to "mux". // UnaryRPC :call LoginServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterLoginServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterLoginServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server LoginServiceServer) error { mux.Handle(http.MethodPost, pattern_LoginService_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.LoginService/Login", runtime.WithHTTPPathPattern("/v1/example/login")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_LoginService_Login_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_LoginService_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_LoginService_Logout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.LoginService/Logout", runtime.WithHTTPPathPattern("/v1/example/logout")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_LoginService_Logout_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_LoginService_Logout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } // RegisterLoginServiceHandlerFromEndpoint is same as RegisterLoginServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterLoginServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterLoginServiceHandler(ctx, mux, conn) } // RegisterLoginServiceHandler registers the http handlers for service LoginService to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterLoginServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterLoginServiceHandlerClient(ctx, mux, NewLoginServiceClient(conn)) } // RegisterLoginServiceHandlerClient registers the http handlers for service LoginService // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "LoginServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "LoginServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "LoginServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterLoginServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client LoginServiceClient) error { mux.Handle(http.MethodPost, pattern_LoginService_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.LoginService/Login", runtime.WithHTTPPathPattern("/v1/example/login")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_LoginService_Login_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_LoginService_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_LoginService_Logout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.LoginService/Logout", runtime.WithHTTPPathPattern("/v1/example/logout")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_LoginService_Logout_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_LoginService_Logout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_LoginService_Login_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "login"}, "")) pattern_LoginService_Logout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "logout"}, "")) ) var ( forward_LoginService_Login_0 = runtime.ForwardResponseMessage forward_LoginService_Logout_0 = runtime.ForwardResponseMessage ) ================================================ FILE: examples/internal/proto/examplepb/use_go_template.proto ================================================ syntax = "proto3"; package grpc.gateway.examples.internal.proto.examplepb; import "google/api/annotations.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; service LoginService { // Login // // {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service. // It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}". // // ## {{.RequestType.Name}} // | Field ID | Name | Type | Description | // | ----------- | --------- | --------------------------------------------------------- | ---------------------------- | {{range .RequestType.Fields}} // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} // // ## {{.ResponseType.Name}} // | Field ID | Name | Type | Description | // | ----------- | --------- | ---------------------------------------------------------- | ---------------------------- | {{range .ResponseType.Fields}} // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} rpc Login(LoginRequest) returns (LoginReply) { option (google.api.http) = { post: "/v1/example/login" body: "*" }; } // Logout // // {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service. // It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}". // // ## {{.RequestType.Name}} // | Field ID | Name | Type | Description | // | ----------- | --------- | --------------------------------------------------------- | ---------------------------- | {{range .RequestType.Fields}} // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} // // ## {{.ResponseType.Name}} // | Field ID | Name | Type | Description | // | ----------- | --------- | ---------------------------------------------------------- | ---------------------------- | {{range .ResponseType.Fields}} // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} rpc Logout(LogoutRequest) returns (LogoutReply) { option (google.api.http) = { post: "/v1/example/logout" body: "*" }; } } message LoginRequest { // The entered username string username = 1; // The entered password string password = 2; } message LoginReply { string message = 1; // Whether you have access or not bool access = 2; } message LogoutRequest { // The time the logout was registered string timeoflogout = 1; // This is the title // // This is the "Description" of field test // you can use as many newlines as you want // // // it will still format the same in the table int32 test = 2; // This is an array // // It displays that using [] in front of the type repeated string stringarray = 3; } message LogoutReply { // Message that tells you whether your // logout was successful or not string message = 1; } ================================================ FILE: examples/internal/proto/examplepb/use_go_template.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/examplepb/use_go_template.proto", "version": "version not set" }, "tags": [ { "name": "LoginService" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/v1/example/login": { "post": { "summary": "Login", "description": "Login is a call with the method(s) POST within the \"LoginService\" service.\nIt takes in \"LoginRequest\" and returns a \"LoginReply\".\n\n## LoginRequest\n| Field ID | Name | Type | Description |\n| ----------- | --------- | --------------------------------------------------------- | ---------------------------- | \n| 1 | username | TYPE_STRING | The entered username | \n| 2 | password | TYPE_STRING | The entered password | \n\n## LoginReply\n| Field ID | Name | Type | Description |\n| ----------- | --------- | ---------------------------------------------------------- | ---------------------------- | \n| 1 | message | TYPE_STRING | | \n| 2 | access | TYPE_BOOL | Whether you have access or not |", "operationId": "LoginService_Login", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbLoginReply" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbLoginRequest" } } ], "tags": [ "LoginService" ] } }, "/v1/example/logout": { "post": { "summary": "Logout", "description": "Logout is a call with the method(s) POST within the \"LoginService\" service.\nIt takes in \"LogoutRequest\" and returns a \"LogoutReply\".\n\n## LogoutRequest\n| Field ID | Name | Type | Description |\n| ----------- | --------- | --------------------------------------------------------- | ---------------------------- | \n| 1 | timeoflogout | TYPE_STRING | The time the logout was registered | \n| 2 | test | TYPE_INT32 | This is the title\u003cbr\u003e\u003cbr\u003eThis is the \"Description\" of field test\u003cbr\u003eyou can use as many newlines as you want\u003cbr\u003e\u003cbr\u003e\u003cbr\u003eit will still format the same in the table | \n| 3 | stringarray | []TYPE_STRING | This is an array\u003cbr\u003e\u003cbr\u003eIt displays that using [] in front of the type | \n\n## LogoutReply\n| Field ID | Name | Type | Description |\n| ----------- | --------- | ---------------------------------------------------------- | ---------------------------- | \n| 1 | message | TYPE_STRING | Message that tells you whether your\u003cbr\u003elogout was successful or not |", "operationId": "LoginService_Logout", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbLogoutReply" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbLogoutRequest" } } ], "tags": [ "LoginService" ] } } }, "definitions": { "examplepbLoginReply": { "type": "object", "properties": { "message": { "type": "string" }, "access": { "type": "boolean", "title": "Whether you have access or not" } } }, "examplepbLoginRequest": { "type": "object", "properties": { "username": { "type": "string", "title": "The entered username" }, "password": { "type": "string", "title": "The entered password" } } }, "examplepbLogoutReply": { "type": "object", "properties": { "message": { "type": "string", "title": "Message that tells you whether your\nlogout was successful or not" } } }, "examplepbLogoutRequest": { "type": "object", "properties": { "timeoflogout": { "type": "string", "title": "The time the logout was registered" }, "test": { "type": "integer", "format": "int32", "description": "This is the \"Description\" of field test\nyou can use as many newlines as you want\n\n\nit will still format the same in the table", "title": "This is the title" }, "stringarray": { "type": "array", "items": { "type": "string" }, "description": "It displays that using [] in front of the type", "title": "This is an array" } } }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string" } }, "additionalProperties": {} }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } } } } ================================================ FILE: examples/internal/proto/examplepb/use_go_template_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: examples/internal/proto/examplepb/use_go_template.proto package examplepb import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( LoginService_Login_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.LoginService/Login" LoginService_Logout_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.LoginService/Logout" ) // LoginServiceClient is the client API for LoginService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type LoginServiceClient interface { // Login // // {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service. // It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}". // // ## {{.RequestType.Name}} // | Field ID | Name | Type | Description | // | ----------- | --------- | --------------------------------------------------------- | ---------------------------- | {{range .RequestType.Fields}} // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} // // ## {{.ResponseType.Name}} // | Field ID | Name | Type | Description | // | ----------- | --------- | ---------------------------------------------------------- | ---------------------------- | {{range .ResponseType.Fields}} // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginReply, error) // Logout // // {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service. // It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}". // // ## {{.RequestType.Name}} // | Field ID | Name | Type | Description | // | ----------- | --------- | --------------------------------------------------------- | ---------------------------- | {{range .RequestType.Fields}} // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} // // ## {{.ResponseType.Name}} // | Field ID | Name | Type | Description | // | ----------- | --------- | ---------------------------------------------------------- | ---------------------------- | {{range .ResponseType.Fields}} // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*LogoutReply, error) } type loginServiceClient struct { cc grpc.ClientConnInterface } func NewLoginServiceClient(cc grpc.ClientConnInterface) LoginServiceClient { return &loginServiceClient{cc} } func (c *loginServiceClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginReply, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(LoginReply) err := c.cc.Invoke(ctx, LoginService_Login_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *loginServiceClient) Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*LogoutReply, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(LogoutReply) err := c.cc.Invoke(ctx, LoginService_Logout_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // LoginServiceServer is the server API for LoginService service. // All implementations should embed UnimplementedLoginServiceServer // for forward compatibility. type LoginServiceServer interface { // Login // // {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service. // It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}". // // ## {{.RequestType.Name}} // | Field ID | Name | Type | Description | // | ----------- | --------- | --------------------------------------------------------- | ---------------------------- | {{range .RequestType.Fields}} // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} // // ## {{.ResponseType.Name}} // | Field ID | Name | Type | Description | // | ----------- | --------- | ---------------------------------------------------------- | ---------------------------- | {{range .ResponseType.Fields}} // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} Login(context.Context, *LoginRequest) (*LoginReply, error) // Logout // // {{.MethodDescriptorProto.Name}} is a call with the method(s) {{$first := true}}{{range .Bindings}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{.HTTPMethod}}{{end}} within the "{{.Service.Name}}" service. // It takes in "{{.RequestType.Name}}" and returns a "{{.ResponseType.Name}}". // // ## {{.RequestType.Name}} // | Field ID | Name | Type | Description | // | ----------- | --------- | --------------------------------------------------------- | ---------------------------- | {{range .RequestType.Fields}} // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} // // ## {{.ResponseType.Name}} // | Field ID | Name | Type | Description | // | ----------- | --------- | ---------------------------------------------------------- | ---------------------------- | {{range .ResponseType.Fields}} // | {{.Number}} | {{.Name}} | {{if eq .Label.String "LABEL_REPEATED"}}[]{{end}}{{.Type}} | {{fieldcomments .Message .}} | {{end}} Logout(context.Context, *LogoutRequest) (*LogoutReply, error) } // UnimplementedLoginServiceServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedLoginServiceServer struct{} func (UnimplementedLoginServiceServer) Login(context.Context, *LoginRequest) (*LoginReply, error) { return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") } func (UnimplementedLoginServiceServer) Logout(context.Context, *LogoutRequest) (*LogoutReply, error) { return nil, status.Errorf(codes.Unimplemented, "method Logout not implemented") } func (UnimplementedLoginServiceServer) testEmbeddedByValue() {} // UnsafeLoginServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to LoginServiceServer will // result in compilation errors. type UnsafeLoginServiceServer interface { mustEmbedUnimplementedLoginServiceServer() } func RegisterLoginServiceServer(s grpc.ServiceRegistrar, srv LoginServiceServer) { // If the following call pancis, it indicates UnimplementedLoginServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&LoginService_ServiceDesc, srv) } func _LoginService_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(LoginRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(LoginServiceServer).Login(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: LoginService_Login_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(LoginServiceServer).Login(ctx, req.(*LoginRequest)) } return interceptor(ctx, in, info, handler) } func _LoginService_Logout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(LogoutRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(LoginServiceServer).Logout(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: LoginService_Logout_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(LoginServiceServer).Logout(ctx, req.(*LogoutRequest)) } return interceptor(ctx, in, info, handler) } // LoginService_ServiceDesc is the grpc.ServiceDesc for LoginService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var LoginService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.LoginService", HandlerType: (*LoginServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Login", Handler: _LoginService_Login_Handler, }, { MethodName: "Logout", Handler: _LoginService_Logout_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/internal/proto/examplepb/use_go_template.proto", } ================================================ FILE: examples/internal/proto/examplepb/visibility_rule_echo_service.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/examplepb/visibility_rule_echo_service.proto // Visibility Rule Echo Service // Similar to echo_service.proto but with annotations to change visibility // of services, methods, fields and enum values. // // `google.api.VisibilityRule` annotations are added to customize where they are generated. // Combined with the option `visibility_restriction_selectors` overlapping rules will appear in the OpenAPI output. // Elements without `google.api.VisibilityRule` annotations will appear as usual in the generated output. // // These restrictions and selectors are completely arbitrary and you can define whatever values or hierarchies you want. // In this example `INTERNAL`, `PREVIEW` are used, but `INTERNAL`, `ALPHA`, `BETA`, `RELEASED`, or anything else could be used if you wish. package examplepb import ( _ "google.golang.org/genproto/googleapis/api/annotations" _ "google.golang.org/genproto/googleapis/api/visibility" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) // EnumInPreviewMethod doesn't define its own visibility restrictions, // but is only included in a method marked as "PREVIEW", so it will only // appear if `visibility_restriction_selectors` include "PREVIEW". type VisibilityRuleEnumInPreviewMethod int32 const ( VisibilityRuleEnumInPreviewMethod_VISIBILITY_RULE_ENUM_IN_PREVIEW_METHOD_UNSPECIFIED VisibilityRuleEnumInPreviewMethod = 0 ) // Enum value maps for VisibilityRuleEnumInPreviewMethod. var ( VisibilityRuleEnumInPreviewMethod_name = map[int32]string{ 0: "VISIBILITY_RULE_ENUM_IN_PREVIEW_METHOD_UNSPECIFIED", } VisibilityRuleEnumInPreviewMethod_value = map[string]int32{ "VISIBILITY_RULE_ENUM_IN_PREVIEW_METHOD_UNSPECIFIED": 0, } ) func (x VisibilityRuleEnumInPreviewMethod) Enum() *VisibilityRuleEnumInPreviewMethod { p := new(VisibilityRuleEnumInPreviewMethod) *p = x return p } func (x VisibilityRuleEnumInPreviewMethod) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (VisibilityRuleEnumInPreviewMethod) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_enumTypes[0].Descriptor() } func (VisibilityRuleEnumInPreviewMethod) Type() protoreflect.EnumType { return &file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_enumTypes[0] } func (x VisibilityRuleEnumInPreviewMethod) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use VisibilityRuleEnumInPreviewMethod.Descriptor instead. func (VisibilityRuleEnumInPreviewMethod) EnumDescriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_rawDescGZIP(), []int{0} } type VisibilityRuleSimpleMessage_VisibilityEnum int32 const ( VisibilityRuleSimpleMessage_VISIBILITY_ENUM_UNSPECIFIED VisibilityRuleSimpleMessage_VisibilityEnum = 0 VisibilityRuleSimpleMessage_VISIBILITY_ENUM_VISIBLE VisibilityRuleSimpleMessage_VisibilityEnum = 1 VisibilityRuleSimpleMessage_VISIBILITY_ENUM_INTERNAL VisibilityRuleSimpleMessage_VisibilityEnum = 2 VisibilityRuleSimpleMessage_VISIBILITY_ENUM_PREVIEW VisibilityRuleSimpleMessage_VisibilityEnum = 3 ) // Enum value maps for VisibilityRuleSimpleMessage_VisibilityEnum. var ( VisibilityRuleSimpleMessage_VisibilityEnum_name = map[int32]string{ 0: "VISIBILITY_ENUM_UNSPECIFIED", 1: "VISIBILITY_ENUM_VISIBLE", 2: "VISIBILITY_ENUM_INTERNAL", 3: "VISIBILITY_ENUM_PREVIEW", } VisibilityRuleSimpleMessage_VisibilityEnum_value = map[string]int32{ "VISIBILITY_ENUM_UNSPECIFIED": 0, "VISIBILITY_ENUM_VISIBLE": 1, "VISIBILITY_ENUM_INTERNAL": 2, "VISIBILITY_ENUM_PREVIEW": 3, } ) func (x VisibilityRuleSimpleMessage_VisibilityEnum) Enum() *VisibilityRuleSimpleMessage_VisibilityEnum { p := new(VisibilityRuleSimpleMessage_VisibilityEnum) *p = x return p } func (x VisibilityRuleSimpleMessage_VisibilityEnum) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (VisibilityRuleSimpleMessage_VisibilityEnum) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_enumTypes[1].Descriptor() } func (VisibilityRuleSimpleMessage_VisibilityEnum) Type() protoreflect.EnumType { return &file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_enumTypes[1] } func (x VisibilityRuleSimpleMessage_VisibilityEnum) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use VisibilityRuleSimpleMessage_VisibilityEnum.Descriptor instead. func (VisibilityRuleSimpleMessage_VisibilityEnum) EnumDescriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_rawDescGZIP(), []int{1, 0} } type VisibilityRuleSimpleMessage_VisibilityEnumHiddenDefault int32 const ( VisibilityRuleSimpleMessage_VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED VisibilityRuleSimpleMessage_VisibilityEnumHiddenDefault = 0 VisibilityRuleSimpleMessage_VISIBILITY_ENUM_HIDDEN_DEFAULT_VISIBLE VisibilityRuleSimpleMessage_VisibilityEnumHiddenDefault = 1 ) // Enum value maps for VisibilityRuleSimpleMessage_VisibilityEnumHiddenDefault. var ( VisibilityRuleSimpleMessage_VisibilityEnumHiddenDefault_name = map[int32]string{ 0: "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED", 1: "VISIBILITY_ENUM_HIDDEN_DEFAULT_VISIBLE", } VisibilityRuleSimpleMessage_VisibilityEnumHiddenDefault_value = map[string]int32{ "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED": 0, "VISIBILITY_ENUM_HIDDEN_DEFAULT_VISIBLE": 1, } ) func (x VisibilityRuleSimpleMessage_VisibilityEnumHiddenDefault) Enum() *VisibilityRuleSimpleMessage_VisibilityEnumHiddenDefault { p := new(VisibilityRuleSimpleMessage_VisibilityEnumHiddenDefault) *p = x return p } func (x VisibilityRuleSimpleMessage_VisibilityEnumHiddenDefault) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (VisibilityRuleSimpleMessage_VisibilityEnumHiddenDefault) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_enumTypes[2].Descriptor() } func (VisibilityRuleSimpleMessage_VisibilityEnumHiddenDefault) Type() protoreflect.EnumType { return &file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_enumTypes[2] } func (x VisibilityRuleSimpleMessage_VisibilityEnumHiddenDefault) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use VisibilityRuleSimpleMessage_VisibilityEnumHiddenDefault.Descriptor instead. func (VisibilityRuleSimpleMessage_VisibilityEnumHiddenDefault) EnumDescriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_rawDescGZIP(), []int{1, 1} } // Embedded represents a message embedded in SimpleMessage. type VisibilityRuleEmbedded struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Types that are assignable to Mark: // // *VisibilityRuleEmbedded_Progress // *VisibilityRuleEmbedded_Note // *VisibilityRuleEmbedded_InternalField // *VisibilityRuleEmbedded_PreviewField Mark isVisibilityRuleEmbedded_Mark `protobuf_oneof:"mark"` } func (x *VisibilityRuleEmbedded) Reset() { *x = VisibilityRuleEmbedded{} mi := &file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *VisibilityRuleEmbedded) String() string { return protoimpl.X.MessageStringOf(x) } func (*VisibilityRuleEmbedded) ProtoMessage() {} func (x *VisibilityRuleEmbedded) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use VisibilityRuleEmbedded.ProtoReflect.Descriptor instead. func (*VisibilityRuleEmbedded) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_rawDescGZIP(), []int{0} } func (m *VisibilityRuleEmbedded) GetMark() isVisibilityRuleEmbedded_Mark { if m != nil { return m.Mark } return nil } func (x *VisibilityRuleEmbedded) GetProgress() int64 { if x, ok := x.GetMark().(*VisibilityRuleEmbedded_Progress); ok { return x.Progress } return 0 } func (x *VisibilityRuleEmbedded) GetNote() string { if x, ok := x.GetMark().(*VisibilityRuleEmbedded_Note); ok { return x.Note } return "" } func (x *VisibilityRuleEmbedded) GetInternalField() string { if x, ok := x.GetMark().(*VisibilityRuleEmbedded_InternalField); ok { return x.InternalField } return "" } func (x *VisibilityRuleEmbedded) GetPreviewField() string { if x, ok := x.GetMark().(*VisibilityRuleEmbedded_PreviewField); ok { return x.PreviewField } return "" } type isVisibilityRuleEmbedded_Mark interface { isVisibilityRuleEmbedded_Mark() } type VisibilityRuleEmbedded_Progress struct { Progress int64 `protobuf:"varint,1,opt,name=progress,proto3,oneof"` } type VisibilityRuleEmbedded_Note struct { Note string `protobuf:"bytes,2,opt,name=note,proto3,oneof"` } type VisibilityRuleEmbedded_InternalField struct { InternalField string `protobuf:"bytes,3,opt,name=internal_field,json=internalField,proto3,oneof"` } type VisibilityRuleEmbedded_PreviewField struct { PreviewField string `protobuf:"bytes,4,opt,name=preview_field,json=previewField,proto3,oneof"` } func (*VisibilityRuleEmbedded_Progress) isVisibilityRuleEmbedded_Mark() {} func (*VisibilityRuleEmbedded_Note) isVisibilityRuleEmbedded_Mark() {} func (*VisibilityRuleEmbedded_InternalField) isVisibilityRuleEmbedded_Mark() {} func (*VisibilityRuleEmbedded_PreviewField) isVisibilityRuleEmbedded_Mark() {} // SimpleMessage represents a simple message sent to the Echo service. type VisibilityRuleSimpleMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Id represents the message identifier. Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Num int64 `protobuf:"varint,2,opt,name=num,proto3" json:"num,omitempty"` // Types that are assignable to Code: // // *VisibilityRuleSimpleMessage_LineNum // *VisibilityRuleSimpleMessage_Lang Code isVisibilityRuleSimpleMessage_Code `protobuf_oneof:"code"` Status *VisibilityRuleEmbedded `protobuf:"bytes,5,opt,name=status,proto3" json:"status,omitempty"` // Types that are assignable to Ext: // // *VisibilityRuleSimpleMessage_En // *VisibilityRuleSimpleMessage_No Ext isVisibilityRuleSimpleMessage_Ext `protobuf_oneof:"ext"` InternalField string `protobuf:"bytes,8,opt,name=internal_field,json=internalField,proto3" json:"internal_field,omitempty"` PreviewField string `protobuf:"bytes,9,opt,name=preview_field,json=previewField,proto3" json:"preview_field,omitempty"` AnEnum VisibilityRuleSimpleMessage_VisibilityEnum `protobuf:"varint,10,opt,name=an_enum,json=anEnum,proto3,enum=grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSimpleMessage_VisibilityEnum" json:"an_enum,omitempty"` AhiddenDefaultEnum VisibilityRuleSimpleMessage_VisibilityEnumHiddenDefault `protobuf:"varint,11,opt,name=ahidden_default_enum,json=ahiddenDefaultEnum,proto3,enum=grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSimpleMessage_VisibilityEnumHiddenDefault" json:"ahidden_default_enum,omitempty"` } func (x *VisibilityRuleSimpleMessage) Reset() { *x = VisibilityRuleSimpleMessage{} mi := &file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *VisibilityRuleSimpleMessage) String() string { return protoimpl.X.MessageStringOf(x) } func (*VisibilityRuleSimpleMessage) ProtoMessage() {} func (x *VisibilityRuleSimpleMessage) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use VisibilityRuleSimpleMessage.ProtoReflect.Descriptor instead. func (*VisibilityRuleSimpleMessage) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_rawDescGZIP(), []int{1} } func (x *VisibilityRuleSimpleMessage) GetId() string { if x != nil { return x.Id } return "" } func (x *VisibilityRuleSimpleMessage) GetNum() int64 { if x != nil { return x.Num } return 0 } func (m *VisibilityRuleSimpleMessage) GetCode() isVisibilityRuleSimpleMessage_Code { if m != nil { return m.Code } return nil } func (x *VisibilityRuleSimpleMessage) GetLineNum() int64 { if x, ok := x.GetCode().(*VisibilityRuleSimpleMessage_LineNum); ok { return x.LineNum } return 0 } func (x *VisibilityRuleSimpleMessage) GetLang() string { if x, ok := x.GetCode().(*VisibilityRuleSimpleMessage_Lang); ok { return x.Lang } return "" } func (x *VisibilityRuleSimpleMessage) GetStatus() *VisibilityRuleEmbedded { if x != nil { return x.Status } return nil } func (m *VisibilityRuleSimpleMessage) GetExt() isVisibilityRuleSimpleMessage_Ext { if m != nil { return m.Ext } return nil } func (x *VisibilityRuleSimpleMessage) GetEn() int64 { if x, ok := x.GetExt().(*VisibilityRuleSimpleMessage_En); ok { return x.En } return 0 } func (x *VisibilityRuleSimpleMessage) GetNo() *VisibilityRuleEmbedded { if x, ok := x.GetExt().(*VisibilityRuleSimpleMessage_No); ok { return x.No } return nil } func (x *VisibilityRuleSimpleMessage) GetInternalField() string { if x != nil { return x.InternalField } return "" } func (x *VisibilityRuleSimpleMessage) GetPreviewField() string { if x != nil { return x.PreviewField } return "" } func (x *VisibilityRuleSimpleMessage) GetAnEnum() VisibilityRuleSimpleMessage_VisibilityEnum { if x != nil { return x.AnEnum } return VisibilityRuleSimpleMessage_VISIBILITY_ENUM_UNSPECIFIED } func (x *VisibilityRuleSimpleMessage) GetAhiddenDefaultEnum() VisibilityRuleSimpleMessage_VisibilityEnumHiddenDefault { if x != nil { return x.AhiddenDefaultEnum } return VisibilityRuleSimpleMessage_VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED } type isVisibilityRuleSimpleMessage_Code interface { isVisibilityRuleSimpleMessage_Code() } type VisibilityRuleSimpleMessage_LineNum struct { LineNum int64 `protobuf:"varint,3,opt,name=line_num,json=lineNum,proto3,oneof"` } type VisibilityRuleSimpleMessage_Lang struct { Lang string `protobuf:"bytes,4,opt,name=lang,proto3,oneof"` } func (*VisibilityRuleSimpleMessage_LineNum) isVisibilityRuleSimpleMessage_Code() {} func (*VisibilityRuleSimpleMessage_Lang) isVisibilityRuleSimpleMessage_Code() {} type isVisibilityRuleSimpleMessage_Ext interface { isVisibilityRuleSimpleMessage_Ext() } type VisibilityRuleSimpleMessage_En struct { En int64 `protobuf:"varint,6,opt,name=en,proto3,oneof"` } type VisibilityRuleSimpleMessage_No struct { No *VisibilityRuleEmbedded `protobuf:"bytes,7,opt,name=no,proto3,oneof"` } func (*VisibilityRuleSimpleMessage_En) isVisibilityRuleSimpleMessage_Ext() {} func (*VisibilityRuleSimpleMessage_No) isVisibilityRuleSimpleMessage_Ext() {} // MessageInPreviewMethod doesn't define its own visibility restrictions, // but is only included in a method marked as "PREVIEW", so it will only // appear if `visibility_restriction_selectors` include "PREVIEW". type VisibilityRuleMessageInPreviewMethod struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` SubMessage *VisibilityRuleSubMessageInPreviewMethod `protobuf:"bytes,2,opt,name=sub_message,json=subMessage,proto3" json:"sub_message,omitempty"` Enum VisibilityRuleEnumInPreviewMethod `protobuf:"varint,3,opt,name=enum,proto3,enum=grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEnumInPreviewMethod" json:"enum,omitempty"` } func (x *VisibilityRuleMessageInPreviewMethod) Reset() { *x = VisibilityRuleMessageInPreviewMethod{} mi := &file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *VisibilityRuleMessageInPreviewMethod) String() string { return protoimpl.X.MessageStringOf(x) } func (*VisibilityRuleMessageInPreviewMethod) ProtoMessage() {} func (x *VisibilityRuleMessageInPreviewMethod) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use VisibilityRuleMessageInPreviewMethod.ProtoReflect.Descriptor instead. func (*VisibilityRuleMessageInPreviewMethod) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_rawDescGZIP(), []int{2} } func (x *VisibilityRuleMessageInPreviewMethod) GetId() string { if x != nil { return x.Id } return "" } func (x *VisibilityRuleMessageInPreviewMethod) GetSubMessage() *VisibilityRuleSubMessageInPreviewMethod { if x != nil { return x.SubMessage } return nil } func (x *VisibilityRuleMessageInPreviewMethod) GetEnum() VisibilityRuleEnumInPreviewMethod { if x != nil { return x.Enum } return VisibilityRuleEnumInPreviewMethod_VISIBILITY_RULE_ENUM_IN_PREVIEW_METHOD_UNSPECIFIED } // SubMessageInPreviewMethod doesn't define its own visibility restrictions, // but is only included in a method marked as "PREVIEW", so it will only // appear if `visibility_restriction_selectors` include "PREVIEW". type VisibilityRuleSubMessageInPreviewMethod struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` } func (x *VisibilityRuleSubMessageInPreviewMethod) Reset() { *x = VisibilityRuleSubMessageInPreviewMethod{} mi := &file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *VisibilityRuleSubMessageInPreviewMethod) String() string { return protoimpl.X.MessageStringOf(x) } func (*VisibilityRuleSubMessageInPreviewMethod) ProtoMessage() {} func (x *VisibilityRuleSubMessageInPreviewMethod) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use VisibilityRuleSubMessageInPreviewMethod.ProtoReflect.Descriptor instead. func (*VisibilityRuleSubMessageInPreviewMethod) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_rawDescGZIP(), []int{3} } func (x *VisibilityRuleSubMessageInPreviewMethod) GetId() string { if x != nil { return x.Id } return "" } var File_examples_internal_proto_examplepb_visibility_rule_echo_service_proto protoreflect.FileDescriptor var file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_rawDesc = []byte{ 0x0a, 0x44, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x76, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x5f, 0x65, 0x63, 0x68, 0x6f, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd0, 0x01, 0x0a, 0x16, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x45, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x12, 0x1c, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x14, 0x0a, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04, 0x6e, 0x6f, 0x74, 0x65, 0x12, 0x39, 0x0a, 0x0e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x10, 0xfa, 0xd2, 0xe4, 0x93, 0x02, 0x0a, 0x12, 0x08, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x48, 0x00, 0x52, 0x0d, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x3f, 0x0a, 0x0d, 0x70, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xfa, 0xd2, 0xe4, 0x93, 0x02, 0x12, 0x12, 0x10, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x2c, 0x50, 0x52, 0x45, 0x56, 0x49, 0x45, 0x57, 0x48, 0x00, 0x52, 0x0c, 0x70, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x42, 0x06, 0x0a, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x22, 0x9c, 0x08, 0x0a, 0x1b, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6e, 0x75, 0x6d, 0x12, 0x1b, 0x0a, 0x08, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00, 0x52, 0x07, 0x6c, 0x69, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x14, 0x0a, 0x04, 0x6c, 0x61, 0x6e, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04, 0x6c, 0x61, 0x6e, 0x67, 0x12, 0x5e, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x46, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x45, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x10, 0x0a, 0x02, 0x65, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x48, 0x01, 0x52, 0x02, 0x65, 0x6e, 0x12, 0x58, 0x0a, 0x02, 0x6e, 0x6f, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x46, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x45, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x48, 0x01, 0x52, 0x02, 0x6e, 0x6f, 0x12, 0x37, 0x0a, 0x0e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x42, 0x10, 0xfa, 0xd2, 0xe4, 0x93, 0x02, 0x0a, 0x12, 0x08, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x52, 0x0d, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x3d, 0x0a, 0x0d, 0x70, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xfa, 0xd2, 0xe4, 0x93, 0x02, 0x12, 0x12, 0x10, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x2c, 0x50, 0x52, 0x45, 0x56, 0x49, 0x45, 0x57, 0x52, 0x0c, 0x70, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x73, 0x0a, 0x07, 0x61, 0x6e, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x5a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x06, 0x61, 0x6e, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x99, 0x01, 0x0a, 0x14, 0x61, 0x68, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x5f, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x67, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x45, 0x6e, 0x75, 0x6d, 0x48, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x52, 0x12, 0x61, 0x68, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x45, 0x6e, 0x75, 0x6d, 0x22, 0xb5, 0x01, 0x0a, 0x0e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x1f, 0x0a, 0x1b, 0x56, 0x49, 0x53, 0x49, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1b, 0x0a, 0x17, 0x56, 0x49, 0x53, 0x49, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x56, 0x49, 0x53, 0x49, 0x42, 0x4c, 0x45, 0x10, 0x01, 0x12, 0x2e, 0x0a, 0x18, 0x56, 0x49, 0x53, 0x49, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x10, 0x02, 0x1a, 0x10, 0xfa, 0xd2, 0xe4, 0x93, 0x02, 0x0a, 0x12, 0x08, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x12, 0x35, 0x0a, 0x17, 0x56, 0x49, 0x53, 0x49, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x50, 0x52, 0x45, 0x56, 0x49, 0x45, 0x57, 0x10, 0x03, 0x1a, 0x18, 0xfa, 0xd2, 0xe4, 0x93, 0x02, 0x12, 0x12, 0x10, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x2c, 0x50, 0x52, 0x45, 0x56, 0x49, 0x45, 0x57, 0x22, 0x8b, 0x01, 0x0a, 0x1b, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x45, 0x6e, 0x75, 0x6d, 0x48, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x40, 0x0a, 0x2a, 0x56, 0x49, 0x53, 0x49, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x48, 0x49, 0x44, 0x44, 0x45, 0x4e, 0x5f, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x1a, 0x10, 0xfa, 0xd2, 0xe4, 0x93, 0x02, 0x0a, 0x12, 0x08, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x12, 0x2a, 0x0a, 0x26, 0x56, 0x49, 0x53, 0x49, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x48, 0x49, 0x44, 0x44, 0x45, 0x4e, 0x5f, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x5f, 0x56, 0x49, 0x53, 0x49, 0x42, 0x4c, 0x45, 0x10, 0x01, 0x42, 0x06, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x42, 0x05, 0x0a, 0x03, 0x65, 0x78, 0x74, 0x22, 0x97, 0x02, 0x0a, 0x24, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x6e, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x78, 0x0a, 0x0b, 0x73, 0x75, 0x62, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x57, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x53, 0x75, 0x62, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x6e, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x0a, 0x73, 0x75, 0x62, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x65, 0x0a, 0x04, 0x65, 0x6e, 0x75, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x51, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x45, 0x6e, 0x75, 0x6d, 0x49, 0x6e, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x52, 0x04, 0x65, 0x6e, 0x75, 0x6d, 0x22, 0x39, 0x0a, 0x27, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x53, 0x75, 0x62, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x6e, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x2a, 0x5b, 0x0a, 0x21, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x45, 0x6e, 0x75, 0x6d, 0x49, 0x6e, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x36, 0x0a, 0x32, 0x56, 0x49, 0x53, 0x49, 0x42, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x5f, 0x52, 0x55, 0x4c, 0x45, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x49, 0x4e, 0x5f, 0x50, 0x52, 0x45, 0x56, 0x49, 0x45, 0x57, 0x5f, 0x4d, 0x45, 0x54, 0x48, 0x4f, 0x44, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x32, 0x9b, 0x07, 0x0a, 0x19, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x45, 0x63, 0x68, 0x6f, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xbf, 0x01, 0x0a, 0x04, 0x45, 0x63, 0x68, 0x6f, 0x12, 0x4b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x4b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x1d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x17, 0x22, 0x15, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0xdb, 0x01, 0x0a, 0x0c, 0x45, 0x63, 0x68, 0x6f, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x12, 0x4b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x4b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x31, 0xfa, 0xd2, 0xe4, 0x93, 0x02, 0x0a, 0x12, 0x08, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1b, 0x12, 0x19, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x12, 0xe1, 0x01, 0x0a, 0x0b, 0x45, 0x63, 0x68, 0x6f, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x12, 0x4b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x54, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x6e, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x22, 0x2f, 0xfa, 0xd2, 0xe4, 0x93, 0x02, 0x09, 0x12, 0x07, 0x50, 0x52, 0x45, 0x56, 0x49, 0x45, 0x57, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x12, 0x18, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x5f, 0x70, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x12, 0xf9, 0x01, 0x0a, 0x16, 0x45, 0x63, 0x68, 0x6f, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x41, 0x6e, 0x64, 0x50, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x12, 0x4b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x4b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x45, 0xfa, 0xd2, 0xe4, 0x93, 0x02, 0x12, 0x12, 0x10, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x2c, 0x50, 0x52, 0x45, 0x56, 0x49, 0x45, 0x57, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x27, 0x12, 0x25, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x61, 0x6e, 0x64, 0x5f, 0x70, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, 0x32, 0x80, 0x02, 0x0a, 0x21, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x45, 0x63, 0x68, 0x6f, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xc8, 0x01, 0x0a, 0x04, 0x45, 0x63, 0x68, 0x6f, 0x12, 0x4b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x4b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x56, 0x69, 0x73, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x26, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x20, 0x22, 0x1e, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x63, 0x68, 0x6f, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x1a, 0x10, 0xfa, 0xd2, 0xe4, 0x93, 0x02, 0x0a, 0x12, 0x08, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x4e, 0x41, 0x4c, 0x42, 0x57, 0x5a, 0x55, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x3b, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_rawDescOnce sync.Once file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_rawDescData = file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_rawDesc ) func file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_rawDescGZIP() []byte { file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_rawDescOnce.Do(func() { file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_rawDescData) }) return file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_rawDescData } var file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_enumTypes = make([]protoimpl.EnumInfo, 3) var file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_goTypes = []any{ (VisibilityRuleEnumInPreviewMethod)(0), // 0: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEnumInPreviewMethod (VisibilityRuleSimpleMessage_VisibilityEnum)(0), // 1: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSimpleMessage.VisibilityEnum (VisibilityRuleSimpleMessage_VisibilityEnumHiddenDefault)(0), // 2: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSimpleMessage.VisibilityEnumHiddenDefault (*VisibilityRuleEmbedded)(nil), // 3: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEmbedded (*VisibilityRuleSimpleMessage)(nil), // 4: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSimpleMessage (*VisibilityRuleMessageInPreviewMethod)(nil), // 5: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleMessageInPreviewMethod (*VisibilityRuleSubMessageInPreviewMethod)(nil), // 6: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSubMessageInPreviewMethod } var file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_depIdxs = []int32{ 3, // 0: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSimpleMessage.status:type_name -> grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEmbedded 3, // 1: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSimpleMessage.no:type_name -> grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEmbedded 1, // 2: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSimpleMessage.an_enum:type_name -> grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSimpleMessage.VisibilityEnum 2, // 3: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSimpleMessage.ahidden_default_enum:type_name -> grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSimpleMessage.VisibilityEnumHiddenDefault 6, // 4: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleMessageInPreviewMethod.sub_message:type_name -> grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSubMessageInPreviewMethod 0, // 5: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleMessageInPreviewMethod.enum:type_name -> grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEnumInPreviewMethod 4, // 6: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService.Echo:input_type -> grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSimpleMessage 4, // 7: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService.EchoInternal:input_type -> grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSimpleMessage 4, // 8: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService.EchoPreview:input_type -> grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSimpleMessage 4, // 9: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService.EchoInternalAndPreview:input_type -> grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSimpleMessage 4, // 10: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleInternalEchoService.Echo:input_type -> grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSimpleMessage 4, // 11: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService.Echo:output_type -> grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSimpleMessage 4, // 12: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService.EchoInternal:output_type -> grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSimpleMessage 5, // 13: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService.EchoPreview:output_type -> grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleMessageInPreviewMethod 4, // 14: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService.EchoInternalAndPreview:output_type -> grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSimpleMessage 4, // 15: grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleInternalEchoService.Echo:output_type -> grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleSimpleMessage 11, // [11:16] is the sub-list for method output_type 6, // [6:11] is the sub-list for method input_type 6, // [6:6] is the sub-list for extension type_name 6, // [6:6] is the sub-list for extension extendee 0, // [0:6] is the sub-list for field type_name } func init() { file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_init() } func file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_init() { if File_examples_internal_proto_examplepb_visibility_rule_echo_service_proto != nil { return } file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_msgTypes[0].OneofWrappers = []any{ (*VisibilityRuleEmbedded_Progress)(nil), (*VisibilityRuleEmbedded_Note)(nil), (*VisibilityRuleEmbedded_InternalField)(nil), (*VisibilityRuleEmbedded_PreviewField)(nil), } file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_msgTypes[1].OneofWrappers = []any{ (*VisibilityRuleSimpleMessage_LineNum)(nil), (*VisibilityRuleSimpleMessage_Lang)(nil), (*VisibilityRuleSimpleMessage_En)(nil), (*VisibilityRuleSimpleMessage_No)(nil), } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_rawDesc, NumEnums: 3, NumMessages: 4, NumExtensions: 0, NumServices: 2, }, GoTypes: file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_goTypes, DependencyIndexes: file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_depIdxs, EnumInfos: file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_enumTypes, MessageInfos: file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_msgTypes, }.Build() File_examples_internal_proto_examplepb_visibility_rule_echo_service_proto = out.File file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_rawDesc = nil file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_goTypes = nil file_examples_internal_proto_examplepb_visibility_rule_echo_service_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/examplepb/visibility_rule_echo_service.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/proto/examplepb/visibility_rule_echo_service.proto /* Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package examplepb import ( "context" "errors" "io" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) var filter_VisibilityRuleEchoService_Echo_0 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_VisibilityRuleEchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, client VisibilityRuleEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq VisibilityRuleSimpleMessage metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_VisibilityRuleEchoService_Echo_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_VisibilityRuleEchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, server VisibilityRuleEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq VisibilityRuleSimpleMessage metadata runtime.ServerMetadata err error ) val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_VisibilityRuleEchoService_Echo_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Echo(ctx, &protoReq) return msg, metadata, err } var filter_VisibilityRuleEchoService_EchoInternal_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_VisibilityRuleEchoService_EchoInternal_0(ctx context.Context, marshaler runtime.Marshaler, client VisibilityRuleEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq VisibilityRuleSimpleMessage metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_VisibilityRuleEchoService_EchoInternal_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.EchoInternal(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_VisibilityRuleEchoService_EchoInternal_0(ctx context.Context, marshaler runtime.Marshaler, server VisibilityRuleEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq VisibilityRuleSimpleMessage metadata runtime.ServerMetadata ) if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_VisibilityRuleEchoService_EchoInternal_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.EchoInternal(ctx, &protoReq) return msg, metadata, err } var filter_VisibilityRuleEchoService_EchoPreview_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_VisibilityRuleEchoService_EchoPreview_0(ctx context.Context, marshaler runtime.Marshaler, client VisibilityRuleEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq VisibilityRuleSimpleMessage metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_VisibilityRuleEchoService_EchoPreview_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.EchoPreview(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_VisibilityRuleEchoService_EchoPreview_0(ctx context.Context, marshaler runtime.Marshaler, server VisibilityRuleEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq VisibilityRuleSimpleMessage metadata runtime.ServerMetadata ) if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_VisibilityRuleEchoService_EchoPreview_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.EchoPreview(ctx, &protoReq) return msg, metadata, err } var filter_VisibilityRuleEchoService_EchoInternalAndPreview_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_VisibilityRuleEchoService_EchoInternalAndPreview_0(ctx context.Context, marshaler runtime.Marshaler, client VisibilityRuleEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq VisibilityRuleSimpleMessage metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_VisibilityRuleEchoService_EchoInternalAndPreview_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.EchoInternalAndPreview(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_VisibilityRuleEchoService_EchoInternalAndPreview_0(ctx context.Context, marshaler runtime.Marshaler, server VisibilityRuleEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq VisibilityRuleSimpleMessage metadata runtime.ServerMetadata ) if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_VisibilityRuleEchoService_EchoInternalAndPreview_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.EchoInternalAndPreview(ctx, &protoReq) return msg, metadata, err } var filter_VisibilityRuleInternalEchoService_Echo_0 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_VisibilityRuleInternalEchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, client VisibilityRuleInternalEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq VisibilityRuleSimpleMessage metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_VisibilityRuleInternalEchoService_Echo_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_VisibilityRuleInternalEchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, server VisibilityRuleInternalEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq VisibilityRuleSimpleMessage metadata runtime.ServerMetadata err error ) val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_VisibilityRuleInternalEchoService_Echo_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Echo(ctx, &protoReq) return msg, metadata, err } // RegisterVisibilityRuleEchoServiceHandlerServer registers the http handlers for service VisibilityRuleEchoService to "mux". // UnaryRPC :call VisibilityRuleEchoServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterVisibilityRuleEchoServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterVisibilityRuleEchoServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server VisibilityRuleEchoServiceServer) error { mux.Handle(http.MethodPost, pattern_VisibilityRuleEchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_VisibilityRuleEchoService_Echo_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_VisibilityRuleEchoService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_VisibilityRuleEchoService_EchoInternal_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService/EchoInternal", runtime.WithHTTPPathPattern("/v1/example/echo_internal")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_VisibilityRuleEchoService_EchoInternal_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_VisibilityRuleEchoService_EchoInternal_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_VisibilityRuleEchoService_EchoPreview_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService/EchoPreview", runtime.WithHTTPPathPattern("/v1/example/echo_preview")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_VisibilityRuleEchoService_EchoPreview_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_VisibilityRuleEchoService_EchoPreview_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_VisibilityRuleEchoService_EchoInternalAndPreview_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService/EchoInternalAndPreview", runtime.WithHTTPPathPattern("/v1/example/echo_internal_and_preview")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_VisibilityRuleEchoService_EchoInternalAndPreview_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_VisibilityRuleEchoService_EchoInternalAndPreview_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } // RegisterVisibilityRuleInternalEchoServiceHandlerServer registers the http handlers for service VisibilityRuleInternalEchoService to "mux". // UnaryRPC :call VisibilityRuleInternalEchoServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterVisibilityRuleInternalEchoServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterVisibilityRuleInternalEchoServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server VisibilityRuleInternalEchoServiceServer) error { mux.Handle(http.MethodPost, pattern_VisibilityRuleInternalEchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleInternalEchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/internal/echo/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_VisibilityRuleInternalEchoService_Echo_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_VisibilityRuleInternalEchoService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } // RegisterVisibilityRuleEchoServiceHandlerFromEndpoint is same as RegisterVisibilityRuleEchoServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterVisibilityRuleEchoServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterVisibilityRuleEchoServiceHandler(ctx, mux, conn) } // RegisterVisibilityRuleEchoServiceHandler registers the http handlers for service VisibilityRuleEchoService to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterVisibilityRuleEchoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterVisibilityRuleEchoServiceHandlerClient(ctx, mux, NewVisibilityRuleEchoServiceClient(conn)) } // RegisterVisibilityRuleEchoServiceHandlerClient registers the http handlers for service VisibilityRuleEchoService // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "VisibilityRuleEchoServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "VisibilityRuleEchoServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "VisibilityRuleEchoServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterVisibilityRuleEchoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client VisibilityRuleEchoServiceClient) error { mux.Handle(http.MethodPost, pattern_VisibilityRuleEchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/echo/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_VisibilityRuleEchoService_Echo_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_VisibilityRuleEchoService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_VisibilityRuleEchoService_EchoInternal_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService/EchoInternal", runtime.WithHTTPPathPattern("/v1/example/echo_internal")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_VisibilityRuleEchoService_EchoInternal_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_VisibilityRuleEchoService_EchoInternal_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_VisibilityRuleEchoService_EchoPreview_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService/EchoPreview", runtime.WithHTTPPathPattern("/v1/example/echo_preview")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_VisibilityRuleEchoService_EchoPreview_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_VisibilityRuleEchoService_EchoPreview_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_VisibilityRuleEchoService_EchoInternalAndPreview_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService/EchoInternalAndPreview", runtime.WithHTTPPathPattern("/v1/example/echo_internal_and_preview")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_VisibilityRuleEchoService_EchoInternalAndPreview_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_VisibilityRuleEchoService_EchoInternalAndPreview_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_VisibilityRuleEchoService_Echo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "example", "echo", "id"}, "")) pattern_VisibilityRuleEchoService_EchoInternal_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "echo_internal"}, "")) pattern_VisibilityRuleEchoService_EchoPreview_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "echo_preview"}, "")) pattern_VisibilityRuleEchoService_EchoInternalAndPreview_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "echo_internal_and_preview"}, "")) ) var ( forward_VisibilityRuleEchoService_Echo_0 = runtime.ForwardResponseMessage forward_VisibilityRuleEchoService_EchoInternal_0 = runtime.ForwardResponseMessage forward_VisibilityRuleEchoService_EchoPreview_0 = runtime.ForwardResponseMessage forward_VisibilityRuleEchoService_EchoInternalAndPreview_0 = runtime.ForwardResponseMessage ) // RegisterVisibilityRuleInternalEchoServiceHandlerFromEndpoint is same as RegisterVisibilityRuleInternalEchoServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterVisibilityRuleInternalEchoServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterVisibilityRuleInternalEchoServiceHandler(ctx, mux, conn) } // RegisterVisibilityRuleInternalEchoServiceHandler registers the http handlers for service VisibilityRuleInternalEchoService to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterVisibilityRuleInternalEchoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterVisibilityRuleInternalEchoServiceHandlerClient(ctx, mux, NewVisibilityRuleInternalEchoServiceClient(conn)) } // RegisterVisibilityRuleInternalEchoServiceHandlerClient registers the http handlers for service VisibilityRuleInternalEchoService // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "VisibilityRuleInternalEchoServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "VisibilityRuleInternalEchoServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "VisibilityRuleInternalEchoServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterVisibilityRuleInternalEchoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client VisibilityRuleInternalEchoServiceClient) error { mux.Handle(http.MethodPost, pattern_VisibilityRuleInternalEchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleInternalEchoService/Echo", runtime.WithHTTPPathPattern("/v1/example/internal/echo/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_VisibilityRuleInternalEchoService_Echo_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_VisibilityRuleInternalEchoService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_VisibilityRuleInternalEchoService_Echo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"v1", "example", "internal", "echo", "id"}, "")) ) var ( forward_VisibilityRuleInternalEchoService_Echo_0 = runtime.ForwardResponseMessage ) ================================================ FILE: examples/internal/proto/examplepb/visibility_rule_echo_service.proto ================================================ syntax = "proto3"; // Visibility Rule Echo Service // Similar to echo_service.proto but with annotations to change visibility // of services, methods, fields and enum values. // // `google.api.VisibilityRule` annotations are added to customize where they are generated. // Combined with the option `visibility_restriction_selectors` overlapping rules will appear in the OpenAPI output. // Elements without `google.api.VisibilityRule` annotations will appear as usual in the generated output. // // These restrictions and selectors are completely arbitrary and you can define whatever values or hierarchies you want. // In this example `INTERNAL`, `PREVIEW` are used, but `INTERNAL`, `ALPHA`, `BETA`, `RELEASED`, or anything else could be used if you wish. package grpc.gateway.examples.internal.proto.examplepb; import "google/api/annotations.proto"; import "google/api/visibility.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb;examplepb"; // Embedded represents a message embedded in SimpleMessage. message VisibilityRuleEmbedded { oneof mark { int64 progress = 1; string note = 2; string internal_field = 3 [(google.api.field_visibility).restriction = "INTERNAL"]; string preview_field = 4 [(google.api.field_visibility).restriction = "INTERNAL,PREVIEW"]; } } // SimpleMessage represents a simple message sent to the Echo service. message VisibilityRuleSimpleMessage { enum VisibilityEnum { VISIBILITY_ENUM_UNSPECIFIED = 0; VISIBILITY_ENUM_VISIBLE = 1; VISIBILITY_ENUM_INTERNAL = 2 [(google.api.value_visibility).restriction = "INTERNAL"]; VISIBILITY_ENUM_PREVIEW = 3 [(google.api.value_visibility).restriction = "INTERNAL,PREVIEW"]; } enum VisibilityEnumHiddenDefault { VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED = 0 [(google.api.value_visibility).restriction = "INTERNAL"]; VISIBILITY_ENUM_HIDDEN_DEFAULT_VISIBLE = 1; } // Id represents the message identifier. string id = 1; int64 num = 2; oneof code { int64 line_num = 3; string lang = 4; } VisibilityRuleEmbedded status = 5; oneof ext { int64 en = 6; VisibilityRuleEmbedded no = 7; } string internal_field = 8 [(google.api.field_visibility).restriction = "INTERNAL"]; string preview_field = 9 [(google.api.field_visibility).restriction = "INTERNAL,PREVIEW"]; VisibilityEnum an_enum = 10; VisibilityEnumHiddenDefault ahidden_default_enum = 11; } // MessageInPreviewMethod doesn't define its own visibility restrictions, // but is only included in a method marked as "PREVIEW", so it will only // appear if `visibility_restriction_selectors` include "PREVIEW". message VisibilityRuleMessageInPreviewMethod { string id = 1; VisibilityRuleSubMessageInPreviewMethod sub_message = 2; VisibilityRuleEnumInPreviewMethod enum = 3; } // SubMessageInPreviewMethod doesn't define its own visibility restrictions, // but is only included in a method marked as "PREVIEW", so it will only // appear if `visibility_restriction_selectors` include "PREVIEW". message VisibilityRuleSubMessageInPreviewMethod { string id = 1; } // EnumInPreviewMethod doesn't define its own visibility restrictions, // but is only included in a method marked as "PREVIEW", so it will only // appear if `visibility_restriction_selectors` include "PREVIEW". enum VisibilityRuleEnumInPreviewMethod { VISIBILITY_RULE_ENUM_IN_PREVIEW_METHOD_UNSPECIFIED = 0; } // VisibilityRuleEchoService service responds to incoming echo requests. // Different services will be available in the swagger documentation depending // based on `google.api.VisibilityRule`s and the set `visibility_restriction_selectors` // flag when calling protoc-gen-openapiv2. service VisibilityRuleEchoService { // Echo method receives a simple message and returns it. // It should always be visible in the open API output. rpc Echo(VisibilityRuleSimpleMessage) returns (VisibilityRuleSimpleMessage) { option (google.api.http) = {post: "/v1/example/echo/{id}"}; } // EchoInternal is an internal API that should only be visible in the OpenAPI spec // if `visibility_restriction_selectors` includes "INTERNAL". rpc EchoInternal(VisibilityRuleSimpleMessage) returns (VisibilityRuleSimpleMessage) { option (google.api.method_visibility).restriction = "INTERNAL"; option (google.api.http) = {get: "/v1/example/echo_internal"}; } // EchoPreview is a preview API that should only be visible in the OpenAPI spec // if `visibility_restriction_selectors` includes "PREVIEW". rpc EchoPreview(VisibilityRuleSimpleMessage) returns (VisibilityRuleMessageInPreviewMethod) { option (google.api.method_visibility).restriction = "PREVIEW"; option (google.api.http) = {get: "/v1/example/echo_preview"}; } // EchoInternalAndPreview is a internal and preview API that should only be visible in the OpenAPI spec // if `visibility_restriction_selectors` includes "PREVIEW" or "INTERNAL". rpc EchoInternalAndPreview(VisibilityRuleSimpleMessage) returns (VisibilityRuleSimpleMessage) { option (google.api.method_visibility).restriction = "INTERNAL,PREVIEW"; option (google.api.http) = {get: "/v1/example/echo_internal_and_preview"}; } } // VisibilityRuleInternalEchoService service responds to incoming echo requests. // It should only be visible in the OpenAPI spec if `visibility_restriction_selectors` includes "INTERNAL". service VisibilityRuleInternalEchoService { option (google.api.api_visibility).restriction = "INTERNAL"; // Echo method receives a simple message and returns it. // It should not be visible in the open API output. rpc Echo(VisibilityRuleSimpleMessage) returns (VisibilityRuleSimpleMessage) { option (google.api.http) = {post: "/v1/example/internal/echo/{id}"}; } } ================================================ FILE: examples/internal/proto/examplepb/visibility_rule_echo_service_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: examples/internal/proto/examplepb/visibility_rule_echo_service.proto // Visibility Rule Echo Service // Similar to echo_service.proto but with annotations to change visibility // of services, methods, fields and enum values. // // `google.api.VisibilityRule` annotations are added to customize where they are generated. // Combined with the option `visibility_restriction_selectors` overlapping rules will appear in the OpenAPI output. // Elements without `google.api.VisibilityRule` annotations will appear as usual in the generated output. // // These restrictions and selectors are completely arbitrary and you can define whatever values or hierarchies you want. // In this example `INTERNAL`, `PREVIEW` are used, but `INTERNAL`, `ALPHA`, `BETA`, `RELEASED`, or anything else could be used if you wish. package examplepb import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( VisibilityRuleEchoService_Echo_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService/Echo" VisibilityRuleEchoService_EchoInternal_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService/EchoInternal" VisibilityRuleEchoService_EchoPreview_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService/EchoPreview" VisibilityRuleEchoService_EchoInternalAndPreview_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService/EchoInternalAndPreview" ) // VisibilityRuleEchoServiceClient is the client API for VisibilityRuleEchoService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // // VisibilityRuleEchoService service responds to incoming echo requests. // Different services will be available in the swagger documentation depending // based on `google.api.VisibilityRule`s and the set `visibility_restriction_selectors` // flag when calling protoc-gen-openapiv2. type VisibilityRuleEchoServiceClient interface { // Echo method receives a simple message and returns it. // It should always be visible in the open API output. Echo(ctx context.Context, in *VisibilityRuleSimpleMessage, opts ...grpc.CallOption) (*VisibilityRuleSimpleMessage, error) // EchoInternal is an internal API that should only be visible in the OpenAPI spec // if `visibility_restriction_selectors` includes "INTERNAL". EchoInternal(ctx context.Context, in *VisibilityRuleSimpleMessage, opts ...grpc.CallOption) (*VisibilityRuleSimpleMessage, error) // EchoPreview is a preview API that should only be visible in the OpenAPI spec // if `visibility_restriction_selectors` includes "PREVIEW". EchoPreview(ctx context.Context, in *VisibilityRuleSimpleMessage, opts ...grpc.CallOption) (*VisibilityRuleMessageInPreviewMethod, error) // EchoInternalAndPreview is a internal and preview API that should only be visible in the OpenAPI spec // if `visibility_restriction_selectors` includes "PREVIEW" or "INTERNAL". EchoInternalAndPreview(ctx context.Context, in *VisibilityRuleSimpleMessage, opts ...grpc.CallOption) (*VisibilityRuleSimpleMessage, error) } type visibilityRuleEchoServiceClient struct { cc grpc.ClientConnInterface } func NewVisibilityRuleEchoServiceClient(cc grpc.ClientConnInterface) VisibilityRuleEchoServiceClient { return &visibilityRuleEchoServiceClient{cc} } func (c *visibilityRuleEchoServiceClient) Echo(ctx context.Context, in *VisibilityRuleSimpleMessage, opts ...grpc.CallOption) (*VisibilityRuleSimpleMessage, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(VisibilityRuleSimpleMessage) err := c.cc.Invoke(ctx, VisibilityRuleEchoService_Echo_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *visibilityRuleEchoServiceClient) EchoInternal(ctx context.Context, in *VisibilityRuleSimpleMessage, opts ...grpc.CallOption) (*VisibilityRuleSimpleMessage, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(VisibilityRuleSimpleMessage) err := c.cc.Invoke(ctx, VisibilityRuleEchoService_EchoInternal_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *visibilityRuleEchoServiceClient) EchoPreview(ctx context.Context, in *VisibilityRuleSimpleMessage, opts ...grpc.CallOption) (*VisibilityRuleMessageInPreviewMethod, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(VisibilityRuleMessageInPreviewMethod) err := c.cc.Invoke(ctx, VisibilityRuleEchoService_EchoPreview_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *visibilityRuleEchoServiceClient) EchoInternalAndPreview(ctx context.Context, in *VisibilityRuleSimpleMessage, opts ...grpc.CallOption) (*VisibilityRuleSimpleMessage, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(VisibilityRuleSimpleMessage) err := c.cc.Invoke(ctx, VisibilityRuleEchoService_EchoInternalAndPreview_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // VisibilityRuleEchoServiceServer is the server API for VisibilityRuleEchoService service. // All implementations should embed UnimplementedVisibilityRuleEchoServiceServer // for forward compatibility. // // VisibilityRuleEchoService service responds to incoming echo requests. // Different services will be available in the swagger documentation depending // based on `google.api.VisibilityRule`s and the set `visibility_restriction_selectors` // flag when calling protoc-gen-openapiv2. type VisibilityRuleEchoServiceServer interface { // Echo method receives a simple message and returns it. // It should always be visible in the open API output. Echo(context.Context, *VisibilityRuleSimpleMessage) (*VisibilityRuleSimpleMessage, error) // EchoInternal is an internal API that should only be visible in the OpenAPI spec // if `visibility_restriction_selectors` includes "INTERNAL". EchoInternal(context.Context, *VisibilityRuleSimpleMessage) (*VisibilityRuleSimpleMessage, error) // EchoPreview is a preview API that should only be visible in the OpenAPI spec // if `visibility_restriction_selectors` includes "PREVIEW". EchoPreview(context.Context, *VisibilityRuleSimpleMessage) (*VisibilityRuleMessageInPreviewMethod, error) // EchoInternalAndPreview is a internal and preview API that should only be visible in the OpenAPI spec // if `visibility_restriction_selectors` includes "PREVIEW" or "INTERNAL". EchoInternalAndPreview(context.Context, *VisibilityRuleSimpleMessage) (*VisibilityRuleSimpleMessage, error) } // UnimplementedVisibilityRuleEchoServiceServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedVisibilityRuleEchoServiceServer struct{} func (UnimplementedVisibilityRuleEchoServiceServer) Echo(context.Context, *VisibilityRuleSimpleMessage) (*VisibilityRuleSimpleMessage, error) { return nil, status.Errorf(codes.Unimplemented, "method Echo not implemented") } func (UnimplementedVisibilityRuleEchoServiceServer) EchoInternal(context.Context, *VisibilityRuleSimpleMessage) (*VisibilityRuleSimpleMessage, error) { return nil, status.Errorf(codes.Unimplemented, "method EchoInternal not implemented") } func (UnimplementedVisibilityRuleEchoServiceServer) EchoPreview(context.Context, *VisibilityRuleSimpleMessage) (*VisibilityRuleMessageInPreviewMethod, error) { return nil, status.Errorf(codes.Unimplemented, "method EchoPreview not implemented") } func (UnimplementedVisibilityRuleEchoServiceServer) EchoInternalAndPreview(context.Context, *VisibilityRuleSimpleMessage) (*VisibilityRuleSimpleMessage, error) { return nil, status.Errorf(codes.Unimplemented, "method EchoInternalAndPreview not implemented") } func (UnimplementedVisibilityRuleEchoServiceServer) testEmbeddedByValue() {} // UnsafeVisibilityRuleEchoServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to VisibilityRuleEchoServiceServer will // result in compilation errors. type UnsafeVisibilityRuleEchoServiceServer interface { mustEmbedUnimplementedVisibilityRuleEchoServiceServer() } func RegisterVisibilityRuleEchoServiceServer(s grpc.ServiceRegistrar, srv VisibilityRuleEchoServiceServer) { // If the following call pancis, it indicates UnimplementedVisibilityRuleEchoServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&VisibilityRuleEchoService_ServiceDesc, srv) } func _VisibilityRuleEchoService_Echo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(VisibilityRuleSimpleMessage) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(VisibilityRuleEchoServiceServer).Echo(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: VisibilityRuleEchoService_Echo_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(VisibilityRuleEchoServiceServer).Echo(ctx, req.(*VisibilityRuleSimpleMessage)) } return interceptor(ctx, in, info, handler) } func _VisibilityRuleEchoService_EchoInternal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(VisibilityRuleSimpleMessage) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(VisibilityRuleEchoServiceServer).EchoInternal(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: VisibilityRuleEchoService_EchoInternal_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(VisibilityRuleEchoServiceServer).EchoInternal(ctx, req.(*VisibilityRuleSimpleMessage)) } return interceptor(ctx, in, info, handler) } func _VisibilityRuleEchoService_EchoPreview_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(VisibilityRuleSimpleMessage) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(VisibilityRuleEchoServiceServer).EchoPreview(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: VisibilityRuleEchoService_EchoPreview_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(VisibilityRuleEchoServiceServer).EchoPreview(ctx, req.(*VisibilityRuleSimpleMessage)) } return interceptor(ctx, in, info, handler) } func _VisibilityRuleEchoService_EchoInternalAndPreview_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(VisibilityRuleSimpleMessage) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(VisibilityRuleEchoServiceServer).EchoInternalAndPreview(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: VisibilityRuleEchoService_EchoInternalAndPreview_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(VisibilityRuleEchoServiceServer).EchoInternalAndPreview(ctx, req.(*VisibilityRuleSimpleMessage)) } return interceptor(ctx, in, info, handler) } // VisibilityRuleEchoService_ServiceDesc is the grpc.ServiceDesc for VisibilityRuleEchoService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var VisibilityRuleEchoService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleEchoService", HandlerType: (*VisibilityRuleEchoServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Echo", Handler: _VisibilityRuleEchoService_Echo_Handler, }, { MethodName: "EchoInternal", Handler: _VisibilityRuleEchoService_EchoInternal_Handler, }, { MethodName: "EchoPreview", Handler: _VisibilityRuleEchoService_EchoPreview_Handler, }, { MethodName: "EchoInternalAndPreview", Handler: _VisibilityRuleEchoService_EchoInternalAndPreview_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/internal/proto/examplepb/visibility_rule_echo_service.proto", } const ( VisibilityRuleInternalEchoService_Echo_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleInternalEchoService/Echo" ) // VisibilityRuleInternalEchoServiceClient is the client API for VisibilityRuleInternalEchoService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // // VisibilityRuleInternalEchoService service responds to incoming echo requests. // It should only be visible in the OpenAPI spec if `visibility_restriction_selectors` includes "INTERNAL". type VisibilityRuleInternalEchoServiceClient interface { // Echo method receives a simple message and returns it. // It should not be visible in the open API output. Echo(ctx context.Context, in *VisibilityRuleSimpleMessage, opts ...grpc.CallOption) (*VisibilityRuleSimpleMessage, error) } type visibilityRuleInternalEchoServiceClient struct { cc grpc.ClientConnInterface } func NewVisibilityRuleInternalEchoServiceClient(cc grpc.ClientConnInterface) VisibilityRuleInternalEchoServiceClient { return &visibilityRuleInternalEchoServiceClient{cc} } func (c *visibilityRuleInternalEchoServiceClient) Echo(ctx context.Context, in *VisibilityRuleSimpleMessage, opts ...grpc.CallOption) (*VisibilityRuleSimpleMessage, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(VisibilityRuleSimpleMessage) err := c.cc.Invoke(ctx, VisibilityRuleInternalEchoService_Echo_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // VisibilityRuleInternalEchoServiceServer is the server API for VisibilityRuleInternalEchoService service. // All implementations should embed UnimplementedVisibilityRuleInternalEchoServiceServer // for forward compatibility. // // VisibilityRuleInternalEchoService service responds to incoming echo requests. // It should only be visible in the OpenAPI spec if `visibility_restriction_selectors` includes "INTERNAL". type VisibilityRuleInternalEchoServiceServer interface { // Echo method receives a simple message and returns it. // It should not be visible in the open API output. Echo(context.Context, *VisibilityRuleSimpleMessage) (*VisibilityRuleSimpleMessage, error) } // UnimplementedVisibilityRuleInternalEchoServiceServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedVisibilityRuleInternalEchoServiceServer struct{} func (UnimplementedVisibilityRuleInternalEchoServiceServer) Echo(context.Context, *VisibilityRuleSimpleMessage) (*VisibilityRuleSimpleMessage, error) { return nil, status.Errorf(codes.Unimplemented, "method Echo not implemented") } func (UnimplementedVisibilityRuleInternalEchoServiceServer) testEmbeddedByValue() {} // UnsafeVisibilityRuleInternalEchoServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to VisibilityRuleInternalEchoServiceServer will // result in compilation errors. type UnsafeVisibilityRuleInternalEchoServiceServer interface { mustEmbedUnimplementedVisibilityRuleInternalEchoServiceServer() } func RegisterVisibilityRuleInternalEchoServiceServer(s grpc.ServiceRegistrar, srv VisibilityRuleInternalEchoServiceServer) { // If the following call pancis, it indicates UnimplementedVisibilityRuleInternalEchoServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&VisibilityRuleInternalEchoService_ServiceDesc, srv) } func _VisibilityRuleInternalEchoService_Echo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(VisibilityRuleSimpleMessage) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(VisibilityRuleInternalEchoServiceServer).Echo(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: VisibilityRuleInternalEchoService_Echo_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(VisibilityRuleInternalEchoServiceServer).Echo(ctx, req.(*VisibilityRuleSimpleMessage)) } return interceptor(ctx, in, info, handler) } // VisibilityRuleInternalEchoService_ServiceDesc is the grpc.ServiceDesc for VisibilityRuleInternalEchoService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var VisibilityRuleInternalEchoService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.VisibilityRuleInternalEchoService", HandlerType: (*VisibilityRuleInternalEchoServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Echo", Handler: _VisibilityRuleInternalEchoService_Echo_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/internal/proto/examplepb/visibility_rule_echo_service.proto", } ================================================ FILE: examples/internal/proto/examplepb/visibility_rule_enums_as_ints_echo_service.buf.gen.yaml ================================================ version: v2 plugins: - local: protoc-gen-openapiv2 out: . opt: - enums_as_ints=true ================================================ FILE: examples/internal/proto/examplepb/visibility_rule_enums_as_ints_echo_service.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/examplepb/visibility_rule_echo_service.proto", "description": "Visibility Rule Echo Service\nSimilar to echo_service.proto but with annotations to change visibility\nof services, methods, fields and enum values.\n\n`google.api.VisibilityRule` annotations are added to customize where they are generated.\nCombined with the option `visibility_restriction_selectors` overlapping rules will appear in the OpenAPI output.\nElements without `google.api.VisibilityRule` annotations will appear as usual in the generated output.\n\nThese restrictions and selectors are completely arbitrary and you can define whatever values or hierarchies you want.\nIn this example `INTERNAL`, `PREVIEW` are used, but `INTERNAL`, `ALPHA`, `BETA`, `RELEASED`, or anything else could be used if you wish.", "version": "version not set" }, "tags": [ { "name": "VisibilityRuleEchoService" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/v1/example/echo/{id}": { "post": { "summary": "Echo method receives a simple message and returns it.\nIt should always be visible in the open API output.", "operationId": "VisibilityRuleEchoService_Echo", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbVisibilityRuleSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "path", "required": true, "type": "string" }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "anEnum", "in": "query", "required": false, "type": "integer", "enum": [ 0, 1 ], "default": 0 }, { "name": "ahiddenDefaultEnum", "in": "query", "required": false, "type": "integer", "enum": [ 1 ], "default": 0 } ], "tags": [ "VisibilityRuleEchoService" ] } } }, "definitions": { "VisibilityRuleSimpleMessageVisibilityEnum": { "type": "integer", "format": "int32", "enum": [ 0, 1 ], "default": 0 }, "VisibilityRuleSimpleMessageVisibilityEnumHiddenDefault": { "type": "integer", "format": "int32", "enum": [ 1 ], "default": 0 }, "examplepbVisibilityRuleEmbedded": { "type": "object", "properties": { "progress": { "type": "string", "format": "int64" }, "note": { "type": "string" } }, "description": "Embedded represents a message embedded in SimpleMessage." }, "examplepbVisibilityRuleSimpleMessage": { "type": "object", "properties": { "id": { "type": "string", "description": "Id represents the message identifier." }, "num": { "type": "string", "format": "int64" }, "lineNum": { "type": "string", "format": "int64" }, "lang": { "type": "string" }, "status": { "$ref": "#/definitions/examplepbVisibilityRuleEmbedded" }, "en": { "type": "string", "format": "int64" }, "no": { "$ref": "#/definitions/examplepbVisibilityRuleEmbedded" }, "anEnum": { "$ref": "#/definitions/VisibilityRuleSimpleMessageVisibilityEnum" }, "ahiddenDefaultEnum": { "$ref": "#/definitions/VisibilityRuleSimpleMessageVisibilityEnumHiddenDefault" } }, "description": "SimpleMessage represents a simple message sent to the Echo service." }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string" } }, "additionalProperties": {} }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } } } } ================================================ FILE: examples/internal/proto/examplepb/visibility_rule_internal_echo_service.buf.gen.yaml ================================================ version: v2 plugins: - local: protoc-gen-openapiv2 out: . opt: - visibility_restriction_selectors=INTERNAL ================================================ FILE: examples/internal/proto/examplepb/visibility_rule_internal_echo_service.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/examplepb/visibility_rule_echo_service.proto", "description": "Visibility Rule Echo Service\nSimilar to echo_service.proto but with annotations to change visibility\nof services, methods, fields and enum values.\n\n`google.api.VisibilityRule` annotations are added to customize where they are generated.\nCombined with the option `visibility_restriction_selectors` overlapping rules will appear in the OpenAPI output.\nElements without `google.api.VisibilityRule` annotations will appear as usual in the generated output.\n\nThese restrictions and selectors are completely arbitrary and you can define whatever values or hierarchies you want.\nIn this example `INTERNAL`, `PREVIEW` are used, but `INTERNAL`, `ALPHA`, `BETA`, `RELEASED`, or anything else could be used if you wish.", "version": "version not set" }, "tags": [ { "name": "VisibilityRuleEchoService" }, { "name": "VisibilityRuleInternalEchoService" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/v1/example/echo/{id}": { "post": { "summary": "Echo method receives a simple message and returns it.\nIt should always be visible in the open API output.", "operationId": "VisibilityRuleEchoService_Echo", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbVisibilityRuleSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "path", "required": true, "type": "string" }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "status.internalField", "in": "query", "required": false, "type": "string" }, { "name": "status.previewField", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "no.internalField", "in": "query", "required": false, "type": "string" }, { "name": "no.previewField", "in": "query", "required": false, "type": "string" }, { "name": "internalField", "in": "query", "required": false, "type": "string" }, { "name": "previewField", "in": "query", "required": false, "type": "string" }, { "name": "anEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_UNSPECIFIED", "VISIBILITY_ENUM_VISIBLE", "VISIBILITY_ENUM_INTERNAL", "VISIBILITY_ENUM_PREVIEW" ], "default": "VISIBILITY_ENUM_UNSPECIFIED" }, { "name": "ahiddenDefaultEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED", "VISIBILITY_ENUM_HIDDEN_DEFAULT_VISIBLE" ], "default": "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED" } ], "tags": [ "VisibilityRuleEchoService" ] } }, "/v1/example/echo_internal": { "get": { "summary": "EchoInternal is an internal API that should only be visible in the OpenAPI spec\nif `visibility_restriction_selectors` includes \"INTERNAL\".", "operationId": "VisibilityRuleEchoService_EchoInternal", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbVisibilityRuleSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "query", "required": false, "type": "string" }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "status.internalField", "in": "query", "required": false, "type": "string" }, { "name": "status.previewField", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "no.internalField", "in": "query", "required": false, "type": "string" }, { "name": "no.previewField", "in": "query", "required": false, "type": "string" }, { "name": "internalField", "in": "query", "required": false, "type": "string" }, { "name": "previewField", "in": "query", "required": false, "type": "string" }, { "name": "anEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_UNSPECIFIED", "VISIBILITY_ENUM_VISIBLE", "VISIBILITY_ENUM_INTERNAL", "VISIBILITY_ENUM_PREVIEW" ], "default": "VISIBILITY_ENUM_UNSPECIFIED" }, { "name": "ahiddenDefaultEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED", "VISIBILITY_ENUM_HIDDEN_DEFAULT_VISIBLE" ], "default": "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED" } ], "tags": [ "VisibilityRuleEchoService" ] } }, "/v1/example/echo_internal_and_preview": { "get": { "summary": "EchoInternalAndPreview is a internal and preview API that should only be visible in the OpenAPI spec\nif `visibility_restriction_selectors` includes \"PREVIEW\" or \"INTERNAL\".", "operationId": "VisibilityRuleEchoService_EchoInternalAndPreview", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbVisibilityRuleSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "query", "required": false, "type": "string" }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "status.internalField", "in": "query", "required": false, "type": "string" }, { "name": "status.previewField", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "no.internalField", "in": "query", "required": false, "type": "string" }, { "name": "no.previewField", "in": "query", "required": false, "type": "string" }, { "name": "internalField", "in": "query", "required": false, "type": "string" }, { "name": "previewField", "in": "query", "required": false, "type": "string" }, { "name": "anEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_UNSPECIFIED", "VISIBILITY_ENUM_VISIBLE", "VISIBILITY_ENUM_INTERNAL", "VISIBILITY_ENUM_PREVIEW" ], "default": "VISIBILITY_ENUM_UNSPECIFIED" }, { "name": "ahiddenDefaultEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED", "VISIBILITY_ENUM_HIDDEN_DEFAULT_VISIBLE" ], "default": "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED" } ], "tags": [ "VisibilityRuleEchoService" ] } }, "/v1/example/internal/echo/{id}": { "post": { "summary": "Echo method receives a simple message and returns it.\nIt should not be visible in the open API output.", "operationId": "VisibilityRuleInternalEchoService_Echo", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbVisibilityRuleSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "path", "required": true, "type": "string" }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "status.internalField", "in": "query", "required": false, "type": "string" }, { "name": "status.previewField", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "no.internalField", "in": "query", "required": false, "type": "string" }, { "name": "no.previewField", "in": "query", "required": false, "type": "string" }, { "name": "internalField", "in": "query", "required": false, "type": "string" }, { "name": "previewField", "in": "query", "required": false, "type": "string" }, { "name": "anEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_UNSPECIFIED", "VISIBILITY_ENUM_VISIBLE", "VISIBILITY_ENUM_INTERNAL", "VISIBILITY_ENUM_PREVIEW" ], "default": "VISIBILITY_ENUM_UNSPECIFIED" }, { "name": "ahiddenDefaultEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED", "VISIBILITY_ENUM_HIDDEN_DEFAULT_VISIBLE" ], "default": "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED" } ], "tags": [ "VisibilityRuleInternalEchoService" ] } } }, "definitions": { "VisibilityRuleSimpleMessageVisibilityEnum": { "type": "string", "enum": [ "VISIBILITY_ENUM_UNSPECIFIED", "VISIBILITY_ENUM_VISIBLE", "VISIBILITY_ENUM_INTERNAL", "VISIBILITY_ENUM_PREVIEW" ], "default": "VISIBILITY_ENUM_UNSPECIFIED" }, "VisibilityRuleSimpleMessageVisibilityEnumHiddenDefault": { "type": "string", "enum": [ "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED", "VISIBILITY_ENUM_HIDDEN_DEFAULT_VISIBLE" ], "default": "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED" }, "examplepbVisibilityRuleEmbedded": { "type": "object", "properties": { "progress": { "type": "string", "format": "int64" }, "note": { "type": "string" }, "internalField": { "type": "string" }, "previewField": { "type": "string" } }, "description": "Embedded represents a message embedded in SimpleMessage." }, "examplepbVisibilityRuleSimpleMessage": { "type": "object", "properties": { "id": { "type": "string", "description": "Id represents the message identifier." }, "num": { "type": "string", "format": "int64" }, "lineNum": { "type": "string", "format": "int64" }, "lang": { "type": "string" }, "status": { "$ref": "#/definitions/examplepbVisibilityRuleEmbedded" }, "en": { "type": "string", "format": "int64" }, "no": { "$ref": "#/definitions/examplepbVisibilityRuleEmbedded" }, "internalField": { "type": "string" }, "previewField": { "type": "string" }, "anEnum": { "$ref": "#/definitions/VisibilityRuleSimpleMessageVisibilityEnum" }, "ahiddenDefaultEnum": { "$ref": "#/definitions/VisibilityRuleSimpleMessageVisibilityEnumHiddenDefault" } }, "description": "SimpleMessage represents a simple message sent to the Echo service." }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string" } }, "additionalProperties": {} }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } } } } ================================================ FILE: examples/internal/proto/examplepb/visibility_rule_none_echo_service.buf.gen.yaml ================================================ version: v2 plugins: - local: protoc-gen-openapiv2 out: . ================================================ FILE: examples/internal/proto/examplepb/visibility_rule_none_echo_service.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/examplepb/visibility_rule_echo_service.proto", "description": "Visibility Rule Echo Service\nSimilar to echo_service.proto but with annotations to change visibility\nof services, methods, fields and enum values.\n\n`google.api.VisibilityRule` annotations are added to customize where they are generated.\nCombined with the option `visibility_restriction_selectors` overlapping rules will appear in the OpenAPI output.\nElements without `google.api.VisibilityRule` annotations will appear as usual in the generated output.\n\nThese restrictions and selectors are completely arbitrary and you can define whatever values or hierarchies you want.\nIn this example `INTERNAL`, `PREVIEW` are used, but `INTERNAL`, `ALPHA`, `BETA`, `RELEASED`, or anything else could be used if you wish.", "version": "version not set" }, "tags": [ { "name": "VisibilityRuleEchoService" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/v1/example/echo/{id}": { "post": { "summary": "Echo method receives a simple message and returns it.\nIt should always be visible in the open API output.", "operationId": "VisibilityRuleEchoService_Echo", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbVisibilityRuleSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "path", "required": true, "type": "string" }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "anEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_UNSPECIFIED", "VISIBILITY_ENUM_VISIBLE" ], "default": "VISIBILITY_ENUM_UNSPECIFIED" }, { "name": "ahiddenDefaultEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_HIDDEN_DEFAULT_VISIBLE" ] } ], "tags": [ "VisibilityRuleEchoService" ] } } }, "definitions": { "VisibilityRuleSimpleMessageVisibilityEnum": { "type": "string", "enum": [ "VISIBILITY_ENUM_UNSPECIFIED", "VISIBILITY_ENUM_VISIBLE" ], "default": "VISIBILITY_ENUM_UNSPECIFIED" }, "VisibilityRuleSimpleMessageVisibilityEnumHiddenDefault": { "type": "string", "enum": [ "VISIBILITY_ENUM_HIDDEN_DEFAULT_VISIBLE" ] }, "examplepbVisibilityRuleEmbedded": { "type": "object", "properties": { "progress": { "type": "string", "format": "int64" }, "note": { "type": "string" } }, "description": "Embedded represents a message embedded in SimpleMessage." }, "examplepbVisibilityRuleSimpleMessage": { "type": "object", "properties": { "id": { "type": "string", "description": "Id represents the message identifier." }, "num": { "type": "string", "format": "int64" }, "lineNum": { "type": "string", "format": "int64" }, "lang": { "type": "string" }, "status": { "$ref": "#/definitions/examplepbVisibilityRuleEmbedded" }, "en": { "type": "string", "format": "int64" }, "no": { "$ref": "#/definitions/examplepbVisibilityRuleEmbedded" }, "anEnum": { "$ref": "#/definitions/VisibilityRuleSimpleMessageVisibilityEnum" }, "ahiddenDefaultEnum": { "$ref": "#/definitions/VisibilityRuleSimpleMessageVisibilityEnumHiddenDefault" } }, "description": "SimpleMessage represents a simple message sent to the Echo service." }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string" } }, "additionalProperties": {} }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } } } } ================================================ FILE: examples/internal/proto/examplepb/visibility_rule_preview_and_internal_echo_service.buf.gen.yaml ================================================ version: v2 plugins: - local: protoc-gen-openapiv2 out: . opt: - visibility_restriction_selectors=PREVIEW - visibility_restriction_selectors=INTERNAL ================================================ FILE: examples/internal/proto/examplepb/visibility_rule_preview_and_internal_echo_service.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/examplepb/visibility_rule_echo_service.proto", "description": "Visibility Rule Echo Service\nSimilar to echo_service.proto but with annotations to change visibility\nof services, methods, fields and enum values.\n\n`google.api.VisibilityRule` annotations are added to customize where they are generated.\nCombined with the option `visibility_restriction_selectors` overlapping rules will appear in the OpenAPI output.\nElements without `google.api.VisibilityRule` annotations will appear as usual in the generated output.\n\nThese restrictions and selectors are completely arbitrary and you can define whatever values or hierarchies you want.\nIn this example `INTERNAL`, `PREVIEW` are used, but `INTERNAL`, `ALPHA`, `BETA`, `RELEASED`, or anything else could be used if you wish.", "version": "version not set" }, "tags": [ { "name": "VisibilityRuleEchoService" }, { "name": "VisibilityRuleInternalEchoService" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/v1/example/echo/{id}": { "post": { "summary": "Echo method receives a simple message and returns it.\nIt should always be visible in the open API output.", "operationId": "VisibilityRuleEchoService_Echo", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbVisibilityRuleSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "path", "required": true, "type": "string" }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "status.internalField", "in": "query", "required": false, "type": "string" }, { "name": "status.previewField", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "no.internalField", "in": "query", "required": false, "type": "string" }, { "name": "no.previewField", "in": "query", "required": false, "type": "string" }, { "name": "internalField", "in": "query", "required": false, "type": "string" }, { "name": "previewField", "in": "query", "required": false, "type": "string" }, { "name": "anEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_UNSPECIFIED", "VISIBILITY_ENUM_VISIBLE", "VISIBILITY_ENUM_INTERNAL", "VISIBILITY_ENUM_PREVIEW" ], "default": "VISIBILITY_ENUM_UNSPECIFIED" }, { "name": "ahiddenDefaultEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED", "VISIBILITY_ENUM_HIDDEN_DEFAULT_VISIBLE" ], "default": "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED" } ], "tags": [ "VisibilityRuleEchoService" ] } }, "/v1/example/echo_internal": { "get": { "summary": "EchoInternal is an internal API that should only be visible in the OpenAPI spec\nif `visibility_restriction_selectors` includes \"INTERNAL\".", "operationId": "VisibilityRuleEchoService_EchoInternal", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbVisibilityRuleSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "query", "required": false, "type": "string" }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "status.internalField", "in": "query", "required": false, "type": "string" }, { "name": "status.previewField", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "no.internalField", "in": "query", "required": false, "type": "string" }, { "name": "no.previewField", "in": "query", "required": false, "type": "string" }, { "name": "internalField", "in": "query", "required": false, "type": "string" }, { "name": "previewField", "in": "query", "required": false, "type": "string" }, { "name": "anEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_UNSPECIFIED", "VISIBILITY_ENUM_VISIBLE", "VISIBILITY_ENUM_INTERNAL", "VISIBILITY_ENUM_PREVIEW" ], "default": "VISIBILITY_ENUM_UNSPECIFIED" }, { "name": "ahiddenDefaultEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED", "VISIBILITY_ENUM_HIDDEN_DEFAULT_VISIBLE" ], "default": "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED" } ], "tags": [ "VisibilityRuleEchoService" ] } }, "/v1/example/echo_internal_and_preview": { "get": { "summary": "EchoInternalAndPreview is a internal and preview API that should only be visible in the OpenAPI spec\nif `visibility_restriction_selectors` includes \"PREVIEW\" or \"INTERNAL\".", "operationId": "VisibilityRuleEchoService_EchoInternalAndPreview", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbVisibilityRuleSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "query", "required": false, "type": "string" }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "status.internalField", "in": "query", "required": false, "type": "string" }, { "name": "status.previewField", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "no.internalField", "in": "query", "required": false, "type": "string" }, { "name": "no.previewField", "in": "query", "required": false, "type": "string" }, { "name": "internalField", "in": "query", "required": false, "type": "string" }, { "name": "previewField", "in": "query", "required": false, "type": "string" }, { "name": "anEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_UNSPECIFIED", "VISIBILITY_ENUM_VISIBLE", "VISIBILITY_ENUM_INTERNAL", "VISIBILITY_ENUM_PREVIEW" ], "default": "VISIBILITY_ENUM_UNSPECIFIED" }, { "name": "ahiddenDefaultEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED", "VISIBILITY_ENUM_HIDDEN_DEFAULT_VISIBLE" ], "default": "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED" } ], "tags": [ "VisibilityRuleEchoService" ] } }, "/v1/example/echo_preview": { "get": { "summary": "EchoPreview is a preview API that should only be visible in the OpenAPI spec\nif `visibility_restriction_selectors` includes \"PREVIEW\".", "operationId": "VisibilityRuleEchoService_EchoPreview", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbVisibilityRuleMessageInPreviewMethod" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "query", "required": false, "type": "string" }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "status.internalField", "in": "query", "required": false, "type": "string" }, { "name": "status.previewField", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "no.internalField", "in": "query", "required": false, "type": "string" }, { "name": "no.previewField", "in": "query", "required": false, "type": "string" }, { "name": "internalField", "in": "query", "required": false, "type": "string" }, { "name": "previewField", "in": "query", "required": false, "type": "string" }, { "name": "anEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_UNSPECIFIED", "VISIBILITY_ENUM_VISIBLE", "VISIBILITY_ENUM_INTERNAL", "VISIBILITY_ENUM_PREVIEW" ], "default": "VISIBILITY_ENUM_UNSPECIFIED" }, { "name": "ahiddenDefaultEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED", "VISIBILITY_ENUM_HIDDEN_DEFAULT_VISIBLE" ], "default": "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED" } ], "tags": [ "VisibilityRuleEchoService" ] } }, "/v1/example/internal/echo/{id}": { "post": { "summary": "Echo method receives a simple message and returns it.\nIt should not be visible in the open API output.", "operationId": "VisibilityRuleInternalEchoService_Echo", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbVisibilityRuleSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "path", "required": true, "type": "string" }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "status.internalField", "in": "query", "required": false, "type": "string" }, { "name": "status.previewField", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "no.internalField", "in": "query", "required": false, "type": "string" }, { "name": "no.previewField", "in": "query", "required": false, "type": "string" }, { "name": "internalField", "in": "query", "required": false, "type": "string" }, { "name": "previewField", "in": "query", "required": false, "type": "string" }, { "name": "anEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_UNSPECIFIED", "VISIBILITY_ENUM_VISIBLE", "VISIBILITY_ENUM_INTERNAL", "VISIBILITY_ENUM_PREVIEW" ], "default": "VISIBILITY_ENUM_UNSPECIFIED" }, { "name": "ahiddenDefaultEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED", "VISIBILITY_ENUM_HIDDEN_DEFAULT_VISIBLE" ], "default": "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED" } ], "tags": [ "VisibilityRuleInternalEchoService" ] } } }, "definitions": { "VisibilityRuleSimpleMessageVisibilityEnum": { "type": "string", "enum": [ "VISIBILITY_ENUM_UNSPECIFIED", "VISIBILITY_ENUM_VISIBLE", "VISIBILITY_ENUM_INTERNAL", "VISIBILITY_ENUM_PREVIEW" ], "default": "VISIBILITY_ENUM_UNSPECIFIED" }, "VisibilityRuleSimpleMessageVisibilityEnumHiddenDefault": { "type": "string", "enum": [ "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED", "VISIBILITY_ENUM_HIDDEN_DEFAULT_VISIBLE" ], "default": "VISIBILITY_ENUM_HIDDEN_DEFAULT_UNSPECIFIED" }, "examplepbVisibilityRuleEmbedded": { "type": "object", "properties": { "progress": { "type": "string", "format": "int64" }, "note": { "type": "string" }, "internalField": { "type": "string" }, "previewField": { "type": "string" } }, "description": "Embedded represents a message embedded in SimpleMessage." }, "examplepbVisibilityRuleEnumInPreviewMethod": { "type": "string", "enum": [ "VISIBILITY_RULE_ENUM_IN_PREVIEW_METHOD_UNSPECIFIED" ], "default": "VISIBILITY_RULE_ENUM_IN_PREVIEW_METHOD_UNSPECIFIED", "description": "EnumInPreviewMethod doesn't define its own visibility restrictions,\nbut is only included in a method marked as \"PREVIEW\", so it will only\nappear if `visibility_restriction_selectors` include \"PREVIEW\"." }, "examplepbVisibilityRuleMessageInPreviewMethod": { "type": "object", "properties": { "id": { "type": "string" }, "subMessage": { "$ref": "#/definitions/examplepbVisibilityRuleSubMessageInPreviewMethod" }, "enum": { "$ref": "#/definitions/examplepbVisibilityRuleEnumInPreviewMethod" } }, "description": "MessageInPreviewMethod doesn't define its own visibility restrictions,\nbut is only included in a method marked as \"PREVIEW\", so it will only\nappear if `visibility_restriction_selectors` include \"PREVIEW\"." }, "examplepbVisibilityRuleSimpleMessage": { "type": "object", "properties": { "id": { "type": "string", "description": "Id represents the message identifier." }, "num": { "type": "string", "format": "int64" }, "lineNum": { "type": "string", "format": "int64" }, "lang": { "type": "string" }, "status": { "$ref": "#/definitions/examplepbVisibilityRuleEmbedded" }, "en": { "type": "string", "format": "int64" }, "no": { "$ref": "#/definitions/examplepbVisibilityRuleEmbedded" }, "internalField": { "type": "string" }, "previewField": { "type": "string" }, "anEnum": { "$ref": "#/definitions/VisibilityRuleSimpleMessageVisibilityEnum" }, "ahiddenDefaultEnum": { "$ref": "#/definitions/VisibilityRuleSimpleMessageVisibilityEnumHiddenDefault" } }, "description": "SimpleMessage represents a simple message sent to the Echo service." }, "examplepbVisibilityRuleSubMessageInPreviewMethod": { "type": "object", "properties": { "id": { "type": "string" } }, "description": "SubMessageInPreviewMethod doesn't define its own visibility restrictions,\nbut is only included in a method marked as \"PREVIEW\", so it will only\nappear if `visibility_restriction_selectors` include \"PREVIEW\"." }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string" } }, "additionalProperties": {} }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } } } } ================================================ FILE: examples/internal/proto/examplepb/visibility_rule_preview_echo_service.buf.gen.yaml ================================================ version: v2 plugins: - local: protoc-gen-openapiv2 out: . opt: - visibility_restriction_selectors=PREVIEW ================================================ FILE: examples/internal/proto/examplepb/visibility_rule_preview_echo_service.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/examplepb/visibility_rule_echo_service.proto", "description": "Visibility Rule Echo Service\nSimilar to echo_service.proto but with annotations to change visibility\nof services, methods, fields and enum values.\n\n`google.api.VisibilityRule` annotations are added to customize where they are generated.\nCombined with the option `visibility_restriction_selectors` overlapping rules will appear in the OpenAPI output.\nElements without `google.api.VisibilityRule` annotations will appear as usual in the generated output.\n\nThese restrictions and selectors are completely arbitrary and you can define whatever values or hierarchies you want.\nIn this example `INTERNAL`, `PREVIEW` are used, but `INTERNAL`, `ALPHA`, `BETA`, `RELEASED`, or anything else could be used if you wish.", "version": "version not set" }, "tags": [ { "name": "VisibilityRuleEchoService" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/v1/example/echo/{id}": { "post": { "summary": "Echo method receives a simple message and returns it.\nIt should always be visible in the open API output.", "operationId": "VisibilityRuleEchoService_Echo", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbVisibilityRuleSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "path", "required": true, "type": "string" }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "status.previewField", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "no.previewField", "in": "query", "required": false, "type": "string" }, { "name": "previewField", "in": "query", "required": false, "type": "string" }, { "name": "anEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_UNSPECIFIED", "VISIBILITY_ENUM_VISIBLE", "VISIBILITY_ENUM_PREVIEW" ], "default": "VISIBILITY_ENUM_UNSPECIFIED" }, { "name": "ahiddenDefaultEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_HIDDEN_DEFAULT_VISIBLE" ] } ], "tags": [ "VisibilityRuleEchoService" ] } }, "/v1/example/echo_internal_and_preview": { "get": { "summary": "EchoInternalAndPreview is a internal and preview API that should only be visible in the OpenAPI spec\nif `visibility_restriction_selectors` includes \"PREVIEW\" or \"INTERNAL\".", "operationId": "VisibilityRuleEchoService_EchoInternalAndPreview", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbVisibilityRuleSimpleMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "query", "required": false, "type": "string" }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "status.previewField", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "no.previewField", "in": "query", "required": false, "type": "string" }, { "name": "previewField", "in": "query", "required": false, "type": "string" }, { "name": "anEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_UNSPECIFIED", "VISIBILITY_ENUM_VISIBLE", "VISIBILITY_ENUM_PREVIEW" ], "default": "VISIBILITY_ENUM_UNSPECIFIED" }, { "name": "ahiddenDefaultEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_HIDDEN_DEFAULT_VISIBLE" ] } ], "tags": [ "VisibilityRuleEchoService" ] } }, "/v1/example/echo_preview": { "get": { "summary": "EchoPreview is a preview API that should only be visible in the OpenAPI spec\nif `visibility_restriction_selectors` includes \"PREVIEW\".", "operationId": "VisibilityRuleEchoService_EchoPreview", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbVisibilityRuleMessageInPreviewMethod" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "id", "description": "Id represents the message identifier.", "in": "query", "required": false, "type": "string" }, { "name": "num", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lineNum", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "lang", "in": "query", "required": false, "type": "string" }, { "name": "status.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "status.note", "in": "query", "required": false, "type": "string" }, { "name": "status.previewField", "in": "query", "required": false, "type": "string" }, { "name": "en", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.progress", "in": "query", "required": false, "type": "string", "format": "int64" }, { "name": "no.note", "in": "query", "required": false, "type": "string" }, { "name": "no.previewField", "in": "query", "required": false, "type": "string" }, { "name": "previewField", "in": "query", "required": false, "type": "string" }, { "name": "anEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_UNSPECIFIED", "VISIBILITY_ENUM_VISIBLE", "VISIBILITY_ENUM_PREVIEW" ], "default": "VISIBILITY_ENUM_UNSPECIFIED" }, { "name": "ahiddenDefaultEnum", "in": "query", "required": false, "type": "string", "enum": [ "VISIBILITY_ENUM_HIDDEN_DEFAULT_VISIBLE" ] } ], "tags": [ "VisibilityRuleEchoService" ] } } }, "definitions": { "VisibilityRuleSimpleMessageVisibilityEnum": { "type": "string", "enum": [ "VISIBILITY_ENUM_UNSPECIFIED", "VISIBILITY_ENUM_VISIBLE", "VISIBILITY_ENUM_PREVIEW" ], "default": "VISIBILITY_ENUM_UNSPECIFIED" }, "VisibilityRuleSimpleMessageVisibilityEnumHiddenDefault": { "type": "string", "enum": [ "VISIBILITY_ENUM_HIDDEN_DEFAULT_VISIBLE" ] }, "examplepbVisibilityRuleEmbedded": { "type": "object", "properties": { "progress": { "type": "string", "format": "int64" }, "note": { "type": "string" }, "previewField": { "type": "string" } }, "description": "Embedded represents a message embedded in SimpleMessage." }, "examplepbVisibilityRuleEnumInPreviewMethod": { "type": "string", "enum": [ "VISIBILITY_RULE_ENUM_IN_PREVIEW_METHOD_UNSPECIFIED" ], "default": "VISIBILITY_RULE_ENUM_IN_PREVIEW_METHOD_UNSPECIFIED", "description": "EnumInPreviewMethod doesn't define its own visibility restrictions,\nbut is only included in a method marked as \"PREVIEW\", so it will only\nappear if `visibility_restriction_selectors` include \"PREVIEW\"." }, "examplepbVisibilityRuleMessageInPreviewMethod": { "type": "object", "properties": { "id": { "type": "string" }, "subMessage": { "$ref": "#/definitions/examplepbVisibilityRuleSubMessageInPreviewMethod" }, "enum": { "$ref": "#/definitions/examplepbVisibilityRuleEnumInPreviewMethod" } }, "description": "MessageInPreviewMethod doesn't define its own visibility restrictions,\nbut is only included in a method marked as \"PREVIEW\", so it will only\nappear if `visibility_restriction_selectors` include \"PREVIEW\"." }, "examplepbVisibilityRuleSimpleMessage": { "type": "object", "properties": { "id": { "type": "string", "description": "Id represents the message identifier." }, "num": { "type": "string", "format": "int64" }, "lineNum": { "type": "string", "format": "int64" }, "lang": { "type": "string" }, "status": { "$ref": "#/definitions/examplepbVisibilityRuleEmbedded" }, "en": { "type": "string", "format": "int64" }, "no": { "$ref": "#/definitions/examplepbVisibilityRuleEmbedded" }, "previewField": { "type": "string" }, "anEnum": { "$ref": "#/definitions/VisibilityRuleSimpleMessageVisibilityEnum" }, "ahiddenDefaultEnum": { "$ref": "#/definitions/VisibilityRuleSimpleMessageVisibilityEnumHiddenDefault" } }, "description": "SimpleMessage represents a simple message sent to the Echo service." }, "examplepbVisibilityRuleSubMessageInPreviewMethod": { "type": "object", "properties": { "id": { "type": "string" } }, "description": "SubMessageInPreviewMethod doesn't define its own visibility restrictions,\nbut is only included in a method marked as \"PREVIEW\", so it will only\nappear if `visibility_restriction_selectors` include \"PREVIEW\"." }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string" } }, "additionalProperties": {} }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } } } } ================================================ FILE: examples/internal/proto/examplepb/wrappers.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/examplepb/wrappers.proto package examplepb import ( _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" emptypb "google.golang.org/protobuf/types/known/emptypb" wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) type Wrappers struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields StringValue *wrapperspb.StringValue `protobuf:"bytes,1,opt,name=string_value,json=stringValue,proto3" json:"string_value,omitempty"` Int32Value *wrapperspb.Int32Value `protobuf:"bytes,2,opt,name=int32_value,json=int32Value,proto3" json:"int32_value,omitempty"` Int64Value *wrapperspb.Int64Value `protobuf:"bytes,3,opt,name=int64_value,json=int64Value,proto3" json:"int64_value,omitempty"` FloatValue *wrapperspb.FloatValue `protobuf:"bytes,4,opt,name=float_value,json=floatValue,proto3" json:"float_value,omitempty"` DoubleValue *wrapperspb.DoubleValue `protobuf:"bytes,5,opt,name=double_value,json=doubleValue,proto3" json:"double_value,omitempty"` BoolValue *wrapperspb.BoolValue `protobuf:"bytes,6,opt,name=bool_value,json=boolValue,proto3" json:"bool_value,omitempty"` Uint32Value *wrapperspb.UInt32Value `protobuf:"bytes,7,opt,name=uint32_value,json=uint32Value,proto3" json:"uint32_value,omitempty"` Uint64Value *wrapperspb.UInt64Value `protobuf:"bytes,8,opt,name=uint64_value,json=uint64Value,proto3" json:"uint64_value,omitempty"` BytesValue *wrapperspb.BytesValue `protobuf:"bytes,9,opt,name=bytes_value,json=bytesValue,proto3" json:"bytes_value,omitempty"` } func (x *Wrappers) Reset() { *x = Wrappers{} mi := &file_examples_internal_proto_examplepb_wrappers_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Wrappers) String() string { return protoimpl.X.MessageStringOf(x) } func (*Wrappers) ProtoMessage() {} func (x *Wrappers) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_examplepb_wrappers_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Wrappers.ProtoReflect.Descriptor instead. func (*Wrappers) Descriptor() ([]byte, []int) { return file_examples_internal_proto_examplepb_wrappers_proto_rawDescGZIP(), []int{0} } func (x *Wrappers) GetStringValue() *wrapperspb.StringValue { if x != nil { return x.StringValue } return nil } func (x *Wrappers) GetInt32Value() *wrapperspb.Int32Value { if x != nil { return x.Int32Value } return nil } func (x *Wrappers) GetInt64Value() *wrapperspb.Int64Value { if x != nil { return x.Int64Value } return nil } func (x *Wrappers) GetFloatValue() *wrapperspb.FloatValue { if x != nil { return x.FloatValue } return nil } func (x *Wrappers) GetDoubleValue() *wrapperspb.DoubleValue { if x != nil { return x.DoubleValue } return nil } func (x *Wrappers) GetBoolValue() *wrapperspb.BoolValue { if x != nil { return x.BoolValue } return nil } func (x *Wrappers) GetUint32Value() *wrapperspb.UInt32Value { if x != nil { return x.Uint32Value } return nil } func (x *Wrappers) GetUint64Value() *wrapperspb.UInt64Value { if x != nil { return x.Uint64Value } return nil } func (x *Wrappers) GetBytesValue() *wrapperspb.BytesValue { if x != nil { return x.BytesValue } return nil } var File_examples_internal_proto_examplepb_wrappers_proto protoreflect.FileDescriptor var file_examples_internal_proto_examplepb_wrappers_proto_rawDesc = []byte{ 0x0a, 0x30, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc1, 0x04, 0x0a, 0x08, 0x57, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x12, 0x3f, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3f, 0x0a, 0x0c, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0b, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x39, 0x0a, 0x0a, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3f, 0x0a, 0x0c, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0b, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3f, 0x0a, 0x0c, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0b, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x42, 0x79, 0x74, 0x65, 0x73, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x62, 0x79, 0x74, 0x65, 0x73, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x32, 0xbe, 0x09, 0x0a, 0x0f, 0x57, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x9d, 0x01, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x38, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x57, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x1a, 0x38, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x57, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x22, 0x1f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x3a, 0x01, 0x2a, 0x22, 0x14, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x12, 0x6a, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x3a, 0x01, 0x2a, 0x22, 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x66, 0x0a, 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x3a, 0x01, 0x2a, 0x22, 0x0d, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x12, 0x66, 0x0a, 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x3a, 0x01, 0x2a, 0x22, 0x0d, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x12, 0x66, 0x0a, 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x3a, 0x01, 0x2a, 0x22, 0x0d, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x12, 0x6a, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x3a, 0x01, 0x2a, 0x22, 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x12, 0x62, 0x0a, 0x0f, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x17, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x3a, 0x01, 0x2a, 0x22, 0x0c, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6c, 0x12, 0x6a, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x3a, 0x01, 0x2a, 0x22, 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x55, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x12, 0x6a, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x3a, 0x01, 0x2a, 0x22, 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x55, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x12, 0x66, 0x0a, 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x79, 0x74, 0x65, 0x73, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x42, 0x79, 0x74, 0x65, 0x73, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x42, 0x79, 0x74, 0x65, 0x73, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x3a, 0x01, 0x2a, 0x22, 0x0d, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x57, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x3a, 0x01, 0x2a, 0x22, 0x0d, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_examplepb_wrappers_proto_rawDescOnce sync.Once file_examples_internal_proto_examplepb_wrappers_proto_rawDescData = file_examples_internal_proto_examplepb_wrappers_proto_rawDesc ) func file_examples_internal_proto_examplepb_wrappers_proto_rawDescGZIP() []byte { file_examples_internal_proto_examplepb_wrappers_proto_rawDescOnce.Do(func() { file_examples_internal_proto_examplepb_wrappers_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_examplepb_wrappers_proto_rawDescData) }) return file_examples_internal_proto_examplepb_wrappers_proto_rawDescData } var file_examples_internal_proto_examplepb_wrappers_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_examples_internal_proto_examplepb_wrappers_proto_goTypes = []any{ (*Wrappers)(nil), // 0: grpc.gateway.examples.internal.proto.examplepb.Wrappers (*wrapperspb.StringValue)(nil), // 1: google.protobuf.StringValue (*wrapperspb.Int32Value)(nil), // 2: google.protobuf.Int32Value (*wrapperspb.Int64Value)(nil), // 3: google.protobuf.Int64Value (*wrapperspb.FloatValue)(nil), // 4: google.protobuf.FloatValue (*wrapperspb.DoubleValue)(nil), // 5: google.protobuf.DoubleValue (*wrapperspb.BoolValue)(nil), // 6: google.protobuf.BoolValue (*wrapperspb.UInt32Value)(nil), // 7: google.protobuf.UInt32Value (*wrapperspb.UInt64Value)(nil), // 8: google.protobuf.UInt64Value (*wrapperspb.BytesValue)(nil), // 9: google.protobuf.BytesValue (*emptypb.Empty)(nil), // 10: google.protobuf.Empty } var file_examples_internal_proto_examplepb_wrappers_proto_depIdxs = []int32{ 1, // 0: grpc.gateway.examples.internal.proto.examplepb.Wrappers.string_value:type_name -> google.protobuf.StringValue 2, // 1: grpc.gateway.examples.internal.proto.examplepb.Wrappers.int32_value:type_name -> google.protobuf.Int32Value 3, // 2: grpc.gateway.examples.internal.proto.examplepb.Wrappers.int64_value:type_name -> google.protobuf.Int64Value 4, // 3: grpc.gateway.examples.internal.proto.examplepb.Wrappers.float_value:type_name -> google.protobuf.FloatValue 5, // 4: grpc.gateway.examples.internal.proto.examplepb.Wrappers.double_value:type_name -> google.protobuf.DoubleValue 6, // 5: grpc.gateway.examples.internal.proto.examplepb.Wrappers.bool_value:type_name -> google.protobuf.BoolValue 7, // 6: grpc.gateway.examples.internal.proto.examplepb.Wrappers.uint32_value:type_name -> google.protobuf.UInt32Value 8, // 7: grpc.gateway.examples.internal.proto.examplepb.Wrappers.uint64_value:type_name -> google.protobuf.UInt64Value 9, // 8: grpc.gateway.examples.internal.proto.examplepb.Wrappers.bytes_value:type_name -> google.protobuf.BytesValue 0, // 9: grpc.gateway.examples.internal.proto.examplepb.WrappersService.Create:input_type -> grpc.gateway.examples.internal.proto.examplepb.Wrappers 1, // 10: grpc.gateway.examples.internal.proto.examplepb.WrappersService.CreateStringValue:input_type -> google.protobuf.StringValue 2, // 11: grpc.gateway.examples.internal.proto.examplepb.WrappersService.CreateInt32Value:input_type -> google.protobuf.Int32Value 3, // 12: grpc.gateway.examples.internal.proto.examplepb.WrappersService.CreateInt64Value:input_type -> google.protobuf.Int64Value 4, // 13: grpc.gateway.examples.internal.proto.examplepb.WrappersService.CreateFloatValue:input_type -> google.protobuf.FloatValue 5, // 14: grpc.gateway.examples.internal.proto.examplepb.WrappersService.CreateDoubleValue:input_type -> google.protobuf.DoubleValue 6, // 15: grpc.gateway.examples.internal.proto.examplepb.WrappersService.CreateBoolValue:input_type -> google.protobuf.BoolValue 7, // 16: grpc.gateway.examples.internal.proto.examplepb.WrappersService.CreateUInt32Value:input_type -> google.protobuf.UInt32Value 8, // 17: grpc.gateway.examples.internal.proto.examplepb.WrappersService.CreateUInt64Value:input_type -> google.protobuf.UInt64Value 9, // 18: grpc.gateway.examples.internal.proto.examplepb.WrappersService.CreateBytesValue:input_type -> google.protobuf.BytesValue 10, // 19: grpc.gateway.examples.internal.proto.examplepb.WrappersService.CreateEmpty:input_type -> google.protobuf.Empty 0, // 20: grpc.gateway.examples.internal.proto.examplepb.WrappersService.Create:output_type -> grpc.gateway.examples.internal.proto.examplepb.Wrappers 1, // 21: grpc.gateway.examples.internal.proto.examplepb.WrappersService.CreateStringValue:output_type -> google.protobuf.StringValue 2, // 22: grpc.gateway.examples.internal.proto.examplepb.WrappersService.CreateInt32Value:output_type -> google.protobuf.Int32Value 3, // 23: grpc.gateway.examples.internal.proto.examplepb.WrappersService.CreateInt64Value:output_type -> google.protobuf.Int64Value 4, // 24: grpc.gateway.examples.internal.proto.examplepb.WrappersService.CreateFloatValue:output_type -> google.protobuf.FloatValue 5, // 25: grpc.gateway.examples.internal.proto.examplepb.WrappersService.CreateDoubleValue:output_type -> google.protobuf.DoubleValue 6, // 26: grpc.gateway.examples.internal.proto.examplepb.WrappersService.CreateBoolValue:output_type -> google.protobuf.BoolValue 7, // 27: grpc.gateway.examples.internal.proto.examplepb.WrappersService.CreateUInt32Value:output_type -> google.protobuf.UInt32Value 8, // 28: grpc.gateway.examples.internal.proto.examplepb.WrappersService.CreateUInt64Value:output_type -> google.protobuf.UInt64Value 9, // 29: grpc.gateway.examples.internal.proto.examplepb.WrappersService.CreateBytesValue:output_type -> google.protobuf.BytesValue 10, // 30: grpc.gateway.examples.internal.proto.examplepb.WrappersService.CreateEmpty:output_type -> google.protobuf.Empty 20, // [20:31] is the sub-list for method output_type 9, // [9:20] is the sub-list for method input_type 9, // [9:9] is the sub-list for extension type_name 9, // [9:9] is the sub-list for extension extendee 0, // [0:9] is the sub-list for field type_name } func init() { file_examples_internal_proto_examplepb_wrappers_proto_init() } func file_examples_internal_proto_examplepb_wrappers_proto_init() { if File_examples_internal_proto_examplepb_wrappers_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_examplepb_wrappers_proto_rawDesc, NumEnums: 0, NumMessages: 1, NumExtensions: 0, NumServices: 1, }, GoTypes: file_examples_internal_proto_examplepb_wrappers_proto_goTypes, DependencyIndexes: file_examples_internal_proto_examplepb_wrappers_proto_depIdxs, MessageInfos: file_examples_internal_proto_examplepb_wrappers_proto_msgTypes, }.Build() File_examples_internal_proto_examplepb_wrappers_proto = out.File file_examples_internal_proto_examplepb_wrappers_proto_rawDesc = nil file_examples_internal_proto_examplepb_wrappers_proto_goTypes = nil file_examples_internal_proto_examplepb_wrappers_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/examplepb/wrappers.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/proto/examplepb/wrappers.proto /* Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package examplepb import ( "context" "errors" "io" "net/http" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/emptypb" "google.golang.org/protobuf/types/known/wrapperspb" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) func request_WrappersService_Create_0(ctx context.Context, marshaler runtime.Marshaler, client WrappersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq Wrappers metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.Create(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_WrappersService_Create_0(ctx context.Context, marshaler runtime.Marshaler, server WrappersServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq Wrappers metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Create(ctx, &protoReq) return msg, metadata, err } func request_WrappersService_CreateStringValue_0(ctx context.Context, marshaler runtime.Marshaler, client WrappersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq wrapperspb.StringValue metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.CreateStringValue(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_WrappersService_CreateStringValue_0(ctx context.Context, marshaler runtime.Marshaler, server WrappersServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq wrapperspb.StringValue metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CreateStringValue(ctx, &protoReq) return msg, metadata, err } func request_WrappersService_CreateInt32Value_0(ctx context.Context, marshaler runtime.Marshaler, client WrappersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq wrapperspb.Int32Value metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.CreateInt32Value(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_WrappersService_CreateInt32Value_0(ctx context.Context, marshaler runtime.Marshaler, server WrappersServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq wrapperspb.Int32Value metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CreateInt32Value(ctx, &protoReq) return msg, metadata, err } func request_WrappersService_CreateInt64Value_0(ctx context.Context, marshaler runtime.Marshaler, client WrappersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq wrapperspb.Int64Value metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.CreateInt64Value(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_WrappersService_CreateInt64Value_0(ctx context.Context, marshaler runtime.Marshaler, server WrappersServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq wrapperspb.Int64Value metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CreateInt64Value(ctx, &protoReq) return msg, metadata, err } func request_WrappersService_CreateFloatValue_0(ctx context.Context, marshaler runtime.Marshaler, client WrappersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq wrapperspb.FloatValue metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.CreateFloatValue(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_WrappersService_CreateFloatValue_0(ctx context.Context, marshaler runtime.Marshaler, server WrappersServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq wrapperspb.FloatValue metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CreateFloatValue(ctx, &protoReq) return msg, metadata, err } func request_WrappersService_CreateDoubleValue_0(ctx context.Context, marshaler runtime.Marshaler, client WrappersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq wrapperspb.DoubleValue metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.CreateDoubleValue(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_WrappersService_CreateDoubleValue_0(ctx context.Context, marshaler runtime.Marshaler, server WrappersServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq wrapperspb.DoubleValue metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CreateDoubleValue(ctx, &protoReq) return msg, metadata, err } func request_WrappersService_CreateBoolValue_0(ctx context.Context, marshaler runtime.Marshaler, client WrappersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq wrapperspb.BoolValue metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.CreateBoolValue(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_WrappersService_CreateBoolValue_0(ctx context.Context, marshaler runtime.Marshaler, server WrappersServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq wrapperspb.BoolValue metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CreateBoolValue(ctx, &protoReq) return msg, metadata, err } func request_WrappersService_CreateUInt32Value_0(ctx context.Context, marshaler runtime.Marshaler, client WrappersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq wrapperspb.UInt32Value metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.CreateUInt32Value(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_WrappersService_CreateUInt32Value_0(ctx context.Context, marshaler runtime.Marshaler, server WrappersServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq wrapperspb.UInt32Value metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CreateUInt32Value(ctx, &protoReq) return msg, metadata, err } func request_WrappersService_CreateUInt64Value_0(ctx context.Context, marshaler runtime.Marshaler, client WrappersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq wrapperspb.UInt64Value metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.CreateUInt64Value(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_WrappersService_CreateUInt64Value_0(ctx context.Context, marshaler runtime.Marshaler, server WrappersServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq wrapperspb.UInt64Value metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CreateUInt64Value(ctx, &protoReq) return msg, metadata, err } func request_WrappersService_CreateBytesValue_0(ctx context.Context, marshaler runtime.Marshaler, client WrappersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq wrapperspb.BytesValue metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.CreateBytesValue(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_WrappersService_CreateBytesValue_0(ctx context.Context, marshaler runtime.Marshaler, server WrappersServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq wrapperspb.BytesValue metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CreateBytesValue(ctx, &protoReq) return msg, metadata, err } func request_WrappersService_CreateEmpty_0(ctx context.Context, marshaler runtime.Marshaler, client WrappersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq emptypb.Empty metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.CreateEmpty(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_WrappersService_CreateEmpty_0(ctx context.Context, marshaler runtime.Marshaler, server WrappersServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq emptypb.Empty metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CreateEmpty(ctx, &protoReq) return msg, metadata, err } // RegisterWrappersServiceHandlerServer registers the http handlers for service WrappersService to "mux". // UnaryRPC :call WrappersServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterWrappersServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterWrappersServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server WrappersServiceServer) error { mux.Handle(http.MethodPost, pattern_WrappersService_Create_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/Create", runtime.WithHTTPPathPattern("/v1/example/wrappers")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_WrappersService_Create_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_Create_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_WrappersService_CreateStringValue_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateStringValue", runtime.WithHTTPPathPattern("/v1/testString")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_WrappersService_CreateStringValue_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_CreateStringValue_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_WrappersService_CreateInt32Value_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateInt32Value", runtime.WithHTTPPathPattern("/v1/testInt32")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_WrappersService_CreateInt32Value_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_CreateInt32Value_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_WrappersService_CreateInt64Value_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateInt64Value", runtime.WithHTTPPathPattern("/v1/testInt64")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_WrappersService_CreateInt64Value_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_CreateInt64Value_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_WrappersService_CreateFloatValue_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateFloatValue", runtime.WithHTTPPathPattern("/v1/testFloat")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_WrappersService_CreateFloatValue_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_CreateFloatValue_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_WrappersService_CreateDoubleValue_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateDoubleValue", runtime.WithHTTPPathPattern("/v1/testDouble")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_WrappersService_CreateDoubleValue_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_CreateDoubleValue_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_WrappersService_CreateBoolValue_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateBoolValue", runtime.WithHTTPPathPattern("/v1/testBool")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_WrappersService_CreateBoolValue_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_CreateBoolValue_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_WrappersService_CreateUInt32Value_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateUInt32Value", runtime.WithHTTPPathPattern("/v1/testUint32")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_WrappersService_CreateUInt32Value_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_CreateUInt32Value_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_WrappersService_CreateUInt64Value_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateUInt64Value", runtime.WithHTTPPathPattern("/v1/testUint64")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_WrappersService_CreateUInt64Value_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_CreateUInt64Value_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_WrappersService_CreateBytesValue_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateBytesValue", runtime.WithHTTPPathPattern("/v1/testBytes")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_WrappersService_CreateBytesValue_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_CreateBytesValue_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_WrappersService_CreateEmpty_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateEmpty", runtime.WithHTTPPathPattern("/v1/testEmpty")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_WrappersService_CreateEmpty_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_CreateEmpty_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } // RegisterWrappersServiceHandlerFromEndpoint is same as RegisterWrappersServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterWrappersServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterWrappersServiceHandler(ctx, mux, conn) } // RegisterWrappersServiceHandler registers the http handlers for service WrappersService to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterWrappersServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterWrappersServiceHandlerClient(ctx, mux, NewWrappersServiceClient(conn)) } // RegisterWrappersServiceHandlerClient registers the http handlers for service WrappersService // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "WrappersServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "WrappersServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "WrappersServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterWrappersServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client WrappersServiceClient) error { mux.Handle(http.MethodPost, pattern_WrappersService_Create_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/Create", runtime.WithHTTPPathPattern("/v1/example/wrappers")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_WrappersService_Create_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_Create_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_WrappersService_CreateStringValue_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateStringValue", runtime.WithHTTPPathPattern("/v1/testString")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_WrappersService_CreateStringValue_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_CreateStringValue_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_WrappersService_CreateInt32Value_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateInt32Value", runtime.WithHTTPPathPattern("/v1/testInt32")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_WrappersService_CreateInt32Value_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_CreateInt32Value_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_WrappersService_CreateInt64Value_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateInt64Value", runtime.WithHTTPPathPattern("/v1/testInt64")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_WrappersService_CreateInt64Value_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_CreateInt64Value_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_WrappersService_CreateFloatValue_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateFloatValue", runtime.WithHTTPPathPattern("/v1/testFloat")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_WrappersService_CreateFloatValue_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_CreateFloatValue_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_WrappersService_CreateDoubleValue_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateDoubleValue", runtime.WithHTTPPathPattern("/v1/testDouble")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_WrappersService_CreateDoubleValue_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_CreateDoubleValue_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_WrappersService_CreateBoolValue_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateBoolValue", runtime.WithHTTPPathPattern("/v1/testBool")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_WrappersService_CreateBoolValue_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_CreateBoolValue_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_WrappersService_CreateUInt32Value_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateUInt32Value", runtime.WithHTTPPathPattern("/v1/testUint32")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_WrappersService_CreateUInt32Value_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_CreateUInt32Value_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_WrappersService_CreateUInt64Value_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateUInt64Value", runtime.WithHTTPPathPattern("/v1/testUint64")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_WrappersService_CreateUInt64Value_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_CreateUInt64Value_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_WrappersService_CreateBytesValue_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateBytesValue", runtime.WithHTTPPathPattern("/v1/testBytes")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_WrappersService_CreateBytesValue_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_CreateBytesValue_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_WrappersService_CreateEmpty_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateEmpty", runtime.WithHTTPPathPattern("/v1/testEmpty")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_WrappersService_CreateEmpty_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_WrappersService_CreateEmpty_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( pattern_WrappersService_Create_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "wrappers"}, "")) pattern_WrappersService_CreateStringValue_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "testString"}, "")) pattern_WrappersService_CreateInt32Value_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "testInt32"}, "")) pattern_WrappersService_CreateInt64Value_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "testInt64"}, "")) pattern_WrappersService_CreateFloatValue_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "testFloat"}, "")) pattern_WrappersService_CreateDoubleValue_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "testDouble"}, "")) pattern_WrappersService_CreateBoolValue_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "testBool"}, "")) pattern_WrappersService_CreateUInt32Value_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "testUint32"}, "")) pattern_WrappersService_CreateUInt64Value_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "testUint64"}, "")) pattern_WrappersService_CreateBytesValue_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "testBytes"}, "")) pattern_WrappersService_CreateEmpty_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "testEmpty"}, "")) ) var ( forward_WrappersService_Create_0 = runtime.ForwardResponseMessage forward_WrappersService_CreateStringValue_0 = runtime.ForwardResponseMessage forward_WrappersService_CreateInt32Value_0 = runtime.ForwardResponseMessage forward_WrappersService_CreateInt64Value_0 = runtime.ForwardResponseMessage forward_WrappersService_CreateFloatValue_0 = runtime.ForwardResponseMessage forward_WrappersService_CreateDoubleValue_0 = runtime.ForwardResponseMessage forward_WrappersService_CreateBoolValue_0 = runtime.ForwardResponseMessage forward_WrappersService_CreateUInt32Value_0 = runtime.ForwardResponseMessage forward_WrappersService_CreateUInt64Value_0 = runtime.ForwardResponseMessage forward_WrappersService_CreateBytesValue_0 = runtime.ForwardResponseMessage forward_WrappersService_CreateEmpty_0 = runtime.ForwardResponseMessage ) ================================================ FILE: examples/internal/proto/examplepb/wrappers.proto ================================================ syntax = "proto3"; package grpc.gateway.examples.internal.proto.examplepb; import "google/api/annotations.proto"; import "google/protobuf/empty.proto"; import "google/protobuf/wrappers.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; message Wrappers { google.protobuf.StringValue string_value = 1; google.protobuf.Int32Value int32_value = 2; google.protobuf.Int64Value int64_value = 3; google.protobuf.FloatValue float_value = 4; google.protobuf.DoubleValue double_value = 5; google.protobuf.BoolValue bool_value = 6; google.protobuf.UInt32Value uint32_value = 7; google.protobuf.UInt64Value uint64_value = 8; google.protobuf.BytesValue bytes_value = 9; } service WrappersService { rpc Create(Wrappers) returns (Wrappers) { option (google.api.http) = { post: "/v1/example/wrappers" body: "*" }; } rpc CreateStringValue(google.protobuf.StringValue) returns (google.protobuf.StringValue) { option (google.api.http) = { post: "/v1/testString" body: "*" }; } rpc CreateInt32Value(google.protobuf.Int32Value) returns (google.protobuf.Int32Value) { option (google.api.http) = { post: "/v1/testInt32" body: "*" }; } rpc CreateInt64Value(google.protobuf.Int64Value) returns (google.protobuf.Int64Value) { option (google.api.http) = { post: "/v1/testInt64" body: "*" }; } rpc CreateFloatValue(google.protobuf.FloatValue) returns (google.protobuf.FloatValue) { option (google.api.http) = { post: "/v1/testFloat" body: "*" }; } rpc CreateDoubleValue(google.protobuf.DoubleValue) returns (google.protobuf.DoubleValue) { option (google.api.http) = { post: "/v1/testDouble" body: "*" }; } rpc CreateBoolValue(google.protobuf.BoolValue) returns (google.protobuf.BoolValue) { option (google.api.http) = { post: "/v1/testBool" body: "*" }; } rpc CreateUInt32Value(google.protobuf.UInt32Value) returns (google.protobuf.UInt32Value) { option (google.api.http) = { post: "/v1/testUint32" body: "*" }; } rpc CreateUInt64Value(google.protobuf.UInt64Value) returns (google.protobuf.UInt64Value) { option (google.api.http) = { post: "/v1/testUint64" body: "*" }; } rpc CreateBytesValue(google.protobuf.BytesValue) returns (google.protobuf.BytesValue) { option (google.api.http) = { post: "/v1/testBytes" body: "*" }; } rpc CreateEmpty(google.protobuf.Empty) returns (google.protobuf.Empty) { option (google.api.http) = { post: "/v1/testEmpty" body: "*" }; } } ================================================ FILE: examples/internal/proto/examplepb/wrappers.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/examplepb/wrappers.proto", "version": "version not set" }, "tags": [ { "name": "WrappersService" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/v1/example/wrappers": { "post": { "operationId": "WrappersService_Create", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbWrappers" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbWrappers" } } ], "tags": [ "WrappersService" ] } }, "/v1/testBool": { "post": { "operationId": "WrappersService_CreateBoolValue", "responses": { "200": { "description": "A successful response.", "schema": { "type": "boolean" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "type": "boolean" } } ], "tags": [ "WrappersService" ] } }, "/v1/testBytes": { "post": { "operationId": "WrappersService_CreateBytesValue", "responses": { "200": { "description": "A successful response.", "schema": { "type": "string", "format": "byte" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "type": "string", "format": "byte" } } ], "tags": [ "WrappersService" ] } }, "/v1/testDouble": { "post": { "operationId": "WrappersService_CreateDoubleValue", "responses": { "200": { "description": "A successful response.", "schema": { "type": "number", "format": "double" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "type": "number", "format": "double" } } ], "tags": [ "WrappersService" ] } }, "/v1/testEmpty": { "post": { "operationId": "WrappersService_CreateEmpty", "responses": { "200": { "description": "A successful response.", "schema": { "type": "object", "properties": {} } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "type": "object", "properties": {} } } ], "tags": [ "WrappersService" ] } }, "/v1/testFloat": { "post": { "operationId": "WrappersService_CreateFloatValue", "responses": { "200": { "description": "A successful response.", "schema": { "type": "number", "format": "float" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "type": "number", "format": "float" } } ], "tags": [ "WrappersService" ] } }, "/v1/testInt32": { "post": { "operationId": "WrappersService_CreateInt32Value", "responses": { "200": { "description": "A successful response.", "schema": { "type": "integer", "format": "int32" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "type": "integer", "format": "int32" } } ], "tags": [ "WrappersService" ] } }, "/v1/testInt64": { "post": { "operationId": "WrappersService_CreateInt64Value", "responses": { "200": { "description": "A successful response.", "schema": { "type": "string", "format": "int64" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "type": "string", "format": "int64" } } ], "tags": [ "WrappersService" ] } }, "/v1/testString": { "post": { "operationId": "WrappersService_CreateStringValue", "responses": { "200": { "description": "A successful response.", "schema": { "type": "string" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "type": "string" } } ], "tags": [ "WrappersService" ] } }, "/v1/testUint32": { "post": { "operationId": "WrappersService_CreateUInt32Value", "responses": { "200": { "description": "A successful response.", "schema": { "type": "integer", "format": "int64" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "type": "integer", "format": "int64" } } ], "tags": [ "WrappersService" ] } }, "/v1/testUint64": { "post": { "operationId": "WrappersService_CreateUInt64Value", "responses": { "200": { "description": "A successful response.", "schema": { "type": "string", "format": "uint64" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/googleRpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "type": "string", "format": "uint64" } } ], "tags": [ "WrappersService" ] } } }, "definitions": { "examplepbWrappers": { "type": "object", "properties": { "stringValue": { "type": "string" }, "int32Value": { "type": "integer", "format": "int32" }, "int64Value": { "type": "string", "format": "int64" }, "floatValue": { "type": "number", "format": "float" }, "doubleValue": { "type": "number", "format": "double" }, "boolValue": { "type": "boolean" }, "uint32Value": { "type": "integer", "format": "int64" }, "uint64Value": { "type": "string", "format": "uint64" }, "bytesValue": { "type": "string", "format": "byte" } } }, "googleRpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32", "description": "The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]." }, "message": { "type": "string", "description": "A developer-facing error message, which should be in English. Any\nuser-facing error message should be localized and sent in the\n[google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client." }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" }, "description": "A list of messages that carry the error details. There is a common set of\nmessage types for APIs to use." } }, "description": "The `Status` type defines a logical error model that is suitable for\ndifferent programming environments, including REST APIs and RPC APIs. It is\nused by [gRPC](https://github.com/grpc). Each `Status` message contains\nthree pieces of data: error code, error message, and error details.\n\nYou can find out more about this error model and how to work with it in the\n[API Design Guide](https://cloud.google.com/apis/design/errors)." }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string", "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics." } }, "additionalProperties": {}, "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }" } } } ================================================ FILE: examples/internal/proto/examplepb/wrappers_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: examples/internal/proto/examplepb/wrappers.proto package examplepb import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" emptypb "google.golang.org/protobuf/types/known/emptypb" wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( WrappersService_Create_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/Create" WrappersService_CreateStringValue_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateStringValue" WrappersService_CreateInt32Value_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateInt32Value" WrappersService_CreateInt64Value_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateInt64Value" WrappersService_CreateFloatValue_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateFloatValue" WrappersService_CreateDoubleValue_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateDoubleValue" WrappersService_CreateBoolValue_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateBoolValue" WrappersService_CreateUInt32Value_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateUInt32Value" WrappersService_CreateUInt64Value_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateUInt64Value" WrappersService_CreateBytesValue_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateBytesValue" WrappersService_CreateEmpty_FullMethodName = "/grpc.gateway.examples.internal.proto.examplepb.WrappersService/CreateEmpty" ) // WrappersServiceClient is the client API for WrappersService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type WrappersServiceClient interface { Create(ctx context.Context, in *Wrappers, opts ...grpc.CallOption) (*Wrappers, error) CreateStringValue(ctx context.Context, in *wrapperspb.StringValue, opts ...grpc.CallOption) (*wrapperspb.StringValue, error) CreateInt32Value(ctx context.Context, in *wrapperspb.Int32Value, opts ...grpc.CallOption) (*wrapperspb.Int32Value, error) CreateInt64Value(ctx context.Context, in *wrapperspb.Int64Value, opts ...grpc.CallOption) (*wrapperspb.Int64Value, error) CreateFloatValue(ctx context.Context, in *wrapperspb.FloatValue, opts ...grpc.CallOption) (*wrapperspb.FloatValue, error) CreateDoubleValue(ctx context.Context, in *wrapperspb.DoubleValue, opts ...grpc.CallOption) (*wrapperspb.DoubleValue, error) CreateBoolValue(ctx context.Context, in *wrapperspb.BoolValue, opts ...grpc.CallOption) (*wrapperspb.BoolValue, error) CreateUInt32Value(ctx context.Context, in *wrapperspb.UInt32Value, opts ...grpc.CallOption) (*wrapperspb.UInt32Value, error) CreateUInt64Value(ctx context.Context, in *wrapperspb.UInt64Value, opts ...grpc.CallOption) (*wrapperspb.UInt64Value, error) CreateBytesValue(ctx context.Context, in *wrapperspb.BytesValue, opts ...grpc.CallOption) (*wrapperspb.BytesValue, error) CreateEmpty(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) } type wrappersServiceClient struct { cc grpc.ClientConnInterface } func NewWrappersServiceClient(cc grpc.ClientConnInterface) WrappersServiceClient { return &wrappersServiceClient{cc} } func (c *wrappersServiceClient) Create(ctx context.Context, in *Wrappers, opts ...grpc.CallOption) (*Wrappers, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Wrappers) err := c.cc.Invoke(ctx, WrappersService_Create_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *wrappersServiceClient) CreateStringValue(ctx context.Context, in *wrapperspb.StringValue, opts ...grpc.CallOption) (*wrapperspb.StringValue, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(wrapperspb.StringValue) err := c.cc.Invoke(ctx, WrappersService_CreateStringValue_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *wrappersServiceClient) CreateInt32Value(ctx context.Context, in *wrapperspb.Int32Value, opts ...grpc.CallOption) (*wrapperspb.Int32Value, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(wrapperspb.Int32Value) err := c.cc.Invoke(ctx, WrappersService_CreateInt32Value_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *wrappersServiceClient) CreateInt64Value(ctx context.Context, in *wrapperspb.Int64Value, opts ...grpc.CallOption) (*wrapperspb.Int64Value, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(wrapperspb.Int64Value) err := c.cc.Invoke(ctx, WrappersService_CreateInt64Value_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *wrappersServiceClient) CreateFloatValue(ctx context.Context, in *wrapperspb.FloatValue, opts ...grpc.CallOption) (*wrapperspb.FloatValue, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(wrapperspb.FloatValue) err := c.cc.Invoke(ctx, WrappersService_CreateFloatValue_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *wrappersServiceClient) CreateDoubleValue(ctx context.Context, in *wrapperspb.DoubleValue, opts ...grpc.CallOption) (*wrapperspb.DoubleValue, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(wrapperspb.DoubleValue) err := c.cc.Invoke(ctx, WrappersService_CreateDoubleValue_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *wrappersServiceClient) CreateBoolValue(ctx context.Context, in *wrapperspb.BoolValue, opts ...grpc.CallOption) (*wrapperspb.BoolValue, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(wrapperspb.BoolValue) err := c.cc.Invoke(ctx, WrappersService_CreateBoolValue_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *wrappersServiceClient) CreateUInt32Value(ctx context.Context, in *wrapperspb.UInt32Value, opts ...grpc.CallOption) (*wrapperspb.UInt32Value, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(wrapperspb.UInt32Value) err := c.cc.Invoke(ctx, WrappersService_CreateUInt32Value_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *wrappersServiceClient) CreateUInt64Value(ctx context.Context, in *wrapperspb.UInt64Value, opts ...grpc.CallOption) (*wrapperspb.UInt64Value, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(wrapperspb.UInt64Value) err := c.cc.Invoke(ctx, WrappersService_CreateUInt64Value_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *wrappersServiceClient) CreateBytesValue(ctx context.Context, in *wrapperspb.BytesValue, opts ...grpc.CallOption) (*wrapperspb.BytesValue, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(wrapperspb.BytesValue) err := c.cc.Invoke(ctx, WrappersService_CreateBytesValue_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *wrappersServiceClient) CreateEmpty(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) err := c.cc.Invoke(ctx, WrappersService_CreateEmpty_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // WrappersServiceServer is the server API for WrappersService service. // All implementations should embed UnimplementedWrappersServiceServer // for forward compatibility. type WrappersServiceServer interface { Create(context.Context, *Wrappers) (*Wrappers, error) CreateStringValue(context.Context, *wrapperspb.StringValue) (*wrapperspb.StringValue, error) CreateInt32Value(context.Context, *wrapperspb.Int32Value) (*wrapperspb.Int32Value, error) CreateInt64Value(context.Context, *wrapperspb.Int64Value) (*wrapperspb.Int64Value, error) CreateFloatValue(context.Context, *wrapperspb.FloatValue) (*wrapperspb.FloatValue, error) CreateDoubleValue(context.Context, *wrapperspb.DoubleValue) (*wrapperspb.DoubleValue, error) CreateBoolValue(context.Context, *wrapperspb.BoolValue) (*wrapperspb.BoolValue, error) CreateUInt32Value(context.Context, *wrapperspb.UInt32Value) (*wrapperspb.UInt32Value, error) CreateUInt64Value(context.Context, *wrapperspb.UInt64Value) (*wrapperspb.UInt64Value, error) CreateBytesValue(context.Context, *wrapperspb.BytesValue) (*wrapperspb.BytesValue, error) CreateEmpty(context.Context, *emptypb.Empty) (*emptypb.Empty, error) } // UnimplementedWrappersServiceServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedWrappersServiceServer struct{} func (UnimplementedWrappersServiceServer) Create(context.Context, *Wrappers) (*Wrappers, error) { return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") } func (UnimplementedWrappersServiceServer) CreateStringValue(context.Context, *wrapperspb.StringValue) (*wrapperspb.StringValue, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateStringValue not implemented") } func (UnimplementedWrappersServiceServer) CreateInt32Value(context.Context, *wrapperspb.Int32Value) (*wrapperspb.Int32Value, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateInt32Value not implemented") } func (UnimplementedWrappersServiceServer) CreateInt64Value(context.Context, *wrapperspb.Int64Value) (*wrapperspb.Int64Value, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateInt64Value not implemented") } func (UnimplementedWrappersServiceServer) CreateFloatValue(context.Context, *wrapperspb.FloatValue) (*wrapperspb.FloatValue, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateFloatValue not implemented") } func (UnimplementedWrappersServiceServer) CreateDoubleValue(context.Context, *wrapperspb.DoubleValue) (*wrapperspb.DoubleValue, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateDoubleValue not implemented") } func (UnimplementedWrappersServiceServer) CreateBoolValue(context.Context, *wrapperspb.BoolValue) (*wrapperspb.BoolValue, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateBoolValue not implemented") } func (UnimplementedWrappersServiceServer) CreateUInt32Value(context.Context, *wrapperspb.UInt32Value) (*wrapperspb.UInt32Value, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateUInt32Value not implemented") } func (UnimplementedWrappersServiceServer) CreateUInt64Value(context.Context, *wrapperspb.UInt64Value) (*wrapperspb.UInt64Value, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateUInt64Value not implemented") } func (UnimplementedWrappersServiceServer) CreateBytesValue(context.Context, *wrapperspb.BytesValue) (*wrapperspb.BytesValue, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateBytesValue not implemented") } func (UnimplementedWrappersServiceServer) CreateEmpty(context.Context, *emptypb.Empty) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateEmpty not implemented") } func (UnimplementedWrappersServiceServer) testEmbeddedByValue() {} // UnsafeWrappersServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to WrappersServiceServer will // result in compilation errors. type UnsafeWrappersServiceServer interface { mustEmbedUnimplementedWrappersServiceServer() } func RegisterWrappersServiceServer(s grpc.ServiceRegistrar, srv WrappersServiceServer) { // If the following call pancis, it indicates UnimplementedWrappersServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&WrappersService_ServiceDesc, srv) } func _WrappersService_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(Wrappers) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(WrappersServiceServer).Create(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: WrappersService_Create_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(WrappersServiceServer).Create(ctx, req.(*Wrappers)) } return interceptor(ctx, in, info, handler) } func _WrappersService_CreateStringValue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(wrapperspb.StringValue) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(WrappersServiceServer).CreateStringValue(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: WrappersService_CreateStringValue_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(WrappersServiceServer).CreateStringValue(ctx, req.(*wrapperspb.StringValue)) } return interceptor(ctx, in, info, handler) } func _WrappersService_CreateInt32Value_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(wrapperspb.Int32Value) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(WrappersServiceServer).CreateInt32Value(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: WrappersService_CreateInt32Value_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(WrappersServiceServer).CreateInt32Value(ctx, req.(*wrapperspb.Int32Value)) } return interceptor(ctx, in, info, handler) } func _WrappersService_CreateInt64Value_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(wrapperspb.Int64Value) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(WrappersServiceServer).CreateInt64Value(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: WrappersService_CreateInt64Value_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(WrappersServiceServer).CreateInt64Value(ctx, req.(*wrapperspb.Int64Value)) } return interceptor(ctx, in, info, handler) } func _WrappersService_CreateFloatValue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(wrapperspb.FloatValue) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(WrappersServiceServer).CreateFloatValue(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: WrappersService_CreateFloatValue_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(WrappersServiceServer).CreateFloatValue(ctx, req.(*wrapperspb.FloatValue)) } return interceptor(ctx, in, info, handler) } func _WrappersService_CreateDoubleValue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(wrapperspb.DoubleValue) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(WrappersServiceServer).CreateDoubleValue(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: WrappersService_CreateDoubleValue_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(WrappersServiceServer).CreateDoubleValue(ctx, req.(*wrapperspb.DoubleValue)) } return interceptor(ctx, in, info, handler) } func _WrappersService_CreateBoolValue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(wrapperspb.BoolValue) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(WrappersServiceServer).CreateBoolValue(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: WrappersService_CreateBoolValue_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(WrappersServiceServer).CreateBoolValue(ctx, req.(*wrapperspb.BoolValue)) } return interceptor(ctx, in, info, handler) } func _WrappersService_CreateUInt32Value_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(wrapperspb.UInt32Value) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(WrappersServiceServer).CreateUInt32Value(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: WrappersService_CreateUInt32Value_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(WrappersServiceServer).CreateUInt32Value(ctx, req.(*wrapperspb.UInt32Value)) } return interceptor(ctx, in, info, handler) } func _WrappersService_CreateUInt64Value_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(wrapperspb.UInt64Value) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(WrappersServiceServer).CreateUInt64Value(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: WrappersService_CreateUInt64Value_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(WrappersServiceServer).CreateUInt64Value(ctx, req.(*wrapperspb.UInt64Value)) } return interceptor(ctx, in, info, handler) } func _WrappersService_CreateBytesValue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(wrapperspb.BytesValue) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(WrappersServiceServer).CreateBytesValue(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: WrappersService_CreateBytesValue_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(WrappersServiceServer).CreateBytesValue(ctx, req.(*wrapperspb.BytesValue)) } return interceptor(ctx, in, info, handler) } func _WrappersService_CreateEmpty_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(emptypb.Empty) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(WrappersServiceServer).CreateEmpty(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: WrappersService_CreateEmpty_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(WrappersServiceServer).CreateEmpty(ctx, req.(*emptypb.Empty)) } return interceptor(ctx, in, info, handler) } // WrappersService_ServiceDesc is the grpc.ServiceDesc for WrappersService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var WrappersService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.examples.internal.proto.examplepb.WrappersService", HandlerType: (*WrappersServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Create", Handler: _WrappersService_Create_Handler, }, { MethodName: "CreateStringValue", Handler: _WrappersService_CreateStringValue_Handler, }, { MethodName: "CreateInt32Value", Handler: _WrappersService_CreateInt32Value_Handler, }, { MethodName: "CreateInt64Value", Handler: _WrappersService_CreateInt64Value_Handler, }, { MethodName: "CreateFloatValue", Handler: _WrappersService_CreateFloatValue_Handler, }, { MethodName: "CreateDoubleValue", Handler: _WrappersService_CreateDoubleValue_Handler, }, { MethodName: "CreateBoolValue", Handler: _WrappersService_CreateBoolValue_Handler, }, { MethodName: "CreateUInt32Value", Handler: _WrappersService_CreateUInt32Value_Handler, }, { MethodName: "CreateUInt64Value", Handler: _WrappersService_CreateUInt64Value_Handler, }, { MethodName: "CreateBytesValue", Handler: _WrappersService_CreateBytesValue_Handler, }, { MethodName: "CreateEmpty", Handler: _WrappersService_CreateEmpty_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/internal/proto/examplepb/wrappers.proto", } ================================================ FILE: examples/internal/proto/oneofenum/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library") load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") load("@rules_proto//proto:defs.bzl", "proto_library") package(default_visibility = ["//visibility:public"]) proto_library( name = "oneofenum_proto", srcs = ["oneof_enum.proto"], ) go_proto_library( name = "oneofenum_go_proto", compilers = ["//:go_apiv2"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/oneofenum", proto = ":oneofenum_proto", ) go_library( name = "oneofenum", embed = [":oneofenum_go_proto"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/oneofenum", ) alias( name = "go_default_library", actual = ":oneofenum", visibility = ["//examples:__subpackages__"], ) ================================================ FILE: examples/internal/proto/oneofenum/oneof_enum.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/oneofenum/oneof_enum.proto package oneofenum import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) type ExampleEnum int32 const ( ExampleEnum_EXAMPLE_ENUM_UNSPECIFIED ExampleEnum = 0 ExampleEnum_EXAMPLE_ENUM_FIRST ExampleEnum = 1 ) // Enum value maps for ExampleEnum. var ( ExampleEnum_name = map[int32]string{ 0: "EXAMPLE_ENUM_UNSPECIFIED", 1: "EXAMPLE_ENUM_FIRST", } ExampleEnum_value = map[string]int32{ "EXAMPLE_ENUM_UNSPECIFIED": 0, "EXAMPLE_ENUM_FIRST": 1, } ) func (x ExampleEnum) Enum() *ExampleEnum { p := new(ExampleEnum) *p = x return p } func (x ExampleEnum) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (ExampleEnum) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_oneofenum_oneof_enum_proto_enumTypes[0].Descriptor() } func (ExampleEnum) Type() protoreflect.EnumType { return &file_examples_internal_proto_oneofenum_oneof_enum_proto_enumTypes[0] } func (x ExampleEnum) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use ExampleEnum.Descriptor instead. func (ExampleEnum) EnumDescriptor() ([]byte, []int) { return file_examples_internal_proto_oneofenum_oneof_enum_proto_rawDescGZIP(), []int{0} } type OneofEnumMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Types that are assignable to One: // // *OneofEnumMessage_ExampleEnum One isOneofEnumMessage_One `protobuf_oneof:"one"` } func (x *OneofEnumMessage) Reset() { *x = OneofEnumMessage{} mi := &file_examples_internal_proto_oneofenum_oneof_enum_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OneofEnumMessage) String() string { return protoimpl.X.MessageStringOf(x) } func (*OneofEnumMessage) ProtoMessage() {} func (x *OneofEnumMessage) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_oneofenum_oneof_enum_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use OneofEnumMessage.ProtoReflect.Descriptor instead. func (*OneofEnumMessage) Descriptor() ([]byte, []int) { return file_examples_internal_proto_oneofenum_oneof_enum_proto_rawDescGZIP(), []int{0} } func (m *OneofEnumMessage) GetOne() isOneofEnumMessage_One { if m != nil { return m.One } return nil } func (x *OneofEnumMessage) GetExampleEnum() ExampleEnum { if x, ok := x.GetOne().(*OneofEnumMessage_ExampleEnum); ok { return x.ExampleEnum } return ExampleEnum_EXAMPLE_ENUM_UNSPECIFIED } type isOneofEnumMessage_One interface { isOneofEnumMessage_One() } type OneofEnumMessage_ExampleEnum struct { ExampleEnum ExampleEnum `protobuf:"varint,1,opt,name=example_enum,json=exampleEnum,proto3,enum=grpc.gateway.examples.internal.proto.oneofenum.ExampleEnum,oneof"` } func (*OneofEnumMessage_ExampleEnum) isOneofEnumMessage_One() {} var File_examples_internal_proto_oneofenum_oneof_enum_proto protoreflect.FileDescriptor var file_examples_internal_proto_oneofenum_oneof_enum_proto_rawDesc = []byte{ 0x0a, 0x32, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x65, 0x6e, 0x75, 0x6d, 0x2f, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x65, 0x6e, 0x75, 0x6d, 0x22, 0x7b, 0x0a, 0x10, 0x4f, 0x6e, 0x65, 0x6f, 0x66, 0x45, 0x6e, 0x75, 0x6d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x60, 0x0a, 0x0c, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x65, 0x6e, 0x75, 0x6d, 0x2e, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x45, 0x6e, 0x75, 0x6d, 0x48, 0x00, 0x52, 0x0b, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x45, 0x6e, 0x75, 0x6d, 0x42, 0x05, 0x0a, 0x03, 0x6f, 0x6e, 0x65, 0x2a, 0x43, 0x0a, 0x0b, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x1c, 0x0a, 0x18, 0x45, 0x58, 0x41, 0x4d, 0x50, 0x4c, 0x45, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x45, 0x58, 0x41, 0x4d, 0x50, 0x4c, 0x45, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x46, 0x49, 0x52, 0x53, 0x54, 0x10, 0x01, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x65, 0x6e, 0x75, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_oneofenum_oneof_enum_proto_rawDescOnce sync.Once file_examples_internal_proto_oneofenum_oneof_enum_proto_rawDescData = file_examples_internal_proto_oneofenum_oneof_enum_proto_rawDesc ) func file_examples_internal_proto_oneofenum_oneof_enum_proto_rawDescGZIP() []byte { file_examples_internal_proto_oneofenum_oneof_enum_proto_rawDescOnce.Do(func() { file_examples_internal_proto_oneofenum_oneof_enum_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_oneofenum_oneof_enum_proto_rawDescData) }) return file_examples_internal_proto_oneofenum_oneof_enum_proto_rawDescData } var file_examples_internal_proto_oneofenum_oneof_enum_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_examples_internal_proto_oneofenum_oneof_enum_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_examples_internal_proto_oneofenum_oneof_enum_proto_goTypes = []any{ (ExampleEnum)(0), // 0: grpc.gateway.examples.internal.proto.oneofenum.ExampleEnum (*OneofEnumMessage)(nil), // 1: grpc.gateway.examples.internal.proto.oneofenum.OneofEnumMessage } var file_examples_internal_proto_oneofenum_oneof_enum_proto_depIdxs = []int32{ 0, // 0: grpc.gateway.examples.internal.proto.oneofenum.OneofEnumMessage.example_enum:type_name -> grpc.gateway.examples.internal.proto.oneofenum.ExampleEnum 1, // [1:1] is the sub-list for method output_type 1, // [1:1] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension extendee 0, // [0:1] is the sub-list for field type_name } func init() { file_examples_internal_proto_oneofenum_oneof_enum_proto_init() } func file_examples_internal_proto_oneofenum_oneof_enum_proto_init() { if File_examples_internal_proto_oneofenum_oneof_enum_proto != nil { return } file_examples_internal_proto_oneofenum_oneof_enum_proto_msgTypes[0].OneofWrappers = []any{ (*OneofEnumMessage_ExampleEnum)(nil), } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_oneofenum_oneof_enum_proto_rawDesc, NumEnums: 1, NumMessages: 1, NumExtensions: 0, NumServices: 0, }, GoTypes: file_examples_internal_proto_oneofenum_oneof_enum_proto_goTypes, DependencyIndexes: file_examples_internal_proto_oneofenum_oneof_enum_proto_depIdxs, EnumInfos: file_examples_internal_proto_oneofenum_oneof_enum_proto_enumTypes, MessageInfos: file_examples_internal_proto_oneofenum_oneof_enum_proto_msgTypes, }.Build() File_examples_internal_proto_oneofenum_oneof_enum_proto = out.File file_examples_internal_proto_oneofenum_oneof_enum_proto_rawDesc = nil file_examples_internal_proto_oneofenum_oneof_enum_proto_goTypes = nil file_examples_internal_proto_oneofenum_oneof_enum_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/oneofenum/oneof_enum.proto ================================================ syntax = "proto3"; package grpc.gateway.examples.internal.proto.oneofenum; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/oneofenum"; enum ExampleEnum { EXAMPLE_ENUM_UNSPECIFIED = 0; EXAMPLE_ENUM_FIRST = 1; } message OneofEnumMessage { oneof one { ExampleEnum example_enum = 1; } } ================================================ FILE: examples/internal/proto/oneofenum/oneof_enum.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/oneofenum/oneof_enum.proto", "version": "version not set" }, "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": {}, "definitions": { "protobufAny": { "type": "object", "properties": { "@type": { "type": "string" } }, "additionalProperties": {} }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } } } } ================================================ FILE: examples/internal/proto/pathenum/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library") load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") load("@rules_proto//proto:defs.bzl", "proto_library") package(default_visibility = ["//visibility:public"]) proto_library( name = "pathenum_proto", srcs = ["path_enum.proto"], ) go_proto_library( name = "pathenum_go_proto", compilers = ["//:go_apiv2"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/pathenum", proto = ":pathenum_proto", ) go_library( name = "pathenum", embed = [":pathenum_go_proto"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/pathenum", ) alias( name = "go_default_library", actual = ":pathenum", visibility = ["//examples:__subpackages__"], ) ================================================ FILE: examples/internal/proto/pathenum/path_enum.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/pathenum/path_enum.proto package pathenum import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) type PathEnum int32 const ( PathEnum_ABC PathEnum = 0 PathEnum_DEF PathEnum = 1 ) // Enum value maps for PathEnum. var ( PathEnum_name = map[int32]string{ 0: "ABC", 1: "DEF", } PathEnum_value = map[string]int32{ "ABC": 0, "DEF": 1, } ) func (x PathEnum) Enum() *PathEnum { p := new(PathEnum) *p = x return p } func (x PathEnum) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (PathEnum) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_pathenum_path_enum_proto_enumTypes[0].Descriptor() } func (PathEnum) Type() protoreflect.EnumType { return &file_examples_internal_proto_pathenum_path_enum_proto_enumTypes[0] } func (x PathEnum) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use PathEnum.Descriptor instead. func (PathEnum) EnumDescriptor() ([]byte, []int) { return file_examples_internal_proto_pathenum_path_enum_proto_rawDescGZIP(), []int{0} } // Ignoring lint warnings as this enum type exist to validate proper functionality // for projects that don't follow these lint rules. // buf:lint:ignore ENUM_PASCAL_CASE type SnakeCaseForImport int32 const ( // buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE SnakeCaseForImport_value_x SnakeCaseForImport = 0 // buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE SnakeCaseForImport_value_y SnakeCaseForImport = 1 ) // Enum value maps for SnakeCaseForImport. var ( SnakeCaseForImport_name = map[int32]string{ 0: "value_x", 1: "value_y", } SnakeCaseForImport_value = map[string]int32{ "value_x": 0, "value_y": 1, } ) func (x SnakeCaseForImport) Enum() *SnakeCaseForImport { p := new(SnakeCaseForImport) *p = x return p } func (x SnakeCaseForImport) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (SnakeCaseForImport) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_pathenum_path_enum_proto_enumTypes[1].Descriptor() } func (SnakeCaseForImport) Type() protoreflect.EnumType { return &file_examples_internal_proto_pathenum_path_enum_proto_enumTypes[1] } func (x SnakeCaseForImport) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use SnakeCaseForImport.Descriptor instead. func (SnakeCaseForImport) EnumDescriptor() ([]byte, []int) { return file_examples_internal_proto_pathenum_path_enum_proto_rawDescGZIP(), []int{1} } type MessagePathEnum_NestedPathEnum int32 const ( MessagePathEnum_GHI MessagePathEnum_NestedPathEnum = 0 MessagePathEnum_JKL MessagePathEnum_NestedPathEnum = 1 ) // Enum value maps for MessagePathEnum_NestedPathEnum. var ( MessagePathEnum_NestedPathEnum_name = map[int32]string{ 0: "GHI", 1: "JKL", } MessagePathEnum_NestedPathEnum_value = map[string]int32{ "GHI": 0, "JKL": 1, } ) func (x MessagePathEnum_NestedPathEnum) Enum() *MessagePathEnum_NestedPathEnum { p := new(MessagePathEnum_NestedPathEnum) *p = x return p } func (x MessagePathEnum_NestedPathEnum) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (MessagePathEnum_NestedPathEnum) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_pathenum_path_enum_proto_enumTypes[2].Descriptor() } func (MessagePathEnum_NestedPathEnum) Type() protoreflect.EnumType { return &file_examples_internal_proto_pathenum_path_enum_proto_enumTypes[2] } func (x MessagePathEnum_NestedPathEnum) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use MessagePathEnum_NestedPathEnum.Descriptor instead. func (MessagePathEnum_NestedPathEnum) EnumDescriptor() ([]byte, []int) { return file_examples_internal_proto_pathenum_path_enum_proto_rawDescGZIP(), []int{0, 0} } type MessagePathEnum struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields } func (x *MessagePathEnum) Reset() { *x = MessagePathEnum{} mi := &file_examples_internal_proto_pathenum_path_enum_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *MessagePathEnum) String() string { return protoimpl.X.MessageStringOf(x) } func (*MessagePathEnum) ProtoMessage() {} func (x *MessagePathEnum) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_pathenum_path_enum_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use MessagePathEnum.ProtoReflect.Descriptor instead. func (*MessagePathEnum) Descriptor() ([]byte, []int) { return file_examples_internal_proto_pathenum_path_enum_proto_rawDescGZIP(), []int{0} } type MessageWithPathEnum struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Value PathEnum `protobuf:"varint,1,opt,name=value,proto3,enum=grpc.gateway.examples.internal.pathenum.PathEnum" json:"value,omitempty"` } func (x *MessageWithPathEnum) Reset() { *x = MessageWithPathEnum{} mi := &file_examples_internal_proto_pathenum_path_enum_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *MessageWithPathEnum) String() string { return protoimpl.X.MessageStringOf(x) } func (*MessageWithPathEnum) ProtoMessage() {} func (x *MessageWithPathEnum) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_pathenum_path_enum_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use MessageWithPathEnum.ProtoReflect.Descriptor instead. func (*MessageWithPathEnum) Descriptor() ([]byte, []int) { return file_examples_internal_proto_pathenum_path_enum_proto_rawDescGZIP(), []int{1} } func (x *MessageWithPathEnum) GetValue() PathEnum { if x != nil { return x.Value } return PathEnum_ABC } type MessageWithNestedPathEnum struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Value MessagePathEnum_NestedPathEnum `protobuf:"varint,1,opt,name=value,proto3,enum=grpc.gateway.examples.internal.pathenum.MessagePathEnum_NestedPathEnum" json:"value,omitempty"` } func (x *MessageWithNestedPathEnum) Reset() { *x = MessageWithNestedPathEnum{} mi := &file_examples_internal_proto_pathenum_path_enum_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *MessageWithNestedPathEnum) String() string { return protoimpl.X.MessageStringOf(x) } func (*MessageWithNestedPathEnum) ProtoMessage() {} func (x *MessageWithNestedPathEnum) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_pathenum_path_enum_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use MessageWithNestedPathEnum.ProtoReflect.Descriptor instead. func (*MessageWithNestedPathEnum) Descriptor() ([]byte, []int) { return file_examples_internal_proto_pathenum_path_enum_proto_rawDescGZIP(), []int{2} } func (x *MessageWithNestedPathEnum) GetValue() MessagePathEnum_NestedPathEnum { if x != nil { return x.Value } return MessagePathEnum_GHI } var File_examples_internal_proto_pathenum_path_enum_proto protoreflect.FileDescriptor var file_examples_internal_proto_pathenum_path_enum_proto_rawDesc = []byte{ 0x0a, 0x30, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x65, 0x6e, 0x75, 0x6d, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x27, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x61, 0x74, 0x68, 0x65, 0x6e, 0x75, 0x6d, 0x22, 0x35, 0x0a, 0x0f, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x50, 0x61, 0x74, 0x68, 0x45, 0x6e, 0x75, 0x6d, 0x22, 0x22, 0x0a, 0x0e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x74, 0x68, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x07, 0x0a, 0x03, 0x47, 0x48, 0x49, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x4a, 0x4b, 0x4c, 0x10, 0x01, 0x22, 0x5e, 0x0a, 0x13, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x57, 0x69, 0x74, 0x68, 0x50, 0x61, 0x74, 0x68, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x47, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x31, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x61, 0x74, 0x68, 0x65, 0x6e, 0x75, 0x6d, 0x2e, 0x50, 0x61, 0x74, 0x68, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x7a, 0x0a, 0x19, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x57, 0x69, 0x74, 0x68, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x74, 0x68, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x5d, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x47, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x61, 0x74, 0x68, 0x65, 0x6e, 0x75, 0x6d, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x50, 0x61, 0x74, 0x68, 0x45, 0x6e, 0x75, 0x6d, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x50, 0x61, 0x74, 0x68, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2a, 0x1c, 0x0a, 0x08, 0x50, 0x61, 0x74, 0x68, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x42, 0x43, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x44, 0x45, 0x46, 0x10, 0x01, 0x2a, 0x31, 0x0a, 0x15, 0x73, 0x6e, 0x61, 0x6b, 0x65, 0x5f, 0x63, 0x61, 0x73, 0x65, 0x5f, 0x66, 0x6f, 0x72, 0x5f, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x0b, 0x0a, 0x07, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x78, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x79, 0x10, 0x01, 0x42, 0x4c, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x65, 0x6e, 0x75, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_pathenum_path_enum_proto_rawDescOnce sync.Once file_examples_internal_proto_pathenum_path_enum_proto_rawDescData = file_examples_internal_proto_pathenum_path_enum_proto_rawDesc ) func file_examples_internal_proto_pathenum_path_enum_proto_rawDescGZIP() []byte { file_examples_internal_proto_pathenum_path_enum_proto_rawDescOnce.Do(func() { file_examples_internal_proto_pathenum_path_enum_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_pathenum_path_enum_proto_rawDescData) }) return file_examples_internal_proto_pathenum_path_enum_proto_rawDescData } var file_examples_internal_proto_pathenum_path_enum_proto_enumTypes = make([]protoimpl.EnumInfo, 3) var file_examples_internal_proto_pathenum_path_enum_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_examples_internal_proto_pathenum_path_enum_proto_goTypes = []any{ (PathEnum)(0), // 0: grpc.gateway.examples.internal.pathenum.PathEnum (SnakeCaseForImport)(0), // 1: grpc.gateway.examples.internal.pathenum.snake_case_for_import (MessagePathEnum_NestedPathEnum)(0), // 2: grpc.gateway.examples.internal.pathenum.MessagePathEnum.NestedPathEnum (*MessagePathEnum)(nil), // 3: grpc.gateway.examples.internal.pathenum.MessagePathEnum (*MessageWithPathEnum)(nil), // 4: grpc.gateway.examples.internal.pathenum.MessageWithPathEnum (*MessageWithNestedPathEnum)(nil), // 5: grpc.gateway.examples.internal.pathenum.MessageWithNestedPathEnum } var file_examples_internal_proto_pathenum_path_enum_proto_depIdxs = []int32{ 0, // 0: grpc.gateway.examples.internal.pathenum.MessageWithPathEnum.value:type_name -> grpc.gateway.examples.internal.pathenum.PathEnum 2, // 1: grpc.gateway.examples.internal.pathenum.MessageWithNestedPathEnum.value:type_name -> grpc.gateway.examples.internal.pathenum.MessagePathEnum.NestedPathEnum 2, // [2:2] is the sub-list for method output_type 2, // [2:2] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name 2, // [2:2] is the sub-list for extension extendee 0, // [0:2] is the sub-list for field type_name } func init() { file_examples_internal_proto_pathenum_path_enum_proto_init() } func file_examples_internal_proto_pathenum_path_enum_proto_init() { if File_examples_internal_proto_pathenum_path_enum_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_pathenum_path_enum_proto_rawDesc, NumEnums: 3, NumMessages: 3, NumExtensions: 0, NumServices: 0, }, GoTypes: file_examples_internal_proto_pathenum_path_enum_proto_goTypes, DependencyIndexes: file_examples_internal_proto_pathenum_path_enum_proto_depIdxs, EnumInfos: file_examples_internal_proto_pathenum_path_enum_proto_enumTypes, MessageInfos: file_examples_internal_proto_pathenum_path_enum_proto_msgTypes, }.Build() File_examples_internal_proto_pathenum_path_enum_proto = out.File file_examples_internal_proto_pathenum_path_enum_proto_rawDesc = nil file_examples_internal_proto_pathenum_path_enum_proto_goTypes = nil file_examples_internal_proto_pathenum_path_enum_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/pathenum/path_enum.proto ================================================ syntax = "proto3"; package grpc.gateway.examples.internal.pathenum; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/pathenum"; enum PathEnum { ABC = 0; DEF = 1; } message MessagePathEnum { enum NestedPathEnum { GHI = 0; JKL = 1; } } message MessageWithPathEnum { PathEnum value = 1; } message MessageWithNestedPathEnum { MessagePathEnum.NestedPathEnum value = 1; } // Ignoring lint warnings as this enum type exist to validate proper functionality // for projects that don't follow these lint rules. // buf:lint:ignore ENUM_PASCAL_CASE enum snake_case_for_import { // buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE value_x = 0; // buf:lint:ignore ENUM_VALUE_UPPER_SNAKE_CASE value_y = 1; } ================================================ FILE: examples/internal/proto/pathenum/path_enum.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/pathenum/path_enum.proto", "version": "version not set" }, "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": {}, "definitions": { "protobufAny": { "type": "object", "properties": { "@type": { "type": "string" } }, "additionalProperties": {} }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } } } } ================================================ FILE: examples/internal/proto/standalone/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "standalone", srcs = ["unannotated_echo_service.pb.gw.go"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/standalone", visibility = ["//examples:__subpackages__"], deps = [ "//examples/internal/proto/examplepb", "//runtime", "//utilities", "@org_golang_google_grpc//:grpc", "@org_golang_google_grpc//codes", "@org_golang_google_grpc//grpclog", "@org_golang_google_grpc//metadata", "@org_golang_google_grpc//status", "@org_golang_google_protobuf//proto", ], ) alias( name = "go_default_library", actual = ":standalone", visibility = ["//examples:__subpackages__"], ) ================================================ FILE: examples/internal/proto/standalone/unannotated_echo_service.pb.gw.go ================================================ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: examples/internal/proto/examplepb/unannotated_echo_service.proto /* Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ package examplepb import ( "context" "errors" "io" "net/http" extExamplepb "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) var filter_UnannotatedEchoService_Echo_0 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_UnannotatedEchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, client extExamplepb.UnannotatedEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq extExamplepb.UnannotatedSimpleMessage metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_Echo_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_UnannotatedEchoService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, server extExamplepb.UnannotatedEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq extExamplepb.UnannotatedSimpleMessage metadata runtime.ServerMetadata err error ) val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_Echo_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Echo(ctx, &protoReq) return msg, metadata, err } var filter_UnannotatedEchoService_Echo_1 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0, "num": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} func request_UnannotatedEchoService_Echo_1(ctx context.Context, marshaler runtime.Marshaler, client extExamplepb.UnannotatedEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq extExamplepb.UnannotatedSimpleMessage metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } val, ok = pathParams["num"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "num") } protoReq.Num, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "num", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_Echo_1); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_UnannotatedEchoService_Echo_1(ctx context.Context, marshaler runtime.Marshaler, server extExamplepb.UnannotatedEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq extExamplepb.UnannotatedSimpleMessage metadata runtime.ServerMetadata err error ) val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } val, ok = pathParams["num"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "num") } protoReq.Num, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "num", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_Echo_1); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Echo(ctx, &protoReq) return msg, metadata, err } var filter_UnannotatedEchoService_Echo_2 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0, "num": 1, "lang": 2}, Base: []int{1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 1, 1, 2, 3, 4}} func request_UnannotatedEchoService_Echo_2(ctx context.Context, marshaler runtime.Marshaler, client extExamplepb.UnannotatedEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq extExamplepb.UnannotatedSimpleMessage metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } val, ok = pathParams["num"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "num") } protoReq.Num, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "num", err) } val, ok = pathParams["lang"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "lang") } if protoReq.Code == nil { protoReq.Code = &extExamplepb.UnannotatedSimpleMessage_Lang{} } else if _, ok := protoReq.Code.(*extExamplepb.UnannotatedSimpleMessage_Lang); !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "expect type: *extExamplepb.UnannotatedSimpleMessage_Lang, but: %t\n", protoReq.Code) } protoReq.Code.(*extExamplepb.UnannotatedSimpleMessage_Lang).Lang, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "lang", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_Echo_2); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_UnannotatedEchoService_Echo_2(ctx context.Context, marshaler runtime.Marshaler, server extExamplepb.UnannotatedEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq extExamplepb.UnannotatedSimpleMessage metadata runtime.ServerMetadata err error ) val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } val, ok = pathParams["num"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "num") } protoReq.Num, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "num", err) } val, ok = pathParams["lang"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "lang") } if protoReq.Code == nil { protoReq.Code = &extExamplepb.UnannotatedSimpleMessage_Lang{} } else if _, ok := protoReq.Code.(*extExamplepb.UnannotatedSimpleMessage_Lang); !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "expect type: *extExamplepb.UnannotatedSimpleMessage_Lang, but: %t\n", protoReq.Code) } protoReq.Code.(*extExamplepb.UnannotatedSimpleMessage_Lang).Lang, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "lang", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_Echo_2); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Echo(ctx, &protoReq) return msg, metadata, err } var filter_UnannotatedEchoService_Echo_3 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0, "line_num": 1, "status": 2, "note": 3}, Base: []int{1, 1, 2, 1, 3, 0, 0, 0}, Check: []int{0, 1, 1, 1, 4, 2, 3, 5}} func request_UnannotatedEchoService_Echo_3(ctx context.Context, marshaler runtime.Marshaler, client extExamplepb.UnannotatedEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq extExamplepb.UnannotatedSimpleMessage metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } val, ok = pathParams["line_num"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "line_num") } if protoReq.Code == nil { protoReq.Code = &extExamplepb.UnannotatedSimpleMessage_LineNum{} } else if _, ok := protoReq.Code.(*extExamplepb.UnannotatedSimpleMessage_LineNum); !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "expect type: *extExamplepb.UnannotatedSimpleMessage_LineNum, but: %t\n", protoReq.Code) } protoReq.Code.(*extExamplepb.UnannotatedSimpleMessage_LineNum).LineNum, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "line_num", err) } val, ok = pathParams["status.note"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "status.note") } err = runtime.PopulateFieldFromPath(&protoReq, "status.note", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "status.note", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_Echo_3); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_UnannotatedEchoService_Echo_3(ctx context.Context, marshaler runtime.Marshaler, server extExamplepb.UnannotatedEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq extExamplepb.UnannotatedSimpleMessage metadata runtime.ServerMetadata err error ) val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } protoReq.Id, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } val, ok = pathParams["line_num"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "line_num") } if protoReq.Code == nil { protoReq.Code = &extExamplepb.UnannotatedSimpleMessage_LineNum{} } else if _, ok := protoReq.Code.(*extExamplepb.UnannotatedSimpleMessage_LineNum); !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "expect type: *extExamplepb.UnannotatedSimpleMessage_LineNum, but: %t\n", protoReq.Code) } protoReq.Code.(*extExamplepb.UnannotatedSimpleMessage_LineNum).LineNum, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "line_num", err) } val, ok = pathParams["status.note"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "status.note") } err = runtime.PopulateFieldFromPath(&protoReq, "status.note", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "status.note", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_Echo_3); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Echo(ctx, &protoReq) return msg, metadata, err } var filter_UnannotatedEchoService_Echo_4 = &utilities.DoubleArray{Encoding: map[string]int{"no": 0, "note": 1}, Base: []int{1, 1, 1, 0}, Check: []int{0, 1, 2, 3}} func request_UnannotatedEchoService_Echo_4(ctx context.Context, marshaler runtime.Marshaler, client extExamplepb.UnannotatedEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq extExamplepb.UnannotatedSimpleMessage metadata runtime.ServerMetadata err error ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } val, ok := pathParams["no.note"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "no.note") } err = runtime.PopulateFieldFromPath(&protoReq, "no.note", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "no.note", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_Echo_4); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.Echo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_UnannotatedEchoService_Echo_4(ctx context.Context, marshaler runtime.Marshaler, server extExamplepb.UnannotatedEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq extExamplepb.UnannotatedSimpleMessage metadata runtime.ServerMetadata err error ) val, ok := pathParams["no.note"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "no.note") } err = runtime.PopulateFieldFromPath(&protoReq, "no.note", val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "no.note", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_Echo_4); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.Echo(ctx, &protoReq) return msg, metadata, err } func request_UnannotatedEchoService_EchoBody_0(ctx context.Context, marshaler runtime.Marshaler, client extExamplepb.UnannotatedEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq extExamplepb.UnannotatedSimpleMessage metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.EchoBody(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_UnannotatedEchoService_EchoBody_0(ctx context.Context, marshaler runtime.Marshaler, server extExamplepb.UnannotatedEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq extExamplepb.UnannotatedSimpleMessage metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.EchoBody(ctx, &protoReq) return msg, metadata, err } var filter_UnannotatedEchoService_EchoDelete_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} func request_UnannotatedEchoService_EchoDelete_0(ctx context.Context, marshaler runtime.Marshaler, client extExamplepb.UnannotatedEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq extExamplepb.UnannotatedSimpleMessage metadata runtime.ServerMetadata ) if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_EchoDelete_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.EchoDelete(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_UnannotatedEchoService_EchoDelete_0(ctx context.Context, marshaler runtime.Marshaler, server extExamplepb.UnannotatedEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq extExamplepb.UnannotatedSimpleMessage metadata runtime.ServerMetadata ) if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UnannotatedEchoService_EchoDelete_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.EchoDelete(ctx, &protoReq) return msg, metadata, err } func request_UnannotatedEchoService_EchoNested_0(ctx context.Context, marshaler runtime.Marshaler, client extExamplepb.UnannotatedEchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq extExamplepb.UnannotatedSimpleMessage metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } msg, err := client.EchoNested(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } func local_request_UnannotatedEchoService_EchoNested_0(ctx context.Context, marshaler runtime.Marshaler, server extExamplepb.UnannotatedEchoServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq extExamplepb.UnannotatedSimpleMessage metadata runtime.ServerMetadata ) if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.EchoNested(ctx, &protoReq) return msg, metadata, err } // RegisterUnannotatedEchoServiceHandlerServer registers the http handlers for service UnannotatedEchoService to "mux". // UnaryRPC :call UnannotatedEchoServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterUnannotatedEchoServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterUnannotatedEchoServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server extExamplepb.UnannotatedEchoServiceServer) error { mux.Handle(http.MethodPost, pattern_UnannotatedEchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/Echo", runtime.WithHTTPPathPattern("/v2/example/echo/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_UnannotatedEchoService_Echo_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_UnannotatedEchoService_Echo_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/Echo", runtime.WithHTTPPathPattern("/v2/example/echo/{id}/{num}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_UnannotatedEchoService_Echo_1(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_Echo_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_UnannotatedEchoService_Echo_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/Echo", runtime.WithHTTPPathPattern("/v2/example/echo/{id}/{num}/{lang}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_UnannotatedEchoService_Echo_2(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_Echo_2(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_UnannotatedEchoService_Echo_3, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/Echo", runtime.WithHTTPPathPattern("/v2/example/echo1/{id}/{line_num}/{status.note}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_UnannotatedEchoService_Echo_3(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_Echo_3(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_UnannotatedEchoService_Echo_4, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/Echo", runtime.WithHTTPPathPattern("/v2/example/echo2/{no.note}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_UnannotatedEchoService_Echo_4(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_Echo_4(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_UnannotatedEchoService_EchoBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/EchoBody", runtime.WithHTTPPathPattern("/v2/example/echo_body")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_UnannotatedEchoService_EchoBody_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_EchoBody_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodDelete, pattern_UnannotatedEchoService_EchoDelete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/EchoDelete", runtime.WithHTTPPathPattern("/v2/example/echo_delete")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_UnannotatedEchoService_EchoDelete_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_EchoDelete_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPut, pattern_UnannotatedEchoService_EchoNested_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/EchoNested", runtime.WithHTTPPathPattern("/v1/example/echo_nested")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_UnannotatedEchoService_EchoNested_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_EchoNested_0(annotatedContext, mux, outboundMarshaler, w, req, response_UnannotatedEchoService_EchoNested_0{resp.(*extExamplepb.UnannotatedSimpleMessage)}, mux.GetForwardResponseOptions()...) }) return nil } // RegisterUnannotatedEchoServiceHandlerFromEndpoint is same as RegisterUnannotatedEchoServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterUnannotatedEchoServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return RegisterUnannotatedEchoServiceHandler(ctx, mux, conn) } // RegisterUnannotatedEchoServiceHandler registers the http handlers for service UnannotatedEchoService to "mux". // The handlers forward requests to the grpc endpoint over "conn". func RegisterUnannotatedEchoServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterUnannotatedEchoServiceHandlerClient(ctx, mux, extExamplepb.NewUnannotatedEchoServiceClient(conn)) } // RegisterUnannotatedEchoServiceHandlerClient registers the http handlers for service UnannotatedEchoService // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "extExamplepb.UnannotatedEchoServiceClient". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "extExamplepb.UnannotatedEchoServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "extExamplepb.UnannotatedEchoServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterUnannotatedEchoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client extExamplepb.UnannotatedEchoServiceClient) error { mux.Handle(http.MethodPost, pattern_UnannotatedEchoService_Echo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/Echo", runtime.WithHTTPPathPattern("/v2/example/echo/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_UnannotatedEchoService_Echo_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_Echo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_UnannotatedEchoService_Echo_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/Echo", runtime.WithHTTPPathPattern("/v2/example/echo/{id}/{num}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_UnannotatedEchoService_Echo_1(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_Echo_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_UnannotatedEchoService_Echo_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/Echo", runtime.WithHTTPPathPattern("/v2/example/echo/{id}/{num}/{lang}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_UnannotatedEchoService_Echo_2(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_Echo_2(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_UnannotatedEchoService_Echo_3, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/Echo", runtime.WithHTTPPathPattern("/v2/example/echo1/{id}/{line_num}/{status.note}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_UnannotatedEchoService_Echo_3(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_Echo_3(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodGet, pattern_UnannotatedEchoService_Echo_4, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/Echo", runtime.WithHTTPPathPattern("/v2/example/echo2/{no.note}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_UnannotatedEchoService_Echo_4(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_Echo_4(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_UnannotatedEchoService_EchoBody_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/EchoBody", runtime.WithHTTPPathPattern("/v2/example/echo_body")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_UnannotatedEchoService_EchoBody_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_EchoBody_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodDelete, pattern_UnannotatedEchoService_EchoDelete_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/EchoDelete", runtime.WithHTTPPathPattern("/v2/example/echo_delete")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_UnannotatedEchoService_EchoDelete_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_EchoDelete_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPut, pattern_UnannotatedEchoService_EchoNested_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/grpc.gateway.examples.internal.proto.examplepb.UnannotatedEchoService/EchoNested", runtime.WithHTTPPathPattern("/v1/example/echo_nested")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_UnannotatedEchoService_EchoNested_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } forward_UnannotatedEchoService_EchoNested_0(annotatedContext, mux, outboundMarshaler, w, req, response_UnannotatedEchoService_EchoNested_0{resp.(*extExamplepb.UnannotatedSimpleMessage)}, mux.GetForwardResponseOptions()...) }) return nil } type response_UnannotatedEchoService_EchoNested_0 struct { *extExamplepb.UnannotatedSimpleMessage } func (m response_UnannotatedEchoService_EchoNested_0) XXX_ResponseBody() interface{} { response := m.UnannotatedSimpleMessage return response.NId } var ( pattern_UnannotatedEchoService_Echo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v2", "example", "echo", "id"}, "")) pattern_UnannotatedEchoService_Echo_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"v2", "example", "echo", "id", "num"}, "")) pattern_UnannotatedEchoService_Echo_2 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"v2", "example", "echo", "id", "num", "lang"}, "")) pattern_UnannotatedEchoService_Echo_3 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"v2", "example", "echo1", "id", "line_num", "status.note"}, "")) pattern_UnannotatedEchoService_Echo_4 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v2", "example", "echo2", "no.note"}, "")) pattern_UnannotatedEchoService_EchoBody_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "example", "echo_body"}, "")) pattern_UnannotatedEchoService_EchoDelete_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "example", "echo_delete"}, "")) pattern_UnannotatedEchoService_EchoNested_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "example", "echo_nested"}, "")) ) var ( forward_UnannotatedEchoService_Echo_0 = runtime.ForwardResponseMessage forward_UnannotatedEchoService_Echo_1 = runtime.ForwardResponseMessage forward_UnannotatedEchoService_Echo_2 = runtime.ForwardResponseMessage forward_UnannotatedEchoService_Echo_3 = runtime.ForwardResponseMessage forward_UnannotatedEchoService_Echo_4 = runtime.ForwardResponseMessage forward_UnannotatedEchoService_EchoBody_0 = runtime.ForwardResponseMessage forward_UnannotatedEchoService_EchoDelete_0 = runtime.ForwardResponseMessage forward_UnannotatedEchoService_EchoNested_0 = runtime.ForwardResponseMessage ) ================================================ FILE: examples/internal/proto/sub/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library") load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") load("@rules_proto//proto:defs.bzl", "proto_library") package(default_visibility = ["//visibility:public"]) proto_library( name = "sub_proto", srcs = [ "camel_case_message.proto", "message.proto", ], ) go_proto_library( name = "sub_go_proto", compilers = ["//:go_apiv2"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub", proto = ":sub_proto", ) go_library( name = "sub", embed = [":sub_go_proto"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub", ) alias( name = "go_default_library", actual = ":sub", visibility = ["//examples:__subpackages__"], ) ================================================ FILE: examples/internal/proto/sub/camel_case_message.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/sub/camel_case_message.proto package sub import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) type StatusEnum int32 const ( StatusEnum_STATUS_ENUM_UNSPECIFIED StatusEnum = 0 StatusEnum_STATUS_ENUM_AVAILABLE StatusEnum = 1 ) // Enum value maps for StatusEnum. var ( StatusEnum_name = map[int32]string{ 0: "STATUS_ENUM_UNSPECIFIED", 1: "STATUS_ENUM_AVAILABLE", } StatusEnum_value = map[string]int32{ "STATUS_ENUM_UNSPECIFIED": 0, "STATUS_ENUM_AVAILABLE": 1, } ) func (x StatusEnum) Enum() *StatusEnum { p := new(StatusEnum) *p = x return p } func (x StatusEnum) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (StatusEnum) Descriptor() protoreflect.EnumDescriptor { return file_examples_internal_proto_sub_camel_case_message_proto_enumTypes[0].Descriptor() } func (StatusEnum) Type() protoreflect.EnumType { return &file_examples_internal_proto_sub_camel_case_message_proto_enumTypes[0] } func (x StatusEnum) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use StatusEnum.Descriptor instead. func (StatusEnum) EnumDescriptor() ([]byte, []int) { return file_examples_internal_proto_sub_camel_case_message_proto_rawDescGZIP(), []int{0} } // Create_book and Status_enum demonstrate snake_case identifiers that need to // be resolved to Go camel case when referenced by other packages. type CreateBook struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` Author string `protobuf:"bytes,2,opt,name=author,proto3" json:"author,omitempty"` } func (x *CreateBook) Reset() { *x = CreateBook{} mi := &file_examples_internal_proto_sub_camel_case_message_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *CreateBook) String() string { return protoimpl.X.MessageStringOf(x) } func (*CreateBook) ProtoMessage() {} func (x *CreateBook) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_sub_camel_case_message_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use CreateBook.ProtoReflect.Descriptor instead. func (*CreateBook) Descriptor() ([]byte, []int) { return file_examples_internal_proto_sub_camel_case_message_proto_rawDescGZIP(), []int{0} } func (x *CreateBook) GetTitle() string { if x != nil { return x.Title } return "" } func (x *CreateBook) GetAuthor() string { if x != nil { return x.Author } return "" } var File_examples_internal_proto_sub_camel_case_message_proto protoreflect.FileDescriptor var file_examples_internal_proto_sub_camel_case_message_proto_rawDesc = []byte{ 0x0a, 0x34, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x75, 0x62, 0x2f, 0x63, 0x61, 0x6d, 0x65, 0x6c, 0x5f, 0x63, 0x61, 0x73, 0x65, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x28, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x73, 0x75, 0x62, 0x22, 0x3b, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x62, 0x6f, 0x6f, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x2a, 0x45, 0x0a, 0x0b, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x12, 0x1b, 0x0a, 0x17, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x19, 0x0a, 0x15, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x41, 0x56, 0x41, 0x49, 0x4c, 0x41, 0x42, 0x4c, 0x45, 0x10, 0x01, 0x42, 0x47, 0x5a, 0x45, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x75, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_sub_camel_case_message_proto_rawDescOnce sync.Once file_examples_internal_proto_sub_camel_case_message_proto_rawDescData = file_examples_internal_proto_sub_camel_case_message_proto_rawDesc ) func file_examples_internal_proto_sub_camel_case_message_proto_rawDescGZIP() []byte { file_examples_internal_proto_sub_camel_case_message_proto_rawDescOnce.Do(func() { file_examples_internal_proto_sub_camel_case_message_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_sub_camel_case_message_proto_rawDescData) }) return file_examples_internal_proto_sub_camel_case_message_proto_rawDescData } var file_examples_internal_proto_sub_camel_case_message_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_examples_internal_proto_sub_camel_case_message_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_examples_internal_proto_sub_camel_case_message_proto_goTypes = []any{ (StatusEnum)(0), // 0: grpc.gateway.examples.internal.proto.sub.Status_enum (*CreateBook)(nil), // 1: grpc.gateway.examples.internal.proto.sub.Create_book } var file_examples_internal_proto_sub_camel_case_message_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type 0, // [0:0] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name } func init() { file_examples_internal_proto_sub_camel_case_message_proto_init() } func file_examples_internal_proto_sub_camel_case_message_proto_init() { if File_examples_internal_proto_sub_camel_case_message_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_sub_camel_case_message_proto_rawDesc, NumEnums: 1, NumMessages: 1, NumExtensions: 0, NumServices: 0, }, GoTypes: file_examples_internal_proto_sub_camel_case_message_proto_goTypes, DependencyIndexes: file_examples_internal_proto_sub_camel_case_message_proto_depIdxs, EnumInfos: file_examples_internal_proto_sub_camel_case_message_proto_enumTypes, MessageInfos: file_examples_internal_proto_sub_camel_case_message_proto_msgTypes, }.Build() File_examples_internal_proto_sub_camel_case_message_proto = out.File file_examples_internal_proto_sub_camel_case_message_proto_rawDesc = nil file_examples_internal_proto_sub_camel_case_message_proto_goTypes = nil file_examples_internal_proto_sub_camel_case_message_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/sub/camel_case_message.proto ================================================ syntax = "proto3"; package grpc.gateway.examples.internal.proto.sub; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub"; // Create_book and Status_enum demonstrate snake_case identifiers that need to // be resolved to Go camel case when referenced by other packages. message Create_book { string title = 1; string author = 2; } enum Status_enum { STATUS_ENUM_UNSPECIFIED = 0; STATUS_ENUM_AVAILABLE = 1; } ================================================ FILE: examples/internal/proto/sub/camel_case_message.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/sub/camel_case_message.proto", "version": "version not set" }, "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": {}, "definitions": { "googleRpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string" } }, "additionalProperties": {} } } } ================================================ FILE: examples/internal/proto/sub/message.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/sub/message.proto package sub import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) type StringMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Value *string `protobuf:"bytes,1,req,name=value" json:"value,omitempty"` } func (x *StringMessage) Reset() { *x = StringMessage{} mi := &file_examples_internal_proto_sub_message_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *StringMessage) String() string { return protoimpl.X.MessageStringOf(x) } func (*StringMessage) ProtoMessage() {} func (x *StringMessage) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_sub_message_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use StringMessage.ProtoReflect.Descriptor instead. func (*StringMessage) Descriptor() ([]byte, []int) { return file_examples_internal_proto_sub_message_proto_rawDescGZIP(), []int{0} } func (x *StringMessage) GetValue() string { if x != nil && x.Value != nil { return *x.Value } return "" } // Status message in sub package type Status struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Code *int32 `protobuf:"varint,1,req,name=code" json:"code,omitempty"` Message *string `protobuf:"bytes,2,opt,name=message" json:"message,omitempty"` } func (x *Status) Reset() { *x = Status{} mi := &file_examples_internal_proto_sub_message_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Status) String() string { return protoimpl.X.MessageStringOf(x) } func (*Status) ProtoMessage() {} func (x *Status) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_sub_message_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Status.ProtoReflect.Descriptor instead. func (*Status) Descriptor() ([]byte, []int) { return file_examples_internal_proto_sub_message_proto_rawDescGZIP(), []int{1} } func (x *Status) GetCode() int32 { if x != nil && x.Code != nil { return *x.Code } return 0 } func (x *Status) GetMessage() string { if x != nil && x.Message != nil { return *x.Message } return "" } var File_examples_internal_proto_sub_message_proto protoreflect.FileDescriptor var file_examples_internal_proto_sub_message_proto_rawDesc = []byte{ 0x0a, 0x29, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x75, 0x62, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x28, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x73, 0x75, 0x62, 0x22, 0x25, 0x0a, 0x0d, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x02, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x36, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x02, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0x47, 0x5a, 0x45, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x75, 0x62, } var ( file_examples_internal_proto_sub_message_proto_rawDescOnce sync.Once file_examples_internal_proto_sub_message_proto_rawDescData = file_examples_internal_proto_sub_message_proto_rawDesc ) func file_examples_internal_proto_sub_message_proto_rawDescGZIP() []byte { file_examples_internal_proto_sub_message_proto_rawDescOnce.Do(func() { file_examples_internal_proto_sub_message_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_sub_message_proto_rawDescData) }) return file_examples_internal_proto_sub_message_proto_rawDescData } var file_examples_internal_proto_sub_message_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_examples_internal_proto_sub_message_proto_goTypes = []any{ (*StringMessage)(nil), // 0: grpc.gateway.examples.internal.proto.sub.StringMessage (*Status)(nil), // 1: grpc.gateway.examples.internal.proto.sub.Status } var file_examples_internal_proto_sub_message_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type 0, // [0:0] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name } func init() { file_examples_internal_proto_sub_message_proto_init() } func file_examples_internal_proto_sub_message_proto_init() { if File_examples_internal_proto_sub_message_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_sub_message_proto_rawDesc, NumEnums: 0, NumMessages: 2, NumExtensions: 0, NumServices: 0, }, GoTypes: file_examples_internal_proto_sub_message_proto_goTypes, DependencyIndexes: file_examples_internal_proto_sub_message_proto_depIdxs, MessageInfos: file_examples_internal_proto_sub_message_proto_msgTypes, }.Build() File_examples_internal_proto_sub_message_proto = out.File file_examples_internal_proto_sub_message_proto_rawDesc = nil file_examples_internal_proto_sub_message_proto_goTypes = nil file_examples_internal_proto_sub_message_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/sub/message.proto ================================================ syntax = "proto2"; package grpc.gateway.examples.internal.proto.sub; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub"; message StringMessage { required string value = 1; } // Status message in sub package message Status { required int32 code = 1; optional string message = 2; } ================================================ FILE: examples/internal/proto/sub/message.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/sub/message.proto", "version": "version not set" }, "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": {}, "definitions": { "googleRpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string" } }, "additionalProperties": {} } } } ================================================ FILE: examples/internal/proto/sub2/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library") load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") load("@rules_proto//proto:defs.bzl", "proto_library") package(default_visibility = ["//visibility:public"]) proto_library( name = "sub2_proto", srcs = ["message.proto"], ) go_proto_library( name = "sub2_go_proto", compilers = ["//:go_apiv2"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub2", proto = ":sub2_proto", ) go_library( name = "sub2", embed = [":sub2_go_proto"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub2", ) alias( name = "go_default_library", actual = ":sub2", visibility = ["//examples:__subpackages__"], ) ================================================ FILE: examples/internal/proto/sub2/message.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: examples/internal/proto/sub2/message.proto package sub2 import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) type IdMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` } func (x *IdMessage) Reset() { *x = IdMessage{} mi := &file_examples_internal_proto_sub2_message_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *IdMessage) String() string { return protoimpl.X.MessageStringOf(x) } func (*IdMessage) ProtoMessage() {} func (x *IdMessage) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_sub2_message_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use IdMessage.ProtoReflect.Descriptor instead. func (*IdMessage) Descriptor() ([]byte, []int) { return file_examples_internal_proto_sub2_message_proto_rawDescGZIP(), []int{0} } func (x *IdMessage) GetUuid() string { if x != nil { return x.Uuid } return "" } // Status message in sub2 package (different structure from sub.Status) type Status struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields ErrorCode string `protobuf:"bytes,1,opt,name=error_code,json=errorCode,proto3" json:"error_code,omitempty"` ErrorMessage string `protobuf:"bytes,2,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` Severity int32 `protobuf:"varint,3,opt,name=severity,proto3" json:"severity,omitempty"` } func (x *Status) Reset() { *x = Status{} mi := &file_examples_internal_proto_sub2_message_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Status) String() string { return protoimpl.X.MessageStringOf(x) } func (*Status) ProtoMessage() {} func (x *Status) ProtoReflect() protoreflect.Message { mi := &file_examples_internal_proto_sub2_message_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Status.ProtoReflect.Descriptor instead. func (*Status) Descriptor() ([]byte, []int) { return file_examples_internal_proto_sub2_message_proto_rawDescGZIP(), []int{1} } func (x *Status) GetErrorCode() string { if x != nil { return x.ErrorCode } return "" } func (x *Status) GetErrorMessage() string { if x != nil { return x.ErrorMessage } return "" } func (x *Status) GetSeverity() int32 { if x != nil { return x.Severity } return 0 } var File_examples_internal_proto_sub2_message_proto protoreflect.FileDescriptor var file_examples_internal_proto_sub2_message_proto_rawDesc = []byte{ 0x0a, 0x2a, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x75, 0x62, 0x32, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x29, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x73, 0x75, 0x62, 0x32, 0x22, 0x1f, 0x0a, 0x09, 0x49, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x22, 0x68, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x75, 0x62, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_examples_internal_proto_sub2_message_proto_rawDescOnce sync.Once file_examples_internal_proto_sub2_message_proto_rawDescData = file_examples_internal_proto_sub2_message_proto_rawDesc ) func file_examples_internal_proto_sub2_message_proto_rawDescGZIP() []byte { file_examples_internal_proto_sub2_message_proto_rawDescOnce.Do(func() { file_examples_internal_proto_sub2_message_proto_rawDescData = protoimpl.X.CompressGZIP(file_examples_internal_proto_sub2_message_proto_rawDescData) }) return file_examples_internal_proto_sub2_message_proto_rawDescData } var file_examples_internal_proto_sub2_message_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_examples_internal_proto_sub2_message_proto_goTypes = []any{ (*IdMessage)(nil), // 0: grpc.gateway.examples.internal.proto.sub2.IdMessage (*Status)(nil), // 1: grpc.gateway.examples.internal.proto.sub2.Status } var file_examples_internal_proto_sub2_message_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type 0, // [0:0] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name } func init() { file_examples_internal_proto_sub2_message_proto_init() } func file_examples_internal_proto_sub2_message_proto_init() { if File_examples_internal_proto_sub2_message_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_examples_internal_proto_sub2_message_proto_rawDesc, NumEnums: 0, NumMessages: 2, NumExtensions: 0, NumServices: 0, }, GoTypes: file_examples_internal_proto_sub2_message_proto_goTypes, DependencyIndexes: file_examples_internal_proto_sub2_message_proto_depIdxs, MessageInfos: file_examples_internal_proto_sub2_message_proto_msgTypes, }.Build() File_examples_internal_proto_sub2_message_proto = out.File file_examples_internal_proto_sub2_message_proto_rawDesc = nil file_examples_internal_proto_sub2_message_proto_goTypes = nil file_examples_internal_proto_sub2_message_proto_depIdxs = nil } ================================================ FILE: examples/internal/proto/sub2/message.proto ================================================ syntax = "proto3"; package grpc.gateway.examples.internal.proto.sub2; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub2"; message IdMessage { string uuid = 1; } // Status message in sub2 package (different structure from sub.Status) message Status { string error_code = 1; string error_message = 2; int32 severity = 3; } ================================================ FILE: examples/internal/proto/sub2/message.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "examples/internal/proto/sub2/message.proto", "version": "version not set" }, "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": {}, "definitions": { "googleRpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string" } }, "additionalProperties": {} } } } ================================================ FILE: examples/internal/server/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library") package(default_visibility = ["//visibility:public"]) go_library( name = "server", srcs = [ "a_bit_of_everything.go", "echo.go", "excess_body.go", "fieldmask_helper.go", "flow_combination.go", "main.go", "non_standard_names.go", "responsebody.go", "unannotatedecho.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/server", deps = [ "//examples/internal/proto/examplepb", "//examples/internal/proto/oneofenum", "//examples/internal/proto/pathenum", "//examples/internal/proto/standalone", "//examples/internal/proto/sub", "//examples/internal/proto/sub2", "//runtime", "@com_github_rogpeppe_fastuuid//:fastuuid", "@org_golang_google_genproto_googleapis_api//httpbody", "@org_golang_google_genproto_googleapis_rpc//errdetails", "@org_golang_google_genproto_googleapis_rpc//status", "@org_golang_google_grpc//:grpc", "@org_golang_google_grpc//codes", "@org_golang_google_grpc//grpclog", "@org_golang_google_grpc//metadata", "@org_golang_google_grpc//status", "@org_golang_google_protobuf//proto", "@org_golang_google_protobuf//reflect/protoreflect", "@org_golang_google_protobuf//types/known/durationpb", "@org_golang_google_protobuf//types/known/emptypb", "@org_golang_google_protobuf//types/known/fieldmaskpb", "@org_golang_google_protobuf//types/known/wrapperspb", ], ) alias( name = "go_default_library", actual = ":server", visibility = ["//examples:__subpackages__"], ) ================================================ FILE: examples/internal/server/a_bit_of_everything.go ================================================ package server import ( "context" "fmt" "io" "sync" "time" examples "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/oneofenum" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/pathenum" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub" "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/sub2" "github.com/rogpeppe/fastuuid" "google.golang.org/genproto/googleapis/api/httpbody" "google.golang.org/genproto/googleapis/rpc/errdetails" statuspb "google.golang.org/genproto/googleapis/rpc/status" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/durationpb" "google.golang.org/protobuf/types/known/emptypb" "google.golang.org/protobuf/types/known/wrapperspb" ) // Implements of ABitOfEverythingServiceServer var uuidgen = fastuuid.MustNewGenerator() type _ABitOfEverythingServer struct { v map[string]*examples.ABitOfEverything m sync.Mutex } type ABitOfEverythingServer interface { examples.ABitOfEverythingServiceServer examples.StreamServiceServer } func newABitOfEverythingServer() ABitOfEverythingServer { return &_ABitOfEverythingServer{ v: make(map[string]*examples.ABitOfEverything), } } func (s *_ABitOfEverythingServer) Create(ctx context.Context, msg *examples.ABitOfEverything) (*examples.ABitOfEverything, error) { s.m.Lock() defer s.m.Unlock() grpclog.Info(msg) var uuid string for { uuid = fmt.Sprintf("%x", uuidgen.Next()) if _, ok := s.v[uuid]; !ok { break } } s.v[uuid] = msg s.v[uuid].Uuid = uuid grpclog.Infof("%v", s.v[uuid]) return s.v[uuid], nil } func (s *_ABitOfEverythingServer) CreateBody(ctx context.Context, msg *examples.ABitOfEverything) (*examples.ABitOfEverything, error) { return s.Create(ctx, msg) } func (s *_ABitOfEverythingServer) CreateBook(ctx context.Context, req *examples.CreateBookRequest) (*examples.Book, error) { return &examples.Book{}, nil } func (s *_ABitOfEverythingServer) UpdateBook(ctx context.Context, req *examples.UpdateBookRequest) (*examples.Book, error) { return &examples.Book{}, nil } func (s *_ABitOfEverythingServer) BulkCreate(stream examples.StreamService_BulkCreateServer) error { ctx := stream.Context() if header, ok := metadata.FromIncomingContext(ctx); ok { if v, ok := header["error"]; ok { return status.Errorf(codes.InvalidArgument, "error metadata: %v", v) } } count := 0 for { msg, err := stream.Recv() if err == io.EOF { break } if err != nil { return err } count++ grpclog.Info(msg) if _, err = s.Create(ctx, msg); err != nil { return err } } err := stream.SendHeader(metadata.New(map[string]string{ "count": fmt.Sprintf("%d", count), })) if err != nil { return nil } stream.SetTrailer(metadata.New(map[string]string{ "foo": "foo2", "bar": "bar2", })) return stream.SendAndClose(new(emptypb.Empty)) } func (s *_ABitOfEverythingServer) Lookup(ctx context.Context, msg *sub2.IdMessage) (*examples.ABitOfEverything, error) { s.m.Lock() defer s.m.Unlock() grpclog.Info(msg) err := grpc.SendHeader(ctx, metadata.New(map[string]string{ "uuid": msg.Uuid, })) if err != nil { return nil, err } if a, ok := s.v[msg.Uuid]; ok { return a, nil } grpc.SetTrailer(ctx, metadata.New(map[string]string{ "foo": "foo2", "bar": "bar2", })) return nil, status.Errorf(codes.NotFound, "not found") } func (s *_ABitOfEverythingServer) List(opt *examples.Options, stream examples.StreamService_ListServer) error { s.m.Lock() defer s.m.Unlock() err := stream.SendHeader(metadata.New(map[string]string{ "count": fmt.Sprintf("%d", len(s.v)), })) if err != nil { return nil } for _, msg := range s.v { if err := stream.Send(msg); err != nil { return err } } if opt.Error { stream.SetTrailer(metadata.New(map[string]string{ "foo": "foo2", "bar": "bar2", })) return status.Error(codes.InvalidArgument, "error") } return nil } func (s *_ABitOfEverythingServer) Download(opt *examples.Options, stream examples.StreamService_DownloadServer) error { msgs := []*httpbody.HttpBody{{ ContentType: "text/html", Data: []byte("Hello 1"), }, { ContentType: "text/html", Data: []byte("Hello 2"), }} for _, msg := range msgs { if err := stream.Send(msg); err != nil { return err } time.Sleep(5 * time.Millisecond) } if opt.Error { stream.SetTrailer(metadata.New(map[string]string{ "foo": "foo2", "bar": "bar2", })) return status.Error(codes.InvalidArgument, "error") } return nil } func (s *_ABitOfEverythingServer) Custom(ctx context.Context, msg *examples.ABitOfEverything) (*examples.ABitOfEverything, error) { s.m.Lock() defer s.m.Unlock() grpclog.Info(msg) if _, ok := s.v[msg.Uuid]; ok { s.v[msg.Uuid] = msg } else { return nil, status.Errorf(codes.NotFound, "not found") } return msg, nil } func (s *_ABitOfEverythingServer) DoubleColon(ctx context.Context, msg *examples.ABitOfEverything) (*examples.ABitOfEverything, error) { s.m.Lock() defer s.m.Unlock() grpclog.Info(msg) if _, ok := s.v[msg.Uuid]; ok { s.v[msg.Uuid] = msg } else { return nil, status.Errorf(codes.NotFound, "not found") } return msg, nil } func (s *_ABitOfEverythingServer) Update(ctx context.Context, msg *examples.ABitOfEverything) (*emptypb.Empty, error) { s.m.Lock() defer s.m.Unlock() grpclog.Info(msg) if _, ok := s.v[msg.Uuid]; ok { s.v[msg.Uuid] = msg } else { return nil, status.Errorf(codes.NotFound, "not found") } return new(emptypb.Empty), nil } func (s *_ABitOfEverythingServer) UpdateV2(ctx context.Context, msg *examples.UpdateV2Request) (*emptypb.Empty, error) { grpclog.Info(msg) // If there is no update mask do a regular update if msg.UpdateMask == nil || len(msg.UpdateMask.GetPaths()) == 0 { return s.Update(ctx, msg.Abe) } s.m.Lock() defer s.m.Unlock() if a, ok := s.v[msg.Abe.Uuid]; ok { applyFieldMask(a, msg.Abe, msg.UpdateMask) } else { return nil, status.Errorf(codes.NotFound, "not found") } return new(emptypb.Empty), nil } func (s *_ABitOfEverythingServer) Delete(ctx context.Context, msg *sub2.IdMessage) (*emptypb.Empty, error) { s.m.Lock() defer s.m.Unlock() grpclog.Info(msg) if _, ok := s.v[msg.Uuid]; ok { delete(s.v, msg.Uuid) } else { return nil, status.Errorf(codes.NotFound, "not found") } return new(emptypb.Empty), nil } func (s *_ABitOfEverythingServer) GetQuery(ctx context.Context, msg *examples.ABitOfEverything) (*emptypb.Empty, error) { s.m.Lock() defer s.m.Unlock() grpclog.Info(msg) if _, ok := s.v[msg.Uuid]; ok { s.v[msg.Uuid] = msg } else { return nil, status.Errorf(codes.NotFound, "not found") } return new(emptypb.Empty), nil } func (s *_ABitOfEverythingServer) GetRepeatedQuery(ctx context.Context, msg *examples.ABitOfEverythingRepeated) (*examples.ABitOfEverythingRepeated, error) { s.m.Lock() defer s.m.Unlock() grpclog.Info(msg) return msg, nil } func (s *_ABitOfEverythingServer) Echo(ctx context.Context, msg *sub.StringMessage) (*sub.StringMessage, error) { s.m.Lock() defer s.m.Unlock() grpclog.Info(msg) return msg, nil } func (s *_ABitOfEverythingServer) BulkEcho(stream examples.StreamService_BulkEchoServer) error { var msgs []*sub.StringMessage for { msg, err := stream.Recv() if err == io.EOF { break } if err != nil { return err } msgs = append(msgs, msg) } hmd := metadata.New(map[string]string{ "foo": "foo1", "bar": "bar1", }) if err := stream.SendHeader(hmd); err != nil { return err } for _, msg := range msgs { grpclog.Info(msg) if err := stream.Send(msg); err != nil { return err } } stream.SetTrailer(metadata.New(map[string]string{ "foo": "foo2", "bar": "bar2", })) return nil } func (s *_ABitOfEverythingServer) BulkEchoDuration(stream examples.StreamService_BulkEchoDurationServer) error { hmd := metadata.New(map[string]string{ "foo": "foo1", "bar": "bar1", }) if err := stream.SendHeader(hmd); err != nil { return err } // Channel to coordinate between read and write goroutines msgChan := make(chan *durationpb.Duration) errChan := make(chan error) go func() { defer close(msgChan) for { msg, err := stream.Recv() if err == io.EOF { return } if err != nil { errChan <- err return } msgChan <- msg } }() go func() { for msg := range msgChan { grpclog.Info(msg) if err := stream.Send(msg); err != nil { errChan <- err return } } // Sleep to mock the delay in receiving the request close. // Accommodates the integration test client which is not a true // bidirectional streaming client that supports request streaming. time.Sleep(1 * time.Second) close(errChan) }() err := <-errChan stream.SetTrailer(metadata.New(map[string]string{ "foo": "foo2", "bar": "bar2", })) return err } func (s *_ABitOfEverythingServer) DeepPathEcho(ctx context.Context, msg *examples.ABitOfEverything) (*examples.ABitOfEverything, error) { s.m.Lock() defer s.m.Unlock() grpclog.Info(msg) return msg, nil } func (s *_ABitOfEverythingServer) NoBindings(ctx context.Context, msg *durationpb.Duration) (*emptypb.Empty, error) { return nil, nil } func (s *_ABitOfEverythingServer) Timeout(ctx context.Context, msg *emptypb.Empty) (*emptypb.Empty, error) { <-ctx.Done() return nil, status.FromContextError(ctx.Err()).Err() } func (s *_ABitOfEverythingServer) ErrorWithDetails(ctx context.Context, msg *emptypb.Empty) (*emptypb.Empty, error) { stat, err := status.New(codes.Unknown, "with details"). WithDetails(&errdetails.DebugInfo{ StackEntries: []string{"foo:1"}, Detail: "error debug details", }) if err != nil { return nil, status.Errorf(codes.Internal, "unexpected error adding details: %s", err) } return nil, stat.Err() } func (s *_ABitOfEverythingServer) GetMessageWithBody(ctx context.Context, msg *examples.MessageWithBody) (*emptypb.Empty, error) { return &emptypb.Empty{}, nil } func (s *_ABitOfEverythingServer) PostWithEmptyBody(ctx context.Context, msg *examples.Body) (*emptypb.Empty, error) { return &emptypb.Empty{}, nil } func (s *_ABitOfEverythingServer) CheckGetQueryParams(ctx context.Context, msg *examples.ABitOfEverything) (*examples.ABitOfEverything, error) { return msg, nil } func (s *_ABitOfEverythingServer) CheckNestedEnumGetQueryParams(ctx context.Context, msg *examples.ABitOfEverything) (*examples.ABitOfEverything, error) { return msg, nil } func (s *_ABitOfEverythingServer) CheckPostQueryParams(ctx context.Context, msg *examples.ABitOfEverything) (*examples.ABitOfEverything, error) { return msg, nil } func (s *_ABitOfEverythingServer) OverwriteRequestContentType(ctx context.Context, msg *examples.Body) (*emptypb.Empty, error) { return &emptypb.Empty{}, nil } func (s *_ABitOfEverythingServer) OverwriteResponseContentType(ctx context.Context, msg *emptypb.Empty) (*wrapperspb.StringValue, error) { return &wrapperspb.StringValue{}, nil } func (s *_ABitOfEverythingServer) CheckExternalPathEnum(ctx context.Context, msg *pathenum.MessageWithPathEnum) (*emptypb.Empty, error) { return &emptypb.Empty{}, nil } func (s *_ABitOfEverythingServer) CheckExternalNestedPathEnum(ctx context.Context, msg *pathenum.MessageWithNestedPathEnum) (*emptypb.Empty, error) { return &emptypb.Empty{}, nil } func (s *_ABitOfEverythingServer) CheckStatus(ctx context.Context, empty *emptypb.Empty) (*examples.CheckStatusResponse, error) { return &examples.CheckStatusResponse{Status: &statuspb.Status{}}, nil } func (s *_ABitOfEverythingServer) Exists(ctx context.Context, msg *examples.ABitOfEverything) (*emptypb.Empty, error) { if _, ok := s.v[msg.Uuid]; ok { return new(emptypb.Empty), nil } return nil, status.Errorf(codes.NotFound, "not found") } func (s *_ABitOfEverythingServer) CustomOptionsRequest(ctx context.Context, msg *examples.ABitOfEverything) (*emptypb.Empty, error) { err := grpc.SendHeader(ctx, metadata.New(map[string]string{ "Allow": "OPTIONS, GET, HEAD, POST, PUT, TRACE", })) if err != nil { return nil, err } return new(emptypb.Empty), nil } func (s *_ABitOfEverythingServer) TraceRequest(ctx context.Context, msg *examples.ABitOfEverything) (*examples.ABitOfEverything, error) { return msg, nil } func (s *_ABitOfEverythingServer) PostOneofEnum(ctx context.Context, msg *oneofenum.OneofEnumMessage) (*emptypb.Empty, error) { return new(emptypb.Empty), nil } func (s *_ABitOfEverythingServer) PostRequiredMessageType(ctx context.Context, req *examples.RequiredMessageTypeRequest) (*emptypb.Empty, error) { return new(emptypb.Empty), nil } ================================================ FILE: examples/internal/server/echo.go ================================================ package server import ( "context" examples "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) // Implements of EchoServiceServer type echoServer struct{} func newEchoServer() examples.EchoServiceServer { return new(echoServer) } func (s *echoServer) Echo(ctx context.Context, msg *examples.SimpleMessage) (*examples.SimpleMessage, error) { grpclog.Info(msg) return msg, nil } func (s *echoServer) EchoBody(ctx context.Context, msg *examples.SimpleMessage) (*examples.SimpleMessage, error) { grpclog.Info(msg) grpc.SendHeader(ctx, metadata.New(map[string]string{ "foo": "foo1", "bar": "bar1", })) grpc.SetTrailer(ctx, metadata.New(map[string]string{ "foo": "foo2", "bar": "bar2", })) return msg, nil } func (s *echoServer) EchoDelete(ctx context.Context, msg *examples.SimpleMessage) (*examples.SimpleMessage, error) { grpclog.Info(msg) return msg, nil } func (s *echoServer) EchoPatch(ctx context.Context, msg *examples.DynamicMessageUpdate) (*examples.DynamicMessageUpdate, error) { grpclog.Info(msg) return msg, nil } func (s *echoServer) EchoUnauthorized(ctx context.Context, msg *examples.SimpleMessage) (*examples.SimpleMessage, error) { grpclog.Info(msg) return nil, status.Error(codes.Unauthenticated, "unauthorized err") } // EchoStatus demonstrates handling of two Status messages with the same name from different packages. func (s *echoServer) EchoStatus(ctx context.Context, req *examples.StatusCheckRequest) (*examples.StatusCheckResponse, error) { grpclog.Info(req) return &examples.StatusCheckResponse{ Result: "ok", SubStatus: req.GetSubStatus(), Sub2Status: req.GetSub2Status(), }, nil } ================================================ FILE: examples/internal/server/excess_body.go ================================================ package server import ( "context" examples "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/emptypb" ) var ( excessBody_contextChRPC = make(chan context.Context) excessBody_contextChStream = make(chan context.Context) ) func ExcessBodyServer_RetrieveContextRPC() context.Context { return <-excessBody_contextChRPC } func ExcessBodyServer_RetrieveContextStream() context.Context { return <-excessBody_contextChStream } type excessBodyServer struct{} func newExcessBodyServer() examples.ExcessBodyServiceServer { return &excessBodyServer{} } func (s excessBodyServer) NoBodyRpc(ctx context.Context, req *emptypb.Empty) (*emptypb.Empty, error) { excessBody_contextChRPC <- ctx <-ctx.Done() return nil, status.Error(codes.Canceled, "context canceled") } func (s excessBodyServer) NoBodyServerStream(req *emptypb.Empty, stream grpc.ServerStreamingServer[emptypb.Empty]) error { excessBody_contextChStream <- stream.Context() <-stream.Context().Done() return status.Error(codes.Canceled, "context canceled") } func (s excessBodyServer) WithBodyRpc(ctx context.Context, req *emptypb.Empty) (*emptypb.Empty, error) { excessBody_contextChRPC <- ctx <-ctx.Done() return nil, status.Error(codes.Canceled, "context canceled") } func (s excessBodyServer) WithBodyServerStream(req *emptypb.Empty, stream grpc.ServerStreamingServer[emptypb.Empty]) error { excessBody_contextChStream <- stream.Context() <-stream.Context().Done() return status.Error(codes.Canceled, "context canceled") } ================================================ FILE: examples/internal/server/fieldmask_helper.go ================================================ package server import ( "strings" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" field_mask "google.golang.org/protobuf/types/known/fieldmaskpb" ) func applyFieldMask(patchee, patcher proto.Message, mask *field_mask.FieldMask) { if mask == nil { return } if patchee.ProtoReflect().Descriptor().FullName() != patcher.ProtoReflect().Descriptor().FullName() { panic("patchee and patcher must be same type") } for _, path := range mask.GetPaths() { patcherField, patcherParent := getField(patcher.ProtoReflect(), path) patcheeField, patcheeParent := getField(patchee.ProtoReflect(), path) patcheeParent.Set(patcheeField, patcherParent.Get(patcherField)) } } func getField(msg protoreflect.Message, path string) (field protoreflect.FieldDescriptor, parent protoreflect.Message) { fields := msg.Descriptor().Fields() parent = msg names := strings.Split(path, ".") for i, name := range names { field = fields.ByName(protoreflect.Name(name)) if i < len(names)-1 { parent = parent.Get(field).Message() fields = field.Message().Fields() } } return field, parent } ================================================ FILE: examples/internal/server/flow_combination.go ================================================ package server import ( "context" "io" examples "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb" ) type flowCombinationServer struct{} func newFlowCombinationServer() examples.FlowCombinationServer { return &flowCombinationServer{} } func (s flowCombinationServer) RpcEmptyRpc(ctx context.Context, req *examples.EmptyProto) (*examples.EmptyProto, error) { return req, nil } func (s flowCombinationServer) RpcEmptyStream(req *examples.EmptyProto, stream examples.FlowCombination_RpcEmptyStreamServer) error { return stream.Send(req) } func (s flowCombinationServer) StreamEmptyRpc(stream examples.FlowCombination_StreamEmptyRpcServer) error { for { _, err := stream.Recv() if err == io.EOF { break } if err != nil { return err } } return stream.SendAndClose(new(examples.EmptyProto)) } func (s flowCombinationServer) StreamEmptyStream(stream examples.FlowCombination_StreamEmptyStreamServer) error { for { _, err := stream.Recv() if err == io.EOF { break } if err != nil { return err } } return stream.Send(new(examples.EmptyProto)) } func (s flowCombinationServer) RpcBodyRpc(ctx context.Context, req *examples.NonEmptyProto) (*examples.EmptyProto, error) { return new(examples.EmptyProto), nil } func (s flowCombinationServer) RpcPathSingleNestedRpc(ctx context.Context, req *examples.SingleNestedProto) (*examples.EmptyProto, error) { return new(examples.EmptyProto), nil } func (s flowCombinationServer) RpcPathNestedRpc(ctx context.Context, req *examples.NestedProto) (*examples.EmptyProto, error) { return new(examples.EmptyProto), nil } func (s flowCombinationServer) RpcBodyStream(req *examples.NonEmptyProto, stream examples.FlowCombination_RpcBodyStreamServer) error { return stream.Send(new(examples.EmptyProto)) } func (s flowCombinationServer) RpcPathSingleNestedStream(req *examples.SingleNestedProto, stream examples.FlowCombination_RpcPathSingleNestedStreamServer) error { return stream.Send(new(examples.EmptyProto)) } func (s flowCombinationServer) RpcPathNestedStream(req *examples.NestedProto, stream examples.FlowCombination_RpcPathNestedStreamServer) error { return stream.Send(new(examples.EmptyProto)) } ================================================ FILE: examples/internal/server/main.go ================================================ package server import ( "context" "net" "net/http" examples "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb" standalone "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/standalone" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "google.golang.org/grpc" "google.golang.org/grpc/grpclog" ) // Run starts the example gRPC service. // "network" and "address" are passed to net.Listen. func Run(ctx context.Context, network, address string) error { l, err := net.Listen(network, address) if err != nil { return err } defer func() { if err := l.Close(); err != nil { grpclog.Errorf("Failed to close %s %s: %v", network, address, err) } }() s := grpc.NewServer() examples.RegisterEchoServiceServer(s, newEchoServer()) examples.RegisterFlowCombinationServer(s, newFlowCombinationServer()) examples.RegisterExcessBodyServiceServer(s, newExcessBodyServer()) examples.RegisterNonStandardServiceServer(s, newNonStandardServer()) examples.RegisterUnannotatedEchoServiceServer(s, newUnannotatedEchoServer()) abe := newABitOfEverythingServer() examples.RegisterABitOfEverythingServiceServer(s, abe) examples.RegisterStreamServiceServer(s, abe) examples.RegisterResponseBodyServiceServer(s, newResponseBodyServer()) go func() { defer s.GracefulStop() <-ctx.Done() }() return s.Serve(l) } // RunInProcessGateway starts the invoke in process http gateway. func RunInProcessGateway(ctx context.Context, addr string, opts ...runtime.ServeMuxOption) error { mux := runtime.NewServeMux(opts...) examples.RegisterEchoServiceHandlerServer(ctx, mux, newEchoServer()) examples.RegisterFlowCombinationHandlerServer(ctx, mux, newFlowCombinationServer()) examples.RegisterExcessBodyServiceHandlerServer(ctx, mux, newExcessBodyServer()) examples.RegisterNonStandardServiceHandlerServer(ctx, mux, newNonStandardServer()) standalone.RegisterUnannotatedEchoServiceHandlerServer(ctx, mux, newUnannotatedEchoServer()) abe := newABitOfEverythingServer() examples.RegisterABitOfEverythingServiceHandlerServer(ctx, mux, abe) examples.RegisterStreamServiceHandlerServer(ctx, mux, abe) examples.RegisterResponseBodyServiceHandlerServer(ctx, mux, newResponseBodyServer()) s := &http.Server{ Addr: addr, Handler: mux, } go func() { <-ctx.Done() grpclog.Infof("Shutting down the http gateway server") if err := s.Shutdown(context.Background()); err != nil { grpclog.Errorf("Failed to shutdown http gateway server: %v", err) } }() if err := s.ListenAndServe(); err != http.ErrServerClosed { grpclog.Errorf("Failed to listen and serve: %v", err) return err } return nil } ================================================ FILE: examples/internal/server/non_standard_names.go ================================================ package server import ( "context" examples "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb" "google.golang.org/grpc/grpclog" ) // Implements NonStandardServiceServer type nonStandardServer struct{} func newNonStandardServer() examples.NonStandardServiceServer { return new(nonStandardServer) } func (s *nonStandardServer) Update(ctx context.Context, msg *examples.NonStandardUpdateRequest) (*examples.NonStandardMessage, error) { grpclog.Info(msg) newMsg := &examples.NonStandardMessage{ Thing: &examples.NonStandardMessage_Thing{SubThing: &examples.NonStandardMessage_Thing_SubThing{}}, // The fieldmask_helper doesn't generate nested structs if they are nil } applyFieldMask(newMsg, msg.Body, msg.UpdateMask) grpclog.Info(newMsg) return newMsg, nil } func (s *nonStandardServer) UpdateWithJSONNames(ctx context.Context, msg *examples.NonStandardWithJSONNamesUpdateRequest) (*examples.NonStandardMessageWithJSONNames, error) { grpclog.Info(msg) newMsg := &examples.NonStandardMessageWithJSONNames{ Thing: &examples.NonStandardMessageWithJSONNames_Thing{SubThing: &examples.NonStandardMessageWithJSONNames_Thing_SubThing{}}, // The fieldmask_helper doesn't generate nested structs if they are nil } applyFieldMask(newMsg, msg.Body, msg.UpdateMask) grpclog.Info(newMsg) return newMsg, nil } ================================================ FILE: examples/internal/server/responsebody.go ================================================ package server import ( "context" "fmt" examples "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb" ) // Implements of ResponseBodyServiceServer type responseBodyServer struct{} func newResponseBodyServer() examples.ResponseBodyServiceServer { return new(responseBodyServer) } func (s *responseBodyServer) GetResponseBody(ctx context.Context, req *examples.ResponseBodyIn) (*examples.ResponseBodyOut, error) { return &examples.ResponseBodyOut{ Response: &examples.ResponseBodyOut_Response{ Data: req.Data, }, }, nil } func (s *responseBodyServer) ListResponseBodies(ctx context.Context, req *examples.ResponseBodyIn) (*examples.RepeatedResponseBodyOut, error) { return &examples.RepeatedResponseBodyOut{ Response: []*examples.RepeatedResponseBodyOut_Response{ { Data: req.Data, }, }, }, nil } func (s *responseBodyServer) ListResponseStrings(ctx context.Context, req *examples.ResponseBodyIn) (*examples.RepeatedResponseStrings, error) { if req.Data == "empty" { return &examples.RepeatedResponseStrings{ Values: []string{}, }, nil } return &examples.RepeatedResponseStrings{ Values: []string{"hello", req.Data}, }, nil } func (s *responseBodyServer) GetResponseBodyStream(req *examples.ResponseBodyIn, stream examples.ResponseBodyService_GetResponseBodyStreamServer) error { if err := stream.Send(&examples.ResponseBodyOut{ Response: &examples.ResponseBodyOut_Response{ Data: fmt.Sprintf("first %s", req.Data), }, }); err != nil { return err } return stream.Send(&examples.ResponseBodyOut{ Response: &examples.ResponseBodyOut_Response{ Data: fmt.Sprintf("second %s", req.Data), }, }) } func (s *responseBodyServer) GetResponseBodySameName(ctx context.Context, req *examples.ResponseBodyIn) (*examples.ResponseBodyValue, error) { return &examples.ResponseBodyValue{ ResponseBodyValue: req.Data, }, nil } ================================================ FILE: examples/internal/server/unannotatedecho.go ================================================ package server import ( "context" examples "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb" "google.golang.org/grpc" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" ) // Implements of UnannotatedEchoServiceServer type unannotatedEchoServer struct{} func newUnannotatedEchoServer() examples.UnannotatedEchoServiceServer { return new(unannotatedEchoServer) } func (s *unannotatedEchoServer) Echo(ctx context.Context, msg *examples.UnannotatedSimpleMessage) (*examples.UnannotatedSimpleMessage, error) { grpclog.Info(msg) return msg, nil } func (s *unannotatedEchoServer) EchoBody(ctx context.Context, msg *examples.UnannotatedSimpleMessage) (*examples.UnannotatedSimpleMessage, error) { grpclog.Info(msg) grpc.SendHeader(ctx, metadata.New(map[string]string{ "foo": "foo1", "bar": "bar1", })) grpc.SetTrailer(ctx, metadata.New(map[string]string{ "foo": "foo2", "bar": "bar2", })) return msg, nil } func (s *unannotatedEchoServer) EchoDelete(ctx context.Context, msg *examples.UnannotatedSimpleMessage) (*examples.UnannotatedSimpleMessage, error) { grpclog.Info(msg) return msg, nil } func (s *unannotatedEchoServer) EchoNested(ctx context.Context, msg *examples.UnannotatedSimpleMessage) (*examples.UnannotatedSimpleMessage, error) { grpclog.Info(msg) return msg, nil } ================================================ FILE: go.mod ================================================ module github.com/grpc-ecosystem/grpc-gateway/v2 go 1.25.0 require ( github.com/antihax/optional v1.0.0 github.com/google/go-cmp v0.7.0 github.com/rogpeppe/fastuuid v1.2.0 go.yaml.in/yaml/v3 v3.0.4 golang.org/x/oauth2 v0.36.0 golang.org/x/text v0.35.0 google.golang.org/genproto/googleapis/api v0.0.0-20260319201613-d00831a3d3e7 google.golang.org/genproto/googleapis/rpc v0.0.0-20260319201613-d00831a3d3e7 google.golang.org/grpc v1.79.3 google.golang.org/protobuf v1.36.11 ) require ( github.com/kr/pretty v0.3.1 // indirect golang.org/x/net v0.48.0 // indirect golang.org/x/sys v0.39.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect ) ================================================ FILE: go.sum ================================================ github.com/antihax/optional v1.0.0 h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwcg= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/rogpeppe/fastuuid v1.2.0 h1:Ppwyp6VYCF1nvBTXL3trRso7mXMlRrw9ooo375wvi2s= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48= go.opentelemetry.io/otel v1.39.0/go.mod h1:kLlFTywNWrFyEdH0oj2xK0bFYZtHRYUdv1NklR/tgc8= go.opentelemetry.io/otel/metric v1.39.0 h1:d1UzonvEZriVfpNKEVmHXbdf909uGTOQjA0HF0Ls5Q0= go.opentelemetry.io/otel/metric v1.39.0/go.mod h1:jrZSWL33sD7bBxg1xjrqyDjnuzTUB0x1nBERXd7Ftcs= go.opentelemetry.io/otel/sdk v1.39.0 h1:nMLYcjVsvdui1B/4FRkwjzoRVsMK8uL/cj0OyhKzt18= go.opentelemetry.io/otel/sdk v1.39.0/go.mod h1:vDojkC4/jsTJsE+kh+LXYQlbL8CgrEcwmt1ENZszdJE= go.opentelemetry.io/otel/sdk/metric v1.39.0 h1:cXMVVFVgsIf2YL6QkRF4Urbr/aMInf+2WKg+sEJTtB8= go.opentelemetry.io/otel/sdk/metric v1.39.0/go.mod h1:xq9HEVH7qeX69/JnwEfp6fVq5wosJsY1mt4lLfYdVew= go.opentelemetry.io/otel/trace v1.39.0 h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6/qCJI= go.opentelemetry.io/otel/trace v1.39.0/go.mod h1:88w4/PnZSazkGzz/w84VHpQafiU4EtqqlVdxWy+rNOA= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs= golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q= golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8= golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/api v0.0.0-20260319201613-d00831a3d3e7 h1:41r6JMbpzBMen0R/4TZeeAmGXSJC7DftGINUodzTkPI= google.golang.org/genproto/googleapis/api v0.0.0-20260319201613-d00831a3d3e7/go.mod h1:EIQZ5bFCfRQDV4MhRle7+OgjNtZ6P1PiZBgAKuxXu/Y= google.golang.org/genproto/googleapis/rpc v0.0.0-20260319201613-d00831a3d3e7 h1:ndE4FoJqsIceKP2oYSnUZqhTdYufCYYkqwtFzfrhI7w= google.golang.org/genproto/googleapis/rpc v0.0.0-20260319201613-d00831a3d3e7/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= google.golang.org/grpc v1.79.3 h1:sybAEdRIEtvcD68Gx7dmnwjZKlyfuc61Dyo9pGXXkKE= google.golang.org/grpc v1.79.3/go.mod h1:KmT0Kjez+0dde/v2j9vzwoAScgEPx/Bw1CYChhHLrHQ= google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= ================================================ FILE: internal/casing/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "casing", srcs = ["camel.go"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/internal/casing", visibility = ["//:__subpackages__"], ) alias( name = "go_default_library", actual = ":casing", visibility = ["//:__subpackages__"], ) go_test( name = "casing_test", srcs = ["camel_test.go"], embed = [":casing"], ) ================================================ FILE: internal/casing/LICENSE.md ================================================ Copyright 2010, 2019 The Go Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: internal/casing/README.md ================================================ # Case conversion This package contains two functions: - `Camel` copied from the `github.com/golang/protobuf/protoc-gen-go/generator` package. - `JSONCamelCase` copied from the `github.com/protocolbuffers/protobuf-go/internal/strs` package. Both these modules are licensed by The Go Authors, as reflected in this package's [LICENSE.md]. ================================================ FILE: internal/casing/camel.go ================================================ package casing import ( "path/filepath" "strings" ) // Camel returns the CamelCased name. // // This was moved from the now deprecated github.com/golang/protobuf/protoc-gen-go/generator package // // If there is an interior underscore followed by a lower case letter, // drop the underscore and convert the letter to upper case. // There is a remote possibility of this rewrite causing a name collision, // but it's so remote we're prepared to pretend it's nonexistent - since the // C++ generator lowercases names, it's extremely unlikely to have two fields // with different capitalizations. // In short, _my_field_name_2 becomes XMyFieldName_2. func Camel(s string) string { if s == "" { return "" } t := make([]byte, 0, 32) i := 0 if s[0] == '_' { // Need a capital letter; drop the '_'. t = append(t, 'X') i++ } // Invariant: if the next letter is lower case, it must be converted // to upper case. // That is, we process a word at a time, where words are marked by _ or // upper case letter. Digits are treated as words. for ; i < len(s); i++ { c := s[i] if c == '_' && i+1 < len(s) && isASCIILower(s[i+1]) { continue // Skip the underscore in s. } if isASCIIDigit(c) { t = append(t, c) continue } // Assume we have a letter now - if not, it's a bogus identifier. // The next word is a sequence of characters that must start upper case. if isASCIILower(c) { c ^= ' ' // Make it a capital letter. } t = append(t, c) // Guaranteed not lower case. // Accept lower case sequence that follows. for i+1 < len(s) && isASCIILower(s[i+1]) { i++ t = append(t, s[i]) } } return string(t) } // CamelIdentifier returns the CamelCased identifier without affecting the package name/path if any. func CamelIdentifier(s string) string { const dot = "." if !strings.Contains(s, dot) { return Camel(s) } identifier := filepath.Ext(s) path := strings.TrimSuffix(s, identifier) identifier = strings.TrimPrefix(identifier, dot) return path + dot + Camel(identifier) } // JSONCamelCase converts a snake_case identifier to a camelCase identifier, // according to the protobuf JSON specification. func JSONCamelCase(s string) string { var b []byte var wasUnderscore bool for i := 0; i < len(s); i++ { // proto identifiers are always ASCII c := s[i] if c != '_' { if wasUnderscore && isASCIILower(c) { c -= 'a' - 'A' // convert to uppercase } b = append(b, c) } wasUnderscore = c == '_' } return string(b) } // And now lots of helper functions. // Is c an ASCII lower-case letter? func isASCIILower(c byte) bool { return 'a' <= c && c <= 'z' } // Is c an ASCII digit? func isASCIIDigit(c byte) bool { return '0' <= c && c <= '9' } ================================================ FILE: internal/casing/camel_test.go ================================================ package casing import "testing" func TestCamelIdentifier(t *testing.T) { casingTests := []struct { name string input string want string }{ { "regular snake case identifier", "snake_case", "SnakeCase", }, { "snake case identifier with digit", "snake_case_0_enum", "SnakeCase_0Enum", }, { "regular snake case identifier with package", "pathenum.snake_case", "pathenum.SnakeCase", }, { "snake case identifier with digit and package", "pathenum.snake_case_0_enum", "pathenum.SnakeCase_0Enum", }, { "snake case identifier with digit and multiple dots", "path.pathenum.snake_case_0_enum", "path.pathenum.SnakeCase_0Enum", }, } for _, ct := range casingTests { t.Run(ct.name, func(t *testing.T) { got := CamelIdentifier(ct.input) if ct.want != got { t.Errorf("want: %s, got: %s", ct.want, got) } }) } } ================================================ FILE: internal/codegenerator/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") package(default_visibility = ["//visibility:public"]) go_library( name = "codegenerator", srcs = [ "doc.go", "parse_req.go", "supported_features.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/internal/codegenerator", deps = [ "@org_golang_google_protobuf//compiler/protogen", "@org_golang_google_protobuf//proto", "@org_golang_google_protobuf//types/descriptorpb", "@org_golang_google_protobuf//types/pluginpb", ], ) go_test( name = "codegenerator_test", srcs = ["parse_req_test.go"], deps = [ ":codegenerator", "@com_github_google_go_cmp//cmp", "@org_golang_google_protobuf//proto", "@org_golang_google_protobuf//testing/protocmp", "@org_golang_google_protobuf//types/pluginpb", ], ) alias( name = "go_default_library", actual = ":codegenerator", visibility = ["//:__subpackages__"], ) ================================================ FILE: internal/codegenerator/doc.go ================================================ /* Package codegenerator contains reusable functions used by the code generators. */ package codegenerator ================================================ FILE: internal/codegenerator/parse_req.go ================================================ package codegenerator import ( "fmt" "io" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/pluginpb" ) // ParseRequest parses a code generator request from a proto Message. func ParseRequest(r io.Reader) (*pluginpb.CodeGeneratorRequest, error) { input, err := io.ReadAll(r) if err != nil { return nil, fmt.Errorf("failed to read code generator request: %w", err) } req := new(pluginpb.CodeGeneratorRequest) if err := proto.Unmarshal(input, req); err != nil { return nil, fmt.Errorf("failed to unmarshal code generator request: %w", err) } return req, nil } ================================================ FILE: internal/codegenerator/parse_req_test.go ================================================ package codegenerator_test import ( "bytes" "errors" "io" "strings" "testing" "github.com/google/go-cmp/cmp" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/codegenerator" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/testing/protocmp" "google.golang.org/protobuf/types/pluginpb" ) var parseReqTests = []struct { name string in io.Reader out *pluginpb.CodeGeneratorRequest expectErr bool }{ { "Empty input should produce empty output", mustGetReader(&pluginpb.CodeGeneratorRequest{}), &pluginpb.CodeGeneratorRequest{}, false, }, { "Invalid reader should produce error", &invalidReader{}, nil, true, }, { "Invalid proto message should produce error", strings.NewReader("{}"), nil, true, }, } func TestParseRequest(t *testing.T) { for _, tt := range parseReqTests { t.Run(tt.name, func(t *testing.T) { out, err := codegenerator.ParseRequest(tt.in) if tt.expectErr && err == nil { t.Error("did not error as expected") } if diff := cmp.Diff(out, tt.out, protocmp.Transform()); diff != "" { t.Error(diff) } }) } } func mustGetReader(pb proto.Message) io.Reader { b, err := proto.Marshal(pb) if err != nil { panic(err) } return bytes.NewBuffer(b) } type invalidReader struct { } func (*invalidReader) Read(p []byte) (int, error) { return 0, errors.New("invalid reader") } ================================================ FILE: internal/codegenerator/supported_features.go ================================================ package codegenerator import ( "google.golang.org/protobuf/compiler/protogen" "google.golang.org/protobuf/types/descriptorpb" "google.golang.org/protobuf/types/pluginpb" ) func supportedCodeGeneratorFeatures() uint64 { // Enable support for Protobuf Editions return uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL | pluginpb.CodeGeneratorResponse_FEATURE_SUPPORTS_EDITIONS) } func supportedEditions() (descriptorpb.Edition, descriptorpb.Edition) { // Declare support for edition 2023 only return descriptorpb.Edition_EDITION_2023, descriptorpb.Edition_EDITION_2023 } // SetSupportedFeaturesOnPluginGen sets supported proto3 features // on protogen.Plugin. func SetSupportedFeaturesOnPluginGen(gen *protogen.Plugin) { gen.SupportedFeatures = supportedCodeGeneratorFeatures() gen.SupportedEditionsMinimum, gen.SupportedEditionsMaximum = supportedEditions() } // SetSupportedFeaturesOnCodeGeneratorResponse sets supported proto3 features // on pluginpb.CodeGeneratorResponse. func SetSupportedFeaturesOnCodeGeneratorResponse(resp *pluginpb.CodeGeneratorResponse) { sf := supportedCodeGeneratorFeatures() resp.SupportedFeatures = &sf minE, maxE := supportedEditions() minEN, maxEN := int32(minE.Number()), int32(maxE.Number()) resp.MinimumEdition, resp.MaximumEdition = &minEN, &maxEN } ================================================ FILE: internal/descriptor/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") package(default_visibility = ["//visibility:public"]) go_library( name = "descriptor", srcs = [ "grpc_api_configuration.go", "openapi_configuration.go", "registry.go", "services.go", "types.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor", deps = [ "//internal/casing", "//internal/codegenerator", "//internal/descriptor/apiconfig", "//internal/descriptor/openapiconfig", "//internal/httprule", "//protoc-gen-openapiv2/options", "@in_yaml_go_yaml_v3//:yaml", "@org_golang_google_genproto_googleapis_api//annotations", "@org_golang_google_grpc//grpclog", "@org_golang_google_protobuf//compiler/protogen", "@org_golang_google_protobuf//encoding/protojson", "@org_golang_google_protobuf//proto", "@org_golang_google_protobuf//types/descriptorpb", "@org_golang_google_protobuf//types/pluginpb", "@org_golang_x_text//cases", "@org_golang_x_text//language", ], ) go_test( name = "descriptor_test", size = "small", srcs = [ "grpc_api_configuration_test.go", "openapi_configuration_test.go", "registry_test.go", "services_test.go", "types_test.go", ], embed = [":descriptor"], deps = [ "//internal/descriptor/openapiconfig", "//internal/httprule", "//protoc-gen-openapiv2/options", "@org_golang_google_protobuf//compiler/protogen", "@org_golang_google_protobuf//encoding/prototext", "@org_golang_google_protobuf//proto", "@org_golang_google_protobuf//types/descriptorpb", "@org_golang_google_protobuf//types/pluginpb", ], ) alias( name = "go_default_library", actual = ":descriptor", visibility = ["//:__subpackages__"], ) ================================================ FILE: internal/descriptor/apiconfig/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library") load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") load("@rules_proto//proto:defs.bzl", "proto_library") package(default_visibility = ["//visibility:public"]) proto_library( name = "apiconfig_proto", srcs = [ "apiconfig.proto", ], deps = ["@googleapis//google/api:http_proto"], ) go_proto_library( name = "apiconfig_go_proto", compilers = ["//:go_apiv2"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor/apiconfig", proto = ":apiconfig_proto", deps = ["@org_golang_google_genproto_googleapis_api//annotations"], ) go_library( name = "apiconfig", embed = [":apiconfig_go_proto"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor/apiconfig", ) alias( name = "go_default_library", actual = ":apiconfig", visibility = ["//:__subpackages__"], ) ================================================ FILE: internal/descriptor/apiconfig/apiconfig.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: internal/descriptor/apiconfig/apiconfig.proto package apiconfig import ( annotations "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) // GrpcAPIService represents a stripped down version of google.api.Service . // Compare to https://github.com/googleapis/googleapis/blob/master/google/api/service.proto // The original imports 23 other protobuf files we are not interested in. If a significant // subset (>50%) of these start being reproduced in this file we should swap to using the // full generated version instead. // // For the purposes of the gateway generator we only consider a small subset of all // available features google supports in their service descriptions. Thanks to backwards // compatibility guarantees by protobuf it is safe for us to remove the other fields. type GrpcAPIService struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Http Rule. Http *annotations.Http `protobuf:"bytes,1,opt,name=http,proto3" json:"http,omitempty"` } func (x *GrpcAPIService) Reset() { *x = GrpcAPIService{} mi := &file_internal_descriptor_apiconfig_apiconfig_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *GrpcAPIService) String() string { return protoimpl.X.MessageStringOf(x) } func (*GrpcAPIService) ProtoMessage() {} func (x *GrpcAPIService) ProtoReflect() protoreflect.Message { mi := &file_internal_descriptor_apiconfig_apiconfig_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use GrpcAPIService.ProtoReflect.Descriptor instead. func (*GrpcAPIService) Descriptor() ([]byte, []int) { return file_internal_descriptor_apiconfig_apiconfig_proto_rawDescGZIP(), []int{0} } func (x *GrpcAPIService) GetHttp() *annotations.Http { if x != nil { return x.Http } return nil } var File_internal_descriptor_apiconfig_apiconfig_proto protoreflect.FileDescriptor var file_internal_descriptor_apiconfig_apiconfig_proto_rawDesc = []byte{ 0x0a, 0x2d, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x61, 0x70, 0x69, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2a, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x61, 0x70, 0x69, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x1a, 0x15, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x36, 0x0a, 0x0e, 0x47, 0x72, 0x70, 0x63, 0x41, 0x50, 0x49, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x24, 0x0a, 0x04, 0x68, 0x74, 0x74, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x48, 0x74, 0x74, 0x70, 0x52, 0x04, 0x68, 0x74, 0x74, 0x70, 0x42, 0x49, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_internal_descriptor_apiconfig_apiconfig_proto_rawDescOnce sync.Once file_internal_descriptor_apiconfig_apiconfig_proto_rawDescData = file_internal_descriptor_apiconfig_apiconfig_proto_rawDesc ) func file_internal_descriptor_apiconfig_apiconfig_proto_rawDescGZIP() []byte { file_internal_descriptor_apiconfig_apiconfig_proto_rawDescOnce.Do(func() { file_internal_descriptor_apiconfig_apiconfig_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_descriptor_apiconfig_apiconfig_proto_rawDescData) }) return file_internal_descriptor_apiconfig_apiconfig_proto_rawDescData } var file_internal_descriptor_apiconfig_apiconfig_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_internal_descriptor_apiconfig_apiconfig_proto_goTypes = []any{ (*GrpcAPIService)(nil), // 0: grpc.gateway.internal.descriptor.apiconfig.GrpcAPIService (*annotations.Http)(nil), // 1: google.api.Http } var file_internal_descriptor_apiconfig_apiconfig_proto_depIdxs = []int32{ 1, // 0: grpc.gateway.internal.descriptor.apiconfig.GrpcAPIService.http:type_name -> google.api.Http 1, // [1:1] is the sub-list for method output_type 1, // [1:1] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension extendee 0, // [0:1] is the sub-list for field type_name } func init() { file_internal_descriptor_apiconfig_apiconfig_proto_init() } func file_internal_descriptor_apiconfig_apiconfig_proto_init() { if File_internal_descriptor_apiconfig_apiconfig_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_internal_descriptor_apiconfig_apiconfig_proto_rawDesc, NumEnums: 0, NumMessages: 1, NumExtensions: 0, NumServices: 0, }, GoTypes: file_internal_descriptor_apiconfig_apiconfig_proto_goTypes, DependencyIndexes: file_internal_descriptor_apiconfig_apiconfig_proto_depIdxs, MessageInfos: file_internal_descriptor_apiconfig_apiconfig_proto_msgTypes, }.Build() File_internal_descriptor_apiconfig_apiconfig_proto = out.File file_internal_descriptor_apiconfig_apiconfig_proto_rawDesc = nil file_internal_descriptor_apiconfig_apiconfig_proto_goTypes = nil file_internal_descriptor_apiconfig_apiconfig_proto_depIdxs = nil } ================================================ FILE: internal/descriptor/apiconfig/apiconfig.proto ================================================ syntax = "proto3"; package grpc.gateway.internal.descriptor.apiconfig; import "google/api/http.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor/apiconfig"; // GrpcAPIService represents a stripped down version of google.api.Service . // Compare to https://github.com/googleapis/googleapis/blob/master/google/api/service.proto // The original imports 23 other protobuf files we are not interested in. If a significant // subset (>50%) of these start being reproduced in this file we should swap to using the // full generated version instead. // // For the purposes of the gateway generator we only consider a small subset of all // available features google supports in their service descriptions. Thanks to backwards // compatibility guarantees by protobuf it is safe for us to remove the other fields. message GrpcAPIService { // Http Rule. google.api.Http http = 1; } ================================================ FILE: internal/descriptor/apiconfig/apiconfig.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "internal/descriptor/apiconfig/apiconfig.proto", "version": "version not set" }, "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": {}, "definitions": { "protobufAny": { "type": "object", "properties": { "@type": { "type": "string" } }, "additionalProperties": {} }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } } } } ================================================ FILE: internal/descriptor/grpc_api_configuration.go ================================================ package descriptor import ( "encoding/json" "fmt" "os" "strings" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor/apiconfig" "go.yaml.in/yaml/v3" "google.golang.org/protobuf/encoding/protojson" ) func loadGrpcAPIServiceFromYAML(yamlFileContents []byte, yamlSourceLogName string) (*apiconfig.GrpcAPIService, error) { var yamlContents interface{} if err := yaml.Unmarshal(yamlFileContents, &yamlContents); err != nil { return nil, fmt.Errorf("failed to parse gRPC API Configuration from YAML in %q: %w", yamlSourceLogName, err) } jsonContents, err := json.Marshal(yamlContents) if err != nil { return nil, err } // As our GrpcAPIService is incomplete, accept unknown fields. unmarshaler := protojson.UnmarshalOptions{ DiscardUnknown: true, } serviceConfiguration := apiconfig.GrpcAPIService{} if err := unmarshaler.Unmarshal(jsonContents, &serviceConfiguration); err != nil { return nil, fmt.Errorf("failed to parse gRPC API Configuration from YAML in %q: %w", yamlSourceLogName, err) } return &serviceConfiguration, nil } func registerHTTPRulesFromGrpcAPIService(registry *Registry, service *apiconfig.GrpcAPIService, sourceLogName string) error { if service.Http == nil { // Nothing to do return nil } for _, rule := range service.Http.GetRules() { selector := "." + strings.Trim(rule.GetSelector(), " ") if strings.ContainsAny(selector, "*, ") { return fmt.Errorf("selector %q in %v must specify a single service method without wildcards", rule.GetSelector(), sourceLogName) } registry.AddExternalHTTPRule(selector, rule) } return nil } // LoadGrpcAPIServiceFromYAML loads a gRPC API Configuration from the given YAML file // and registers the HttpRule descriptions contained in it as externalHTTPRules in // the given registry. This must be done before loading the proto file. // // You can learn more about gRPC API Service descriptions from Google's documentation // at https://cloud.google.com/endpoints/docs/grpc/grpc-service-config // // Note that for the purposes of the gateway generator we only consider a subset of all // available features google supports in their service descriptions. func (r *Registry) LoadGrpcAPIServiceFromYAML(yamlFile string) error { yamlFileContents, err := os.ReadFile(yamlFile) if err != nil { return fmt.Errorf("failed to read gRPC API Configuration description from %q: %w", yamlFile, err) } service, err := loadGrpcAPIServiceFromYAML(yamlFileContents, yamlFile) if err != nil { return err } return registerHTTPRulesFromGrpcAPIService(r, service, yamlFile) } ================================================ FILE: internal/descriptor/grpc_api_configuration_test.go ================================================ package descriptor import ( "strings" "testing" ) func TestLoadGrpcAPIServiceFromYAMLInvalidType(t *testing.T) { // Ideally this would fail but for now this test documents that it doesn't service, err := loadGrpcAPIServiceFromYAML([]byte(`type: not.the.right.type`), "invalidtype") if err != nil { t.Fatal(err) } if service == nil { t.Fatal("No service returned") } } func TestLoadGrpcAPIServiceFromYAMLSingleRule(t *testing.T) { service, err := loadGrpcAPIServiceFromYAML([]byte(` type: google.api.Service config_version: 3 http: rules: - selector: grpctest.YourService.Echo post: /v1/myecho body: "*" `), "example") if err != nil { t.Fatal(err) } if service.Http == nil { t.Fatal("HTTP is empty") } if len(service.Http.GetRules()) != 1 { t.Fatalf("Have %v rules instead of one. Got: %v", len(service.Http.GetRules()), service.Http.GetRules()) } rule := service.Http.GetRules()[0] if rule.GetSelector() != "grpctest.YourService.Echo" { t.Errorf("Rule has unexpected selector '%v'", rule.GetSelector()) } if rule.GetPost() != "/v1/myecho" { t.Errorf("Rule has unexpected post '%v'", rule.GetPost()) } if rule.GetBody() != "*" { t.Errorf("Rule has unexpected body '%v'", rule.GetBody()) } } func TestLoadGrpcAPIServiceFromYAMLRejectInvalidYAML(t *testing.T) { service, err := loadGrpcAPIServiceFromYAML([]byte(` type: google.api.Service config_version: 3 http: rules: - selector: grpctest.YourService.Echo - post: thislinebreakstheselectorblockabovewiththeleadingdash body: "*" `), "invalidyaml") if err == nil { t.Fatal(err) } if !strings.Contains(err.Error(), "line 6") { t.Errorf("Expected yaml error to be detected in line 6. Got other error: %v", err) } if service != nil { t.Fatal("Service returned") } } func TestLoadGrpcAPIServiceFromYAMLMultipleWithAdditionalBindings(t *testing.T) { service, err := loadGrpcAPIServiceFromYAML([]byte(` type: google.api.Service config_version: 3 http: rules: - selector: first.selector post: /my/post/path body: "*" additional_bindings: - post: /additional/post/path - put: /additional/put/{value}/path - delete: "{value}" - patch: "/additional/patch/{value}" - selector: some.other.service delete: foo `), "example") if err != nil { t.Fatalf("Failed to load service description from YAML: %v", err) } if service == nil { t.Fatal("No service returned") } if service.Http == nil { t.Fatal("HTTP is empty") } if len(service.Http.GetRules()) != 2 { t.Fatalf("%v service(s) returned when two were expected. Got: %v", len(service.Http.GetRules()), service.Http) } first := service.Http.GetRules()[0] if first.GetSelector() != "first.selector" { t.Errorf("first.selector has unexpected selector '%v'", first.GetSelector()) } if first.GetBody() != "*" { t.Errorf("first.selector has unexpected body '%v'", first.GetBody()) } if first.GetPost() != "/my/post/path" { t.Errorf("first.selector has unexpected post '%v'", first.GetPost()) } if len(first.GetAdditionalBindings()) != 4 { t.Fatalf("first.selector has unexpected number of bindings %v instead of four. Got: %v", len(first.GetAdditionalBindings()), first.GetAdditionalBindings()) } if first.GetAdditionalBindings()[0].GetPost() != "/additional/post/path" { t.Errorf("first.selector additional binding 0 has unexpected post '%v'", first.GetAdditionalBindings()[0].GetPost()) } if first.GetAdditionalBindings()[1].GetPut() != "/additional/put/{value}/path" { t.Errorf("first.selector additional binding 1 has unexpected put '%v'", first.GetAdditionalBindings()[0].GetPost()) } if first.GetAdditionalBindings()[2].GetDelete() != "{value}" { t.Errorf("first.selector additional binding 2 has unexpected delete '%v'", first.GetAdditionalBindings()[0].GetPost()) } if first.GetAdditionalBindings()[3].GetPatch() != "/additional/patch/{value}" { t.Errorf("first.selector additional binding 3 has unexpected patch '%v'", first.GetAdditionalBindings()[0].GetPost()) } second := service.Http.GetRules()[1] if second.GetSelector() != "some.other.service" { t.Errorf("some.other.service has unexpected selector '%v'", second.GetSelector()) } if second.GetDelete() != "foo" { t.Errorf("some.other.service has unexpected delete '%v'", second.GetDelete()) } if len(second.GetAdditionalBindings()) != 0 { t.Errorf("some.other.service has %v additional bindings when it should not have any. Got: %v", len(second.GetAdditionalBindings()), second.GetAdditionalBindings()) } } func TestLoadGrpcAPIServiceFromYAMLUnknownKeys(t *testing.T) { service, err := loadGrpcAPIServiceFromYAML([]byte(` type: google.api.Service config_version: 3 very: key much: 1 http: rules: - selector: some.other.service delete: foo invalidkey: yes `), "example") if err != nil { t.Fatalf("Failed to load service description from YAML: %v", err) } if service == nil { t.Fatal("No service returned") } if service.Http == nil { t.Fatal("HTTP is empty") } if len(service.Http.GetRules()) != 1 { t.Fatalf("%v service(s) returned when two were expected. Got: %v", len(service.Http.GetRules()), service.Http) } first := service.Http.GetRules()[0] if first.GetSelector() != "some.other.service" { t.Errorf("first.selector has unexpected selector '%v'", first.GetSelector()) } if first.GetDelete() != "foo" { t.Errorf("first.selector has unexpected delete '%v'", first.GetPost()) } } ================================================ FILE: internal/descriptor/openapi_configuration.go ================================================ package descriptor import ( "encoding/json" "fmt" "os" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor/openapiconfig" "go.yaml.in/yaml/v3" "google.golang.org/protobuf/encoding/protojson" ) func loadOpenAPIConfigFromYAML(yamlFileContents []byte, yamlSourceLogName string) (*openapiconfig.OpenAPIConfig, error) { var yamlContents interface{} if err := yaml.Unmarshal(yamlFileContents, &yamlContents); err != nil { return nil, fmt.Errorf("failed to parse gRPC API Configuration from YAML in %q: %w", yamlSourceLogName, err) } jsonContents, err := json.Marshal(yamlContents) if err != nil { return nil, err } // Reject unknown fields because OpenAPIConfig is only used here unmarshaler := protojson.UnmarshalOptions{ DiscardUnknown: false, } openapiConfiguration := openapiconfig.OpenAPIConfig{} if err := unmarshaler.Unmarshal(jsonContents, &openapiConfiguration); err != nil { return nil, fmt.Errorf("failed to parse OpenAPI Configuration from YAML in %q: %w", yamlSourceLogName, err) } return &openapiConfiguration, nil } func registerOpenAPIOptions(registry *Registry, openAPIConfig *openapiconfig.OpenAPIConfig, yamlSourceLogName string) error { if openAPIConfig.OpenapiOptions == nil { // Nothing to do return nil } if err := registry.RegisterOpenAPIOptions(openAPIConfig.OpenapiOptions); err != nil { return fmt.Errorf("failed to register option in %s: %w", yamlSourceLogName, err) } return nil } // LoadOpenAPIConfigFromYAML loads an OpenAPI Configuration from the given YAML file // and registers the OpenAPI options the given registry. // This must be done after loading the proto file. func (r *Registry) LoadOpenAPIConfigFromYAML(yamlFile string) error { yamlFileContents, err := os.ReadFile(yamlFile) if err != nil { return fmt.Errorf("failed to read OpenAPI Configuration description from %q: %w", yamlFile, err) } config, err := loadOpenAPIConfigFromYAML(yamlFileContents, yamlFile) if err != nil { return err } return registerOpenAPIOptions(r, config, yamlFile) } ================================================ FILE: internal/descriptor/openapi_configuration_test.go ================================================ package descriptor import ( "strings" "testing" "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" ) func TestLoadOpenAPIConfigFromYAMLRejectInvalidYAML(t *testing.T) { config, err := loadOpenAPIConfigFromYAML([]byte(` openapiOptions: file: - file: test.proto - option: schemes: - HTTP - HTTPS - WSS securityDefinitions: security: ApiKeyAuth: type: TYPE_API_KEY in: IN_HEADER name: "X-API-Key" `), "invalidyaml") if err == nil { t.Fatal(err) } if !strings.Contains(err.Error(), "line 3") { t.Errorf("Expected yaml error to be detected in line 3. Got other error: %v", err) } if config != nil { t.Fatal("Config returned") } } func TestLoadOpenAPIConfigFromYAML(t *testing.T) { config, err := loadOpenAPIConfigFromYAML([]byte(` openapiOptions: file: - file: test.proto option: schemes: - HTTP - HTTPS - WSS securityDefinitions: security: ApiKeyAuth: type: TYPE_API_KEY in: IN_HEADER name: "X-API-Key" `), "openapi_options") if err != nil { t.Fatal(err) } if config.OpenapiOptions == nil { t.Fatal("OpenAPIOptions is empty") } opts := config.OpenapiOptions if numFileOpts := len(opts.File); numFileOpts != 1 { t.Fatalf("expected 1 file option but got %d", numFileOpts) } fileOpt := opts.File[0] if fileOpt.File != "test.proto" { t.Fatalf("file option has unexpected binding %s", fileOpt.File) } swaggerOpt := fileOpt.Option if swaggerOpt == nil { t.Fatal("expected option to be set") } if numSchemes := len(swaggerOpt.Schemes); numSchemes != 3 { t.Fatalf("expected 3 schemes but got %d", numSchemes) } if swaggerOpt.Schemes[0] != options.Scheme_HTTP { t.Fatalf("expected first scheme to be HTTP but got %s", swaggerOpt.Schemes[0]) } if swaggerOpt.Schemes[1] != options.Scheme_HTTPS { t.Fatalf("expected second scheme to be HTTPS but got %s", swaggerOpt.Schemes[1]) } if swaggerOpt.Schemes[2] != options.Scheme_WSS { t.Fatalf("expected third scheme to be WSS but got %s", swaggerOpt.Schemes[2]) } if swaggerOpt.SecurityDefinitions == nil { t.Fatal("expected securityDefinitions to be set") } if numSecOpts := len(swaggerOpt.SecurityDefinitions.Security); numSecOpts != 1 { t.Fatalf("expected 1 security option but got %d", numSecOpts) } secOpt, ok := swaggerOpt.SecurityDefinitions.Security["ApiKeyAuth"] if !ok { t.Fatal("no SecurityScheme for key \"ApiKeyAuth\"") } if secOpt.Type != options.SecurityScheme_TYPE_API_KEY { t.Fatalf("expected scheme type to be TYPE_API_KEY but got %s", secOpt.Type) } if secOpt.In != options.SecurityScheme_IN_HEADER { t.Fatalf("expected scheme in to be IN_HEADER but got %s", secOpt.In) } if secOpt.Name != "X-API-Key" { t.Fatalf("expected name to be X-API-Key but got %s", secOpt.Name) } } func TestLoadOpenAPIConfigFromYAMLUnknownKeys(t *testing.T) { _, err := loadOpenAPIConfigFromYAML([]byte(` closedapiOptions: get: it? openapiOptions: file: - file: test.proto option: schemes: - HTTP `), "openapi_options") if err == nil { t.Errorf("Expected invalid key error") } } ================================================ FILE: internal/descriptor/openapiconfig/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library") load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") load("@rules_proto//proto:defs.bzl", "proto_library") proto_library( name = "openapiconfig_proto", srcs = ["openapiconfig.proto"], visibility = ["//:__subpackages__"], deps = ["//protoc-gen-openapiv2/options:options_proto"], ) go_proto_library( name = "openapiconfig_go_proto", compilers = ["//:go_apiv2"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor/openapiconfig", proto = ":openapiconfig_proto", visibility = ["//:__subpackages__"], deps = ["//protoc-gen-openapiv2/options"], ) go_library( name = "openapiconfig", embed = [":openapiconfig_go_proto"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor/openapiconfig", visibility = ["//:__subpackages__"], ) alias( name = "go_default_library", actual = ":openapiconfig", visibility = ["//:__subpackages__"], ) ================================================ FILE: internal/descriptor/openapiconfig/openapiconfig.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: internal/descriptor/openapiconfig/openapiconfig.proto package openapiconfig import ( options "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) // OpenAPIFileOption represents OpenAPI options on a file type OpenAPIFileOption struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields File string `protobuf:"bytes,1,opt,name=file,proto3" json:"file,omitempty"` Option *options.Swagger `protobuf:"bytes,2,opt,name=option,proto3" json:"option,omitempty"` } func (x *OpenAPIFileOption) Reset() { *x = OpenAPIFileOption{} mi := &file_internal_descriptor_openapiconfig_openapiconfig_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpenAPIFileOption) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpenAPIFileOption) ProtoMessage() {} func (x *OpenAPIFileOption) ProtoReflect() protoreflect.Message { mi := &file_internal_descriptor_openapiconfig_openapiconfig_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use OpenAPIFileOption.ProtoReflect.Descriptor instead. func (*OpenAPIFileOption) Descriptor() ([]byte, []int) { return file_internal_descriptor_openapiconfig_openapiconfig_proto_rawDescGZIP(), []int{0} } func (x *OpenAPIFileOption) GetFile() string { if x != nil { return x.File } return "" } func (x *OpenAPIFileOption) GetOption() *options.Swagger { if x != nil { return x.Option } return nil } // OpenAPIMethodOption represents OpenAPI options on a method type OpenAPIMethodOption struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"` Option *options.Operation `protobuf:"bytes,2,opt,name=option,proto3" json:"option,omitempty"` } func (x *OpenAPIMethodOption) Reset() { *x = OpenAPIMethodOption{} mi := &file_internal_descriptor_openapiconfig_openapiconfig_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpenAPIMethodOption) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpenAPIMethodOption) ProtoMessage() {} func (x *OpenAPIMethodOption) ProtoReflect() protoreflect.Message { mi := &file_internal_descriptor_openapiconfig_openapiconfig_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use OpenAPIMethodOption.ProtoReflect.Descriptor instead. func (*OpenAPIMethodOption) Descriptor() ([]byte, []int) { return file_internal_descriptor_openapiconfig_openapiconfig_proto_rawDescGZIP(), []int{1} } func (x *OpenAPIMethodOption) GetMethod() string { if x != nil { return x.Method } return "" } func (x *OpenAPIMethodOption) GetOption() *options.Operation { if x != nil { return x.Option } return nil } // OpenAPIMessageOption represents OpenAPI options on a message type OpenAPIMessageOption struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` Option *options.Schema `protobuf:"bytes,2,opt,name=option,proto3" json:"option,omitempty"` } func (x *OpenAPIMessageOption) Reset() { *x = OpenAPIMessageOption{} mi := &file_internal_descriptor_openapiconfig_openapiconfig_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpenAPIMessageOption) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpenAPIMessageOption) ProtoMessage() {} func (x *OpenAPIMessageOption) ProtoReflect() protoreflect.Message { mi := &file_internal_descriptor_openapiconfig_openapiconfig_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use OpenAPIMessageOption.ProtoReflect.Descriptor instead. func (*OpenAPIMessageOption) Descriptor() ([]byte, []int) { return file_internal_descriptor_openapiconfig_openapiconfig_proto_rawDescGZIP(), []int{2} } func (x *OpenAPIMessageOption) GetMessage() string { if x != nil { return x.Message } return "" } func (x *OpenAPIMessageOption) GetOption() *options.Schema { if x != nil { return x.Option } return nil } // OpenAPIServiceOption represents OpenAPI options on a service type OpenAPIServiceOption struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"` // ex: Service Option *options.Tag `protobuf:"bytes,2,opt,name=option,proto3" json:"option,omitempty"` } func (x *OpenAPIServiceOption) Reset() { *x = OpenAPIServiceOption{} mi := &file_internal_descriptor_openapiconfig_openapiconfig_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpenAPIServiceOption) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpenAPIServiceOption) ProtoMessage() {} func (x *OpenAPIServiceOption) ProtoReflect() protoreflect.Message { mi := &file_internal_descriptor_openapiconfig_openapiconfig_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use OpenAPIServiceOption.ProtoReflect.Descriptor instead. func (*OpenAPIServiceOption) Descriptor() ([]byte, []int) { return file_internal_descriptor_openapiconfig_openapiconfig_proto_rawDescGZIP(), []int{3} } func (x *OpenAPIServiceOption) GetService() string { if x != nil { return x.Service } return "" } func (x *OpenAPIServiceOption) GetOption() *options.Tag { if x != nil { return x.Option } return nil } // OpenAPIFieldOption represents OpenAPI options on a field type OpenAPIFieldOption struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Field string `protobuf:"bytes,1,opt,name=field,proto3" json:"field,omitempty"` Option *options.JSONSchema `protobuf:"bytes,2,opt,name=option,proto3" json:"option,omitempty"` } func (x *OpenAPIFieldOption) Reset() { *x = OpenAPIFieldOption{} mi := &file_internal_descriptor_openapiconfig_openapiconfig_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpenAPIFieldOption) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpenAPIFieldOption) ProtoMessage() {} func (x *OpenAPIFieldOption) ProtoReflect() protoreflect.Message { mi := &file_internal_descriptor_openapiconfig_openapiconfig_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use OpenAPIFieldOption.ProtoReflect.Descriptor instead. func (*OpenAPIFieldOption) Descriptor() ([]byte, []int) { return file_internal_descriptor_openapiconfig_openapiconfig_proto_rawDescGZIP(), []int{4} } func (x *OpenAPIFieldOption) GetField() string { if x != nil { return x.Field } return "" } func (x *OpenAPIFieldOption) GetOption() *options.JSONSchema { if x != nil { return x.Option } return nil } // OpenAPIOptions represents OpenAPI protobuf options type OpenAPIOptions struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields File []*OpenAPIFileOption `protobuf:"bytes,1,rep,name=file,proto3" json:"file,omitempty"` Method []*OpenAPIMethodOption `protobuf:"bytes,2,rep,name=method,proto3" json:"method,omitempty"` Message []*OpenAPIMessageOption `protobuf:"bytes,3,rep,name=message,proto3" json:"message,omitempty"` Service []*OpenAPIServiceOption `protobuf:"bytes,4,rep,name=service,proto3" json:"service,omitempty"` Field []*OpenAPIFieldOption `protobuf:"bytes,5,rep,name=field,proto3" json:"field,omitempty"` } func (x *OpenAPIOptions) Reset() { *x = OpenAPIOptions{} mi := &file_internal_descriptor_openapiconfig_openapiconfig_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpenAPIOptions) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpenAPIOptions) ProtoMessage() {} func (x *OpenAPIOptions) ProtoReflect() protoreflect.Message { mi := &file_internal_descriptor_openapiconfig_openapiconfig_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use OpenAPIOptions.ProtoReflect.Descriptor instead. func (*OpenAPIOptions) Descriptor() ([]byte, []int) { return file_internal_descriptor_openapiconfig_openapiconfig_proto_rawDescGZIP(), []int{5} } func (x *OpenAPIOptions) GetFile() []*OpenAPIFileOption { if x != nil { return x.File } return nil } func (x *OpenAPIOptions) GetMethod() []*OpenAPIMethodOption { if x != nil { return x.Method } return nil } func (x *OpenAPIOptions) GetMessage() []*OpenAPIMessageOption { if x != nil { return x.Message } return nil } func (x *OpenAPIOptions) GetService() []*OpenAPIServiceOption { if x != nil { return x.Service } return nil } func (x *OpenAPIOptions) GetField() []*OpenAPIFieldOption { if x != nil { return x.Field } return nil } // OpenAPIConfig represents a set of OpenAPI options type OpenAPIConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields OpenapiOptions *OpenAPIOptions `protobuf:"bytes,1,opt,name=openapi_options,json=openapiOptions,proto3" json:"openapi_options,omitempty"` } func (x *OpenAPIConfig) Reset() { *x = OpenAPIConfig{} mi := &file_internal_descriptor_openapiconfig_openapiconfig_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *OpenAPIConfig) String() string { return protoimpl.X.MessageStringOf(x) } func (*OpenAPIConfig) ProtoMessage() {} func (x *OpenAPIConfig) ProtoReflect() protoreflect.Message { mi := &file_internal_descriptor_openapiconfig_openapiconfig_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use OpenAPIConfig.ProtoReflect.Descriptor instead. func (*OpenAPIConfig) Descriptor() ([]byte, []int) { return file_internal_descriptor_openapiconfig_openapiconfig_proto_rawDescGZIP(), []int{6} } func (x *OpenAPIConfig) GetOpenapiOptions() *OpenAPIOptions { if x != nil { return x.OpenapiOptions } return nil } var File_internal_descriptor_openapiconfig_openapiconfig_proto protoreflect.FileDescriptor var file_internal_descriptor_openapiconfig_openapiconfig_proto_rawDesc = []byte{ 0x0a, 0x35, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x1a, 0x2c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x73, 0x0a, 0x11, 0x4f, 0x70, 0x65, 0x6e, 0x41, 0x50, 0x49, 0x46, 0x69, 0x6c, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x4a, 0x0a, 0x06, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x52, 0x06, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x7b, 0x0a, 0x13, 0x4f, 0x70, 0x65, 0x6e, 0x41, 0x50, 0x49, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x4c, 0x0a, 0x06, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x06, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x7b, 0x0a, 0x14, 0x4f, 0x70, 0x65, 0x6e, 0x41, 0x50, 0x49, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x49, 0x0a, 0x06, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x06, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x78, 0x0a, 0x14, 0x4f, 0x70, 0x65, 0x6e, 0x41, 0x50, 0x49, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x46, 0x0a, 0x06, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x54, 0x61, 0x67, 0x52, 0x06, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x79, 0x0a, 0x12, 0x4f, 0x70, 0x65, 0x6e, 0x41, 0x50, 0x49, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x4d, 0x0a, 0x06, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4a, 0x53, 0x4f, 0x4e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x06, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xde, 0x03, 0x0a, 0x0e, 0x4f, 0x70, 0x65, 0x6e, 0x41, 0x50, 0x49, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x55, 0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x41, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x41, 0x50, 0x49, 0x46, 0x69, 0x6c, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x5b, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x43, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x41, 0x50, 0x49, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x5e, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x44, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x41, 0x50, 0x49, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x5e, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x44, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x41, 0x50, 0x49, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x58, 0x0a, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x42, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x41, 0x50, 0x49, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x22, 0x78, 0x0a, 0x0d, 0x4f, 0x70, 0x65, 0x6e, 0x41, 0x50, 0x49, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x67, 0x0a, 0x0f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x3e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x4f, 0x70, 0x65, 0x6e, 0x41, 0x50, 0x49, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x0e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_internal_descriptor_openapiconfig_openapiconfig_proto_rawDescOnce sync.Once file_internal_descriptor_openapiconfig_openapiconfig_proto_rawDescData = file_internal_descriptor_openapiconfig_openapiconfig_proto_rawDesc ) func file_internal_descriptor_openapiconfig_openapiconfig_proto_rawDescGZIP() []byte { file_internal_descriptor_openapiconfig_openapiconfig_proto_rawDescOnce.Do(func() { file_internal_descriptor_openapiconfig_openapiconfig_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_descriptor_openapiconfig_openapiconfig_proto_rawDescData) }) return file_internal_descriptor_openapiconfig_openapiconfig_proto_rawDescData } var file_internal_descriptor_openapiconfig_openapiconfig_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_internal_descriptor_openapiconfig_openapiconfig_proto_goTypes = []any{ (*OpenAPIFileOption)(nil), // 0: grpc.gateway.internal.descriptor.openapiconfig.OpenAPIFileOption (*OpenAPIMethodOption)(nil), // 1: grpc.gateway.internal.descriptor.openapiconfig.OpenAPIMethodOption (*OpenAPIMessageOption)(nil), // 2: grpc.gateway.internal.descriptor.openapiconfig.OpenAPIMessageOption (*OpenAPIServiceOption)(nil), // 3: grpc.gateway.internal.descriptor.openapiconfig.OpenAPIServiceOption (*OpenAPIFieldOption)(nil), // 4: grpc.gateway.internal.descriptor.openapiconfig.OpenAPIFieldOption (*OpenAPIOptions)(nil), // 5: grpc.gateway.internal.descriptor.openapiconfig.OpenAPIOptions (*OpenAPIConfig)(nil), // 6: grpc.gateway.internal.descriptor.openapiconfig.OpenAPIConfig (*options.Swagger)(nil), // 7: grpc.gateway.protoc_gen_openapiv2.options.Swagger (*options.Operation)(nil), // 8: grpc.gateway.protoc_gen_openapiv2.options.Operation (*options.Schema)(nil), // 9: grpc.gateway.protoc_gen_openapiv2.options.Schema (*options.Tag)(nil), // 10: grpc.gateway.protoc_gen_openapiv2.options.Tag (*options.JSONSchema)(nil), // 11: grpc.gateway.protoc_gen_openapiv2.options.JSONSchema } var file_internal_descriptor_openapiconfig_openapiconfig_proto_depIdxs = []int32{ 7, // 0: grpc.gateway.internal.descriptor.openapiconfig.OpenAPIFileOption.option:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Swagger 8, // 1: grpc.gateway.internal.descriptor.openapiconfig.OpenAPIMethodOption.option:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Operation 9, // 2: grpc.gateway.internal.descriptor.openapiconfig.OpenAPIMessageOption.option:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Schema 10, // 3: grpc.gateway.internal.descriptor.openapiconfig.OpenAPIServiceOption.option:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Tag 11, // 4: grpc.gateway.internal.descriptor.openapiconfig.OpenAPIFieldOption.option:type_name -> grpc.gateway.protoc_gen_openapiv2.options.JSONSchema 0, // 5: grpc.gateway.internal.descriptor.openapiconfig.OpenAPIOptions.file:type_name -> grpc.gateway.internal.descriptor.openapiconfig.OpenAPIFileOption 1, // 6: grpc.gateway.internal.descriptor.openapiconfig.OpenAPIOptions.method:type_name -> grpc.gateway.internal.descriptor.openapiconfig.OpenAPIMethodOption 2, // 7: grpc.gateway.internal.descriptor.openapiconfig.OpenAPIOptions.message:type_name -> grpc.gateway.internal.descriptor.openapiconfig.OpenAPIMessageOption 3, // 8: grpc.gateway.internal.descriptor.openapiconfig.OpenAPIOptions.service:type_name -> grpc.gateway.internal.descriptor.openapiconfig.OpenAPIServiceOption 4, // 9: grpc.gateway.internal.descriptor.openapiconfig.OpenAPIOptions.field:type_name -> grpc.gateway.internal.descriptor.openapiconfig.OpenAPIFieldOption 5, // 10: grpc.gateway.internal.descriptor.openapiconfig.OpenAPIConfig.openapi_options:type_name -> grpc.gateway.internal.descriptor.openapiconfig.OpenAPIOptions 11, // [11:11] is the sub-list for method output_type 11, // [11:11] is the sub-list for method input_type 11, // [11:11] is the sub-list for extension type_name 11, // [11:11] is the sub-list for extension extendee 0, // [0:11] is the sub-list for field type_name } func init() { file_internal_descriptor_openapiconfig_openapiconfig_proto_init() } func file_internal_descriptor_openapiconfig_openapiconfig_proto_init() { if File_internal_descriptor_openapiconfig_openapiconfig_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_internal_descriptor_openapiconfig_openapiconfig_proto_rawDesc, NumEnums: 0, NumMessages: 7, NumExtensions: 0, NumServices: 0, }, GoTypes: file_internal_descriptor_openapiconfig_openapiconfig_proto_goTypes, DependencyIndexes: file_internal_descriptor_openapiconfig_openapiconfig_proto_depIdxs, MessageInfos: file_internal_descriptor_openapiconfig_openapiconfig_proto_msgTypes, }.Build() File_internal_descriptor_openapiconfig_openapiconfig_proto = out.File file_internal_descriptor_openapiconfig_openapiconfig_proto_rawDesc = nil file_internal_descriptor_openapiconfig_openapiconfig_proto_goTypes = nil file_internal_descriptor_openapiconfig_openapiconfig_proto_depIdxs = nil } ================================================ FILE: internal/descriptor/openapiconfig/openapiconfig.proto ================================================ syntax = "proto3"; package grpc.gateway.internal.descriptor.openapiconfig; import "protoc-gen-openapiv2/options/openapiv2.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor/openapiconfig"; // OpenAPIFileOption represents OpenAPI options on a file message OpenAPIFileOption { string file = 1; grpc.gateway.protoc_gen_openapiv2.options.Swagger option = 2; } // OpenAPIMethodOption represents OpenAPI options on a method message OpenAPIMethodOption { string method = 1; grpc.gateway.protoc_gen_openapiv2.options.Operation option = 2; } // OpenAPIMessageOption represents OpenAPI options on a message message OpenAPIMessageOption { string message = 1; grpc.gateway.protoc_gen_openapiv2.options.Schema option = 2; } // OpenAPIServiceOption represents OpenAPI options on a service message OpenAPIServiceOption { string service = 1; // ex: Service grpc.gateway.protoc_gen_openapiv2.options.Tag option = 2; } // OpenAPIFieldOption represents OpenAPI options on a field message OpenAPIFieldOption { string field = 1; grpc.gateway.protoc_gen_openapiv2.options.JSONSchema option = 2; } // OpenAPIOptions represents OpenAPI protobuf options message OpenAPIOptions { repeated OpenAPIFileOption file = 1; repeated OpenAPIMethodOption method = 2; repeated OpenAPIMessageOption message = 3; repeated OpenAPIServiceOption service = 4; repeated OpenAPIFieldOption field = 5; } // OpenAPIConfig represents a set of OpenAPI options message OpenAPIConfig { OpenAPIOptions openapi_options = 1; } ================================================ FILE: internal/descriptor/openapiconfig/openapiconfig.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "internal/descriptor/openapiconfig/openapiconfig.proto", "version": "version not set" }, "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": {}, "definitions": { "protobufAny": { "type": "object", "properties": { "@type": { "type": "string" } }, "additionalProperties": {} }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } } } } ================================================ FILE: internal/descriptor/registry.go ================================================ package descriptor import ( "fmt" "sort" "strings" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/codegenerator" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor/openapiconfig" "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" "golang.org/x/text/cases" "golang.org/x/text/language" "google.golang.org/genproto/googleapis/api/annotations" "google.golang.org/grpc/grpclog" "google.golang.org/protobuf/compiler/protogen" "google.golang.org/protobuf/types/descriptorpb" "google.golang.org/protobuf/types/pluginpb" ) // Registry is a registry of information extracted from pluginpb.CodeGeneratorRequest. type Registry struct { // msgs is a mapping from fully-qualified message name to descriptor msgs map[string]*Message // enums is a mapping from fully-qualified enum name to descriptor enums map[string]*Enum // files is a mapping from file path to descriptor files map[string]*File // meths is a mapping from fully-qualified method name to descriptor meths map[string]*Method // prefix is a prefix to be inserted to golang package paths generated from proto package names. prefix string // pkgMap is a user-specified mapping from file path to proto package. pkgMap map[string]string // pkgAliases is a mapping from package aliases to package paths in go which are already taken. pkgAliases map[string]string // allowDeleteBody permits http delete methods to have a body allowDeleteBody bool // externalHttpRules is a mapping from fully qualified service method names to additional HttpRules applicable besides the ones found in annotations. externalHTTPRules map[string][]*annotations.HttpRule // allowMerge generation one OpenAPI file out of multiple protos allowMerge bool // mergeFileName target OpenAPI file name after merge mergeFileName string // includePackageInTags controls whether the package name defined in the `package` directive // in the proto file can be prepended to the gRPC service name in the `Tags` field of every operation. includePackageInTags bool // repeatedPathParamSeparator specifies how path parameter repeated fields are separated repeatedPathParamSeparator repeatedFieldSeparator // useJSONNamesForFields if true json tag name is used for generating fields in OpenAPI definitions, // otherwise the original proto name is used. It's helpful for synchronizing the OpenAPI definition // with gRPC-Gateway response, if it uses json tags for marshaling. useJSONNamesForFields bool // useProto3FieldSemantics if true proto3 field semantics are used for generating fields in OpenAPI definitions. useProto3FieldSemantics bool // openAPINamingStrategy is the naming strategy to use for assigning OpenAPI field and parameter names. This can be one of the following: // - `legacy`: use the legacy naming strategy from protoc-gen-swagger, that generates unique but not necessarily // maximally concise names. Components are concatenated directly, e.g., `MyOuterMessageMyNestedMessage`. // - `simple`: use a simple heuristic for generating unique and concise names. Components are concatenated using // dots as a separator, e.g., `MyOuterMessage.MyNestedMessage` (if `MyNestedMessage` alone is unique, // `MyNestedMessage` will be used as the OpenAPI name). // - `fqn`: always use the fully-qualified name of the proto message (leading dot removed) as the OpenAPI // name. openAPINamingStrategy string // visibilityRestrictionSelectors is a map of selectors for `google.api.VisibilityRule`s that will be included in the OpenAPI output. visibilityRestrictionSelectors map[string]bool // useGoTemplate determines whether you want to use GO templates // in your protofile comments useGoTemplate bool // goTemplateArgs specifies a list of key value pair inputs to be displayed in Go templates goTemplateArgs map[string]string // ignoreComments determines whether all protofile comments should be excluded from output ignoreComments bool // removeInternalComments determines whether to remove substrings in comments that begin with // `(--` and end with `--)` as specified in https://google.aip.dev/192#internal-comments. removeInternalComments bool // enumsAsInts render enum as integer, as opposed to string enumsAsInts bool // omitEnumDefaultValue omits default value of enum omitEnumDefaultValue bool // disableDefaultErrors disables the generation of the default error types. // This is useful for users who have defined custom error handling. disableDefaultErrors bool // simpleOperationIDs removes the service prefix from the generated // operationIDs. This risks generating duplicate operationIDs. simpleOperationIDs bool standalone bool // warnOnUnboundMethods causes the registry to emit warning logs if an RPC method // has no HttpRule annotation. warnOnUnboundMethods bool // proto3OptionalNullable specifies whether Proto3 Optional fields should be marked as x-nullable. proto3OptionalNullable bool // fileOptions is a mapping of file name to additional OpenAPI file options fileOptions map[string]*options.Swagger // methodOptions is a mapping of fully-qualified method name to additional OpenAPI method options methodOptions map[string]*options.Operation // messageOptions is a mapping of fully-qualified message name to additional OpenAPI message options messageOptions map[string]*options.Schema //serviceOptions is a mapping of fully-qualified service name to additional OpenAPI service options serviceOptions map[string]*options.Tag // fieldOptions is a mapping of the fully-qualified name of the parent message concat // field name and a period to additional OpenAPI field options fieldOptions map[string]*options.JSONSchema // generateUnboundMethods causes the registry to generate proxy methods even for // RPC methods that have no HttpRule annotation. generateUnboundMethods bool // omitPackageDoc, if false, causes a package comment to be included in the generated code. omitPackageDoc bool // recursiveDepth sets the maximum depth of a field parameter recursiveDepth int // annotationMap is used to check for duplicate HTTP annotations annotationMap map[annotationIdentifier]struct{} // disableServiceTags disables the generation of service tags. // This is useful if you do not want to expose the names of your backend grpc services. disableServiceTags bool // disableDefaultResponses disables the generation of default responses. // Useful if you have to support custom response codes that are not 200. disableDefaultResponses bool // useAllOfForRefs, if set, will use allOf as container for $ref to preserve same-level // properties useAllOfForRefs bool // omitArrayItemTypeWhenRefSibling, if set, will omit 'type: object' in array items when $ref is present // to avoid no-$ref-siblings violations in OpenAPI v2 omitArrayItemTypeWhenRefSibling bool // allowPatchFeature determines whether to use PATCH feature involving update masks (using google.protobuf.FieldMask). allowPatchFeature bool // preserveRPCOrder, if true, will ensure the order of paths emitted in openapi swagger files mirror // the order of RPC methods found in proto files. If false, emitted paths will be ordered alphabetically. preserveRPCOrder bool // enableRpcDeprecation whether to process grpc method's deprecated option enableRpcDeprecation bool // enableFieldDeprecation whether to process proto field's deprecated option enableFieldDeprecation bool // expandSlashedPathPatterns, if true, for a path parameter carrying a sub-path, described via parameter pattern (i.e. // the pattern contains forward slashes), this will expand the _pattern_ into the URI and will _replace_ the parameter // with new path parameters inferred from patterns wildcards. // // Example: a Google AIP style path "/v1/{name=projects/*/locations/*}/datasets/{dataset}" with a "name" parameter // containing sub-path will generate "/v1/projects/{project}/locations/{location}/datasets/{dataset}" path in OpenAPI. // Note that the original "name" parameter is replaced with "project" and "location" parameters. // // This leads to more compliant and readable OpenAPI suitable for documentation, but may complicate client // implementation if you want to pass the original "name" parameter. expandSlashedPathPatterns bool // generateXGoType is a global generator option for generating x-go-type annotations generateXGoType bool } type repeatedFieldSeparator struct { name string sep rune } type annotationIdentifier struct { method string pathTemplate string service *Service } // NewRegistry returns a new Registry. func NewRegistry() *Registry { return &Registry{ msgs: make(map[string]*Message), enums: make(map[string]*Enum), meths: make(map[string]*Method), files: make(map[string]*File), pkgMap: make(map[string]string), pkgAliases: make(map[string]string), externalHTTPRules: make(map[string][]*annotations.HttpRule), openAPINamingStrategy: "legacy", visibilityRestrictionSelectors: make(map[string]bool), repeatedPathParamSeparator: repeatedFieldSeparator{ name: "csv", sep: ',', }, fileOptions: make(map[string]*options.Swagger), methodOptions: make(map[string]*options.Operation), messageOptions: make(map[string]*options.Schema), serviceOptions: make(map[string]*options.Tag), fieldOptions: make(map[string]*options.JSONSchema), annotationMap: make(map[annotationIdentifier]struct{}), recursiveDepth: 1000, } } // Load loads definitions of services, methods, messages, enumerations and fields from "req". func (r *Registry) Load(req *pluginpb.CodeGeneratorRequest) error { gen, err := protogen.Options{}.New(req) if err != nil { return err } // Note: keep in mind that this might be not enough because // protogen.Plugin is used only to load files here. // The support for features must be set on the pluginpb.CodeGeneratorResponse. codegenerator.SetSupportedFeaturesOnPluginGen(gen) return r.load(gen) } func (r *Registry) LoadFromPlugin(gen *protogen.Plugin) error { return r.load(gen) } func (r *Registry) load(gen *protogen.Plugin) error { filePaths := make([]string, 0, len(gen.FilesByPath)) for filePath := range gen.FilesByPath { filePaths = append(filePaths, filePath) } sort.Strings(filePaths) for _, filePath := range filePaths { r.loadFile(filePath, gen.FilesByPath[filePath]) } for _, filePath := range filePaths { if !gen.FilesByPath[filePath].Generate { continue } file := r.files[filePath] if err := r.loadServices(file); err != nil { return err } } return nil } // loadFile loads messages, enumerations and fields from "file". // It does not load services and methods in "file". You need to call // loadServices after loadFiles is called for all files to load services and methods. func (r *Registry) loadFile(filePath string, file *protogen.File) { pkg := GoPackage{ Path: string(file.GoImportPath), Name: string(file.GoPackageName), } if r.standalone { pkg.Alias = "ext" + cases.Title(language.AmericanEnglish).String(pkg.Name) } if err := r.ReserveGoPackageAlias(pkg.Name, pkg.Path); err != nil { for i := 0; ; i++ { alias := fmt.Sprintf("%s_%d", pkg.Name, i) if err := r.ReserveGoPackageAlias(alias, pkg.Path); err == nil { pkg.Alias = alias break } } } f := &File{ FileDescriptorProto: file.Proto, GoPkg: pkg, GeneratedFilenamePrefix: file.GeneratedFilenamePrefix, } r.files[filePath] = f r.registerMsg(f, nil, file.Proto.MessageType) r.registerEnum(f, nil, file.Proto.EnumType) } func (r *Registry) registerMsg(file *File, outerPath []string, msgs []*descriptorpb.DescriptorProto) { for i, md := range msgs { m := &Message{ File: file, Outers: outerPath, DescriptorProto: md, Index: i, ForcePrefixedName: r.standalone, } for _, fd := range md.GetField() { m.Fields = append(m.Fields, &Field{ Message: m, FieldDescriptorProto: fd, ForcePrefixedName: r.standalone, }) } file.Messages = append(file.Messages, m) r.msgs[m.FQMN()] = m if grpclog.V(1) { grpclog.Infof("Register name: %s", m.FQMN()) } var outers []string outers = append(outers, outerPath...) outers = append(outers, m.GetName()) r.registerMsg(file, outers, m.GetNestedType()) r.registerEnum(file, outers, m.GetEnumType()) } } func (r *Registry) registerEnum(file *File, outerPath []string, enums []*descriptorpb.EnumDescriptorProto) { for i, ed := range enums { e := &Enum{ File: file, Outers: outerPath, EnumDescriptorProto: ed, Index: i, ForcePrefixedName: r.standalone, } file.Enums = append(file.Enums, e) r.enums[e.FQEN()] = e if grpclog.V(1) { grpclog.Infof("Register enum name: %s", e.FQEN()) } } } // LookupMsg looks up a message type by "name". // It tries to resolve "name" from "location" if "name" is a relative message name. func (r *Registry) LookupMsg(location, name string) (*Message, error) { if grpclog.V(1) { grpclog.Infof("Lookup %s from %s", name, location) } if strings.HasPrefix(name, ".") { m, ok := r.msgs[name] if !ok { return nil, fmt.Errorf("no message found: %s", name) } return m, nil } if !strings.HasPrefix(location, ".") { location = fmt.Sprintf(".%s", location) } components := strings.Split(location, ".") for len(components) > 0 { fqmn := strings.Join(append(components, name), ".") if m, ok := r.msgs[fqmn]; ok { return m, nil } components = components[:len(components)-1] } return nil, fmt.Errorf("no message found: %s", name) } // LookupEnum looks up an enum type by "name". // It tries to resolve "name" from "location" if "name" is a relative enum name. func (r *Registry) LookupEnum(location, name string) (*Enum, error) { if grpclog.V(1) { grpclog.Infof("Lookup enum %s from %s", name, location) } if strings.HasPrefix(name, ".") { e, ok := r.enums[name] if !ok { return nil, fmt.Errorf("no enum found: %s", name) } return e, nil } if !strings.HasPrefix(location, ".") { location = fmt.Sprintf(".%s", location) } components := strings.Split(location, ".") for len(components) > 0 { fqen := strings.Join(append(components, name), ".") if e, ok := r.enums[fqen]; ok { return e, nil } components = components[:len(components)-1] } return nil, fmt.Errorf("no enum found: %s", name) } // LookupFile looks up a file by name. func (r *Registry) LookupFile(name string) (*File, error) { f, ok := r.files[name] if !ok { return nil, fmt.Errorf("no such file given: %s", name) } return f, nil } func (r *Registry) GetUseProto3FieldSemantics() bool { return r.useProto3FieldSemantics } func (r *Registry) SetUseProto3FieldSemantics(useProto3FieldSemantics bool) { r.useProto3FieldSemantics = useProto3FieldSemantics } // LookupExternalHTTPRules looks up external http rules by fully qualified service method name func (r *Registry) LookupExternalHTTPRules(qualifiedMethodName string) []*annotations.HttpRule { return r.externalHTTPRules[qualifiedMethodName] } // AddExternalHTTPRule adds an external http rule for the given fully qualified service method name func (r *Registry) AddExternalHTTPRule(qualifiedMethodName string, rule *annotations.HttpRule) { r.externalHTTPRules[qualifiedMethodName] = append(r.externalHTTPRules[qualifiedMethodName], rule) } // UnboundExternalHTTPRules returns the list of External HTTPRules // which does not have a matching method in the registry func (r *Registry) UnboundExternalHTTPRules() []string { allServiceMethods := make(map[string]struct{}) for _, f := range r.files { for _, s := range f.GetService() { svc := &Service{File: f, ServiceDescriptorProto: s} for _, m := range s.GetMethod() { method := &Method{Service: svc, MethodDescriptorProto: m} allServiceMethods[method.FQMN()] = struct{}{} } } } var missingMethods []string for httpRuleMethod := range r.externalHTTPRules { if _, ok := allServiceMethods[httpRuleMethod]; !ok { missingMethods = append(missingMethods, httpRuleMethod) } } return missingMethods } // AddPkgMap adds a mapping from a .proto file to proto package name. func (r *Registry) AddPkgMap(file, protoPkg string) { r.pkgMap[file] = protoPkg } // SetPrefix registers the prefix to be added to go package paths generated from proto package names. func (r *Registry) SetPrefix(prefix string) { r.prefix = prefix } // SetStandalone registers standalone flag to control package prefix func (r *Registry) SetStandalone(standalone bool) { r.standalone = standalone } // SetRecursiveDepth records the max recursion count func (r *Registry) SetRecursiveDepth(count int) { r.recursiveDepth = count } // GetRecursiveDepth returns the max recursion count func (r *Registry) GetRecursiveDepth() int { return r.recursiveDepth } // ReserveGoPackageAlias reserves the unique alias of go package. // If succeeded, the alias will be never used for other packages in generated go files. // If failed, the alias is already taken by another package, so you need to use another // alias for the package in your go files. func (r *Registry) ReserveGoPackageAlias(alias, pkgpath string) error { if taken, ok := r.pkgAliases[alias]; ok { if taken == pkgpath { return nil } return fmt.Errorf("package name %s is already taken. Use another alias", alias) } r.pkgAliases[alias] = pkgpath return nil } // GetAllFQMNs returns a list of all FQMNs func (r *Registry) GetAllFQMNs() []string { keys := make([]string, 0, len(r.msgs)) for k := range r.msgs { keys = append(keys, k) } return keys } // GetAllFQENs returns a list of all FQENs func (r *Registry) GetAllFQENs() []string { keys := make([]string, 0, len(r.enums)) for k := range r.enums { keys = append(keys, k) } return keys } func (r *Registry) GetAllFQMethNs() []string { keys := make([]string, 0, len(r.meths)) for k := range r.meths { keys = append(keys, k) } return keys } // SetAllowDeleteBody controls whether http delete methods may have a // body or fail loading if encountered. func (r *Registry) SetAllowDeleteBody(allow bool) { r.allowDeleteBody = allow } // SetAllowMerge controls whether generation one OpenAPI file out of multiple protos func (r *Registry) SetAllowMerge(allow bool) { r.allowMerge = allow } // IsAllowMerge whether generation one OpenAPI file out of multiple protos func (r *Registry) IsAllowMerge() bool { return r.allowMerge } // SetMergeFileName controls the target OpenAPI file name out of multiple protos func (r *Registry) SetMergeFileName(mergeFileName string) { r.mergeFileName = mergeFileName } // SetIncludePackageInTags controls whether the package name defined in the `package` directive // in the proto file can be prepended to the gRPC service name in the `Tags` field of every operation. func (r *Registry) SetIncludePackageInTags(allow bool) { r.includePackageInTags = allow } // IsIncludePackageInTags checks whether the package name defined in the `package` directive // in the proto file can be prepended to the gRPC service name in the `Tags` field of every operation. func (r *Registry) IsIncludePackageInTags() bool { return r.includePackageInTags } // GetRepeatedPathParamSeparator returns a rune specifying how // path parameter repeated fields are separated. func (r *Registry) GetRepeatedPathParamSeparator() rune { return r.repeatedPathParamSeparator.sep } // GetRepeatedPathParamSeparatorName returns the name path parameter repeated // fields repeatedFieldSeparator. I.e. 'csv', 'pipe', 'ssv' or 'tsv' func (r *Registry) GetRepeatedPathParamSeparatorName() string { return r.repeatedPathParamSeparator.name } // SetRepeatedPathParamSeparator sets how path parameter repeated fields are // separated. Allowed names are 'csv', 'pipe', 'ssv' and 'tsv'. func (r *Registry) SetRepeatedPathParamSeparator(name string) error { var sep rune switch name { case "csv": sep = ',' case "pipes": sep = '|' case "ssv": sep = ' ' case "tsv": sep = '\t' default: return fmt.Errorf("unknown repeated path parameter separator: %s", name) } r.repeatedPathParamSeparator = repeatedFieldSeparator{ name: name, sep: sep, } return nil } // SetUseJSONNamesForFields sets useJSONNamesForFields func (r *Registry) SetUseJSONNamesForFields(use bool) { r.useJSONNamesForFields = use } // GetUseJSONNamesForFields returns useJSONNamesForFields func (r *Registry) GetUseJSONNamesForFields() bool { return r.useJSONNamesForFields } // SetUseFQNForOpenAPIName sets useFQNForOpenAPIName // Deprecated: use SetOpenAPINamingStrategy instead. func (r *Registry) SetUseFQNForOpenAPIName(use bool) { r.openAPINamingStrategy = "fqn" } // GetUseFQNForOpenAPIName returns useFQNForOpenAPIName // Deprecated: Use GetOpenAPINamingStrategy(). func (r *Registry) GetUseFQNForOpenAPIName() bool { return r.openAPINamingStrategy == "fqn" } // GetMergeFileName return the target merge OpenAPI file name func (r *Registry) GetMergeFileName() string { return r.mergeFileName } // SetOpenAPINamingStrategy sets the naming strategy to be used. func (r *Registry) SetOpenAPINamingStrategy(strategy string) { r.openAPINamingStrategy = strategy } // GetOpenAPINamingStrategy retrieves the naming strategy that is in use. func (r *Registry) GetOpenAPINamingStrategy() string { return r.openAPINamingStrategy } // SetUseGoTemplate sets useGoTemplate func (r *Registry) SetUseGoTemplate(use bool) { r.useGoTemplate = use } // GetUseGoTemplate returns useGoTemplate func (r *Registry) GetUseGoTemplate() bool { return r.useGoTemplate } func (r *Registry) SetGoTemplateArgs(kvs []string) { r.goTemplateArgs = make(map[string]string) for _, kv := range kvs { if key, value, found := strings.Cut(kv, "="); found { r.goTemplateArgs[key] = value } } } func (r *Registry) GetGoTemplateArgs() map[string]string { return r.goTemplateArgs } // SetIgnoreComments sets ignoreComments func (r *Registry) SetIgnoreComments(ignore bool) { r.ignoreComments = ignore } // GetIgnoreComments returns ignoreComments func (r *Registry) GetIgnoreComments() bool { return r.ignoreComments } // SetRemoveInternalComments sets removeInternalComments func (r *Registry) SetRemoveInternalComments(remove bool) { r.removeInternalComments = remove } // GetRemoveInternalComments returns removeInternalComments func (r *Registry) GetRemoveInternalComments() bool { return r.removeInternalComments } // SetEnumsAsInts set enumsAsInts func (r *Registry) SetEnumsAsInts(enumsAsInts bool) { r.enumsAsInts = enumsAsInts } // GetEnumsAsInts returns enumsAsInts func (r *Registry) GetEnumsAsInts() bool { return r.enumsAsInts } // SetOmitEnumDefaultValue sets omitEnumDefaultValue func (r *Registry) SetOmitEnumDefaultValue(omit bool) { r.omitEnumDefaultValue = omit } // GetOmitEnumDefaultValue returns omitEnumDefaultValue func (r *Registry) GetOmitEnumDefaultValue() bool { return r.omitEnumDefaultValue } // SetVisibilityRestrictionSelectors sets the visibility restriction selectors. func (r *Registry) SetVisibilityRestrictionSelectors(selectors []string) { r.visibilityRestrictionSelectors = make(map[string]bool) for _, selector := range selectors { r.visibilityRestrictionSelectors[strings.TrimSpace(selector)] = true } } // GetVisibilityRestrictionSelectors retrieves the visibility restriction selectors. func (r *Registry) GetVisibilityRestrictionSelectors() map[string]bool { return r.visibilityRestrictionSelectors } // SetDisableDefaultErrors sets disableDefaultErrors func (r *Registry) SetDisableDefaultErrors(use bool) { r.disableDefaultErrors = use } // GetDisableDefaultErrors returns disableDefaultErrors func (r *Registry) GetDisableDefaultErrors() bool { return r.disableDefaultErrors } // SetSimpleOperationIDs sets simpleOperationIDs func (r *Registry) SetSimpleOperationIDs(use bool) { r.simpleOperationIDs = use } // GetSimpleOperationIDs returns simpleOperationIDs func (r *Registry) GetSimpleOperationIDs() bool { return r.simpleOperationIDs } // SetWarnOnUnboundMethods sets warnOnUnboundMethods func (r *Registry) SetWarnOnUnboundMethods(warn bool) { r.warnOnUnboundMethods = warn } // SetGenerateUnboundMethods sets generateUnboundMethods func (r *Registry) SetGenerateUnboundMethods(generate bool) { r.generateUnboundMethods = generate } // SetOmitPackageDoc controls whether the generated code contains a package comment (if set to false, it will contain one) func (r *Registry) SetOmitPackageDoc(omit bool) { r.omitPackageDoc = omit } // GetOmitPackageDoc returns whether a package comment will be omitted from the generated code func (r *Registry) GetOmitPackageDoc() bool { return r.omitPackageDoc } // SetProto3OptionalNullable set proto3OptionalNullable func (r *Registry) SetProto3OptionalNullable(proto3OptionalNullable bool) { r.proto3OptionalNullable = proto3OptionalNullable } // GetProto3OptionalNullable returns proto3OptionalNullable func (r *Registry) GetProto3OptionalNullable() bool { return r.proto3OptionalNullable } // RegisterOpenAPIOptions registers OpenAPI options func (r *Registry) RegisterOpenAPIOptions(opts *openapiconfig.OpenAPIOptions) error { if opts == nil { return nil } for _, opt := range opts.File { if _, ok := r.files[opt.File]; !ok { return fmt.Errorf("no file %s found", opt.File) } r.fileOptions[opt.File] = opt.Option } // build map of all registered methods methods := make(map[string]struct{}) services := make(map[string]struct{}) for _, f := range r.files { for _, s := range f.Services { services[s.FQSN()] = struct{}{} for _, m := range s.Methods { methods[m.FQMN()] = struct{}{} } } } for _, opt := range opts.Method { qualifiedMethod := "." + opt.Method if _, ok := methods[qualifiedMethod]; !ok { return fmt.Errorf("no method %s found", opt.Method) } r.methodOptions[qualifiedMethod] = opt.Option } for _, opt := range opts.Message { qualifiedMessage := "." + opt.Message if _, ok := r.msgs[qualifiedMessage]; !ok { return fmt.Errorf("no message %s found", opt.Message) } r.messageOptions[qualifiedMessage] = opt.Option } for _, opt := range opts.Service { qualifiedService := "." + opt.Service if _, ok := services[qualifiedService]; !ok { return fmt.Errorf("no service %s found", opt.Service) } r.serviceOptions[qualifiedService] = opt.Option } // build map of all registered fields fields := make(map[string]struct{}) for _, m := range r.msgs { for _, f := range m.Fields { fields[f.FQFN()] = struct{}{} } } for _, opt := range opts.Field { qualifiedField := "." + opt.Field if _, ok := fields[qualifiedField]; !ok { return fmt.Errorf("no field %s found", opt.Field) } r.fieldOptions[qualifiedField] = opt.Option } return nil } // GetOpenAPIFileOption returns a registered OpenAPI option for a file func (r *Registry) GetOpenAPIFileOption(file string) (*options.Swagger, bool) { opt, ok := r.fileOptions[file] return opt, ok } // GetOpenAPIMethodOption returns a registered OpenAPI option for a method func (r *Registry) GetOpenAPIMethodOption(qualifiedMethod string) (*options.Operation, bool) { opt, ok := r.methodOptions[qualifiedMethod] return opt, ok } // GetOpenAPIMessageOption returns a registered OpenAPI option for a message func (r *Registry) GetOpenAPIMessageOption(qualifiedMessage string) (*options.Schema, bool) { opt, ok := r.messageOptions[qualifiedMessage] return opt, ok } // GetOpenAPIServiceOption returns a registered OpenAPI option for a service func (r *Registry) GetOpenAPIServiceOption(qualifiedService string) (*options.Tag, bool) { opt, ok := r.serviceOptions[qualifiedService] return opt, ok } // GetOpenAPIFieldOption returns a registered OpenAPI option for a field func (r *Registry) GetOpenAPIFieldOption(qualifiedField string) (*options.JSONSchema, bool) { opt, ok := r.fieldOptions[qualifiedField] return opt, ok } func (r *Registry) FieldName(f *Field) string { if r.useJSONNamesForFields { return f.GetJsonName() } return f.GetName() } func (r *Registry) CheckDuplicateAnnotation(httpMethod string, httpTemplate string, svc *Service) error { a := annotationIdentifier{method: httpMethod, pathTemplate: httpTemplate, service: svc} if _, ok := r.annotationMap[a]; ok { return fmt.Errorf("duplicate annotation: method=%s, template=%s", httpMethod, httpTemplate) } r.annotationMap[a] = struct{}{} return nil } // SetDisableServiceTags sets disableServiceTags func (r *Registry) SetDisableServiceTags(use bool) { r.disableServiceTags = use } // GetDisableServiceTags returns disableServiceTags func (r *Registry) GetDisableServiceTags() bool { return r.disableServiceTags } // SetDisableDefaultResponses sets disableDefaultResponses func (r *Registry) SetDisableDefaultResponses(use bool) { r.disableDefaultResponses = use } // GetDisableDefaultResponses returns disableDefaultResponses func (r *Registry) GetDisableDefaultResponses() bool { return r.disableDefaultResponses } // SetUseAllOfForRefs sets useAllOfForRefs func (r *Registry) SetUseAllOfForRefs(use bool) { r.useAllOfForRefs = use } // GetUseAllOfForRefs returns useAllOfForRefs func (r *Registry) GetUseAllOfForRefs() bool { return r.useAllOfForRefs } // SetOmitArrayItemTypeWhenRefSibling sets omitArrayItemTypeWhenRefSibling func (r *Registry) SetOmitArrayItemTypeWhenRefSibling(omit bool) { r.omitArrayItemTypeWhenRefSibling = omit } // GetOmitArrayItemTypeWhenRefSibling returns omitArrayItemTypeWhenRefSibling func (r *Registry) GetOmitArrayItemTypeWhenRefSibling() bool { return r.omitArrayItemTypeWhenRefSibling } // SetAllowPatchFeature sets allowPatchFeature func (r *Registry) SetAllowPatchFeature(allow bool) { r.allowPatchFeature = allow } // GetAllowPatchFeature returns allowPatchFeature func (r *Registry) GetAllowPatchFeature() bool { return r.allowPatchFeature } // SetPreserveRPCOrder sets preserveRPCOrder func (r *Registry) SetPreserveRPCOrder(preserve bool) { r.preserveRPCOrder = preserve } // IsPreserveRPCOrder returns preserveRPCOrder func (r *Registry) IsPreserveRPCOrder() bool { return r.preserveRPCOrder } // SetEnableRpcDeprecation sets enableRpcDeprecation func (r *Registry) SetEnableRpcDeprecation(enable bool) { r.enableRpcDeprecation = enable } // GetEnableRpcDeprecation returns enableRpcDeprecation func (r *Registry) GetEnableRpcDeprecation() bool { return r.enableRpcDeprecation } // SetEnableFieldDeprecation sets enableFieldDeprecation func (r *Registry) SetEnableFieldDeprecation(enable bool) { r.enableFieldDeprecation = enable } // GetEnableFieldDeprecation returns enableFieldDeprecation func (r *Registry) GetEnableFieldDeprecation() bool { return r.enableFieldDeprecation } func (r *Registry) SetExpandSlashedPathPatterns(expandSlashedPathPatterns bool) { r.expandSlashedPathPatterns = expandSlashedPathPatterns } func (r *Registry) GetExpandSlashedPathPatterns() bool { return r.expandSlashedPathPatterns } func (r *Registry) SetGenerateXGoType(generateXGoType bool) { r.generateXGoType = generateXGoType } func (r *Registry) GetGenerateXGoType() bool { return r.generateXGoType } ================================================ FILE: internal/descriptor/registry_test.go ================================================ package descriptor import ( "testing" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor/openapiconfig" "google.golang.org/protobuf/compiler/protogen" "google.golang.org/protobuf/encoding/prototext" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/descriptorpb" "google.golang.org/protobuf/types/pluginpb" ) func newGeneratorFromSources(req *pluginpb.CodeGeneratorRequest, sources ...string) (*protogen.Plugin, error) { for _, src := range sources { var fd descriptorpb.FileDescriptorProto if err := prototext.Unmarshal([]byte(src), &fd); err != nil { return nil, err } req.FileToGenerate = append(req.FileToGenerate, fd.GetName()) req.ProtoFile = append(req.ProtoFile, &fd) } return protogen.Options{}.New(req) } func loadFileWithCodeGeneratorRequest(t *testing.T, reg *Registry, req *pluginpb.CodeGeneratorRequest, sources ...string) []*descriptorpb.FileDescriptorProto { t.Helper() plugin, err := newGeneratorFromSources(req, sources...) if err != nil { t.Fatalf("failed to create a generator: %v", err) } err = reg.LoadFromPlugin(plugin) if err != nil { t.Fatalf("failed to Registry.LoadFromPlugin(): %v", err) } return plugin.Request.ProtoFile } func loadFile(t *testing.T, reg *Registry, src string) *descriptorpb.FileDescriptorProto { t.Helper() fds := loadFileWithCodeGeneratorRequest(t, reg, &pluginpb.CodeGeneratorRequest{}, src) return fds[0] } func TestLoadFile(t *testing.T) { reg := NewRegistry() fd := loadFile(t, reg, ` name: 'example.proto' package: 'example' options < go_package: 'github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example' > message_type < name: 'ExampleMessage' field < name: 'str' label: LABEL_OPTIONAL type: TYPE_STRING number: 1 > > `) file := reg.files["example.proto"] if file == nil { t.Errorf("reg.files[%q] = nil; want non-nil", "example.proto") return } wantPkg := GoPackage{Path: "github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example", Name: "example"} if got, want := file.GoPkg, wantPkg; got != want { t.Errorf("file.GoPkg = %#v; want %#v", got, want) } msg, err := reg.LookupMsg("", ".example.ExampleMessage") if err != nil { t.Errorf("reg.LookupMsg(%q, %q)) failed with %v; want success", "", ".example.ExampleMessage", err) return } if got, want := msg.DescriptorProto, fd.MessageType[0]; got != want { t.Errorf("reg.lookupMsg(%q, %q).DescriptorProto = %#v; want %#v", "", ".example.ExampleMessage", got, want) } if got, want := msg.File, file; got != want { t.Errorf("msg.File = %v; want %v", got, want) } if got := msg.Outers; got != nil { t.Errorf("msg.Outers = %v; want %v", got, nil) } if got, want := len(msg.Fields), 1; got != want { t.Errorf("len(msg.Fields) = %d; want %d", got, want) } else if got, want := msg.Fields[0].FieldDescriptorProto, fd.MessageType[0].Field[0]; got != want { t.Errorf("msg.Fields[0].FieldDescriptorProto = %v; want %v", got, want) } else if got, want := msg.Fields[0].Message, msg; got != want { t.Errorf("msg.Fields[0].Message = %v; want %v", got, want) } if got, want := len(file.Messages), 1; got != want { t.Errorf("file.Meeesages = %#v; want %#v", file.Messages, []*Message{msg}) } if got, want := file.Messages[0], msg; got != want { t.Errorf("file.Meeesages[0] = %v; want %v", got, want) } } func TestLoadFileNestedPackage(t *testing.T) { reg := NewRegistry() loadFile(t, reg, ` name: 'example.proto' package: 'example.nested.nested2' options < go_package: 'github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example.nested.nested2' > `) file := reg.files["example.proto"] if file == nil { t.Errorf("reg.files[%q] = nil; want non-nil", "example.proto") return } wantPkg := GoPackage{Path: "github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example.nested.nested2", Name: "example_nested_nested2"} if got, want := file.GoPkg, wantPkg; got != want { t.Errorf("file.GoPkg = %#v; want %#v", got, want) } } func TestLoadFileWithDir(t *testing.T) { reg := NewRegistry() loadFile(t, reg, ` name: 'path/to/example.proto' package: 'example' options < go_package: 'github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example' > `) file := reg.files["path/to/example.proto"] if file == nil { t.Errorf("reg.files[%q] = nil; want non-nil", "example.proto") return } wantPkg := GoPackage{Path: "github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example", Name: "example"} if got, want := file.GoPkg, wantPkg; got != want { t.Errorf("file.GoPkg = %#v; want %#v", got, want) } } func TestLoadFileWithoutPackage(t *testing.T) { reg := NewRegistry() loadFile(t, reg, ` name: 'path/to/example_file.proto' options < go_package: 'github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example_file' > `) file := reg.files["path/to/example_file.proto"] if file == nil { t.Errorf("reg.files[%q] = nil; want non-nil", "example.proto") return } wantPkg := GoPackage{Path: "github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example_file", Name: "example_file"} if got, want := file.GoPkg, wantPkg; got != want { t.Errorf("file.GoPkg = %#v; want %#v", got, want) } } func TestLoadFileWithMapping(t *testing.T) { reg := NewRegistry() loadFileWithCodeGeneratorRequest(t, reg, &pluginpb.CodeGeneratorRequest{ Parameter: proto.String("Mpath/to/example.proto=example.com/proj/example/proto"), }, ` name: 'path/to/example.proto' package: 'example' options < go_package: 'github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example' > `) file := reg.files["path/to/example.proto"] if file == nil { t.Errorf("reg.files[%q] = nil; want non-nil", "example.proto") return } wantPkg := GoPackage{Path: "example.com/proj/example/proto", Name: "example"} if got, want := file.GoPkg, wantPkg; got != want { t.Errorf("file.GoPkg = %#v; want %#v", got, want) } } func TestLoadFileWithPackageNameCollision(t *testing.T) { reg := NewRegistry() loadFile(t, reg, ` name: 'path/to/another.proto' package: 'example' options < go_package: 'github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example' > `) loadFile(t, reg, ` name: 'path/to/example.proto' package: 'example' options < go_package: 'github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example' > `) if err := reg.ReserveGoPackageAlias("ioutil", "io/ioutil"); err != nil { t.Fatalf("reg.ReserveGoPackageAlias(%q) failed with %v; want success", "ioutil", err) } loadFile(t, reg, ` name: 'path/to/ioutil.proto' package: 'ioutil' options < go_package: 'github.com/grpc-ecosystem/grpc-gateway/runtime/internal/ioutil' > `) file := reg.files["path/to/another.proto"] if file == nil { t.Errorf("reg.files[%q] = nil; want non-nil", "path/to/another.proto") return } wantPkg := GoPackage{Path: "github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example", Name: "example"} if got, want := file.GoPkg, wantPkg; got != want { t.Errorf("file.GoPkg = %#v; want %#v", got, want) } file = reg.files["path/to/example.proto"] if file == nil { t.Errorf("reg.files[%q] = nil; want non-nil", "path/to/example.proto") return } wantPkg = GoPackage{Path: "github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example", Name: "example", Alias: ""} if got, want := file.GoPkg, wantPkg; got != want { t.Errorf("file.GoPkg = %#v; want %#v", got, want) } file = reg.files["path/to/ioutil.proto"] if file == nil { t.Errorf("reg.files[%q] = nil; want non-nil", "path/to/ioutil.proto") return } wantPkg = GoPackage{Path: "github.com/grpc-ecosystem/grpc-gateway/runtime/internal/ioutil", Name: "ioutil", Alias: "ioutil_0"} if got, want := file.GoPkg, wantPkg; got != want { t.Errorf("file.GoPkg = %#v; want %#v", got, want) } } func TestLoadFileWithIdenticalGoPkg(t *testing.T) { reg := NewRegistry() loadFileWithCodeGeneratorRequest(t, reg, &pluginpb.CodeGeneratorRequest{ Parameter: proto.String("Mpath/to/another.proto=example.com/example,Mpath/to/example.proto=example.com/example"), }, ` name: 'path/to/another.proto' package: 'example' options < go_package: 'github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example' > `, ` name: 'path/to/example.proto' package: 'example' options < go_package: 'github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example' > `) file := reg.files["path/to/example.proto"] if file == nil { t.Errorf("reg.files[%q] = nil; want non-nil", "example.proto") return } wantPkg := GoPackage{Path: "example.com/example", Name: "example"} if got, want := file.GoPkg, wantPkg; got != want { t.Errorf("file.GoPkg = %#v; want %#v", got, want) } file = reg.files["path/to/another.proto"] if file == nil { t.Errorf("reg.files[%q] = nil; want non-nil", "example.proto") return } wantPkg = GoPackage{Path: "example.com/example", Name: "example"} if got, want := file.GoPkg, wantPkg; got != want { t.Errorf("file.GoPkg = %#v; want %#v", got, want) } } // TestLookupMsgWithoutPackage tests a case when there is no "package" directive. // In Go, it is required to have a generated package so we rely on // google.golang.org/protobuf/compiler/protogen to provide it. func TestLookupMsgWithoutPackage(t *testing.T) { reg := NewRegistry() fd := loadFile(t, reg, ` name: 'example.proto' options < go_package: 'github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example' > message_type < name: 'ExampleMessage' field < name: 'str' label: LABEL_OPTIONAL type: TYPE_STRING number: 1 > > `) msg, err := reg.LookupMsg("", ".ExampleMessage") if err != nil { t.Errorf("reg.LookupMsg(%q, %q)) failed with %v; want success", "", ".ExampleMessage", err) return } if got, want := msg.DescriptorProto, fd.MessageType[0]; got != want { t.Errorf("reg.lookupMsg(%q, %q).DescriptorProto = %#v; want %#v", "", ".ExampleMessage", got, want) } } func TestLookupMsgWithNestedPackage(t *testing.T) { reg := NewRegistry() fd := loadFile(t, reg, ` name: 'example.proto' package: 'nested.nested2.mypackage' options < go_package: 'github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example' > message_type < name: 'ExampleMessage' field < name: 'str' label: LABEL_OPTIONAL type: TYPE_STRING number: 1 > > `) for _, name := range []string{ "nested.nested2.mypackage.ExampleMessage", "nested2.mypackage.ExampleMessage", "mypackage.ExampleMessage", "ExampleMessage", } { msg, err := reg.LookupMsg("nested.nested2.mypackage", name) if err != nil { t.Errorf("reg.LookupMsg(%q, %q)) failed with %v; want success", ".nested.nested2.mypackage", name, err) return } if got, want := msg.DescriptorProto, fd.MessageType[0]; got != want { t.Errorf("reg.lookupMsg(%q, %q).DescriptorProto = %#v; want %#v", ".nested.nested2.mypackage", name, got, want) } } for _, loc := range []string{ ".nested.nested2.mypackage", "nested.nested2.mypackage", ".nested.nested2", "nested.nested2", ".nested", "nested", ".", "", "somewhere.else", } { name := "nested.nested2.mypackage.ExampleMessage" msg, err := reg.LookupMsg(loc, name) if err != nil { t.Errorf("reg.LookupMsg(%q, %q)) failed with %v; want success", loc, name, err) return } if got, want := msg.DescriptorProto, fd.MessageType[0]; got != want { t.Errorf("reg.lookupMsg(%q, %q).DescriptorProto = %#v; want %#v", loc, name, got, want) } } for _, loc := range []string{ ".nested.nested2.mypackage", "nested.nested2.mypackage", ".nested.nested2", "nested.nested2", ".nested", "nested", } { name := "nested2.mypackage.ExampleMessage" msg, err := reg.LookupMsg(loc, name) if err != nil { t.Errorf("reg.LookupMsg(%q, %q)) failed with %v; want success", loc, name, err) return } if got, want := msg.DescriptorProto, fd.MessageType[0]; got != want { t.Errorf("reg.lookupMsg(%q, %q).DescriptorProto = %#v; want %#v", loc, name, got, want) } } } func TestLoadWithInconsistentTargetPackage(t *testing.T) { for _, spec := range []struct { req string consistent bool }{ // root package, explicit go package { req: ` file_to_generate: 'a.proto' file_to_generate: 'b.proto' proto_file < name: 'a.proto' options < go_package: 'github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example.foo' > message_type < name: 'A' > service < name: "AService" method < name: "Meth" input_type: "A" output_type: "A" options < [google.api.http] < post: "/v1/a" body: "*" > > > > > proto_file < name: 'b.proto' options < go_package: 'github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example.foo' > message_type < name: 'B' > service < name: "BService" method < name: "Meth" input_type: "B" output_type: "B" options < [google.api.http] < post: "/v1/b" body: "*" > > > > > `, consistent: true, }, // named package, explicit go package { req: ` file_to_generate: 'a.proto' file_to_generate: 'b.proto' proto_file < name: 'a.proto' package: 'example.foo' options < go_package: 'github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example.foo' > message_type < name: 'A' > service < name: "AService" method < name: "Meth" input_type: "A" output_type: "A" options < [google.api.http] < post: "/v1/a" body: "*" > > > > > proto_file < name: 'b.proto' package: 'example.foo' options < go_package: 'github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example.foo' > message_type < name: 'B' > service < name: "BService" method < name: "Meth" input_type: "B" output_type: "B" options < [google.api.http] < post: "/v1/b" body: "*" > > > > > `, consistent: true, }, } { var req pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal([]byte(spec.req), &req); err != nil { t.Fatalf("proto.UnmarshalText(%s, &file) failed with %v; want success", spec.req, err) } _, err := newGeneratorFromSources(&req) if got, want := err == nil, spec.consistent; got != want { if want { t.Errorf("reg.Load(%s) failed with %v; want success", spec.req, err) continue } t.Errorf("reg.Load(%s) succeeded; want an package inconsistency error", spec.req) } } } func TestLoadOverriddenPackageName(t *testing.T) { reg := NewRegistry() loadFile(t, reg, ` name: 'example.proto' package: 'example' options < go_package: 'example.com/xyz;pb' > `) file := reg.files["example.proto"] if file == nil { t.Errorf("reg.files[%q] = nil; want non-nil", "example.proto") return } wantPkg := GoPackage{Path: "example.com/xyz", Name: "pb"} if got, want := file.GoPkg, wantPkg; got != want { t.Errorf("file.GoPkg = %#v; want %#v", got, want) } } func TestLoadWithStandalone(t *testing.T) { reg := NewRegistry() reg.SetStandalone(true) loadFile(t, reg, ` name: 'example.proto' package: 'example' options < go_package: 'example.com/xyz;pb' > `) file := reg.files["example.proto"] if file == nil { t.Errorf("reg.files[%q] = nil; want non-nil", "example.proto") return } wantPkg := GoPackage{Path: "example.com/xyz", Name: "pb", Alias: "extPb"} if got, want := file.GoPkg, wantPkg; got != want { t.Errorf("file.GoPkg = %#v; want %#v", got, want) } } func TestUnboundExternalHTTPRules(t *testing.T) { reg := NewRegistry() methodName := ".example.ExampleService.Echo" reg.AddExternalHTTPRule(methodName, nil) assertStringSlice(t, "unbound external HTTP rules", reg.UnboundExternalHTTPRules(), []string{methodName}) loadFile(t, reg, ` name: "path/to/example.proto", package: "example" options < go_package: 'github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example' > message_type < name: "StringMessage" field < name: "string" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING > > service < name: "ExampleService" method < name: "Echo" input_type: "StringMessage" output_type: "StringMessage" > > `) assertStringSlice(t, "unbound external HTTP rules", reg.UnboundExternalHTTPRules(), []string{}) } func TestRegisterOpenAPIOptions(t *testing.T) { codeReqText := `file_to_generate: 'a.proto' proto_file < name: 'a.proto' package: 'example.foo' options < go_package: 'github.com/grpc-ecosystem/grpc-gateway/runtime/internal/example' > message_type < name: 'ExampleMessage' field < name: 'str' label: LABEL_OPTIONAL type: TYPE_STRING number: 1 > > service < name: "AService" method < name: "Meth" input_type: "ExampleMessage" output_type: "ExampleMessage" options < [google.api.http] < post: "/v1/a" body: "*" > > > > > ` var codeReq pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal([]byte(codeReqText), &codeReq); err != nil { t.Fatalf("proto.UnmarshalText(%s, &file) failed with %v; want success", codeReqText, err) } for _, tcase := range []struct { options *openapiconfig.OpenAPIOptions shouldErr bool desc string }{ { desc: "handle nil options", }, { desc: "successfully add options if referenced entity exists", options: &openapiconfig.OpenAPIOptions{ File: []*openapiconfig.OpenAPIFileOption{ { File: "a.proto", }, }, Method: []*openapiconfig.OpenAPIMethodOption{ { Method: "example.foo.AService.Meth", }, }, Message: []*openapiconfig.OpenAPIMessageOption{ { Message: "example.foo.ExampleMessage", }, }, Service: []*openapiconfig.OpenAPIServiceOption{ { Service: "example.foo.AService", }, }, Field: []*openapiconfig.OpenAPIFieldOption{ { Field: "example.foo.ExampleMessage.str", }, }, }, }, { desc: "reject fully qualified names with leading \".\"", options: &openapiconfig.OpenAPIOptions{ File: []*openapiconfig.OpenAPIFileOption{ { File: "a.proto", }, }, Method: []*openapiconfig.OpenAPIMethodOption{ { Method: ".example.foo.AService.Meth", }, }, Message: []*openapiconfig.OpenAPIMessageOption{ { Message: ".example.foo.ExampleMessage", }, }, Service: []*openapiconfig.OpenAPIServiceOption{ { Service: ".example.foo.AService", }, }, Field: []*openapiconfig.OpenAPIFieldOption{ { Field: ".example.foo.ExampleMessage.str", }, }, }, shouldErr: true, }, { desc: "error if file does not exist", options: &openapiconfig.OpenAPIOptions{ File: []*openapiconfig.OpenAPIFileOption{ { File: "b.proto", }, }, }, shouldErr: true, }, { desc: "error if method does not exist", options: &openapiconfig.OpenAPIOptions{ Method: []*openapiconfig.OpenAPIMethodOption{ { Method: "example.foo.AService.Meth2", }, }, }, shouldErr: true, }, { desc: "error if message does not exist", options: &openapiconfig.OpenAPIOptions{ Message: []*openapiconfig.OpenAPIMessageOption{ { Message: "example.foo.NonexistentMessage", }, }, }, shouldErr: true, }, { desc: "error if service does not exist", options: &openapiconfig.OpenAPIOptions{ Service: []*openapiconfig.OpenAPIServiceOption{ { Service: "example.foo.AService1", }, }, }, shouldErr: true, }, { desc: "error if field does not exist", options: &openapiconfig.OpenAPIOptions{ Field: []*openapiconfig.OpenAPIFieldOption{ { Field: "example.foo.ExampleMessage.str1", }, }, }, shouldErr: true, }, } { t.Run(tcase.desc, func(t *testing.T) { reg := NewRegistry() loadFileWithCodeGeneratorRequest(t, reg, &codeReq) err := reg.RegisterOpenAPIOptions(tcase.options) if (err != nil) != tcase.shouldErr { t.Fatalf("got unexpected error: %s", err) } }) } } func assertStringSlice(t *testing.T, message string, got, want []string) { if len(got) != len(want) { t.Errorf("%s = %#v len(%d); want %#v len(%d)", message, got, len(got), want, len(want)) } for i := range want { if got[i] != want[i] { t.Errorf("%s[%d] = %#v; want %#v", message, i, got[i], want[i]) } } } ================================================ FILE: internal/descriptor/services.go ================================================ package descriptor import ( "errors" "fmt" "strings" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/httprule" options "google.golang.org/genproto/googleapis/api/annotations" "google.golang.org/grpc/grpclog" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/descriptorpb" ) // loadServices registers services and their methods from "targetFile" to "r". // It must be called after loadFile is called for all files so that loadServices // can resolve names of message types and their fields. func (r *Registry) loadServices(file *File) error { if grpclog.V(1) { grpclog.Infof("Loading services from %s", file.GetName()) } var svcs []*Service for _, sd := range file.GetService() { if grpclog.V(2) { grpclog.Infof("Registering %s", sd.GetName()) } svc := &Service{ File: file, ServiceDescriptorProto: sd, ForcePrefixedName: r.standalone, } for _, md := range sd.GetMethod() { if grpclog.V(2) { grpclog.Infof("Processing %s.%s", sd.GetName(), md.GetName()) } opts, err := extractAPIOptions(md) if err != nil { grpclog.Errorf("Failed to extract HttpRule from %s.%s: %v", svc.GetName(), md.GetName(), err) return err } optsList := r.LookupExternalHTTPRules((&Method{Service: svc, MethodDescriptorProto: md}).FQMN()) if opts != nil { optsList = append(optsList, opts) } if len(optsList) == 0 { if r.generateUnboundMethods { defaultOpts, err := defaultAPIOptions(svc, md) if err != nil { grpclog.Errorf("Failed to generate default HttpRule from %s.%s: %v", svc.GetName(), md.GetName(), err) return err } optsList = append(optsList, defaultOpts) } else { if grpclog.V(1) { logFn := grpclog.Infof if r.warnOnUnboundMethods { logFn = grpclog.Warningf } logFn("No HttpRule found for method: %s.%s", svc.GetName(), md.GetName()) } } } meth, err := r.newMethod(svc, md, optsList) if err != nil { return err } svc.Methods = append(svc.Methods, meth) r.meths[meth.FQMN()] = meth } if len(svc.Methods) == 0 { continue } if grpclog.V(2) { grpclog.Infof("Registered %s with %d method(s)", svc.GetName(), len(svc.Methods)) } svcs = append(svcs, svc) } file.Services = svcs return nil } func (r *Registry) newMethod(svc *Service, md *descriptorpb.MethodDescriptorProto, optsList []*options.HttpRule) (*Method, error) { requestType, err := r.LookupMsg(svc.File.GetPackage(), md.GetInputType()) if err != nil { return nil, err } responseType, err := r.LookupMsg(svc.File.GetPackage(), md.GetOutputType()) if err != nil { return nil, err } meth := &Method{ Service: svc, MethodDescriptorProto: md, RequestType: requestType, ResponseType: responseType, } newBinding := func(opts *options.HttpRule, idx int) (*Binding, error) { var ( httpMethod string pathTemplate string ) switch { case opts.GetGet() != "": httpMethod = "GET" pathTemplate = opts.GetGet() if opts.Body != "" { return nil, fmt.Errorf("must not set request body when http method is GET: %s", md.GetName()) } case opts.GetPut() != "": httpMethod = "PUT" pathTemplate = opts.GetPut() case opts.GetPost() != "": httpMethod = "POST" pathTemplate = opts.GetPost() case opts.GetDelete() != "": httpMethod = "DELETE" pathTemplate = opts.GetDelete() if opts.Body != "" && !r.allowDeleteBody { return nil, fmt.Errorf("must not set request body when http method is DELETE except allow_delete_body option is true: %s", md.GetName()) } case opts.GetPatch() != "": httpMethod = "PATCH" pathTemplate = opts.GetPatch() case opts.GetCustom() != nil: custom := opts.GetCustom() httpMethod = custom.Kind pathTemplate = custom.Path default: if grpclog.V(1) { grpclog.Infof("No pattern specified in google.api.HttpRule: %s", md.GetName()) } return nil, nil } parsed, err := httprule.Parse(pathTemplate) if err != nil { return nil, err } tmpl := parsed.Compile() if md.GetClientStreaming() && len(tmpl.Fields) > 0 { return nil, errors.New("cannot use path parameter in client streaming") } b := &Binding{ Method: meth, Index: idx, PathTmpl: tmpl, HTTPMethod: httpMethod, } for _, f := range tmpl.Fields { param, err := r.newParam(meth, f) if err != nil { return nil, err } b.PathParams = append(b.PathParams, param) } // TODO(yugui) Handle query params b.Body, err = r.newBody(meth, opts.Body) if err != nil { return nil, err } b.ResponseBody, err = r.newResponse(meth, opts.ResponseBody) if err != nil { return nil, err } return b, nil } applyOpts := func(opts *options.HttpRule) error { b, err := newBinding(opts, len(meth.Bindings)) if err != nil { return err } if b != nil { meth.Bindings = append(meth.Bindings, b) } for _, additional := range opts.GetAdditionalBindings() { if len(additional.AdditionalBindings) > 0 { return fmt.Errorf("additional_binding in additional_binding not allowed: %s.%s", svc.GetName(), meth.GetName()) } b, err := newBinding(additional, len(meth.Bindings)) if err != nil { return err } meth.Bindings = append(meth.Bindings, b) } return nil } for _, opts := range optsList { if err := applyOpts(opts); err != nil { return nil, err } } return meth, nil } func extractAPIOptions(meth *descriptorpb.MethodDescriptorProto) (*options.HttpRule, error) { if meth.Options == nil { return nil, nil } if !proto.HasExtension(meth.Options, options.E_Http) { return nil, nil } ext := proto.GetExtension(meth.Options, options.E_Http) opts, ok := ext.(*options.HttpRule) if !ok { return nil, fmt.Errorf("extension is %T; want an HttpRule", ext) } return opts, nil } func defaultAPIOptions(svc *Service, md *descriptorpb.MethodDescriptorProto) (*options.HttpRule, error) { // FQSN prefixes the service's full name with a '.', e.g.: '.example.ExampleService' fqsn := strings.TrimPrefix(svc.FQSN(), ".") // This generates an HttpRule that matches the gRPC mapping to HTTP/2 described in // https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests // i.e.: // * method is POST // * path is "//" // * body should contain the serialized request message rule := &options.HttpRule{ Pattern: &options.HttpRule_Post{ Post: fmt.Sprintf("/%s/%s", fqsn, md.GetName()), }, Body: "*", } return rule, nil } func (r *Registry) newParam(meth *Method, path string) (Parameter, error) { msg := meth.RequestType fields, err := r.resolveFieldPath(msg, path, true) if err != nil { return Parameter{}, err } l := len(fields) if l == 0 { return Parameter{}, fmt.Errorf("invalid field access list for %s", path) } target := fields[l-1].Target switch target.GetType() { case descriptorpb.FieldDescriptorProto_TYPE_MESSAGE, descriptorpb.FieldDescriptorProto_TYPE_GROUP: if grpclog.V(2) { grpclog.Infoln("found aggregate type:", target, target.TypeName) } if IsWellKnownType(*target.TypeName) { if grpclog.V(2) { grpclog.Infoln("found well known aggregate type:", target) } } else { return Parameter{}, fmt.Errorf("%s.%s: %s is a protobuf message type. Protobuf message types cannot be used as path parameters, use a scalar value type (such as string) instead", meth.Service.GetName(), meth.GetName(), path) } } return Parameter{ FieldPath: FieldPath(fields), Method: meth, Target: fields[l-1].Target, }, nil } func (r *Registry) newBody(meth *Method, path string) (*Body, error) { switch path { case "": return nil, nil case "*": return &Body{FieldPath: nil}, nil } msg := meth.RequestType fields, err := r.resolveFieldPath(msg, path, false) if err != nil { return nil, err } return &Body{FieldPath: FieldPath(fields)}, nil } func (r *Registry) newResponse(meth *Method, path string) (*Body, error) { msg := meth.ResponseType switch path { case "", "*": return nil, nil } fields, err := r.resolveFieldPath(msg, path, false) if err != nil { return nil, err } return &Body{FieldPath: FieldPath(fields)}, nil } // lookupField looks up a field named "name" within "msg". // It returns nil if no such field found. func lookupField(msg *Message, name string) *Field { for _, f := range msg.Fields { if f.GetName() == name { return f } } return nil } // resolveFieldPath resolves "path" into a list of fieldDescriptor, starting from "msg". func (r *Registry) resolveFieldPath(msg *Message, path string, isPathParam bool) ([]FieldPathComponent, error) { if path == "" { return nil, nil } root := msg var result []FieldPathComponent for i, c := range strings.Split(path, ".") { if i > 0 { f := result[i-1].Target switch f.GetType() { case descriptorpb.FieldDescriptorProto_TYPE_MESSAGE, descriptorpb.FieldDescriptorProto_TYPE_GROUP: var err error msg, err = r.LookupMsg(msg.FQMN(), f.GetTypeName()) if err != nil { return nil, err } default: return nil, fmt.Errorf("not an aggregate type: %s in %s", f.GetName(), path) } } if grpclog.V(2) { grpclog.Infof("Lookup %s in %s", c, msg.FQMN()) } f := lookupField(msg, c) if f == nil { return nil, fmt.Errorf("no field %q found in %s", path, root.GetName()) } result = append(result, FieldPathComponent{Name: c, Target: f}) } return result, nil } ================================================ FILE: internal/descriptor/services_test.go ================================================ package descriptor import ( "reflect" "testing" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/httprule" "google.golang.org/protobuf/compiler/protogen" "google.golang.org/protobuf/encoding/prototext" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/descriptorpb" ) func compilePath(t *testing.T, path string) httprule.Template { parsed, err := httprule.Parse(path) if err != nil { t.Fatalf("httprule.Parse(%q) failed with %v; want success", path, err) } return parsed.Compile() } func testExtractServices(t *testing.T, input []*descriptorpb.FileDescriptorProto, target string, wantSvcs []*Service) { testExtractServicesWithRegistry(t, NewRegistry(), input, target, wantSvcs) } func testExtractServicesWithRegistry(t *testing.T, reg *Registry, input []*descriptorpb.FileDescriptorProto, target string, wantSvcs []*Service) { for _, file := range input { reg.loadFile(file.GetName(), &protogen.File{ Proto: file, }) } err := reg.loadServices(reg.files[target]) if err != nil { t.Errorf("loadServices(%q) failed with %v; want success; files=%v", target, err, input) } file := reg.files[target] svcs := file.Services var i int for i = 0; i < len(svcs) && i < len(wantSvcs); i++ { svc, wantSvc := svcs[i], wantSvcs[i] if got, want := svc.ServiceDescriptorProto, wantSvc.ServiceDescriptorProto; !proto.Equal(got, want) { t.Errorf("svcs[%d].ServiceDescriptorProto = %v; want %v; input = %v", i, got, want, input) continue } var j int for j = 0; j < len(svc.Methods) && j < len(wantSvc.Methods); j++ { meth, wantMeth := svc.Methods[j], wantSvc.Methods[j] if got, want := meth.MethodDescriptorProto, wantMeth.MethodDescriptorProto; !proto.Equal(got, want) { t.Errorf("svcs[%d].Methods[%d].MethodDescriptorProto = %v; want %v; input = %v", i, j, got, want, input) continue } if got, want := meth.RequestType, wantMeth.RequestType; got.FQMN() != want.FQMN() { t.Errorf("svcs[%d].Methods[%d].RequestType = %s; want %s; input = %v", i, j, got.FQMN(), want.FQMN(), input) } if got, want := meth.ResponseType, wantMeth.ResponseType; got.FQMN() != want.FQMN() { t.Errorf("svcs[%d].Methods[%d].ResponseType = %s; want %s; input = %v", i, j, got.FQMN(), want.FQMN(), input) } var k int for k = 0; k < len(meth.Bindings) && k < len(wantMeth.Bindings); k++ { binding, wantBinding := meth.Bindings[k], wantMeth.Bindings[k] if got, want := binding.Index, wantBinding.Index; got != want { t.Errorf("svcs[%d].Methods[%d].Bindings[%d].Index = %d; want %d; input = %v", i, j, k, got, want, input) } if got, want := binding.PathTmpl, wantBinding.PathTmpl; !reflect.DeepEqual(got, want) { t.Errorf("svcs[%d].Methods[%d].Bindings[%d].PathTmpl = %#v; want %#v; input = %v", i, j, k, got, want, input) } if got, want := binding.HTTPMethod, wantBinding.HTTPMethod; got != want { t.Errorf("svcs[%d].Methods[%d].Bindings[%d].HTTPMethod = %q; want %q; input = %v", i, j, k, got, want, input) } var l int for l = 0; l < len(binding.PathParams) && l < len(wantBinding.PathParams); l++ { param, wantParam := binding.PathParams[l], wantBinding.PathParams[l] if got, want := param.FieldPath.String(), wantParam.FieldPath.String(); got != want { t.Errorf("svcs[%d].Methods[%d].Bindings[%d].PathParams[%d].FieldPath.String() = %q; want %q; input = %v", i, j, k, l, got, want, input) continue } for m := 0; m < len(param.FieldPath) && m < len(wantParam.FieldPath); m++ { field, wantField := param.FieldPath[m].Target, wantParam.FieldPath[m].Target if got, want := field.FieldDescriptorProto, wantField.FieldDescriptorProto; !proto.Equal(got, want) { t.Errorf("svcs[%d].Methods[%d].Bindings[%d].PathParams[%d].FieldPath[%d].Target.FieldDescriptorProto = %v; want %v; input = %v", i, j, k, l, m, got, want, input) } } } for ; l < len(binding.PathParams); l++ { got := binding.PathParams[l].FieldPath.String() t.Errorf("svcs[%d].Methods[%d].Bindings[%d].PathParams[%d] = %q; want it to be missing; input = %v", i, j, k, l, got, input) } for ; l < len(wantBinding.PathParams); l++ { want := wantBinding.PathParams[l].FieldPath.String() t.Errorf("svcs[%d].Methods[%d].Bindings[%d].PathParams[%d] missing; want %q; input = %v", i, j, k, l, want, input) } if got, want := (binding.Body != nil), (wantBinding.Body != nil); got != want { if got { t.Errorf("svcs[%d].Methods[%d].Bindings[%d].Body = %q; want it to be missing; input = %v", i, j, k, binding.Body.FieldPath.String(), input) } else { t.Errorf("svcs[%d].Methods[%d].Bindings[%d].Body missing; want %q; input = %v", i, j, k, wantBinding.Body.FieldPath.String(), input) } } else if binding.Body != nil { if got, want := binding.Body.FieldPath.String(), wantBinding.Body.FieldPath.String(); got != want { t.Errorf("svcs[%d].Methods[%d].Bindings[%d].Body = %q; want %q; input = %v", i, j, k, got, want, input) } } } for ; k < len(meth.Bindings); k++ { got := meth.Bindings[k] t.Errorf("svcs[%d].Methods[%d].Bindings[%d] = %v; want it to be missing; input = %v", i, j, k, got, input) } for ; k < len(wantMeth.Bindings); k++ { want := wantMeth.Bindings[k] t.Errorf("svcs[%d].Methods[%d].Bindings[%d] missing; want %v; input = %v", i, j, k, want, input) } } for ; j < len(svc.Methods); j++ { got := svc.Methods[j].MethodDescriptorProto t.Errorf("svcs[%d].Methods[%d] = %v; want it to be missing; input = %v", i, j, got, input) } for ; j < len(wantSvc.Methods); j++ { want := wantSvc.Methods[j].MethodDescriptorProto t.Errorf("svcs[%d].Methods[%d] missing; want %v; input = %v", i, j, want, input) } } for ; i < len(svcs); i++ { got := svcs[i].ServiceDescriptorProto t.Errorf("svcs[%d] = %v; want it to be missing; input = %v", i, got, input) } for ; i < len(wantSvcs); i++ { want := wantSvcs[i].ServiceDescriptorProto t.Errorf("svcs[%d] missing; want %v; input = %v", i, want, input) } } func crossLinkFixture(f *File) *File { for _, m := range f.Messages { m.File = f for _, f := range m.Fields { f.Message = m } } for _, svc := range f.Services { svc.File = f for _, m := range svc.Methods { m.Service = svc for _, b := range m.Bindings { b.Method = m for _, param := range b.PathParams { param.Method = m } } } } for _, e := range f.Enums { e.File = f } return f } func TestExtractServicesSimple(t *testing.T) { src := ` name: "path/to/example.proto", package: "example" message_type < name: "StringMessage" field < name: "string" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING > > service < name: "ExampleService" method < name: "Echo" input_type: "StringMessage" output_type: "StringMessage" options < [google.api.http] < post: "/v1/example/echo" body: "*" > > > > ` var fd descriptorpb.FileDescriptorProto if err := prototext.Unmarshal([]byte(src), &fd); err != nil { t.Fatalf("proto.UnmarshalText(%s, &fd) failed with %v; want success", src, err) } msg := &Message{ DescriptorProto: fd.MessageType[0], Fields: []*Field{ { FieldDescriptorProto: fd.MessageType[0].Field[0], }, }, } file := &File{ FileDescriptorProto: &fd, GoPkg: GoPackage{ Path: "path/to/example.pb", Name: "example_pb", }, Messages: []*Message{msg}, Services: []*Service{ { ServiceDescriptorProto: fd.Service[0], Methods: []*Method{ { MethodDescriptorProto: fd.Service[0].Method[0], RequestType: msg, ResponseType: msg, Bindings: []*Binding{ { PathTmpl: compilePath(t, "/v1/example/echo"), HTTPMethod: "POST", Body: &Body{FieldPath: nil}, }, }, }, }, }, }, } crossLinkFixture(file) testExtractServices(t, []*descriptorpb.FileDescriptorProto{&fd}, "path/to/example.proto", file.Services) } func TestExtractServicesWithoutAnnotation(t *testing.T) { src := ` name: "path/to/example.proto", package: "example" message_type < name: "StringMessage" field < name: "string" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING > > service < name: "ExampleService" method < name: "Echo" input_type: "StringMessage" output_type: "StringMessage" > > ` var fd descriptorpb.FileDescriptorProto if err := prototext.Unmarshal([]byte(src), &fd); err != nil { t.Fatalf("proto.UnmarshalText(%s, &fd) failed with %v; want success", src, err) } msg := &Message{ DescriptorProto: fd.MessageType[0], Fields: []*Field{ { FieldDescriptorProto: fd.MessageType[0].Field[0], }, }, } file := &File{ FileDescriptorProto: &fd, GoPkg: GoPackage{ Path: "path/to/example.pb", Name: "example_pb", }, Messages: []*Message{msg}, Services: []*Service{ { ServiceDescriptorProto: fd.Service[0], Methods: []*Method{ { MethodDescriptorProto: fd.Service[0].Method[0], RequestType: msg, ResponseType: msg, }, }, }, }, } crossLinkFixture(file) testExtractServices(t, []*descriptorpb.FileDescriptorProto{&fd}, "path/to/example.proto", file.Services) } func TestExtractServicesGenerateUnboundMethods(t *testing.T) { src := ` name: "path/to/example.proto", package: "example" message_type < name: "StringMessage" field < name: "string" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING > > service < name: "ExampleService" method < name: "Echo" input_type: "StringMessage" output_type: "StringMessage" > > ` var fd descriptorpb.FileDescriptorProto if err := prototext.Unmarshal([]byte(src), &fd); err != nil { t.Fatalf("prototext.Unmarshal (%s, &fd) failed with %v; want success", src, err) } msg := &Message{ DescriptorProto: fd.MessageType[0], Fields: []*Field{ { FieldDescriptorProto: fd.MessageType[0].Field[0], }, }, } file := &File{ FileDescriptorProto: &fd, GoPkg: GoPackage{ Path: "path/to/example.pb", Name: "example_pb", }, Messages: []*Message{msg}, Services: []*Service{ { ServiceDescriptorProto: fd.Service[0], Methods: []*Method{ { MethodDescriptorProto: fd.Service[0].Method[0], RequestType: msg, ResponseType: msg, Bindings: []*Binding{ { PathTmpl: compilePath(t, "/example.ExampleService/Echo"), HTTPMethod: "POST", Body: &Body{FieldPath: nil}, }, }, }, }, }, }, } crossLinkFixture(file) reg := NewRegistry() reg.SetGenerateUnboundMethods(true) testExtractServicesWithRegistry(t, reg, []*descriptorpb.FileDescriptorProto{&fd}, "path/to/example.proto", file.Services) } func TestExtractServicesCrossPackage(t *testing.T) { srcs := []string{ ` name: "path/to/example.proto", package: "example" message_type < name: "StringMessage" field < name: "string" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING > > service < name: "ExampleService" method < name: "ToString" input_type: ".another.example.BoolMessage" output_type: "StringMessage" options < [google.api.http] < post: "/v1/example/to_s" body: "*" > > > > `, ` name: "path/to/another/example.proto", package: "another.example" message_type < name: "BoolMessage" field < name: "bool" number: 1 label: LABEL_OPTIONAL type: TYPE_BOOL > > `, } var fds []*descriptorpb.FileDescriptorProto for _, src := range srcs { var fd descriptorpb.FileDescriptorProto if err := prototext.Unmarshal([]byte(src), &fd); err != nil { t.Fatalf("prototext.Unmarshal(%s, &fd) failed with %v; want success", src, err) } fds = append(fds, &fd) } stringMsg := &Message{ DescriptorProto: fds[0].MessageType[0], Fields: []*Field{ { FieldDescriptorProto: fds[0].MessageType[0].Field[0], }, }, } boolMsg := &Message{ DescriptorProto: fds[1].MessageType[0], Fields: []*Field{ { FieldDescriptorProto: fds[1].MessageType[0].Field[0], }, }, } files := []*File{ { FileDescriptorProto: fds[0], GoPkg: GoPackage{ Path: "path/to/example.pb", Name: "example_pb", }, Messages: []*Message{stringMsg}, Services: []*Service{ { ServiceDescriptorProto: fds[0].Service[0], Methods: []*Method{ { MethodDescriptorProto: fds[0].Service[0].Method[0], RequestType: boolMsg, ResponseType: stringMsg, Bindings: []*Binding{ { PathTmpl: compilePath(t, "/v1/example/to_s"), HTTPMethod: "POST", Body: &Body{FieldPath: nil}, }, }, }, }, }, }, }, { FileDescriptorProto: fds[1], GoPkg: GoPackage{ Path: "path/to/another/example.pb", Name: "example_pb", }, Messages: []*Message{boolMsg}, }, } for _, file := range files { crossLinkFixture(file) } testExtractServices(t, fds, "path/to/example.proto", files[0].Services) } func TestExtractServicesWithBodyPath(t *testing.T) { src := ` name: "path/to/example.proto", package: "example" message_type < name: "OuterMessage" nested_type < name: "StringMessage" field < name: "string" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING > > field < name: "nested" number: 1 label: LABEL_OPTIONAL type: TYPE_MESSAGE type_name: "StringMessage" > > service < name: "ExampleService" method < name: "Echo" input_type: "OuterMessage" output_type: "OuterMessage" options < [google.api.http] < post: "/v1/example/echo" body: "nested" > > > > ` var fd descriptorpb.FileDescriptorProto if err := prototext.Unmarshal([]byte(src), &fd); err != nil { t.Fatalf("proto.UnmarshalText(%s, &fd) failed with %v; want success", src, err) } msg := &Message{ DescriptorProto: fd.MessageType[0], Fields: []*Field{ { FieldDescriptorProto: fd.MessageType[0].Field[0], }, }, } file := &File{ FileDescriptorProto: &fd, GoPkg: GoPackage{ Path: "path/to/example.pb", Name: "example_pb", }, Messages: []*Message{msg}, Services: []*Service{ { ServiceDescriptorProto: fd.Service[0], Methods: []*Method{ { MethodDescriptorProto: fd.Service[0].Method[0], RequestType: msg, ResponseType: msg, Bindings: []*Binding{ { PathTmpl: compilePath(t, "/v1/example/echo"), HTTPMethod: "POST", Body: &Body{ FieldPath: FieldPath{ { Name: "nested", Target: msg.Fields[0], }, }, }, }, }, }, }, }, }, } crossLinkFixture(file) testExtractServices(t, []*descriptorpb.FileDescriptorProto{&fd}, "path/to/example.proto", file.Services) } func TestExtractServicesWithPathParam(t *testing.T) { src := ` name: "path/to/example.proto", package: "example" message_type < name: "StringMessage" field < name: "string" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING > > service < name: "ExampleService" method < name: "Echo" input_type: "StringMessage" output_type: "StringMessage" options < [google.api.http] < get: "/v1/example/echo/{string=*}" > > > > ` var fd descriptorpb.FileDescriptorProto if err := prototext.Unmarshal([]byte(src), &fd); err != nil { t.Fatalf("proto.UnmarshalText(%s, &fd) failed with %v; want success", src, err) } msg := &Message{ DescriptorProto: fd.MessageType[0], Fields: []*Field{ { FieldDescriptorProto: fd.MessageType[0].Field[0], }, }, } file := &File{ FileDescriptorProto: &fd, GoPkg: GoPackage{ Path: "path/to/example.pb", Name: "example_pb", }, Messages: []*Message{msg}, Services: []*Service{ { ServiceDescriptorProto: fd.Service[0], Methods: []*Method{ { MethodDescriptorProto: fd.Service[0].Method[0], RequestType: msg, ResponseType: msg, Bindings: []*Binding{ { PathTmpl: compilePath(t, "/v1/example/echo/{string=*}"), HTTPMethod: "GET", PathParams: []Parameter{ { FieldPath: FieldPath{ { Name: "string", Target: msg.Fields[0], }, }, Target: msg.Fields[0], }, }, }, }, }, }, }, }, } crossLinkFixture(file) testExtractServices(t, []*descriptorpb.FileDescriptorProto{&fd}, "path/to/example.proto", file.Services) } func TestExtractServicesWithAdditionalBinding(t *testing.T) { src := ` name: "path/to/example.proto", package: "example" message_type < name: "StringMessage" field < name: "string" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING > > service < name: "ExampleService" method < name: "Echo" input_type: "StringMessage" output_type: "StringMessage" options < [google.api.http] < post: "/v1/example/echo" body: "*" additional_bindings < get: "/v1/example/echo/{string}" > additional_bindings < post: "/v2/example/echo" body: "string" > > > > > ` var fd descriptorpb.FileDescriptorProto if err := prototext.Unmarshal([]byte(src), &fd); err != nil { t.Fatalf("proto.UnmarshalText(%s, &fd) failed with %v; want success", src, err) } msg := &Message{ DescriptorProto: fd.MessageType[0], Fields: []*Field{ { FieldDescriptorProto: fd.MessageType[0].Field[0], }, }, } file := &File{ FileDescriptorProto: &fd, GoPkg: GoPackage{ Path: "path/to/example.pb", Name: "example_pb", }, Messages: []*Message{msg}, Services: []*Service{ { ServiceDescriptorProto: fd.Service[0], Methods: []*Method{ { MethodDescriptorProto: fd.Service[0].Method[0], RequestType: msg, ResponseType: msg, Bindings: []*Binding{ { Index: 0, PathTmpl: compilePath(t, "/v1/example/echo"), HTTPMethod: "POST", Body: &Body{FieldPath: nil}, }, { Index: 1, PathTmpl: compilePath(t, "/v1/example/echo/{string}"), HTTPMethod: "GET", PathParams: []Parameter{ { FieldPath: FieldPath{ { Name: "string", Target: msg.Fields[0], }, }, Target: msg.Fields[0], }, }, Body: nil, }, { Index: 2, PathTmpl: compilePath(t, "/v2/example/echo"), HTTPMethod: "POST", Body: &Body{ FieldPath: FieldPath{ FieldPathComponent{ Name: "string", Target: msg.Fields[0], }, }, }, }, }, }, }, }, }, } crossLinkFixture(file) testExtractServices(t, []*descriptorpb.FileDescriptorProto{&fd}, "path/to/example.proto", file.Services) } func TestExtractServicesWithError(t *testing.T) { for _, spec := range []struct { target string srcs []string }{ { target: "path/to/example.proto", srcs: []string{ // message not found ` name: "path/to/example.proto", package: "example" service < name: "ExampleService" method < name: "Echo" input_type: "StringMessage" output_type: "StringMessage" options < [google.api.http] < post: "/v1/example/echo" body: "*" > > > > `, }, }, // body field path not resolved { target: "path/to/example.proto", srcs: []string{` name: "path/to/example.proto", package: "example" message_type < name: "StringMessage" field < name: "string" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING > > service < name: "ExampleService" method < name: "Echo" input_type: "StringMessage" output_type: "StringMessage" options < [google.api.http] < post: "/v1/example/echo" body: "bool" > > > >`, }, }, // param field path not resolved { target: "path/to/example.proto", srcs: []string{ ` name: "path/to/example.proto", package: "example" message_type < name: "StringMessage" field < name: "string" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING > > service < name: "ExampleService" method < name: "Echo" input_type: "StringMessage" output_type: "StringMessage" options < [google.api.http] < post: "/v1/example/echo/{bool=*}" > > > > `, }, }, // non aggregate type on field path { target: "path/to/example.proto", srcs: []string{ ` name: "path/to/example.proto", package: "example" message_type < name: "OuterMessage" field < name: "mid" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING > field < name: "bool" number: 2 label: LABEL_OPTIONAL type: TYPE_BOOL > > service < name: "ExampleService" method < name: "Echo" input_type: "OuterMessage" output_type: "OuterMessage" options < [google.api.http] < post: "/v1/example/echo/{mid.bool=*}" > > > > `, }, }, // path param in client streaming { target: "path/to/example.proto", srcs: []string{ ` name: "path/to/example.proto", package: "example" message_type < name: "StringMessage" field < name: "string" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING > > service < name: "ExampleService" method < name: "Echo" input_type: "StringMessage" output_type: "StringMessage" options < [google.api.http] < post: "/v1/example/echo/{bool=*}" > > client_streaming: true > > `, }, }, // body for GET { target: "path/to/example.proto", srcs: []string{ ` name: "path/to/example.proto", package: "example" message_type < name: "StringMessage" field < name: "string" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING > > service < name: "ExampleService" method < name: "Echo" input_type: "StringMessage" output_type: "StringMessage" options < [google.api.http] < get: "/v1/example/echo" body: "string" > > > > `, }, }, // body for DELETE { target: "path/to/example.proto", srcs: []string{ ` name: "path/to/example.proto", package: "example" message_type < name: "StringMessage" field < name: "string" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING > > service < name: "ExampleService" method < name: "RemoveResource" input_type: "StringMessage" output_type: "StringMessage" options < [google.api.http] < delete: "/v1/example/resource" body: "string" > > > > `, }, }, // no pattern specified { target: "path/to/example.proto", srcs: []string{ ` name: "path/to/example.proto", package: "example" service < name: "ExampleService" method < name: "RemoveResource" input_type: "StringMessage" output_type: "StringMessage" options < [google.api.http] < body: "string" > > > > `, }, }, // unsupported path parameter type { target: "path/to/example.proto", srcs: []string{` name: "path/to/example.proto", package: "example" message_type < name: "OuterMessage" nested_type < name: "StringMessage" field < name: "value" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING > > field < name: "string" number: 1 label: LABEL_OPTIONAL type: TYPE_MESSAGE type_name: "StringMessage" > > service < name: "ExampleService" method < name: "Echo" input_type: "OuterMessage" output_type: "OuterMessage" options < [google.api.http] < get: "/v1/example/echo/{string=*}" > > > > `, }, }, } { reg := NewRegistry() for _, src := range spec.srcs { var fd descriptorpb.FileDescriptorProto if err := prototext.Unmarshal([]byte(src), &fd); err != nil { t.Fatalf("proto.UnmarshalText(%s, &fd) failed with %v; want success", src, err) } reg.loadFile(spec.target, &protogen.File{ Proto: &fd, }) } err := reg.loadServices(reg.files[spec.target]) if err == nil { t.Errorf("loadServices(%q) succeeded; want an error; files=%v", spec.target, spec.srcs) } t.Log(err) } } func TestResolveFieldPath(t *testing.T) { for _, spec := range []struct { src string path string wantErr bool }{ { src: ` name: 'example.proto' package: 'example' message_type < name: 'ExampleMessage' field < name: 'string' type: TYPE_STRING label: LABEL_OPTIONAL number: 1 > > `, path: "string", wantErr: false, }, // no such field { src: ` name: 'example.proto' package: 'example' message_type < name: 'ExampleMessage' field < name: 'string' type: TYPE_STRING label: LABEL_OPTIONAL number: 1 > > `, path: "something_else", wantErr: true, }, // repeated field { src: ` name: 'example.proto' package: 'example' message_type < name: 'ExampleMessage' field < name: 'string' type: TYPE_STRING label: LABEL_REPEATED number: 1 > > `, path: "string", wantErr: false, }, // nested field { src: ` name: 'example.proto' package: 'example' message_type < name: 'ExampleMessage' field < name: 'nested' type: TYPE_MESSAGE type_name: 'AnotherMessage' label: LABEL_OPTIONAL number: 1 > field < name: 'terminal' type: TYPE_BOOL label: LABEL_OPTIONAL number: 2 > > message_type < name: 'AnotherMessage' field < name: 'nested2' type: TYPE_MESSAGE type_name: 'ExampleMessage' label: LABEL_OPTIONAL number: 1 > > `, path: "nested.nested2.nested.nested2.nested.nested2.terminal", wantErr: false, }, // non aggregate field on the path { src: ` name: 'example.proto' package: 'example' message_type < name: 'ExampleMessage' field < name: 'nested' type: TYPE_MESSAGE type_name: 'AnotherMessage' label: LABEL_OPTIONAL number: 1 > field < name: 'terminal' type: TYPE_BOOL label: LABEL_OPTIONAL number: 2 > > message_type < name: 'AnotherMessage' field < name: 'nested2' type: TYPE_MESSAGE type_name: 'ExampleMessage' label: LABEL_OPTIONAL number: 1 > > `, path: "nested.terminal.nested2", wantErr: true, }, // repeated field { src: ` name: 'example.proto' package: 'example' message_type < name: 'ExampleMessage' field < name: 'nested' type: TYPE_MESSAGE type_name: 'AnotherMessage' label: LABEL_OPTIONAL number: 1 > field < name: 'terminal' type: TYPE_BOOL label: LABEL_OPTIONAL number: 2 > > message_type < name: 'AnotherMessage' field < name: 'nested2' type: TYPE_MESSAGE type_name: 'ExampleMessage' label: LABEL_REPEATED number: 1 > > `, path: "nested.nested2.terminal", wantErr: false, }, } { var file descriptorpb.FileDescriptorProto if err := prototext.Unmarshal([]byte(spec.src), &file); err != nil { t.Fatalf("proto.Unmarshal(%s) failed with %v; want success", spec.src, err) } reg := NewRegistry() reg.loadFile(file.GetName(), &protogen.File{ Proto: &file, }) f, err := reg.LookupFile(file.GetName()) if err != nil { t.Fatalf("reg.LookupFile(%q) failed with %v; want success; on file=%s", file.GetName(), err, spec.src) } _, err = reg.resolveFieldPath(f.Messages[0], spec.path, false) if got, want := err != nil, spec.wantErr; got != want { if want { t.Errorf("reg.resolveFiledPath(%q, %q) succeeded; want an error", f.Messages[0].GetName(), spec.path) continue } t.Errorf("reg.resolveFiledPath(%q, %q) failed with %v; want success", f.Messages[0].GetName(), spec.path, err) } } } func TestExtractServicesWithDeleteBody(t *testing.T) { for _, spec := range []struct { allowDeleteBody bool expectErr bool target string srcs []string }{ // body for DELETE, but registry configured to allow it { allowDeleteBody: true, expectErr: false, target: "path/to/example.proto", srcs: []string{ ` name: "path/to/example.proto", package: "example" message_type < name: "StringMessage" field < name: "string" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING > > service < name: "ExampleService" method < name: "RemoveResource" input_type: "StringMessage" output_type: "StringMessage" options < [google.api.http] < delete: "/v1/example/resource" body: "string" > > > > `, }, }, // body for DELETE, registry configured not to allow it { allowDeleteBody: false, expectErr: true, target: "path/to/example.proto", srcs: []string{ ` name: "path/to/example.proto", package: "example" message_type < name: "StringMessage" field < name: "string" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING > > service < name: "ExampleService" method < name: "RemoveResource" input_type: "StringMessage" output_type: "StringMessage" options < [google.api.http] < delete: "/v1/example/resource" body: "string" > > > > `, }, }, } { reg := NewRegistry() reg.SetAllowDeleteBody(spec.allowDeleteBody) for _, src := range spec.srcs { var fd descriptorpb.FileDescriptorProto if err := prototext.Unmarshal([]byte(src), &fd); err != nil { t.Fatalf("proto.UnmarshalText(%s, &fd) failed with %v; want success", src, err) } reg.loadFile(fd.GetName(), &protogen.File{ Proto: &fd, }) } err := reg.loadServices(reg.files[spec.target]) if spec.expectErr && err == nil { t.Errorf("loadServices(%q) succeeded; want an error; allowDeleteBody=%v, files=%v", spec.target, spec.allowDeleteBody, spec.srcs) } if !spec.expectErr && err != nil { t.Errorf("loadServices(%q) failed; do not want an error; allowDeleteBody=%v, files=%v", spec.target, spec.allowDeleteBody, spec.srcs) } t.Log(err) } } func TestCauseErrorWithPathParam(t *testing.T) { src := ` name: "path/to/example.proto", package: "example" message_type < name: "TypeMessage" field < name: "message" type: TYPE_MESSAGE type_name: 'ExampleMessage' number: 1, label: LABEL_OPTIONAL > > service < name: "ExampleService" method < name: "Echo" input_type: "TypeMessage" output_type: "TypeMessage" options < [google.api.http] < get: "/v1/example/echo/{message=*}" > > > > ` var fd descriptorpb.FileDescriptorProto if err := prototext.Unmarshal([]byte(src), &fd); err != nil { t.Fatalf("proto.UnmarshalText(%s, &fd) failed with %v; want success", src, err) } target := "path/to/example.proto" reg := NewRegistry() input := []*descriptorpb.FileDescriptorProto{&fd} reg.loadFile(fd.GetName(), &protogen.File{ Proto: &fd, }) // switch this field to see the error wantErr := true err := reg.loadServices(reg.files[target]) if got, want := err != nil, wantErr; got != want { if want { t.Errorf("loadServices(%q, %q) succeeded; want an error", target, input) } t.Errorf("loadServices(%q, %q) failed with %v; want success", target, input, err) } } func TestOptionalProto3URLPathMappingSuccess(t *testing.T) { src := ` name: "path/to/example.proto" package: "example" message_type < name: "StringMessage" field < name: "field1" number: 1 type: TYPE_STRING proto3_optional: true > > service < name: "ExampleService" method < name: "Echo" input_type: "StringMessage" output_type: "StringMessage" options < [google.api.http] < get: "/v1/example/echo/{field1=*}" > > > > ` var fd descriptorpb.FileDescriptorProto if err := prototext.Unmarshal([]byte(src), &fd); err != nil { t.Fatalf("proto.UnmarshalText(%s, &fd) failed with %v; want success", src, err) } target := "path/to/example.proto" reg := NewRegistry() input := []*descriptorpb.FileDescriptorProto{&fd} reg.loadFile(fd.GetName(), &protogen.File{ Proto: &fd, }) err := reg.loadServices(reg.files[target]) if err != nil { t.Errorf("loadServices(%q, %q) failed with %v; want success", target, input, err) } } ================================================ FILE: internal/descriptor/types.go ================================================ package descriptor import ( "fmt" "strings" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/casing" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/httprule" "google.golang.org/protobuf/types/descriptorpb" "google.golang.org/protobuf/types/pluginpb" ) // IsWellKnownType returns true if the provided fully qualified type name is considered 'well-known'. func IsWellKnownType(typeName string) bool { _, ok := wellKnownTypeConv[typeName] return ok } // GoPackage represents a golang package. type GoPackage struct { // Path is the package path to the package. Path string // Name is the package name of the package Name string // Alias is an alias of the package unique within the current invocation of gRPC-Gateway generator. Alias string } // Standard returns whether the import is a golang standard package. func (p GoPackage) Standard() bool { return !strings.Contains(p.Path, ".") } // String returns a string representation of this package in the form of import line in golang. func (p GoPackage) String() string { if p.Alias == "" { return fmt.Sprintf("%q", p.Path) } return fmt.Sprintf("%s %q", p.Alias, p.Path) } // ResponseFile wraps pluginpb.CodeGeneratorResponse_File. type ResponseFile struct { *pluginpb.CodeGeneratorResponse_File // GoPkg is the Go package of the generated file. GoPkg GoPackage } // File wraps descriptorpb.FileDescriptorProto for richer features. type File struct { *descriptorpb.FileDescriptorProto // GoPkg is the go package of the go file generated from this file. GoPkg GoPackage // GeneratedFilenamePrefix is used to construct filenames for generated // files associated with this source file. // // For example, the source file "dir/foo.proto" might have a filename prefix // of "dir/foo". Appending ".pb.go" produces an output file of "dir/foo.pb.go". GeneratedFilenamePrefix string // Messages is the list of messages defined in this file. Messages []*Message // Enums is the list of enums defined in this file. Enums []*Enum // Services is the list of services defined in this file. Services []*Service } // Pkg returns package name or alias if it's present func (f *File) Pkg() string { pkg := f.GoPkg.Name if alias := f.GoPkg.Alias; alias != "" { pkg = alias } return pkg } // proto2 determines if the syntax of the file is proto2. func (f *File) proto2() bool { return f.Syntax == nil || f.GetSyntax() == "proto2" } // Message describes a protocol buffer message types. type Message struct { *descriptorpb.DescriptorProto // File is the file where the message is defined. File *File // Outers is a list of outer messages if this message is a nested type. Outers []string // Fields is a list of message fields. Fields []*Field // Index is proto path index of this message in File. Index int // ForcePrefixedName when set to true, prefixes a type with a package prefix. ForcePrefixedName bool } // FQMN returns a fully qualified message name of this message. func (m *Message) FQMN() string { components := []string{""} if m.File.Package != nil { components = append(components, m.File.GetPackage()) } components = append(components, m.Outers...) components = append(components, m.GetName()) return strings.Join(components, ".") } // GoType returns a go type name for the message type. // It prefixes the type name with the package alias if // its belonging package is not "currentPackage". func (m *Message) GoType(currentPackage string) string { name := goTypeName(m.Outers, m.GetName()) if !m.ForcePrefixedName && m.File.GoPkg.Path == currentPackage { return name } return fmt.Sprintf("%s.%s", m.File.Pkg(), name) } // Enum describes a protocol buffer enum types. type Enum struct { *descriptorpb.EnumDescriptorProto // File is the file where the enum is defined File *File // Outers is a list of outer messages if this enum is a nested type. Outers []string // Index is a enum index value. Index int // ForcePrefixedName when set to true, prefixes a type with a package prefix. ForcePrefixedName bool } // FQEN returns a fully qualified enum name of this enum. func (e *Enum) FQEN() string { components := []string{""} if e.File.Package != nil { components = append(components, e.File.GetPackage()) } components = append(components, e.Outers...) components = append(components, e.GetName()) return strings.Join(components, ".") } // GoType returns a go type name for the enum type. // It prefixes the type name with the package alias if // its belonging package is not "currentPackage". func (e *Enum) GoType(currentPackage string) string { name := goTypeName(e.Outers, e.GetName()) if !e.ForcePrefixedName && e.File.GoPkg.Path == currentPackage { return name } return fmt.Sprintf("%s.%s", e.File.Pkg(), name) } func goTypeName(outers []string, name string) string { components := make([]string, 0, len(outers)+1) for _, outer := range outers { components = append(components, casing.Camel(outer)) } components = append(components, casing.Camel(name)) return strings.Join(components, "_") } // Service wraps descriptorpb.ServiceDescriptorProto for richer features. type Service struct { *descriptorpb.ServiceDescriptorProto // File is the file where this service is defined. File *File // Methods is the list of methods defined in this service. Methods []*Method // ForcePrefixedName when set to true, prefixes a type with a package prefix. ForcePrefixedName bool } // FQSN returns the fully qualified service name of this service. func (s *Service) FQSN() string { components := []string{""} if s.File.Package != nil { components = append(components, s.File.GetPackage()) } components = append(components, s.GetName()) return strings.Join(components, ".") } // InstanceName returns object name of the service with package prefix if needed func (s *Service) InstanceName() string { if !s.ForcePrefixedName { return s.GetName() } return fmt.Sprintf("%s.%s", s.File.Pkg(), s.GetName()) } // ClientConstructorName returns name of the Client constructor with package prefix if needed func (s *Service) ClientConstructorName() string { constructor := "New" + s.GetName() + "Client" if !s.ForcePrefixedName { return constructor } return fmt.Sprintf("%s.%s", s.File.Pkg(), constructor) } // Method wraps descriptorpb.MethodDescriptorProto for richer features. type Method struct { *descriptorpb.MethodDescriptorProto // Service is the service which this method belongs to. Service *Service // RequestType is the message type of requests to this method. RequestType *Message // ResponseType is the message type of responses from this method. ResponseType *Message Bindings []*Binding } // FQMN returns a fully qualified rpc method name of this method. func (m *Method) FQMN() string { var components []string components = append(components, m.Service.FQSN()) components = append(components, m.GetName()) return strings.Join(components, ".") } // Binding describes how an HTTP endpoint is bound to a gRPC method. type Binding struct { // Method is the method which the endpoint is bound to. Method *Method // Index is a zero-origin index of the binding in the target method Index int // PathTmpl is path template where this method is mapped to. PathTmpl httprule.Template // HTTPMethod is the HTTP method which this method is mapped to. HTTPMethod string // PathParams is the list of parameters provided in HTTP request paths. PathParams []Parameter // Body describes parameters provided in HTTP request body. Body *Body // ResponseBody describes field in response struct to marshal in HTTP response body. ResponseBody *Body } // ExplicitParams returns a list of explicitly bound parameters of "b", // i.e. a union of field path for body and field paths for path parameters. func (b *Binding) ExplicitParams() []string { var result []string if b.Body != nil { result = append(result, b.Body.FieldPath.String()) } for _, p := range b.PathParams { result = append(result, p.FieldPath.String()) } return result } // Field wraps descriptorpb.FieldDescriptorProto for richer features. type Field struct { *descriptorpb.FieldDescriptorProto // Message is the message type which this field belongs to. Message *Message // FieldMessage is the message type of the field. FieldMessage *Message // ForcePrefixedName when set to true, prefixes a type with a package prefix. ForcePrefixedName bool } // FQFN returns a fully qualified field name of this field. func (f *Field) FQFN() string { return strings.Join([]string{f.Message.FQMN(), f.GetName()}, ".") } // Parameter is a parameter provided in http requests type Parameter struct { // FieldPath is a path to a proto field which this parameter is mapped to. FieldPath // Target is the proto field which this parameter is mapped to. Target *Field // Method is the method which this parameter is used for. Method *Method } // ConvertFuncExpr returns a go expression of a converter function. // The converter function converts a string into a value for the parameter. func (p Parameter) ConvertFuncExpr() (string, error) { tbl := proto3ConvertFuncs if !p.IsProto2() && p.IsRepeated() { tbl = proto3RepeatedConvertFuncs } else if !p.IsProto2() && p.IsOptionalProto3() { tbl = proto3OptionalConvertFuncs } else if p.IsProto2() && !p.IsRepeated() { tbl = proto2ConvertFuncs } else if p.IsProto2() && p.IsRepeated() { tbl = proto2RepeatedConvertFuncs } typ := p.Target.GetType() conv, ok := tbl[typ] if !ok { conv, ok = wellKnownTypeConv[p.Target.GetTypeName()] } if !ok { return "", fmt.Errorf("unsupported field type %s of parameter %s in %s.%s", typ, p.FieldPath, p.Method.Service.GetName(), p.Method.GetName()) } return conv, nil } // IsEnum returns true if the field is an enum type, otherwise false is returned. func (p Parameter) IsEnum() bool { return p.Target.GetType() == descriptorpb.FieldDescriptorProto_TYPE_ENUM } // IsRepeated returns true if the field is repeated, otherwise false is returned. func (p Parameter) IsRepeated() bool { return p.Target.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_REPEATED } // IsProto2 returns true if the field is proto2, otherwise false is returned. func (p Parameter) IsProto2() bool { return p.Target.Message.File.proto2() } // Body describes a http (request|response) body to be sent to the (method|client). // This is used in body and response_body options in google.api.HttpRule type Body struct { // FieldPath is a path to a proto field which the (request|response) body is mapped to. // The (request|response) body is mapped to the (request|response) type itself if FieldPath is empty. FieldPath FieldPath } // AssignableExpr returns an assignable expression in Go to be used to initialize method request object. // It starts with "msgExpr", which is the go expression of the method request object. func (b Body) AssignableExpr(msgExpr string, currentPackage string) string { return b.FieldPath.AssignableExpr(msgExpr, currentPackage) } // AssignableExprPrep returns preparatory statements for an assignable expression to initialize the // method request object. func (b Body) AssignableExprPrep(msgExpr string, currentPackage string) string { return b.FieldPath.AssignableExprPrep(msgExpr, currentPackage) } // FieldPath is a path to a field from a request message. type FieldPath []FieldPathComponent // String returns a string representation of the field path. func (p FieldPath) String() string { components := make([]string, 0, len(p)) for _, c := range p { components = append(components, c.Name) } return strings.Join(components, ".") } // IsNestedProto3 indicates whether the FieldPath is a nested Proto3 path. func (p FieldPath) IsNestedProto3() bool { if len(p) > 1 && !p[0].Target.Message.File.proto2() { return true } return false } // IsOptionalProto3 indicates whether the FieldPath is a proto3 optional field. func (p FieldPath) IsOptionalProto3() bool { if len(p) == 0 { return false } return p[0].Target.GetProto3Optional() } // AssignableExpr is an assignable expression in Go to be used to assign a value to the target field. // It starts with "msgExpr", which is the go expression of the method request object. Before using // such an expression the prep statements must be emitted first, in case the field path includes // a oneof. See FieldPath.AssignableExprPrep. func (p FieldPath) AssignableExpr(msgExpr string, currentPackage string) string { l := len(p) if l == 0 { return msgExpr } components := msgExpr for i, c := range p { // We need to check if the target is not proto3_optional first. // Under the hood, proto3_optional uses oneof to signal to old proto3 clients // that presence is tracked for this field. This oneof is known as a "synthetic" oneof. if !c.Target.GetProto3Optional() && c.Target.OneofIndex != nil { index := c.Target.OneofIndex msg := c.Target.Message oneOfName := casing.Camel(msg.GetOneofDecl()[*index].GetName()) oneofFieldName := msg.GoType(currentPackage) + "_" + c.AssignableExpr() if c.Target.ForcePrefixedName { oneofFieldName = msg.File.Pkg() + "." + msg.GetName() + "_" + c.AssignableExpr() } components = components + "." + oneOfName + ".(*" + oneofFieldName + ")" } if i == l-1 { components = components + "." + c.AssignableExpr() continue } components = components + "." + c.ValueExpr() } return components } // AssignableExprPrep returns preparation statements for an assignable expression to assign a value // to the target field. The Go expression of the method request object is "msgExpr". This is only // needed for field paths that contain oneofs. Otherwise, an empty string is returned. func (p FieldPath) AssignableExprPrep(msgExpr string, currentPackage string) string { l := len(p) if l == 0 { return "" } var preparations []string components := msgExpr for i, c := range p { // We need to check if the target is not proto3_optional first. // Under the hood, proto3_optional uses oneof to signal to old proto3 clients // that presence is tracked for this field. This oneof is known as a "synthetic" oneof. if !c.Target.GetProto3Optional() && c.Target.OneofIndex != nil { index := c.Target.OneofIndex msg := c.Target.Message oneOfName := casing.Camel(msg.GetOneofDecl()[*index].GetName()) oneofFieldName := msg.GoType(currentPackage) + "_" + c.AssignableExpr() if c.Target.ForcePrefixedName { oneofFieldName = msg.File.Pkg() + "." + msg.GetName() + "_" + c.AssignableExpr() } components = components + "." + oneOfName s := `if %s == nil { %s =&%s{} } else if _, ok := %s.(*%s); !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "expect type: *%s, but: %%t\n",%s) }` preparations = append(preparations, fmt.Sprintf(s, components, components, oneofFieldName, components, oneofFieldName, oneofFieldName, components)) components = components + ".(*" + oneofFieldName + ")" } if i == l-1 { components = components + "." + c.AssignableExpr() continue } components = components + "." + c.ValueExpr() } return strings.Join(preparations, "\n") } // OpaqueSetterExpr returns the Go expression to invoke the generated setter for // the final component in the path while respecting nested getters required by // the opaque API. func (p FieldPath) OpaqueSetterExpr(msgExpr string) string { if len(p) == 0 { return msgExpr } return fmt.Sprintf("%s.Set%s", p.opaqueOwnerExpr(msgExpr), casing.Camel(p[len(p)-1].Name)) } // opaqueOwnerExpr builds the Go expression for the message that owns the final // component in the path by chaining the generated getters. func (p FieldPath) opaqueOwnerExpr(msgExpr string) string { if len(p) <= 1 { return msgExpr } var sb strings.Builder sb.WriteString(msgExpr) for i := range len(p) - 1 { sb.WriteString(".Get") sb.WriteString(casing.Camel(p[i].Name)) sb.WriteString("()") } return sb.String() } // FieldPathComponent is a path component in FieldPath type FieldPathComponent struct { // Name is a name of the proto field which this component corresponds to. // TODO(yugui) is this necessary? Name string // Target is the proto field which this component corresponds to. Target *Field } // AssignableExpr returns an assignable expression in go for this field. func (c FieldPathComponent) AssignableExpr() string { return casing.Camel(c.Name) } // ValueExpr returns an expression in go for this field. func (c FieldPathComponent) ValueExpr() string { if c.Target.Message.File.proto2() { return fmt.Sprintf("Get%s()", casing.Camel(c.Name)) } return casing.Camel(c.Name) } var ( proto3ConvertFuncs = map[descriptorpb.FieldDescriptorProto_Type]string{ descriptorpb.FieldDescriptorProto_TYPE_DOUBLE: "runtime.Float64", descriptorpb.FieldDescriptorProto_TYPE_FLOAT: "runtime.Float32", descriptorpb.FieldDescriptorProto_TYPE_INT64: "runtime.Int64", descriptorpb.FieldDescriptorProto_TYPE_UINT64: "runtime.Uint64", descriptorpb.FieldDescriptorProto_TYPE_INT32: "runtime.Int32", descriptorpb.FieldDescriptorProto_TYPE_FIXED64: "runtime.Uint64", descriptorpb.FieldDescriptorProto_TYPE_FIXED32: "runtime.Uint32", descriptorpb.FieldDescriptorProto_TYPE_BOOL: "runtime.Bool", descriptorpb.FieldDescriptorProto_TYPE_STRING: "runtime.String", // FieldDescriptorProto_TYPE_GROUP // FieldDescriptorProto_TYPE_MESSAGE descriptorpb.FieldDescriptorProto_TYPE_BYTES: "runtime.Bytes", descriptorpb.FieldDescriptorProto_TYPE_UINT32: "runtime.Uint32", descriptorpb.FieldDescriptorProto_TYPE_ENUM: "runtime.Enum", descriptorpb.FieldDescriptorProto_TYPE_SFIXED32: "runtime.Int32", descriptorpb.FieldDescriptorProto_TYPE_SFIXED64: "runtime.Int64", descriptorpb.FieldDescriptorProto_TYPE_SINT32: "runtime.Int32", descriptorpb.FieldDescriptorProto_TYPE_SINT64: "runtime.Int64", } proto3OptionalConvertFuncs = func() map[descriptorpb.FieldDescriptorProto_Type]string { result := make(map[descriptorpb.FieldDescriptorProto_Type]string) for typ, converter := range proto3ConvertFuncs { // TODO: this will use convert functions from proto2. // The converters returning pointers should be moved // to a more generic file. result[typ] = converter + "P" } return result }() // TODO: replace it with a IIFE proto3RepeatedConvertFuncs = map[descriptorpb.FieldDescriptorProto_Type]string{ descriptorpb.FieldDescriptorProto_TYPE_DOUBLE: "runtime.Float64Slice", descriptorpb.FieldDescriptorProto_TYPE_FLOAT: "runtime.Float32Slice", descriptorpb.FieldDescriptorProto_TYPE_INT64: "runtime.Int64Slice", descriptorpb.FieldDescriptorProto_TYPE_UINT64: "runtime.Uint64Slice", descriptorpb.FieldDescriptorProto_TYPE_INT32: "runtime.Int32Slice", descriptorpb.FieldDescriptorProto_TYPE_FIXED64: "runtime.Uint64Slice", descriptorpb.FieldDescriptorProto_TYPE_FIXED32: "runtime.Uint32Slice", descriptorpb.FieldDescriptorProto_TYPE_BOOL: "runtime.BoolSlice", descriptorpb.FieldDescriptorProto_TYPE_STRING: "runtime.StringSlice", // FieldDescriptorProto_TYPE_GROUP // FieldDescriptorProto_TYPE_MESSAGE descriptorpb.FieldDescriptorProto_TYPE_BYTES: "runtime.BytesSlice", descriptorpb.FieldDescriptorProto_TYPE_UINT32: "runtime.Uint32Slice", descriptorpb.FieldDescriptorProto_TYPE_ENUM: "runtime.EnumSlice", descriptorpb.FieldDescriptorProto_TYPE_SFIXED32: "runtime.Int32Slice", descriptorpb.FieldDescriptorProto_TYPE_SFIXED64: "runtime.Int64Slice", descriptorpb.FieldDescriptorProto_TYPE_SINT32: "runtime.Int32Slice", descriptorpb.FieldDescriptorProto_TYPE_SINT64: "runtime.Int64Slice", } proto2ConvertFuncs = map[descriptorpb.FieldDescriptorProto_Type]string{ descriptorpb.FieldDescriptorProto_TYPE_DOUBLE: "runtime.Float64P", descriptorpb.FieldDescriptorProto_TYPE_FLOAT: "runtime.Float32P", descriptorpb.FieldDescriptorProto_TYPE_INT64: "runtime.Int64P", descriptorpb.FieldDescriptorProto_TYPE_UINT64: "runtime.Uint64P", descriptorpb.FieldDescriptorProto_TYPE_INT32: "runtime.Int32P", descriptorpb.FieldDescriptorProto_TYPE_FIXED64: "runtime.Uint64P", descriptorpb.FieldDescriptorProto_TYPE_FIXED32: "runtime.Uint32P", descriptorpb.FieldDescriptorProto_TYPE_BOOL: "runtime.BoolP", descriptorpb.FieldDescriptorProto_TYPE_STRING: "runtime.StringP", // FieldDescriptorProto_TYPE_GROUP // FieldDescriptorProto_TYPE_MESSAGE // FieldDescriptorProto_TYPE_BYTES // TODO(yugui) Handle bytes descriptorpb.FieldDescriptorProto_TYPE_UINT32: "runtime.Uint32P", descriptorpb.FieldDescriptorProto_TYPE_ENUM: "runtime.EnumP", descriptorpb.FieldDescriptorProto_TYPE_SFIXED32: "runtime.Int32P", descriptorpb.FieldDescriptorProto_TYPE_SFIXED64: "runtime.Int64P", descriptorpb.FieldDescriptorProto_TYPE_SINT32: "runtime.Int32P", descriptorpb.FieldDescriptorProto_TYPE_SINT64: "runtime.Int64P", } proto2RepeatedConvertFuncs = map[descriptorpb.FieldDescriptorProto_Type]string{ descriptorpb.FieldDescriptorProto_TYPE_DOUBLE: "runtime.Float64Slice", descriptorpb.FieldDescriptorProto_TYPE_FLOAT: "runtime.Float32Slice", descriptorpb.FieldDescriptorProto_TYPE_INT64: "runtime.Int64Slice", descriptorpb.FieldDescriptorProto_TYPE_UINT64: "runtime.Uint64Slice", descriptorpb.FieldDescriptorProto_TYPE_INT32: "runtime.Int32Slice", descriptorpb.FieldDescriptorProto_TYPE_FIXED64: "runtime.Uint64Slice", descriptorpb.FieldDescriptorProto_TYPE_FIXED32: "runtime.Uint32Slice", descriptorpb.FieldDescriptorProto_TYPE_BOOL: "runtime.BoolSlice", descriptorpb.FieldDescriptorProto_TYPE_STRING: "runtime.StringSlice", // FieldDescriptorProto_TYPE_GROUP // FieldDescriptorProto_TYPE_MESSAGE // FieldDescriptorProto_TYPE_BYTES // TODO(maros7) Handle bytes descriptorpb.FieldDescriptorProto_TYPE_UINT32: "runtime.Uint32Slice", descriptorpb.FieldDescriptorProto_TYPE_ENUM: "runtime.EnumSlice", descriptorpb.FieldDescriptorProto_TYPE_SFIXED32: "runtime.Int32Slice", descriptorpb.FieldDescriptorProto_TYPE_SFIXED64: "runtime.Int64Slice", descriptorpb.FieldDescriptorProto_TYPE_SINT32: "runtime.Int32Slice", descriptorpb.FieldDescriptorProto_TYPE_SINT64: "runtime.Int64Slice", } wellKnownTypeConv = map[string]string{ ".google.protobuf.Timestamp": "runtime.Timestamp", ".google.protobuf.Duration": "runtime.Duration", ".google.protobuf.StringValue": "runtime.StringValue", ".google.protobuf.FloatValue": "runtime.FloatValue", ".google.protobuf.DoubleValue": "runtime.DoubleValue", ".google.protobuf.BoolValue": "runtime.BoolValue", ".google.protobuf.BytesValue": "runtime.BytesValue", ".google.protobuf.Int32Value": "runtime.Int32Value", ".google.protobuf.UInt32Value": "runtime.UInt32Value", ".google.protobuf.Int64Value": "runtime.Int64Value", ".google.protobuf.UInt64Value": "runtime.UInt64Value", } ) ================================================ FILE: internal/descriptor/types_test.go ================================================ package descriptor import ( "testing" "google.golang.org/protobuf/encoding/prototext" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/descriptorpb" ) func TestGoPackageStandard(t *testing.T) { for _, spec := range []struct { pkg GoPackage want bool }{ { pkg: GoPackage{Path: "fmt", Name: "fmt"}, want: true, }, { pkg: GoPackage{Path: "encoding/json", Name: "json"}, want: true, }, { pkg: GoPackage{Path: "google.golang.org/protobuf/encoding/protojson", Name: "jsonpb"}, want: false, }, { pkg: GoPackage{Path: "golang.org/x/net/context", Name: "context"}, want: false, }, { pkg: GoPackage{Path: "github.com/grpc-ecosystem/grpc-gateway", Name: "main"}, want: false, }, { pkg: GoPackage{Path: "github.com/google/googleapis/google/api/http.pb", Name: "http_pb", Alias: "htpb"}, want: false, }, } { if got, want := spec.pkg.Standard(), spec.want; got != want { t.Errorf("%#v.Standard() = %v; want %v", spec.pkg, got, want) } } } func TestGoPackageString(t *testing.T) { for _, spec := range []struct { pkg GoPackage want string }{ { pkg: GoPackage{Path: "fmt", Name: "fmt"}, want: `"fmt"`, }, { pkg: GoPackage{Path: "encoding/json", Name: "json"}, want: `"encoding/json"`, }, { pkg: GoPackage{Path: "google.golang.org/protobuf/encoding/protojson", Name: "jsonpb"}, want: `"google.golang.org/protobuf/encoding/protojson"`, }, { pkg: GoPackage{Path: "golang.org/x/net/context", Name: "context"}, want: `"golang.org/x/net/context"`, }, { pkg: GoPackage{Path: "github.com/grpc-ecosystem/grpc-gateway", Name: "main"}, want: `"github.com/grpc-ecosystem/grpc-gateway"`, }, { pkg: GoPackage{Path: "github.com/google/googleapis/google/api/http.pb", Name: "http_pb", Alias: "htpb"}, want: `htpb "github.com/google/googleapis/google/api/http.pb"`, }, } { if got, want := spec.pkg.String(), spec.want; got != want { t.Errorf("%#v.String() = %q; want %q", spec.pkg, got, want) } } } func TestFieldPath(t *testing.T) { var fds []*descriptorpb.FileDescriptorProto for _, src := range []string{ ` name: 'example.proto' package: 'example' message_type < name: 'Nest' field < name: 'nest2_field' label: LABEL_OPTIONAL type: TYPE_MESSAGE type_name: 'Nest2' number: 1 > field < name: 'terminal_field' label: LABEL_OPTIONAL type: TYPE_STRING number: 2 > > syntax: "proto3" `, ` name: 'another.proto' package: 'example' message_type < name: 'Nest2' field < name: 'nest_field' label: LABEL_OPTIONAL type: TYPE_MESSAGE type_name: 'Nest' number: 1 > field < name: 'terminal_field' label: LABEL_OPTIONAL type: TYPE_STRING number: 2 > > syntax: "proto2" `, } { var fd descriptorpb.FileDescriptorProto if err := prototext.Unmarshal([]byte(src), &fd); err != nil { t.Fatalf("proto.UnmarshalText(%s, &fd) failed with %v; want success", src, err) } fds = append(fds, &fd) } nest1 := &Message{ DescriptorProto: fds[0].MessageType[0], Fields: []*Field{ {FieldDescriptorProto: fds[0].MessageType[0].Field[0]}, {FieldDescriptorProto: fds[0].MessageType[0].Field[1]}, }, } nest2 := &Message{ DescriptorProto: fds[1].MessageType[0], Fields: []*Field{ {FieldDescriptorProto: fds[1].MessageType[0].Field[0]}, {FieldDescriptorProto: fds[1].MessageType[0].Field[1]}, }, } file1 := &File{ FileDescriptorProto: fds[0], GoPkg: GoPackage{Path: "example", Name: "example"}, Messages: []*Message{nest1}, } file2 := &File{ FileDescriptorProto: fds[1], GoPkg: GoPackage{Path: "example", Name: "example"}, Messages: []*Message{nest2}, } crossLinkFixture(file1) crossLinkFixture(file2) c1 := FieldPathComponent{ Name: "nest_field", Target: nest2.Fields[0], } if got, want := c1.ValueExpr(), "GetNestField()"; got != want { t.Errorf("c1.ValueExpr() = %q; want %q", got, want) } if got, want := c1.AssignableExpr(), "NestField"; got != want { t.Errorf("c1.AssignableExpr() = %q; want %q", got, want) } c2 := FieldPathComponent{ Name: "nest2_field", Target: nest1.Fields[0], } if got, want := c2.ValueExpr(), "Nest2Field"; got != want { t.Errorf("c2.ValueExpr() = %q; want %q", got, want) } if got, want := c2.ValueExpr(), "Nest2Field"; got != want { t.Errorf("c2.ValueExpr() = %q; want %q", got, want) } fp := FieldPath{ c1, c2, c1, FieldPathComponent{ Name: "terminal_field", Target: nest1.Fields[1], }, } if got, want := fp.AssignableExpr("resp", "example"), "resp.GetNestField().Nest2Field.GetNestField().TerminalField"; got != want { t.Errorf("fp.AssignableExpr(%q) = %q; want %q", "resp", got, want) } fp2 := FieldPath{ c2, c1, c2, FieldPathComponent{ Name: "terminal_field", Target: nest2.Fields[1], }, } if got, want := fp2.AssignableExpr("resp", "example"), "resp.Nest2Field.GetNestField().Nest2Field.TerminalField"; got != want { t.Errorf("fp2.AssignableExpr(%q) = %q; want %q", "resp", got, want) } var fpEmpty FieldPath if got, want := fpEmpty.AssignableExpr("resp", "example"), "resp"; got != want { t.Errorf("fpEmpty.AssignableExpr(%q) = %q; want %q", "resp", got, want) } } func TestFieldPathOpaqueSetterExpr(t *testing.T) { tcs := map[string]struct { fieldPath FieldPath msgExpr string want string }{ "top-level field": { fieldPath: FieldPath{{Name: "data"}}, msgExpr: "req", want: "req.SetData", }, "nested field": { fieldPath: FieldPath{{Name: "key"}, {Name: "date_type"}}, msgExpr: "req", want: "req.GetKey().SetDateType", }, } for name, tc := range tcs { t.Run(name, func(t *testing.T) { if got := tc.fieldPath.OpaqueSetterExpr(tc.msgExpr); got != tc.want { t.Fatalf("OpaqueSetterExpr(%q) = %q; want %q", tc.msgExpr, got, tc.want) } }) } } func TestGoType(t *testing.T) { src := ` name: 'example.proto' package: 'example' message_type < name: 'Message' field < name: 'field' type: TYPE_STRING number: 1 > >, enum_type < name: 'EnumName' >, ` var fd descriptorpb.FileDescriptorProto if err := prototext.Unmarshal([]byte(src), &fd); err != nil { t.Fatalf("proto.UnmarshalText(%s, &fd) failed with %v; want success", src, err) } msg := &Message{ DescriptorProto: fd.MessageType[0], Fields: []*Field{ {FieldDescriptorProto: fd.MessageType[0].Field[0]}, }, } enum := &Enum{ EnumDescriptorProto: fd.EnumType[0], } underscoreMsgDesc := &descriptorpb.DescriptorProto{ Name: proto.String("create_book"), } fd.MessageType = append(fd.MessageType, underscoreMsgDesc) underscoreEnumDesc := &descriptorpb.EnumDescriptorProto{ Name: proto.String("status_enum"), } fd.EnumType = append(fd.EnumType, underscoreEnumDesc) underscoreMsg := &Message{ DescriptorProto: underscoreMsgDesc, } underscoreEnum := &Enum{ EnumDescriptorProto: underscoreEnumDesc, } file := &File{ FileDescriptorProto: &fd, GoPkg: GoPackage{Path: "example", Name: "example"}, Messages: []*Message{msg, underscoreMsg}, Enums: []*Enum{enum, underscoreEnum}, } crossLinkFixture(file) if got, want := msg.GoType("example"), "Message"; got != want { t.Errorf("msg.GoType() = %q; want %q", got, want) } if got, want := msg.GoType("extPackage"), "example.Message"; got != want { t.Errorf("msg.GoType() = %q; want %q", got, want) } msg.ForcePrefixedName = true if got, want := msg.GoType("example"), "example.Message"; got != want { t.Errorf("msg.GoType() = %q; want %q", got, want) } if got, want := enum.GoType("example"), "EnumName"; got != want { t.Errorf("enum.GoType() = %q; want %q", got, want) } if got, want := enum.GoType("extPackage"), "example.EnumName"; got != want { t.Errorf("enum.GoType() = %q; want %q", got, want) } enum.ForcePrefixedName = true if got, want := enum.GoType("example"), "example.EnumName"; got != want { t.Errorf("enum.GoType() = %q; want %q", got, want) } if got, want := underscoreMsg.GoType("example"), "CreateBook"; got != want { t.Errorf("underscoreMsg.GoType() = %q; want %q", got, want) } if got, want := underscoreMsg.GoType("extPackage"), "example.CreateBook"; got != want { t.Errorf("underscoreMsg.GoType() with ext package = %q; want %q", got, want) } if got, want := underscoreEnum.GoType("example"), "StatusEnum"; got != want { t.Errorf("underscoreEnum.GoType() = %q; want %q", got, want) } if got, want := underscoreEnum.GoType("extPackage"), "example.StatusEnum"; got != want { t.Errorf("underscoreEnum.GoType() with ext package = %q; want %q", got, want) } } ================================================ FILE: internal/generator/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library") package(default_visibility = ["//visibility:public"]) go_library( name = "generator", srcs = ["generator.go"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/internal/generator", deps = ["//internal/descriptor"], ) alias( name = "go_default_library", actual = ":generator", visibility = ["//:__subpackages__"], ) ================================================ FILE: internal/generator/generator.go ================================================ // Package generator provides an abstract interface to code generators. package generator import ( "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor" ) // Generator is an abstraction of code generators. type Generator interface { // Generate generates output files from input .proto files. Generate(targets []*descriptor.File) ([]*descriptor.ResponseFile, error) } ================================================ FILE: internal/httprule/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") package(default_visibility = ["//visibility:public"]) go_library( name = "httprule", srcs = [ "compile.go", "parse.go", "types.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/internal/httprule", deps = ["//utilities"], ) go_test( name = "httprule_test", size = "small", srcs = [ "compile_test.go", "parse_test.go", "types_test.go", ], embed = [":httprule"], deps = [ "//utilities", "@org_golang_google_grpc//grpclog", ], ) alias( name = "go_default_library", actual = ":httprule", visibility = ["//:__subpackages__"], ) ================================================ FILE: internal/httprule/compile.go ================================================ package httprule import ( "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" ) const ( opcodeVersion = 1 ) // Template is a compiled representation of path templates. type Template struct { // Version is the version number of the format. Version int // OpCodes is a sequence of operations. OpCodes []int // Pool is a constant pool Pool []string // Verb is a VERB part in the template. Verb string // Fields is a list of field paths bound in this template. Fields []string // Original template (example: /v1/a_bit_of_everything) Template string } // Compiler compiles utilities representation of path templates into marshallable operations. // They can be unmarshalled by runtime.NewPattern. type Compiler interface { Compile() Template } type op struct { // code is the opcode of the operation code utilities.OpCode // str is a string operand of the code. // num is ignored if str is not empty. str string // num is a numeric operand of the code. num int } func (w wildcard) compile() []op { return []op{ {code: utilities.OpPush}, } } func (w deepWildcard) compile() []op { return []op{ {code: utilities.OpPushM}, } } func (l literal) compile() []op { return []op{ { code: utilities.OpLitPush, str: string(l), }, } } func (v variable) compile() []op { var ops []op for _, s := range v.segments { ops = append(ops, s.compile()...) } ops = append(ops, op{ code: utilities.OpConcatN, num: len(v.segments), }, op{ code: utilities.OpCapture, str: v.path, }) return ops } func (t template) Compile() Template { var rawOps []op for _, s := range t.segments { rawOps = append(rawOps, s.compile()...) } var ( ops []int pool []string fields []string ) consts := make(map[string]int) for _, op := range rawOps { ops = append(ops, int(op.code)) if op.str == "" { ops = append(ops, op.num) } else { // eof segment literal represents the "/" path pattern if op.str == eof { op.str = "" } if _, ok := consts[op.str]; !ok { consts[op.str] = len(pool) pool = append(pool, op.str) } ops = append(ops, consts[op.str]) } if op.code == utilities.OpCapture { fields = append(fields, op.str) } } return Template{ Version: opcodeVersion, OpCodes: ops, Pool: pool, Verb: t.verb, Fields: fields, Template: t.template, } } ================================================ FILE: internal/httprule/compile_test.go ================================================ package httprule import ( "reflect" "testing" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" ) const ( operandFiller = 0 ) func TestCompile(t *testing.T) { for _, spec := range []struct { segs []segment verb string ops []int pool []string fields []string }{ {}, { segs: []segment{ literal(eof), }, ops: []int{int(utilities.OpLitPush), 0}, pool: []string{""}, }, { segs: []segment{ wildcard{}, }, ops: []int{int(utilities.OpPush), operandFiller}, }, { segs: []segment{ deepWildcard{}, }, ops: []int{int(utilities.OpPushM), operandFiller}, }, { segs: []segment{ literal("v1"), }, ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"v1"}, }, { segs: []segment{ literal("v1"), }, verb: "LOCK", ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"v1"}, }, { segs: []segment{ variable{ path: "name.nested", segments: []segment{ wildcard{}, }, }, }, ops: []int{ int(utilities.OpPush), operandFiller, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 0, }, pool: []string{"name.nested"}, fields: []string{"name.nested"}, }, { segs: []segment{ literal("obj"), variable{ path: "name.nested", segments: []segment{ literal("a"), wildcard{}, literal("b"), }, }, variable{ path: "obj", segments: []segment{ deepWildcard{}, }, }, }, ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpLitPush), 1, int(utilities.OpPush), operandFiller, int(utilities.OpLitPush), 2, int(utilities.OpConcatN), 3, int(utilities.OpCapture), 3, int(utilities.OpPushM), operandFiller, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 0, }, pool: []string{"obj", "a", "b", "name.nested"}, fields: []string{"name.nested", "obj"}, }, } { tmpl := template{ segments: spec.segs, verb: spec.verb, } compiled := tmpl.Compile() if got, want := compiled.Version, opcodeVersion; got != want { t.Errorf("tmpl.Compile().Version = %d; want %d; segs=%#v, verb=%q", got, want, spec.segs, spec.verb) } if got, want := compiled.OpCodes, spec.ops; !reflect.DeepEqual(got, want) { t.Errorf("tmpl.Compile().OpCodes = %v; want %v; segs=%#v, verb=%q", got, want, spec.segs, spec.verb) } if got, want := compiled.Pool, spec.pool; !reflect.DeepEqual(got, want) { t.Errorf("tmpl.Compile().Pool = %q; want %q; segs=%#v, verb=%q", got, want, spec.segs, spec.verb) } if got, want := compiled.Verb, spec.verb; got != want { t.Errorf("tmpl.Compile().Verb = %q; want %q; segs=%#v, verb=%q", got, want, spec.segs, spec.verb) } if got, want := compiled.Fields, spec.fields; !reflect.DeepEqual(got, want) { t.Errorf("tmpl.Compile().Fields = %q; want %q; segs=%#v, verb=%q", got, want, spec.segs, spec.verb) } } } ================================================ FILE: internal/httprule/fuzz.go ================================================ //go:build gofuzz // +build gofuzz package httprule func Fuzz(data []byte) int { if _, err := Parse(string(data)); err != nil { return 0 } return 0 } ================================================ FILE: internal/httprule/parse.go ================================================ package httprule import ( "errors" "fmt" "strings" ) // InvalidTemplateError indicates that the path template is not valid. type InvalidTemplateError struct { tmpl string msg string } func (e InvalidTemplateError) Error() string { return fmt.Sprintf("%s: %s", e.msg, e.tmpl) } // Parse parses the string representation of path template func Parse(tmpl string) (Compiler, error) { if !strings.HasPrefix(tmpl, "/") { return template{}, InvalidTemplateError{tmpl: tmpl, msg: "no leading /"} } tokens, verb := tokenize(tmpl[1:]) p := parser{tokens: tokens} segs, err := p.topLevelSegments() if err != nil { return template{}, InvalidTemplateError{tmpl: tmpl, msg: err.Error()} } return template{ segments: segs, verb: verb, template: tmpl, }, nil } func tokenize(path string) (tokens []string, verb string) { if path == "" { return []string{eof}, "" } const ( init = iota field nested ) st := init for path != "" { var idx int switch st { case init: idx = strings.IndexAny(path, "/{") case field: idx = strings.IndexAny(path, ".=}") case nested: idx = strings.IndexAny(path, "/}") } if idx < 0 { tokens = append(tokens, path) break } switch r := path[idx]; r { case '/', '.': case '{': st = field case '=': st = nested case '}': st = init } if idx == 0 { tokens = append(tokens, path[idx:idx+1]) } else { tokens = append(tokens, path[:idx], path[idx:idx+1]) } path = path[idx+1:] } l := len(tokens) // See // https://github.com/grpc-ecosystem/grpc-gateway/pull/1947#issuecomment-774523693 ; // although normal and backwards-compat logic here is to use the last index // of a colon, if the final segment is a variable followed by a colon, the // part following the colon must be a verb. Hence if the previous token is // an end var marker, we switch the index we're looking for to Index instead // of LastIndex, so that we correctly grab the remaining part of the path as // the verb. var penultimateTokenIsEndVar bool switch l { case 0, 1: // Not enough to be variable so skip this logic and don't result in an // invalid index default: penultimateTokenIsEndVar = tokens[l-2] == "}" } t := tokens[l-1] var idx int if penultimateTokenIsEndVar { idx = strings.Index(t, ":") } else { idx = strings.LastIndex(t, ":") } if idx == 0 { tokens, verb = tokens[:l-1], t[1:] } else if idx > 0 { tokens[l-1], verb = t[:idx], t[idx+1:] } tokens = append(tokens, eof) return tokens, verb } // parser is a parser of the template syntax defined in github.com/googleapis/googleapis/google/api/http.proto. type parser struct { tokens []string accepted []string } // topLevelSegments is the target of this parser. func (p *parser) topLevelSegments() ([]segment, error) { if _, err := p.accept(typeEOF); err == nil { p.tokens = p.tokens[:0] return []segment{literal(eof)}, nil } segs, err := p.segments() if err != nil { return nil, err } if _, err := p.accept(typeEOF); err != nil { return nil, fmt.Errorf("unexpected token %q after segments %q", p.tokens[0], strings.Join(p.accepted, "")) } return segs, nil } func (p *parser) segments() ([]segment, error) { s, err := p.segment() if err != nil { return nil, err } segs := []segment{s} for { if _, err := p.accept("/"); err != nil { return segs, nil } s, err := p.segment() if err != nil { return segs, err } segs = append(segs, s) } } func (p *parser) segment() (segment, error) { if _, err := p.accept("*"); err == nil { return wildcard{}, nil } if _, err := p.accept("**"); err == nil { return deepWildcard{}, nil } if l, err := p.literal(); err == nil { return l, nil } v, err := p.variable() if err != nil { return nil, fmt.Errorf("segment neither wildcards, literal or variable: %w", err) } return v, nil } func (p *parser) literal() (segment, error) { lit, err := p.accept(typeLiteral) if err != nil { return nil, err } return literal(lit), nil } func (p *parser) variable() (segment, error) { if _, err := p.accept("{"); err != nil { return nil, err } path, err := p.fieldPath() if err != nil { return nil, err } var segs []segment if _, err := p.accept("="); err == nil { segs, err = p.segments() if err != nil { return nil, fmt.Errorf("invalid segment in variable %q: %w", path, err) } } else { segs = []segment{wildcard{}} } if _, err := p.accept("}"); err != nil { return nil, fmt.Errorf("unterminated variable segment: %s", path) } return variable{ path: path, segments: segs, }, nil } func (p *parser) fieldPath() (string, error) { c, err := p.accept(typeIdent) if err != nil { return "", err } components := []string{c} for { if _, err := p.accept("."); err != nil { return strings.Join(components, "."), nil } c, err := p.accept(typeIdent) if err != nil { return "", fmt.Errorf("invalid field path component: %w", err) } components = append(components, c) } } // A termType is a type of terminal symbols. type termType string // These constants define some of valid values of termType. // They improve readability of parse functions. // // You can also use "/", "*", "**", "." or "=" as valid values. const ( typeIdent = termType("ident") typeLiteral = termType("literal") typeEOF = termType("$") ) // eof is the terminal symbol which always appears at the end of token sequence. const eof = "\u0000" // accept tries to accept a token in "p". // This function consumes a token and returns it if it matches to the specified "term". // If it doesn't match, the function does not consume any tokens and return an error. func (p *parser) accept(term termType) (string, error) { t := p.tokens[0] switch term { case "/", "*", "**", ".", "=", "{", "}": if t != string(term) && t != "/" { return "", fmt.Errorf("expected %q but got %q", term, t) } case typeEOF: if t != eof { return "", fmt.Errorf("expected EOF but got %q", t) } case typeIdent: if err := expectIdent(t); err != nil { return "", err } case typeLiteral: if err := expectPChars(t); err != nil { return "", err } default: return "", fmt.Errorf("unknown termType %q", term) } p.tokens = p.tokens[1:] p.accepted = append(p.accepted, t) return t, nil } // expectPChars determines if "t" consists of only pchars defined in RFC3986. // // https://www.ietf.org/rfc/rfc3986.txt, P.49 // // pchar = unreserved / pct-encoded / sub-delims / ":" / "@" // unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" // sub-delims = "!" / "$" / "&" / "'" / "(" / ")" // / "*" / "+" / "," / ";" / "=" // pct-encoded = "%" HEXDIG HEXDIG func expectPChars(t string) error { const ( init = iota pct1 pct2 ) st := init for _, r := range t { if st != init { if !isHexDigit(r) { return fmt.Errorf("invalid hexdigit: %c(%U)", r, r) } switch st { case pct1: st = pct2 case pct2: st = init } continue } // unreserved switch { case 'A' <= r && r <= 'Z': continue case 'a' <= r && r <= 'z': continue case '0' <= r && r <= '9': continue } switch r { case '-', '.', '_', '~': // unreserved case '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=': // sub-delims case ':', '@': // rest of pchar case '%': // pct-encoded st = pct1 default: return fmt.Errorf("invalid character in path segment: %q(%U)", r, r) } } if st != init { return fmt.Errorf("invalid percent-encoding in %q", t) } return nil } // expectIdent determines if "ident" is a valid identifier in .proto schema ([[:alpha:]_][[:alphanum:]_]*). func expectIdent(ident string) error { if ident == "" { return errors.New("empty identifier") } for pos, r := range ident { switch { case '0' <= r && r <= '9': if pos == 0 { return fmt.Errorf("identifier starting with digit: %s", ident) } continue case 'A' <= r && r <= 'Z': continue case 'a' <= r && r <= 'z': continue case r == '_': continue default: return fmt.Errorf("invalid character %q(%U) in identifier: %s", r, r, ident) } } return nil } func isHexDigit(r rune) bool { switch { case '0' <= r && r <= '9': return true case 'A' <= r && r <= 'F': return true case 'a' <= r && r <= 'f': return true } return false } ================================================ FILE: internal/httprule/parse_test.go ================================================ package httprule import ( "errors" "fmt" "reflect" "testing" "google.golang.org/grpc/grpclog" ) func TestTokenize(t *testing.T) { for _, spec := range []struct { src string tokens []string verb string }{ { src: "", tokens: []string{eof}, }, { src: "v1", tokens: []string{"v1", eof}, }, { src: "v1/b", tokens: []string{"v1", "/", "b", eof}, }, { src: "v1/endpoint/*", tokens: []string{"v1", "/", "endpoint", "/", "*", eof}, }, { src: "v1/endpoint/**", tokens: []string{"v1", "/", "endpoint", "/", "**", eof}, }, { src: "v1/b/{bucket_name=*}", tokens: []string{ "v1", "/", "b", "/", "{", "bucket_name", "=", "*", "}", eof, }, }, { src: "v1/b/{bucket_name=buckets/*}", tokens: []string{ "v1", "/", "b", "/", "{", "bucket_name", "=", "buckets", "/", "*", "}", eof, }, }, { src: "v1/b/{bucket_name=buckets/*}/o", tokens: []string{ "v1", "/", "b", "/", "{", "bucket_name", "=", "buckets", "/", "*", "}", "/", "o", eof, }, }, { src: "v1/b/{bucket_name=buckets/*}/o/{name}", tokens: []string{ "v1", "/", "b", "/", "{", "bucket_name", "=", "buckets", "/", "*", "}", "/", "o", "/", "{", "name", "}", eof, }, }, { src: "v1/a=b&c=d;e=f:g/endpoint.rdf", tokens: []string{ "v1", "/", "a=b&c=d;e=f:g", "/", "endpoint.rdf", eof, }, }, { src: "v1/a/{endpoint}:a", tokens: []string{ "v1", "/", "a", "/", "{", "endpoint", "}", eof, }, verb: "a", }, { src: "v1/a/{endpoint}:b:c", tokens: []string{ "v1", "/", "a", "/", "{", "endpoint", "}", eof, }, verb: "b:c", }, } { tokens, verb := tokenize(spec.src) if got, want := tokens, spec.tokens; !reflect.DeepEqual(got, want) { t.Errorf("tokenize(%q) = %q, _; want %q, _", spec.src, got, want) } switch { case spec.verb != "": if got, want := verb, spec.verb; !reflect.DeepEqual(got, want) { t.Errorf("tokenize(%q) = %q, _; want %q, _", spec.src, got, want) } default: if got, want := verb, ""; got != want { t.Errorf("tokenize(%q) = _, %q; want _, %q", spec.src, got, want) } src := fmt.Sprintf("%s:%s", spec.src, "LOCK") tokens, verb = tokenize(src) if got, want := tokens, spec.tokens; !reflect.DeepEqual(got, want) { t.Errorf("tokenize(%q) = %q, _; want %q, _", src, got, want) } if got, want := verb, "LOCK"; got != want { t.Errorf("tokenize(%q) = _, %q; want _, %q", src, got, want) } } } } func TestParseSegments(t *testing.T) { for _, spec := range []struct { tokens []string want []segment }{ { tokens: []string{eof}, want: []segment{ literal(eof), }, }, { // Note: this case will never arise as tokenize() will never return such a sequence of tokens // and even if it does it will be treated as [eof] tokens: []string{eof, "v1", eof}, want: []segment{ literal(eof), }, }, { tokens: []string{"v1", eof}, want: []segment{ literal("v1"), }, }, { tokens: []string{"/", eof}, want: []segment{ wildcard{}, }, }, { tokens: []string{"-._~!$&'()*+,;=:@", eof}, want: []segment{ literal("-._~!$&'()*+,;=:@"), }, }, { tokens: []string{"%e7%ac%ac%e4%b8%80%e7%89%88", eof}, want: []segment{ literal("%e7%ac%ac%e4%b8%80%e7%89%88"), }, }, { tokens: []string{"v1", "/", "*", eof}, want: []segment{ literal("v1"), wildcard{}, }, }, { tokens: []string{"v1", "/", "**", eof}, want: []segment{ literal("v1"), deepWildcard{}, }, }, { tokens: []string{"{", "name", "}", eof}, want: []segment{ variable{ path: "name", segments: []segment{ wildcard{}, }, }, }, }, { tokens: []string{"{", "name", "=", "*", "}", eof}, want: []segment{ variable{ path: "name", segments: []segment{ wildcard{}, }, }, }, }, { tokens: []string{"{", "field", ".", "nested", ".", "nested2", "=", "*", "}", eof}, want: []segment{ variable{ path: "field.nested.nested2", segments: []segment{ wildcard{}, }, }, }, }, { tokens: []string{"{", "name", "=", "a", "/", "b", "/", "*", "}", eof}, want: []segment{ variable{ path: "name", segments: []segment{ literal("a"), literal("b"), wildcard{}, }, }, }, }, { tokens: []string{ "v1", "/", "{", "name", ".", "nested", ".", "nested2", "=", "a", "/", "b", "/", "*", "}", "/", "o", "/", "{", "another_name", "=", "a", "/", "b", "/", "*", "/", "c", "}", "/", "**", eof, }, want: []segment{ literal("v1"), variable{ path: "name.nested.nested2", segments: []segment{ literal("a"), literal("b"), wildcard{}, }, }, literal("o"), variable{ path: "another_name", segments: []segment{ literal("a"), literal("b"), wildcard{}, literal("c"), }, }, deepWildcard{}, }, }, } { p := parser{tokens: spec.tokens} segs, err := p.topLevelSegments() if err != nil { t.Errorf("parser{%q}.segments() failed with %v; want success", spec.tokens, err) continue } if got, want := segs, spec.want; !reflect.DeepEqual(got, want) { t.Errorf("parser{%q}.segments() = %#v; want %#v", spec.tokens, got, want) } if got := p.tokens; len(got) > 0 { t.Errorf("p.tokens = %q; want []; spec.tokens=%q", got, spec.tokens) } } } func TestParse(t *testing.T) { for _, spec := range []struct { input string wantFields []string wantOpCodes []int wantPool []string wantVerb string }{ { input: "/v1/{name}:bla:baa", wantFields: []string{ "name", }, wantPool: []string{"v1", "name"}, wantVerb: "bla:baa", }, { input: "/v1/{name}:", wantFields: []string{ "name", }, wantPool: []string{"v1", "name"}, wantVerb: "", }, { input: "/v1/{name=segment/wi:th}", wantFields: []string{ "name", }, wantPool: []string{"v1", "segment", "wi:th", "name"}, wantVerb: "", }, } { f, err := Parse(spec.input) if err != nil { t.Errorf("Parse(%q) failed with %v; want success", spec.input, err) continue } tmpl := f.Compile() if !reflect.DeepEqual(tmpl.Fields, spec.wantFields) { t.Errorf("Parse(%q).Fields = %#v; want %#v", spec.input, tmpl.Fields, spec.wantFields) } if !reflect.DeepEqual(tmpl.Pool, spec.wantPool) { t.Errorf("Parse(%q).Pool = %#v; want %#v", spec.input, tmpl.Pool, spec.wantPool) } if tmpl.Template != spec.input { t.Errorf("Parse(%q).Template = %q; want %q", spec.input, tmpl.Template, spec.input) } if tmpl.Verb != spec.wantVerb { t.Errorf("Parse(%q).Verb = %q; want %q", spec.input, tmpl.Verb, spec.wantVerb) } } } func TestParseError(t *testing.T) { for _, spec := range []struct { input string wantError error }{ { input: "v1/{name}", wantError: InvalidTemplateError{ tmpl: "v1/{name}", msg: "no leading /", }, }, } { _, err := Parse(spec.input) if err == nil { t.Errorf("Parse(%q) unexpectedly did not fail", spec.input) continue } if !errors.Is(err, spec.wantError) { t.Errorf("Error did not match expected error: got %v wanted %v", err, spec.wantError) } } } func TestParseSegmentsWithErrors(t *testing.T) { for _, spec := range []struct { tokens []string }{ { // double slash tokens: []string{"//", eof}, }, { // invalid literal tokens: []string{"a?b", eof}, }, { // invalid percent-encoding tokens: []string{"%", eof}, }, { // invalid percent-encoding tokens: []string{"%2", eof}, }, { // invalid percent-encoding tokens: []string{"a%2z", eof}, }, { // unterminated variable tokens: []string{"{", "name", eof}, }, { // unterminated variable tokens: []string{"{", "name", "=", eof}, }, { // unterminated variable tokens: []string{"{", "name", "=", "*", eof}, }, { // empty component in field path tokens: []string{"{", "name", ".", "}", eof}, }, { // empty component in field path tokens: []string{"{", "name", ".", ".", "nested", "}", eof}, }, { // invalid character in identifier tokens: []string{"{", "field-name", "}", eof}, }, { // no slash between segments tokens: []string{"v1", "endpoint", eof}, }, { // no slash between segments tokens: []string{"v1", "{", "name", "}", eof}, }, } { p := parser{tokens: spec.tokens} segs, err := p.topLevelSegments() if err == nil { t.Errorf("parser{%q}.segments() succeeded; want InvalidTemplateError; accepted %#v", spec.tokens, segs) continue } if grpclog.V(1) { grpclog.Info(err) } } } ================================================ FILE: internal/httprule/types.go ================================================ package httprule import ( "fmt" "strings" ) type template struct { segments []segment verb string template string } type segment interface { fmt.Stringer compile() (ops []op) } type wildcard struct{} type deepWildcard struct{} type literal string type variable struct { path string segments []segment } func (wildcard) String() string { return "*" } func (deepWildcard) String() string { return "**" } func (l literal) String() string { return string(l) } func (v variable) String() string { var segs []string for _, s := range v.segments { segs = append(segs, s.String()) } return fmt.Sprintf("{%s=%s}", v.path, strings.Join(segs, "/")) } func (t template) String() string { var segs []string for _, s := range t.segments { segs = append(segs, s.String()) } str := strings.Join(segs, "/") if t.verb != "" { str = fmt.Sprintf("%s:%s", str, t.verb) } return "/" + str } ================================================ FILE: internal/httprule/types_test.go ================================================ package httprule import ( "fmt" "testing" ) func TestTemplateStringer(t *testing.T) { for _, spec := range []struct { segs []segment want string }{ { segs: []segment{ literal("v1"), }, want: "/v1", }, { segs: []segment{ wildcard{}, }, want: "/*", }, { segs: []segment{ deepWildcard{}, }, want: "/**", }, { segs: []segment{ variable{ path: "name", segments: []segment{ literal("a"), }, }, }, want: "/{name=a}", }, { segs: []segment{ variable{ path: "name", segments: []segment{ literal("a"), wildcard{}, literal("b"), }, }, }, want: "/{name=a/*/b}", }, { segs: []segment{ literal("v1"), variable{ path: "name", segments: []segment{ literal("a"), wildcard{}, literal("b"), }, }, literal("c"), variable{ path: "field.nested", segments: []segment{ wildcard{}, literal("d"), }, }, wildcard{}, literal("e"), deepWildcard{}, }, want: "/v1/{name=a/*/b}/c/{field.nested=*/d}/*/e/**", }, } { tmpl := template{segments: spec.segs} if got, want := tmpl.String(), spec.want; got != want { t.Errorf("%#v.String() = %q; want %q", tmpl, got, want) } tmpl.verb = "LOCK" if got, want := tmpl.String(), fmt.Sprintf("%s:LOCK", spec.want); got != want { t.Errorf("%#v.String() = %q; want %q", tmpl, got, want) } } } ================================================ FILE: non_module_deps.bzl ================================================ """Module extension for non-module dependencies.""" load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def _non_module_deps_impl( # buildifier: disable=unused-variable mctx): # TODO(bazelbuild/buildtools#1204): Remove when available as module. http_archive( name = "com_github_bazelbuild_buildtools", sha256 = "f3b800e9f6ca60bdef3709440f393348f7c18a29f30814288a7326285c80aab9", strip_prefix = "buildtools-8.5.1", urls = ["https://github.com/bazelbuild/buildtools/archive/v8.5.1.tar.gz"], ) non_module_deps = module_extension( implementation = _non_module_deps_impl, ) ================================================ FILE: protoc-gen-grpc-gateway/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") load("@io_bazel_rules_go//proto:compiler.bzl", "go_proto_compiler") package(default_visibility = ["//visibility:private"]) go_library( name = "protoc-gen-grpc-gateway_lib", srcs = ["main.go"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway", deps = [ "//internal/codegenerator", "//internal/descriptor", "//protoc-gen-grpc-gateway/internal/gengateway", "@org_golang_google_grpc//grpclog", "@org_golang_google_protobuf//compiler/protogen", ], ) go_binary( name = "protoc-gen-grpc-gateway", embed = [":protoc-gen-grpc-gateway_lib"], visibility = ["//visibility:public"], ) go_proto_compiler( name = "go_gen_grpc_gateway", plugin = ":protoc-gen-grpc-gateway", suffix = ".pb.gw.go", visibility = ["//visibility:public"], deps = [ "//runtime:go_default_library", "//utilities:go_default_library", "@org_golang_google_grpc//grpclog:go_default_library", "@org_golang_google_grpc//metadata:go_default_library", ], ) go_proto_compiler( name = "go_gen_grpc_gateway_opaque", options = [ "paths=source_relative", "use_opaque_api=true", ], plugin = ":protoc-gen-grpc-gateway", suffix = ".pb.gw.go", visibility = ["//visibility:public"], deps = [ "//runtime:go_default_library", "//utilities:go_default_library", "@org_golang_google_grpc//grpclog:go_default_library", "@org_golang_google_grpc//metadata:go_default_library", ], ) ================================================ FILE: protoc-gen-grpc-gateway/internal/gengateway/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") package(default_visibility = ["//protoc-gen-grpc-gateway:__subpackages__"]) go_library( name = "gengateway", srcs = [ "doc.go", "generator.go", "template.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway/internal/gengateway", deps = [ "//internal/casing", "//internal/descriptor", "//internal/generator", "//utilities", "@org_golang_google_grpc//grpclog", "@org_golang_google_protobuf//proto", "@org_golang_google_protobuf//types/descriptorpb", "@org_golang_google_protobuf//types/pluginpb", ], ) go_test( name = "gengateway_test", size = "small", srcs = [ "generator_test.go", "template_test.go", ], embed = [":gengateway"], deps = [ "//internal/descriptor", "//internal/httprule", "@org_golang_google_protobuf//proto", "@org_golang_google_protobuf//types/descriptorpb", "@org_golang_google_protobuf//types/pluginpb", ], ) alias( name = "go_default_library", actual = ":gengateway", visibility = ["//protoc-gen-grpc-gateway:__subpackages__"], ) ================================================ FILE: protoc-gen-grpc-gateway/internal/gengateway/doc.go ================================================ // Package gengateway provides a code generator for grpc gateway files. package gengateway ================================================ FILE: protoc-gen-grpc-gateway/internal/gengateway/generator.go ================================================ package gengateway import ( "errors" "fmt" "go/format" "path" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor" gen "github.com/grpc-ecosystem/grpc-gateway/v2/internal/generator" "google.golang.org/grpc/grpclog" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/pluginpb" ) var errNoTargetService = errors.New("no target service defined in the file") type generator struct { reg *descriptor.Registry baseImports []descriptor.GoPackage useRequestContext bool registerFuncSuffix string allowPatchFeature bool standalone bool useOpaqueAPI bool } // New returns a new generator which generates grpc gateway files. func New(reg *descriptor.Registry, useRequestContext bool, registerFuncSuffix string, allowPatchFeature, standalone bool, useOpaqueAPI bool) gen.Generator { var imports []descriptor.GoPackage for _, pkgpath := range []string{ "context", "errors", "io", "net/http", "github.com/grpc-ecosystem/grpc-gateway/v2/runtime", "github.com/grpc-ecosystem/grpc-gateway/v2/utilities", "google.golang.org/protobuf/proto", "google.golang.org/grpc", "google.golang.org/grpc/codes", "google.golang.org/grpc/grpclog", "google.golang.org/grpc/metadata", "google.golang.org/grpc/status", } { pkg := descriptor.GoPackage{ Path: pkgpath, Name: path.Base(pkgpath), } if err := reg.ReserveGoPackageAlias(pkg.Name, pkg.Path); err != nil { for i := 0; ; i++ { alias := fmt.Sprintf("%s_%d", pkg.Name, i) if err := reg.ReserveGoPackageAlias(alias, pkg.Path); err != nil { continue } pkg.Alias = alias break } } imports = append(imports, pkg) } return &generator{ reg: reg, baseImports: imports, useRequestContext: useRequestContext, registerFuncSuffix: registerFuncSuffix, allowPatchFeature: allowPatchFeature, standalone: standalone, useOpaqueAPI: useOpaqueAPI, } } func (g *generator) Generate(targets []*descriptor.File) ([]*descriptor.ResponseFile, error) { var files []*descriptor.ResponseFile for _, file := range targets { if grpclog.V(1) { grpclog.Infof("Processing %s", file.GetName()) } code, err := g.generate(file) if errors.Is(err, errNoTargetService) { if grpclog.V(1) { grpclog.Infof("%s: %v", file.GetName(), err) } continue } if err != nil { return nil, err } formatted, err := format.Source([]byte(code)) if err != nil { grpclog.Errorf("%v: %s", err, code) return nil, err } files = append(files, &descriptor.ResponseFile{ GoPkg: file.GoPkg, CodeGeneratorResponse_File: &pluginpb.CodeGeneratorResponse_File{ Name: proto.String(file.GeneratedFilenamePrefix + ".pb.gw.go"), Content: proto.String(string(formatted)), }, }) } return files, nil } func (g *generator) generate(file *descriptor.File) (string, error) { pkgSeen := make(map[string]bool) var imports []descriptor.GoPackage for _, pkg := range g.baseImports { pkgSeen[pkg.Path] = true imports = append(imports, pkg) } if g.standalone { imports = append(imports, file.GoPkg) } for _, svc := range file.Services { for _, m := range svc.Methods { imports = append(imports, g.addEnumPathParamImports(file, m, pkgSeen)...) imports = append(imports, g.addBodyFieldImports(file, m, pkgSeen)...) pkg := m.RequestType.File.GoPkg if len(m.Bindings) == 0 || pkg == file.GoPkg || pkgSeen[pkg.Path] { continue } pkgSeen[pkg.Path] = true imports = append(imports, pkg) } } params := param{ File: file, Imports: imports, UseRequestContext: g.useRequestContext, RegisterFuncSuffix: g.registerFuncSuffix, AllowPatchFeature: g.allowPatchFeature, UseOpaqueAPI: g.useOpaqueAPI, } if g.reg != nil { params.OmitPackageDoc = g.reg.GetOmitPackageDoc() } return applyTemplate(params, g.reg) } // addEnumPathParamImports handles adding import of enum path parameter go packages func (g *generator) addEnumPathParamImports(file *descriptor.File, m *descriptor.Method, pkgSeen map[string]bool) []descriptor.GoPackage { var imports []descriptor.GoPackage for _, b := range m.Bindings { for _, p := range b.PathParams { e, err := g.reg.LookupEnum("", p.Target.GetTypeName()) if err != nil { continue } pkg := e.File.GoPkg if pkg == file.GoPkg || pkgSeen[pkg.Path] { continue } pkgSeen[pkg.Path] = true imports = append(imports, pkg) } } return imports } // addBodyFieldImports ensures nested body message types pull in their Go packages. func (g *generator) addBodyFieldImports( file *descriptor.File, m *descriptor.Method, pkgSeen map[string]bool, ) []descriptor.GoPackage { if g.reg == nil || !g.useOpaqueAPI { return nil } imports := make([]descriptor.GoPackage, 0, len(m.Bindings)) for _, b := range m.Bindings { if b.Body == nil || len(b.Body.FieldPath) == 0 { continue } target := b.Body.FieldPath[len(b.Body.FieldPath)-1].Target if target == nil || target.GetTypeName() == "" || target.Message == nil { continue } msg, err := g.reg.LookupMsg(target.Message.FQMN(), target.GetTypeName()) if err != nil { continue } pkg := msg.File.GoPkg if pkg == file.GoPkg || pkgSeen[pkg.Path] { continue } pkgSeen[pkg.Path] = true imports = append(imports, pkg) } return imports } ================================================ FILE: protoc-gen-grpc-gateway/internal/gengateway/generator_test.go ================================================ package gengateway import ( "testing" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/descriptorpb" "google.golang.org/protobuf/types/pluginpb" ) func newExampleFileDescriptorWithGoPkg(gp *descriptor.GoPackage, filenamePrefix string) *descriptor.File { msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), } msg := &descriptor.Message{ DescriptorProto: msgdesc, } msg1 := &descriptor.Message{ DescriptorProto: msgdesc, File: &descriptor.File{ GoPkg: descriptor.GoPackage{ Path: "github.com/golang/protobuf/ptypes/empty", Name: "emptypb", }, }, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Example"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), } meth1 := &descriptorpb.MethodDescriptorProto{ Name: proto.String("ExampleWithoutBindings"), InputType: proto.String("empty.Empty"), OutputType: proto.String("empty.Empty"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth, meth1}, } return &descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ Name: proto.String("example.proto"), Package: proto.String("example"), Dependency: []string{"a.example/b/c.proto", "a.example/d/e.proto"}, MessageType: []*descriptorpb.DescriptorProto{msgdesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, }, GoPkg: *gp, GeneratedFilenamePrefix: filenamePrefix, Messages: []*descriptor.Message{msg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "GET", Body: &descriptor.Body{FieldPath: nil}, }, }, }, { MethodDescriptorProto: meth1, RequestType: msg1, ResponseType: msg1, }, }, }, }, } } func TestGenerator_Generate(t *testing.T) { // Test with Open Struct API (default) t.Run("OpenStructAPI", func(t *testing.T) { testGeneratorGenerate(t, false) }) // Test with Opaque API t.Run("OpaqueAPI", func(t *testing.T) { testGeneratorGenerate(t, true) }) } func testGeneratorGenerate(t *testing.T, useOpaqueAPI bool) { g := new(generator) g.reg = descriptor.NewRegistry() g.useOpaqueAPI = useOpaqueAPI result, err := g.Generate([]*descriptor.File{ crossLinkFixture(newExampleFileDescriptorWithGoPkg(&descriptor.GoPackage{ Path: "example.com/path/to/example", Name: "example_pb", }, "path/to/example")), }) if err != nil { t.Fatalf("failed to generate stubs: %v", err) } if len(result) != 1 { t.Fatalf("expected to generate one file, got: %d", len(result)) } expectedName := "path/to/example.pb.gw.go" gotName := result[0].GetName() if gotName != expectedName { t.Fatalf("invalid name %q, expected %q", gotName, expectedName) } } func TestAddBodyFieldImportsOpaqueOnly(t *testing.T) { reg, file := buildBodyImportTestFile(t) svc := file.Services[0] m := svc.Methods[0] bookField := m.RequestType.Fields[0] bookMessage, err := reg.LookupMsg("", ".example.sub.CreateBook") if err != nil { t.Fatalf("lookup book message: %v", err) } bookField.FieldMessage = bookMessage bodyPath := descriptor.FieldPath{ { Name: bookField.GetName(), Target: bookField, }, } m.Bindings = []*descriptor.Binding{ { HTTPMethod: "POST", Body: &descriptor.Body{ FieldPath: bodyPath, }, }, } g := &generator{ reg: reg, useOpaqueAPI: false, } if got := g.addBodyFieldImports(file, m, map[string]bool{}); len(got) != 0 { t.Fatalf("expected no imports when opaque API disabled, got %v", got) } g.useOpaqueAPI = true imports := g.addBodyFieldImports(file, m, map[string]bool{}) if len(imports) != 1 { t.Fatalf("expected 1 import when opaque API enabled, got %d", len(imports)) } if imports[0].Path != bookMessage.File.GoPkg.Path { t.Fatalf("import path mismatch: got %q want %q", imports[0].Path, bookMessage.File.GoPkg.Path) } } func buildBodyImportTestFile(t *testing.T) (*descriptor.Registry, *descriptor.File) { t.Helper() subFile := &descriptorpb.FileDescriptorProto{ Name: proto.String("sub.proto"), Package: proto.String("example.sub"), Syntax: proto.String("proto3"), Options: &descriptorpb.FileOptions{ GoPackage: proto.String("example.com/sub;subpb"), }, MessageType: []*descriptorpb.DescriptorProto{ { Name: proto.String("CreateBook"), }, }, } mainFile := &descriptorpb.FileDescriptorProto{ Name: proto.String("svc.proto"), Package: proto.String("example.svc"), Syntax: proto.String("proto3"), Dependency: []string{"sub.proto"}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("example.com/svc;svcpb"), }, MessageType: []*descriptorpb.DescriptorProto{ { Name: proto.String("CreateBookRequest"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("book"), Number: proto.Int32(1), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.sub.CreateBook"), }, }, }, { Name: proto.String("CreateBookResponse"), }, }, Service: []*descriptorpb.ServiceDescriptorProto{ { Name: proto.String("LibraryService"), Method: []*descriptorpb.MethodDescriptorProto{ { Name: proto.String("CreateBook"), InputType: proto.String(".example.svc.CreateBookRequest"), OutputType: proto.String(".example.svc.CreateBookResponse"), }, }, }, }, } req := &pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{subFile, mainFile}, FileToGenerate: []string{"svc.proto"}, CompilerVersion: &pluginpb.Version{ Major: proto.Int32(3), Minor: proto.Int32(21), }, } reg := descriptor.NewRegistry() if err := reg.Load(req); err != nil { t.Fatalf("registry load failed: %v", err) } file, err := reg.LookupFile("svc.proto") if err != nil { t.Fatalf("lookup svc file: %v", err) } return reg, crossLinkFixture(file) } ================================================ FILE: protoc-gen-grpc-gateway/internal/gengateway/template.go ================================================ package gengateway import ( "bytes" "errors" "fmt" "net/http" "strings" "text/template" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/casing" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc/grpclog" "google.golang.org/protobuf/types/descriptorpb" ) type param struct { *descriptor.File Imports []descriptor.GoPackage UseRequestContext bool RegisterFuncSuffix string AllowPatchFeature bool OmitPackageDoc bool UseOpaqueAPI bool } type binding struct { *descriptor.Binding Registry *descriptor.Registry AllowPatchFeature bool UseOpaqueAPI bool } // GetBodyFieldPath returns the binding body's field path. func (b binding) GetBodyFieldPath() string { if b.Body != nil && len(b.Body.FieldPath) != 0 { return b.Body.FieldPath.String() } return "*" } // GetBodyFieldStructName returns the binding body's struct field name. func (b binding) GetBodyFieldStructName() (string, error) { if b.Body != nil && len(b.Body.FieldPath) != 0 { return casing.Camel(b.Body.FieldPath.String()), nil } return "", errors.New("no body field found") } // GetBodyFieldType returns the Go type of the body field. func (b binding) GetBodyFieldType() (string, error) { if b.Body == nil || len(b.Body.FieldPath) == 0 { return "", errors.New("no body field found") } lastComponent := b.Body.FieldPath[len(b.Body.FieldPath)-1] fieldType := lastComponent.Target.GetType() // Handle message types if fieldType == descriptorpb.FieldDescriptorProto_TYPE_MESSAGE { // Get the parent message to provide proper lookup context parentMsg := lastComponent.Target.Message msg, err := b.Registry.LookupMsg(parentMsg.FQMN(), lastComponent.Target.GetTypeName()) if err != nil { return "", fmt.Errorf("failed to lookup message type %s: %w", lastComponent.Target.GetTypeName(), err) } return msg.GoType(b.Method.Service.File.GoPkg.Path), nil } return "", errors.New("unsupported body field type") } // HasQueryParam determines if the binding needs parameters in query string. // // It sometimes returns true even though actually the binding does not need. // But it is not serious because it just results in a small amount of extra codes generated. func (b binding) HasQueryParam() bool { if b.Body != nil && len(b.Body.FieldPath) == 0 { return false } fields := make(map[string]bool) for _, f := range b.Method.RequestType.Fields { fields[f.GetName()] = true } if b.Body != nil { delete(fields, b.Body.FieldPath.String()) } for _, p := range b.PathParams { delete(fields, p.FieldPath.String()) } return len(fields) > 0 } func (b binding) QueryParamFilter() queryParamFilter { var seqs [][]string if b.Body != nil { seqs = append(seqs, strings.Split(b.Body.FieldPath.String(), ".")) } for _, p := range b.PathParams { seqs = append(seqs, strings.Split(p.FieldPath.String(), ".")) } return queryParamFilter{utilities.NewDoubleArray(seqs)} } // HasEnumPathParam returns true if the path parameter slice contains a parameter // that maps to an enum proto field that is not repeated, if not false is returned. func (b binding) HasEnumPathParam() bool { return b.hasEnumPathParam(false) } // HasRepeatedEnumPathParam returns true if the path parameter slice contains a parameter // that maps to a repeated enum proto field, if not false is returned. func (b binding) HasRepeatedEnumPathParam() bool { return b.hasEnumPathParam(true) } // hasEnumPathParam returns true if the path parameter slice contains a parameter // that maps to an enum proto field and that the enum proto field is or isn't repeated // based on the provided 'repeated' parameter. func (b binding) hasEnumPathParam(repeated bool) bool { for _, p := range b.PathParams { if p.IsEnum() && p.IsRepeated() == repeated { return true } } return false } // LookupEnum looks up an enum type by path parameter. func (b binding) LookupEnum(p descriptor.Parameter) *descriptor.Enum { e, err := b.Registry.LookupEnum("", p.Target.GetTypeName()) if err != nil { return nil } return e } // FieldMaskField returns the golang-style name of the variable for a FieldMask, if there is exactly one of that type in // the message. Otherwise, it returns an empty string. func (b binding) FieldMaskField() string { var fieldMaskField *descriptor.Field for _, f := range b.Method.RequestType.Fields { if f.GetTypeName() == ".google.protobuf.FieldMask" { // if there is more than 1 FieldMask for this request, then return none if fieldMaskField != nil { return "" } fieldMaskField = f } } if fieldMaskField != nil { return casing.Camel(fieldMaskField.GetName()) } return "" } // queryParamFilter is a wrapper of utilities.DoubleArray which provides String() to output DoubleArray.Encoding in a stable and predictable format. type queryParamFilter struct { *utilities.DoubleArray } func (f queryParamFilter) String() string { encodings := make([]string, len(f.Encoding)) for str, enc := range f.Encoding { encodings[enc] = fmt.Sprintf("%q: %d", str, enc) } e := strings.Join(encodings, ", ") return fmt.Sprintf("&utilities.DoubleArray{Encoding: map[string]int{%s}, Base: %#v, Check: %#v}", e, f.Base, f.Check) } type trailerParams struct { Services []*descriptor.Service UseRequestContext bool RegisterFuncSuffix string UseOpaqueAPI bool } func applyTemplate(p param, reg *descriptor.Registry) (string, error) { w := bytes.NewBuffer(nil) if err := headerTemplate.Execute(w, p); err != nil { return "", err } var targetServices []*descriptor.Service for _, msg := range p.Messages { msgName := casing.Camel(*msg.Name) msg.Name = &msgName } for _, svc := range p.Services { var methodWithBindingsSeen bool svcName := casing.Camel(*svc.Name) svc.Name = &svcName for _, meth := range svc.Methods { if grpclog.V(2) { grpclog.Infof("Processing %s.%s", svc.GetName(), meth.GetName()) } methName := casing.Camel(*meth.Name) meth.Name = &methName for _, b := range meth.Bindings { if err := reg.CheckDuplicateAnnotation(b.HTTPMethod, b.PathTmpl.Template, svc); err != nil { return "", err } methodWithBindingsSeen = true if err := handlerTemplate.Execute(w, binding{ Binding: b, Registry: reg, AllowPatchFeature: p.AllowPatchFeature, UseOpaqueAPI: p.UseOpaqueAPI, }); err != nil { return "", err } // Local if err := localHandlerTemplate.Execute(w, binding{ Binding: b, Registry: reg, AllowPatchFeature: p.AllowPatchFeature, UseOpaqueAPI: p.UseOpaqueAPI, }); err != nil { return "", err } } } if methodWithBindingsSeen { targetServices = append(targetServices, svc) } } if len(targetServices) == 0 { return "", errNoTargetService } tp := trailerParams{ Services: targetServices, UseRequestContext: p.UseRequestContext, RegisterFuncSuffix: p.RegisterFuncSuffix, UseOpaqueAPI: p.UseOpaqueAPI, } // Local if err := localTrailerTemplate.Execute(w, tp); err != nil { return "", err } if err := trailerTemplate.Execute(w, tp); err != nil { return "", err } return w.String(), nil } var ( httpMethods = map[string]string{ http.MethodGet: "http.MethodGet", http.MethodHead: "http.MethodHead", http.MethodPost: "http.MethodPost", http.MethodPut: "http.MethodPut", http.MethodPatch: "http.MethodPatch", http.MethodDelete: "http.MethodDelete", http.MethodConnect: "http.MethodConnect", http.MethodOptions: "http.MethodOptions", http.MethodTrace: "http.MethodTrace", } headerTemplate = template.Must(template.New("header").Parse(` // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. // source: {{ .GetName }} {{ if not .OmitPackageDoc }}/* Package {{ .GoPkg.Name }} is a reverse proxy. It translates gRPC into RESTful JSON APIs. */{{ end }} package {{ .GoPkg.Name }} import ( {{ range $i := .Imports }}{{ if $i.Standard }}{{ $i | printf "%s\n" }}{{ end }}{{ end }} {{ range $i := .Imports }}{{ if not $i.Standard }}{{ $i | printf "%s\n" }}{{ end }}{{ end }} ) // Suppress "imported and not used" errors var ( _ codes.Code _ io.Reader _ status.Status _ = errors.New _ = runtime.String _ = utilities.NewDoubleArray _ = metadata.Join ) `)) handlerTemplate = template.Must(template.New("handler").Parse(` {{ if and .Method.GetClientStreaming .Method.GetServerStreaming }} {{ template "bidi-streaming-request-func" . }} {{ else if .Method.GetClientStreaming }} {{ template "client-streaming-request-func" . }} {{ else }} {{ template "client-rpc-request-func" . }} {{ end }} `)) _ = template.Must(handlerTemplate.New("request-func-signature").Parse(strings.ReplaceAll(` {{ if and .Method.GetClientStreaming .Method.GetServerStreaming }} func request_{{ .Method.Service.GetName }}_{{ .Method.GetName }}_{{ .Index }}(ctx context.Context, marshaler runtime.Marshaler, client {{ .Method.Service.InstanceName }}Client, req *http.Request, pathParams map[string]string) ({{ .Method.Service.InstanceName }}_{{ .Method.GetName }}Client, runtime.ServerMetadata, error) {{ else if .Method.GetServerStreaming }} func request_{{ .Method.Service.GetName }}_{{ .Method.GetName }}_{{ .Index }}(ctx context.Context, marshaler runtime.Marshaler, client {{ .Method.Service.InstanceName }}Client, req *http.Request, pathParams map[string]string) ({{ .Method.Service.InstanceName }}_{{ .Method.GetName }}Client, runtime.ServerMetadata, error) {{ else }} func request_{{ .Method.Service.GetName }}_{{ .Method.GetName }}_{{ .Index }}(ctx context.Context, marshaler runtime.Marshaler, client {{ .Method.Service.InstanceName }}Client, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {{ end }}`, "\n", ""))) _ = template.Must(handlerTemplate.New("client-streaming-request-func").Parse(` {{ template "request-func-signature" . }} { var metadata runtime.ServerMetadata stream, err := client.{{ .Method.GetName }}(ctx) if err != nil { grpclog.Errorf("Failed to start streaming: %v", err) return nil, metadata, err } dec := marshaler.NewDecoder(req.Body) for { var protoReq {{ .Method.RequestType.GoType .Method.Service.File.GoPkg.Path }} err = dec.Decode(&protoReq) if errors.Is(err, io.EOF) { break } if err != nil { grpclog.Errorf("Failed to decode request: %v", err) return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err = stream.Send(&protoReq); err != nil { if errors.Is(err, io.EOF) { break } grpclog.Errorf("Failed to send request: %v", err) return nil, metadata, err } } if err := stream.CloseSend(); err != nil { grpclog.Errorf("Failed to terminate client stream: %v", err) return nil, metadata, err } header, err := stream.Header() if err != nil { grpclog.Errorf("Failed to get header from client: %v", err) return nil, metadata, err } metadata.HeaderMD = header {{- if .Method.GetServerStreaming }} return stream, metadata, nil {{- else }} msg, err := stream.CloseAndRecv() metadata.TrailerMD = stream.Trailer() return msg, metadata, err {{- end }} } `)) funcMap template.FuncMap = map[string]interface{}{ "camelIdentifier": casing.CamelIdentifier, "opaqueSetter": func(p descriptor.FieldPath, msgExpr string) string { return p.OpaqueSetterExpr(msgExpr) }, "toHTTPMethod": func(method string) string { return httpMethods[method] }, } _ = template.Must(handlerTemplate.New("client-rpc-request-func").Funcs(funcMap).Parse(` {{ $AllowPatchFeature := .AllowPatchFeature }} {{ $UseOpaqueAPI := .UseOpaqueAPI }} {{ if .HasQueryParam }} var filter_{{ .Method.Service.GetName }}_{{ .Method.GetName }}_{{ .Index }} = {{ .QueryParamFilter }} {{ end }} {{ template "request-func-signature" . }} { var ( protoReq {{ .Method.RequestType.GoType .Method.Service.File.GoPkg.Path }} metadata runtime.ServerMetadata {{- if .PathParams }} {{- if .HasEnumPathParam }} e int32 {{- end }} {{- if .HasRepeatedEnumPathParam }} es []int32 {{- end }} err error {{- end }} ) {{- if .Body }} {{- $isFieldMask := and $AllowPatchFeature (eq (.HTTPMethod) "PATCH") (.FieldMaskField) (not (eq "*" .GetBodyFieldPath)) }} {{- if $isFieldMask }} newReader, berr := utilities.IOReaderFactory(req.Body) if berr != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) } {{- end }} {{- $protoReq := .Body.AssignableExprPrep "protoReq" .Method.Service.File.GoPkg.Path -}} {{- if ne "" $protoReq }} {{printf "%s" $protoReq }} {{- end }} {{- if not $isFieldMask }} {{- if $UseOpaqueAPI }} {{- if eq "*" .GetBodyFieldPath }} var bodyData {{.Method.RequestType.GoType .Method.Service.File.GoPkg.Path}} if err := marshaler.NewDecoder(req.Body).Decode(&bodyData); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } proto.Merge(&protoReq, &bodyData) {{- else }} bodyData := &{{ .GetBodyFieldType }}{} if err := marshaler.NewDecoder(req.Body).Decode(bodyData); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } protoReq.Set{{ .GetBodyFieldStructName }}(bodyData) {{- end }} {{- else }} if err := marshaler.NewDecoder(req.Body).Decode(&{{.Body.AssignableExpr "protoReq" .Method.Service.File.GoPkg.Path}}); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } {{- end }} if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } {{- end }} {{- if $isFieldMask }} {{- if $UseOpaqueAPI }} {{- if eq "*" .GetBodyFieldPath }} var bodyData {{.Method.RequestType.GoType .Method.Service.File.GoPkg.Path}} if err := marshaler.NewDecoder(newReader()).Decode(&bodyData); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } proto.Merge(&protoReq, &bodyData) {{- else }} bodyData := &{{ .GetBodyFieldType }}{} if err := marshaler.NewDecoder(newReader()).Decode(bodyData); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } protoReq.Set{{ .GetBodyFieldStructName }}(bodyData) {{- end }} {{- else }} if err := marshaler.NewDecoder(newReader()).Decode(&{{ .Body.AssignableExpr "protoReq" .Method.Service.File.GoPkg.Path }}); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } {{- end }} if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } {{- if $UseOpaqueAPI }} if !protoReq.Has{{ .FieldMaskField }}() || len(protoReq.Get{{ .FieldMaskField }}().GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Get{{ .GetBodyFieldStructName }}()); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } else { protoReq.Set{{ .FieldMaskField }}(fieldMask) } } {{- else }} if protoReq.{{ .FieldMaskField }} == nil || len(protoReq.{{ .FieldMaskField }}.GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.{{ .GetBodyFieldStructName }}); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } else { protoReq.{{ .FieldMaskField }} = fieldMask } } {{- end }} {{- end }} {{- else }} if req.Body != nil { _, _ = io.Copy(io.Discard, req.Body) } {{- end }} {{- if .PathParams }} {{- $binding := . }} {{- range $index, $param := .PathParams }} {{- $enum := $binding.LookupEnum $param }} val, ok {{ if eq $index 0 }}:{{ end }}= pathParams[{{ $param | printf "%q" }}] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", {{ $param | printf "%q"}}) } {{- if $param.IsNestedProto3 }} err = runtime.PopulateFieldFromPath(&protoReq, {{ $param | printf "%q" }}, val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", {{ $param | printf "%q" }}, err) } {{- if $enum }} e{{ if $param.IsRepeated }}s{{ end }}, err = {{ $param.ConvertFuncExpr }}(val{{ if $param.IsRepeated }}, {{ $binding.Registry.GetRepeatedPathParamSeparator | printf "%c" | printf "%q" }}{{ end }}, {{ $enum.GoType $param.Method.Service.File.GoPkg.Path | camelIdentifier }}_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "could not parse path as enum value, parameter: %s, error: %v", {{ $param | printf "%q"}}, err) } {{- end }} {{- else if $enum }} e{{ if $param.IsRepeated }}s{{ end }}, err = {{ $param.ConvertFuncExpr }}(val{{ if $param.IsRepeated }}, {{ $binding.Registry.GetRepeatedPathParamSeparator | printf "%c" | printf "%q" }}{{ end }}, {{ $enum.GoType $param.Method.Service.File.GoPkg.Path | camelIdentifier }}_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", {{ $param | printf "%q"}}, err) } {{- else -}} {{- $protoReq := $param.AssignableExprPrep "protoReq" $binding.Method.Service.File.GoPkg.Path -}} {{- if ne "" $protoReq }} {{ printf "%s" $protoReq }} {{- end}} {{- if $UseOpaqueAPI }} converted{{ $param.FieldPath.String | camelIdentifier }}, err := {{ $param.ConvertFuncExpr }}(val{{ if $param.IsRepeated }}, {{ $binding.Registry.GetRepeatedPathParamSeparator | printf "%c" | printf "%q" }}{{ end }}) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", {{ $param | printf "%q"}}, err) } {{ opaqueSetter $param.FieldPath "protoReq" }}(converted{{ $param.FieldPath.String | camelIdentifier }}) {{- else }} {{ $param.AssignableExpr "protoReq" $binding.Method.Service.File.GoPkg.Path }}, err = {{ $param.ConvertFuncExpr }}(val{{ if $param.IsRepeated }}, {{ $binding.Registry.GetRepeatedPathParamSeparator | printf "%c" | printf "%q" }}{{ end }}) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", {{ $param | printf "%q"}}, err) } {{- end }} {{- end}} {{- if and $enum $param.IsRepeated }} s := make([]{{ $enum.GoType $param.Method.Service.File.GoPkg.Path }}, len(es)) for i, v := range es { s[i] = {{ $enum.GoType $param.Method.Service.File.GoPkg.Path}}(v) } {{- if $UseOpaqueAPI }} {{ opaqueSetter $param.FieldPath "protoReq" }}(s) {{- else }} {{ $param.AssignableExpr "protoReq" $binding.Method.Service.File.GoPkg.Path }} = s {{- end }} {{- else if $enum}} {{- if $UseOpaqueAPI }} {{ opaqueSetter $param.FieldPath "protoReq" }}({{ $enum.GoType $param.Method.Service.File.GoPkg.Path | camelIdentifier }}(e)) {{- else }} {{ $param.AssignableExpr "protoReq" $binding.Method.Service.File.GoPkg.Path }} = {{ $enum.GoType $param.Method.Service.File.GoPkg.Path | camelIdentifier }}(e) {{- end }} {{- end}} {{- end }} {{- end }} {{- if .HasQueryParam }} if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_{{ .Method.Service.GetName }}_{{ .Method.GetName }}_{{ .Index }}); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } {{- end }} {{- if .Method.GetServerStreaming }} stream, err := client.{{ .Method.GetName }}(ctx, &protoReq) if err != nil { return nil, metadata, err } header, err := stream.Header() if err != nil { return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil {{- else }} msg, err := client.{{ .Method.GetName }}(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err {{- end }} }`)) _ = template.Must(handlerTemplate.New("bidi-streaming-request-func").Parse(` {{ template "request-func-signature" . }} { var metadata runtime.ServerMetadata stream, err := client.{{ .Method.GetName }}(ctx) if err != nil { grpclog.Errorf("Failed to start streaming: %v", err) return nil, metadata, err } dec := marshaler.NewDecoder(req.Body) handleSend := func() error { var protoReq {{.Method.RequestType.GoType .Method.Service.File.GoPkg.Path}} err := dec.Decode(&protoReq) if errors.Is(err, io.EOF) { return err } if err != nil { grpclog.Errorf("Failed to decode request: %v", err) return status.Errorf(codes.InvalidArgument, "Failed to decode request: %v", err) } if err := stream.Send(&protoReq); err != nil { grpclog.Errorf("Failed to send request: %v", err) return err } return nil } go func() { for { if err := handleSend(); err != nil { break } } if err := stream.CloseSend(); err != nil { grpclog.Errorf("Failed to terminate client stream: %v", err) } }() header, err := stream.Header() if err != nil { grpclog.Errorf("Failed to get header from client: %v", err) return nil, metadata, err } metadata.HeaderMD = header return stream, metadata, nil } `)) localHandlerTemplate = template.Must(template.New("local-handler").Parse(` {{ if and .Method.GetClientStreaming .Method.GetServerStreaming }} {{ else if .Method.GetClientStreaming }} {{ else if .Method.GetServerStreaming }} {{ else}} {{ template "local-client-rpc-request-func" . }} {{ end }} `)) _ = template.Must(localHandlerTemplate.New("local-request-func-signature").Parse(strings.ReplaceAll(` {{ if .Method.GetServerStreaming }} {{ else }} func local_request_{{ .Method.Service.GetName }}_{{ .Method.GetName }}_{{ .Index }}(ctx context.Context, marshaler runtime.Marshaler, server {{ .Method.Service.InstanceName }}Server, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {{ end }}`, "\n", ""))) _ = template.Must(localHandlerTemplate.New("local-client-rpc-request-func").Funcs(funcMap).Parse(` {{ $AllowPatchFeature := .AllowPatchFeature }} {{ $UseOpaqueAPI := .UseOpaqueAPI }} {{ template "local-request-func-signature" . }} { var ( protoReq {{.Method.RequestType.GoType .Method.Service.File.GoPkg.Path}} metadata runtime.ServerMetadata {{- if .PathParams }} {{- if .HasEnumPathParam }} e int32 {{- end }} {{- if .HasRepeatedEnumPathParam }} es []int32 {{- end }} err error {{- end }} ) {{- if .Body }} {{- $isFieldMask := and $AllowPatchFeature (eq (.HTTPMethod) "PATCH") (.FieldMaskField) (not (eq "*" .GetBodyFieldPath)) }} {{- if $isFieldMask }} newReader, berr := utilities.IOReaderFactory(req.Body) if berr != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) } {{- end }} {{- $protoReq := .Body.AssignableExprPrep "protoReq" .Method.Service.File.GoPkg.Path -}} {{- if ne "" $protoReq }} {{ printf "%s" $protoReq }} {{- end }} {{- if not $isFieldMask }} {{- if $UseOpaqueAPI }} {{- if eq "*" .GetBodyFieldPath }} var bodyData {{.Method.RequestType.GoType .Method.Service.File.GoPkg.Path}} if err := marshaler.NewDecoder(req.Body).Decode(&bodyData); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } proto.Merge(&protoReq, &bodyData) {{- else }} bodyData := &{{ .GetBodyFieldType }}{} if err := marshaler.NewDecoder(req.Body).Decode(bodyData); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } protoReq.Set{{ .GetBodyFieldStructName }}(bodyData) {{- end }} {{- else }} if err := marshaler.NewDecoder(req.Body).Decode(&{{ .Body.AssignableExpr "protoReq" .Method.Service.File.GoPkg.Path }}); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } {{- end }} {{- end }} {{- if $isFieldMask }} {{- if $UseOpaqueAPI }} {{- if eq "*" .GetBodyFieldPath }} var bodyData {{.Method.RequestType.GoType .Method.Service.File.GoPkg.Path}} if err := marshaler.NewDecoder(newReader()).Decode(&bodyData); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } proto.Merge(&protoReq, &bodyData) {{- else }} bodyData := &{{ .GetBodyFieldType }}{} if err := marshaler.NewDecoder(newReader()).Decode(bodyData); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } protoReq.Set{{ .GetBodyFieldStructName }}(bodyData) {{- end }} {{- else }} if err := marshaler.NewDecoder(newReader()).Decode(&{{ .Body.AssignableExpr "protoReq" .Method.Service.File.GoPkg.Path }}); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } {{- end }} {{- if $UseOpaqueAPI }} if !protoReq.Has{{ .FieldMaskField }}() || len(protoReq.Get{{ .FieldMaskField }}().GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Get{{ .GetBodyFieldStructName }}()); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } else { protoReq.Set{{ .FieldMaskField }}(fieldMask) } } {{- else }} if protoReq.{{ .FieldMaskField }} == nil || len(protoReq.{{ .FieldMaskField }}.GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.{{ .GetBodyFieldStructName }}); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } else { protoReq.{{.FieldMaskField}} = fieldMask } } {{- end }} {{- end }} {{- end }} {{- if .PathParams}} {{- $binding := .}} {{- range $index, $param := .PathParams}} {{- $enum := $binding.LookupEnum $param}} val, ok {{if eq $index 0}}:{{ end }}= pathParams[{{ $param | printf "%q"}}] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", {{ $param | printf "%q" }}) } {{- if $param.IsNestedProto3 }} err = runtime.PopulateFieldFromPath(&protoReq, {{ $param | printf "%q"}}, val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", {{ $param | printf "%q"}}, err) } {{- if $enum }} e{{ if $param.IsRepeated }}s{{ end }}, err = {{ $param.ConvertFuncExpr }}(val{{ if $param.IsRepeated }}, {{ $binding.Registry.GetRepeatedPathParamSeparator | printf "%c" | printf "%q" }}{{ end }}, {{ $enum.GoType $param.Method.Service.File.GoPkg.Path | camelIdentifier }}_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "could not parse path as enum value, parameter: %s, error: %v", {{ $param | printf "%q"}}, err) } {{- end }} {{- else if $enum}} e{{ if $param.IsRepeated }}s{{ end }}, err = {{ $param.ConvertFuncExpr }}(val{{ if $param.IsRepeated }}, {{ $binding.Registry.GetRepeatedPathParamSeparator | printf "%c" | printf "%q" }}{{ end }}, {{ $enum.GoType $param.Method.Service.File.GoPkg.Path | camelIdentifier }}_value) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", {{ $param | printf "%q"}}, err) } {{- else}} {{- $protoReq := $param.AssignableExprPrep "protoReq" $binding.Method.Service.File.GoPkg.Path -}} {{- if ne "" $protoReq }} {{ printf "%s" $protoReq }} {{- end}} {{- if $UseOpaqueAPI }} converted{{ $param.FieldPath.String | camelIdentifier }}, err := {{ $param.ConvertFuncExpr }}(val{{ if $param.IsRepeated }}, {{ $binding.Registry.GetRepeatedPathParamSeparator | printf "%c" | printf "%q" }}{{ end }}) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", {{ $param | printf "%q"}}, err) } {{ opaqueSetter $param.FieldPath "protoReq" }}(converted{{ $param.FieldPath.String | camelIdentifier }}) {{- else }} {{ $param.AssignableExpr "protoReq" $binding.Method.Service.File.GoPkg.Path }}, err = {{ $param.ConvertFuncExpr }}(val{{ if $param.IsRepeated }}, {{ $binding.Registry.GetRepeatedPathParamSeparator | printf "%c" | printf "%q" }}{{ end }}) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", {{ $param | printf "%q" }}, err) } {{- end }} {{- end}} {{- if and $enum $param.IsRepeated }} s := make([]{{ $enum.GoType $param.Method.Service.File.GoPkg.Path }}, len(es)) for i, v := range es { s[i] = {{ $enum.GoType $param.Method.Service.File.GoPkg.Path }}(v) } {{- if $UseOpaqueAPI }} {{ opaqueSetter $param.FieldPath "protoReq" }}(s) {{- else }} {{ $param.AssignableExpr "protoReq" $binding.Method.Service.File.GoPkg.Path }} = s {{- end }} {{- else if $enum }} {{- if $UseOpaqueAPI }} {{ opaqueSetter $param.FieldPath "protoReq" }}({{ $enum.GoType $param.Method.Service.File.GoPkg.Path | camelIdentifier }}(e)) {{- else }} {{ $param.AssignableExpr "protoReq" $binding.Method.Service.File.GoPkg.Path }} = {{ $enum.GoType $param.Method.Service.File.GoPkg.Path | camelIdentifier }}(e) {{- end }} {{- end }} {{- end }} {{- end }} {{- if .HasQueryParam }} if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_{{ .Method.Service.GetName }}_{{ .Method.GetName }}_{{ .Index }}); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } {{- end}} {{- if .Method.GetServerStreaming }} // TODO {{- else}} msg, err := server.{{ .Method.GetName }}(ctx, &protoReq) return msg, metadata, err {{- end}} }`)) localTrailerTemplate = template.Must(template.New("local-trailer").Funcs(funcMap).Parse(` {{ $UseRequestContext := .UseRequestContext }} {{ range $svc := .Services }} // Register{{ $svc.GetName }}{{ $.RegisterFuncSuffix }}Server registers the http handlers for service {{ $svc.GetName }} to "mux". // UnaryRPC :call {{ $svc.GetName }}Server directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using Register{{ $svc.GetName }}{{ $.RegisterFuncSuffix }}FromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func Register{{ $svc.GetName }}{{ $.RegisterFuncSuffix }}Server(ctx context.Context, mux *runtime.ServeMux, server {{ $svc.InstanceName }}Server) error { {{- range $m := $svc.Methods }} {{- range $b := $m.Bindings }} {{- if or $m.GetClientStreaming $m.GetServerStreaming }} mux.Handle({{ $b.HTTPMethod | toHTTPMethod }}, pattern_{{ $svc.GetName }}_{{ $m.GetName }}_{{ $b.Index }}, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return }) {{- else -}} mux.Handle({{ $b.HTTPMethod | toHTTPMethod}}, pattern_{{ $svc.GetName }}_{{ $m.GetName }}_{{ $b.Index }}, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { {{- if $UseRequestContext }} ctx, cancel := context.WithCancel(req.Context()) {{- else -}} ctx, cancel := context.WithCancel(ctx) {{- end }} defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) {{- if $b.PathTmpl }} annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/{{ $svc.File.GetPackage }}.{{ $svc.GetName }}/{{ $m.GetName }}", runtime.WithHTTPPathPattern("{{ $b.PathTmpl.Template }}")) {{- else -}} annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/{{ $svc.File.GetPackage }}.{{ $svc.GetName }}/{{ $m.GetName }}") {{- end }} if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := local_request_{{ $svc.GetName }}_{{ $m.GetName }}_{{ $b.Index }}(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } {{- if $b.ResponseBody }} forward_{{ $svc.GetName }}_{{ $m.GetName }}_{{ $b.Index }}(annotatedContext, mux, outboundMarshaler, w, req, response_{{ $svc.GetName }}_{{ $m.GetName }}_{{ $b.Index }}{resp.(*{{ $m.ResponseType.GoType $m.Service.File.GoPkg.Path }})}, mux.GetForwardResponseOptions()...) {{- else }} forward_{{ $svc.GetName }}_{{ $m.GetName }}_{{ $b.Index }}(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) {{- end }} }) {{- end }} {{ end }} {{- end }} return nil } {{ end }}`)) trailerTemplate = template.Must(template.New("trailer").Funcs(funcMap).Parse(` {{ $UseRequestContext := .UseRequestContext }} {{ $UseOpaqueAPI := .UseOpaqueAPI }} {{range $svc := .Services}} // Register{{ $svc.GetName }}{{ $.RegisterFuncSuffix }}FromEndpoint is same as Register{{ $svc.GetName }}{{ $.RegisterFuncSuffix }} but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func Register{{ $svc.GetName }}{{ $.RegisterFuncSuffix }}FromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err } defer func() { if err != nil { if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } return } go func() { <-ctx.Done() if cerr := conn.Close(); cerr != nil { grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) } }() }() return Register{{ $svc.GetName }}{{ $.RegisterFuncSuffix }}(ctx, mux, conn) } // Register{{ $svc.GetName}}{{ $.RegisterFuncSuffix}} registers the http handlers for service {{ $svc.GetName }} to "mux". // The handlers forward requests to the grpc endpoint over "conn". func Register{{ $svc.GetName }}{{ $.RegisterFuncSuffix }}(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return Register{{ $svc.GetName }}{{ $.RegisterFuncSuffix }}Client(ctx, mux, {{ $svc.ClientConstructorName }}(conn)) } // Register{{ $svc.GetName }}{{ $.RegisterFuncSuffix }}Client registers the http handlers for service {{ $svc.GetName }} // to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "{{ $svc.InstanceName }}Client". // Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "{{ $svc.InstanceName }}Client" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "{{ $svc.InstanceName }}Client" to call the correct interceptors. This client ignores the HTTP middlewares. func Register{{ $svc.GetName }}{{ $.RegisterFuncSuffix }}Client(ctx context.Context, mux *runtime.ServeMux, client {{ $svc.InstanceName }}Client) error { {{- range $m := $svc.Methods }} {{- range $b := $m.Bindings }} mux.Handle({{ $b.HTTPMethod | toHTTPMethod }}, pattern_{{ $svc.GetName }}_{{ $m.GetName }}_{{ $b.Index }}, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { {{- if $UseRequestContext }} ctx, cancel := context.WithCancel(req.Context()) {{- else -}} ctx, cancel := context.WithCancel(ctx) {{- end }} defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) {{- if $b.PathTmpl }} annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/{{ $svc.File.GetPackage }}.{{ $svc.GetName }}/{{ $m.GetName }}", runtime.WithHTTPPathPattern("{{ $b.PathTmpl.Template}}")) {{- else -}} annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/{{ $svc.File.GetPackage }}.{{ $svc.GetName }}/{{ $m.GetName }}") {{- end }} if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } resp, md, err := request_{{ $svc.GetName }}_{{ $m.GetName }}_{{ $b.Index }}(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } {{- if $m.GetServerStreaming }} {{- if $b.ResponseBody }} forward_{{ $svc.GetName }}_{{ $m.GetName }}_{{ $b.Index }}(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { res, err := resp.Recv() return response_{{ $svc.GetName }}_{{ $m.GetName }}_{{ $b.Index }}{res}, err }, mux.GetForwardResponseOptions()...) {{- else }} forward_{{ $svc.GetName }}_{{ $m.GetName }}_{{ $b.Index }}(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) {{- end }} {{- else }} {{- if $b.ResponseBody }} forward_{{ $svc.GetName }}_{{ $m.GetName }}_{{ $b.Index }}(annotatedContext, mux, outboundMarshaler, w, req, response_{{ $svc.GetName }}_{{ $m.GetName }}_{{ $b.Index }}{resp.(*{{ $m.ResponseType.GoType $m.Service.File.GoPkg.Path }})}, mux.GetForwardResponseOptions()...) {{- else }} forward_{{ $svc.GetName }}_{{ $m.GetName }}_{{ $b.Index }}(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) {{- end }} {{- end }} }) {{- end }} {{- end }} return nil } {{range $m := $svc.Methods}} {{range $b := $m.Bindings}} {{if $b.ResponseBody}} type response_{{ $svc.GetName }}_{{ $m.GetName }}_{{ $b.Index }} struct { *{{ $m.ResponseType.GoType $m.Service.File.GoPkg.Path }} } func (m response_{{ $svc.GetName }}_{{ $m.GetName }}_{{ $b.Index }}) XXX_ResponseBody() interface{} { response := m.{{ $m.ResponseType.GetName }} {{- if $UseOpaqueAPI }} {{- if eq "*" $b.ResponseBody.FieldPath.String }} return response {{- else }} return response.Get{{ $b.ResponseBody.FieldPath.String | camelIdentifier }}() {{- end }} {{- else }} return {{ $b.ResponseBody.AssignableExpr "response" $m.Service.File.GoPkg.Path }} {{- end }} } {{ end }} {{ end }} {{ end }} var ( {{- range $m := $svc.Methods }} {{- range $b := $m.Bindings }} pattern_{{ $svc.GetName }}_{{ $m.GetName }}_{{ $b.Index }} = runtime.MustPattern(runtime.NewPattern({{ $b.PathTmpl.Version }}, {{ $b.PathTmpl.OpCodes | printf "%#v" }}, {{ $b.PathTmpl.Pool | printf "%#v" }}, {{ $b.PathTmpl.Verb | printf "%q" }})) {{- end }} {{- end }} ) var ( {{- range $m := $svc.Methods }} {{- range $b := $m.Bindings }} forward_{{ $svc.GetName }}_{{ $m.GetName }}_{{ $b.Index }} = {{ if $m.GetServerStreaming }}runtime.ForwardResponseStream{{ else }}runtime.ForwardResponseMessage{{ end }} {{- end }} {{- end }} ) {{ end }}`)) ) ================================================ FILE: protoc-gen-grpc-gateway/internal/gengateway/template_test.go ================================================ package gengateway import ( "strings" "testing" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/httprule" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/descriptorpb" "google.golang.org/protobuf/types/pluginpb" ) func crossLinkFixture(f *descriptor.File) *descriptor.File { for _, m := range f.Messages { m.File = f } for _, svc := range f.Services { svc.File = f for _, m := range svc.Methods { m.Service = svc for _, b := range m.Bindings { b.Method = m for _, param := range b.PathParams { param.Method = m } } } } return f } func compilePath(t *testing.T, path string) httprule.Template { parsed, err := httprule.Parse(path) if err != nil { t.Fatalf("httprule.Parse(%q) failed with %v; want success", path, err) } return parsed.Compile() } func TestApplyTemplateHeader(t *testing.T) { msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Example"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } msg := &descriptor.Message{ DescriptorProto: msgdesc, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ Name: proto.String("example.proto"), Package: proto.String("example"), Dependency: []string{"a.example/b/c.proto", "a.example/d/e.proto"}, MessageType: []*descriptorpb.DescriptorProto{msgdesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "GET", Body: &descriptor.Body{FieldPath: nil}, }, }, }, }, }, }, } got, err := applyTemplate(param{File: crossLinkFixture(&file), RegisterFuncSuffix: "Handler", AllowPatchFeature: true}, descriptor.NewRegistry()) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } if want := "package example_pb\n"; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `grpclog.Errorf("Failed`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `mux.Handle(http.MethodGet,`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } } func TestApplyTemplateRequestWithoutClientStreaming(t *testing.T) { msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("nested"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String("NestedMessage"), Number: proto.Int32(1), }, }, } nesteddesc := &descriptorpb.DescriptorProto{ Name: proto.String("NestedMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("int32"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_INT32.Enum(), Number: proto.Int32(1), }, { Name: proto.String("bool"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_BOOL.Enum(), Number: proto.Int32(2), }, }, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Echo"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), ClientStreaming: proto.Bool(false), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } for _, spec := range []struct { serverStreaming bool sigWant string }{ { serverStreaming: false, sigWant: `func request_ExampleService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, client ExampleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {`, }, { serverStreaming: true, sigWant: `func request_ExampleService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, client ExampleServiceClient, req *http.Request, pathParams map[string]string) (ExampleService_EchoClient, runtime.ServerMetadata, error) {`, }, } { meth.ServerStreaming = proto.Bool(spec.serverStreaming) msg := &descriptor.Message{ DescriptorProto: msgdesc, } nested := &descriptor.Message{ DescriptorProto: nesteddesc, } nestedField := &descriptor.Field{ Message: msg, FieldDescriptorProto: msg.GetField()[0], } intField := &descriptor.Field{ Message: nested, FieldDescriptorProto: nested.GetField()[0], } boolField := &descriptor.Field{ Message: nested, FieldDescriptorProto: nested.GetField()[1], } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgdesc, nesteddesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg, nested}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1", }, PathParams: []descriptor.Parameter{ { FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "nested", Target: nestedField, }, { Name: "int32", Target: intField, }, }), Target: intField, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "nested", Target: nestedField, }, { Name: "bool", Target: boolField, }, }), }, }, }, }, }, }, }, } got, err := applyTemplate(param{File: crossLinkFixture(&file), RegisterFuncSuffix: "Handler", AllowPatchFeature: true}, descriptor.NewRegistry()) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } if want := spec.sigWant; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `marshaler.NewDecoder(req.Body).Decode(&protoReq.GetNested().Bool)`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `val, ok := pathParams["nested.int32"]`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `protoReq.GetNested().Int32, err = runtime.Int32P(val)`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `func RegisterExampleServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `pattern_ExampleService_Echo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{0, 0}, []string(nil), ""))`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/example.ExampleService/Echo", runtime.WithHTTPPathPattern("/v1"))`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `grpclog.Errorf("Failed`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `mux.Handle(http.MethodPost,`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } } } func TestApplyTemplateOpaquePathParams(t *testing.T) { enumDesc := &descriptorpb.EnumDescriptorProto{ Name: proto.String("Color"), Value: []*descriptorpb.EnumValueDescriptorProto{ { Name: proto.String("COLOR_UNSPECIFIED"), Number: proto.Int32(0), }, { Name: proto.String("COLOR_RED"), Number: proto.Int32(1), }, }, } baseField := &descriptorpb.FieldDescriptorProto{ Name: proto.String("kind"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), } enumField := proto.Clone(baseField).(*descriptorpb.FieldDescriptorProto) enumField.Type = descriptorpb.FieldDescriptorProto_TYPE_ENUM.Enum() enumField.TypeName = proto.String(".example.Color") tcs := map[string]struct { field *descriptorpb.FieldDescriptorProto enumDesc *descriptorpb.EnumDescriptorProto httpMethod string expect string }{ "scalar GET": { field: baseField, httpMethod: "GET", expect: "protoReq.SetKind(convertedKind)", }, "enum PATCH": { field: enumField, enumDesc: enumDesc, httpMethod: "PATCH", expect: "protoReq.SetKind(Color(e))", }, } for name, tc := range tcs { t.Run(name, func(t *testing.T) { msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ proto.Clone(tc.field).(*descriptorpb.FieldDescriptorProto), }, } if tc.enumDesc != nil { msgdesc.EnumType = []*descriptorpb.EnumDescriptorProto{proto.Clone(tc.enumDesc).(*descriptorpb.EnumDescriptorProto)} } fileDesc := &descriptorpb.FileDescriptorProto{ Name: proto.String("example.proto"), Package: proto.String("example"), Syntax: proto.String("proto3"), MessageType: []*descriptorpb.DescriptorProto{msgdesc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("example.com/path/to/example/example.pb;example_pb"), }, } if tc.enumDesc != nil { fileDesc.EnumType = []*descriptorpb.EnumDescriptorProto{proto.Clone(tc.enumDesc).(*descriptorpb.EnumDescriptorProto)} } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("DoThing"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } msg := &descriptor.Message{ DescriptorProto: msgdesc, } field := &descriptor.Field{ Message: msg, FieldDescriptorProto: msgdesc.Field[0], } msg.Fields = []*descriptor.Field{field} file := descriptor.File{ FileDescriptorProto: fileDesc, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: tc.httpMethod, PathTmpl: compilePath(t, "/v1/{kind}"), PathParams: []descriptor.Parameter{ { FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "kind", Target: field, }, }), Target: field, }, }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() req := &pluginpb.CodeGeneratorRequest{ FileToGenerate: []string{"example.proto"}, ProtoFile: []*descriptorpb.FileDescriptorProto{fileDesc}, } if err := reg.Load(req); err != nil { t.Fatalf("registry load failed: %v", err) } cloned := crossLinkFixture(&file) cloned.Services[0].Methods[0].Bindings[0].PathParams[0].Method = cloned.Services[0].Methods[0] got, err := applyTemplate(param{ File: cloned, RegisterFuncSuffix: "Handler", AllowPatchFeature: true, UseOpaqueAPI: true, }, reg) if err != nil { t.Fatalf("applyTemplate failed: %v", err) } if !strings.Contains(got, tc.expect) { t.Fatalf("generated code missing %q: %s", tc.expect, got) } }) } } func TestApplyTemplateRequestWithClientStreaming(t *testing.T) { msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("nested"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String("NestedMessage"), Number: proto.Int32(1), }, }, } nesteddesc := &descriptorpb.DescriptorProto{ Name: proto.String("NestedMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("int32"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_INT32.Enum(), Number: proto.Int32(1), }, { Name: proto.String("bool"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_BOOL.Enum(), Number: proto.Int32(2), }, }, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Echo"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), ClientStreaming: proto.Bool(true), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } for _, spec := range []struct { serverStreaming bool sigWant string }{ { serverStreaming: false, sigWant: `func request_ExampleService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, client ExampleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {`, }, { serverStreaming: true, sigWant: `func request_ExampleService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, client ExampleServiceClient, req *http.Request, pathParams map[string]string) (ExampleService_EchoClient, runtime.ServerMetadata, error) {`, }, } { meth.ServerStreaming = proto.Bool(spec.serverStreaming) msg := &descriptor.Message{ DescriptorProto: msgdesc, } nested := &descriptor.Message{ DescriptorProto: nesteddesc, } nestedField := &descriptor.Field{ Message: msg, FieldDescriptorProto: msg.GetField()[0], } intField := &descriptor.Field{ Message: nested, FieldDescriptorProto: nested.GetField()[0], } boolField := &descriptor.Field{ Message: nested, FieldDescriptorProto: nested.GetField()[1], } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgdesc, nesteddesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg, nested}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, }, PathParams: []descriptor.Parameter{ { FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "nested", Target: nestedField, }, { Name: "int32", Target: intField, }, }), Target: intField, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "nested", Target: nestedField, }, { Name: "bool", Target: boolField, }, }), }, }, }, }, }, }, }, } got, err := applyTemplate(param{File: crossLinkFixture(&file), RegisterFuncSuffix: "Handler", AllowPatchFeature: true}, descriptor.NewRegistry()) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } if want := spec.sigWant; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `func RegisterExampleServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `pattern_ExampleService_Echo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{0, 0}, []string(nil), ""))`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `grpclog.Errorf("Failed`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `mux.Handle(http.MethodPost,`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } } } func TestApplyTemplateInProcess(t *testing.T) { msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("nested"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String("NestedMessage"), Number: proto.Int32(1), }, }, } nesteddesc := &descriptorpb.DescriptorProto{ Name: proto.String("NestedMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("int32"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_INT32.Enum(), Number: proto.Int32(1), }, { Name: proto.String("bool"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_BOOL.Enum(), Number: proto.Int32(2), }, }, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Echo"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), ClientStreaming: proto.Bool(true), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } for _, spec := range []struct { clientStreaming bool serverStreaming bool sigWant []string }{ { clientStreaming: false, serverStreaming: false, sigWant: []string{ `func local_request_ExampleService_Echo_0(ctx context.Context, marshaler runtime.Marshaler, server ExampleServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {`, `resp, md, err := local_request_ExampleService_Echo_0(annotatedContext, inboundMarshaler, server, req, pathParams)`, }, }, { clientStreaming: true, serverStreaming: true, sigWant: []string{ `err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport")`, }, }, { clientStreaming: true, serverStreaming: false, sigWant: []string{ `err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport")`, }, }, { clientStreaming: false, serverStreaming: true, sigWant: []string{ `err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport")`, }, }, } { meth.ClientStreaming = proto.Bool(spec.clientStreaming) meth.ServerStreaming = proto.Bool(spec.serverStreaming) msg := &descriptor.Message{ DescriptorProto: msgdesc, } nested := &descriptor.Message{ DescriptorProto: nesteddesc, } nestedField := &descriptor.Field{ Message: msg, FieldDescriptorProto: msg.GetField()[0], } intField := &descriptor.Field{ Message: nested, FieldDescriptorProto: nested.GetField()[0], } boolField := &descriptor.Field{ Message: nested, FieldDescriptorProto: nested.GetField()[1], } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgdesc, nesteddesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg, nested}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, }, PathParams: []descriptor.Parameter{ { FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "nested", Target: nestedField, }, { Name: "int32", Target: intField, }, }), Target: intField, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "nested", Target: nestedField, }, { Name: "bool", Target: boolField, }, }), }, }, }, }, }, }, }, } got, err := applyTemplate(param{File: crossLinkFixture(&file), RegisterFuncSuffix: "Handler", AllowPatchFeature: true}, descriptor.NewRegistry()) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } for _, want := range spec.sigWant { if !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } } if want := `func RegisterExampleServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ExampleServiceServer) error {`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `grpclog.Errorf("Failed`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `mux.Handle(http.MethodPost,`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } } } func TestAllowPatchFeature(t *testing.T) { updateMaskDesc := &descriptorpb.FieldDescriptorProto{ Name: proto.String("UpdateMask"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".google.protobuf.FieldMask"), Number: proto.Int32(1), } msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{updateMaskDesc}, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Example"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } msg := &descriptor.Message{ DescriptorProto: msgdesc, } updateMaskField := &descriptor.Field{ Message: msg, FieldDescriptorProto: updateMaskDesc, } msg.Fields = append(msg.Fields, updateMaskField) file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgdesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "PATCH", Body: &descriptor.Body{FieldPath: descriptor.FieldPath{descriptor.FieldPathComponent{ Name: "abe", Target: msg.Fields[0], }}}, }, }, }, }, }, }, } want := "if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 {\n" for _, allowPatchFeature := range []bool{true, false} { got, err := applyTemplate(param{File: crossLinkFixture(&file), RegisterFuncSuffix: "Handler", AllowPatchFeature: allowPatchFeature}, descriptor.NewRegistry()) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } if allowPatchFeature { if want := `marshaler.NewDecoder(newReader()).Decode(&protoReq.Abe)`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } } else { if strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to _not_ contain %s", file, got, want) } } if want := `grpclog.Errorf("Failed`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `mux.Handle(http.MethodPatch,`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } } } func TestIdentifierCapitalization(t *testing.T) { msgdesc1 := &descriptorpb.DescriptorProto{ Name: proto.String("Exam_pleRequest"), } msgdesc2 := &descriptorpb.DescriptorProto{ Name: proto.String("example_response"), } meth1 := &descriptorpb.MethodDescriptorProto{ Name: proto.String("ExampleGe2t"), InputType: proto.String("Exam_pleRequest"), OutputType: proto.String("example_response"), } meth2 := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Exampl_ePost"), InputType: proto.String("Exam_pleRequest"), OutputType: proto.String("example_response"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("Example"), Method: []*descriptorpb.MethodDescriptorProto{meth1, meth2}, } msg1 := &descriptor.Message{ DescriptorProto: msgdesc1, } msg2 := &descriptor.Message{ DescriptorProto: msgdesc2, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ Name: proto.String("example.proto"), Package: proto.String("example"), Dependency: []string{"a.example/b/c.proto", "a.example/d/e.proto"}, MessageType: []*descriptorpb.DescriptorProto{msgdesc1, msgdesc2}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg1, msg2}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth1, RequestType: msg1, ResponseType: msg1, Bindings: []*descriptor.Binding{ { HTTPMethod: "GET", Body: &descriptor.Body{FieldPath: nil}, }, }, }, }, }, { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth2, RequestType: msg2, ResponseType: msg2, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", Body: &descriptor.Body{FieldPath: nil}, }, }, }, }, }, }, } got, err := applyTemplate(param{File: crossLinkFixture(&file), RegisterFuncSuffix: "Handler", AllowPatchFeature: true}, descriptor.NewRegistry()) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } if want := `msg, err := client.ExampleGe2T(ctx, &protoReq, grpc.Header(&metadata.HeaderMD)`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `msg, err := client.ExamplEPost(ctx, &protoReq, grpc.Header(&metadata.HeaderMD)`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `var ( protoReq ExamPleRequest`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `var ( protoReq ExampleResponse`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `grpclog.Errorf("Failed`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `mux.Handle(http.MethodGet,`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } if want := `mux.Handle(http.MethodPost,`; !strings.Contains(got, want) { t.Errorf("applyTemplate(%#v) = %s; want to contain %s", file, got, want) } } func TestDuplicatePathsInSameService(t *testing.T) { msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("nested"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), TypeName: proto.String(".google.protobuf.StringValue"), Number: proto.Int32(1), }, }, } meth1 := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Echo"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), } meth2 := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Echo2"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth1, meth2}, } msg := &descriptor.Message{ DescriptorProto: msgdesc, } binding := &descriptor.Binding{ Index: 1, PathTmpl: compilePath(t, "/v1/example/echo"), HTTPMethod: "GET", PathParams: nil, Body: nil, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgdesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth1, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{binding}, }, { MethodDescriptorProto: meth2, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{binding}, }, }, }, }, } _, err := applyTemplate(param{File: crossLinkFixture(&file), RegisterFuncSuffix: "Handler", AllowPatchFeature: true}, descriptor.NewRegistry()) if err == nil { t.Errorf("applyTemplate(%#v) succeeded; want an error", file) return } } func TestDuplicatePathsInDifferentService(t *testing.T) { msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("nested"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), TypeName: proto.String(".google.protobuf.StringValue"), Number: proto.Int32(1), }, }, } meth1 := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Echo"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), } meth2 := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Echo2"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), } svc1 := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleServiceNumberOne"), Method: []*descriptorpb.MethodDescriptorProto{meth1, meth2}, } svc2 := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleServiceNumberTwo"), Method: []*descriptorpb.MethodDescriptorProto{meth1, meth2}, } msg := &descriptor.Message{ DescriptorProto: msgdesc, } binding := &descriptor.Binding{ Index: 1, PathTmpl: compilePath(t, "/v1/example/echo"), HTTPMethod: "GET", PathParams: nil, Body: nil, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgdesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc1, svc2}, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc1, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth1, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{binding}, }, }, }, { ServiceDescriptorProto: svc2, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth2, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{binding}, }, }, }, }, } _, err := applyTemplate(param{File: crossLinkFixture(&file), RegisterFuncSuffix: "Handler", AllowPatchFeature: true}, descriptor.NewRegistry()) if err != nil { t.Errorf("applyTemplate(%#v) failed; want success - %s", file, err) return } } ================================================ FILE: protoc-gen-grpc-gateway/main.go ================================================ // Command protoc-gen-grpc-gateway is a plugin for Google protocol buffer // compiler to generate a reverse-proxy, which converts incoming RESTful // HTTP/1 requests gRPC invocation. // You rarely need to run this program directly. Instead, put this program // into your $PATH with a name "protoc-gen-grpc-gateway" and run // // protoc --grpc-gateway_out=output_directory path/to/input.proto // // See README.md for more details. package main import ( "flag" "fmt" "os" "runtime/debug" "strings" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/codegenerator" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor" "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway/internal/gengateway" "google.golang.org/grpc/grpclog" "google.golang.org/protobuf/compiler/protogen" ) var ( registerFuncSuffix = flag.String("register_func_suffix", "Handler", "used to construct names of generated Register* methods.") useRequestContext = flag.Bool("request_context", true, "determine whether to use http.Request's context or not") allowDeleteBody = flag.Bool("allow_delete_body", false, "unless set, HTTP DELETE methods may not have a body") grpcAPIConfiguration = flag.String("grpc_api_configuration", "", "path to gRPC API Configuration in YAML format") _ = flag.Bool("allow_repeated_fields_in_body", true, "allows to use repeated field in `body` and `response_body` field of `google.api.http` annotation option. DEPRECATED: the value is ignored and always behaves as `true`.") repeatedPathParamSeparator = flag.String("repeated_path_param_separator", "csv", "configures how repeated fields should be split. Allowed values are `csv`, `pipes`, `ssv` and `tsv`.") allowPatchFeature = flag.Bool("allow_patch_feature", true, "determines whether to use PATCH feature involving update masks (using google.protobuf.FieldMask).") omitPackageDoc = flag.Bool("omit_package_doc", false, "if true, no package comment will be included in the generated code") standalone = flag.Bool("standalone", false, "generates a standalone gateway package, which imports the target service package") versionFlag = flag.Bool("version", false, "print the current version") warnOnUnboundMethods = flag.Bool("warn_on_unbound_methods", false, "emit a warning message if an RPC method has no HttpRule annotation") generateUnboundMethods = flag.Bool("generate_unbound_methods", false, "generate proxy methods even for RPC methods that have no HttpRule annotation") useOpaqueAPI = flag.Bool("use_opaque_api", false, "generate code compatible with the new Opaque API instead of the older Open Struct API") _ = flag.Bool("logtostderr", false, "Legacy glog compatibility. This flag is a no-op, you can safely remove it") ) // Variables set by goreleaser at build time var ( version = "dev" commit = "unknown" date = "unknown" ) func main() { flag.Parse() if *versionFlag { if commit == "unknown" { buildInfo, ok := debug.ReadBuildInfo() if ok { version = buildInfo.Main.Version for _, setting := range buildInfo.Settings { if setting.Key == "vcs.revision" { commit = setting.Value } if setting.Key == "vcs.time" { date = setting.Value } } } } fmt.Printf("Version %v, commit %v, built at %v\n", version, commit, date) os.Exit(0) } protogen.Options{ ParamFunc: flag.CommandLine.Set, }.Run(func(gen *protogen.Plugin) error { reg := descriptor.NewRegistry() if err := applyFlags(reg); err != nil { return err } codegenerator.SetSupportedFeaturesOnPluginGen(gen) generator := gengateway.New(reg, *useRequestContext, *registerFuncSuffix, *allowPatchFeature, *standalone, *useOpaqueAPI) if grpclog.V(1) { grpclog.Infof("Parsing code generator request") } if err := reg.LoadFromPlugin(gen); err != nil { return err } unboundHTTPRules := reg.UnboundExternalHTTPRules() if len(unboundHTTPRules) != 0 { return fmt.Errorf("HTTP rules without a matching selector: %s", strings.Join(unboundHTTPRules, ", ")) } targets := make([]*descriptor.File, 0, len(gen.Request.FileToGenerate)) for _, target := range gen.Request.FileToGenerate { f, err := reg.LookupFile(target) if err != nil { return err } targets = append(targets, f) } files, err := generator.Generate(targets) for _, f := range files { if grpclog.V(1) { grpclog.Infof("NewGeneratedFile %q in %s", f.GetName(), f.GoPkg) } genFile := gen.NewGeneratedFile(f.GetName(), protogen.GoImportPath(f.GoPkg.Path)) if _, err := genFile.Write([]byte(f.GetContent())); err != nil { return err } } if grpclog.V(1) { grpclog.Info("Processed code generator request") } return err }) } func applyFlags(reg *descriptor.Registry) error { if *grpcAPIConfiguration != "" { if err := reg.LoadGrpcAPIServiceFromYAML(*grpcAPIConfiguration); err != nil { return err } } if *warnOnUnboundMethods && *generateUnboundMethods { grpclog.Warningf("Option warn_on_unbound_methods has no effect when generate_unbound_methods is used.") } reg.SetStandalone(*standalone) reg.SetAllowDeleteBody(*allowDeleteBody) flag.Visit(func(f *flag.Flag) { if f.Name == "allow_repeated_fields_in_body" { grpclog.Warning("The `allow_repeated_fields_in_body` flag is deprecated and will always behave as `true`.") } }) reg.SetOmitPackageDoc(*omitPackageDoc) reg.SetWarnOnUnboundMethods(*warnOnUnboundMethods) reg.SetGenerateUnboundMethods(*generateUnboundMethods) return reg.SetRepeatedPathParamSeparator(*repeatedPathParamSeparator) } ================================================ FILE: protoc-gen-openapiv2/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test") package(default_visibility = ["//visibility:private"]) go_library( name = "protoc-gen-openapiv2_lib", srcs = ["main.go"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2", deps = [ "//internal/codegenerator", "//internal/descriptor", "//protoc-gen-openapiv2/internal/genopenapi", "//utilities", "@org_golang_google_grpc//grpclog", "@org_golang_google_protobuf//proto", "@org_golang_google_protobuf//types/pluginpb", ], ) go_binary( name = "protoc-gen-openapiv2", embed = [":protoc-gen-openapiv2_lib"], visibility = ["//visibility:public"], ) go_test( name = "protoc-gen-openapiv2_test", size = "small", srcs = ["main_test.go"], embed = [":protoc-gen-openapiv2_lib"], ) ================================================ FILE: protoc-gen-openapiv2/defs.bzl ================================================ """Generated an open-api spec for a grpc api spec. Reads the api spec in protobuf format and generate an open-api spec. Optionally applies settings from the grpc-service configuration. """ load("@rules_proto//proto:defs.bzl", "ProtoInfo") # TODO(yannic): Replace with |proto_common.direct_source_infos| when # https://github.com/bazelbuild/rules_proto/pull/22 lands. def _direct_source_infos(proto_info, provided_sources = []): """Returns sequence of `ProtoFileInfo` for `proto_info`'s direct sources. Files that are both in `proto_info`'s direct sources and in `provided_sources` are skipped. This is useful, e.g., for well-known protos that are already provided by the Protobuf runtime. Args: proto_info: An instance of `ProtoInfo`. provided_sources: Optional. A sequence of files to ignore. Usually, these files are already provided by the Protocol Buffer runtime (e.g. Well-Known protos). Returns: A sequence of `ProtoFileInfo` containing information about `proto_info`'s direct sources. """ source_root = proto_info.proto_source_root if "." == source_root: return [struct(file = src, import_path = src.path) for src in proto_info.check_deps_sources.to_list()] offset = len(source_root) + 1 # + '/'. infos = [] for src in proto_info.check_deps_sources.to_list(): # TODO(yannic): Remove this hack when we drop support for Bazel < 1.0. local_offset = offset if src.root.path and not source_root.startswith(src.root.path): # Before Bazel 1.0, `proto_source_root` wasn't guaranteed to be a # prefix of `src.path`. This could happened, e.g., if `file` was # generated (https://github.com/bazelbuild/bazel/issues/9215). local_offset += len(src.root.path) + 1 # + '/'. infos.append(struct(file = src, import_path = src.path[local_offset:])) return infos def _run_proto_gen_openapi( actions, proto_info, target_name, transitive_proto_srcs, protoc, protoc_gen_openapiv2, single_output, allow_delete_body, grpc_api_configuration, json_names_for_fields, repeated_path_param_separator, include_package_in_tags, fqn_for_openapi_name, openapi_naming_strategy, use_go_templates, go_template_args, ignore_comments, remove_internal_comments, disable_default_errors, disable_service_tags, enums_as_ints, omit_enum_default_value, output_format, simple_operation_ids, proto3_optional_nullable, openapi_configuration, generate_unbound_methods, visibility_restriction_selectors, use_allof_for_refs, omit_array_item_type_when_ref_sibling, disable_default_responses, enable_rpc_deprecation, enable_field_deprecation, expand_slashed_path_patterns, preserve_rpc_order, generate_x_go_type): args = actions.args() args.add("--plugin", "protoc-gen-openapiv2=%s" % protoc_gen_openapiv2.path) extra_inputs = [] if grpc_api_configuration: extra_inputs.append(grpc_api_configuration) args.add("--openapiv2_opt", "grpc_api_configuration=%s" % grpc_api_configuration.path) if openapi_configuration: extra_inputs.append(openapi_configuration) args.add("--openapiv2_opt", "openapi_configuration=%s" % openapi_configuration.path) if not json_names_for_fields: args.add("--openapiv2_opt", "json_names_for_fields=false") if fqn_for_openapi_name: args.add("--openapiv2_opt", "fqn_for_openapi_name=true") if openapi_naming_strategy: args.add("--openapiv2_opt", "openapi_naming_strategy=%s" % openapi_naming_strategy) if generate_unbound_methods: args.add("--openapiv2_opt", "generate_unbound_methods=true") if simple_operation_ids: args.add("--openapiv2_opt", "simple_operation_ids=true") if allow_delete_body: args.add("--openapiv2_opt", "allow_delete_body=true") if include_package_in_tags: args.add("--openapiv2_opt", "include_package_in_tags=true") if use_go_templates: args.add("--openapiv2_opt", "use_go_templates=true") for go_template_arg in go_template_args: args.add("--openapiv2_opt", "go_template_args=%s" % go_template_arg) if ignore_comments: args.add("--openapiv2_opt", "ignore_comments=true") if remove_internal_comments: args.add("--openapiv2_opt", "remove_internal_comments=true") if disable_default_errors: args.add("--openapiv2_opt", "disable_default_errors=true") if disable_service_tags: args.add("--openapiv2_opt", "disable_service_tags=true") if enums_as_ints: args.add("--openapiv2_opt", "enums_as_ints=true") if omit_enum_default_value: args.add("--openapiv2_opt", "omit_enum_default_value=true") if output_format: args.add("--openapiv2_opt", "output_format=%s" % output_format) if proto3_optional_nullable: args.add("--openapiv2_opt", "proto3_optional_nullable=true") for visibility_restriction_selector in visibility_restriction_selectors: args.add("--openapiv2_opt", "visibility_restriction_selectors=%s" % visibility_restriction_selector) if use_allof_for_refs: args.add("--openapiv2_opt", "use_allof_for_refs=true") if omit_array_item_type_when_ref_sibling: args.add("--openapiv2_opt", "omit_array_item_type_when_ref_sibling=true") if disable_default_responses: args.add("--openapiv2_opt", "disable_default_responses=true") if enable_rpc_deprecation: args.add("--openapiv2_opt", "enable_rpc_deprecation=true") if enable_field_deprecation: args.add("--openapiv2_opt", "enable_field_deprecation=true") if expand_slashed_path_patterns: args.add("--openapiv2_opt", "expand_slashed_path_patterns=true") if preserve_rpc_order: args.add("--openapiv2_opt", "preserve_rpc_order=true") if generate_x_go_type: args.add("--openapiv2_opt", "generate_x_go_type=true") args.add("--openapiv2_opt", "repeated_path_param_separator=%s" % repeated_path_param_separator) proto_file_infos = _direct_source_infos(proto_info) # TODO(yannic): Use |proto_info.transitive_descriptor_sets| when # https://github.com/bazelbuild/bazel/issues/9337 is fixed. args.add_all(proto_info.transitive_proto_path, format_each = "--proto_path=%s") if single_output: args.add("--openapiv2_opt", "allow_merge=true") args.add("--openapiv2_opt", "merge_file_name=%s" % target_name) openapi_file = actions.declare_file("%s.swagger.json" % target_name) args.add("--openapiv2_out", openapi_file.dirname) args.add_all([f.import_path for f in proto_file_infos]) actions.run( executable = protoc, tools = [protoc_gen_openapiv2], inputs = depset( direct = extra_inputs, transitive = [transitive_proto_srcs], ), outputs = [openapi_file], arguments = [args], ) return [openapi_file] # TODO(yannic): We may be able to generate all files in a single action, # but that will change at least the semantics of `use_go_template.proto`. openapi_files = [] for proto_file_info in proto_file_infos: # TODO(yannic): This probably doesn't work as expected: we only add this # option after we have seen it, so `.proto` sources that happen to be # in the list of `.proto` files before `use_go_template.proto` will be # compiled without this option, and all sources that get compiled after # `use_go_template.proto` will have this option on. if proto_file_info.file.basename == "use_go_template.proto": args.add("--openapiv2_opt", "use_go_templates=true") file_name = "%s.swagger.json" % proto_file_info.import_path[:-len(".proto")] openapi_file = actions.declare_file( "_virtual_imports/%s/%s" % (target_name, file_name), ) file_args = actions.args() offset = len(file_name) + 1 # + '/'. file_args.add("--openapiv2_out", openapi_file.path[:-offset]) file_args.add(proto_file_info.import_path) actions.run( executable = protoc, tools = [protoc_gen_openapiv2], inputs = depset( direct = extra_inputs, transitive = [transitive_proto_srcs], ), outputs = [openapi_file], arguments = [args, file_args], ) openapi_files.append(openapi_file) return openapi_files def _proto_gen_openapi_impl(ctx): proto = ctx.attr.proto[ProtoInfo] return [ DefaultInfo( files = depset( _run_proto_gen_openapi( actions = ctx.actions, proto_info = proto, target_name = ctx.attr.name, transitive_proto_srcs = depset( direct = ctx.files._well_known_protos, transitive = [proto.transitive_sources], ), protoc = ctx.executable._protoc, protoc_gen_openapiv2 = ctx.executable._protoc_gen_openapi, single_output = ctx.attr.single_output, allow_delete_body = ctx.attr.allow_delete_body, grpc_api_configuration = ctx.file.grpc_api_configuration, json_names_for_fields = ctx.attr.json_names_for_fields, repeated_path_param_separator = ctx.attr.repeated_path_param_separator, include_package_in_tags = ctx.attr.include_package_in_tags, fqn_for_openapi_name = ctx.attr.fqn_for_openapi_name, openapi_naming_strategy = ctx.attr.openapi_naming_strategy, use_go_templates = ctx.attr.use_go_templates, go_template_args = ctx.attr.go_template_args, ignore_comments = ctx.attr.ignore_comments, remove_internal_comments = ctx.attr.remove_internal_comments, disable_default_errors = ctx.attr.disable_default_errors, disable_service_tags = ctx.attr.disable_service_tags, enums_as_ints = ctx.attr.enums_as_ints, omit_enum_default_value = ctx.attr.omit_enum_default_value, output_format = ctx.attr.output_format, simple_operation_ids = ctx.attr.simple_operation_ids, proto3_optional_nullable = ctx.attr.proto3_optional_nullable, openapi_configuration = ctx.file.openapi_configuration, generate_unbound_methods = ctx.attr.generate_unbound_methods, visibility_restriction_selectors = ctx.attr.visibility_restriction_selectors, use_allof_for_refs = ctx.attr.use_allof_for_refs, omit_array_item_type_when_ref_sibling = ctx.attr.omit_array_item_type_when_ref_sibling, disable_default_responses = ctx.attr.disable_default_responses, enable_rpc_deprecation = ctx.attr.enable_rpc_deprecation, enable_field_deprecation = ctx.attr.enable_field_deprecation, expand_slashed_path_patterns = ctx.attr.expand_slashed_path_patterns, preserve_rpc_order = ctx.attr.preserve_rpc_order, generate_x_go_type = ctx.attr.generate_x_go_type, ), ), ), ] protoc_gen_openapiv2 = rule( attrs = { "proto": attr.label( mandatory = True, providers = [ProtoInfo], ), "single_output": attr.bool( default = False, mandatory = False, doc = "if set, the rule will generate a single OpenAPI file", ), "allow_delete_body": attr.bool( default = False, mandatory = False, doc = "unless set, HTTP DELETE methods may not have a body", ), "grpc_api_configuration": attr.label( allow_single_file = True, mandatory = False, doc = "path to file which describes the gRPC API Configuration in YAML format", ), "json_names_for_fields": attr.bool( default = True, mandatory = False, doc = "if disabled, the original proto name will be used for generating OpenAPI definitions", ), "repeated_path_param_separator": attr.string( default = "csv", mandatory = False, values = ["csv", "pipes", "ssv", "tsv"], doc = "configures how repeated fields should be split." + " Allowed values are `csv`, `pipes`, `ssv` and `tsv`", ), "include_package_in_tags": attr.bool( default = False, mandatory = False, doc = "if unset, the gRPC service name is added to the `Tags`" + " field of each operation. If set and the `package` directive" + " is shown in the proto file, the package name will be " + " prepended to the service name", ), "fqn_for_openapi_name": attr.bool( default = False, mandatory = False, doc = "if set, the object's OpenAPI names will use the fully" + " qualified names from the proto definition" + " (ie my.package.MyMessage.MyInnerMessage", ), "openapi_naming_strategy": attr.string( default = "", mandatory = False, values = ["", "simple", "package", "legacy", "fqn"], doc = "configures how OpenAPI names are determined." + " Allowed values are `` (empty), `simple`, `package`, `legacy` and `fqn`." + " If unset, either `legacy` or `fqn` are selected, depending" + " on the value of the `fqn_for_openapi_name` setting", ), "use_go_templates": attr.bool( default = False, mandatory = False, doc = "if set, you can use Go templates in protofile comments", ), "go_template_args": attr.string_list( mandatory = False, doc = "specify a key value pair as inputs to the Go template of the protofile" + " comments. Repeat this option to specify multiple template arguments." + " Requires the `use_go_templates` option to be set.", ), "ignore_comments": attr.bool( default = False, mandatory = False, doc = "if set, all protofile comments are excluded from output", ), "remove_internal_comments": attr.bool( default = False, mandatory = False, doc = "if set, removes all substrings in comments that start with " + "`(--` and end with `--)` as specified in " + "https://google.aip.dev/192#internal-comments", ), "disable_default_errors": attr.bool( default = False, mandatory = False, doc = "if set, disables generation of default errors." + " This is useful if you have defined custom error handling", ), "disable_service_tags": attr.bool( default = False, mandatory = False, doc = "if set, disables generation of service tags." + " This is useful if you do not want to expose the names of your backend grpc services.", ), "enums_as_ints": attr.bool( default = False, mandatory = False, doc = "whether to render enum values as integers, as opposed to string values", ), "omit_enum_default_value": attr.bool( default = False, mandatory = False, doc = "if set, omit default enum value", ), "output_format": attr.string( default = "json", mandatory = False, values = ["json", "yaml"], doc = "output content format. Allowed values are: `json`, `yaml`", ), "simple_operation_ids": attr.bool( default = False, mandatory = False, doc = "whether to remove the service prefix in the operationID" + " generation. Can introduce duplicate operationIDs, use with caution.", ), "proto3_optional_nullable": attr.bool( default = False, mandatory = False, doc = "whether Proto3 Optional fields should be marked as x-nullable", ), "openapi_configuration": attr.label( allow_single_file = True, mandatory = False, doc = "path to file which describes the OpenAPI Configuration in YAML format", ), "generate_unbound_methods": attr.bool( default = False, mandatory = False, doc = "generate swagger metadata even for RPC methods that have" + " no HttpRule annotation", ), "visibility_restriction_selectors": attr.string_list( mandatory = False, doc = "list of `google.api.VisibilityRule` visibility labels to include" + " in the generated output when a visibility annotation is defined." + " Repeat this option to supply multiple values. Elements without" + " visibility annotations are unaffected by this setting.", ), "use_allof_for_refs": attr.bool( default = False, mandatory = False, doc = "if set, will use allOf as container for $ref to preserve" + " same-level properties.", ), "omit_array_item_type_when_ref_sibling": attr.bool( default = False, mandatory = False, doc = "if set, will omit 'type: object' in array items when $ref is present" + " to avoid strict no-$ref-siblings rule violations.", ), "disable_default_responses": attr.bool( default = False, mandatory = False, doc = "if set, disables generation of default responses. Useful" + " if you have to support custom response codes that are" + " not 200.", ), "enable_rpc_deprecation": attr.bool( default = False, mandatory = False, doc = "whether to process grpc method's deprecated option.", ), "enable_field_deprecation": attr.bool( default = False, mandatory = False, doc = "whether to process proto field's deprecated option.", ), "expand_slashed_path_patterns": attr.bool( default = False, mandatory = False, doc = "if set, expands path patterns containing slashes into URI." + " It also creates a new path parameter for each wildcard in " + " the path pattern.", ), "preserve_rpc_order": attr.bool( default = False, mandatory = False, doc = "if set, ensures the order of paths emitted in OpenAPI files" + " mirrors the order of RPC methods found in proto files." + " If false, emitted paths will be ordered alphabetically.", ), "use_proto3_field_semantics": attr.bool( default = False, mandatory = False, doc = "if set, uses proto3 field semantics for the OpenAPI schema." + " This means that fields are required by default.", ), "generate_x_go_type": attr.bool( default = False, mandatory = False, doc = "Generate x-go-type extension using the go_package option from proto files", ), "_protoc": attr.label( default = "@com_google_protobuf//:protoc", executable = True, cfg = "exec", ), "_well_known_protos": attr.label( default = "@com_google_protobuf//:well_known_type_protos", allow_files = True, ), "_protoc_gen_openapi": attr.label( default = Label("//protoc-gen-openapiv2:protoc-gen-openapiv2"), executable = True, cfg = "exec", ), }, implementation = _proto_gen_openapi_impl, ) ================================================ FILE: protoc-gen-openapiv2/internal/genopenapi/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") package(default_visibility = ["//protoc-gen-openapiv2:__subpackages__"]) go_library( name = "genopenapi", srcs = [ "doc.go", "format.go", "generator.go", "helpers.go", "helpers_go111_old.go", "naming.go", "template.go", "types.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/internal/genopenapi", deps = [ "//internal/casing", "//internal/descriptor", "//internal/generator", "//protoc-gen-openapiv2/options", "@in_yaml_go_yaml_v3//:yaml", "@org_golang_google_genproto_googleapis_api//annotations", "@org_golang_google_genproto_googleapis_api//visibility", "@org_golang_google_genproto_googleapis_rpc//status", "@org_golang_google_grpc//grpclog", "@org_golang_google_protobuf//encoding/protojson", "@org_golang_google_protobuf//proto", "@org_golang_google_protobuf//reflect/protodesc", "@org_golang_google_protobuf//types/descriptorpb", "@org_golang_google_protobuf//types/known/anypb", "@org_golang_google_protobuf//types/known/structpb", "@org_golang_google_protobuf//types/pluginpb", "@org_golang_x_text//cases", "@org_golang_x_text//language", ], ) go_test( name = "genopenapi_test", size = "small", srcs = [ "cycle_test.go", "format_test.go", "generator_test.go", "helpers_test.go", "naming_test.go", "template_fuzz_test.go", "template_test.go", "types_test.go", ], data = glob(["testdata/**"]), embed = [":genopenapi"], deps = [ "//internal/descriptor", "//internal/descriptor/openapiconfig", "//internal/httprule", "//protoc-gen-openapiv2/options", "//runtime", "@com_github_google_go_cmp//cmp", "@in_yaml_go_yaml_v3//:yaml", "@org_golang_google_genproto_googleapis_api//annotations", "@org_golang_google_genproto_googleapis_api//visibility", "@org_golang_google_protobuf//encoding/protojson", "@org_golang_google_protobuf//encoding/prototext", "@org_golang_google_protobuf//proto", "@org_golang_google_protobuf//reflect/protodesc", "@org_golang_google_protobuf//reflect/protoreflect", "@org_golang_google_protobuf//reflect/protoregistry", "@org_golang_google_protobuf//types/descriptorpb", "@org_golang_google_protobuf//types/known/anypb", "@org_golang_google_protobuf//types/known/durationpb", "@org_golang_google_protobuf//types/known/emptypb", "@org_golang_google_protobuf//types/known/fieldmaskpb", "@org_golang_google_protobuf//types/known/structpb", "@org_golang_google_protobuf//types/known/timestamppb", "@org_golang_google_protobuf//types/known/wrapperspb", "@org_golang_google_protobuf//types/pluginpb", ], ) alias( name = "go_default_library", actual = ":genopenapi", visibility = ["//protoc-gen-openapiv2:__subpackages__"], ) ================================================ FILE: protoc-gen-openapiv2/internal/genopenapi/cycle_test.go ================================================ package genopenapi import ( "testing" ) func TestCycle(t *testing.T) { for _, tt := range []struct { max int attempt int e bool }{ { max: 3, attempt: 3, e: true, }, { max: 5, attempt: 6, }, { max: 1000, attempt: 1001, }, } { c := newCycleChecker(tt.max) var final bool for i := 0; i < tt.attempt; i++ { final = c.Check("a") if !final { break } } if final != tt.e { t.Errorf("got: %t wanted: %t", final, tt.e) } } } ================================================ FILE: protoc-gen-openapiv2/internal/genopenapi/doc.go ================================================ // Package genopenapi provides a code generator for OpenAPI v2. package genopenapi ================================================ FILE: protoc-gen-openapiv2/internal/genopenapi/format.go ================================================ package genopenapi import ( "encoding/json" "errors" "io" "go.yaml.in/yaml/v3" ) type Format string const ( FormatJSON Format = "json" FormatYAML Format = "yaml" ) type ContentEncoder interface { Encode(v interface{}) (err error) } func (f Format) Validate() error { switch f { case FormatJSON, FormatYAML: return nil default: return errors.New("unknown format: " + string(f)) } } func (f Format) NewEncoder(w io.Writer) (ContentEncoder, error) { switch f { case FormatYAML: enc := yaml.NewEncoder(w) enc.SetIndent(2) return enc, nil case FormatJSON: enc := json.NewEncoder(w) enc.SetIndent("", " ") return enc, nil default: return nil, errors.New("unknown format: " + string(f)) } } ================================================ FILE: protoc-gen-openapiv2/internal/genopenapi/format_test.go ================================================ package genopenapi_test import ( "bytes" "encoding/json" "io" "reflect" "testing" "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/internal/genopenapi" "go.yaml.in/yaml/v3" ) func TestFormatValidate(t *testing.T) { t.Parallel() testCases := [...]struct { Format genopenapi.Format Valid bool }{{ Format: genopenapi.FormatJSON, Valid: true, }, { Format: genopenapi.FormatYAML, Valid: true, }, { Format: genopenapi.Format("unknown"), Valid: false, }, { Format: genopenapi.Format(""), Valid: false, }} for _, tc := range testCases { tc := tc t.Run(string(tc.Format), func(t *testing.T) { t.Parallel() err := tc.Format.Validate() switch { case tc.Valid && err != nil: t.Fatalf("expect no validation error, got: %s", err) case !tc.Valid && err == nil: t.Fatal("expect validation error, got nil") } }) } } func TestFormatEncode(t *testing.T) { t.Parallel() type contentDecoder interface { Decode(v interface{}) error } testCases := [...]struct { Format genopenapi.Format NewDecoder func(r io.Reader) contentDecoder }{{ Format: genopenapi.FormatJSON, NewDecoder: func(r io.Reader) contentDecoder { return json.NewDecoder(r) }, }, { Format: genopenapi.FormatYAML, NewDecoder: func(r io.Reader) contentDecoder { return yaml.NewDecoder(r) }, }} for _, tc := range testCases { tc := tc t.Run(string(tc.Format), func(t *testing.T) { t.Parallel() expParams := map[string]string{ "hello": "world", } var buf bytes.Buffer enc, err := tc.Format.NewEncoder(&buf) if err != nil { t.Fatalf("expect no encoder creating error, got: %s", err) } err = enc.Encode(expParams) if err != nil { t.Fatalf("expect no encoding error, got: %s", err) } gotParams := make(map[string]string) err = tc.NewDecoder(&buf).Decode(&gotParams) if err != nil { t.Fatalf("expect no decoding error, got: %s", err) } if !reflect.DeepEqual(expParams, gotParams) { t.Fatalf("expected: %+v, actual: %+v", expParams, gotParams) } }) } } ================================================ FILE: protoc-gen-openapiv2/internal/genopenapi/generator.go ================================================ package genopenapi import ( "bytes" "encoding/json" "errors" "fmt" "path/filepath" "reflect" "sort" "strings" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor" gen "github.com/grpc-ecosystem/grpc-gateway/v2/internal/generator" openapioptions "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" "go.yaml.in/yaml/v3" statuspb "google.golang.org/genproto/googleapis/rpc/status" "google.golang.org/grpc/grpclog" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protodesc" "google.golang.org/protobuf/types/descriptorpb" "google.golang.org/protobuf/types/known/anypb" "google.golang.org/protobuf/types/pluginpb" ) var errNoTargetService = errors.New("no target service defined in the file") type generator struct { reg *descriptor.Registry format Format } type wrapper struct { fileName string swagger *openapiSwaggerObject } type GeneratorOptions struct { Registry *descriptor.Registry RecursiveDepth int } // New returns a new generator which generates grpc gateway files. func New(reg *descriptor.Registry, format Format) gen.Generator { return &generator{ reg: reg, format: format, } } // Merge a lot of OpenAPI file (wrapper) to single one OpenAPI file func mergeTargetFile(targets []*wrapper, mergeFileName string) *wrapper { var mergedTarget *wrapper for _, f := range targets { if mergedTarget == nil { mergedTarget = &wrapper{ fileName: mergeFileName, swagger: f.swagger, } } else { for k, v := range f.swagger.Definitions { mergedTarget.swagger.Definitions[k] = v } for k, v := range f.swagger.SecurityDefinitions { mergedTarget.swagger.SecurityDefinitions[k] = v } copy(mergedTarget.swagger.Paths, f.swagger.Paths) mergedTarget.swagger.Security = append(mergedTarget.swagger.Security, f.swagger.Security...) } } return mergedTarget } // Q: What's up with the alias types here? // A: We don't want to completely override how these structs are marshaled into // JSON, we only want to add fields (see below, extensionMarshalJSON). // An infinite recursion would happen if we'd call json.Marshal on the struct // that has swaggerObject as an embedded field. To avoid that, we'll create // type aliases, and those don't have the custom MarshalJSON methods defined // on them. See http://choly.ca/post/go-json-marshalling/ (or, if it ever // goes away, use // https://web.archive.org/web/20190806073003/http://choly.ca/post/go-json-marshalling/). func (so openapiSwaggerObject) MarshalJSON() ([]byte, error) { type alias openapiSwaggerObject return extensionMarshalJSON(alias(so), so.extensions) } // MarshalYAML implements yaml.Marshaler interface. // // It is required in order to pass extensions inline. // // Example: // // extensions: {x-key: x-value} // type: string // // It will be rendered as: // // x-key: x-value // type: string // // Use generics when the project will be upgraded to go 1.18+. func (so openapiSwaggerObject) MarshalYAML() (interface{}, error) { type Alias openapiSwaggerObject return struct { Extension map[string]interface{} `yaml:",inline"` Alias `yaml:",inline"` }{ Extension: extensionsToMap(so.extensions), Alias: Alias(so), }, nil } // Custom json marshaller for openapiPathsObject. Ensures // openapiPathsObject is marshalled into expected format in generated // swagger.json. func (po openapiPathsObject) MarshalJSON() ([]byte, error) { var buf bytes.Buffer buf.WriteString("{") for i, pd := range po { if i != 0 { buf.WriteString(",") } // marshal key key, err := json.Marshal(pd.Path) if err != nil { return nil, err } buf.Write(key) buf.WriteString(":") // marshal value val, err := json.Marshal(pd.PathItemObject) if err != nil { return nil, err } buf.Write(val) } buf.WriteString("}") return buf.Bytes(), nil } // Custom yaml marshaller for openapiPathsObject. Ensures // openapiPathsObject is marshalled into expected format in generated // swagger.yaml. func (po openapiPathsObject) MarshalYAML() (interface{}, error) { var pathObjectNode yaml.Node pathObjectNode.Kind = yaml.MappingNode for _, pathData := range po { var pathNode yaml.Node pathNode.SetString(pathData.Path) pathItemObjectNode, err := pathData.PathItemObject.toYAMLNode() if err != nil { return nil, err } pathObjectNode.Content = append(pathObjectNode.Content, &pathNode, pathItemObjectNode) } return pathObjectNode, nil } // We can simplify this implementation once the go-yaml bug is resolved. See: https://github.com/go-yaml/yaml/issues/643. // // func (pio *openapiPathItemObject) toYAMLNode() (*yaml.Node, error) { // var node yaml.Node // if err := node.Encode(pio); err != nil { // return nil, err // } // return &node, nil // } func (pio *openapiPathItemObject) toYAMLNode() (*yaml.Node, error) { var doc yaml.Node var buf bytes.Buffer ec := yaml.NewEncoder(&buf) ec.SetIndent(2) if err := ec.Encode(pio); err != nil { return nil, err } if err := yaml.Unmarshal(buf.Bytes(), &doc); err != nil { return nil, err } if len(doc.Content) == 0 { return nil, errors.New("unexpected number of yaml nodes") } return doc.Content[0], nil } func (so openapiInfoObject) MarshalJSON() ([]byte, error) { type alias openapiInfoObject return extensionMarshalJSON(alias(so), so.extensions) } func (so openapiInfoObject) MarshalYAML() (interface{}, error) { type Alias openapiInfoObject return struct { Extension map[string]interface{} `yaml:",inline"` Alias `yaml:",inline"` }{ Extension: extensionsToMap(so.extensions), Alias: Alias(so), }, nil } func (so openapiSecuritySchemeObject) MarshalJSON() ([]byte, error) { type alias openapiSecuritySchemeObject return extensionMarshalJSON(alias(so), so.extensions) } func (so openapiSecuritySchemeObject) MarshalYAML() (interface{}, error) { type Alias openapiSecuritySchemeObject return struct { Extension map[string]interface{} `yaml:",inline"` Alias `yaml:",inline"` }{ Extension: extensionsToMap(so.extensions), Alias: Alias(so), }, nil } func (so openapiOperationObject) MarshalJSON() ([]byte, error) { type alias openapiOperationObject return extensionMarshalJSON(alias(so), so.extensions) } func (so openapiOperationObject) MarshalYAML() (interface{}, error) { type Alias openapiOperationObject return struct { Extension map[string]interface{} `yaml:",inline"` Alias `yaml:",inline"` }{ Extension: extensionsToMap(so.extensions), Alias: Alias(so), }, nil } func (so openapiResponseObject) MarshalJSON() ([]byte, error) { type alias openapiResponseObject return extensionMarshalJSON(alias(so), so.extensions) } func (so openapiResponseObject) MarshalYAML() (interface{}, error) { type Alias openapiResponseObject return struct { Extension map[string]interface{} `yaml:",inline"` Alias `yaml:",inline"` }{ Extension: extensionsToMap(so.extensions), Alias: Alias(so), }, nil } func (so openapiSchemaObject) MarshalJSON() ([]byte, error) { type alias openapiSchemaObject return extensionMarshalJSON(alias(so), so.extensions) } func (so openapiSchemaObject) MarshalYAML() (interface{}, error) { type Alias openapiSchemaObject return struct { Extension map[string]interface{} `yaml:",inline"` Alias `yaml:",inline"` }{ Extension: extensionsToMap(so.extensions), Alias: Alias(so), }, nil } func (so openapiParameterObject) MarshalJSON() ([]byte, error) { type alias openapiParameterObject return extensionMarshalJSON(alias(so), so.extensions) } func (so openapiParameterObject) MarshalYAML() (interface{}, error) { type Alias openapiParameterObject return struct { Extension map[string]interface{} `yaml:",inline"` Alias `yaml:",inline"` }{ Extension: extensionsToMap(so.extensions), Alias: Alias(so), }, nil } func (so openapiTagObject) MarshalJSON() ([]byte, error) { type alias openapiTagObject return extensionMarshalJSON(alias(so), so.extensions) } func (so openapiTagObject) MarshalYAML() (interface{}, error) { type Alias openapiTagObject return struct { Extension map[string]interface{} `yaml:",inline"` Alias `yaml:",inline"` }{ Extension: extensionsToMap(so.extensions), Alias: Alias(so), }, nil } func extensionMarshalJSON(so interface{}, extensions []extension) ([]byte, error) { // To append arbitrary keys to the struct we'll render into json, // we're creating another struct that embeds the original one, and // its extra fields: // // The struct will look like // struct { // *openapiCore // XGrpcGatewayFoo json.RawMessage `json:"x-grpc-gateway-foo"` // XGrpcGatewayBar json.RawMessage `json:"x-grpc-gateway-bar"` // } // and thus render into what we want -- the JSON of openapiCore with the // extensions appended. fields := []reflect.StructField{ { // embedded Name: "Embedded", Type: reflect.TypeOf(so), Anonymous: true, }, } for _, ext := range extensions { fields = append(fields, reflect.StructField{ Name: fieldName(ext.key), Type: reflect.TypeOf(ext.value), Tag: reflect.StructTag(fmt.Sprintf("json:\"%s\"", ext.key)), }) } t := reflect.StructOf(fields) s := reflect.New(t).Elem() s.Field(0).Set(reflect.ValueOf(so)) for _, ext := range extensions { s.FieldByName(fieldName(ext.key)).Set(reflect.ValueOf(ext.value)) } return json.Marshal(s.Interface()) } // encodeOpenAPI converts OpenAPI file obj to pluginpb.CodeGeneratorResponse_File func encodeOpenAPI(file *wrapper, format Format) (*descriptor.ResponseFile, error) { var contentBuf bytes.Buffer enc, err := format.NewEncoder(&contentBuf) if err != nil { return nil, err } if err := enc.Encode(*file.swagger); err != nil { return nil, err } name := file.fileName ext := filepath.Ext(name) base := strings.TrimSuffix(name, ext) output := fmt.Sprintf("%s.swagger."+string(format), base) return &descriptor.ResponseFile{ CodeGeneratorResponse_File: &pluginpb.CodeGeneratorResponse_File{ Name: proto.String(output), Content: proto.String(contentBuf.String()), }, }, nil } func (g *generator) Generate(targets []*descriptor.File) ([]*descriptor.ResponseFile, error) { var files []*descriptor.ResponseFile if g.reg.IsAllowMerge() { var mergedTarget *descriptor.File // try to find proto leader for _, f := range targets { if proto.HasExtension(f.Options, openapioptions.E_Openapiv2Swagger) { mergedTarget = f break } } // merge protos to leader for _, f := range targets { if mergedTarget == nil { mergedTarget = f } else if mergedTarget != f { mergedTarget.Enums = append(mergedTarget.Enums, f.Enums...) mergedTarget.Messages = append(mergedTarget.Messages, f.Messages...) mergedTarget.Services = append(mergedTarget.Services, f.Services...) } } targets = nil targets = append(targets, mergedTarget) } var openapis []*wrapper for _, file := range targets { if grpclog.V(1) { grpclog.Infof("Processing %s", file.GetName()) } swagger, err := applyTemplate(param{File: file, reg: g.reg}) if errors.Is(err, errNoTargetService) { if grpclog.V(1) { grpclog.Infof("%s: %v", file.GetName(), err) } continue } if err != nil { return nil, err } openapis = append(openapis, &wrapper{ fileName: file.GetName(), swagger: swagger, }) } if g.reg.IsAllowMerge() { targetOpenAPI := mergeTargetFile(openapis, g.reg.GetMergeFileName()) if !g.reg.IsPreserveRPCOrder() { targetOpenAPI.swagger.sortPathsAlphabetically() } f, err := encodeOpenAPI(targetOpenAPI, g.format) if err != nil { return nil, fmt.Errorf("failed to encode OpenAPI for %s: %w", g.reg.GetMergeFileName(), err) } files = append(files, f) if grpclog.V(1) { grpclog.Infof("New OpenAPI file will emit") } } else { for _, file := range openapis { if !g.reg.IsPreserveRPCOrder() { file.swagger.sortPathsAlphabetically() } f, err := encodeOpenAPI(file, g.format) if err != nil { return nil, fmt.Errorf("failed to encode OpenAPI for %s: %w", file.fileName, err) } files = append(files, f) if grpclog.V(1) { grpclog.Infof("New OpenAPI file will emit") } } } return files, nil } func (so openapiSwaggerObject) sortPathsAlphabetically() { sort.Slice(so.Paths, func(i, j int) bool { return so.Paths[i].Path < so.Paths[j].Path }) } // AddErrorDefs Adds google.rpc.Status and google.protobuf.Any // to registry (used for error-related API responses) func AddErrorDefs(reg *descriptor.Registry) error { // load internal protos any := protodesc.ToFileDescriptorProto((&anypb.Any{}).ProtoReflect().Descriptor().ParentFile()) any.SourceCodeInfo = new(descriptorpb.SourceCodeInfo) status := protodesc.ToFileDescriptorProto((&statuspb.Status{}).ProtoReflect().Descriptor().ParentFile()) status.SourceCodeInfo = new(descriptorpb.SourceCodeInfo) return reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{ any, status, }, }) } func extensionsToMap(extensions []extension) map[string]interface{} { m := make(map[string]interface{}, len(extensions)) for _, v := range extensions { m[v.key] = RawExample(v.value) } return m } ================================================ FILE: protoc-gen-openapiv2/internal/genopenapi/generator_test.go ================================================ package genopenapi_test import ( "bytes" "os" "reflect" "sort" "strings" "testing" "github.com/google/go-cmp/cmp" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor" "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/internal/genopenapi" "go.yaml.in/yaml/v3" "google.golang.org/protobuf/encoding/prototext" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/descriptorpb" "google.golang.org/protobuf/types/pluginpb" ) func TestGenerate_YAML(t *testing.T) { t.Parallel() req := &pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{{ Name: proto.String("file.proto"), Package: proto.String("example"), Options: &descriptorpb.FileOptions{ GoPackage: proto.String("goexample/v1;goexample"), }, }}, FileToGenerate: []string{ "file.proto", }, } resp := requireGenerate(t, req, genopenapi.FormatYAML, false, false) if len(resp) != 1 { t.Fatalf("invalid count, expected: 1, actual: %d", len(resp)) } var p map[string]interface{} err := yaml.Unmarshal([]byte(resp[0].GetContent()), &p) if err != nil { t.Fatalf("failed to unmarshall yaml: %s", err) } } func TestGenerateExtension(t *testing.T) { t.Parallel() const in = ` file_to_generate: "exampleproto/v1/example.proto" parameter: "output_format=yaml,allow_delete_body=true" proto_file: { name: "exampleproto/v1/example.proto" package: "example.v1" message_type: { name: "Foo" field: { name: "bar" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "bar" options: { [grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field]: { description: "This is bar" extensions: { key: "x-go-default" value: { string_value: "0.5s" } } } } } } service: { name: "TestService" method: { name: "Test" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/v1/test" } } } } options: { go_package: "exampleproto/v1;exampleproto" } }` var req pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal([]byte(in), &req); err != nil { t.Fatalf("failed to marshall yaml: %s", err) } formats := [...]genopenapi.Format{ genopenapi.FormatJSON, genopenapi.FormatYAML, } for _, format := range formats { format := format t.Run(string(format), func(t *testing.T) { t.Parallel() resp := requireGenerate(t, &req, format, false, false) if len(resp) != 1 { t.Fatalf("invalid count, expected: 1, actual: %d", len(resp)) } content := resp[0].GetContent() t.Log(content) if !strings.Contains(content, "x-go-default") { t.Fatal("x-go-default not found in content message") } }) } } func TestGenerateYAML(t *testing.T) { t.Parallel() tests := []struct { name string inputProtoText string wantYAML string }{ { // It tests https://github.com/grpc-ecosystem/grpc-gateway/issues/3557. name: "path item object", inputProtoText: "testdata/generator/path_item_object.prototext", wantYAML: "testdata/generator/path_item_object.swagger.yaml", }, } for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() b, err := os.ReadFile(tt.inputProtoText) if err != nil { t.Fatal(err) } var req pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal(b, &req); err != nil { t.Fatal(err) } resp := requireGenerate(t, &req, genopenapi.FormatYAML, false, true) if len(resp) != 1 { t.Fatalf("invalid count, expected: 1, actual: %d", len(resp)) } got := resp[0].GetContent() want, err := os.ReadFile(tt.wantYAML) if err != nil { t.Fatal(err) } diff := cmp.Diff(string(want), got) if diff != "" { t.Fatalf("content not match\n%s", diff) } }) } } func requireGenerate( tb testing.TB, req *pluginpb.CodeGeneratorRequest, format genopenapi.Format, preserveRPCOrder bool, allowMerge bool, ) []*descriptor.ResponseFile { tb.Helper() reg := descriptor.NewRegistry() reg.SetPreserveRPCOrder(preserveRPCOrder) reg.SetAllowMerge(allowMerge) if err := reg.Load(req); err != nil { tb.Fatalf("failed to load request: %s", err) } var targets []*descriptor.File for _, target := range req.FileToGenerate { f, err := reg.LookupFile(target) if err != nil { tb.Fatalf("failed to lookup file: %s", err) } targets = append(targets, f) } g := genopenapi.New(reg, format) resp, err := g.Generate(targets) switch { case err != nil: tb.Fatalf("failed to generate targets: %s", err) case len(resp) != len(targets) && !allowMerge: tb.Fatalf("invalid count, expected: %d, actual: %d", len(targets), len(resp)) } return resp } func TestGeneratedYAMLIndent(t *testing.T) { // It tests https://github.com/grpc-ecosystem/grpc-gateway/issues/2745. const in = ` file_to_generate: "exampleproto/v1/exampleproto.proto" parameter: "output_format=yaml,allow_delete_body=true" proto_file: { name: "exampleproto/v1/exampleproto.proto" package: "repro" message_type: { name: "RollupRequest" field: { name: "type" number: 1 label: LABEL_OPTIONAL type: TYPE_ENUM type_name: ".repro.RollupType" json_name: "type" } } message_type: { name: "RollupResponse" } enum_type: { name: "RollupType" value: { name: "UNKNOWN_ROLLUP" number: 0 } value: { name: "APPLE" number: 1 } value: { name: "BANANA" number: 2 } value: { name: "CARROT" number: 3 } } service: { name: "Repro" method: { name: "GetRollup" input_type: ".repro.RollupRequest" output_type: ".repro.RollupResponse" options: { [google.api.http]: { get: "/rollup" } } } } options: { go_package: "repro/foobar" } source_code_info: { location: { path: 5 path: 0 path: 2 path: 1 span: 24 span: 4 span: 14 leading_comments: " Apples are good\n" } location: { path: 5 path: 0 path: 2 path: 3 span: 28 span: 4 span: 15 leading_comments: " Carrots are mediocre\n" } } syntax: "proto3" } ` var req pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal([]byte(in), &req); err != nil { t.Fatalf("failed to marshall yaml: %s", err) } resp := requireGenerate(t, &req, genopenapi.FormatYAML, false, false) if len(resp) != 1 { t.Fatalf("invalid count, expected: 1, actual: %d", len(resp)) } content := resp[0].GetContent() err := yaml.Unmarshal([]byte(content), map[string]interface{}{}) if err != nil { t.Log(content) t.Fatalf("got invalid yaml: %s", err) } } func TestGenerateRPCOrderPreserved(t *testing.T) { t.Parallel() const in = ` file_to_generate: "exampleproto/v1/example.proto" parameter: "output_format=yaml,allow_delete_body=true" proto_file: { name: "exampleproto/v1/example.proto" package: "example.v1" message_type: { name: "Foo" field: { name: "bar" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "bar" } } service: { name: "TestService" method: { name: "Test1" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/b/first" } } } method: { name: "Test2" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/a/second" } } } method: { name: "Test3" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/c/third" } } } } options: { go_package: "exampleproto/v1;exampleproto" } }` var req pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal([]byte(in), &req); err != nil { t.Fatalf("failed to marshall yaml: %s", err) } formats := [...]genopenapi.Format{ genopenapi.FormatJSON, genopenapi.FormatYAML, } for _, format := range formats { format := format t.Run(string(format), func(t *testing.T) { t.Parallel() resp := requireGenerate(t, &req, format, true, false) if len(resp) != 1 { t.Fatalf("invalid count, expected: 1, actual: %d", len(resp)) } content := resp[0].GetContent() t.Log(content) contentsSlice := strings.Fields(content) expectedPaths := []string{"/b/first", "/a/second", "/c/third"} foundPaths := []string{} for _, contentValue := range contentsSlice { findExpectedPaths(&foundPaths, expectedPaths, contentValue) } if allPresent := reflect.DeepEqual(foundPaths, expectedPaths); !allPresent { t.Fatalf("Found paths differed from expected paths. Got: %#v, want %#v", foundPaths, expectedPaths) } }) } } func TestGenerateRPCOrderNotPreserved(t *testing.T) { t.Parallel() const in = ` file_to_generate: "exampleproto/v1/example.proto" parameter: "output_format=yaml,allow_delete_body=true" proto_file: { name: "exampleproto/v1/example.proto" package: "example.v1" message_type: { name: "Foo" field: { name: "bar" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "bar" } } service: { name: "TestService" method: { name: "Test1" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/b/first" } } } method: { name: "Test2" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/a/second" } } } method: { name: "Test3" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/c/third" } } } } options: { go_package: "exampleproto/v1;exampleproto" } }` var req pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal([]byte(in), &req); err != nil { t.Fatalf("failed to marshall yaml: %s", err) } formats := [...]genopenapi.Format{ genopenapi.FormatJSON, genopenapi.FormatYAML, } for _, format := range formats { format := format t.Run(string(format), func(t *testing.T) { t.Parallel() resp := requireGenerate(t, &req, format, false, false) if len(resp) != 1 { t.Fatalf("invalid count, expected: 1, actual: %d", len(resp)) } content := resp[0].GetContent() t.Log(content) contentsSlice := strings.Fields(content) expectedPaths := []string{"/a/second", "/b/first", "/c/third"} foundPaths := []string{} for _, contentValue := range contentsSlice { findExpectedPaths(&foundPaths, expectedPaths, contentValue) } if allPresent := reflect.DeepEqual(foundPaths, expectedPaths); !allPresent { t.Fatalf("Found paths differed from expected paths. Got: %#v, want %#v", foundPaths, expectedPaths) } }) } } func TestGenerateRPCOrderPreservedMultipleServices(t *testing.T) { t.Parallel() const in = ` file_to_generate: "exampleproto/v1/example.proto" parameter: "output_format=yaml,allow_delete_body=true" proto_file: { name: "exampleproto/v1/example.proto" package: "example.v1" message_type: { name: "Foo" field: { name: "bar" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "bar" } } service: { name: "TestServiceOne" method: { name: "Test1" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/d/first" } } } method: { name: "Test2" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/e/second" } } } method: { name: "Test3" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/c/third" } } } } service: { name: "TestServiceTwo" method: { name: "Test1" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/b/first" } } } method: { name: "Test2" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/a/second" } } } method: { name: "Test3" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/g/third" } } } } options: { go_package: "exampleproto/v1;exampleproto" } }` var req pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal([]byte(in), &req); err != nil { t.Fatalf("failed to marshall yaml: %s", err) } formats := [...]genopenapi.Format{ genopenapi.FormatJSON, genopenapi.FormatYAML, } for _, format := range formats { format := format t.Run(string(format), func(t *testing.T) { t.Parallel() resp := requireGenerate(t, &req, format, true, false) if len(resp) != 1 { t.Fatalf("invalid count, expected: 1, actual: %d", len(resp)) } content := resp[0].GetContent() t.Log(content) contentsSlice := strings.Fields(content) expectedPaths := []string{"/d/first", "/e/second", "/c/third", "/b/first", "/a/second", "/g/third"} foundPaths := []string{} for _, contentValue := range contentsSlice { findExpectedPaths(&foundPaths, expectedPaths, contentValue) } if allPresent := reflect.DeepEqual(foundPaths, expectedPaths); !allPresent { t.Fatalf("Found paths differed from expected paths. Got: %#v, want %#v", foundPaths, expectedPaths) } }) } } func TestGenerateRPCOrderNotPreservedMultipleServices(t *testing.T) { t.Parallel() const in = ` file_to_generate: "exampleproto/v1/example.proto" parameter: "output_format=yaml,allow_delete_body=true" proto_file: { name: "exampleproto/v1/example.proto" package: "example.v1" message_type: { name: "Foo" field: { name: "bar" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "bar" } } service: { name: "TestServiceOne" method: { name: "Test1" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/d/first" } } } method: { name: "Test2" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/e/second" } } } method: { name: "Test3" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/c/third" } } } } service: { name: "TestServiceTwo" method: { name: "Test1" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/b/first" } } } method: { name: "Test2" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/a/second" } } } method: { name: "Test3" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/g/third" } } } } options: { go_package: "exampleproto/v1;exampleproto" } }` var req pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal([]byte(in), &req); err != nil { t.Fatalf("failed to marshall yaml: %s", err) } formats := [...]genopenapi.Format{ genopenapi.FormatJSON, genopenapi.FormatYAML, } for _, format := range formats { format := format t.Run(string(format), func(t *testing.T) { t.Parallel() resp := requireGenerate(t, &req, format, false, false) if len(resp) != 1 { t.Fatalf("invalid count, expected: 1, actual: %d", len(resp)) } content := resp[0].GetContent() t.Log(content) contentsSlice := strings.Fields(content) expectedPaths := []string{"/d/first", "/e/second", "/c/third", "/b/first", "/a/second", "/g/third"} sort.Strings(expectedPaths) foundPaths := []string{} for _, contentValue := range contentsSlice { findExpectedPaths(&foundPaths, expectedPaths, contentValue) } if allPresent := reflect.DeepEqual(foundPaths, expectedPaths); !allPresent { t.Fatalf("Found paths differed from expected paths. Got: %#v, want %#v", foundPaths, expectedPaths) } }) } } func TestGenerateRPCOrderPreservedMergeFiles(t *testing.T) { t.Parallel() const in1 = ` file_to_generate: "exampleproto/v1/example.proto" parameter: "output_format=yaml,allow_delete_body=true" proto_file: { name: "exampleproto/v1/example.proto" package: "example.v1" message_type: { name: "Foo" field: { name: "bar" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "bar" } } service: { name: "TestService" method: { name: "Test1" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/c/cpath" } } } method: { name: "Test2" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/b/bpath" } } } method: { name: "Test3" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/a/apath" } } } } options: { go_package: "exampleproto/v1;exampleproto" } }` const in2 = ` file_to_generate: "exampleproto/v2/example.proto" parameter: "output_format=yaml,allow_delete_body=true" proto_file: { name: "exampleproto/v2/example.proto" package: "example.v2" message_type: { name: "Foo" field: { name: "bar" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "bar" } } service: { name: "TestService" method: { name: "Test1" input_type: ".example.v2.Foo" output_type: ".example.v2.Foo" options: { [google.api.http]: { get: "/f/fpath" } } } method: { name: "Test2" input_type: ".example.v2.Foo" output_type: ".example.v2.Foo" options: { [google.api.http]: { get: "/e/epath" } } } method: { name: "Test3" input_type: ".example.v2.Foo" output_type: ".example.v2.Foo" options: { [google.api.http]: { get: "/d/dpath" } } } } options: { go_package: "exampleproto/v2;exampleproto" } }` var req1, req2 pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal([]byte(in1), &req1); err != nil { t.Fatalf("failed to marshall yaml: %s", err) } if err := prototext.Unmarshal([]byte(in2), &req2); err != nil { t.Fatalf("failed to marshall yaml: %s", err) } req1.ProtoFile = append(req1.ProtoFile, req2.ProtoFile...) req1.FileToGenerate = append(req1.FileToGenerate, req2.FileToGenerate...) formats := [...]genopenapi.Format{ genopenapi.FormatJSON, genopenapi.FormatYAML, } for _, format := range formats { format := format t.Run(string(format), func(t *testing.T) { t.Parallel() resp := requireGenerate(t, &req1, format, true, true) if len(resp) != 1 { t.Fatalf("invalid count, expected: 1, actual: %d", len(resp)) } content := resp[0].GetContent() t.Log(content) contentsSlice := strings.Fields(content) expectedPaths := []string{"/c/cpath", "/b/bpath", "/a/apath", "/f/fpath", "/e/epath", "/d/dpath"} foundPaths := []string{} for _, contentValue := range contentsSlice { findExpectedPaths(&foundPaths, expectedPaths, contentValue) } if allPresent := reflect.DeepEqual(foundPaths, expectedPaths); !allPresent { t.Fatalf("Found paths differed from expected paths. Got: %#v, want %#v", foundPaths, expectedPaths) } }) } } func TestGenerateRPCOrderNotPreservedMergeFiles(t *testing.T) { t.Parallel() const in1 = ` file_to_generate: "exampleproto/v1/example.proto" parameter: "output_format=yaml,allow_delete_body=true" proto_file: { name: "exampleproto/v1/example.proto" package: "example.v1" message_type: { name: "Foo" field: { name: "bar" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "bar" } } service: { name: "TestService" method: { name: "Test1" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/c/cpath" } } } method: { name: "Test2" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/b/bpath" } } } method: { name: "Test3" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/a/apath" } } } } options: { go_package: "exampleproto/v1;exampleproto" } }` const in2 = ` file_to_generate: "exampleproto/v2/example.proto" parameter: "output_format=yaml,allow_delete_body=true" proto_file: { name: "exampleproto/v2/example.proto" package: "example.v2" message_type: { name: "Foo" field: { name: "bar" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "bar" } } service: { name: "TestService" method: { name: "Test1" input_type: ".example.v2.Foo" output_type: ".example.v2.Foo" options: { [google.api.http]: { get: "/f/fpath" } } } method: { name: "Test2" input_type: ".example.v2.Foo" output_type: ".example.v2.Foo" options: { [google.api.http]: { get: "/e/epath" } } } method: { name: "Test3" input_type: ".example.v2.Foo" output_type: ".example.v2.Foo" options: { [google.api.http]: { get: "/d/dpath" } } } } options: { go_package: "exampleproto/v2;exampleproto" } }` var req1, req2 pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal([]byte(in1), &req1); err != nil { t.Fatalf("failed to marshall yaml: %s", err) } if err := prototext.Unmarshal([]byte(in2), &req2); err != nil { t.Fatalf("failed to marshall yaml: %s", err) } req1.ProtoFile = append(req1.ProtoFile, req2.ProtoFile...) req1.FileToGenerate = append(req1.FileToGenerate, req2.FileToGenerate...) formats := [...]genopenapi.Format{ genopenapi.FormatJSON, genopenapi.FormatYAML, } for _, format := range formats { format := format t.Run(string(format), func(t *testing.T) { t.Parallel() resp := requireGenerate(t, &req1, format, false, true) if len(resp) != 1 { t.Fatalf("invalid count, expected: 1, actual: %d", len(resp)) } content := resp[0].GetContent() t.Log(content) contentsSlice := strings.Fields(content) expectedPaths := []string{"/c/cpath", "/b/bpath", "/a/apath", "/f/fpath", "/e/epath", "/d/dpath"} sort.Strings(expectedPaths) foundPaths := []string{} for _, contentValue := range contentsSlice { findExpectedPaths(&foundPaths, expectedPaths, contentValue) } if allPresent := reflect.DeepEqual(foundPaths, expectedPaths); !allPresent { t.Fatalf("Found paths differed from expected paths. Got: %#v, want %#v", foundPaths, expectedPaths) } }) } } func TestGenerateRPCOrderPreservedAdditionalBindings(t *testing.T) { t.Parallel() const in = ` file_to_generate: "exampleproto/v1/example.proto" parameter: "output_format=yaml,allow_delete_body=true" proto_file: { name: "exampleproto/v1/example.proto" package: "example.v1" message_type: { name: "Foo" field: { name: "bar" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "bar" } } service: { name: "TestService" method: { name: "Test1" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/b/first" additional_bindings { get: "/a/additional" } } } } method: { name: "Test2" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/a/second" additional_bindings { get: "/z/zAdditional" } } } } method: { name: "Test3" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/c/third" additional_bindings { get: "/b/bAdditional" } } } } } options: { go_package: "exampleproto/v1;exampleproto" } }` var req pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal([]byte(in), &req); err != nil { t.Fatalf("failed to marshall yaml: %s", err) } formats := [...]genopenapi.Format{ genopenapi.FormatJSON, genopenapi.FormatYAML, } for _, format := range formats { format := format t.Run(string(format), func(t *testing.T) { t.Parallel() resp := requireGenerate(t, &req, format, true, false) if len(resp) != 1 { t.Fatalf("invalid count, expected: 1, actual: %d", len(resp)) } content := resp[0].GetContent() t.Log(content) contentsSlice := strings.Fields(content) expectedPaths := []string{"/b/first", "/a/additional", "/a/second", "/z/zAdditional", "/c/third", "/b/bAdditional"} foundPaths := []string{} for _, contentValue := range contentsSlice { findExpectedPaths(&foundPaths, expectedPaths, contentValue) } if allPresent := reflect.DeepEqual(foundPaths, expectedPaths); !allPresent { t.Fatalf("Found paths differed from expected paths. Got: %#v, want %#v", foundPaths, expectedPaths) } }) } } func TestGenerateRPCOneOfFieldBodyAdditionalBindings(t *testing.T) { t.Parallel() const in = ` file_to_generate: "exampleproto/v1/example.proto" parameter: "output_format=yaml,allow_delete_body=true" proto_file: { name: "exampleproto/v1/example.proto" package: "example.v1" message_type: { name: "Foo" oneof_decl: { name: "foo" } field: { name: "bar" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "bar" oneof_index: 0 } field: { name: "baz" number: 2 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "bar" oneof_index: 0 } } service: { name: "TestService" method: { name: "Test1" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { post: "/b/foo" body: "*" additional_bindings { post: "/b/foo/bar" body: "bar" } additional_bindings { post: "/b/foo/baz" body: "baz" } } } } } options: { go_package: "exampleproto/v1;exampleproto" } }` var req pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal([]byte(in), &req); err != nil { t.Fatalf("failed to marshall yaml: %s", err) } formats := [...]genopenapi.Format{ genopenapi.FormatJSON, genopenapi.FormatYAML, } for _, format := range formats { format := format t.Run(string(format), func(t *testing.T) { t.Parallel() resp := requireGenerate(t, &req, format, true, false) if len(resp) != 1 { t.Fatalf("invalid count, expected: 1, actual: %d", len(resp)) } content := resp[0].GetContent() t.Log(content) contentsSlice := strings.Fields(content) expectedPaths := []string{"/b/foo", "/b/foo/bar", "/b/foo/baz"} foundPaths := []string{} for _, contentValue := range contentsSlice { findExpectedPaths(&foundPaths, expectedPaths, contentValue) } if allPresent := reflect.DeepEqual(foundPaths, expectedPaths); !allPresent { t.Fatalf("Found paths differed from expected paths. Got: %#v, want %#v", foundPaths, expectedPaths) } // The input message only contains oneof fields, so no other fields should be mapped to the query. if strings.Contains(content, "query") { t.Fatalf("Found query in content, expected not to find any") } }) } } func TestGenerateRPCOrderNotPreservedAdditionalBindings(t *testing.T) { t.Parallel() const in = ` file_to_generate: "exampleproto/v1/example.proto" parameter: "output_format=yaml,allow_delete_body=true" proto_file: { name: "exampleproto/v1/example.proto" package: "example.v1" message_type: { name: "Foo" field: { name: "bar" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "bar" } } service: { name: "TestService" method: { name: "Test1" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/b/first" additional_bindings { get: "/a/additional" } } } } method: { name: "Test2" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/a/second" additional_bindings { get: "/z/zAdditional" } } } } method: { name: "Test3" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/c/third" additional_bindings { get: "/b/bAdditional" } } } } } options: { go_package: "exampleproto/v1;exampleproto" } }` var req pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal([]byte(in), &req); err != nil { t.Fatalf("failed to marshall yaml: %s", err) } formats := [...]genopenapi.Format{ genopenapi.FormatJSON, genopenapi.FormatYAML, } for _, format := range formats { format := format t.Run(string(format), func(t *testing.T) { t.Parallel() resp := requireGenerate(t, &req, format, false, false) if len(resp) != 1 { t.Fatalf("invalid count, expected: 1, actual: %d", len(resp)) } content := resp[0].GetContent() t.Log(content) contentsSlice := strings.Fields(content) expectedPaths := []string{"/b/first", "/a/additional", "/a/second", "/z/zAdditional", "/c/third", "/b/bAdditional"} sort.Strings(expectedPaths) foundPaths := []string{} for _, contentValue := range contentsSlice { findExpectedPaths(&foundPaths, expectedPaths, contentValue) } if allPresent := reflect.DeepEqual(foundPaths, expectedPaths); !allPresent { t.Fatalf("Found paths differed from expected paths. Got: %#v, want %#v", foundPaths, expectedPaths) } }) } } func TestGenerateRPCOrderPreservedMergeFilesAdditionalBindingsMultipleServices(t *testing.T) { t.Parallel() const in1 = ` file_to_generate: "exampleproto/v1/example.proto" parameter: "output_format=yaml,allow_delete_body=true" proto_file: { name: "exampleproto/v1/example.proto" package: "example.v1" message_type: { name: "Foo" field: { name: "bar" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "bar" } } service: { name: "TestServiceOne" method: { name: "Test1" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/d/first" } } } method: { name: "Test2" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/e/second" } } } method: { name: "Test3" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/c/third" } } } } service: { name: "TestServiceTwo" method: { name: "Test1" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/b/first" } } } method: { name: "Test2" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/a/second" } } } method: { name: "Test3" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/g/third" } } } } options: { go_package: "exampleproto/v1;exampleproto" } }` const in2 = ` file_to_generate: "exampleproto/v2/example.proto" parameter: "output_format=yaml,allow_delete_body=true" proto_file: { name: "exampleproto/v2/example.proto" package: "example.v2" message_type: { name: "Foo" field: { name: "bar" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "bar" } } service: { name: "TestService" method: { name: "Test1" input_type: ".example.v2.Foo" output_type: ".example.v2.Foo" options: { [google.api.http]: { get: "/b/bpath" additional_bindings { get: "/a/additional" } } } } method: { name: "Test2" input_type: ".example.v2.Foo" output_type: ".example.v2.Foo" options: { [google.api.http]: { get: "/a/apath" additional_bindings { get: "/z/zAdditional" } } } } method: { name: "Test3" input_type: ".example.v2.Foo" output_type: ".example.v2.Foo" options: { [google.api.http]: { get: "/c/cpath" additional_bindings { get: "/b/bAdditional" } } } } } options: { go_package: "exampleproto/v2;exampleproto" } }` var req1, req2 pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal([]byte(in1), &req1); err != nil { t.Fatalf("failed to marshall yaml: %s", err) } if err := prototext.Unmarshal([]byte(in2), &req2); err != nil { t.Fatalf("failed to marshall yaml: %s", err) } req1.ProtoFile = append(req1.ProtoFile, req2.ProtoFile...) req1.FileToGenerate = append(req1.FileToGenerate, req2.FileToGenerate...) formats := [...]genopenapi.Format{ genopenapi.FormatJSON, genopenapi.FormatYAML, } for _, format := range formats { format := format t.Run(string(format), func(t *testing.T) { t.Parallel() resp := requireGenerate(t, &req1, format, true, true) if len(resp) != 1 { t.Fatalf("invalid count, expected: 1, actual: %d", len(resp)) } content := resp[0].GetContent() t.Log(content) contentsSlice := strings.Fields(content) expectedPaths := []string{"/d/first", "/e/second", "/c/third", "/b/first", "/a/second", "/g/third", "/b/bpath", "/a/additional", "/a/apath", "/z/zAdditional", "/c/cpath", "/b/bAdditional"} foundPaths := []string{} for _, contentValue := range contentsSlice { findExpectedPaths(&foundPaths, expectedPaths, contentValue) } if allPresent := reflect.DeepEqual(foundPaths, expectedPaths); !allPresent { t.Fatalf("Found paths differed from expected paths. Got: %#v, want %#v", foundPaths, expectedPaths) } }) } } func TestGenerateRPCOrderNotPreservedMergeFilesAdditionalBindingsMultipleServices(t *testing.T) { t.Parallel() const in1 = ` file_to_generate: "exampleproto/v1/example.proto" parameter: "output_format=yaml,allow_delete_body=true" proto_file: { name: "exampleproto/v1/example.proto" package: "example.v1" message_type: { name: "Foo" field: { name: "bar" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "bar" } } service: { name: "TestServiceOne" method: { name: "Test1" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/d/first" } } } method: { name: "Test2" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/e/second" } } } method: { name: "Test3" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/c/third" } } } } service: { name: "TestServiceTwo" method: { name: "Test1" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/b/first" } } } method: { name: "Test2" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/a/second" } } } method: { name: "Test3" input_type: ".example.v1.Foo" output_type: ".example.v1.Foo" options: { [google.api.http]: { get: "/g/third" } } } } options: { go_package: "exampleproto/v1;exampleproto" } }` const in2 = ` file_to_generate: "exampleproto/v2/example.proto" parameter: "output_format=yaml,allow_delete_body=true" proto_file: { name: "exampleproto/v2/example.proto" package: "example.v2" message_type: { name: "Foo" field: { name: "bar" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "bar" } } service: { name: "TestService" method: { name: "Test1" input_type: ".example.v2.Foo" output_type: ".example.v2.Foo" options: { [google.api.http]: { get: "/b/bpath" additional_bindings { get: "/a/additional" } } } } method: { name: "Test2" input_type: ".example.v2.Foo" output_type: ".example.v2.Foo" options: { [google.api.http]: { get: "/a/apath" additional_bindings { get: "/z/zAdditional" } } } } method: { name: "Test3" input_type: ".example.v2.Foo" output_type: ".example.v2.Foo" options: { [google.api.http]: { get: "/c/cpath" additional_bindings { get: "/b/bAdditional" } } } } } options: { go_package: "exampleproto/v2;exampleproto" } }` var req1, req2 pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal([]byte(in1), &req1); err != nil { t.Fatalf("failed to marshall yaml: %s", err) } if err := prototext.Unmarshal([]byte(in2), &req2); err != nil { t.Fatalf("failed to marshall yaml: %s", err) } req1.ProtoFile = append(req1.ProtoFile, req2.ProtoFile...) req1.FileToGenerate = append(req1.FileToGenerate, req2.FileToGenerate...) formats := [...]genopenapi.Format{ genopenapi.FormatJSON, genopenapi.FormatYAML, } for _, format := range formats { format := format t.Run(string(format), func(t *testing.T) { t.Parallel() resp := requireGenerate(t, &req1, format, false, true) if len(resp) != 1 { t.Fatalf("invalid count, expected: 1, actual: %d", len(resp)) } content := resp[0].GetContent() t.Log(content) contentsSlice := strings.Fields(content) expectedPaths := []string{"/d/first", "/e/second", "/c/third", "/b/first", "/a/second", "/g/third", "/b/bpath", "/a/additional", "/a/apath", "/z/zAdditional", "/c/cpath", "/b/bAdditional"} sort.Strings(expectedPaths) foundPaths := []string{} for _, contentValue := range contentsSlice { findExpectedPaths(&foundPaths, expectedPaths, contentValue) } if allPresent := reflect.DeepEqual(foundPaths, expectedPaths); !allPresent { t.Fatalf("Found paths differed from expected paths. Got: %#v, want %#v", foundPaths, expectedPaths) } }) } } // Tries to find expected paths from a provided substring and store them in the foundPaths // slice. func findExpectedPaths(foundPaths *[]string, expectedPaths []string, potentialPath string) { seenPaths := map[string]struct{}{} // foundPaths may not be empty when this function is called multiple times, // so we add them to seenPaths map to avoid duplicates. for _, path := range *foundPaths { seenPaths[path] = struct{}{} } for _, path := range expectedPaths { _, pathAlreadySeen := seenPaths[path] if strings.Contains(potentialPath, path) && !pathAlreadySeen { *foundPaths = append(*foundPaths, path) seenPaths[path] = struct{}{} } } } func TestFindExpectedPaths(t *testing.T) { t.Parallel() testCases := [...]struct { testName string requiredPaths []string potentialPath string expectedPathsFound []string }{ { testName: "One potential path present", requiredPaths: []string{"/d/first", "/e/second", "/c/third", "/b/first"}, potentialPath: "[{\"path: \"/d/first\"", expectedPathsFound: []string{"/d/first"}, }, { testName: "No potential Paths present", requiredPaths: []string{"/d/first", "/e/second", "/c/third", "/b/first"}, potentialPath: "[{\"path: \"/z/zpath\"", expectedPathsFound: []string{}, }, { testName: "Multiple potential paths present", requiredPaths: []string{"/d/first", "/e/second", "/c/third", "/b/first", "/d/first"}, potentialPath: "[{\"path: \"/d/first\"someData\"/c/third\"someData\"/b/third\"", expectedPathsFound: []string{"/d/first", "/c/third"}, }, } for _, tc := range testCases { tc := tc t.Run(tc.testName, func(t *testing.T) { t.Parallel() foundPaths := []string{} findExpectedPaths(&foundPaths, tc.requiredPaths, tc.potentialPath) if correctPathsFound := reflect.DeepEqual(foundPaths, tc.expectedPathsFound); !correctPathsFound { t.Fatalf("Found paths differed from expected paths. Got: %#v, want %#v", foundPaths, tc.expectedPathsFound) } }) } } func TestGenerateXGoType(t *testing.T) { t.Parallel() tests := []struct { name string inputProtoText string wantYAML string }{ { name: "x-go-type extension", inputProtoText: "testdata/generator/x_go_type.prototext", wantYAML: "testdata/generator/x_go_type.swagger.yaml", }, } for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() b, err := os.ReadFile(tt.inputProtoText) if err != nil { t.Fatal(err) } var req pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal(b, &req); err != nil { t.Fatal(err) } reg := descriptor.NewRegistry() reg.SetGenerateXGoType(true) if err := reg.Load(&req); err != nil { t.Fatalf("failed to load request: %s", err) } var targets []*descriptor.File for _, target := range req.FileToGenerate { f, err := reg.LookupFile(target) if err != nil { t.Fatalf("failed to lookup file: %s", err) } targets = append(targets, f) } g := genopenapi.New(reg, genopenapi.FormatYAML) resp, err := g.Generate(targets) if err != nil { t.Fatalf("failed to generate: %s", err) } if len(resp) != 1 { t.Fatalf("expected 1 file, got %d", len(resp)) } want, err := os.ReadFile(tt.wantYAML) if err != nil { t.Fatal(err) } var gotMap, wantMap map[string]interface{} if err := yaml.Unmarshal([]byte(resp[0].GetContent()), &gotMap); err != nil { t.Fatalf("failed to unmarshal generated YAML: %v", err) } if err := yaml.Unmarshal(want, &wantMap); err != nil { t.Fatalf("failed to unmarshal expected YAML: %v", err) } gotYAML, err := yaml.Marshal(gotMap) if err != nil { t.Fatalf("failed to marshal got YAML: %v", err) } wantYAML, err := yaml.Marshal(wantMap) if err != nil { t.Fatalf("failed to marshal want YAML: %v", err) } if !bytes.Equal(gotYAML, wantYAML) { t.Errorf("YAMLs don't match:\ngot:\n%s\nwant:\n%s", gotYAML, wantYAML) } }) } } // TestIssue5684_UnusedMethodsNotInOpenAPI tests that methods without HTTP bindings // do not appear in the OpenAPI definitions. // See https://github.com/grpc-ecosystem/grpc-gateway/issues/5684 func TestIssue5684_UnusedMethodsNotInOpenAPI(t *testing.T) { t.Parallel() // Create a proto definition similar to the issue report: // - Service with two methods: Add (no HTTP binding) and Show (with HTTP binding) // - Only Show should appear in the OpenAPI output // - AddRequest and AddResponse should NOT appear in definitions const in = ` file_to_generate: "account/account.proto" proto_file: { name: "account/account.proto" package: "account" message_type: { name: "Money" field: { name: "amount" number: 1 label: LABEL_OPTIONAL type: TYPE_INT64 json_name: "amount" } } message_type: { name: "AddRequest" field: { name: "money" number: 1 label: LABEL_OPTIONAL type: TYPE_MESSAGE type_name: ".account.Money" json_name: "money" } } message_type: { name: "AddResponse" } message_type: { name: "ShowRequest" } message_type: { name: "ShowResponse" field: { name: "money" number: 1 label: LABEL_OPTIONAL type: TYPE_MESSAGE type_name: ".account.Money" json_name: "money" } } service: { name: "AccountService" method: { name: "Add" input_type: ".account.AddRequest" output_type: ".account.AddResponse" } method: { name: "Show" input_type: ".account.ShowRequest" output_type: ".account.ShowResponse" options: { [google.api.http]: { get: "/v1/account" } } } } options: { go_package: "accounts/pkg/account;account" } }` var req pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal([]byte(in), &req); err != nil { t.Fatalf("failed to unmarshal proto: %v", err) } resp := requireGenerate(t, &req, genopenapi.FormatYAML, false, false) if len(resp) != 1 { t.Fatalf("invalid count, expected: 1, actual: %d", len(resp)) } var openAPIDoc map[string]interface{} if err := yaml.Unmarshal([]byte(resp[0].GetContent()), &openAPIDoc); err != nil { t.Fatalf("failed to parse OpenAPI YAML: %v", err) } definitions, ok := openAPIDoc["definitions"].(map[string]interface{}) if !ok { t.Fatalf("no definitions found in OpenAPI document") } if _, exists := definitions["accountAddRequest"]; exists { t.Error("accountAddRequest found in definitions, but should be excluded (Add method has no HTTP binding)") } if _, exists := definitions["accountAddResponse"]; exists { t.Error("accountAddResponse found in definitions, but should be excluded (Add method has no HTTP binding)") } if _, exists := definitions["accountShowResponse"]; !exists { t.Error("accountShowResponse not found in definitions, but should be included (Show method has HTTP binding)") } if _, exists := definitions["accountMoney"]; !exists { t.Error("accountMoney not found in definitions, but should be included (referenced by ShowResponse)") } paths, ok := openAPIDoc["paths"].(map[string]interface{}) if !ok { t.Fatalf("no paths found in OpenAPI document") } if _, exists := paths["/v1/account"]; !exists { t.Error("/v1/account path not found, but should be included (Show method)") } if len(paths) != 1 { t.Errorf("expected exactly 1 path, got %d paths", len(paths)) } } // TestGenerateMergeFilesWithBodyAndPathParams tests issue #6274: // When processing multiple proto files where one file has messages (no services) // and another has services with body:"*" and path params, the generator should // not panic when looking up method FQNs for body definitions. func TestGenerateMergeFilesWithBodyAndPathParams(t *testing.T) { t.Parallel() // File 1: messages.proto - defines messages but no services const messagesProto = ` file_to_generate: "example/messages.proto" proto_file: { name: "example/messages.proto" package: "example" message_type: { name: "Item" field: { name: "id" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "id" } field: { name: "name" number: 2 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "name" } } message_type: { name: "CreateItemRequest" field: { name: "parent" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "parent" } field: { name: "item" number: 2 label: LABEL_OPTIONAL type: TYPE_MESSAGE type_name: ".example.Item" json_name: "item" } } message_type: { name: "CreateItemResponse" field: { name: "item" number: 1 label: LABEL_OPTIONAL type: TYPE_MESSAGE type_name: ".example.Item" json_name: "item" } } options: { go_package: "github.com/example/v1;example" } }` // File 2: service.proto - defines a service with body:"*" and path params const serviceProto = ` file_to_generate: "example/service.proto" proto_file: { name: "example/service.proto" package: "example" dependency: "example/messages.proto" service: { name: "ItemService" method: { name: "CreateItem" input_type: ".example.CreateItemRequest" output_type: ".example.CreateItemResponse" options: { [google.api.http]: { post: "/v1/{parent=projects/*}/items" body: "*" } } } } options: { go_package: "github.com/example/v1;example" } }` var req1, req2 pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal([]byte(messagesProto), &req1); err != nil { t.Fatalf("failed to unmarshal messages proto: %s", err) } if err := prototext.Unmarshal([]byte(serviceProto), &req2); err != nil { t.Fatalf("failed to unmarshal service proto: %s", err) } // Combine into a single request with both files as targets req1.ProtoFile = append(req1.ProtoFile, req2.ProtoFile...) req1.FileToGenerate = append(req1.FileToGenerate, req2.FileToGenerate...) // This should not panic - the bug was that processing messages.proto first // would build a cache without method FQNs, causing service.proto to panic // when looking up method FQNs for body:"*" with path params. resp := requireGenerate(t, &req1, genopenapi.FormatJSON, false, false) // We expect 2 files (one per proto file) if len(resp) != 2 { t.Fatalf("expected 2 response files, got %d", len(resp)) } // Verify the service file has the expected structure var foundService bool for _, r := range resp { if strings.Contains(r.GetName(), "service") { foundService = true content := r.GetContent() // Verify the body definition was created if !strings.Contains(content, "ItemServiceCreateItemBody") { t.Errorf("expected ItemServiceCreateItemBody definition, not found in output:\n%s", content) } } } if !foundService { t.Error("service.proto output not found in response") } } // requireGenerateWithNamingStrategy is a helper that allows setting the naming strategy func requireGenerateWithNamingStrategy( tb testing.TB, req *pluginpb.CodeGeneratorRequest, format genopenapi.Format, preserveRPCOrder bool, allowMerge bool, namingStrategy string, ) []*descriptor.ResponseFile { tb.Helper() reg := descriptor.NewRegistry() reg.SetPreserveRPCOrder(preserveRPCOrder) reg.SetAllowMerge(allowMerge) reg.SetOpenAPINamingStrategy(namingStrategy) if err := reg.Load(req); err != nil { tb.Fatalf("failed to load request: %s", err) } var targets []*descriptor.File for _, target := range req.FileToGenerate { f, err := reg.LookupFile(target) if err != nil { tb.Fatalf("failed to lookup file: %s", err) } targets = append(targets, f) } g := genopenapi.New(reg, format) resp, err := g.Generate(targets) switch { case err != nil: tb.Fatalf("failed to generate targets: %s", err) case len(resp) != len(targets) && !allowMerge: tb.Fatalf("invalid count, expected: %d, actual: %d", len(targets), len(resp)) } return resp } // TestGenerateMultiFileNamingConsistency tests issue #6308: // When using simple naming strategy with multiple files, $refs and definitions // must use consistent names. Previously, renderServices() would use one cache // while renderMessagesAsDefinition() would use a different filtered cache, // causing $ref mismatches. func TestGenerateMultiFileNamingConsistency(t *testing.T) { t.Parallel() // File 1: types.proto - has a nested Status enum that could collide with google.rpc.Status const typesProto = ` file_to_generate: "myapi/types.proto" proto_file: { name: "myapi/types.proto" package: "myapi" message_type: { name: "Operation" field: { name: "status" number: 1 label: LABEL_OPTIONAL type: TYPE_ENUM type_name: ".myapi.Operation.Status" json_name: "status" } enum_type: { name: "Status" value: { name: "UNKNOWN" number: 0 } value: { name: "RUNNING" number: 1 } value: { name: "COMPLETED" number: 2 } } } message_type: { name: "GetOperationRequest" field: { name: "name" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "name" } } service: { name: "OperationService" method: { name: "GetOperation" input_type: ".myapi.GetOperationRequest" output_type: ".myapi.Operation" options: { [google.api.http]: { get: "/v1/operations/{name}" } } } } options: { go_package: "github.com/myapi/v1;myapi" } }` // File 2: service.proto - references google.rpc.Status via default error responses // but does NOT use Operation.Status const serviceProto = ` file_to_generate: "myapi/service.proto" proto_file: { name: "myapi/service.proto" package: "myapi" message_type: { name: "EchoRequest" field: { name: "message" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "message" } } message_type: { name: "EchoResponse" field: { name: "message" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "message" } } service: { name: "EchoService" method: { name: "Echo" input_type: ".myapi.EchoRequest" output_type: ".myapi.EchoResponse" options: { [google.api.http]: { post: "/v1/echo" body: "*" } } } } options: { go_package: "github.com/myapi/v1;myapi" } }` var req1, req2 pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal([]byte(typesProto), &req1); err != nil { t.Fatalf("failed to unmarshal types proto: %s", err) } if err := prototext.Unmarshal([]byte(serviceProto), &req2); err != nil { t.Fatalf("failed to unmarshal service proto: %s", err) } // Combine into single request, processing types.proto first req1.ProtoFile = append(req1.ProtoFile, req2.ProtoFile...) req1.FileToGenerate = append(req1.FileToGenerate, req2.FileToGenerate...) // Use "simple" naming strategy which is most likely to produce collisions resp := requireGenerateWithNamingStrategy(t, &req1, genopenapi.FormatJSON, false, false, "simple") if len(resp) != 2 { t.Fatalf("expected 2 response files, got %d", len(resp)) } // For each output file, verify that all $refs have matching definitions for _, r := range resp { content := r.GetContent() // Parse the JSON to verify $ref consistency var doc map[string]interface{} if err := yaml.Unmarshal([]byte(content), &doc); err != nil { t.Fatalf("failed to parse OpenAPI JSON for %s: %v", r.GetName(), err) } definitions, ok := doc["definitions"].(map[string]interface{}) if !ok { // No definitions is acceptable for some files continue } // Collect all $refs from the document refs := collectRefs(doc) // Verify each $ref has a matching definition for ref := range refs { // Extract definition name from $ref (format: "#/definitions/Name") if !strings.HasPrefix(ref, "#/definitions/") { continue } defName := strings.TrimPrefix(ref, "#/definitions/") if _, exists := definitions[defName]; !exists { t.Errorf("file %s: $ref %q has no matching definition. Available definitions: %v", r.GetName(), ref, getKeys(definitions)) } } } } // collectRefs recursively collects all $ref values from a document func collectRefs(v interface{}) map[string]bool { refs := make(map[string]bool) collectRefsRecursive(v, refs) return refs } func collectRefsRecursive(v interface{}, refs map[string]bool) { switch val := v.(type) { case map[string]interface{}: if ref, ok := val["$ref"].(string); ok { refs[ref] = true } for _, child := range val { collectRefsRecursive(child, refs) } case []interface{}: for _, item := range val { collectRefsRecursive(item, refs) } } } func getKeys(m map[string]interface{}) []string { keys := make([]string, 0, len(m)) for k := range m { keys = append(keys, k) } sort.Strings(keys) return keys } // TestGenerateEnumInNestedMessageMultiComponentPackage tests issue #6366: // When a service method returns a message that contains another message with an // enum field, and the package has multiple components (e.g. "example.v1"), // protoc-gen-openapiv2 panicked with "can't resolve OpenAPI ref from typename". // This was caused by two bugs in PR #6315: // 1. collectReferencedNamesForCache pre-populated all message FQMNs before scanning // services, causing collectNestedTypeFQNs to short-circuit on already-visited // entries and miss nested enum types. // 2. The package filter compared only the first dot-component against the full // multi-component package name, so it never matched. func TestGenerateEnumInNestedMessageMultiComponentPackage(t *testing.T) { t.Parallel() // Single file with multi-component package "example.v1": // service Do(DoRequest) returns (DoResponse) // DoResponse has field "what" of type What // What has field "type" of enum EventType const protoText = ` file_to_generate: "example/v1/example.proto" proto_file: { name: "example/v1/example.proto" package: "example.v1" message_type: { name: "DoRequest" } message_type: { name: "DoResponse" field: { name: "what" number: 1 label: LABEL_OPTIONAL type: TYPE_MESSAGE type_name: ".example.v1.What" json_name: "what" } } message_type: { name: "What" field: { name: "type" number: 1 label: LABEL_OPTIONAL type: TYPE_ENUM type_name: ".example.v1.EventType" json_name: "type" } } enum_type: { name: "EventType" value: { name: "EVENT_TYPE_UNSPECIFIED" number: 0 } value: { name: "EVENT_TYPE_ONE" number: 1 } } service: { name: "ExampleService" method: { name: "Do" input_type: ".example.v1.DoRequest" output_type: ".example.v1.DoResponse" options: { [google.api.http]: { post: "/v1/do" body: "*" } } } } options: { go_package: "github.com/example/v1;example" } }` var req pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal([]byte(protoText), &req); err != nil { t.Fatalf("failed to unmarshal proto: %s", err) } // This should not panic. Before the fix, it panicked with: // "can't resolve OpenAPI ref from typename .example.v1.EventType" resp := requireGenerate(t, &req, genopenapi.FormatJSON, false, false) if len(resp) != 1 { t.Fatalf("expected 1 response file, got %d", len(resp)) } content := resp[0].GetContent() var doc map[string]interface{} if err := yaml.Unmarshal([]byte(content), &doc); err != nil { t.Fatalf("failed to parse OpenAPI JSON: %v", err) } definitions, ok := doc["definitions"].(map[string]interface{}) if !ok { t.Fatal("expected definitions in OpenAPI output") } // Verify all $refs resolve to existing definitions refs := collectRefs(doc) for ref := range refs { if !strings.HasPrefix(ref, "#/definitions/") { continue } defName := strings.TrimPrefix(ref, "#/definitions/") if _, exists := definitions[defName]; !exists { t.Errorf("$ref %q has no matching definition. Available definitions: %v", ref, getKeys(definitions)) } } } // TestGenerateCrossPackageMessageReference tests a scenario related to #6366: // When a message in the current file references a message type from a different // proto package, the cross-package type must be included in the naming cache. // Without this, renderMessagesAsDefinition panics because it renders all // messages from the file but the naming cache only contains types reachable // from service method request/response types. func TestGenerateCrossPackageMessageReference(t *testing.T) { t.Parallel() // File 1: user.proto defines User in package domains.user.v1 // File 2: usercontrol.proto has a service and a message referencing User const userProto = ` file_to_generate: "domains/user/v1/user.proto" proto_file: { name: "domains/user/v1/user.proto" package: "domains.user.v1" message_type: { name: "User" field: { name: "name" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "name" } } options: { go_package: "github.com/example/domains/user/v1;user" } }` const usercontrolProto = ` file_to_generate: "usercontrol/v1/usercontrol.proto" proto_file: { name: "usercontrol/v1/usercontrol.proto" package: "usercontrol.v1" dependency: "domains/user/v1/user.proto" message_type: { name: "ListUsersRequest" } message_type: { name: "ListUsersResponse" field: { name: "users" number: 1 label: LABEL_REPEATED type: TYPE_MESSAGE type_name: ".domains.user.v1.User" json_name: "users" } } service: { name: "UserControlService" method: { name: "ListUsers" input_type: ".usercontrol.v1.ListUsersRequest" output_type: ".usercontrol.v1.ListUsersResponse" options: { [google.api.http]: { get: "/v1/users" } } } } options: { go_package: "github.com/example/usercontrol/v1;usercontrol" } }` var req1, req2 pluginpb.CodeGeneratorRequest if err := prototext.Unmarshal([]byte(userProto), &req1); err != nil { t.Fatalf("failed to unmarshal user proto: %s", err) } if err := prototext.Unmarshal([]byte(usercontrolProto), &req2); err != nil { t.Fatalf("failed to unmarshal usercontrol proto: %s", err) } // Combine: process both files, but only generate usercontrol req2.ProtoFile = append(req1.ProtoFile, req2.ProtoFile...) req2.FileToGenerate = []string{"usercontrol/v1/usercontrol.proto"} // This should not panic resp := requireGenerate(t, &req2, genopenapi.FormatJSON, false, false) if len(resp) != 1 { t.Fatalf("expected 1 response file, got %d", len(resp)) } var doc map[string]interface{} if err := yaml.Unmarshal([]byte(resp[0].GetContent()), &doc); err != nil { t.Fatalf("failed to parse OpenAPI JSON: %v", err) } definitions, ok := doc["definitions"].(map[string]interface{}) if !ok { t.Fatal("expected definitions in OpenAPI output") } refs := collectRefs(doc) for ref := range refs { if !strings.HasPrefix(ref, "#/definitions/") { continue } defName := strings.TrimPrefix(ref, "#/definitions/") if _, exists := definitions[defName]; !exists { t.Errorf("$ref %q has no matching definition. Available definitions: %v", ref, getKeys(definitions)) } } } ================================================ FILE: protoc-gen-openapiv2/internal/genopenapi/helpers.go ================================================ //go:build go1.12 // +build go1.12 package genopenapi import ( "strings" "golang.org/x/text/cases" "golang.org/x/text/language" ) func fieldName(k string) string { return strings.ReplaceAll(cases.Title(language.AmericanEnglish).String(k), "-", "_") } // this method will filter the same fields and return the unique one func getUniqueFields(schemaFieldsRequired []string, fieldsRequired []string) []string { var unique []string var index *int for j, schemaFieldRequired := range schemaFieldsRequired { index = nil for i, fieldRequired := range fieldsRequired { i := i if schemaFieldRequired == fieldRequired { index = &i break } } if index == nil { unique = append(unique, schemaFieldsRequired[j]) } } return unique } ================================================ FILE: protoc-gen-openapiv2/internal/genopenapi/helpers_go111_old.go ================================================ //go:build !go1.12 // +build !go1.12 package genopenapi import "strings" func fieldName(k string) string { return strings.Replace(strings.Title(k), "-", "_", -1) } ================================================ FILE: protoc-gen-openapiv2/internal/genopenapi/helpers_test.go ================================================ package genopenapi import ( "reflect" "testing" ) func Test_getUniqueFields(t *testing.T) { type args struct { schemaFieldsRequired []string fieldsRequired []string } var tests = []struct { name string args args want []string }{ { name: "test_1", args: args{ schemaFieldsRequired: []string{"Field_1", "Field_2", "Field_3"}, fieldsRequired: []string{"Field_2"}, }, want: []string{"Field_1", "Field_3"}, }, { name: "test_2", args: args{ schemaFieldsRequired: []string{"Field_1", "Field_2", "Field_3"}, fieldsRequired: []string{"Field_3"}, }, want: []string{"Field_1", "Field_2"}, }, { name: "test_3", args: args{ schemaFieldsRequired: []string{"Field_1", "Field_2", "Field_3"}, fieldsRequired: []string{"Field_4"}, }, want: []string{"Field_1", "Field_2", "Field_3"}, }, { name: "test_4", args: args{ schemaFieldsRequired: []string{"Field_1", "Field_2", "Field_3", "Field_4", "Field_5", "Field_6"}, fieldsRequired: []string{"Field_6", "Field_4", "Field_1"}, }, want: []string{"Field_2", "Field_3", "Field_5"}, }, { name: "test_5", args: args{ schemaFieldsRequired: []string{"Field_1", "Field_2", "Field_3"}, fieldsRequired: []string{}, }, want: []string{"Field_1", "Field_2", "Field_3"}, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := getUniqueFields(tt.args.schemaFieldsRequired, tt.args.fieldsRequired); !reflect.DeepEqual(got, tt.want) { t.Errorf("getUniqueFields() = %v, want %v", got, tt.want) } }) } } ================================================ FILE: protoc-gen-openapiv2/internal/genopenapi/naming.go ================================================ package genopenapi import ( "reflect" "regexp" "strings" ) // LookupNamingStrategy looks up the given naming strategy and returns the naming // strategy function for it. The naming strategy function takes in the list of all // fully-qualified proto message names, and returns a mapping from fully-qualified // name to OpenAPI name. func LookupNamingStrategy(strategyName string) func([]string) map[string]string { switch strings.ToLower(strategyName) { case "fqn": return resolveNamesFQN case "legacy": return resolveNamesLegacy case "simple": return resolveNamesSimple case "package": return resolveNamesPackage } return nil } // resolveNamesFQN uses the fully-qualified proto message name as the // OpenAPI name, stripping the leading dot. func resolveNamesFQN(messages []string) map[string]string { uniqueNames := make(map[string]string, len(messages)) for _, p := range messages { // strip leading dot from proto fqn uniqueNames[p] = p[1:] } return uniqueNames } // resolveNamesLegacy takes the names of all proto messages and generates unique references by // applying the legacy heuristics for deriving unique names: starting from the bottom of the name hierarchy, it // determines the minimum number of components necessary to yield a unique name, adds one // to that number, and then concatenates those last components with no separator in between // to form a unique name. // // E.g., if the fully qualified name is `.a.b.C.D`, and there are other messages with fully // qualified names ending in `.D` but not in `.C.D`, it assigns the unique name `bCD`. func resolveNamesLegacy(messages []string) map[string]string { return resolveNamesUniqueWithContext(messages, 1, "", false) } // resolveNamesSimple takes the names of all proto messages and generates unique references by using a simple // heuristic: starting from the bottom of the name hierarchy, it determines the minimum // number of components necessary to yield a unique name, and then concatenates those last // components with a "." separator in between to form a unique name. // // E.g., if the fully qualified name is `.a.b.C.D`, and there are other messages with // fully qualified names ending in `.D` but not in `.C.D`, it assigns the unique name `C.D`. func resolveNamesSimple(messages []string) map[string]string { return resolveNamesUniqueWithContext(messages, 0, ".", false) } // resolveNamesPackage takes the names of all proto messages and generates unique references by // starting with the package-scoped name (with nested message types qualified by their containing // "parent" types), and then following the "simple" heuristic above to add package name components // until each message has a unique name with a "." between each component. // // E.g., if the fully qualified name is `.a.b.C.D`, the name is `C.D` unless there is another // package-scoped name ending in "C.D", in which case it would be `b.C.D` (unless that also // conflicted, in which case the name would be the fully-qualified `a.b.C`). func resolveNamesPackage(messages []string) map[string]string { return resolveNamesUniqueWithContext(messages, 0, ".", true) } // For the "package" naming strategy, we rely on the convention that package names are lowercase // but message names are capitalized. var pkgEndRegexp = regexp.MustCompile(`\.[A-Z]`) // Take the names of every proto message and generates a unique reference by: // first, separating each message name into its components by splitting at dots. Then, // take the shortest suffix slice from each components slice that is unique among all // messages, and convert it into a component name by taking extraContext additional // components into consideration and joining all components with componentSeparator. func resolveNamesUniqueWithContext(messages []string, extraContext int, componentSeparator string, qualifyNestedMessages bool) map[string]string { packagesByDepth := make(map[int][][]string) uniqueNames := make(map[string]string) hierarchy := func(pkg string) []string { if !qualifyNestedMessages { return strings.Split(pkg, ".") } pkgEnd := pkgEndRegexp.FindStringIndex(pkg) if pkgEnd == nil { // Fall back to non-qualified behavior if search based on convention fails. return strings.Split(pkg, ".") } // Return each package component as an element, followed by the full message name // (potentially qualified, if nested) as a single element. qualifiedPkgName := pkg[:pkgEnd[0]] nestedTypeName := pkg[pkgEnd[0]+1:] return append(strings.Split(qualifiedPkgName, "."), nestedTypeName) } for _, p := range messages { h := hierarchy(p) for depth := range h { if _, ok := packagesByDepth[depth]; !ok { packagesByDepth[depth] = make([][]string, 0) } packagesByDepth[depth] = append(packagesByDepth[depth], h[len(h)-depth:]) } } count := func(list [][]string, item []string) int { i := 0 for _, element := range list { if reflect.DeepEqual(element, item) { i++ } } return i } for _, p := range messages { h := hierarchy(p) depth := 0 for ; depth < len(h); depth++ { // depth + extraContext > 0 ensures that we only break for values of depth when the // resulting slice of name components is non-empty. Otherwise, we would return the // empty string as the concise unique name is len(messages) == 1 (which is // technically correct). if depth+extraContext > 0 && count(packagesByDepth[depth], h[len(h)-depth:]) == 1 { break } } start := len(h) - depth - extraContext if start < 0 { start = 0 } components := h[start:] // When using empty separator (legacy mode), apply camelCase by title-casing // intermediate lowercase package components. E.g., "google.rpc.Status" -> "googleRpcStatus" // We only title-case components that are entirely lowercase (package names), // not message names which are already PascalCase. // Skip the first non-empty component (keep it lowercase for camelCase). if componentSeparator == "" && len(components) > 1 { firstNonEmpty := -1 for i := 0; i < len(components); i++ { if components[i] != "" { firstNonEmpty = i break } } for i := firstNonEmpty + 1; i < len(components); i++ { if len(components[i]) > 0 && components[i] == strings.ToLower(components[i]) { components[i] = strings.ToUpper(components[i][:1]) + components[i][1:] } } } uniqueNames[p] = strings.Join(components, componentSeparator) } return uniqueNames } ================================================ FILE: protoc-gen-openapiv2/internal/genopenapi/naming_test.go ================================================ package genopenapi import "testing" func TestNaming(t *testing.T) { type expectedNames struct { fqn, legacy, simple, pkg string } messageNameToExpected := map[string]expectedNames{ ".A": {"A", "A", "A", "A"}, ".a.B.C": {"a.B.C", "aBC", "B.C", "B.C"}, ".a.D.C": {"a.D.C", "aDC", "D.C", "D.C"}, ".a.E.F": {"a.E.F", "aEF", "a.E.F", "a.E.F"}, ".b.E.F": {"b.E.F", "bEF", "b.E.F", "b.E.F"}, ".c.G.H": {"c.G.H", "GH", "H", "G.H"}, } allMessageNames := make([]string, 0, len(messageNameToExpected)) for msgName := range messageNameToExpected { allMessageNames = append(allMessageNames, msgName) } t.Run("fqn", func(t *testing.T) { uniqueNames := resolveNamesFQN(allMessageNames) for _, msgName := range allMessageNames { expected := messageNameToExpected[msgName].fqn actual := uniqueNames[msgName] if expected != actual { t.Errorf("fqn unique name %q does not match expected name %q", actual, expected) } } }) t.Run("legacy", func(t *testing.T) { uniqueNames := resolveNamesLegacy(allMessageNames) for _, msgName := range allMessageNames { expected := messageNameToExpected[msgName].legacy actual := uniqueNames[msgName] if expected != actual { t.Errorf("legacy unique name %q does not match expected name %q", actual, expected) } } }) t.Run("simple", func(t *testing.T) { uniqueNames := resolveNamesSimple(allMessageNames) for _, msgName := range allMessageNames { expected := messageNameToExpected[msgName].simple actual := uniqueNames[msgName] if expected != actual { t.Errorf("simple unique name %q does not match expected name %q", actual, expected) } } }) t.Run("package", func(t *testing.T) { uniqueNames := resolveNamesPackage(allMessageNames) for _, msgName := range allMessageNames { expected := messageNameToExpected[msgName].pkg actual := uniqueNames[msgName] if expected != actual { t.Errorf("package unique name %q does not match expected name %q", actual, expected) } } }) } ================================================ FILE: protoc-gen-openapiv2/internal/genopenapi/template.go ================================================ package genopenapi import ( "bytes" "encoding/json" "errors" "fmt" "math" "net/textproto" "os" "reflect" "regexp" "slices" "sort" "strconv" "strings" "sync" "text/template" "time" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/casing" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor" openapi_options "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" "google.golang.org/genproto/googleapis/api/annotations" "google.golang.org/genproto/googleapis/api/visibility" "google.golang.org/grpc/grpclog" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/descriptorpb" "google.golang.org/protobuf/types/known/structpb" ) // The OpenAPI specification does not allow for more than one endpoint with the same HTTP method and path. // This prevents multiple gRPC service methods from sharing the same stripped version of the path and method. // For example: `GET /v1/{name=organizations/*}/roles` and `GET /v1/{name=users/*}/roles` both get stripped to `GET /v1/{name}/roles`. // We must make the URL unique by adding a suffix and an incrementing index to each path parameter // to differentiate the endpoints. // Since path parameter names do not affect the request contents (i.e. they're replaced in the path) // this will be hidden from the real grpc gateway consumer. const pathParamUniqueSuffixDeliminator = "_" const paragraphDeliminator = "\n\n" // wktSchemas are the schemas of well-known-types. // The schemas must match with the behavior of the JSON unmarshaler in // https://github.com/protocolbuffers/protobuf-go/blob/v1.25.0/encoding/protojson/well_known_types.go var wktSchemas = map[string]schemaCore{ ".google.protobuf.FieldMask": { Type: "string", }, ".google.protobuf.Timestamp": { Type: "string", Format: "date-time", }, ".google.protobuf.Duration": { Type: "string", }, ".google.protobuf.StringValue": { Type: "string", }, ".google.protobuf.BytesValue": { Type: "string", Format: "byte", }, ".google.protobuf.Int32Value": { Type: "integer", Format: "int32", }, ".google.protobuf.UInt32Value": { Type: "integer", Format: "int64", }, ".google.protobuf.Int64Value": { Type: "string", Format: "int64", }, ".google.protobuf.UInt64Value": { Type: "string", Format: "uint64", }, ".google.protobuf.FloatValue": { Type: "number", Format: "float", }, ".google.protobuf.DoubleValue": { Type: "number", Format: "double", }, ".google.protobuf.BoolValue": { Type: "boolean", }, ".google.protobuf.Empty": { Type: "object", }, ".google.protobuf.Struct": { Type: "object", }, ".google.protobuf.Value": {}, ".google.protobuf.ListValue": { Type: "array", Items: (*openapiItemsObject)(&openapiSchemaObject{ schemaCore: schemaCore{ Type: "object", }, }), }, ".google.protobuf.NullValue": { Type: "string", }, } func listEnumNames(reg *descriptor.Registry, enum *descriptor.Enum) interface{} { var names []string for _, value := range enum.GetValue() { if !isVisible(getEnumValueVisibilityOption(value), reg) { continue } if reg.GetOmitEnumDefaultValue() && value.GetNumber() == 0 { continue } names = append(names, value.GetName()) } if len(names) > 0 { return names } return nil } func listEnumNumbers(reg *descriptor.Registry, enum *descriptor.Enum) interface{} { var numbers []int for _, value := range enum.GetValue() { if reg.GetOmitEnumDefaultValue() && value.GetNumber() == 0 { continue } if !isVisible(getEnumValueVisibilityOption(value), reg) { continue } numbers = append(numbers, int(value.GetNumber())) } if len(numbers) > 0 { return numbers } return nil } func getEnumDefault(reg *descriptor.Registry, enum *descriptor.Enum) interface{} { if !reg.GetOmitEnumDefaultValue() { for _, value := range enum.GetValue() { if value.GetNumber() == 0 { if !isVisible(getEnumValueVisibilityOption(value), reg) { return nil } return value.GetName() } } } return nil } func getEnumDefaultNumber(reg *descriptor.Registry, enum *descriptor.Enum) interface{} { if !reg.GetOmitEnumDefaultValue() { for _, value := range enum.GetValue() { if value.GetNumber() == 0 { return int(value.GetNumber()) } } } return nil } // messageToQueryParameters converts a message to a list of OpenAPI query parameters. func messageToQueryParameters(message *descriptor.Message, reg *descriptor.Registry, pathParams []descriptor.Parameter, body *descriptor.Body, httpMethod string) (params []openapiParameterObject, err error) { for _, field := range message.Fields { // When body is set to oneof field, we want to skip other fields in the oneof group. if isBodySameOneOf(body, field) { continue } if !isVisible(getFieldVisibilityOption(field), reg) { continue } if reg.GetAllowPatchFeature() && field.GetTypeName() == ".google.protobuf.FieldMask" && field.GetName() == "update_mask" && httpMethod == "PATCH" && len(body.FieldPath) != 0 { continue } p, err := queryParams(message, field, "", reg, pathParams, body, reg.GetRecursiveDepth()) if err != nil { return nil, err } params = append(params, p...) } return params, nil } func isBodySameOneOf(body *descriptor.Body, field *descriptor.Field) bool { if field.OneofIndex == nil { return false } if body == nil || len(body.FieldPath) == 0 { return false } if body.FieldPath[0].Target.OneofIndex == nil { return false } return *body.FieldPath[0].Target.OneofIndex == *field.OneofIndex } // queryParams converts a field to a list of OpenAPI query parameters recursively through the use of nestedQueryParams. func queryParams(message *descriptor.Message, field *descriptor.Field, prefix string, reg *descriptor.Registry, pathParams []descriptor.Parameter, body *descriptor.Body, recursiveCount int) (params []openapiParameterObject, err error) { return nestedQueryParams(message, field, prefix, reg, pathParams, body, newCycleChecker(recursiveCount)) } type cycleChecker struct { m map[string]int count int } func newCycleChecker(recursive int) *cycleChecker { return &cycleChecker{ m: make(map[string]int), count: recursive, } } // Check returns whether name is still within recursion // toleration func (c *cycleChecker) Check(name string) bool { count, ok := c.m[name] count += 1 isCycle := count > c.count if isCycle { return false } // provision map entry if not available if !ok { c.m[name] = 1 return true } c.m[name] = count return true } func (c *cycleChecker) Branch() *cycleChecker { copy := &cycleChecker{ count: c.count, m: make(map[string]int, len(c.m)), } for k, v := range c.m { copy.m[k] = v } return copy } // nestedQueryParams converts a field to a list of OpenAPI query parameters recursively. // This function is a helper function for queryParams, that keeps track of cyclical message references // through the use of // // touched map[string]int // // If a cycle is discovered, an error is returned, as cyclical data structures are dangerous // in query parameters. func nestedQueryParams(message *descriptor.Message, field *descriptor.Field, prefix string, reg *descriptor.Registry, pathParams []descriptor.Parameter, body *descriptor.Body, cycle *cycleChecker) (params []openapiParameterObject, err error) { // make sure the parameter is not already listed as a path parameter for _, pathParam := range pathParams { if pathParam.Target == field { return nil, nil } } // make sure the parameter is not already listed as a body parameter if body != nil { if body.FieldPath == nil { return nil, nil } for _, fieldPath := range body.FieldPath { if fieldPath.Target == field { return nil, nil } } } schema := schemaOfField(field, reg, nil) fieldType := field.GetTypeName() if message.File != nil { comments := fieldProtoComments(reg, message, field) if err := updateOpenAPIDataFromComments(reg, &schema, message, comments, false); err != nil { return nil, err } } isEnum := field.GetType() == descriptorpb.FieldDescriptorProto_TYPE_ENUM items := schema.Items if schema.Type != "" || isEnum { if schema.Type == "object" { location := "" if ix := strings.LastIndex(field.Message.FQMN(), "."); ix > 0 { location = field.Message.FQMN()[0:ix] } if m, err := reg.LookupMsg(location, field.GetTypeName()); err == nil { if opt := m.GetOptions(); opt != nil && opt.MapEntry != nil && *opt.MapEntry { k := m.GetField()[0] kType, err := getMapParamKey(k.GetType()) if err != nil { return nil, err } // This will generate a query in the format map_name[key_type] fName := fmt.Sprintf("%s[%s]", *field.Name, kType) field.Name = proto.String(fName) schema.Type = schema.AdditionalProperties.schemaCore.Type } } } if items != nil && (items.Type == "" || items.Type == "object") && !isEnum { return nil, nil // TODO: currently, mapping object in query parameter is not supported } desc := mergeDescription(schema) // verify if the field is required required := false for _, fieldName := range schema.Required { if fieldName == reg.FieldName(field) { required = true break } } // verify if the field is required in message options if messageSchema, err := extractSchemaOptionFromMessageDescriptor(message.DescriptorProto); err == nil { for _, fieldName := range messageSchema.GetJsonSchema().GetRequired() { // Required fields can be field names or json_name values if fieldName == field.GetJsonName() || fieldName == field.GetName() { required = true break } } } // verify if the field is deprecated, either via proto or annotation protoDeprecated := field.GetOptions().GetDeprecated() && reg.GetEnableFieldDeprecation() annotationDeprecated := getFieldConfiguration(reg, field).GetDeprecated() deprecated := protoDeprecated || annotationDeprecated param := openapiParameterObject{ Description: desc, In: "query", Default: schema.Default, Type: schema.Type, Items: schema.Items, Format: schema.Format, Pattern: schema.Pattern, Required: required, Deprecated: deprecated, UniqueItems: schema.UniqueItems, extensions: schema.extensions, Enum: schema.Enum, } if param.Type == "array" { param.CollectionFormat = "multi" } param.Name = prefix + reg.FieldName(field) if isEnum { enum, err := reg.LookupEnum("", fieldType) if err != nil { return nil, fmt.Errorf("unknown enum type %s", fieldType) } if items != nil { // array param.Items = &openapiItemsObject{ schemaCore: schemaCore{ Type: "string", Enum: listEnumNames(reg, enum), }, } if reg.GetEnumsAsInts() { param.Items.Type = "integer" param.Items.Enum = listEnumNumbers(reg, enum) } } else { param.Type = "string" param.Enum = listEnumNames(reg, enum) param.Default = getEnumDefault(reg, enum) if reg.GetEnumsAsInts() { param.Type = "integer" param.Enum = listEnumNumbers(reg, enum) param.Default = getEnumDefaultNumber(reg, enum) } } valueComments := enumValueProtoComments(reg, enum) if valueComments != "" { param.Description = strings.TrimLeft(param.Description+"\n\n "+valueComments, "\n") } } return []openapiParameterObject{param}, nil } // nested type, recurse msg, err := reg.LookupMsg("", fieldType) if err != nil { return nil, fmt.Errorf("unknown message type %s", fieldType) } // Check for cyclical message reference: if ok := cycle.Check(*msg.Name); !ok { return nil, fmt.Errorf("exceeded recursive count (%d) for query parameter %q", cycle.count, fieldType) } // Construct a new map with the message name so a cycle further down the recursive path can be detected. // Do not keep anything in the original touched reference and do not pass that reference along. This will // prevent clobbering adjacent records while recursing. touchedOut := cycle.Branch() for _, nestedField := range msg.Fields { if !isVisible(getFieldVisibilityOption(nestedField), reg) { continue } fieldName := reg.FieldName(field) p, err := nestedQueryParams(msg, nestedField, prefix+fieldName+".", reg, pathParams, body, touchedOut) if err != nil { return nil, err } params = append(params, p...) } return params, nil } func getMapParamKey(t descriptorpb.FieldDescriptorProto_Type) (string, error) { tType, f, ok := primitiveSchema(t) if !ok || f == "byte" || f == "float" || f == "double" { return "", fmt.Errorf("unsupported type: %q", f) } return tType, nil } // findServicesMessagesAndEnumerations discovers all messages and enums defined in the RPC methods of the service. func findServicesMessagesAndEnumerations(s []*descriptor.Service, reg *descriptor.Registry, m messageMap, ms messageMap, e enumMap, refs refMap) { for _, svc := range s { if !isVisible(getServiceVisibilityOption(svc), reg) { continue } for _, meth := range svc.Methods { // Request may be fully included in query { if !isVisible(getMethodVisibilityOption(meth), reg) { continue } // Only process methods with HTTP bindings (exposed via HTTP annotations) // This prevents unused message definitions from appearing in the OpenAPI document if len(meth.Bindings) == 0 { continue } swgReqName, ok := fullyQualifiedNameToOpenAPIName(meth.RequestType.FQMN(), reg) if !ok { grpclog.Errorf("couldn't resolve OpenAPI name for FQMN %q", meth.RequestType.FQMN()) continue } if _, ok := refs[fmt.Sprintf("#/definitions/%s", swgReqName)]; ok { if !skipRenderingRef(meth.RequestType.FQMN()) { m[swgReqName] = meth.RequestType } } } swgRspName, ok := fullyQualifiedNameToOpenAPIName(meth.ResponseType.FQMN(), reg) if !ok && !skipRenderingRef(meth.ResponseType.FQMN()) { grpclog.Errorf("couldn't resolve OpenAPI name for FQMN %q", meth.ResponseType.FQMN()) continue } findNestedMessagesAndEnumerations(meth.RequestType, reg, m, e) if !skipRenderingRef(meth.ResponseType.FQMN()) { m[swgRspName] = meth.ResponseType } findNestedMessagesAndEnumerations(meth.ResponseType, reg, m, e) } } } // findNestedMessagesAndEnumerations those can be generated by the services. func findNestedMessagesAndEnumerations(message *descriptor.Message, reg *descriptor.Registry, m messageMap, e enumMap) { // Iterate over all the fields that for _, t := range message.Fields { if !isVisible(getFieldVisibilityOption(t), reg) { continue } fieldType := t.GetTypeName() // If the type is an empty string then it is a proto primitive if fieldType != "" { if _, ok := m[fieldType]; !ok { msg, err := reg.LookupMsg("", fieldType) if err != nil { enum, err := reg.LookupEnum("", fieldType) if err != nil { panic(err) } e[fieldType] = enum continue } m[fieldType] = msg findNestedMessagesAndEnumerations(msg, reg, m, e) } } } } // collectReferencedNamesForCache scans services and messages to collect all // FQMNs/FQENs that will be referenced, WITHOUT using the naming cache. // This allows us to build the cache with the correct filtered names BEFORE // any code tries to use it. func collectReferencedNamesForCache(services []*descriptor.Service, messages []*descriptor.Message, reg *descriptor.Registry) map[string]bool { refs := make(map[string]bool) // Scan services FIRST so collectNestedTypeFQNs fully traverses // message graphs without being short-circuited by pre-populated entries. for _, svc := range services { if !isVisible(getServiceVisibilityOption(svc), reg) { continue } for _, meth := range svc.Methods { if !isVisible(getMethodVisibilityOption(meth), reg) { continue } if len(meth.Bindings) == 0 { continue } // Add method FQN (needed for body:"*" with path params) refs[meth.FQMN()] = true // Add request/response types refs[meth.RequestType.FQMN()] = true refs[meth.ResponseType.FQMN()] = true // Recursively add nested types collectNestedTypeFQNs(meth.RequestType, reg, refs) collectNestedTypeFQNs(meth.ResponseType, reg, refs) } } // Add messages from the current file AFTER service scanning. // This must come after the service loop's collectNestedTypeFQNs calls, // otherwise pre-populated message entries cause the traversal to // short-circuit and miss nested types like enums inside referenced messages. // We also traverse each message's nested types here because // renderMessagesAsDefinition renders ALL messages from the file, not just // those reachable from service methods. Without this, cross-package types // referenced by non-service messages would be missing from the naming cache. for _, msg := range messages { refs[msg.FQMN()] = true collectNestedTypeFQNs(msg, reg, refs) } // Add google.rpc.Status if default errors enabled if !reg.GetDisableDefaultErrors() { refs[".google.rpc.Status"] = true // Also add nested types of Status if statusMsg, err := reg.LookupMsg("google.rpc", "Status"); err == nil { collectNestedTypeFQNs(statusMsg, reg, refs) } } return refs } // collectNestedTypeFQNs recursively collects FQMNs/FQENs for all nested types // of a message. Does NOT use the naming cache. func collectNestedTypeFQNs(message *descriptor.Message, reg *descriptor.Registry, refs map[string]bool) { for _, field := range message.Fields { if !isVisible(getFieldVisibilityOption(field), reg) { continue } fieldType := field.GetTypeName() if fieldType == "" { continue // primitive type } if refs[fieldType] { continue // already visited } refs[fieldType] = true // If it's a message, recurse if msg, err := reg.LookupMsg("", fieldType); err == nil { collectNestedTypeFQNs(msg, reg, refs) } // Enums don't have nested types, no recursion needed } } func skipRenderingRef(refName string) bool { _, ok := wktSchemas[refName] return ok } func renderMessageAsDefinition(msg *descriptor.Message, reg *descriptor.Registry, customRefs refMap, pathParams []descriptor.Parameter) (openapiSchemaObject, error) { schema := openapiSchemaObject{ schemaCore: schemaCore{ Type: "object", }, } if reg.GetGenerateXGoType() && msg.File.GoPkg.Path != "" { if schema.extensions == nil { schema.extensions = []extension{} } goTypeName := msg.GetName() goTypeName = casing.JSONCamelCase(goTypeName) schema.extensions = append(schema.extensions, extension{ key: "x-go-type", value: json.RawMessage(`{ "import": { "package": "` + msg.File.GoPkg.Path + `" }, "type": "` + goTypeName + `" }`), }) } msgComments := protoComments(reg, msg.File, msg.Outers, "MessageType", int32(msg.Index)) if err := updateOpenAPIDataFromComments(reg, &schema, msg, msgComments, false); err != nil { return openapiSchemaObject{}, err } opts, err := getMessageOpenAPIOption(reg, msg) if err != nil { return openapiSchemaObject{}, err } if opts != nil { protoSchema := openapiSchemaFromProtoSchema(opts, reg, customRefs, msg) // Warning: Make sure not to overwrite any fields already set on the schema type. schema.ExternalDocs = protoSchema.ExternalDocs schema.ReadOnly = protoSchema.ReadOnly schema.MultipleOf = protoSchema.MultipleOf schema.Maximum = protoSchema.Maximum schema.ExclusiveMaximum = protoSchema.ExclusiveMaximum schema.Minimum = protoSchema.Minimum schema.ExclusiveMinimum = protoSchema.ExclusiveMinimum schema.MaxLength = protoSchema.MaxLength schema.MinLength = protoSchema.MinLength schema.Pattern = protoSchema.Pattern schema.Default = protoSchema.Default schema.MaxItems = protoSchema.MaxItems schema.MinItems = protoSchema.MinItems schema.UniqueItems = protoSchema.UniqueItems schema.MaxProperties = protoSchema.MaxProperties schema.MinProperties = protoSchema.MinProperties schema.Required = protoSchema.Required schema.XNullable = protoSchema.XNullable schema.extensions = protoSchema.extensions if protoSchema.schemaCore.Type != "" || protoSchema.schemaCore.Ref != "" { schema.schemaCore = protoSchema.schemaCore } if protoSchema.Title != "" { schema.Title = protoSchema.Title } if protoSchema.Description != "" { schema.Description = protoSchema.Description } if protoSchema.Example != nil { schema.Example = protoSchema.Example } } schema.Required = filterOutExcludedFields(schema.Required, pathParams) for _, f := range msg.Fields { if !isVisible(getFieldVisibilityOption(f), reg) { continue } if shouldExcludeField(f.GetName(), pathParams) { continue } subPathParams := subPathParams(f.GetName(), pathParams) fieldSchema, err := renderFieldAsDefinition(f, reg, customRefs, subPathParams) if err != nil { return openapiSchemaObject{}, err } comments := fieldProtoComments(reg, msg, f) if err := updateOpenAPIDataFromComments(reg, &fieldSchema, f, comments, false); err != nil { return openapiSchemaObject{}, err } if requiredIdx := find(schema.Required, *f.Name); requiredIdx != -1 && reg.GetUseJSONNamesForFields() { schema.Required[requiredIdx] = f.GetJsonName() } if fieldSchema.Required != nil { // Only hoist required fields to parent if there are no path params inside this field. if len(subPathParams) == 0 { schema.Required = getUniqueFields(schema.Required, fieldSchema.Required) schema.Required = append(schema.Required, fieldSchema.Required...) // To avoid populating both the field schema require and message schema require, unset the field schema require. // See issue #2635. fieldSchema.Required = nil } else { // When there are path params, we need to separate field-level required from nested required. // The field name itself (if required) should be in parent's required, but nested field names // should stay in the nested schema's required. fieldName := f.GetName() if reg.GetUseJSONNamesForFields() { fieldName = f.GetJsonName() } // Check if the field name is in the fieldSchema.Required (it would be if the field is marked REQUIRED) var nestedRequired []string fieldIsRequired := false for _, req := range fieldSchema.Required { if req == fieldName { fieldIsRequired = true } else { nestedRequired = append(nestedRequired, req) } } // Add the field name to parent's required if the field itself is required if fieldIsRequired && find(schema.Required, fieldName) == -1 { schema.Required = append(schema.Required, fieldName) } // Keep only the nested required fields in the field schema fieldSchema.Required = nestedRequired } } if reg.GetUseAllOfForRefs() { if fieldSchema.Ref != "" { // Per the JSON Reference syntax: Any members other than "$ref" in a JSON Reference object SHALL be ignored. // https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03#section-3 // However, use allOf to specify Title/Description/Example/readOnly fields. if fieldSchema.Title != "" || fieldSchema.Description != "" || len(fieldSchema.Example) > 0 || fieldSchema.ReadOnly { fieldSchema = openapiSchemaObject{ Title: fieldSchema.Title, Description: fieldSchema.Description, schemaCore: schemaCore{ Example: fieldSchema.Example, }, ReadOnly: fieldSchema.ReadOnly, AllOf: []allOfEntry{{Ref: fieldSchema.Ref}}, } } else { fieldSchema = openapiSchemaObject{schemaCore: schemaCore{Ref: fieldSchema.Ref}} } } } kv := keyVal{Value: fieldSchema} kv.Key = reg.FieldName(f) if schema.Properties == nil { schema.Properties = &openapiSchemaObjectProperties{} } *schema.Properties = append(*schema.Properties, kv) } if msg.FQMN() == ".google.protobuf.Any" { transformAnyForJSON(&schema, reg.GetUseJSONNamesForFields()) } return schema, nil } func renderFieldAsDefinition(f *descriptor.Field, reg *descriptor.Registry, refs refMap, pathParams []descriptor.Parameter) (openapiSchemaObject, error) { if len(pathParams) == 0 { return schemaOfField(f, reg, refs), nil } location := "" if ix := strings.LastIndex(f.Message.FQMN(), "."); ix > 0 { location = f.Message.FQMN()[0:ix] } msg, err := reg.LookupMsg(location, f.GetTypeName()) if err != nil { return openapiSchemaObject{}, err } schema, err := renderMessageAsDefinition(msg, reg, refs, pathParams) if err != nil { return openapiSchemaObject{}, err } comments := fieldProtoComments(reg, f.Message, f) if len(comments) > 0 { // Use title and description from field instead of nested message if present. paragraphs := strings.Split(comments, paragraphDeliminator) firstParagraph := strings.TrimSpace(paragraphs[0]) if !strings.Contains(firstParagraph, "\n") { schema.Title = firstParagraph schema.Description = strings.TrimSpace(strings.Join(paragraphs[1:], paragraphDeliminator)) } else { schema.Description = strings.TrimSpace(comments) } } // to handle case where path param is present inside the field of descriptorpb.FieldDescriptorProto_TYPE_MESSAGE type // it still needs to consider the behaviour of the field which was being done by schemaOfField() in case there are no path params if j, err := getFieldBehaviorOption(reg, f); err == nil { updateSwaggerObjectFromFieldBehavior(&schema, j, reg, f) } return schema, nil } // transformAnyForJSON should be called when the schema object represents a google.protobuf.Any, and will replace the // Properties slice with a single value for '@type'. We mutate the incorrectly named field so that we inherit the same // documentation as specified on the original field in the protobuf descriptors. func transformAnyForJSON(schema *openapiSchemaObject, useJSONNames bool) { var typeFieldName string if useJSONNames { typeFieldName = "typeUrl" } else { typeFieldName = "type_url" } for _, property := range *schema.Properties { if property.Key == typeFieldName { schema.AdditionalProperties = &openapiSchemaObject{} schema.Properties = &openapiSchemaObjectProperties{keyVal{ Key: "@type", Value: property.Value, }} break } } } func renderMessagesAsDefinition(messages messageMap, d openapiDefinitionsObject, reg *descriptor.Registry, customRefs refMap, pathParams []descriptor.Parameter) error { for name, msg := range messages { swgName, ok := fullyQualifiedNameToOpenAPIName(msg.FQMN(), reg) if !ok { return fmt.Errorf("can't resolve OpenAPI name from %q", msg.FQMN()) } if skipRenderingRef(name) { continue } if opt := msg.GetOptions(); opt != nil && opt.MapEntry != nil && *opt.MapEntry { continue } var err error d[swgName], err = renderMessageAsDefinition(msg, reg, customRefs, pathParams) if err != nil { return err } } return nil } // isVisible checks if a field/RPC is visible based on the visibility restriction // combined with the `visibility_restriction_selectors`. // Elements with an overlap on `visibility_restriction_selectors` are visible, those without are not visible. // Elements without `google.api.VisibilityRule` annotations entirely are always visible. func isVisible(r *visibility.VisibilityRule, reg *descriptor.Registry) bool { if r == nil { return true } restrictions := strings.Split(strings.TrimSpace(r.Restriction), ",") // No restrictions results in the element always being visible if len(restrictions) == 0 { return true } for _, restriction := range restrictions { if reg.GetVisibilityRestrictionSelectors()[strings.TrimSpace(restriction)] { return true } } return false } func shouldExcludeField(name string, excluded []descriptor.Parameter) bool { for _, p := range excluded { if len(p.FieldPath) == 1 && name == p.FieldPath[0].Name { return true } } return false } func filterOutExcludedFields(fields []string, excluded []descriptor.Parameter) []string { var filtered []string for _, f := range fields { if !shouldExcludeField(f, excluded) { filtered = append(filtered, f) } } return filtered } // schemaOfFieldBase returns a base Schema Object for a protobuf field. func schemaOfFieldBase(f *descriptor.Field, reg *descriptor.Registry, refs refMap) openapiSchemaObject { const ( singular = 0 array = 1 object = 2 ) var ( core schemaCore aggregate int ) fd := f.FieldDescriptorProto location := "" if ix := strings.LastIndex(f.Message.FQMN(), "."); ix > 0 { location = f.Message.FQMN()[0:ix] } if m, err := reg.LookupMsg(location, f.GetTypeName()); err == nil { if opt := m.GetOptions(); opt != nil && opt.MapEntry != nil && *opt.MapEntry { fd = m.GetField()[1] aggregate = object } } if fd.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_REPEATED { aggregate = array } var props *openapiSchemaObjectProperties switch ft := fd.GetType(); ft { case descriptorpb.FieldDescriptorProto_TYPE_ENUM, descriptorpb.FieldDescriptorProto_TYPE_MESSAGE, descriptorpb.FieldDescriptorProto_TYPE_GROUP: if wktSchema, ok := wktSchemas[fd.GetTypeName()]; ok { core = wktSchema if fd.GetTypeName() == ".google.protobuf.Empty" { props = &openapiSchemaObjectProperties{} } } else { swgRef, ok := fullyQualifiedNameToOpenAPIName(fd.GetTypeName(), reg) if !ok { panic(fmt.Sprintf("can't resolve OpenAPI ref from typename %q", fd.GetTypeName())) } core = schemaCore{ Ref: "#/definitions/" + swgRef, } if refs != nil { refs[fd.GetTypeName()] = struct{}{} } } default: ftype, format, ok := primitiveSchema(ft) if ok { core = schemaCore{Type: ftype, Format: format} } else { core = schemaCore{Type: ft.String(), Format: "UNKNOWN"} } } var ret openapiSchemaObject switch aggregate { case array: // Only set core.Type = "object" for MESSAGE types with $ref if the flag is not set. // When omitArrayItemTypeWhenRefSibling is true, we omit "type: object" to avoid // no-$ref-siblings violations in OpenAPI v2, since $ref already implies the type is object. if !reg.GetOmitArrayItemTypeWhenRefSibling() { if _, ok := wktSchemas[fd.GetTypeName()]; !ok && fd.GetType() == descriptorpb.FieldDescriptorProto_TYPE_MESSAGE { core.Type = "object" } } ret = openapiSchemaObject{ schemaCore: schemaCore{ Type: "array", Items: (*openapiItemsObject)(&openapiSchemaObject{schemaCore: core}), }, } case object: ret = openapiSchemaObject{ schemaCore: schemaCore{ Type: "object", }, AdditionalProperties: &openapiSchemaObject{Properties: props, schemaCore: core}, } default: ret = openapiSchemaObject{ schemaCore: core, Properties: props, } } return ret } // schemaOfField returns a OpenAPI Schema Object for a protobuf field. func schemaOfField(f *descriptor.Field, reg *descriptor.Registry, refs refMap) openapiSchemaObject { ret := schemaOfFieldBase(f, reg, refs) if j, err := getFieldOpenAPIOption(reg, f); err == nil { updateswaggerObjectFromJSONSchema(&ret, j, reg, f) } if j, err := getFieldBehaviorOption(reg, f); err == nil { updateSwaggerObjectFromFieldBehavior(&ret, j, reg, f) } for i, required := range ret.Required { if required == f.GetName() { ret.Required[i] = reg.FieldName(f) } } slices.Sort(ret.Required) ret.Required = slices.Compact(ret.Required) if reg.GetProto3OptionalNullable() && f.GetProto3Optional() { ret.XNullable = true } return ret } // primitiveSchema returns a pair of "Type" and "Format" in JSON Schema for // the given primitive field type. // The last return parameter is true iff the field type is actually primitive. func primitiveSchema(t descriptorpb.FieldDescriptorProto_Type) (ftype, format string, ok bool) { switch t { case descriptorpb.FieldDescriptorProto_TYPE_DOUBLE: return "number", "double", true case descriptorpb.FieldDescriptorProto_TYPE_FLOAT: return "number", "float", true case descriptorpb.FieldDescriptorProto_TYPE_INT64: return "string", "int64", true case descriptorpb.FieldDescriptorProto_TYPE_UINT64: // 64bit integer types are marshaled as string in the default JSONPb marshaler. // TODO(yugui) Add an option to declare 64bit integers as int64. // // NOTE: uint64 is not a predefined format of integer type in OpenAPI spec. // So we cannot expect that uint64 is commonly supported by OpenAPI processor. return "string", "uint64", true case descriptorpb.FieldDescriptorProto_TYPE_INT32: return "integer", "int32", true case descriptorpb.FieldDescriptorProto_TYPE_FIXED64: // Ditto. return "string", "uint64", true case descriptorpb.FieldDescriptorProto_TYPE_FIXED32: // Ditto. return "integer", "int64", true case descriptorpb.FieldDescriptorProto_TYPE_BOOL: // NOTE: in OpenAPI specification, format should be empty on boolean type return "boolean", "", true case descriptorpb.FieldDescriptorProto_TYPE_STRING: // NOTE: in OpenAPI specification, can be empty on string type // see: https://swagger.io/specification/v2/#data-types return "string", "", true case descriptorpb.FieldDescriptorProto_TYPE_BYTES: return "string", "byte", true case descriptorpb.FieldDescriptorProto_TYPE_UINT32: // Ditto. return "integer", "int64", true case descriptorpb.FieldDescriptorProto_TYPE_SFIXED32: return "integer", "int32", true case descriptorpb.FieldDescriptorProto_TYPE_SFIXED64: return "string", "int64", true case descriptorpb.FieldDescriptorProto_TYPE_SINT32: return "integer", "int32", true case descriptorpb.FieldDescriptorProto_TYPE_SINT64: return "string", "int64", true default: return "", "", false } } // renderEnumerationsAsDefinition inserts enums into the definitions object. func renderEnumerationsAsDefinition(enums enumMap, d openapiDefinitionsObject, reg *descriptor.Registry, customRefs refMap) { for _, enum := range enums { swgName, ok := fullyQualifiedNameToOpenAPIName(enum.FQEN(), reg) if !ok { panic(fmt.Sprintf("can't resolve OpenAPI name from FQEN %q", enum.FQEN())) } enumComments := protoComments(reg, enum.File, enum.Outers, "EnumType", int32(enum.Index)) // it may be necessary to sort the result of the GetValue function. enumNames := listEnumNames(reg, enum) defaultValue := getEnumDefault(reg, enum) valueComments := enumValueProtoComments(reg, enum) if valueComments != "" { enumComments = strings.TrimLeft(enumComments+"\n\n "+valueComments, "\n") } enumSchemaObject := openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", Enum: enumNames, Default: defaultValue, }, } if reg.GetEnumsAsInts() { enumSchemaObject.Type = "integer" enumSchemaObject.Format = "int32" enumSchemaObject.Default = getEnumDefaultNumber(reg, enum) enumSchemaObject.Enum = listEnumNumbers(reg, enum) } opts, err := getEnumOpenAPIOption(reg, enum) if err != nil { panic(err) } if opts != nil { protoSchema := openapiSchemaFromProtoEnumSchema(opts, reg, customRefs, enum) // Warning: Make sure not to overwrite any fields already set on the schema type. // This is only a subset of the fields from JsonSchema since most of them only apply to arrays or objects not enums enumSchemaObject.ExternalDocs = protoSchema.ExternalDocs enumSchemaObject.ReadOnly = protoSchema.ReadOnly enumSchemaObject.extensions = protoSchema.extensions if protoSchema.Type != "" || protoSchema.Ref != "" { enumSchemaObject.schemaCore = protoSchema.schemaCore } if protoSchema.Title != "" { enumSchemaObject.Title = protoSchema.Title } if protoSchema.Description != "" { enumSchemaObject.Description = protoSchema.Description } if protoSchema.Example != nil { enumSchemaObject.Example = protoSchema.Example } } if err := updateOpenAPIDataFromComments(reg, &enumSchemaObject, enum, enumComments, false); err != nil { panic(err) } d[swgName] = enumSchemaObject } } // Take in a FQMN or FQEN and return a OpenAPI safe version of the FQMN and // a boolean indicating if FQMN was properly resolved. func fullyQualifiedNameToOpenAPIName(fqn string, reg *descriptor.Registry) (string, bool) { registriesSeenMutex.Lock() defer registriesSeenMutex.Unlock() if mapping, present := registriesSeen[reg]; present { ret, ok := mapping[fqn] return ret, ok } mapping := resolveFullyQualifiedNameToOpenAPINames(append(reg.GetAllFQMNs(), append(reg.GetAllFQENs(), reg.GetAllFQMethNs()...)...), reg.GetOpenAPINamingStrategy()) registriesSeen[reg] = mapping ret, ok := mapping[fqn] return ret, ok } // Lookup message type by location.name and return an openapiv2-safe version // of its FQMN. func lookupMsgAndOpenAPIName(location, name string, reg *descriptor.Registry) (*descriptor.Message, string, error) { msg, err := reg.LookupMsg(location, name) if err != nil { return nil, "", err } swgName, ok := fullyQualifiedNameToOpenAPIName(msg.FQMN(), reg) if !ok { return nil, "", fmt.Errorf("can't map OpenAPI name from FQMN %q", msg.FQMN()) } return msg, swgName, nil } // registriesSeen is used to memoise calls to resolveFullyQualifiedNameToOpenAPINames so // we don't repeat it unnecessarily, since it can take some time. var ( registriesSeen = map[*descriptor.Registry]map[string]string{} registriesSeenMutex sync.Mutex ) // Take the names of every proto message and generate a unique reference for each, according to the given strategy. func resolveFullyQualifiedNameToOpenAPINames(messages []string, namingStrategy string) map[string]string { strategyFn := LookupNamingStrategy(namingStrategy) if strategyFn == nil { return nil } return strategyFn(messages) } var canRegexp = regexp.MustCompile("{([a-zA-Z][a-zA-Z0-9_.-]*)([^}]*)}") // templateToParts splits a URL template into path segments for use by `partsToOpenAPIPath` and `partsToRegexpMap`. // // Parameters: // - path: The URL template as defined by https://github.com/googleapis/googleapis/blob/master/google/api/http.proto // - reg: The descriptor registry used to read compiler flags // - fields: The fields of the request message, only used when `useJSONNamesForFields` is true // - msgs: The Messages of the service binding, only used when `useJSONNamesForFields` is true // // Returns: // // The path segments of the URL template. func templateToParts(path string, reg *descriptor.Registry, fields []*descriptor.Field, msgs []*descriptor.Message) []string { // It seems like the right thing to do here is to just use // strings.Split(path, "/") but that breaks badly when you hit a url like // /{my_field=prefix/*}/ and end up with 2 sections representing my_field. // Instead do the right thing and write a small pushdown (counter) automata // for it. var parts []string depth := 0 buffer := "" for i, char := range path { switch char { case '{': // Push on the stack depth++ buffer += string(char) case '}': if depth == 0 { panic("Encountered } without matching { before it.") } // Pop from the stack depth-- if !reg.GetUseJSONNamesForFields() { buffer += string(char) continue } paramNameProto := strings.SplitN(buffer[1:], "=", 2)[0] paramNameCamelCase := lowerCamelCase(paramNameProto, fields, msgs) buffer = strings.Join([]string{"{", paramNameCamelCase, buffer[len(paramNameProto)+1:], "}"}, "") case '/': if depth == 0 { parts = append(parts, buffer) buffer = "" // Since the stack was empty when we hit the '/' we are done with this // section. continue } buffer += string(char) case ':': if depth == 0 { // Only treat this as a verb if we're at the end of the path or // if there are no more path segments (only more literals after the colon) remainingPath := path[i:] if !strings.Contains(remainingPath, "/") { parts = append(parts, buffer) verbSegment := remainingPath if reg.GetUseJSONNamesForFields() { verbSegment = processParametersInSegment(verbSegment, fields, msgs) } parts = append(parts, verbSegment) return parts } } buffer += string(char) default: buffer += string(char) } } // Now append the last element to parts parts = append(parts, buffer) return parts } // processParametersInSegment processes a path segment (like ":verb/{param}") to convert // parameter names to camelCase while preserving the overall structure func processParametersInSegment(segment string, fields []*descriptor.Field, msgs []*descriptor.Message) string { result := segment depth := 0 var paramStart int for i, char := range segment { switch char { case '{': if depth == 0 { paramStart = i } depth++ case '}': depth-- if depth == 0 { paramContent := segment[paramStart+1 : i] paramNameProto := strings.SplitN(paramContent, "=", 2)[0] paramNameCamelCase := lowerCamelCase(paramNameProto, fields, msgs) oldParam := "{" + paramContent + "}" newParam := "{" + paramNameCamelCase if strings.Contains(paramContent, "=") { newParam += paramContent[len(paramNameProto):] } newParam += "}" result = strings.Replace(result, oldParam, newParam, 1) } } } return result } // partsToOpenAPIPath converts each path part of the form /path/{string_value=strprefix/*} which is defined in // https://github.com/googleapis/googleapis/blob/master/google/api/http.proto to the OpenAPI expected form /path/{string_value}. // For example this would replace the path segment of "{foo=bar/*}" with "{foo}" or "prefix{bang=bash/**}" with "prefix{bang}". // OpenAPI 2 only allows simple path parameters with the constraints on that parameter specified in the OpenAPI // schema's "pattern" instead of in the path parameter itself. func partsToOpenAPIPath(parts []string, overrides map[string]string) string { for index, part := range parts { part = canRegexp.ReplaceAllString(part, "{$1}") if override, ok := overrides[part]; ok { part = override } parts[index] = part } if last := len(parts) - 1; strings.HasPrefix(parts[last], ":") { // Last item is a verb (":" LITERAL). return strings.Join(parts[:last], "/") + parts[last] } return strings.Join(parts, "/") } // partsToRegexpMap returns a map of parameter name to ECMA 262 patterns // which is what the "pattern" field on an OpenAPI parameter expects. // See https://swagger.io/specification/v2/ (Parameter Object) and // https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.2.3. // The expression is generated based on expressions defined by https://github.com/googleapis/googleapis/blob/master/google/api/http.proto // "Path Template Syntax" section which allow for a "param_name=foobar/*/bang/**" style expressions inside // the path parameter placeholders that indicate constraints on the values of those parameters. // This function will scan the split parts of a path template for parameters and // outputs a map of the name of the parameter to a ECMA regular expression. See the http.proto file for descriptions // of the supported syntax. This function will ignore any path parameters that don't contain a "=" after the // parameter name. For supported parameters, we assume "*" represent all characters except "/" as it's // intended to match a single path element and we assume "**" matches any character as it's intended to match multiple // path elements. // For example "{name=organizations/*/roles/*}" would produce the regular expression for the "name" parameter of // "organizations/[^/]+/roles/[^/]+" or "{bar=bing/*/bang/**}" would produce the regular expression for the "bar" // parameter of "bing/[^/]+/bang/.+". // // Note that OpenAPI does not actually support path parameters with "/", see https://github.com/OAI/OpenAPI-Specification/issues/892 func partsToRegexpMap(parts []string) map[string]string { regExps := make(map[string]string) for _, part := range parts { if strings.Contains(part, "/") { grpclog.Warningf("Path parameter %q contains '/', which is not supported in OpenAPI", part) } if submatch := canRegexp.FindStringSubmatch(part); len(submatch) > 2 { if strings.HasPrefix(submatch[2], "=") { // this part matches the standard and should be made into a regular expression // assume the string's characters other than "**" and "*" are literals (not necessarily a good assumption 100% of the times, but it will support most use cases) regex := submatch[2][1:] regex = strings.ReplaceAll(regex, "**", ".+") // ** implies any character including "/" regex = strings.ReplaceAll(regex, "*", "[^/]+") // * implies any character except "/" regExps[submatch[1]] = regex } } } return regExps } func renderServiceTags(services []*descriptor.Service, reg *descriptor.Registry) []openapiTagObject { var tags []openapiTagObject for _, svc := range services { if !isVisible(getServiceVisibilityOption(svc), reg) { continue } tagName := svc.GetName() if pkg := svc.File.GetPackage(); pkg != "" && reg.IsIncludePackageInTags() { tagName = pkg + "." + tagName } tag := openapiTagObject{ Name: tagName, } opts, err := getServiceOpenAPIOption(reg, svc) if err != nil { grpclog.Error(err) return nil } if opts != nil { tag.Description = opts.Description if reg.GetUseGoTemplate() { tag.Description = goTemplateComments(tag.Description, svc, reg) } if opts.ExternalDocs != nil { tag.ExternalDocs = &openapiExternalDocumentationObject{ Description: opts.ExternalDocs.Description, URL: opts.ExternalDocs.Url, } if reg.GetUseGoTemplate() { tag.ExternalDocs.Description = goTemplateComments(opts.ExternalDocs.Description, svc, reg) } } if opts.GetName() != "" { tag.Name = opts.GetName() } } tags = append(tags, tag) } return tags } // expandPathPatterns searches the URI parts for path parameters with pattern and when the pattern contains a sub-path, // it expands the pattern into the URI parts and adds the new path parameters to the pathParams slice. // // Parameters: // - pathParts: the URI parts parsed from the path template with `templateToParts` function // - pathParams: the path parameters of the service binding // // Returns: // // The modified pathParts and pathParams slice. func expandPathPatterns(pathParts []string, pathParams []descriptor.Parameter, reg *descriptor.Registry) ([]string, []descriptor.Parameter) { expandedPathParts := []string{} modifiedPathParams := pathParams for _, pathPart := range pathParts { if !strings.HasPrefix(pathPart, "{") || !strings.HasSuffix(pathPart, "}") { expandedPathParts = append(expandedPathParts, pathPart) continue } woBraces := pathPart[1 : len(pathPart)-1] paramPattern := strings.SplitN(woBraces, "=", 2) if len(paramPattern) != 2 { expandedPathParts = append(expandedPathParts, pathPart) continue } paramName := paramPattern[0] pattern := paramPattern[1] if pattern == "*" { expandedPathParts = append(expandedPathParts, pathPart) continue } pathParamIndex := slices.IndexFunc(modifiedPathParams, func(p descriptor.Parameter) bool { if !reg.GetUseJSONNamesForFields() { return p.FieldPath.String() == paramName } fieldPath := casing.JSONCamelCase(p.FieldPath.String()) return fieldPath == paramName }) if pathParamIndex == -1 { panic(fmt.Sprintf("Path parameter %q not found in path parameters", paramName)) } pathParam := modifiedPathParams[pathParamIndex] patternParts := strings.Split(pattern, "/") for _, patternPart := range patternParts { if patternPart != "*" { expandedPathParts = append(expandedPathParts, patternPart) continue } lastPart := expandedPathParts[len(expandedPathParts)-1] paramName := strings.TrimSuffix(lastPart, "s") if reg.GetUseJSONNamesForFields() { paramName = casing.JSONCamelCase(paramName) } expandedPathParts = append(expandedPathParts, "{"+paramName+"}") newParam := descriptor.Parameter{ Target: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String(paramName), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), }, Message: pathParam.Target.Message, FieldMessage: pathParam.Target.FieldMessage, ForcePrefixedName: pathParam.Target.ForcePrefixedName, }, FieldPath: []descriptor.FieldPathComponent{{ Name: paramName, Target: nil, }}, Method: nil, } modifiedPathParams = append(modifiedPathParams, newParam) if pathParamIndex != -1 { // the new parameter from the pattern replaces the old path parameter modifiedPathParams = append(modifiedPathParams[:pathParamIndex], modifiedPathParams[pathParamIndex+1:]...) pathParamIndex = -1 } } } return expandedPathParts, modifiedPathParams } func renderServices(services []*descriptor.Service, paths *openapiPathsObject, reg *descriptor.Registry, requestResponseRefs, customRefs refMap, msgs []*descriptor.Message, defs openapiDefinitionsObject) error { // Correctness of svcIdx and methIdx depends on 'services' containing the services in the same order as the 'file.Service' array. svcBaseIdx := 0 var lastFile *descriptor.File = nil for svcIdx, svc := range services { if svc.File != lastFile { lastFile = svc.File svcBaseIdx = svcIdx } if !isVisible(getServiceVisibilityOption(svc), reg) { continue } for methIdx, meth := range svc.Methods { if !isVisible(getMethodVisibilityOption(meth), reg) { continue } deprecated := reg.GetEnableRpcDeprecation() && meth.GetOptions().GetDeprecated() for bIdx, b := range meth.Bindings { operationFunc := operationForMethod(b.HTTPMethod) // Iterate over all the OpenAPI parameters parameters := openapiParametersObject{} // split the path template into its parts parts := templateToParts(b.PathTmpl.Template, reg, meth.RequestType.Fields, msgs) pathParams := b.PathParams if reg.GetExpandSlashedPathPatterns() { parts, pathParams = expandPathPatterns(parts, pathParams, reg) } // extract any constraints specified in the path placeholders into ECMA regular expressions pathParamRegexpMap := partsToRegexpMap(parts) // Keep track of path parameter overrides pathParamNames := make(map[string]string) for _, parameter := range pathParams { var paramType, paramFormat, desc, collectionFormat string var defaultValue interface{} var enumNames interface{} var items *openapiItemsObject var minItems *int var extensions []extension switch pt := parameter.Target.GetType(); pt { case descriptorpb.FieldDescriptorProto_TYPE_GROUP, descriptorpb.FieldDescriptorProto_TYPE_MESSAGE: if descriptor.IsWellKnownType(parameter.Target.GetTypeName()) { if parameter.IsRepeated() { return errors.New("only primitive and enum types are allowed in repeated path parameters") } schema := schemaOfField(parameter.Target, reg, customRefs) paramType = schema.Type paramFormat = schema.Format desc = schema.Description defaultValue = schema.Default extensions = schema.extensions } else { return errors.New("only primitive and well-known types are allowed in path parameters") } case descriptorpb.FieldDescriptorProto_TYPE_ENUM: enum, err := reg.LookupEnum("", parameter.Target.GetTypeName()) if err != nil { return err } paramType = "string" paramFormat = "" enumNames = listEnumNames(reg, enum) if reg.GetEnumsAsInts() { paramType = "integer" paramFormat = "" enumNames = listEnumNumbers(reg, enum) } schema := schemaOfField(parameter.Target, reg, customRefs) desc = schema.Description defaultValue = schema.Default extensions = schema.extensions default: var ok bool paramType, paramFormat, ok = primitiveSchema(pt) if !ok { return fmt.Errorf("unknown field type %v", pt) } schema := schemaOfField(parameter.Target, reg, customRefs) desc = schema.Description defaultValue = schema.Default extensions = schema.extensions // If there is no mandatory format based on the field, // allow it to be overridden by the user if paramFormat == "" { paramFormat = schema.Format } } if parameter.IsRepeated() { core := schemaCore{Type: paramType, Format: paramFormat} if parameter.IsEnum() { core.Enum = enumNames enumNames = nil } items = (*openapiItemsObject)(&openapiSchemaObject{schemaCore: core}) paramType = "array" paramFormat = "" collectionFormat = reg.GetRepeatedPathParamSeparatorName() minItems = new(int) *minItems = 1 } if desc == "" { desc = fieldProtoComments(reg, parameter.Target.Message, parameter.Target) } parameterString := parameter.String() if reg.GetUseJSONNamesForFields() { parameterString = lowerCamelCase(parameterString, meth.RequestType.Fields, msgs) } var pattern string if regExp, ok := pathParamRegexpMap[parameterString]; ok { pattern = regExp } fc := getFieldConfiguration(reg, parameter.Target) if fc != nil { pathParamName := fc.GetPathParamName() if pathParamName != "" && pathParamName != parameterString { pathParamNames["{"+parameterString+"}"] = "{" + pathParamName + "}" parameterString, _, _ = strings.Cut(pathParamName, "=") } } // verify if the parameter is deprecated, either via proto or annotation protoDeprecated := parameter.Target.GetOptions().GetDeprecated() && reg.GetEnableFieldDeprecation() annotationDeprecated := fc.GetDeprecated() deprecated := protoDeprecated || annotationDeprecated parameters = append(parameters, openapiParameterObject{ Name: parameterString, Description: desc, In: "path", Required: true, Deprecated: deprecated, Default: defaultValue, // Parameters in gRPC-Gateway can only be strings? Type: paramType, Format: paramFormat, Enum: enumNames, Items: items, CollectionFormat: collectionFormat, MinItems: minItems, Pattern: pattern, extensions: extensions, }) } // Now check if there is a body parameter if b.Body != nil { // Recursively render fields as definitions as long as they contain path parameters. // Special case for top level body if we don't have a body field. var schema openapiSchemaObject desc := "" var bodyFieldName string schema = openapiSchemaObject{ schemaCore: schemaCore{}, } if len(b.Body.FieldPath) == 0 { // No field for body, use type. bodyFieldName = "body" wknSchemaCore, isWkn := wktSchemas[meth.RequestType.FQMN()] if isWkn { schema.schemaCore = wknSchemaCore // Special workaround for Empty: it's well-known type but wknSchemas only returns schema.schemaCore; but we need to set schema.Properties which is a level higher. if meth.RequestType.FQMN() == ".google.protobuf.Empty" { schema.Properties = &openapiSchemaObjectProperties{} } } else { messageSchema, err := renderMessageAsDefinition(meth.RequestType, reg, customRefs, b.PathParams) if err != nil { return err } if len(b.PathParams) == 0 { if err := schema.setRefFromFQN(meth.RequestType.FQMN(), reg); err != nil { return err } desc = messageSchema.Description } else { if meth.Name != nil { methFQN, ok := fullyQualifiedNameToOpenAPIName(meth.FQMN(), reg) if !ok { panic(fmt.Errorf("failed to resolve method FQN: '%s'", meth.FQMN())) } defName := methFQN + "Body" schema.Ref = fmt.Sprintf("#/definitions/%s", defName) defs[defName] = messageSchema } else { schema = messageSchema if schema.Properties == nil || len(*schema.Properties) == 0 { grpclog.Warningf("created a body with 0 properties in the message, this might be unintended: %s", *meth.RequestType) } } } } } else { // Body field path is limited to one path component. From google.api.HttpRule.body: // "NOTE: the referred field must be present at the top-level of the request message type." // Ref: https://github.com/googleapis/googleapis/blob/b3397f5febbf21dfc69b875ddabaf76bee765058/google/api/http.proto#L350-L352 if len(b.Body.FieldPath) > 1 { return fmt.Errorf("body of request %q is not a top level field: '%v'", meth.Service.GetName(), b.Body.FieldPath) } bodyField := b.Body.FieldPath[0] if reg.GetUseJSONNamesForFields() { bodyFieldName = lowerCamelCase(bodyField.Name, meth.RequestType.Fields, msgs) } else { bodyFieldName = bodyField.Name } // Align pathParams with body field path. pathParams := subPathParams(bodyField.Name, b.PathParams) if len(pathParams) == 0 { // When there are no path parameters, we only need the base schema of the field. // https://github.com/grpc-ecosystem/grpc-gateway/issues/3058 schema = schemaOfFieldBase(bodyField.Target, reg, customRefs) } else { var err error schema, err = renderFieldAsDefinition(bodyField.Target, reg, customRefs, pathParams) if err != nil { return err } // renderFieldAsDefinition may add the body field name to the schema's required array // via updateSwaggerObjectFromFieldBehavior. However, for body parameters, the schema // represents the field's type, not the containing message. The body field name should // only be in the schema's required array if it's actually a property of the schema. // Remove the body field name from required if it's not a property to avoid invalid entries. if schema.Required != nil && schema.Properties != nil { // Build a set of property names propertyNames := make(map[string]bool) for _, prop := range *schema.Properties { propertyNames[prop.Key] = true } // Filter required array: keep field names that are either: // 1. Not the body field name, OR // 2. The body field name AND it's actually a property filteredRequired := make([]string, 0, len(schema.Required)) seenBodyFieldName := false for _, req := range schema.Required { if req == bodyFieldName { if propertyNames[req] { // It's a property, keep it (but only once) if !seenBodyFieldName { filteredRequired = append(filteredRequired, req) seenBodyFieldName = true } } // else: It's not a property, skip it } else { // Not the body field name, keep it filteredRequired = append(filteredRequired, req) } } schema.Required = filteredRequired } } if schema.Title != "" { desc = mergeDescription(schema) } else { desc = fieldProtoComments(reg, bodyField.Target.Message, bodyField.Target) } } if meth.GetClientStreaming() { desc += " (streaming inputs)" } parameters = append(parameters, openapiParameterObject{ Name: bodyFieldName, Description: desc, In: "body", Required: true, Schema: &schema, }) } // add the parameters to the query string queryParams, err := messageToQueryParameters(meth.RequestType, reg, b.PathParams, b.Body, b.HTTPMethod) if err != nil { return err } parameters = append(parameters, queryParams...) path := partsToOpenAPIPath(parts, pathParamNames) pathItemObject, ok := getPathItemObject(*paths, path) if !ok { pathItemObject = openapiPathItemObject{} } else { // handle case where we have an existing mapping for the same path and method existingOperationObject := operationFunc(&pathItemObject) if existingOperationObject != nil { var firstPathParameter *openapiParameterObject var firstParamIndex int for index, param := range parameters { param := param if param.In == "path" { firstPathParameter = ¶m firstParamIndex = index break } } if firstPathParameter == nil { // Without a path parameter, there is nothing to vary to support multiple mappings of the same path/method. // Previously this did not log an error and only overwrote the mapping, we now log the error but // still overwrite the mapping grpclog.Errorf("Duplicate mapping for path %s %s", b.HTTPMethod, path) } else { newPathCount := 0 var newPath string var newPathElement string // Iterate until there is not an existing operation that matches the same escaped path. // Most of the time this will only be a single iteration, but a large API could technically have // a pretty large amount of these if it used similar patterns for all its functions. for existingOperationObject != nil { newPathCount += 1 newPathElement = firstPathParameter.Name + pathParamUniqueSuffixDeliminator + strconv.Itoa(newPathCount) newPath = strings.ReplaceAll(path, "{"+firstPathParameter.Name+"}", "{"+newPathElement+"}") if newPathItemObject, ok := getPathItemObject(*paths, newPath); ok { existingOperationObject = operationFunc(&newPathItemObject) } else { existingOperationObject = nil } } // update the pathItemObject we are adding to with the new path pathItemObject, _ = getPathItemObject(*paths, newPath) firstPathParameter.Name = newPathElement path = newPath parameters[firstParamIndex] = *firstPathParameter } } } methProtoPath := protoPathIndex(reflect.TypeOf((*descriptorpb.ServiceDescriptorProto)(nil)), "Method") desc := "A successful response." var responseSchema openapiSchemaObject if b.ResponseBody == nil || len(b.ResponseBody.FieldPath) == 0 { responseSchema = openapiSchemaObject{ schemaCore: schemaCore{}, } // Don't link to a full definition for // empty; it's overly verbose. // schema.Properties{} renders it as // well, without a definition wknSchemaCore, isWkn := wktSchemas[meth.ResponseType.FQMN()] if !isWkn { if err := responseSchema.setRefFromFQN(meth.ResponseType.FQMN(), reg); err != nil { return err } } else { responseSchema.schemaCore = wknSchemaCore // Special workaround for Empty: it's well-known type but wknSchemas only returns schema.schemaCore; but we need to set schema.Properties which is a level higher. if meth.ResponseType.FQMN() == ".google.protobuf.Empty" { responseSchema.Properties = &openapiSchemaObjectProperties{} } } } else { // This is resolving the value of response_body in the google.api.HttpRule lastField := b.ResponseBody.FieldPath[len(b.ResponseBody.FieldPath)-1] responseSchema = schemaOfField(lastField.Target, reg, customRefs) if responseSchema.Description != "" { desc = responseSchema.Description } else { desc = fieldProtoComments(reg, lastField.Target.Message, lastField.Target) } } if meth.GetServerStreaming() { desc += "(streaming responses)" responseSchema.Type = "object" swgRef, _ := fullyQualifiedNameToOpenAPIName(meth.ResponseType.FQMN(), reg) responseSchema.Title = "Stream result of " + swgRef props := openapiSchemaObjectProperties{ keyVal{ Key: "result", Value: openapiSchemaObject{ schemaCore: schemaCore{ Ref: responseSchema.Ref, }, }, }, } if !reg.GetDisableDefaultErrors() { statusDef, hasStatus := fullyQualifiedNameToOpenAPIName(".google.rpc.Status", reg) if hasStatus { props = append(props, keyVal{ Key: "error", Value: openapiSchemaObject{ schemaCore: schemaCore{ Ref: fmt.Sprintf("#/definitions/%s", statusDef), }, }, }) } } // Special case HttpBody responses, they will be unformatted bytes if meth.ResponseType.FQMN() == ".google.api.HttpBody" { responseSchema.Type = "string" responseSchema.Format = "binary" responseSchema.Title = "Free form byte stream" // The error response is still JSON, but technically the full response // is still unformatted, so don't include the error response structure. props = nil } responseSchema.Properties = &props responseSchema.Ref = "" } operationObject := &openapiOperationObject{ Parameters: parameters, Responses: openapiResponsesObject{}, Deprecated: deprecated, } if !reg.GetDisableDefaultResponses() { operationObject.Responses["200"] = openapiResponseObject{ Description: desc, Schema: responseSchema, Headers: openapiHeadersObject{}, } } if !reg.GetDisableServiceTags() { tag := svc.GetName() if pkg := svc.File.GetPackage(); pkg != "" && reg.IsIncludePackageInTags() { tag = pkg + "." + tag } operationObject.Tags = []string{tag} } if !reg.GetDisableDefaultErrors() { errDef, hasErrDef := fullyQualifiedNameToOpenAPIName(".google.rpc.Status", reg) if hasErrDef { // https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#responses-object operationObject.Responses["default"] = openapiResponseObject{ Description: "An unexpected error response.", Schema: openapiSchemaObject{ schemaCore: schemaCore{ Ref: fmt.Sprintf("#/definitions/%s", errDef), }, }, } } } operationObject.OperationID = fmt.Sprintf("%s_%s", svc.GetName(), meth.GetName()) if reg.GetSimpleOperationIDs() { operationObject.OperationID = meth.GetName() } if bIdx != 0 { // OperationID must be unique in an OpenAPI v2 definition. operationObject.OperationID += strconv.Itoa(bIdx + 1) } // Fill reference map with referenced request messages for _, param := range operationObject.Parameters { if param.Schema != nil && param.Schema.Ref != "" { requestResponseRefs[param.Schema.Ref] = struct{}{} } } methComments := protoComments(reg, svc.File, nil, "Service", int32(svcIdx-svcBaseIdx), methProtoPath, int32(methIdx)) if err := updateOpenAPIDataFromComments(reg, operationObject, meth, methComments, false); err != nil { panic(err) } svcOpts, err := getServiceOpenAPIOption(reg, svc) if err != nil { grpclog.Error(err) return err } // Set Tag with the user-defined service name if svcOpts.GetName() != "" { operationObject.Tags = []string{svcOpts.GetName()} } opts, err := getMethodOpenAPIOption(reg, meth) if opts != nil { if err != nil { panic(err) } operationObject.ExternalDocs = protoExternalDocumentationToOpenAPIExternalDocumentation(opts.ExternalDocs, reg, meth) if opts.Deprecated { operationObject.Deprecated = true } if opts.Summary != "" { operationObject.Summary = opts.Summary } if opts.Description != "" { operationObject.Description = opts.Description } if len(opts.Tags) > 0 { operationObject.Tags = make([]string, len(opts.Tags)) copy(operationObject.Tags, opts.Tags) } if opts.OperationId != "" { operationObject.OperationID = opts.OperationId } if opts.Security != nil { newSecurity := []openapiSecurityRequirementObject{} if operationObject.Security != nil { newSecurity = *operationObject.Security } for _, secReq := range opts.Security { newSecReq := openapiSecurityRequirementObject{} for secReqKey, secReqValue := range secReq.SecurityRequirement { if secReqValue == nil { continue } newSecReqValue := make([]string, len(secReqValue.Scope)) copy(newSecReqValue, secReqValue.Scope) newSecReq[secReqKey] = newSecReqValue } if len(newSecReq) > 0 { newSecurity = append(newSecurity, newSecReq) } } operationObject.Security = &newSecurity } if opts.Responses != nil { for name, resp := range opts.Responses { // Merge response data into default response if available. respObj := operationObject.Responses[name] if resp.Description != "" { respObj.Description = resp.Description } if resp.Schema != nil { respObj.Schema = openapiSchemaFromProtoSchema(resp.Schema, reg, customRefs, meth) } if resp.Examples != nil { respObj.Examples = openapiExamplesFromProtoExamples(resp.Examples) } if resp.Headers != nil { hdrs, err := processHeaders(resp.Headers) if err != nil { return err } respObj.Headers = hdrs } if resp.Extensions != nil { exts, err := processExtensions(resp.Extensions) if err != nil { return err } respObj.extensions = exts } operationObject.Responses[name] = respObj } } if opts.Extensions != nil { exts, err := processExtensions(opts.Extensions) if err != nil { return err } operationObject.extensions = exts } if len(opts.Consumes) > 0 { operationObject.Consumes = make([]string, len(opts.Consumes)) copy(operationObject.Consumes, opts.Consumes) } if len(opts.Produces) > 0 { operationObject.Produces = make([]string, len(opts.Produces)) copy(operationObject.Produces, opts.Produces) } if params := opts.Parameters; params != nil && len(params.Headers) > 0 { for _, header := range params.Headers { param := openapiParameterObject{ In: "header", Name: header.Name, Description: header.Description, Required: header.Required, Format: header.Format, } switch header.Type { case openapi_options.HeaderParameter_STRING: param.Type = "string" case openapi_options.HeaderParameter_NUMBER: param.Type = "number" case openapi_options.HeaderParameter_INTEGER: param.Type = "integer" case openapi_options.HeaderParameter_BOOLEAN: param.Type = "boolean" default: return fmt.Errorf("invalid header parameter type: %+v", header.Type) } operationObject.Parameters = append(operationObject.Parameters, param) } } // TODO(ivucica): add remaining fields of operation object } switch b.HTTPMethod { case "DELETE": pathItemObject.Delete = operationObject case "GET": pathItemObject.Get = operationObject case "POST": pathItemObject.Post = operationObject case "PUT": pathItemObject.Put = operationObject case "PATCH": pathItemObject.Patch = operationObject case "HEAD": pathItemObject.Head = operationObject case "OPTIONS": pathItemObject.Options = operationObject } updatePaths(paths, path, pathItemObject) } } } // Success! return nil on the error object return nil } // Returns the openapiPathItemObject associated with a path. If path is not present, returns // empty openapiPathItemObject and false. func getPathItemObject(paths openapiPathsObject, path string) (openapiPathItemObject, bool) { for _, pathData := range paths { if pathData.Path == path { return pathData.PathItemObject, true } } return openapiPathItemObject{}, false } // If a path already exists in openapiPathsObject, updates that path's openapiPathItemObject. If not, // appends a new path and openapiPathItemObject to the openapiPathsObject. func updatePaths(paths *openapiPathsObject, path string, pathItemObject openapiPathItemObject) { for i, p := range *paths { if p.Path == path { (*paths)[i].PathItemObject = pathItemObject return } } *paths = append(*paths, pathData{ Path: path, PathItemObject: pathItemObject, }) } func mergeDescription(schema openapiSchemaObject) string { desc := schema.Description if schema.Title != "" { // join title because title of parameter object will be ignored desc = strings.TrimSpace(schema.Title + paragraphDeliminator + schema.Description) } return desc } func operationForMethod(httpMethod string) func(*openapiPathItemObject) *openapiOperationObject { switch httpMethod { case "GET": return func(obj *openapiPathItemObject) *openapiOperationObject { return obj.Get } case "POST": return func(obj *openapiPathItemObject) *openapiOperationObject { return obj.Post } case "PUT": return func(obj *openapiPathItemObject) *openapiOperationObject { return obj.Put } case "DELETE": return func(obj *openapiPathItemObject) *openapiOperationObject { return obj.Delete } case "PATCH": return func(obj *openapiPathItemObject) *openapiOperationObject { return obj.Patch } case "HEAD": return func(obj *openapiPathItemObject) *openapiOperationObject { return obj.Head } case "OPTIONS": return func(obj *openapiPathItemObject) *openapiOperationObject { return obj.Options } default: return func(obj *openapiPathItemObject) *openapiOperationObject { return nil } } } // This function is called with a param which contains the entire definition of a method. func applyTemplate(p param) (*openapiSwaggerObject, error) { // Create the basic template object. This is the object that everything is // defined off of. s := openapiSwaggerObject{ // OpenAPI 2.0 is the version of this document Swagger: "2.0", Consumes: []string{"application/json"}, Produces: []string{"application/json"}, Paths: openapiPathsObject{}, Definitions: make(openapiDefinitionsObject), Info: openapiInfoObject{ Title: *p.File.Name, Version: "version not set", }, } // IMPORTANT: Initialize the naming cache BEFORE any code that uses fullyQualifiedNameToOpenAPIName. // This ensures consistent naming between renderServices (which generates $refs) and // renderMessagesAsDefinition (which generates definitions). // // Pre-scan to collect referenced names WITHOUT using the naming cache. // This allows us to build the cache with the correct filtered names upfront. referencedNames := collectReferencedNamesForCache(p.Services, p.Messages, p.reg) // Get all names from the registry allFQMNs := p.reg.GetAllFQMNs() allFQENs := p.reg.GetAllFQENs() allFQMethNs := p.reg.GetAllFQMethNs() allNames := append(append(allFQMNs, allFQENs...), allFQMethNs...) // Filter: EXCLUDE names that are from a DIFFERENT package AND are NOT referenced // This way we keep all names from the current package, and all referenced names from other packages currentPackage := p.File.GetPackage() filteredNames := make([]string, 0, len(allNames)) for _, name := range allNames { trimmedName := strings.TrimPrefix(name, ".") if trimmedName == "" { continue } // Include if: (1) from current package, OR (2) actually referenced, OR (3) from google.*/grpc.* packages isCurrentPackage := strings.HasPrefix(trimmedName, currentPackage+".") isGoogle := strings.HasPrefix(trimmedName, "google.") isGRPC := strings.HasPrefix(trimmedName, "grpc.") if isCurrentPackage || referencedNames[name] || isGoogle || isGRPC { filteredNames = append(filteredNames, name) } } // Initialize the naming cache BEFORE renderServices so all lookups use consistent naming registriesSeenMutex.Lock() resolvedNames := resolveFullyQualifiedNameToOpenAPINames(filteredNames, p.reg.GetOpenAPINamingStrategy()) registriesSeen[p.reg] = resolvedNames registriesSeenMutex.Unlock() // Loops through all the services and their exposed GET/POST/PUT/DELETE definitions // and create entries for all of them. // Also adds custom user specified references to second map. // NOTE: This now uses the naming cache initialized above. requestResponseRefs, customRefs := refMap{}, refMap{} if err := renderServices(p.Services, &s.Paths, p.reg, requestResponseRefs, customRefs, p.Messages, s.Definitions); err != nil { panic(err) } messages := messageMap{} streamingMessages := messageMap{} enums := enumMap{} if !p.reg.GetDisableDefaultErrors() { // Add the error type to the message map runtimeError, swgRef, err := lookupMsgAndOpenAPIName("google.rpc", "Status", p.reg) if err == nil { messages[swgRef] = runtimeError } else { // just in case there is an error looking up runtimeError grpclog.Error(err) } } // Find all the service's messages and enumerations that are defined (recursively) // and write request, response and other custom (but referenced) types out as definition objects. // NOTE: This uses the same naming cache that was used by renderServices above. findServicesMessagesAndEnumerations(p.Services, p.reg, messages, streamingMessages, enums, requestResponseRefs) if err := renderMessagesAsDefinition(messages, s.Definitions, p.reg, customRefs, nil); err != nil { return nil, err } renderEnumerationsAsDefinition(enums, s.Definitions, p.reg, requestResponseRefs) // File itself might have some comments and metadata. packageProtoPath := protoPathIndex(reflect.TypeOf((*descriptorpb.FileDescriptorProto)(nil)), "Package") packageComments := protoComments(p.reg, p.File, nil, "Package", packageProtoPath) if err := updateOpenAPIDataFromComments(p.reg, &s, p, packageComments, true); err != nil { return nil, err } // There may be additional options in the OpenAPI option in the proto. spb, err := getFileOpenAPIOption(p.reg, p.File) if err != nil { return nil, err } if spb != nil { if spb.Swagger != "" { s.Swagger = spb.Swagger } if spb.Info != nil { if spb.Info.Title != "" { s.Info.Title = spb.Info.Title } if spb.Info.Description != "" { s.Info.Description = spb.Info.Description } if spb.Info.TermsOfService != "" { s.Info.TermsOfService = spb.Info.TermsOfService } if spb.Info.Version != "" { s.Info.Version = spb.Info.Version } if spb.Info.Contact != nil { if s.Info.Contact == nil { s.Info.Contact = &openapiContactObject{} } if spb.Info.Contact.Name != "" { s.Info.Contact.Name = spb.Info.Contact.Name } if spb.Info.Contact.Url != "" { s.Info.Contact.URL = spb.Info.Contact.Url } if spb.Info.Contact.Email != "" { s.Info.Contact.Email = spb.Info.Contact.Email } } if spb.Info.License != nil { if s.Info.License == nil { s.Info.License = &openapiLicenseObject{} } if spb.Info.License.Name != "" { s.Info.License.Name = spb.Info.License.Name } if spb.Info.License.Url != "" { s.Info.License.URL = spb.Info.License.Url } } if spb.Info.Extensions != nil { exts, err := processExtensions(spb.Info.Extensions) if err != nil { return nil, err } s.Info.extensions = exts } } if spb.Host != "" { s.Host = spb.Host } if spb.BasePath != "" { s.BasePath = spb.BasePath } if len(spb.Schemes) > 0 { s.Schemes = make([]string, len(spb.Schemes)) for i, scheme := range spb.Schemes { s.Schemes[i] = strings.ToLower(scheme.String()) } } if len(spb.Consumes) > 0 { s.Consumes = make([]string, len(spb.Consumes)) copy(s.Consumes, spb.Consumes) } if len(spb.Produces) > 0 { s.Produces = make([]string, len(spb.Produces)) copy(s.Produces, spb.Produces) } if spb.SecurityDefinitions != nil && spb.SecurityDefinitions.Security != nil { if s.SecurityDefinitions == nil { s.SecurityDefinitions = openapiSecurityDefinitionsObject{} } for secDefKey, secDefValue := range spb.SecurityDefinitions.Security { var newSecDefValue openapiSecuritySchemeObject if oldSecDefValue, ok := s.SecurityDefinitions[secDefKey]; !ok { newSecDefValue = openapiSecuritySchemeObject{} } else { newSecDefValue = oldSecDefValue } if secDefValue.Type != openapi_options.SecurityScheme_TYPE_INVALID { switch secDefValue.Type { case openapi_options.SecurityScheme_TYPE_BASIC: newSecDefValue.Type = "basic" case openapi_options.SecurityScheme_TYPE_API_KEY: newSecDefValue.Type = "apiKey" case openapi_options.SecurityScheme_TYPE_OAUTH2: newSecDefValue.Type = "oauth2" } } if secDefValue.Description != "" { newSecDefValue.Description = secDefValue.Description } if secDefValue.Name != "" { newSecDefValue.Name = secDefValue.Name } if secDefValue.In != openapi_options.SecurityScheme_IN_INVALID { switch secDefValue.In { case openapi_options.SecurityScheme_IN_QUERY: newSecDefValue.In = "query" case openapi_options.SecurityScheme_IN_HEADER: newSecDefValue.In = "header" } } if secDefValue.Flow != openapi_options.SecurityScheme_FLOW_INVALID { switch secDefValue.Flow { case openapi_options.SecurityScheme_FLOW_IMPLICIT: newSecDefValue.Flow = "implicit" case openapi_options.SecurityScheme_FLOW_PASSWORD: newSecDefValue.Flow = "password" case openapi_options.SecurityScheme_FLOW_APPLICATION: newSecDefValue.Flow = "application" case openapi_options.SecurityScheme_FLOW_ACCESS_CODE: newSecDefValue.Flow = "accessCode" } } if secDefValue.AuthorizationUrl != "" { newSecDefValue.AuthorizationURL = secDefValue.AuthorizationUrl } if secDefValue.TokenUrl != "" { newSecDefValue.TokenURL = secDefValue.TokenUrl } if secDefValue.Scopes != nil { if newSecDefValue.Scopes == nil { newSecDefValue.Scopes = openapiScopesObject{} } for scopeKey, scopeDesc := range secDefValue.Scopes.Scope { newSecDefValue.Scopes[scopeKey] = scopeDesc } } if secDefValue.Extensions != nil { exts, err := processExtensions(secDefValue.Extensions) if err != nil { return nil, err } newSecDefValue.extensions = exts } s.SecurityDefinitions[secDefKey] = newSecDefValue } } if spb.Security != nil { var newSecurity []openapiSecurityRequirementObject if s.Security != nil { newSecurity = s.Security } for _, secReq := range spb.Security { newSecReq := openapiSecurityRequirementObject{} for secReqKey, secReqValue := range secReq.SecurityRequirement { if secReqValue == nil { return nil, fmt.Errorf("malformed security requirement spec for key %q; value is required", secReqKey) } newSecReqValue := make([]string, len(secReqValue.Scope)) copy(newSecReqValue, secReqValue.Scope) newSecReq[secReqKey] = newSecReqValue } newSecurity = append(newSecurity, newSecReq) } s.Security = newSecurity } s.ExternalDocs = protoExternalDocumentationToOpenAPIExternalDocumentation(spb.ExternalDocs, p.reg, spb) // Populate all Paths with Responses set at top level, // preferring Responses already set over those at the top level. if spb.Responses != nil { for _, verbs := range s.Paths { var maps []openapiResponsesObject if verbs.PathItemObject.Delete != nil { maps = append(maps, verbs.PathItemObject.Delete.Responses) } if verbs.PathItemObject.Get != nil { maps = append(maps, verbs.PathItemObject.Get.Responses) } if verbs.PathItemObject.Post != nil { maps = append(maps, verbs.PathItemObject.Post.Responses) } if verbs.PathItemObject.Put != nil { maps = append(maps, verbs.PathItemObject.Put.Responses) } if verbs.PathItemObject.Patch != nil { maps = append(maps, verbs.PathItemObject.Patch.Responses) } for k, v := range spb.Responses { for _, respMap := range maps { if _, ok := respMap[k]; ok { // Don't overwrite already existing Responses continue } respMap[k] = openapiResponseObject{ Description: v.Description, Schema: openapiSchemaFromProtoSchema(v.Schema, p.reg, customRefs, nil), Examples: openapiExamplesFromProtoExamples(v.Examples), } } } } } if spb.Extensions != nil { exts, err := processExtensions(spb.Extensions) if err != nil { return nil, err } s.extensions = exts } if spb.Tags != nil { for _, v := range spb.Tags { newTag := openapiTagObject{} newTag.Name = v.Name newTag.Description = v.Description if p.reg.GetUseGoTemplate() { newTag.Description = goTemplateComments(newTag.Description, nil, p.reg) } if v.ExternalDocs != nil { newTag.ExternalDocs = &openapiExternalDocumentationObject{ Description: v.ExternalDocs.Description, URL: v.ExternalDocs.Url, } if p.reg.GetUseGoTemplate() { newTag.ExternalDocs.Description = goTemplateComments(v.ExternalDocs.Description, nil, p.reg) } } if v.Extensions != nil { exts, err := processExtensions(v.Extensions) if err != nil { return nil, err } newTag.extensions = exts } s.Tags = append(s.Tags, newTag) } } // Additional fields on the OpenAPI v2 spec's "OpenAPI" object // should be added here, once supported in the proto. } if !p.reg.GetDisableServiceTags() { s.Tags = mergeTags(s.Tags, renderServiceTags(p.Services, p.reg)) } // Finally add any references added by users that aren't // otherwise rendered. if err := addCustomRefs(s.Definitions, p.reg, customRefs); err != nil { return nil, err } return &s, nil } func mergeTags(existingTags []openapiTagObject, tags []openapiTagObject) []openapiTagObject { for _, tag := range tags { matched := false for i, existingTag := range existingTags { if existingTag.Name == tag.Name { if existingTag.Description == "" { existingTags[i].Description = tag.Description } if existingTag.ExternalDocs == nil { existingTags[i].ExternalDocs = tag.ExternalDocs } else if tag.ExternalDocs != nil { if existingTag.ExternalDocs.Description == "" { existingTags[i].ExternalDocs.Description = tag.ExternalDocs.Description } if existingTag.ExternalDocs.URL == "" { existingTags[i].ExternalDocs.URL = tag.ExternalDocs.URL } } if existingTag.extensions == nil { existingTags[i].extensions = tag.extensions } else if tag.extensions != nil { for _, ext := range tag.extensions { matchedExt := false for _, existingExt := range existingTag.extensions { if existingExt.key == ext.key { matchedExt = true break } } if !matchedExt { existingTags[i].extensions = append(existingTags[i].extensions, ext) } } } matched = true break } } if !matched { existingTags = append(existingTags, tag) } } return existingTags } func processExtensions(inputExts map[string]*structpb.Value) ([]extension, error) { exts := make([]extension, 0, len(inputExts)) for k, v := range inputExts { if !strings.HasPrefix(k, "x-") { return nil, fmt.Errorf("extension keys need to start with \"x-\": %q", k) } ext, err := (&protojson.MarshalOptions{Indent: " "}).Marshal(v) if err != nil { return nil, err } exts = append(exts, extension{key: k, value: ext}) } sort.Slice(exts, func(i, j int) bool { return exts[i].key < exts[j].key }) return exts, nil } func validateHeaderTypeAndFormat(headerType, format string) error { // The type of the object. The value MUST be one of "string", "number", "integer", "boolean", or "array" // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#headerObject // Note: currently not implementing array as we are only implementing this in the operation response context switch headerType { // the format property is an open string-valued property, and can have any value to support documentation needs // primary check for format is to ensure that the number/integer formats are extensions of the specified type // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#dataTypeFormat case "string": return nil case "number": switch format { case "uint", "uint8", "uint16", "uint32", "uint64", "int", "int8", "int16", "int32", "int64", "float", "float32", "float64", "complex64", "complex128", "double", "byte", "rune", "uintptr", "": return nil default: return fmt.Errorf("the provided format %q is not a valid extension of the type %q", format, headerType) } case "integer": switch format { case "uint", "uint8", "uint16", "uint32", "uint64", "int", "int8", "int16", "int32", "int64", "": return nil default: return fmt.Errorf("the provided format %q is not a valid extension of the type %q", format, headerType) } case "boolean": return nil } return fmt.Errorf("the provided header type %q is not supported", headerType) } func validateDefaultValueTypeAndFormat(headerType string, defaultValue string, format string) error { switch headerType { case "string": if !isQuotedString(defaultValue) { return fmt.Errorf("the provided default value %q does not match provider type %q, or is not properly quoted with escaped quotations", defaultValue, headerType) } switch format { case "date-time": unquoteTime := strings.Trim(defaultValue, `"`) if _, err := time.Parse(time.RFC3339, unquoteTime); err != nil { return fmt.Errorf("the provided default value %q is not a valid RFC3339 date-time string", defaultValue) } case "date": const layoutRFC3339Date = "2006-01-02" unquoteDate := strings.Trim(defaultValue, `"`) if _, err := time.Parse(layoutRFC3339Date, unquoteDate); err != nil { return fmt.Errorf("the provided default value %q is not a valid RFC3339 date-time string", defaultValue) } } case "number": if err := isJSONNumber(defaultValue, headerType); err != nil { return err } case "integer": switch format { case "int32": if _, err := strconv.ParseInt(defaultValue, 0, 32); err != nil { return fmt.Errorf("the provided default value %q does not match provided format %q", defaultValue, format) } case "uint32": if _, err := strconv.ParseUint(defaultValue, 0, 32); err != nil { return fmt.Errorf("the provided default value %q does not match provided format %q", defaultValue, format) } case "int64": if _, err := strconv.ParseInt(defaultValue, 0, 64); err != nil { return fmt.Errorf("the provided default value %q does not match provided format %q", defaultValue, format) } case "uint64": if _, err := strconv.ParseUint(defaultValue, 0, 64); err != nil { return fmt.Errorf("the provided default value %q does not match provided format %q", defaultValue, format) } default: if _, err := strconv.ParseInt(defaultValue, 0, 64); err != nil { return fmt.Errorf("the provided default value %q does not match provided type %q", defaultValue, headerType) } } case "boolean": if !isBool(defaultValue) { return fmt.Errorf("the provided default value %q does not match provider type %q", defaultValue, headerType) } } return nil } func isQuotedString(s string) bool { return len(s) >= 2 && s[0] == '"' && s[len(s)-1] == '"' } func isJSONNumber(s string, t string) error { val, err := strconv.ParseFloat(s, 64) if err != nil { return fmt.Errorf("the provided default value %q does not match provider type %q", s, t) } // Floating point values that cannot be represented as sequences of digits (such as Infinity and NaN) are not permitted. // See: https://tools.ietf.org/html/rfc4627#section-2.4 if math.IsInf(val, 0) || math.IsNaN(val) { return fmt.Errorf("the provided number %q is not a valid JSON number", s) } return nil } func isBool(s string) bool { // Unable to use strconv.ParseBool because it returns truthy values https://golang.org/pkg/strconv/#example_ParseBool // per https://swagger.io/specification/v2/#data-types // type: boolean represents two values: true and false. Note that truthy and falsy values such as "true", "", 0 or null are not considered boolean values. return s == "true" || s == "false" } func processHeaders(inputHdrs map[string]*openapi_options.Header) (openapiHeadersObject, error) { hdrs := make(map[string]openapiHeaderObject, len(inputHdrs)) for k, v := range inputHdrs { header := textproto.CanonicalMIMEHeaderKey(k) ret := openapiHeaderObject{ Description: v.Description, Format: v.Format, Pattern: v.Pattern, } if err := validateHeaderTypeAndFormat(v.Type, v.Format); err != nil { return nil, err } ret.Type = v.Type if v.Default != "" { if err := validateDefaultValueTypeAndFormat(v.Type, v.Default, v.Format); err != nil { return nil, err } ret.Default = RawExample(v.Default) } hdrs[header] = ret } return hdrs, nil } func removeInternalComments(comment string) string { c := []string{} for len(comment) > 0 { open := strings.SplitN(comment, "(--", 2) if len(open) == 1 { c = append(c, open[0]) break } ex := strings.TrimRight(open[0], " \t") // Trim only one line prior to all spaces switch { case strings.HasSuffix(ex, "\r\n"): ex = strings.TrimSuffix(ex, "\r\n") case strings.HasSuffix(ex, "\n"): ex = strings.TrimSuffix(ex, "\n") } if ex != "" { c = append(c, ex) } comment = open[1] close := strings.SplitN(comment, "--)", 2) if len(close) > 1 { comment = close[1] } else { break } } return strings.Join(c, "") } // updateOpenAPIDataFromComments updates a OpenAPI object based on a comment // from the proto file. // // First paragraph of a comment is used for summary. Remaining paragraphs of // a comment are used for description. If 'Summary' field is not present on // the passed swaggerObject, the summary and description are joined by \n\n. // // If there is a field named 'Info', its 'Summary' and 'Description' fields // will be updated instead. // // If there is no 'Summary', the same behavior will be attempted on 'Title', // but only if the last character is not a period. func updateOpenAPIDataFromComments(reg *descriptor.Registry, swaggerObject interface{}, data interface{}, comment string, isPackageObject bool) error { if len(comment) == 0 { return nil } // Checks whether the "ignore_comments" flag is set to true if reg.GetIgnoreComments() { return nil } // Checks whether the "remove_internal_comments" flag is set to true if reg.GetRemoveInternalComments() { comment = removeInternalComments(comment) } // Checks whether the "use_go_templates" flag is set to true if reg.GetUseGoTemplate() { comment = goTemplateComments(comment, data, reg) } // Figure out what to apply changes to. swaggerObjectValue := reflect.ValueOf(swaggerObject) infoObjectValue := swaggerObjectValue.Elem().FieldByName("Info") if !infoObjectValue.CanSet() { // No such field? Apply summary and description directly to // passed object. infoObjectValue = swaggerObjectValue.Elem() } // Figure out which properties to update. summaryValue := infoObjectValue.FieldByName("Summary") descriptionValue := infoObjectValue.FieldByName("Description") readOnlyValue := infoObjectValue.FieldByName("ReadOnly") if readOnlyValue.Kind() == reflect.Bool && readOnlyValue.CanSet() && strings.Contains(comment, "Output only.") { readOnlyValue.Set(reflect.ValueOf(true)) } usingTitle := false if !summaryValue.CanSet() { summaryValue = infoObjectValue.FieldByName("Title") usingTitle = true } paragraphs := strings.Split(comment, paragraphDeliminator) // If there is a summary (or summary-equivalent) and it's empty, use the first // paragraph as summary, and the rest as description. if summaryValue.CanSet() { summary := strings.TrimSpace(paragraphs[0]) description := strings.TrimSpace(strings.Join(paragraphs[1:], paragraphDeliminator)) if !usingTitle || (len(summary) > 0 && summary[len(summary)-1] != '.') { // overrides the schema value only if it's empty // keep the comment precedence when updating the package definition if summaryValue.Len() == 0 || isPackageObject { summaryValue.Set(reflect.ValueOf(summary)) } if len(description) > 0 { if !descriptionValue.CanSet() { return errors.New("encountered object type with a summary, but no description") } // overrides the schema value only if it's empty // keep the comment precedence when updating the package definition if descriptionValue.Len() == 0 || isPackageObject { descriptionValue.Set(reflect.ValueOf(description)) } } return nil } } // There was no summary field on the swaggerObject. Try to apply the // whole comment into description if the OpenAPI object description is empty. if descriptionValue.CanSet() { if descriptionValue.Len() == 0 || isPackageObject { descriptionValue.Set(reflect.ValueOf(strings.Join(paragraphs, paragraphDeliminator))) } return nil } return errors.New("no description nor summary property") } func fieldProtoComments(reg *descriptor.Registry, msg *descriptor.Message, field *descriptor.Field) string { protoPath := protoPathIndex(reflect.TypeOf((*descriptorpb.DescriptorProto)(nil)), "Field") for i, f := range msg.Fields { if f == field { return protoComments(reg, msg.File, msg.Outers, "MessageType", int32(msg.Index), protoPath, int32(i)) } } return "" } func enumValueProtoComments(reg *descriptor.Registry, enum *descriptor.Enum) string { protoPath := protoPathIndex(reflect.TypeOf((*descriptorpb.EnumDescriptorProto)(nil)), "Value") var comments []string for idx, value := range enum.GetValue() { if reg.GetOmitEnumDefaultValue() && value.GetNumber() == 0 { continue } if !isVisible(getEnumValueVisibilityOption(value), reg) { continue } name := value.GetName() if reg.GetEnumsAsInts() { name = strconv.Itoa(int(value.GetNumber())) } if str := protoComments(reg, enum.File, enum.Outers, "EnumType", int32(enum.Index), protoPath, int32(idx)); str != "" { comments = append(comments, name+": "+str) } } if len(comments) > 0 { return "- " + strings.Join(comments, "\n - ") } return "" } func protoComments(reg *descriptor.Registry, file *descriptor.File, outers []string, typeName string, typeIndex int32, fieldPaths ...int32) string { if file.SourceCodeInfo == nil { fmt.Fprintln(os.Stderr, file.GetName(), "descriptor.File should not contain nil SourceCodeInfo") return "" } outerPaths := make([]int32, len(outers)) for i := range outers { location := "" if file.Package != nil { location = file.GetPackage() } msg, err := reg.LookupMsg(location, strings.Join(outers[:i+1], ".")) if err != nil { panic(err) } outerPaths[i] = int32(msg.Index) } for _, loc := range file.SourceCodeInfo.Location { if !isProtoPathMatches(loc.Path, outerPaths, typeName, typeIndex, fieldPaths) { continue } comments := "" if loc.LeadingComments != nil { comments = strings.TrimRight(*loc.LeadingComments, "\n") comments = strings.TrimSpace(comments) // TODO(ivucica): this is a hack to fix "// " being interpreted as "//". // perhaps we should: // - split by \n // - determine if every (but first and last) line begins with " " // - trim every line only if that is the case // - join by \n comments = strings.ReplaceAll(comments, "\n ", "\n") comments = removeInternalComments(comments) } if loc.TrailingComments != nil { trailing := strings.TrimSpace(*loc.TrailingComments) if comments == "" { comments = trailing } else { comments += "\n\n" + trailing } } return comments } return "" } func goTemplateComments(comment string, data interface{}, reg *descriptor.Registry) string { var temp bytes.Buffer tpl, err := template.New("").Funcs(template.FuncMap{ // Allows importing documentation from a file "import": func(name string) string { file, err := os.ReadFile(name) if err != nil { return err.Error() } // Runs template over imported file return goTemplateComments(string(file), data, reg) }, // Grabs title and description from a field "fieldcomments": func(msg *descriptor.Message, field *descriptor.Field) string { return strings.ReplaceAll(fieldProtoComments(reg, msg, field), "\n", "
") }, "arg": func(name string) string { if v, f := reg.GetGoTemplateArgs()[name]; f { return v } return fmt.Sprintf("goTemplateArg %s not found", name) }, }).Parse(comment) if err != nil { // If there is an error parsing the templating insert the error as string in the comment // to make it easier to debug the template error return err.Error() } if err := tpl.Execute(&temp, data); err != nil { // If there is an error executing the templating insert the error as string in the comment // to make it easier to debug the error return err.Error() } return temp.String() } var ( messageProtoPath = protoPathIndex(reflect.TypeOf((*descriptorpb.FileDescriptorProto)(nil)), "MessageType") nestedProtoPath = protoPathIndex(reflect.TypeOf((*descriptorpb.DescriptorProto)(nil)), "NestedType") packageProtoPath = protoPathIndex(reflect.TypeOf((*descriptorpb.FileDescriptorProto)(nil)), "Package") serviceProtoPath = protoPathIndex(reflect.TypeOf((*descriptorpb.FileDescriptorProto)(nil)), "Service") methodProtoPath = protoPathIndex(reflect.TypeOf((*descriptorpb.ServiceDescriptorProto)(nil)), "Method") ) func isProtoPathMatches(paths []int32, outerPaths []int32, typeName string, typeIndex int32, fieldPaths []int32) bool { if typeName == "Package" && typeIndex == packageProtoPath { // path for package comments is just [2], and all the other processing // is too complex for it. if len(paths) == 0 || typeIndex != paths[0] { return false } return true } if len(paths) != len(outerPaths)*2+2+len(fieldPaths) { return false } if typeName == "Method" { if paths[0] != serviceProtoPath || paths[2] != methodProtoPath { return false } paths = paths[2:] } else { typeNameDescriptor := reflect.TypeOf((*descriptorpb.FileDescriptorProto)(nil)) if len(outerPaths) > 0 { if paths[0] != messageProtoPath || paths[1] != outerPaths[0] { return false } paths = paths[2:] outerPaths = outerPaths[1:] for i, v := range outerPaths { if paths[i*2] != nestedProtoPath || paths[i*2+1] != v { return false } } paths = paths[len(outerPaths)*2:] if typeName == "MessageType" { typeName = "NestedType" } typeNameDescriptor = reflect.TypeOf((*descriptorpb.DescriptorProto)(nil)) } if paths[0] != protoPathIndex(typeNameDescriptor, typeName) || paths[1] != typeIndex { return false } paths = paths[2:] } for i, v := range fieldPaths { if paths[i] != v { return false } } return true } // protoPathIndex returns a path component for google.protobuf.descriptor.SourceCode_Location. // // Specifically, it returns an id as generated from descriptor proto which // can be used to determine what type the id following it in the path is. // For example, if we are trying to locate comments related to a field named // `Address` in a message named `Person`, the path will be: // // [4, a, 2, b] // // While `a` gets determined by the order in which the messages appear in // the proto file, and `b` is the field index specified in the proto // file itself, the path actually needs to specify that `a` refers to a // message and not, say, a service; and that `b` refers to a field and not // an option. // // protoPathIndex figures out the values 4 and 2 in the above example. Because // messages are top level objects, the value of 4 comes from field id for // `MessageType` inside `google.protobuf.descriptor.FileDescriptor` message. // This field has a message type `google.protobuf.descriptor.DescriptorProto`. // And inside message `DescriptorProto`, there is a field named `Field` with id // 2. // // Some code generators seem to be hardcoding these values; this method instead // interprets them from `descriptor.proto`-derived Go source as necessary. func protoPathIndex(descriptorType reflect.Type, what string) int32 { field, ok := descriptorType.Elem().FieldByName(what) if !ok { panic(fmt.Errorf("could not find protobuf descriptor type id for %s", what)) } pbtag := field.Tag.Get("protobuf") if pbtag == "" { panic(fmt.Errorf("no Go tag 'protobuf' on protobuf descriptor for %s", what)) } path, err := strconv.ParseInt(strings.Split(pbtag, ",")[1], 10, 32) if err != nil { panic(fmt.Errorf("protobuf descriptor id for %s cannot be converted to a number: %s", what, err.Error())) } return int32(path) } // extractOperationOptionFromMethodDescriptor extracts the message of type // openapi_options.Operation from a given proto method's descriptor. func extractOperationOptionFromMethodDescriptor(meth *descriptorpb.MethodDescriptorProto) (*openapi_options.Operation, error) { if meth.Options == nil { return nil, nil } if !proto.HasExtension(meth.Options, openapi_options.E_Openapiv2Operation) { return nil, nil } ext := proto.GetExtension(meth.Options, openapi_options.E_Openapiv2Operation) opts, ok := ext.(*openapi_options.Operation) if !ok { return nil, fmt.Errorf("extension is %T; want an Operation", ext) } return opts, nil } // extractSchemaOptionFromMessageDescriptor extracts the message of type // openapi_options.Schema from a given proto message's descriptor. func extractSchemaOptionFromMessageDescriptor(msg *descriptorpb.DescriptorProto) (*openapi_options.Schema, error) { if msg.Options == nil { return nil, nil } if !proto.HasExtension(msg.Options, openapi_options.E_Openapiv2Schema) { return nil, nil } ext := proto.GetExtension(msg.Options, openapi_options.E_Openapiv2Schema) opts, ok := ext.(*openapi_options.Schema) if !ok { return nil, fmt.Errorf("extension is %T; want a Schema", ext) } return opts, nil } // extractEnumSchemaOptionFromEnumDescriptor extracts the message of type // openapi_options.EnumSchema from a given proto enum's descriptor. func extractEnumSchemaOptionFromEnumDescriptor(enum *descriptorpb.EnumDescriptorProto) (*openapi_options.EnumSchema, error) { if enum.Options == nil { return nil, nil } if !proto.HasExtension(enum.Options, openapi_options.E_Openapiv2Enum) { return nil, nil } ext := proto.GetExtension(enum.Options, openapi_options.E_Openapiv2Enum) opts, ok := ext.(*openapi_options.EnumSchema) if !ok { return nil, fmt.Errorf("extension is %T; want a EnumSchema", ext) } return opts, nil } // extractTagOptionFromServiceDescriptor extracts the tag of type // openapi_options.Tag from a given proto service's descriptor. func extractTagOptionFromServiceDescriptor(svc *descriptorpb.ServiceDescriptorProto) (*openapi_options.Tag, error) { if svc.Options == nil { return nil, nil } if !proto.HasExtension(svc.Options, openapi_options.E_Openapiv2Tag) { return nil, nil } ext := proto.GetExtension(svc.Options, openapi_options.E_Openapiv2Tag) opts, ok := ext.(*openapi_options.Tag) if !ok { return nil, fmt.Errorf("extension is %T; want a Tag", ext) } return opts, nil } // extractOpenAPIOptionFromFileDescriptor extracts the message of type // openapi_options.OpenAPI from a given proto method's descriptor. func extractOpenAPIOptionFromFileDescriptor(file *descriptorpb.FileDescriptorProto) (*openapi_options.Swagger, error) { if file.Options == nil { return nil, nil } if !proto.HasExtension(file.Options, openapi_options.E_Openapiv2Swagger) { return nil, nil } ext := proto.GetExtension(file.Options, openapi_options.E_Openapiv2Swagger) opts, ok := ext.(*openapi_options.Swagger) if !ok { return nil, fmt.Errorf("extension is %T; want a OpenAPI object", ext) } return opts, nil } func extractJSONSchemaFromFieldDescriptor(fd *descriptorpb.FieldDescriptorProto) (*openapi_options.JSONSchema, error) { if fd.Options == nil { return nil, nil } if !proto.HasExtension(fd.Options, openapi_options.E_Openapiv2Field) { return nil, nil } ext := proto.GetExtension(fd.Options, openapi_options.E_Openapiv2Field) opts, ok := ext.(*openapi_options.JSONSchema) if !ok { return nil, fmt.Errorf("extension is %T; want a JSONSchema object", ext) } return opts, nil } func extractFieldBehaviorFromFieldDescriptor(fd *descriptorpb.FieldDescriptorProto) ([]annotations.FieldBehavior, error) { if fd.Options == nil { return nil, nil } if !proto.HasExtension(fd.Options, annotations.E_FieldBehavior) { return nil, nil } ext := proto.GetExtension(fd.Options, annotations.E_FieldBehavior) opts, ok := ext.([]annotations.FieldBehavior) if !ok { return nil, fmt.Errorf("extension is %T; want a []FieldBehavior object", ext) } return opts, nil } func getFieldVisibilityOption(fd *descriptor.Field) *visibility.VisibilityRule { if fd.Options == nil { return nil } if !proto.HasExtension(fd.Options, visibility.E_FieldVisibility) { return nil } ext := proto.GetExtension(fd.Options, visibility.E_FieldVisibility) opts, ok := ext.(*visibility.VisibilityRule) if !ok { return nil } return opts } func getServiceVisibilityOption(fd *descriptor.Service) *visibility.VisibilityRule { if fd.Options == nil { return nil } if !proto.HasExtension(fd.Options, visibility.E_ApiVisibility) { return nil } ext := proto.GetExtension(fd.Options, visibility.E_ApiVisibility) opts, ok := ext.(*visibility.VisibilityRule) if !ok { return nil } return opts } func getMethodVisibilityOption(fd *descriptor.Method) *visibility.VisibilityRule { if fd.Options == nil { return nil } if !proto.HasExtension(fd.Options, visibility.E_MethodVisibility) { return nil } ext := proto.GetExtension(fd.Options, visibility.E_MethodVisibility) opts, ok := ext.(*visibility.VisibilityRule) if !ok { return nil } return opts } func getEnumValueVisibilityOption(fd *descriptorpb.EnumValueDescriptorProto) *visibility.VisibilityRule { if fd.Options == nil { return nil } if !proto.HasExtension(fd.Options, visibility.E_ValueVisibility) { return nil } ext := proto.GetExtension(fd.Options, visibility.E_ValueVisibility) opts, ok := ext.(*visibility.VisibilityRule) if !ok { return nil } return opts } func getMethodOpenAPIOption(reg *descriptor.Registry, meth *descriptor.Method) (*openapi_options.Operation, error) { opts, err := extractOperationOptionFromMethodDescriptor(meth.MethodDescriptorProto) if err != nil { return nil, err } if opts != nil { return opts, nil } opts, ok := reg.GetOpenAPIMethodOption(meth.FQMN()) if !ok { return nil, nil } return opts, nil } func getMessageOpenAPIOption(reg *descriptor.Registry, msg *descriptor.Message) (*openapi_options.Schema, error) { opts, err := extractSchemaOptionFromMessageDescriptor(msg.DescriptorProto) if err != nil { return nil, err } if opts != nil { return opts, nil } opts, ok := reg.GetOpenAPIMessageOption(msg.FQMN()) if !ok { return nil, nil } return opts, nil } func getEnumOpenAPIOption(reg *descriptor.Registry, enum *descriptor.Enum) (*openapi_options.EnumSchema, error) { opts, err := extractEnumSchemaOptionFromEnumDescriptor(enum.EnumDescriptorProto) if err != nil { return nil, err } return opts, nil } func getServiceOpenAPIOption(reg *descriptor.Registry, svc *descriptor.Service) (*openapi_options.Tag, error) { if opts, ok := reg.GetOpenAPIServiceOption(svc.FQSN()); ok { return opts, nil } opts, err := extractTagOptionFromServiceDescriptor(svc.ServiceDescriptorProto) if err != nil { return nil, err } return opts, nil } func getFileOpenAPIOption(reg *descriptor.Registry, file *descriptor.File) (*openapi_options.Swagger, error) { opts, err := extractOpenAPIOptionFromFileDescriptor(file.FileDescriptorProto) if err != nil { return nil, err } if opts != nil { return opts, nil } opts, ok := reg.GetOpenAPIFileOption(*file.Name) if !ok { return nil, nil } return opts, nil } func getFieldOpenAPIOption(reg *descriptor.Registry, fd *descriptor.Field) (*openapi_options.JSONSchema, error) { opts, err := extractJSONSchemaFromFieldDescriptor(fd.FieldDescriptorProto) if err != nil { return nil, err } if opts != nil { return opts, nil } opts, ok := reg.GetOpenAPIFieldOption(fd.FQFN()) if !ok { return nil, nil } return opts, nil } func getFieldBehaviorOption(reg *descriptor.Registry, fd *descriptor.Field) ([]annotations.FieldBehavior, error) { opts, err := extractFieldBehaviorFromFieldDescriptor(fd.FieldDescriptorProto) if err != nil { return nil, err } if opts != nil { return opts, nil } return opts, nil } func protoJSONSchemaToOpenAPISchemaCore(j *openapi_options.JSONSchema, reg *descriptor.Registry, refs refMap) schemaCore { ret := schemaCore{} if j.GetRef() != "" { openapiName, ok := fullyQualifiedNameToOpenAPIName(j.GetRef(), reg) if ok { ret.Ref = "#/definitions/" + openapiName if refs != nil { refs[j.GetRef()] = struct{}{} } } else { ret.Ref += j.GetRef() } } else { f, t := protoJSONSchemaTypeToFormat(j.GetType()) ret.Format = f ret.Type = t } return ret } func updateswaggerObjectFromJSONSchema(s *openapiSchemaObject, j *openapi_options.JSONSchema, reg *descriptor.Registry, data interface{}) { s.Title = j.GetTitle() s.Description = j.GetDescription() if reg.GetUseGoTemplate() { s.Title = goTemplateComments(s.Title, data, reg) s.Description = goTemplateComments(s.Description, data, reg) } if s.Type == "array" { s.Items.MaxLength = j.GetMaxLength() s.Items.MinLength = j.GetMinLength() s.Items.Pattern = j.GetPattern() s.Items.Default = j.GetDefault() s.Items.MaxProperties = j.GetMaxProperties() s.Items.MinProperties = j.GetMinProperties() s.Items.Required = j.GetRequired() s.Items.Minimum = j.GetMinimum() s.Items.Maximum = j.GetMaximum() s.Items.ReadOnly = j.GetReadOnly() s.Items.MultipleOf = j.GetMultipleOf() s.Items.ExclusiveMaximum = j.GetExclusiveMaximum() s.Items.ExclusiveMinimum = j.GetExclusiveMinimum() s.Items.Enum = j.GetEnum() if j.GetDefault() == "" { s.Items.Default = nil } if len(j.GetEnum()) == 0 { s.Items.Enum = nil } if j.GetFormat() != "" { s.Items.Format = j.GetFormat() } } else { s.MaxLength = j.GetMaxLength() s.MinLength = j.GetMinLength() s.Pattern = j.GetPattern() s.Default = j.GetDefault() s.MaxProperties = j.GetMaxProperties() s.MinProperties = j.GetMinProperties() s.Required = j.GetRequired() s.Minimum = j.GetMinimum() s.Maximum = j.GetMaximum() s.ReadOnly = j.GetReadOnly() s.MultipleOf = j.GetMultipleOf() s.ExclusiveMaximum = j.GetExclusiveMaximum() s.ExclusiveMinimum = j.GetExclusiveMinimum() s.Enum = j.GetEnum() if j.GetDefault() == "" { s.Default = nil } if len(j.GetEnum()) == 0 { s.Enum = nil } if j.GetFormat() != "" { s.Format = j.GetFormat() } } s.UniqueItems = j.GetUniqueItems() s.MaxItems = j.GetMaxItems() s.MinItems = j.GetMinItems() if j.GetExtensions() != nil { exts, err := processExtensions(j.GetExtensions()) if err != nil { panic(err) } s.extensions = exts } if overrideType := j.GetType(); len(overrideType) > 0 { s.Type = strings.ToLower(overrideType[0].String()) } if j.GetExample() != "" { s.Example = RawExample(j.GetExample()) } } func updateSwaggerObjectFromFieldBehavior(s *openapiSchemaObject, j []annotations.FieldBehavior, reg *descriptor.Registry, field *descriptor.Field) { required := false if reg.GetUseProto3FieldSemantics() { required = !field.GetProto3Optional() && field.OneofIndex == nil } for _, fb := range j { switch fb { case annotations.FieldBehavior_REQUIRED: required = true case annotations.FieldBehavior_OUTPUT_ONLY: s.ReadOnly = true case annotations.FieldBehavior_FIELD_BEHAVIOR_UNSPECIFIED: case annotations.FieldBehavior_OPTIONAL: required = false case annotations.FieldBehavior_INPUT_ONLY: // OpenAPI v3 supports a writeOnly property, but this is not supported in Open API v2 case annotations.FieldBehavior_IMMUTABLE: } } if required { if reg.GetUseJSONNamesForFields() { s.Required = append(s.Required, *field.JsonName) } else { s.Required = append(s.Required, *field.Name) } } } func openapiSchemaFromProtoEnumSchema(s *openapi_options.EnumSchema, reg *descriptor.Registry, refs refMap, data interface{}) openapiSchemaObject { ret := openapiSchemaObject{ ExternalDocs: protoExternalDocumentationToOpenAPIExternalDocumentation(s.GetExternalDocs(), reg, data), } jsonSchema := &openapi_options.JSONSchema{ Ref: s.Ref, Title: s.Title, Extensions: s.Extensions, Description: s.Description, Default: s.Default, ReadOnly: s.ReadOnly, Example: s.Example, } ret.schemaCore = protoJSONSchemaToOpenAPISchemaCore(jsonSchema, reg, refs) updateswaggerObjectFromJSONSchema(&ret, jsonSchema, reg, data) return ret } func openapiSchemaFromProtoSchema(s *openapi_options.Schema, reg *descriptor.Registry, refs refMap, data interface{}) openapiSchemaObject { ret := openapiSchemaObject{ ExternalDocs: protoExternalDocumentationToOpenAPIExternalDocumentation(s.GetExternalDocs(), reg, data), } ret.schemaCore = protoJSONSchemaToOpenAPISchemaCore(s.GetJsonSchema(), reg, refs) updateswaggerObjectFromJSONSchema(&ret, s.GetJsonSchema(), reg, data) if s != nil && s.Example != "" { ret.Example = RawExample(s.Example) } return ret } func openapiExamplesFromProtoExamples(in map[string]string) map[string]interface{} { if len(in) == 0 { return nil } out := make(map[string]interface{}, len(in)) for mimeType, exampleStr := range in { switch mimeType { case "application/json": // JSON example objects are rendered raw. out[mimeType] = RawExample(exampleStr) default: // All other mimetype examples are rendered as strings. out[mimeType] = exampleStr } } return out } func protoJSONSchemaTypeToFormat(in []openapi_options.JSONSchema_JSONSchemaSimpleTypes) (string, string) { if len(in) == 0 { return "", "" } // Can't support more than 1 type, just return the first element. // This is due to an inconsistency in the design of the openapiv2 proto // and that used in schemaCore. schemaCore uses the v3 definition of types, // which only allows a single string, while the openapiv2 proto uses the OpenAPI v2 // definition, which defers to the JSON schema definition, which allows a string or an array. // Sources: // https://swagger.io/specification/#itemsObject // https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.2 switch in[0] { case openapi_options.JSONSchema_UNKNOWN, openapi_options.JSONSchema_NULL: return "", "" case openapi_options.JSONSchema_OBJECT: return "object", "" case openapi_options.JSONSchema_ARRAY: return "array", "" case openapi_options.JSONSchema_BOOLEAN: // NOTE: in OpenAPI specification, format should be empty on boolean type return "boolean", "" case openapi_options.JSONSchema_INTEGER: return "integer", "int32" case openapi_options.JSONSchema_NUMBER: return "number", "double" case openapi_options.JSONSchema_STRING: // NOTE: in OpenAPI specification, format should be empty on string type return "string", "" default: // Maybe panic? return "", "" } } func protoExternalDocumentationToOpenAPIExternalDocumentation(in *openapi_options.ExternalDocumentation, reg *descriptor.Registry, data interface{}) *openapiExternalDocumentationObject { if in == nil { return nil } if reg.GetUseGoTemplate() { in.Description = goTemplateComments(in.Description, data, reg) } return &openapiExternalDocumentationObject{ Description: in.Description, URL: in.Url, } } func addCustomRefs(d openapiDefinitionsObject, reg *descriptor.Registry, refs refMap) error { if len(refs) == 0 { return nil } msgMap := make(messageMap) enumMap := make(enumMap) for ref := range refs { swgName, swgOk := fullyQualifiedNameToOpenAPIName(ref, reg) if !swgOk { grpclog.Errorf("can't resolve OpenAPI name from CustomRef %q", ref) continue } if _, ok := d[swgName]; ok { // Skip already existing definitions delete(refs, ref) continue } msg, err := reg.LookupMsg("", ref) if err == nil { msgMap[swgName] = msg continue } enum, err := reg.LookupEnum("", ref) if err == nil { enumMap[swgName] = enum continue } // ?? Should be either enum or msg } if err := renderMessagesAsDefinition(msgMap, d, reg, refs, nil); err != nil { return err } renderEnumerationsAsDefinition(enumMap, d, reg, refs) // Run again in case any new refs were added return addCustomRefs(d, reg, refs) } func lowerCamelCase(fieldName string, fields []*descriptor.Field, msgs []*descriptor.Message) string { for _, oneField := range fields { if oneField.GetName() == fieldName { return oneField.GetJsonName() } } messageNameToFieldsToJSONName := make(map[string]map[string]string, len(msgs)) fieldNameToType := make(map[string]string) for _, msg := range msgs { fieldNameToJSONName := make(map[string]string) for _, oneField := range msg.GetField() { fieldNameToJSONName[oneField.GetName()] = oneField.GetJsonName() fieldNameToType[oneField.GetName()] = oneField.GetTypeName() } messageNameToFieldsToJSONName[msg.GetName()] = fieldNameToJSONName } if strings.Contains(fieldName, ".") { fieldNames := strings.Split(fieldName, ".") fieldNamesWithCamelCase := make([]string, 0) for i := 0; i < len(fieldNames)-1; i++ { fieldNamesWithCamelCase = append(fieldNamesWithCamelCase, casing.JSONCamelCase(fieldNames[i])) } prefix := strings.Join(fieldNamesWithCamelCase, ".") reservedJSONName := getReservedJSONName(fieldName, messageNameToFieldsToJSONName, fieldNameToType) if reservedJSONName != "" { return prefix + "." + reservedJSONName } } return casing.JSONCamelCase(fieldName) } func getReservedJSONName(fieldName string, messageNameToFieldsToJSONName map[string]map[string]string, fieldNameToType map[string]string) string { if len(strings.Split(fieldName, ".")) == 2 { fieldNames := strings.Split(fieldName, ".") firstVariable := fieldNames[0] firstType := fieldNameToType[firstVariable] firstTypeShortNames := strings.Split(firstType, ".") firstTypeShortName := firstTypeShortNames[len(firstTypeShortNames)-1] return messageNameToFieldsToJSONName[firstTypeShortName][fieldNames[1]] } fieldNames := strings.Split(fieldName, ".") return getReservedJSONName(strings.Join(fieldNames[1:], "."), messageNameToFieldsToJSONName, fieldNameToType) } func find(a []string, x string) int { // This is a linear search but we are dealing with a small number of fields for i, n := range a { if x == n { return i } } return -1 } // Make a deep copy of the outer parameters that has paramName as the first component, // but remove the first component of the field path. func subPathParams(paramName string, outerParams []descriptor.Parameter) []descriptor.Parameter { var innerParams []descriptor.Parameter for _, p := range outerParams { if len(p.FieldPath) > 1 && p.FieldPath[0].Name == paramName { subParam := descriptor.Parameter{ FieldPath: p.FieldPath[1:], Target: p.Target, Method: p.Method, } innerParams = append(innerParams, subParam) } } return innerParams } func getFieldConfiguration(reg *descriptor.Registry, fd *descriptor.Field) *openapi_options.JSONSchema_FieldConfiguration { if j, err := getFieldOpenAPIOption(reg, fd); err == nil { return j.GetFieldConfiguration() } return nil } ================================================ FILE: protoc-gen-openapiv2/internal/genopenapi/template_fuzz_test.go ================================================ //go:build go1.18 // +build go1.18 package genopenapi import ( "regexp" "testing" ) var replaceInternalCommentsRegex = regexp.MustCompile(`(?s)(\r?\n)?[ \t]*(\(--)((.*?--\))|.*$)?`) func FuzzRemoveInternalComments(f *testing.F) { f.Add("Text\n\n(-- Comment --)\n\nMore Text\n") f.Add("Text\n\n(-- Multi\nLine\n\nComment --)\n\nMore Text\n") f.Add("(-- Starting with comment --)\n\nMore Text\n") f.Add("\n\n(-- Starting with new line and comment --)\n\nMore Text\n") f.Add("Ending with\n\n(-- Comment --)") f.Fuzz(func(t *testing.T, s string) { s1 := removeInternalComments(s) s2 := replaceInternalCommentsRegex.ReplaceAllString(s, "") if s1 != s2 { t.Errorf("Unexpected comment removal difference: our function produced %q but regex produced %q on %q", s1, s2, s) } }) } ================================================ FILE: protoc-gen-openapiv2/internal/genopenapi/template_test.go ================================================ package genopenapi import ( "bytes" "encoding/json" "errors" "fmt" "math" "os" "reflect" "strings" "testing" "github.com/google/go-cmp/cmp" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor/openapiconfig" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/httprule" openapi_options "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "google.golang.org/genproto/googleapis/api/annotations" "google.golang.org/genproto/googleapis/api/visibility" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protodesc" "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/reflect/protoregistry" "google.golang.org/protobuf/types/descriptorpb" "google.golang.org/protobuf/types/known/anypb" "google.golang.org/protobuf/types/known/durationpb" "google.golang.org/protobuf/types/known/emptypb" field_mask "google.golang.org/protobuf/types/known/fieldmaskpb" "google.golang.org/protobuf/types/known/structpb" "google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/wrapperspb" "google.golang.org/protobuf/types/pluginpb" ) var marshaler = &runtime.JSONPb{} func TestOpenapiExamplesFromProtoExamples(t *testing.T) { examples := openapiExamplesFromProtoExamples(map[string]string{ "application/json": `{"Hello": "Worldr!"}`, "plain/text": "Hello, World!", }) testCases := map[Format]string{ FormatJSON: ` { "application/json": { "Hello": "Worldr!" }, "plain/text": "Hello, World!" } `, FormatYAML: ` application/json: Hello: Worldr! plain/text: Hello, World! `, } spaceRemover := strings.NewReplacer(" ", "", "\t", "", "\n", "") for format, expected := range testCases { t.Run(string(format), func(t *testing.T) { var buf bytes.Buffer encoder, err := format.NewEncoder(&buf) if err != nil { t.Fatalf("creating encoder: %s", err) } err = encoder.Encode(examples) if err != nil { t.Fatalf("encoding: %s", err) } actual := spaceRemover.Replace(buf.String()) expected = spaceRemover.Replace(expected) if expected != actual { t.Fatalf("expected:\n%s\nactual:\n%s", expected, actual) } }) } } func crossLinkFixture(f *descriptor.File) *descriptor.File { for _, m := range f.Messages { m.File = f } for _, svc := range f.Services { svc.File = f for _, m := range svc.Methods { m.Service = svc for _, b := range m.Bindings { b.Method = m for _, param := range b.PathParams { param.Method = m } } } } return f } func reqFromFile(f *descriptor.File) *pluginpb.CodeGeneratorRequest { return &pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{ f.FileDescriptorProto, }, FileToGenerate: []string{f.GetName()}, } } func TestMessageToQueryParametersWithEnumAsInt(t *testing.T) { type test struct { MsgDescs []*descriptorpb.DescriptorProto Message string Params []openapiParameterObject } tests := []test{ { MsgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("a"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("b"), Type: descriptorpb.FieldDescriptorProto_TYPE_DOUBLE.Enum(), Number: proto.Int32(2), }, { Name: proto.String("c"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Label: descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum(), Number: proto.Int32(3), }, }, }, }, Message: "ExampleMessage", Params: []openapiParameterObject{ { Name: "a", In: "query", Required: false, Type: "string", }, { Name: "b", In: "query", Required: false, Type: "number", Format: "double", }, { Name: "c", In: "query", Required: false, Type: "array", CollectionFormat: "multi", }, }, }, { MsgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("nested"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.Nested"), Number: proto.Int32(1), }, }, }, { Name: proto.String("Nested"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("a"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("deep"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.Nested.DeepNested"), Number: proto.Int32(2), }, }, NestedType: []*descriptorpb.DescriptorProto{{ Name: proto.String("DeepNested"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("b"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("c"), Type: descriptorpb.FieldDescriptorProto_TYPE_ENUM.Enum(), TypeName: proto.String(".example.Nested.DeepNested.DeepEnum"), Number: proto.Int32(2), }, }, EnumType: []*descriptorpb.EnumDescriptorProto{ { Name: proto.String("DeepEnum"), Value: []*descriptorpb.EnumValueDescriptorProto{ {Name: proto.String("FALSE"), Number: proto.Int32(0)}, {Name: proto.String("TRUE"), Number: proto.Int32(1)}, }, }, }, }}, }, }, Message: "ExampleMessage", Params: []openapiParameterObject{ { Name: "nested.a", In: "query", Required: false, Type: "string", }, { Name: "nested.deep.b", In: "query", Required: false, Type: "string", }, { Name: "nested.deep.c", In: "query", Required: false, Type: "integer", Enum: []int{0, 1}, Default: 0, }, }, }, } for _, test := range tests { reg := descriptor.NewRegistry() reg.SetEnumsAsInts(true) var msgs []*descriptor.Message for _, msgdesc := range test.MsgDescs { msgs = append(msgs, &descriptor.Message{DescriptorProto: msgdesc}) } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), Dependency: []string{}, MessageType: test.MsgDescs, Service: []*descriptorpb.ServiceDescriptorProto{}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: msgs, } err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}, }) if err != nil { t.Fatalf("failed to load code generator request: %v", err) } message, err := reg.LookupMsg("", ".example."+test.Message) if err != nil { t.Fatalf("failed to lookup message: %s", err) } params, err := messageToQueryParameters(message, reg, []descriptor.Parameter{}, nil, "") if err != nil { t.Fatalf("failed to convert message to query parameters: %s", err) } // avoid checking Items for array types for i := range params { params[i].Items = nil } if !reflect.DeepEqual(params, test.Params) { t.Errorf("expected %v, got %v", test.Params, params) } } } func TestMessageToQueryParametersWithOmitEnumDefaultValue(t *testing.T) { type test struct { MsgDescs []*descriptorpb.DescriptorProto Message string Params []openapiParameterObject } tests := []test{ { MsgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("a"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("b"), Type: descriptorpb.FieldDescriptorProto_TYPE_DOUBLE.Enum(), Number: proto.Int32(2), }, { Name: proto.String("c"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Label: descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum(), Number: proto.Int32(3), }, }, }, }, Message: "ExampleMessage", Params: []openapiParameterObject{ { Name: "a", In: "query", Required: false, Type: "string", }, { Name: "b", In: "query", Required: false, Type: "number", Format: "double", }, { Name: "c", In: "query", Required: false, Type: "array", CollectionFormat: "multi", }, }, }, { MsgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("nested"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.Nested"), Number: proto.Int32(1), }, }, }, { Name: proto.String("Nested"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("a"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("deep"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.Nested.DeepNested"), Number: proto.Int32(2), }, }, NestedType: []*descriptorpb.DescriptorProto{{ Name: proto.String("DeepNested"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("b"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("c"), Type: descriptorpb.FieldDescriptorProto_TYPE_ENUM.Enum(), TypeName: proto.String(".example.Nested.DeepNested.DeepEnum"), Number: proto.Int32(2), }, }, EnumType: []*descriptorpb.EnumDescriptorProto{ { Name: proto.String("DeepEnum"), Value: []*descriptorpb.EnumValueDescriptorProto{ {Name: proto.String("FALSE"), Number: proto.Int32(0)}, {Name: proto.String("TRUE"), Number: proto.Int32(1)}, }, }, }, }}, }, }, Message: "ExampleMessage", Params: []openapiParameterObject{ { Name: "nested.a", In: "query", Required: false, Type: "string", }, { Name: "nested.deep.b", In: "query", Required: false, Type: "string", }, { Name: "nested.deep.c", In: "query", Required: false, Type: "string", Enum: []string{"TRUE"}, }, }, }, } for _, test := range tests { reg := descriptor.NewRegistry() reg.SetOmitEnumDefaultValue(true) var msgs []*descriptor.Message for _, msgdesc := range test.MsgDescs { msgs = append(msgs, &descriptor.Message{DescriptorProto: msgdesc}) } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), Dependency: []string{}, MessageType: test.MsgDescs, Service: []*descriptorpb.ServiceDescriptorProto{}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: msgs, } err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}, }) if err != nil { t.Fatalf("failed to load code generator request: %v", err) } message, err := reg.LookupMsg("", ".example."+test.Message) if err != nil { t.Fatalf("failed to lookup message: %s", err) } params, err := messageToQueryParameters(message, reg, []descriptor.Parameter{}, nil, "") if err != nil { t.Fatalf("failed to convert message to query parameters: %s", err) } // avoid checking Items for array types for i := range params { params[i].Items = nil } if !reflect.DeepEqual(params, test.Params) { t.Errorf("expected %v, got %v", test.Params, params) } } } func TestMessageToQueryParameters(t *testing.T) { type test struct { MsgDescs []*descriptorpb.DescriptorProto Message string Params []openapiParameterObject } tests := []test{ { MsgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("a"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("b"), Type: descriptorpb.FieldDescriptorProto_TYPE_DOUBLE.Enum(), Number: proto.Int32(2), }, { Name: proto.String("c"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Label: descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum(), Number: proto.Int32(3), }, }, }, }, Message: "ExampleMessage", Params: []openapiParameterObject{ { Name: "a", In: "query", Required: false, Type: "string", }, { Name: "b", In: "query", Required: false, Type: "number", Format: "double", }, { Name: "c", In: "query", Required: false, Type: "array", CollectionFormat: "multi", }, }, }, { MsgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("nested"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.Nested"), Number: proto.Int32(1), }, }, }, { Name: proto.String("Nested"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("a"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("deep"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.Nested.DeepNested"), Number: proto.Int32(2), }, }, NestedType: []*descriptorpb.DescriptorProto{{ Name: proto.String("DeepNested"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("b"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("c"), Type: descriptorpb.FieldDescriptorProto_TYPE_ENUM.Enum(), TypeName: proto.String(".example.Nested.DeepNested.DeepEnum"), Number: proto.Int32(2), }, }, EnumType: []*descriptorpb.EnumDescriptorProto{ { Name: proto.String("DeepEnum"), Value: []*descriptorpb.EnumValueDescriptorProto{ {Name: proto.String("FALSE"), Number: proto.Int32(0)}, {Name: proto.String("TRUE"), Number: proto.Int32(1)}, }, }, }, }}, }, }, Message: "ExampleMessage", Params: []openapiParameterObject{ { Name: "nested.a", In: "query", Required: false, Type: "string", }, { Name: "nested.deep.b", In: "query", Required: false, Type: "string", }, { Name: "nested.deep.c", In: "query", Required: false, Type: "string", Enum: []string{"FALSE", "TRUE"}, Default: "FALSE", }, }, }, } for _, test := range tests { reg := descriptor.NewRegistry() msgs := []*descriptor.Message{} for _, msgdesc := range test.MsgDescs { msgs = append(msgs, &descriptor.Message{DescriptorProto: msgdesc}) } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), Dependency: []string{}, MessageType: test.MsgDescs, Service: []*descriptorpb.ServiceDescriptorProto{}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: msgs, } err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}, }) if err != nil { t.Fatalf("failed to load code generator request: %v", err) } message, err := reg.LookupMsg("", ".example."+test.Message) if err != nil { t.Fatalf("failed to lookup message: %s", err) } params, err := messageToQueryParameters(message, reg, []descriptor.Parameter{}, nil, "") if err != nil { t.Fatalf("failed to convert message to query parameters: %s", err) } // avoid checking Items for array types for i := range params { params[i].Items = nil } if !reflect.DeepEqual(params, test.Params) { t.Errorf("expected %v, got %v", test.Params, params) } } } // TestMessageToQueryParametersNoRecursive, is a check that cyclical references between messages // are not falsely detected given previous known edge-cases. func TestMessageToQueryParametersNoRecursive(t *testing.T) { type test struct { MsgDescs []*descriptorpb.DescriptorProto Message string } tests := []test{ // First test: // Here is a message that has two of another message adjacent to one another in a nested message. // There is no loop but this was previously falsely flagged as a cycle. // Example proto: // message NonRecursiveMessage { // string field = 1; // } // message BaseMessage { // NonRecursiveMessage first = 1; // NonRecursiveMessage second = 2; // } // message QueryMessage { // BaseMessage first = 1; // string second = 2; // } { MsgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("QueryMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("first"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.BaseMessage"), Number: proto.Int32(1), }, { Name: proto.String("second"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), }, }, }, { Name: proto.String("BaseMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("first"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.NonRecursiveMessage"), Number: proto.Int32(1), }, { Name: proto.String("second"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.NonRecursiveMessage"), Number: proto.Int32(2), }, }, }, // Note there is no recursive nature to this message { Name: proto.String("NonRecursiveMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("field"), // Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, }, }, }, Message: "QueryMessage", }, } for _, test := range tests { reg := descriptor.NewRegistry() msgs := []*descriptor.Message{} for _, msgdesc := range test.MsgDescs { msgs = append(msgs, &descriptor.Message{DescriptorProto: msgdesc}) } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), Dependency: []string{}, MessageType: test.MsgDescs, Service: []*descriptorpb.ServiceDescriptorProto{}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: msgs, } err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}, }) if err != nil { t.Fatalf("failed to load code generator request: %v", err) } message, err := reg.LookupMsg("", ".example."+test.Message) if err != nil { t.Fatalf("failed to lookup message: %s", err) } _, err = messageToQueryParameters(message, reg, []descriptor.Parameter{}, nil, "") if err != nil { t.Fatalf("No recursion error should be thrown: %s", err) } } } // TestMessageToQueryParametersRecursive, is a check that cyclical references between messages // are handled gracefully. The goal is to ensure that attempts to add messages with cyclical // references to query-parameters returns an error message. func TestMessageToQueryParametersRecursive(t *testing.T) { type test struct { MsgDescs []*descriptorpb.DescriptorProto Message string } tests := []test{ // First test: // Here we test that a message that references itself through a field will return an error. // Example proto: // message DirectRecursiveMessage { // DirectRecursiveMessage nested = 1; // } { MsgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("DirectRecursiveMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("nested"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.DirectRecursiveMessage"), Number: proto.Int32(1), }, }, }, }, Message: "DirectRecursiveMessage", }, // Second test: // Here we test that a cycle through multiple messages is detected and that an error is returned. // Sample: // message Root { NodeMessage nested = 1; } // message NodeMessage { CycleMessage nested = 1; } // message CycleMessage { Root nested = 1; } { MsgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("RootMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("nested"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.NodeMessage"), Number: proto.Int32(1), }, }, }, { Name: proto.String("NodeMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("nested"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.CycleMessage"), Number: proto.Int32(1), }, }, }, { Name: proto.String("CycleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("nested"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.RootMessage"), Number: proto.Int32(1), }, }, }, }, Message: "RootMessage", }, } for _, test := range tests { reg := descriptor.NewRegistry() msgs := []*descriptor.Message{} for _, msgdesc := range test.MsgDescs { msgs = append(msgs, &descriptor.Message{DescriptorProto: msgdesc}) } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), Dependency: []string{}, MessageType: test.MsgDescs, Service: []*descriptorpb.ServiceDescriptorProto{}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: msgs, } err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}, }) if err != nil { t.Fatalf("failed to load code generator request: %v", err) } message, err := reg.LookupMsg("", ".example."+test.Message) if err != nil { t.Fatalf("failed to lookup message: %s", err) } _, err = messageToQueryParameters(message, reg, []descriptor.Parameter{}, nil, "") if err == nil { t.Fatalf("It should not be allowed to have recursive query parameters") } } } func TestMessageToQueryParametersWithJsonName(t *testing.T) { type test struct { MsgDescs []*descriptorpb.DescriptorProto Message string Params []openapiParameterObject } requiredField := []annotations.FieldBehavior{annotations.FieldBehavior_REQUIRED} requiredFieldOptions := new(descriptorpb.FieldOptions) proto.SetExtension(requiredFieldOptions, annotations.E_FieldBehavior, requiredField) messageSchema := &openapi_options.Schema{ JsonSchema: &openapi_options.JSONSchema{ Required: []string{"test_field_b"}, }, } messageOption := &descriptorpb.MessageOptions{} proto.SetExtension(messageOption, openapi_options.E_Openapiv2Schema, messageSchema) tests := []test{ { MsgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("test_field_a"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), JsonName: proto.String("testFieldA"), }, }, }, }, Message: "ExampleMessage", Params: []openapiParameterObject{ { Name: "testFieldA", In: "query", Required: false, Type: "string", }, }, }, { MsgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("SubMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("test_field_a"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), JsonName: proto.String("testFieldA"), }, }, }, { Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("sub_message"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.SubMessage"), Number: proto.Int32(1), JsonName: proto.String("subMessage"), }, }, }, }, Message: "ExampleMessage", Params: []openapiParameterObject{ { Name: "subMessage.testFieldA", In: "query", Required: false, Type: "string", }, }, }, { MsgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("test_field_a"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), JsonName: proto.String("testFieldACustom"), Options: requiredFieldOptions, }, { Name: proto.String("test_field_b"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), JsonName: proto.String("testFieldBCustom"), }, }, Options: messageOption, }, }, Message: "ExampleMessage", Params: []openapiParameterObject{ { Name: "testFieldACustom", In: "query", Required: true, Type: "string", }, { Name: "testFieldBCustom", In: "query", Required: true, Type: "string", }, }, }, } for _, test := range tests { reg := descriptor.NewRegistry() reg.SetUseJSONNamesForFields(true) msgs := []*descriptor.Message{} for _, msgdesc := range test.MsgDescs { msgs = append(msgs, &descriptor.Message{DescriptorProto: msgdesc}) } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), Dependency: []string{}, MessageType: test.MsgDescs, Service: []*descriptorpb.ServiceDescriptorProto{}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: msgs, } err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}, }) if err != nil { t.Fatalf("failed to load code generator request: %v", err) } message, err := reg.LookupMsg("", ".example."+test.Message) if err != nil { t.Fatalf("failed to lookup message: %s", err) } params, err := messageToQueryParameters(message, reg, []descriptor.Parameter{}, nil, "") if err != nil { t.Fatalf("failed to convert message to query parameters: %s", err) } if !reflect.DeepEqual(params, test.Params) { t.Errorf("expected %#v, got %#v", test.Params, params) } } } func TestMessageToQueryParametersWellKnownTypes(t *testing.T) { type test struct { MsgDescs []*descriptorpb.DescriptorProto WellKnownMsgDescs []*descriptorpb.DescriptorProto Message string Params []openapiParameterObject } tests := []test{ { MsgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("a_field_mask"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".google.protobuf.FieldMask"), Number: proto.Int32(1), }, { Name: proto.String("a_timestamp"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".google.protobuf.Timestamp"), Number: proto.Int32(2), }, }, }, }, WellKnownMsgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("FieldMask"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("paths"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Label: descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum(), Number: proto.Int32(1), }, }, }, { Name: proto.String("Timestamp"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("seconds"), Type: descriptorpb.FieldDescriptorProto_TYPE_INT64.Enum(), Number: proto.Int32(1), }, { Name: proto.String("nanos"), Type: descriptorpb.FieldDescriptorProto_TYPE_INT32.Enum(), Number: proto.Int32(2), }, }, }, }, Message: "ExampleMessage", Params: []openapiParameterObject{ { Name: "a_field_mask", In: "query", Required: false, Type: "string", }, { Name: "a_timestamp", In: "query", Required: false, Type: "string", Format: "date-time", }, }, }, } for _, test := range tests { reg := descriptor.NewRegistry() reg.SetEnumsAsInts(true) err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{ { SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("google/well_known.proto"), Package: proto.String("google.protobuf"), Dependency: []string{}, MessageType: test.WellKnownMsgDescs, Service: []*descriptorpb.ServiceDescriptorProto{}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("google/well_known"), }, }, { SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("acme/example.proto"), Package: proto.String("example"), Dependency: []string{"google/well_known.proto"}, MessageType: test.MsgDescs, Service: []*descriptorpb.ServiceDescriptorProto{}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("acme/example"), }, }, }, }) if err != nil { t.Fatalf("failed to load CodeGeneratorRequest: %v", err) } message, err := reg.LookupMsg("", ".example."+test.Message) if err != nil { t.Fatalf("failed to lookup message: %s", err) } params, err := messageToQueryParameters(message, reg, []descriptor.Parameter{}, nil, "") if err != nil { t.Fatalf("failed to convert message to query parameters: %s", err) } if !reflect.DeepEqual(params, test.Params) { t.Errorf("expected %v, got %v", test.Params, params) } } } func TestMessageToQueryParametersWithRequiredField(t *testing.T) { type test struct { MsgDescs []*descriptorpb.DescriptorProto Message string Params []openapiParameterObject } messageSchema := &openapi_options.Schema{ JsonSchema: &openapi_options.JSONSchema{ Required: []string{"a"}, }, } messageOption := &descriptorpb.MessageOptions{} proto.SetExtension(messageOption, openapi_options.E_Openapiv2Schema, messageSchema) fieldSchema := &openapi_options.JSONSchema{Required: []string{"b"}} fieldOption := &descriptorpb.FieldOptions{} proto.SetExtension(fieldOption, openapi_options.E_Openapiv2Field, fieldSchema) // TODO(makdon): is nested field's test case necessary here? tests := []test{ { MsgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("a"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("b"), Type: descriptorpb.FieldDescriptorProto_TYPE_DOUBLE.Enum(), Number: proto.Int32(2), Options: fieldOption, }, { Name: proto.String("c"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Label: descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum(), Number: proto.Int32(3), }, }, Options: messageOption, }, }, Message: "ExampleMessage", Params: []openapiParameterObject{ { Name: "a", In: "query", Required: true, Type: "string", }, { Name: "b", In: "query", Required: true, Type: "number", Format: "double", }, { Name: "c", In: "query", Required: false, Type: "array", CollectionFormat: "multi", }, }, }, } for _, test := range tests { reg := descriptor.NewRegistry() msgs := []*descriptor.Message{} for _, msgdesc := range test.MsgDescs { msgs = append(msgs, &descriptor.Message{DescriptorProto: msgdesc}) } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), Dependency: []string{}, MessageType: test.MsgDescs, Service: []*descriptorpb.ServiceDescriptorProto{}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: msgs, } err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}, }) if err != nil { t.Fatalf("failed to load code generator request: %v", err) } message, err := reg.LookupMsg("", ".example."+test.Message) if err != nil { t.Fatalf("failed to lookup message: %s", err) } params, err := messageToQueryParameters(message, reg, []descriptor.Parameter{}, nil, "") if err != nil { t.Fatalf("failed to convert message to query parameters: %s", err) } // avoid checking Items for array types for i := range params { params[i].Items = nil } if !reflect.DeepEqual(params, test.Params) { t.Errorf("expected %v, got %v", test.Params, params) } } } func TestMessageToQueryParametersWithDeprecatedField(t *testing.T) { annotationOptions := func() *descriptorpb.FieldOptions { opts := &descriptorpb.FieldOptions{} proto.SetExtension(opts, openapi_options.E_Openapiv2Field, &openapi_options.JSONSchema{ FieldConfiguration: &openapi_options.JSONSchema_FieldConfiguration{ Deprecated: true, }, }) return opts } type test struct { MsgDescs []*descriptorpb.DescriptorProto Message string Params []openapiParameterObject enableFieldDeprecation bool } tests := []test{ { MsgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("deprecated_via_proto"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), Options: &descriptorpb.FieldOptions{ Deprecated: proto.Bool(true), }, }, { Name: proto.String("deprecated_via_annotation"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), Options: annotationOptions(), }, { Name: proto.String("active_field"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(3), }, }, }, }, Message: "ExampleMessage", enableFieldDeprecation: true, Params: []openapiParameterObject{ { Name: "deprecated_via_proto", In: "query", Required: false, Type: "string", Deprecated: true, }, { Name: "deprecated_via_annotation", In: "query", Required: false, Type: "string", Deprecated: true, }, { Name: "active_field", In: "query", Required: false, Type: "string", }, }, }, { MsgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("deprecated_via_proto"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), Options: &descriptorpb.FieldOptions{ Deprecated: proto.Bool(true), }, }, { Name: proto.String("deprecated_via_annotation"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), Options: annotationOptions(), }, { Name: proto.String("active_field"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(3), }, }, }, }, Message: "ExampleMessage", enableFieldDeprecation: false, Params: []openapiParameterObject{ { Name: "deprecated_via_proto", In: "query", Required: false, Type: "string", Deprecated: false, }, { Name: "deprecated_via_annotation", In: "query", Required: false, Type: "string", Deprecated: true, }, { Name: "active_field", In: "query", Required: false, Type: "string", }, }, }, } // Enable or disable proto-field deprecation per test case before loading descriptors. for _, test := range tests { reg := descriptor.NewRegistry() reg.SetEnableFieldDeprecation(test.enableFieldDeprecation) msgs := []*descriptor.Message{} for _, msgdesc := range test.MsgDescs { msgs = append(msgs, &descriptor.Message{DescriptorProto: msgdesc}) } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), Dependency: []string{}, MessageType: test.MsgDescs, Service: []*descriptorpb.ServiceDescriptorProto{}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: msgs, } err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}, }) if err != nil { t.Fatalf("failed to load code generator request: %v", err) } message, err := reg.LookupMsg("", ".example."+test.Message) if err != nil { t.Fatalf("failed to lookup message: %s", err) } params, err := messageToQueryParameters(message, reg, []descriptor.Parameter{}, nil, "") if err != nil { t.Fatalf("failed to convert message to query parameters: %s", err) } for i := range params { params[i].Items = nil } if !reflect.DeepEqual(params, test.Params) { t.Errorf("expected %v, got %v", test.Params, params) } } } func TestMessageToQueryParametersWithEnumFieldOption(t *testing.T) { type test struct { MsgDescs []*descriptorpb.DescriptorProto Message string Params []openapiParameterObject } fieldSchema := &openapi_options.JSONSchema{Enum: []string{"enum1", "enum2"}} fieldOption := &descriptorpb.FieldOptions{} proto.SetExtension(fieldOption, openapi_options.E_Openapiv2Field, fieldSchema) tests := []test{ { MsgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("a"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), Options: fieldOption, }, { Name: proto.String("b"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), }, { Name: proto.String("c"), Type: descriptorpb.FieldDescriptorProto_TYPE_ENUM.Enum(), TypeName: proto.String(".example.ExampleMessage.EnabledEnum"), Number: proto.Int32(3), }, { Name: proto.String("d"), Type: descriptorpb.FieldDescriptorProto_TYPE_ENUM.Enum(), TypeName: proto.String(".example.ExampleMessage.EnabledEnum"), Number: proto.Int32(4), Options: fieldOption, }, }, EnumType: []*descriptorpb.EnumDescriptorProto{ { Name: proto.String("EnabledEnum"), Value: []*descriptorpb.EnumValueDescriptorProto{ {Name: proto.String("FALSE"), Number: proto.Int32(0)}, {Name: proto.String("TRUE"), Number: proto.Int32(1)}, }, }, }, }, }, Message: "ExampleMessage", Params: []openapiParameterObject{ { Name: "a", In: "query", Type: "string", Enum: []string{"enum1", "enum2"}, }, { Name: "b", In: "query", Type: "string", }, { Name: "c", In: "query", Type: "string", Enum: []string{"FALSE", "TRUE"}, Default: "FALSE", }, { Name: "d", In: "query", Type: "string", Enum: []string{"FALSE", "TRUE"}, Default: "FALSE", }, }, }, } for _, test := range tests { reg := descriptor.NewRegistry() msgs := []*descriptor.Message{} for _, msgdesc := range test.MsgDescs { msgs = append(msgs, &descriptor.Message{DescriptorProto: msgdesc}) } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), Dependency: []string{}, MessageType: test.MsgDescs, Service: []*descriptorpb.ServiceDescriptorProto{}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: msgs, } err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}, }) if err != nil { t.Fatalf("failed to load code generator request: %v", err) } message, err := reg.LookupMsg("", ".example."+test.Message) if err != nil { t.Fatalf("failed to lookup message: %s", err) } params, err := messageToQueryParameters(message, reg, []descriptor.Parameter{}, nil, "") if err != nil { t.Fatalf("failed to convert message to query parameters: %s", err) } // avoid checking Items for array types for i := range params { params[i].Items = nil } if !reflect.DeepEqual(params, test.Params) { t.Errorf("expected %v, got %v", test.Params, params) } } } func TestApplyTemplateSimple(t *testing.T) { msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Example"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } msg := &descriptor.Message{ DescriptorProto: msgdesc, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgdesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "GET", Body: &descriptor.Body{FieldPath: nil}, PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/echo", // TODO(achew22): Figure out what this should really be }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() if err := AddErrorDefs(reg); err != nil { t.Errorf("AddErrorDefs(%#v) failed with %v; want success", reg, err) return } fileCL := crossLinkFixture(&file) err := reg.Load(reqFromFile(fileCL)) if err != nil { t.Errorf("reg.Load(%#v) failed with %v; want success", file, err) return } result, err := applyTemplate(param{File: fileCL, reg: reg}) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } if want, is, name := "2.0", result.Swagger, "Swagger"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } if want, is, name := "", result.BasePath, "BasePath"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } if want, is, name := ([]string)(nil), result.Schemes, "Schemes"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } if want, is, name := []string{"application/json"}, result.Consumes, "Consumes"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } if want, is, name := []string{"application/json"}, result.Produces, "Produces"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } // If there was a failure, print out the input and the json result for debugging. if t.Failed() { t.Errorf("had: %s", file) t.Errorf("got: %s", fmt.Sprint(result)) } } func TestApplyTemplateMultiService(t *testing.T) { msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Example"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), } // Create two services that have the same method name. We will test that the // operation IDs are different svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } svc2 := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("OtherService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } msg := &descriptor.Message{ DescriptorProto: msgdesc, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgdesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "GET", Body: &descriptor.Body{FieldPath: nil}, PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/echo", }, }, }, }, }, }, { ServiceDescriptorProto: svc2, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "GET", Body: &descriptor.Body{FieldPath: nil}, PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/ping", }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() if err := AddErrorDefs(reg); err != nil { t.Errorf("AddErrorDefs(%#v) failed with %v; want success", reg, err) return } fileCL := crossLinkFixture(&file) err := reg.Load(reqFromFile(fileCL)) if err != nil { t.Errorf("reg.Load(%#v) failed with %v; want success", file, err) return } result, err := applyTemplate(param{File: fileCL, reg: reg}) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } // Check that the two services have unique operation IDs even though they // have the same method name. if want, is := "ExampleService_Example", result.getPathItemObject("/v1/echo").Get.OperationID; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).Paths[0].Get.OperationID = %s want to be %s", file, is, want) } if want, is := "OtherService_Example", result.getPathItemObject("/v1/ping").Get.OperationID; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).Paths[0].Get.OperationID = %s want to be %s", file, is, want) } // If there was a failure, print out the input and the json result for debugging. if t.Failed() { t.Errorf("had: %s", file) t.Errorf("got: %s", fmt.Sprint(result)) } } func TestApplyTemplateOpenAPIConfigFromYAML(t *testing.T) { msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Example"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } msg := &descriptor.Message{ DescriptorProto: msgdesc, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgdesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "GET", Body: &descriptor.Body{FieldPath: nil}, PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/echo", // TODO(achew22): Figure out what this should really be }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() if err := AddErrorDefs(reg); err != nil { t.Errorf("AddErrorDefs(%#v) failed with %v; want success", reg, err) return } fileCL := crossLinkFixture(&file) err := reg.Load(reqFromFile(fileCL)) if err != nil { t.Errorf("reg.Load(%#v) failed with %v; want success", file, err) return } openapiOptions := &openapiconfig.OpenAPIOptions{ Service: []*openapiconfig.OpenAPIServiceOption{ { Service: "example.ExampleService", Option: &openapi_options.Tag{ Description: "ExampleService description", ExternalDocs: &openapi_options.ExternalDocumentation{ Description: "Find out more about ExampleService", }, }, }, }, } if err := reg.RegisterOpenAPIOptions(openapiOptions); err != nil { t.Errorf("reg.RegisterOpenAPIOptions for Service %#v failed with %v; want success", openapiOptions.Service, err) return } result, err := applyTemplate(param{File: fileCL, reg: reg}) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } if want, is, name := "ExampleService description", result.Tags[0].Description, "Tags[0].Description"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } if want, is, name := "Find out more about ExampleService", result.Tags[0].ExternalDocs.Description, "Tags[0].ExternalDocs.Description"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } reg.SetDisableServiceTags(true) res, err := applyTemplate(param{File: fileCL, reg: reg}) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } if got, want := len(res.Tags), 0; got != want { t.Fatalf("len(applyTemplate(%#v).Tags) = %d want to be %d", file, got, want) } // If there was a failure, print out the input and the json result for debugging. if t.Failed() { t.Errorf("had: %s", file) t.Errorf("got: %s", fmt.Sprint(result)) } } func TestApplyTemplateOverrideWithOperation(t *testing.T) { newFile := func() *descriptor.File { msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Example"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), Options: &descriptorpb.MethodOptions{}, } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } msg := &descriptor.Message{ DescriptorProto: msgdesc, } return &descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgdesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "GET", Body: &descriptor.Body{FieldPath: nil}, PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/echo", // TODO(achew22): Figure out what this should really be }, }, }, }, }, }, }, } } verifyTemplateFromReq := func(t *testing.T, reg *descriptor.Registry, file *descriptor.File, opts *openapiconfig.OpenAPIOptions) { if err := AddErrorDefs(reg); err != nil { t.Errorf("AddErrorDefs(%#v) failed with %v; want success", reg, err) return } fileCL := crossLinkFixture(file) err := reg.Load(reqFromFile(fileCL)) if err != nil { t.Errorf("reg.Load(%#v) failed with %v; want success", *file, err) return } if opts != nil { if err := reg.RegisterOpenAPIOptions(opts); err != nil { t.Fatalf("failed to register OpenAPI options: %s", err) } } result, err := applyTemplate(param{File: fileCL, reg: reg}) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", *file, err) return } if want, is := "MyExample", result.getPathItemObject("/v1/echo").Get.OperationID; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).Paths[0].Get.OperationID = %s want to be %s", *file, is, want) } if want, is := []string{"application/xml"}, result.getPathItemObject("/v1/echo").Get.Consumes; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).Paths[0].Get.Consumes = %s want to be %s", *file, is, want) } if want, is := []string{"application/json", "application/xml"}, result.getPathItemObject("/v1/echo").Get.Produces; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).Paths[0].Get.Produces = %s want to be %s", *file, is, want) } // If there was a failure, print out the input and the json result for debugging. if t.Failed() { t.Errorf("had: %s", *file) t.Errorf("got: %s", fmt.Sprint(result)) } } openapiOperation := openapi_options.Operation{ OperationId: "MyExample", Consumes: []string{"application/xml"}, Produces: []string{"application/json", "application/xml"}, } t.Run("verify override via method option", func(t *testing.T) { file := newFile() proto.SetExtension(proto.Message(file.Services[0].Methods[0].MethodDescriptorProto.Options), openapi_options.E_Openapiv2Operation, &openapiOperation) reg := descriptor.NewRegistry() verifyTemplateFromReq(t, reg, file, nil) }) t.Run("verify override options annotations", func(t *testing.T) { file := newFile() reg := descriptor.NewRegistry() opts := &openapiconfig.OpenAPIOptions{ Method: []*openapiconfig.OpenAPIMethodOption{ { Method: "example.ExampleService.Example", Option: &openapiOperation, }, }, } verifyTemplateFromReq(t, reg, file, opts) }) } func TestApplyTemplateExtensions(t *testing.T) { newFile := func() *descriptor.File { msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Example"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), Options: &descriptorpb.MethodOptions{}, } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } msg := &descriptor.Message{ DescriptorProto: msgdesc, } return &descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgdesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "GET", Body: &descriptor.Body{FieldPath: nil}, PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/echo", // TODO(achew22): Figure out what this should really be }, }, }, }, }, }, }, } } swagger := openapi_options.Swagger{ Info: &openapi_options.Info{ Title: "test", Extensions: map[string]*structpb.Value{ "x-info-extension": {Kind: &structpb.Value_StringValue{StringValue: "bar"}}, }, }, Extensions: map[string]*structpb.Value{ "x-foo": {Kind: &structpb.Value_StringValue{StringValue: "bar"}}, "x-bar": {Kind: &structpb.Value_ListValue{ListValue: &structpb.ListValue{ Values: []*structpb.Value{{Kind: &structpb.Value_StringValue{StringValue: "baz"}}}, }}}, }, SecurityDefinitions: &openapi_options.SecurityDefinitions{ Security: map[string]*openapi_options.SecurityScheme{ "somescheme": { Extensions: map[string]*structpb.Value{ "x-security-baz": {Kind: &structpb.Value_BoolValue{BoolValue: true}}, }, }, }, }, Tags: []*openapi_options.Tag{ { Name: "test tag", Description: "test tag description", Extensions: map[string]*structpb.Value{ "x-traitTag": {Kind: &structpb.Value_BoolValue{BoolValue: true}}, }, }, }, } openapiOperation := openapi_options.Operation{ Responses: map[string]*openapi_options.Response{ "200": { Extensions: map[string]*structpb.Value{ "x-resp-id": {Kind: &structpb.Value_StringValue{StringValue: "resp1000"}}, }, }, }, Extensions: map[string]*structpb.Value{ "x-op-foo": {Kind: &structpb.Value_StringValue{StringValue: "baz"}}, }, } verifyTemplateExtensions := func(t *testing.T, reg *descriptor.Registry, file *descriptor.File, opts *openapiconfig.OpenAPIOptions, ) { if err := AddErrorDefs(reg); err != nil { t.Errorf("AddErrorDefs(%#v) failed with %v; want success", reg, err) return } fileCL := crossLinkFixture(file) err := reg.Load(reqFromFile(fileCL)) if err != nil { t.Errorf("reg.Load(%#v) failed with %v; want success", file, err) return } if opts != nil { if err := reg.RegisterOpenAPIOptions(opts); err != nil { t.Fatalf("failed to register OpenAPI annotations: %s", err) } } result, err := applyTemplate(param{File: fileCL, reg: reg}) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } if want, is, name := "2.0", result.Swagger, "Swagger"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } if got, want := len(result.extensions), 2; got != want { t.Fatalf("len(applyTemplate(%#v).Extensions) = %d want to be %d", file, got, want) } if got, want := result.extensions[0].key, "x-bar"; got != want { t.Errorf("applyTemplate(%#v).Extensions[0].key = %s want to be %s", file, got, want) } if got, want := result.extensions[1].key, "x-foo"; got != want { t.Errorf("applyTemplate(%#v).Extensions[1].key = %s want to be %s", file, got, want) } { var got []string err = marshaler.Unmarshal(result.extensions[0].value, &got) if err != nil { t.Fatalf("marshaler.Unmarshal failed: %v", err) } want := []string{"baz"} if diff := cmp.Diff(got, want); diff != "" { t.Error(diff) } } { var got string err = marshaler.Unmarshal(result.extensions[1].value, &got) if err != nil { t.Fatalf("marshaler.Unmarshal failed: %v", err) } want := "bar" if diff := cmp.Diff(got, want); diff != "" { t.Error(diff) } } var scheme openapiSecuritySchemeObject for _, v := range result.SecurityDefinitions { scheme = v } if want, is, name := []extension{ {key: "x-security-baz", value: json.RawMessage("true")}, }, scheme.extensions, "SecurityScheme.Extensions"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } if want, is, name := []extension{ {key: "x-info-extension", value: json.RawMessage("\"bar\"")}, }, result.Info.extensions, "Info.Extensions"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } var operation *openapiOperationObject var response openapiResponseObject for _, v := range result.Paths { operation = v.PathItemObject.Get response = v.PathItemObject.Get.Responses["200"] } if want, is, name := []extension{ {key: "x-op-foo", value: json.RawMessage("\"baz\"")}, }, operation.extensions, "operation.Extensions"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } if want, is, name := []extension{ {key: "x-resp-id", value: json.RawMessage("\"resp1000\"")}, }, response.extensions, "response.Extensions"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } if len(result.Tags) == 0 { t.Errorf("No tags found in result") return } tag := result.Tags[0] if want, is, name := []extension{ {key: "x-traitTag", value: json.RawMessage("true")}, }, tag.extensions, "Tags[0].Extensions"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } } t.Run("verify template options set via proto options", func(t *testing.T) { file := newFile() proto.SetExtension(proto.Message(file.FileDescriptorProto.Options), openapi_options.E_Openapiv2Swagger, &swagger) proto.SetExtension(proto.Message(file.Services[0].Methods[0].Options), openapi_options.E_Openapiv2Operation, &openapiOperation) reg := descriptor.NewRegistry() verifyTemplateExtensions(t, reg, file, nil) }) t.Run("verify template options set via annotations", func(t *testing.T) { file := newFile() opts := &openapiconfig.OpenAPIOptions{ File: []*openapiconfig.OpenAPIFileOption{ { File: "example.proto", Option: &swagger, }, }, Method: []*openapiconfig.OpenAPIMethodOption{ { Method: "example.ExampleService.Example", Option: &openapiOperation, }, }, } reg := descriptor.NewRegistry() verifyTemplateExtensions(t, reg, file, opts) }) } func TestApplyTemplateHeaders(t *testing.T) { newFile := func() *descriptor.File { msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Example"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), Options: &descriptorpb.MethodOptions{}, } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } msg := &descriptor.Message{ DescriptorProto: msgdesc, } return &descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgdesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "GET", Body: &descriptor.Body{FieldPath: nil}, PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/echo", // TODO(achew22): Figure out what this should really be }, }, }, }, }, }, }, } } openapiOperation := openapi_options.Operation{ Responses: map[string]*openapi_options.Response{ "200": { Description: "Testing Headers", Headers: map[string]*openapi_options.Header{ "string": { Description: "string header description", Type: "string", Format: "uuid", Pattern: "", }, "boolean": { Description: "boolean header description", Type: "boolean", Default: "true", Pattern: "^true|false$", }, "integer": { Description: "integer header description", Type: "integer", Default: "0", Pattern: "^[0-9]$", }, "number": { Description: "number header description", Type: "number", Default: "1.2", Pattern: "^[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$", }, }, }, }, } verifyTemplateHeaders := func(t *testing.T, reg *descriptor.Registry, file *descriptor.File, opts *openapiconfig.OpenAPIOptions, ) { if err := AddErrorDefs(reg); err != nil { t.Errorf("AddErrorDefs(%#v) failed with %v; want success", reg, err) return } fileCL := crossLinkFixture(file) err := reg.Load(reqFromFile(fileCL)) if err != nil { t.Errorf("reg.Load(%#v) failed with %v; want success", file, err) return } if opts != nil { if err := reg.RegisterOpenAPIOptions(opts); err != nil { t.Fatalf("failed to register OpenAPI annotations: %s", err) } } result, err := applyTemplate(param{File: fileCL, reg: reg}) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } if want, is, name := "2.0", result.Swagger, "Swagger"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } var response openapiResponseObject for _, v := range result.Paths { response = v.PathItemObject.Get.Responses["200"] } if want, is, name := []openapiHeadersObject{ { "String": openapiHeaderObject{ Description: "string header description", Type: "string", Format: "uuid", Pattern: "", }, "Boolean": openapiHeaderObject{ Description: "boolean header description", Type: "boolean", Default: RawExample("true"), Pattern: "^true|false$", }, "Integer": openapiHeaderObject{ Description: "integer header description", Type: "integer", Default: RawExample("0"), Pattern: "^[0-9]$", }, "Number": openapiHeaderObject{ Description: "number header description", Type: "number", Default: RawExample("1.2"), Pattern: "^[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$", }, }, }[0], response.Headers, "response.Headers"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } } t.Run("verify template options set via proto options", func(t *testing.T) { file := newFile() proto.SetExtension(proto.Message(file.Services[0].Methods[0].Options), openapi_options.E_Openapiv2Operation, &openapiOperation) reg := descriptor.NewRegistry() verifyTemplateHeaders(t, reg, file, nil) }) } func TestValidateHeaderType(t *testing.T) { type test struct { Type string Format string expectedError error } tests := []test{ { "string", "date-time", nil, }, { "boolean", "", nil, }, { "integer", "uint", nil, }, { "integer", "uint8", nil, }, { "integer", "uint16", nil, }, { "integer", "uint32", nil, }, { "integer", "uint64", nil, }, { "integer", "int", nil, }, { "integer", "int8", nil, }, { "integer", "int16", nil, }, { "integer", "int32", nil, }, { "integer", "int64", nil, }, { "integer", "float64", errors.New("the provided format \"float64\" is not a valid extension of the type \"integer\""), }, { "integer", "uuid", errors.New("the provided format \"uuid\" is not a valid extension of the type \"integer\""), }, { "number", "uint", nil, }, { "number", "uint8", nil, }, { "number", "uint16", nil, }, { "number", "uint32", nil, }, { "number", "uint64", nil, }, { "number", "int", nil, }, { "number", "int8", nil, }, { "number", "int16", nil, }, { "number", "int32", nil, }, { "number", "int64", nil, }, { "number", "float", nil, }, { "number", "float32", nil, }, { "number", "float64", nil, }, { "number", "complex64", nil, }, { "number", "complex128", nil, }, { "number", "double", nil, }, { "number", "byte", nil, }, { "number", "rune", nil, }, { "number", "uintptr", nil, }, { "number", "date", errors.New("the provided format \"date\" is not a valid extension of the type \"number\""), }, { "array", "", errors.New("the provided header type \"array\" is not supported"), }, { "foo", "", errors.New("the provided header type \"foo\" is not supported"), }, } for _, v := range tests { err := validateHeaderTypeAndFormat(v.Type, v.Format) if v.expectedError == nil { if err != nil { t.Errorf("unexpected error %v", err) } } else { if err == nil { t.Fatal("expected header error not returned") } if err.Error() != v.expectedError.Error() { t.Errorf("expected error malformed, expected %q, got %q", v.expectedError.Error(), err.Error()) } } } } func TestValidateDefaultValueType(t *testing.T) { type test struct { Type string Value string Format string expectedError error } tests := []test{ { "string", `"string"`, "", nil, }, { "string", "\"2012-11-01T22:08:41+00:00\"", "date-time", nil, }, { "string", "\"2012-11-01\"", "date", nil, }, { "string", "0", "", errors.New("the provided default value \"0\" does not match provider type \"string\", or is not properly quoted with escaped quotations"), }, { "string", "false", "", errors.New("the provided default value \"false\" does not match provider type \"string\", or is not properly quoted with escaped quotations"), }, { "boolean", "true", "", nil, }, { "boolean", "0", "", errors.New("the provided default value \"0\" does not match provider type \"boolean\""), }, { "boolean", `"string"`, "", errors.New("the provided default value \"\\\"string\\\"\" does not match provider type \"boolean\""), }, { "number", "1.2", "", nil, }, { "number", "123", "", nil, }, { "number", "nan", "", errors.New("the provided number \"nan\" is not a valid JSON number"), }, { "number", "NaN", "", errors.New("the provided number \"NaN\" is not a valid JSON number"), }, { "number", "-459.67", "", nil, }, { "number", "inf", "", errors.New("the provided number \"inf\" is not a valid JSON number"), }, { "number", "infinity", "", errors.New("the provided number \"infinity\" is not a valid JSON number"), }, { "number", "Inf", "", errors.New("the provided number \"Inf\" is not a valid JSON number"), }, { "number", "Infinity", "", errors.New("the provided number \"Infinity\" is not a valid JSON number"), }, { "number", "false", "", errors.New("the provided default value \"false\" does not match provider type \"number\""), }, { "number", `"string"`, "", errors.New("the provided default value \"\\\"string\\\"\" does not match provider type \"number\""), }, { "integer", "2", "", nil, }, { "integer", fmt.Sprint(math.MaxInt32), "int32", nil, }, { "integer", fmt.Sprint(int64(math.MaxInt32) + 1), "int32", errors.New("the provided default value \"2147483648\" does not match provided format \"int32\""), }, { "integer", fmt.Sprint(int64(math.MaxInt64)), "int64", nil, }, { "integer", "9223372036854775808", "int64", errors.New("the provided default value \"9223372036854775808\" does not match provided format \"int64\""), }, { "integer", "18446744073709551615", "uint64", nil, }, { "integer", "false", "", errors.New("the provided default value \"false\" does not match provided type \"integer\""), }, { "integer", "1.2", "", errors.New("the provided default value \"1.2\" does not match provided type \"integer\""), }, { "integer", `"string"`, "", errors.New("the provided default value \"\\\"string\\\"\" does not match provided type \"integer\""), }, } for _, v := range tests { err := validateDefaultValueTypeAndFormat(v.Type, v.Value, v.Format) if v.expectedError == nil { if err != nil { t.Errorf("unexpected error '%v'", err) } } else { if err == nil { t.Error("expected update error not returned") } if err.Error() != v.expectedError.Error() { t.Errorf("expected error malformed, expected %q, got %q", v.expectedError.Error(), err.Error()) } } } } func TestApplyTemplateRequestWithoutClientStreaming(t *testing.T) { msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("nested"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String("NestedMessage"), Number: proto.Int32(1), }, }, } nesteddesc := &descriptorpb.DescriptorProto{ Name: proto.String("NestedMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("int32"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_INT32.Enum(), Number: proto.Int32(1), }, { Name: proto.String("bool"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_BOOL.Enum(), Number: proto.Int32(2), }, }, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Echo"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), ClientStreaming: proto.Bool(false), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } meth.ServerStreaming = proto.Bool(false) msg := &descriptor.Message{ DescriptorProto: msgdesc, } nested := &descriptor.Message{ DescriptorProto: nesteddesc, } nestedField := &descriptor.Field{ Message: msg, FieldDescriptorProto: msg.GetField()[0], } intField := &descriptor.Field{ Message: nested, FieldDescriptorProto: nested.GetField()[0], } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgdesc, nesteddesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg, nested}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/echo", // TODO(achew): Figure out what this should really be }, PathParams: []descriptor.Parameter{ { FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "nested", Target: nestedField, }, { Name: "int32", Target: intField, }, }), Target: intField, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "nested", Target: nestedField, }, }), }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() if err := AddErrorDefs(reg); err != nil { t.Errorf("AddErrorDefs(%#v) failed with %v; want success", reg, err) return } fmt.Fprintln(os.Stderr, "fd", file.FileDescriptorProto) err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}, }) if err != nil { t.Fatalf("failed to load code generator request: %v", err) } fmt.Fprintln(os.Stderr, "AllFQMNs", reg.GetAllFQMNs()) result, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } if want, got := "2.0", result.Swagger; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).Swagger = %s want to be %s", file, got, want) } if want, got := "", result.BasePath; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).BasePath = %s want to be %s", file, got, want) } if want, got := ([]string)(nil), result.Schemes; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).Schemes = %s want to be %s", file, got, want) } if want, got := []string{"application/json"}, result.Consumes; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).Consumes = %s want to be %s", file, got, want) } if want, got := []string{"application/json"}, result.Produces; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).Produces = %s want to be %s", file, got, want) } // If there was a failure, print out the input and the json result for debugging. if t.Failed() { t.Errorf("had: %s", file) t.Errorf("got: %s", fmt.Sprint(result)) } } func TestApplyTemplateRequestWithClientStreaming(t *testing.T) { msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("nested"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String("NestedMessage"), Number: proto.Int32(1), }, }, } nesteddesc := &descriptorpb.DescriptorProto{ Name: proto.String("NestedMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("int32"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_INT32.Enum(), Number: proto.Int32(1), }, { Name: proto.String("bool"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_BOOL.Enum(), Number: proto.Int32(2), }, }, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Echo"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), ClientStreaming: proto.Bool(true), ServerStreaming: proto.Bool(true), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } msg := &descriptor.Message{ DescriptorProto: msgdesc, } nested := &descriptor.Message{ DescriptorProto: nesteddesc, } nestedField := &descriptor.Field{ Message: msg, FieldDescriptorProto: msg.GetField()[0], } intField := &descriptor.Field{ Message: nested, FieldDescriptorProto: nested.GetField()[0], } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgdesc, nesteddesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg, nested}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/echo", // TODO(achew): Figure out what this should really be }, PathParams: []descriptor.Parameter{ { FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "nested", Target: nestedField, }, { Name: "int32", Target: intField, }, }), Target: intField, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "nested", Target: nestedField, }, }), }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() if err := AddErrorDefs(reg); err != nil { t.Errorf("AddErrorDefs(%#v) failed with %v; want success", reg, err) return } err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}, }) if err != nil { t.Fatalf("failed to load code generator request: %v", err) } result, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } // Only ExampleMessage must be present, not NestedMessage if want, got, name := 3, len(result.Definitions), "len(Definitions)"; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %d want to be %d", file, name, got, want) } if _, ok := result.getPathItemObject("/v1/echo").Post.Responses["200"]; !ok { t.Errorf("applyTemplate(%#v).%s = expected 200 response to be defined", file, `result.getPathItemObject("/v1/echo").Post.Responses["200"]`) } else { if want, got, name := "A successful response.(streaming responses)", result.getPathItemObject("/v1/echo").Post.Responses["200"].Description, `result.getPathItemObject("/v1/echo").Post.Responses["200"].Description`; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, got, want) } streamExampleExampleMessage := result.getPathItemObject("/v1/echo").Post.Responses["200"].Schema if want, got, name := "object", streamExampleExampleMessage.Type, `result.getPathItemObject("/v1/echo").Post.Responses["200"].Schema.Type`; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, got, want) } if want, got, name := "Stream result of exampleExampleMessage", streamExampleExampleMessage.Title, `result.getPathItemObject("/v1/echo").Post.Responses["200"].Schema.Title`; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, got, want) } streamExampleExampleMessageProperties := *(streamExampleExampleMessage.Properties) if want, got, name := 2, len(streamExampleExampleMessageProperties), `len(StreamDefinitions["exampleExampleMessage"].Properties)`; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %d want to be %d", file, name, got, want) } else { resultProperty := streamExampleExampleMessageProperties[0] if want, got, name := "result", resultProperty.Key, `(*(StreamDefinitions["exampleExampleMessage"].Properties))[0].Key`; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, got, want) } result := resultProperty.Value.(openapiSchemaObject) if want, got, name := "#/definitions/exampleExampleMessage", result.Ref, `((*(StreamDefinitions["exampleExampleMessage"].Properties))[0].Value.(openapiSchemaObject)).Ref`; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, got, want) } errorProperty := streamExampleExampleMessageProperties[1] if want, got, name := "error", errorProperty.Key, `(*(StreamDefinitions["exampleExampleMessage"].Properties))[0].Key`; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, got, want) } err := errorProperty.Value.(openapiSchemaObject) if want, got, name := "#/definitions/rpcStatus", err.Ref, `((*(StreamDefinitions["exampleExampleMessage"].Properties))[0].Value.(openapiSchemaObject)).Ref`; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, got, want) } } } // If there was a failure, print out the input and the json result for debugging. if t.Failed() { t.Errorf("had: %s", file) t.Errorf("got: %s", fmt.Sprint(result)) } } func TestApplyTemplateRequestWithServerStreamingAndNoStandardErrors(t *testing.T) { msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("nested"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String("NestedMessage"), Number: proto.Int32(1), }, }, } nesteddesc := &descriptorpb.DescriptorProto{ Name: proto.String("NestedMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("int32"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_INT32.Enum(), Number: proto.Int32(1), }, { Name: proto.String("bool"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_BOOL.Enum(), Number: proto.Int32(2), }, }, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Echo"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), ClientStreaming: proto.Bool(false), ServerStreaming: proto.Bool(true), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } msg := &descriptor.Message{ DescriptorProto: msgdesc, } nested := &descriptor.Message{ DescriptorProto: nesteddesc, } nestedField := &descriptor.Field{ Message: msg, FieldDescriptorProto: msg.GetField()[0], } intField := &descriptor.Field{ Message: nested, FieldDescriptorProto: nested.GetField()[0], } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgdesc, nesteddesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg, nested}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/echo", }, PathParams: []descriptor.Parameter{ { FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "nested", Target: nestedField, }, { Name: "int32", Target: intField, }, }), Target: intField, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "nested", Target: nestedField, }, }), }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() if err := AddErrorDefs(reg); err != nil { t.Errorf("AddErrorDefs(%#v) failed with %v; want success", reg, err) return } err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}, }) if err != nil { t.Fatalf("failed to load code generator request: %v", err) } reg.SetDisableDefaultErrors(true) result, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } // Should only include the message, no status or any type if want, got, name := 1, len(result.Definitions), "len(Definitions)"; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %d want to be %d", file, name, got, want) } if _, ok := result.getPathItemObject("/v1/echo").Post.Responses["200"]; !ok { t.Errorf("applyTemplate(%#v).%s = expected 200 response to be defined", file, `result.getPathItemObject("/v1/echo").Post.Responses["200"]`) } else { if want, got, name := "A successful response.(streaming responses)", result.getPathItemObject("/v1/echo").Post.Responses["200"].Description, `result.getPathItemObject("/v1/echo").Post.Responses["200"].Description`; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, got, want) } streamExampleExampleMessage := result.getPathItemObject("/v1/echo").Post.Responses["200"].Schema if want, got, name := "object", streamExampleExampleMessage.Type, `result.getPathItemObject("/v1/echo").Post.Responses["200"].Schema.Type`; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, got, want) } if want, got, name := "Stream result of exampleExampleMessage", streamExampleExampleMessage.Title, `result.getPathItemObject("/v1/echo").Post.Responses["200"].Schema.Title`; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, got, want) } streamExampleExampleMessageProperties := *(streamExampleExampleMessage.Properties) if want, got, name := 1, len(streamExampleExampleMessageProperties), `len(StreamDefinitions["exampleExampleMessage"].Properties)`; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %d want to be %d", file, name, got, want) } else { resultProperty := streamExampleExampleMessageProperties[0] if want, got, name := "result", resultProperty.Key, `(*(StreamDefinitions["exampleExampleMessage"].Properties))[0].Key`; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, got, want) } result := resultProperty.Value.(openapiSchemaObject) if want, got, name := "#/definitions/exampleExampleMessage", result.Ref, `((*(StreamDefinitions["exampleExampleMessage"].Properties))[0].Value.(openapiSchemaObject)).Ref`; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, got, want) } } } // If there was a failure, print out the input and the json result for debugging. if t.Failed() { t.Errorf("had: %s", file) t.Errorf("got: %s", fmt.Sprint(result)) } } func TestApplyTemplateRequestWithUnusedReferences(t *testing.T) { reqdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("string"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, }, } respdesc := &descriptorpb.DescriptorProto{ Name: proto.String("EmptyMessage"), } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Example"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("EmptyMessage"), ClientStreaming: proto.Bool(false), ServerStreaming: proto.Bool(false), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } req := &descriptor.Message{ DescriptorProto: reqdesc, } resp := &descriptor.Message{ DescriptorProto: respdesc, } stringField := &descriptor.Field{ Message: req, FieldDescriptorProto: req.GetField()[0], } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{reqdesc, respdesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{req, resp}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: req, ResponseType: resp, Bindings: []*descriptor.Binding{ { HTTPMethod: "GET", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/example", }, }, { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/example/{string}", }, PathParams: []descriptor.Parameter{ { FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "string", Target: stringField, }, }), Target: stringField, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "string", Target: stringField, }, }), }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() if err := AddErrorDefs(reg); err != nil { t.Errorf("AddErrorDefs(%#v) failed with %v; want success", reg, err) return } err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}, }) if err != nil { t.Fatalf("failed to load code generator request: %v", err) } result, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } // Only EmptyMessage must be present, not ExampleMessage (plus error status) if want, got, name := 3, len(result.Definitions), "len(Definitions)"; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %d want to be %d", file, name, got, want) } // If there was a failure, print out the input and the json result for debugging. if t.Failed() { t.Errorf("had: %s", file) t.Errorf("got: %s", fmt.Sprint(result)) } } func TestApplyTemplateRequestWithBodyQueryParameters(t *testing.T) { bookDesc := &descriptorpb.DescriptorProto{ Name: proto.String("Book"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("name"), Label: descriptorpb.FieldDescriptorProto_LABEL_REQUIRED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("id"), Label: descriptorpb.FieldDescriptorProto_LABEL_REQUIRED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), }, }, } createDesc := &descriptorpb.DescriptorProto{ Name: proto.String("CreateBookRequest"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("parent"), Label: descriptorpb.FieldDescriptorProto_LABEL_REQUIRED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("book"), Label: descriptorpb.FieldDescriptorProto_LABEL_REQUIRED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), }, { Name: proto.String("book_id"), Label: descriptorpb.FieldDescriptorProto_LABEL_REQUIRED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(3), }, }, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("CreateBook"), InputType: proto.String("CreateBookRequest"), OutputType: proto.String("Book"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("BookService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } bookMsg := &descriptor.Message{ DescriptorProto: bookDesc, } createMsg := &descriptor.Message{ DescriptorProto: createDesc, } parentField := &descriptor.Field{ Message: createMsg, FieldDescriptorProto: createMsg.GetField()[0], } bookField := &descriptor.Field{ Message: createMsg, FieldMessage: bookMsg, FieldDescriptorProto: createMsg.GetField()[1], } bookIDField := &descriptor.Field{ Message: createMsg, FieldDescriptorProto: createMsg.GetField()[2], } createMsg.Fields = []*descriptor.Field{parentField, bookField, bookIDField} newFile := func() descriptor.File { return descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("book.proto"), MessageType: []*descriptorpb.DescriptorProto{bookDesc, createDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/book.pb", Name: "book_pb", }, Messages: []*descriptor.Message{bookMsg, createMsg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: createMsg, ResponseType: bookMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/{parent=publishers/*}/books", }, PathParams: []descriptor.Parameter{ { FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "parent", Target: parentField, }, }), Target: parentField, }, }, Body: &descriptor.Body{ FieldPath: []descriptor.FieldPathComponent{ { Name: "book", Target: bookField, }, }, }, }, }, }, }, }, }, } } type args struct { file descriptor.File } type paramOut struct { Name string In string Required bool } tests := []struct { name string args args want []paramOut }{ { name: "book_in_body", args: args{file: newFile()}, want: []paramOut{ {"parent", "path", true}, {"book", "body", true}, {"book_id", "query", false}, }, }, { name: "book_in_query", args: args{file: func() descriptor.File { f := newFile() f.Services[0].Methods[0].Bindings[0].Body = nil return f }()}, want: []paramOut{ {"parent", "path", true}, {"book", "query", false}, {"book_id", "query", false}, }, }, } for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { reg := descriptor.NewRegistry() if err := AddErrorDefs(reg); err != nil { t.Errorf("AddErrorDefs(%#v) failed with %v; want success", reg, err) return } err := reg.Load(&pluginpb.CodeGeneratorRequest{ProtoFile: []*descriptorpb.FileDescriptorProto{tt.args.file.FileDescriptorProto}}) if err != nil { t.Errorf("Registry.Load() failed with %v; want success", err) return } result, err := applyTemplate(param{File: crossLinkFixture(&tt.args.file), reg: reg}) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", tt.args.file, err) return } if _, ok := result.getPathItemObject("/v1/{parent}/books").Post.Responses["200"]; !ok { t.Errorf("applyTemplate(%#v).%s = expected 200 response to be defined", tt.args.file, `result.getPathItemObject("/v1/{parent}/books").Post.Responses["200"]`) } else { if want, got, name := 3, len(result.getPathItemObject("/v1/{parent}/books").Post.Parameters), `len(result.getPathItemObject("/v1/{parent}/books").Post.Parameters)`; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %d want to be %d", tt.args.file, name, got, want) } for i, want := range tt.want { p := result.getPathItemObject("/v1/{parent}/books").Post.Parameters[i] if got, name := (paramOut{p.Name, p.In, p.Required}), `result.getPathItemObject("/v1/{parent}/books").Post.Parameters[0]`; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %v want to be %v", tt.args.file, name, got, want) } } } // If there was a failure, print out the input and the json result for debugging. if t.Failed() { t.Errorf("had: %s", tt.args.file) t.Errorf("got: %s", fmt.Sprint(result)) } }) } } func TestApplyTemplateWithRequestAndBodyParameters(t *testing.T) { bookDesc := &descriptorpb.DescriptorProto{ Name: proto.String("Book"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("name"), Label: descriptorpb.FieldDescriptorProto_LABEL_REQUIRED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("id"), Label: descriptorpb.FieldDescriptorProto_LABEL_REQUIRED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), }, }, } createDesc := &descriptorpb.DescriptorProto{ Name: proto.String("CreateBookRequest"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("parent"), Label: descriptorpb.FieldDescriptorProto_LABEL_REQUIRED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("book"), Label: descriptorpb.FieldDescriptorProto_LABEL_REQUIRED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), }, { Name: proto.String("book_id"), Label: descriptorpb.FieldDescriptorProto_LABEL_REQUIRED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(3), }, }, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("CreateBook"), InputType: proto.String("CreateBookRequest"), OutputType: proto.String("Book"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("BookService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } bookMsg := &descriptor.Message{ DescriptorProto: bookDesc, } createMsg := &descriptor.Message{ DescriptorProto: createDesc, } parentField := &descriptor.Field{ Message: createMsg, FieldDescriptorProto: createMsg.GetField()[0], } bookField := &descriptor.Field{ Message: createMsg, FieldMessage: bookMsg, FieldDescriptorProto: createMsg.GetField()[1], } bookIDField := &descriptor.Field{ Message: createMsg, FieldDescriptorProto: createMsg.GetField()[2], } createMsg.Fields = []*descriptor.Field{parentField, bookField, bookIDField} file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("book.proto"), MessageType: []*descriptorpb.DescriptorProto{bookDesc, createDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/book.pb", Name: "book_pb", }, Messages: []*descriptor.Message{bookMsg, createMsg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: createMsg, ResponseType: bookMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/{parent=publishers/*}/books", }, PathParams: []descriptor.Parameter{ { FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "parent", Target: parentField, }, }), Target: parentField, }, }, Body: &descriptor.Body{ FieldPath: []descriptor.FieldPathComponent{}, }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() if err := AddErrorDefs(reg); err != nil { t.Errorf("AddErrorDefs(%#v) failed with %v; want success", reg, err) return } fileCL := crossLinkFixture(&file) err := reg.Load(reqFromFile(fileCL)) if err != nil { t.Errorf("reg.Load(%#v) failed with %v; want success", file, err) return } result, err := applyTemplate(param{File: fileCL, reg: reg}) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } if want, is, name := "2.0", result.Swagger, "Swagger"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } if want, is, name := "", result.BasePath, "BasePath"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } if want, is, name := ([]string)(nil), result.Schemes, "Schemes"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } if want, is, name := []string{"application/json"}, result.Consumes, "Consumes"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } if want, is, name := []string{"application/json"}, result.Produces, "Produces"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } if want, is, name := 1, len(result.Paths), "len(result.Paths)"; !reflect.DeepEqual(is, want) { t.Errorf("%s = %d want to be %d", name, want, is) } if want, is, name := 4, len(result.Paths[0].PathItemObject.Post.Parameters), "len(result.Paths[0].PathItemObject.Post.Parameters)"; !reflect.DeepEqual(is, want) { t.Errorf("%s = %d want to be %d", name, want, is) } if want, is, name := "#/definitions/BookServiceCreateBookBody", result.Paths[0].PathItemObject.Post.Parameters[1].Schema.schemaCore.Ref, "result.Paths[0].PathItemObject.Post.Parameters[1].Schema.schemaCore.Ref"; !reflect.DeepEqual(is, want) { t.Errorf("%s = %s want to be %s", name, want, is) } _, found := result.Definitions["BookServiceCreateBookBody"] if !found { t.Error("expecting definition to contain BookServiceCreateBookBody") } // If there was a failure, print out the input and the json result for debugging. if t.Failed() { t.Errorf("had: %s", file) t.Errorf("got: %s", fmt.Sprint(result)) } } // TestApplyTemplateProtobufAny tests that the protobufAny definition is correctly rendered with the @type field and // allowing additional properties. func TestApplyTemplateProtobufAny(t *testing.T) { // checkProtobufAnyFormat verifies the only property should be @type and additional properties are allowed checkProtobufAnyFormat := func(t *testing.T, protobufAny openapiSchemaObject) { anyPropsJSON, err := protobufAny.Properties.MarshalJSON() if err != nil { t.Errorf("protobufAny.Properties.MarshalJSON(), got error = %v", err) } var anyPropsMap map[string]interface{} if err := json.Unmarshal(anyPropsJSON, &anyPropsMap); err != nil { t.Errorf("json.Unmarshal(), got error = %v", err) } // @type should exist if _, ok := anyPropsMap["@type"]; !ok { t.Errorf("protobufAny.Properties missing key, \"@type\". got = %#v", anyPropsMap) } // and @type should be the only property if len(anyPropsMap) > 1 { t.Errorf("len(protobufAny.Properties) = %v, want = %v", len(anyPropsMap), 1) } // protobufAny should have additionalProperties allowed if protobufAny.AdditionalProperties == nil { t.Errorf("protobufAny.AdditionalProperties = nil, want not-nil") } } type args struct { regConfig func(registry *descriptor.Registry) msgContainsAny bool } tests := []struct { name string args args wantNumDefinitions int }{ { // our proto schema doesn't directly use protobufAny, but it is implicitly used by rpcStatus being // automatically rendered name: "default_protobufAny_from_rpcStatus", args: args{ msgContainsAny: false, }, wantNumDefinitions: 4, }, { // we have a protobufAny in a message, it should contain a ref inside the custom message name: "protobufAny_referenced_in_message", args: args{ msgContainsAny: true, }, wantNumDefinitions: 4, }, { // we have a protobufAny in a message but with automatic rendering of rpcStatus disabled name: "protobufAny_referenced_in_message_with_default_errors_disabled", args: args{ msgContainsAny: true, regConfig: func(reg *descriptor.Registry) { reg.SetDisableDefaultErrors(true) }, }, wantNumDefinitions: 3, }, { // we have a protobufAny in a message but with automatic rendering of responses disabled name: "protobufAny_referenced_in_message_with_default_responses_disabled", args: args{ msgContainsAny: true, regConfig: func(reg *descriptor.Registry) { reg.SetDisableDefaultResponses(true) }, }, wantNumDefinitions: 4, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { reqdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("name"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, }, } respdesc := &descriptorpb.DescriptorProto{ Name: proto.String("EmptyMessage"), } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Example"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("EmptyMessage"), ClientStreaming: proto.Bool(false), ServerStreaming: proto.Bool(false), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } req := &descriptor.Message{ DescriptorProto: reqdesc, } resp := &descriptor.Message{ DescriptorProto: respdesc, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{reqdesc, respdesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{req, resp}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: req, ResponseType: resp, }, }, }, }, } reg := descriptor.NewRegistry() reg.SetGenerateUnboundMethods(true) if tt.args.regConfig != nil { tt.args.regConfig(reg) } if err := AddErrorDefs(reg); err != nil { t.Errorf("AddErrorDefs(%#v) failed with %v; want success", reg, err) return } protoFiles := []*descriptorpb.FileDescriptorProto{ file.FileDescriptorProto, } if tt.args.msgContainsAny { // add an Any field to the request message reqdesc.Field = append(reqdesc.Field, &descriptorpb.FieldDescriptorProto{ Name: proto.String("any_value"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".google.protobuf.Any"), Number: proto.Int32(2), }) // update the dependencies to import it file.Dependency = append(file.Dependency, "google/protobuf/any.proto") anyDescriptorProto := protodesc.ToFileDescriptorProto((&anypb.Any{}).ProtoReflect().Descriptor().ParentFile()) anyDescriptorProto.SourceCodeInfo = &descriptorpb.SourceCodeInfo{} // prepend the anyDescriptorProto to the protoFiles slice so that the dependency can be resolved protoFiles = append(append(make([]*descriptorpb.FileDescriptorProto, 0, len(protoFiles)+1), anyDescriptorProto), protoFiles[0:]...) } err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: protoFiles, FileToGenerate: []string{file.GetName()}, }) if err != nil { t.Fatalf("failed to load code generator request: %v", err) } target, err := reg.LookupFile(file.GetName()) if err != nil { t.Fatalf("failed to lookup file from reg: %v", err) } result, err := applyTemplate(param{File: crossLinkFixture(target), reg: reg}) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } if want, got, name := tt.wantNumDefinitions, len(result.Definitions), "len(Definitions)"; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %d want to be %d", file, name, got, want) } protobufAny, ok := result.Definitions["protobufAny"] if !ok { t.Error("expecting Definitions to contain protobufAny") } checkProtobufAnyFormat(t, protobufAny) // If there was a failure, print out the input and the json result for debugging. if t.Failed() { t.Errorf("had: %s", file) resultJSON, _ := json.Marshal(result) t.Errorf("got: %s", resultJSON) } }) } } func generateFieldsForJSONReservedName() []*descriptor.Field { fields := make([]*descriptor.Field, 0) fieldName := "json_name" fieldJSONName := "jsonNAME" fieldDescriptor := descriptorpb.FieldDescriptorProto{Name: &fieldName, JsonName: &fieldJSONName} field := &descriptor.Field{FieldDescriptorProto: &fieldDescriptor} return append(fields, field) } func generateMsgsForJSONReservedName() []*descriptor.Message { result := make([]*descriptor.Message, 0) // The first message, its field is field_abc and its type is NewType // NewType field_abc fieldName := "field_abc" fieldJSONName := "fieldAbc" messageName1 := "message1" messageType := "pkg.a.NewType" pfd := descriptorpb.FieldDescriptorProto{Name: &fieldName, JsonName: &fieldJSONName, TypeName: &messageType} result = append(result, &descriptor.Message{ DescriptorProto: &descriptorpb.DescriptorProto{ Name: &messageName1, Field: []*descriptorpb.FieldDescriptorProto{&pfd}, }, }) // The second message, its name is NewName, its type is string // message NewType { // string field_newName [json_name = RESERVEDJSONNAME] // } messageName := "NewType" field := "field_newName" fieldJSONName2 := "RESERVEDJSONNAME" pfd2 := descriptorpb.FieldDescriptorProto{Name: &field, JsonName: &fieldJSONName2} result = append(result, &descriptor.Message{ DescriptorProto: &descriptorpb.DescriptorProto{ Name: &messageName, Field: []*descriptorpb.FieldDescriptorProto{&pfd2}, }, }) return result } func TestTemplateWithJsonCamelCase(t *testing.T) { tests := []struct { input string expected string }{ {"/test/{test_id}", "/test/{testId}"}, {"/test1/{test1_id}/test2/{test2_id}", "/test1/{test1Id}/test2/{test2Id}"}, {"/test1/{test1_id}/{test2_id}", "/test1/{test1Id}/{test2Id}"}, {"/test1/test2/{test1_id}/{test2_id}", "/test1/test2/{test1Id}/{test2Id}"}, {"/test1/{test1_id1_id2}", "/test1/{test1Id1Id2}"}, {"/test1/{test1_id1_id2}/test2/{test2_id3_id4}", "/test1/{test1Id1Id2}/test2/{test2Id3Id4}"}, {"/test1/test2/{test1_id1_id2}/{test2_id3_id4}", "/test1/test2/{test1Id1Id2}/{test2Id3Id4}"}, {"test/{a}", "test/{a}"}, {"test/{ab}", "test/{ab}"}, {"test/{a_a}", "test/{aA}"}, {"test/{ab_c}", "test/{abC}"}, {"test/{json_name}", "test/{jsonNAME}"}, {"test/{field_abc.field_newName}", "test/{fieldAbc.RESERVEDJSONNAME}"}, {"/item/search:item/{item_no_query}", "/item/search:item/{itemNoQuery}"}, } reg := descriptor.NewRegistry() reg.SetUseJSONNamesForFields(true) for _, data := range tests { actual := templateToOpenAPIPath(data.input, reg, generateFieldsForJSONReservedName(), generateMsgsForJSONReservedName(), make(map[string]string)) if data.expected != actual { t.Errorf("Expected templateToOpenAPIPath(%v) = %v, actual: %v", data.input, data.expected, actual) } } } func TestTemplateWithoutJsonCamelCase(t *testing.T) { tests := []struct { input string expected string }{ {"/test/{test_id}", "/test/{test_id}"}, {"/test1/{test1_id}/test2/{test2_id}", "/test1/{test1_id}/test2/{test2_id}"}, {"/test1/{test1_id}/{test2_id}", "/test1/{test1_id}/{test2_id}"}, {"/test1/test2/{test1_id}/{test2_id}", "/test1/test2/{test1_id}/{test2_id}"}, {"/test1/{test1_id1_id2}", "/test1/{test1_id1_id2}"}, {"/test1/{test1_id1_id2}/test2/{test2_id3_id4}", "/test1/{test1_id1_id2}/test2/{test2_id3_id4}"}, {"/test1/test2/{test1_id1_id2}/{test2_id3_id4}", "/test1/test2/{test1_id1_id2}/{test2_id3_id4}"}, {"test/{a}", "test/{a}"}, {"test/{ab}", "test/{ab}"}, {"test/{a_a}", "test/{a_a}"}, {"test/{json_name}", "test/{json_name}"}, {"test/{field_abc.field_newName}", "test/{field_abc.field_newName}"}, } reg := descriptor.NewRegistry() reg.SetUseJSONNamesForFields(false) for _, data := range tests { actual := templateToOpenAPIPath(data.input, reg, generateFieldsForJSONReservedName(), generateMsgsForJSONReservedName(), make(map[string]string)) if data.expected != actual { t.Errorf("Expected templateToOpenAPIPath(%v) = %v, actual: %v", data.input, data.expected, actual) } } } func TestTemplateToOpenAPIPath(t *testing.T) { tests := []struct { input string expected string }{ {"/test", "/test"}, {"/{test}", "/{test}"}, {"/{test=prefix/*}", "/{test}"}, {"/{test=prefix/that/has/multiple/parts/to/it/*}", "/{test}"}, {"/{test1}/{test2}", "/{test1}/{test2}"}, {"/{test1}/{test2}/", "/{test1}/{test2}/"}, {"/{name=prefix/*}", "/{name}"}, {"/{name=prefix1/*/prefix2/*}", "/{name}"}, {"/{user.name=prefix/*}", "/{user.name}"}, {"/{user.name=prefix1/*/prefix2/*}", "/{user.name}"}, {"/{parent=prefix/*}/children", "/{parent}/children"}, {"/{name=prefix/*}:customMethod", "/{name}:customMethod"}, {"/{name=prefix1/*/prefix2/*}:customMethod", "/{name}:customMethod"}, {"/{user.name=prefix/*}:customMethod", "/{user.name}:customMethod"}, {"/{user.name=prefix1/*/prefix2/*}:customMethod", "/{user.name}:customMethod"}, {"/{parent=prefix/*}/children:customMethod", "/{parent}/children:customMethod"}, } reg := descriptor.NewRegistry() reg.SetUseJSONNamesForFields(false) for _, data := range tests { actual := templateToOpenAPIPath(data.input, reg, generateFieldsForJSONReservedName(), generateMsgsForJSONReservedName(), make(map[string]string)) if data.expected != actual { t.Errorf("Expected templateToOpenAPIPath(%v) = %v, actual: %v", data.input, data.expected, actual) } } reg.SetUseJSONNamesForFields(true) for _, data := range tests { actual := templateToOpenAPIPath(data.input, reg, generateFieldsForJSONReservedName(), generateMsgsForJSONReservedName(), make(map[string]string)) if data.expected != actual { t.Errorf("Expected templateToOpenAPIPath(%v) = %v, actual: %v", data.input, data.expected, actual) } } } func getParameters(names []string) []descriptor.Parameter { params := make([]descriptor.Parameter, 0) for _, name := range names { params = append(params, descriptor.Parameter{ Target: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String(name), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), }, Message: &descriptor.Message{ File: &descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{}, }, DescriptorProto: &descriptorpb.DescriptorProto{ Name: proto.String(""), }, }, FieldMessage: nil, ForcePrefixedName: false, }, FieldPath: []descriptor.FieldPathComponent{{ Name: name, Target: nil, }}, Method: nil, }) } return params } func TestTemplateToOpenAPIPathExpandSlashed(t *testing.T) { tests := []struct { input string expected string pathParams []descriptor.Parameter expectedPathParams []string useJSONNames bool }{ {"/v1/{name=projects/*/documents/*}:exportResults", "/v1/projects/{project}/documents/{document}:exportResults", getParameters([]string{"name"}), []string{"project", "document"}, true}, {"/test/{name=*}", "/test/{name}", getParameters([]string{"name"}), []string{"name"}, true}, {"/test/{name=*}/", "/test/{name}/", getParameters([]string{"name"}), []string{"name"}, true}, {"/test/{name=test_cases/*}/", "/test/test_cases/{testCase}/", getParameters([]string{"name"}), []string{"testCase"}, true}, {"/test/{name=test_cases/*}/", "/test/test_cases/{test_case}/", getParameters([]string{"name"}), []string{"test_case"}, false}, {"/test/{name=test-cases/*}/", "/test/test-cases/{test-case}/", getParameters([]string{"name"}), []string{"test-case"}, false}, {"/test/{test_type.name=test_cases/*}/", "/test/test_cases/{testCase}/", getParameters([]string{"test_type.name"}), []string{"testCase"}, true}, {"/test/{test_type.name=test_cases/*}/", "/test/test_cases/{test_case}/", getParameters([]string{"test_type.name"}), []string{"test_case"}, false}, } reg := descriptor.NewRegistry() reg.SetExpandSlashedPathPatterns(true) for _, data := range tests { reg.SetUseJSONNamesForFields(data.useJSONNames) actualParts, actualParams := templateToExpandedPath(data.input, reg, generateFieldsForJSONReservedName(), generateMsgsForJSONReservedName(), data.pathParams) if data.expected != actualParts { t.Errorf("Expected templateToOpenAPIPath(%v) = %v, actual: %v", data.input, data.expected, actualParts) } pathParamsNames := make([]string, 0) for _, param := range actualParams { pathParamsNames = append(pathParamsNames, param.FieldPath[0].Name) } if !reflect.DeepEqual(data.expectedPathParams, pathParamsNames) { t.Errorf("Expected mutated path params in templateToOpenAPIPath(%v) = %v, actual: %v", data.input, data.expectedPathParams, data.pathParams) } } } func TestExpandedPathParametersStringType(t *testing.T) { tests := []struct { input string }{ {"/test/{name=test_cases/*}/"}, {"/v1/{name=projects/*/documents/*}:exportResults"}, } reg := descriptor.NewRegistry() reg.SetExpandSlashedPathPatterns(true) expectedParamType := openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, } for _, data := range tests { _, actualParams := templateToExpandedPath(data.input, reg, generateFieldsForJSONReservedName(), generateMsgsForJSONReservedName(), getParameters([]string{"name"})) for _, param := range actualParams { refs := make(refMap) actualParamType := schemaOfField(param.Target, reg, refs) if !reflect.DeepEqual(actualParamType, expectedParamType) { t.Errorf("Expected all path parameters to be type of 'string', actual: %#+v", actualParamType) } } } } func BenchmarkTemplateToOpenAPIPath(b *testing.B) { const input = "/{user.name=prefix1/*/prefix2/*}:customMethod" b.Run("with JSON names", func(b *testing.B) { reg := descriptor.NewRegistry() reg.SetUseJSONNamesForFields(false) for i := 0; i < b.N; i++ { _ = templateToOpenAPIPath(input, reg, generateFieldsForJSONReservedName(), generateMsgsForJSONReservedName(), make(map[string]string)) } }) b.Run("without JSON names", func(b *testing.B) { reg := descriptor.NewRegistry() reg.SetUseJSONNamesForFields(true) for i := 0; i < b.N; i++ { _ = templateToOpenAPIPath(input, reg, generateFieldsForJSONReservedName(), generateMsgsForJSONReservedName(), make(map[string]string)) } }) } func TestResolveFullyQualifiedNameToOpenAPIName(t *testing.T) { tests := []struct { input string output string listOfFQMNs []string namingStrategy string }{ { ".a.b.C", "C", []string{ ".a.b.C", }, "legacy", }, { ".a.b.C", "C", []string{ ".a.b.C", }, "simple", }, { ".a.b.C", "aBC", []string{ ".a.C", ".a.b.C", }, "legacy", }, { ".a.b.C", "b.C", []string{ ".a.C", ".a.b.C", }, "simple", }, { ".a.b.C", "aBC", []string{ ".C", ".a.C", ".a.b.C", }, "legacy", }, { ".a.b.C", "b.C", []string{ ".C", ".a.C", ".a.b.C", }, "simple", }, { ".a.b.C", "a.b.C", []string{ ".C", ".a.C", ".a.b.C", }, "fqn", }, } for _, data := range tests { names := resolveFullyQualifiedNameToOpenAPINames(data.listOfFQMNs, data.namingStrategy) output := names[data.input] if output != data.output { t.Errorf("Expected fullyQualifiedNameToOpenAPIName(%v, %s) to be %s but got %s", data.input, data.namingStrategy, data.output, output) } } } func templateToOpenAPIPath(path string, reg *descriptor.Registry, fields []*descriptor.Field, msgs []*descriptor.Message, pathParamNames map[string]string) string { return partsToOpenAPIPath(templateToParts(path, reg, fields, msgs), pathParamNames) } func templateToRegexpMap(path string, reg *descriptor.Registry, fields []*descriptor.Field, msgs []*descriptor.Message) map[string]string { return partsToRegexpMap(templateToParts(path, reg, fields, msgs)) } func templateToExpandedPath(path string, reg *descriptor.Registry, fields []*descriptor.Field, msgs []*descriptor.Message, pathParams []descriptor.Parameter) (string, []descriptor.Parameter) { pathParts, pathParams := expandPathPatterns(templateToParts(path, reg, fields, msgs), pathParams, reg) return partsToOpenAPIPath(pathParts, make(map[string]string)), pathParams } func TestFQMNToRegexpMap(t *testing.T) { tests := []struct { input string expected map[string]string }{ {"/test", map[string]string{}}, {"/{test}", map[string]string{}}, {"/{test" + pathParamUniqueSuffixDeliminator + "1=prefix/*}", map[string]string{"test" + pathParamUniqueSuffixDeliminator + "1": "prefix/[^/]+"}}, {"/{test=prefix/that/has/multiple/parts/to/it/**}", map[string]string{"test": "prefix/that/has/multiple/parts/to/it/.+"}}, {"/{test1=organizations/*}/{test2=divisions/*}", map[string]string{ "test1": "organizations/[^/]+", "test2": "divisions/[^/]+", }}, {"/v1/{name=projects/*/topics/*}:delete", map[string]string{"name": "projects/[^/]+/topics/[^/]+"}}, } reg := descriptor.NewRegistry() for _, data := range tests { actual := templateToRegexpMap(data.input, reg, generateFieldsForJSONReservedName(), generateMsgsForJSONReservedName()) if !reflect.DeepEqual(data.expected, actual) { t.Errorf("Expected partsToRegexpMap(%v) = %v, actual: %v", data.input, data.expected, actual) } } } func TestFQMNtoOpenAPIName(t *testing.T) { tests := []struct { input string expected string }{ {"/test", "/test"}, {"/{test}", "/{test}"}, {"/{test=prefix/*}", "/{test}"}, {"/{test=prefix/that/has/multiple/parts/to/it/*}", "/{test}"}, {"/{test1}/{test2}", "/{test1}/{test2}"}, {"/{test1}/{test2}/", "/{test1}/{test2}/"}, {"/v1/{name=tests/*}/tests", "/v1/{name}/tests"}, } reg := descriptor.NewRegistry() reg.SetUseJSONNamesForFields(false) for _, data := range tests { actual := templateToOpenAPIPath(data.input, reg, generateFieldsForJSONReservedName(), generateMsgsForJSONReservedName(), make(map[string]string)) if data.expected != actual { t.Errorf("Expected templateToOpenAPIPath(%v) = %v, actual: %v", data.input, data.expected, actual) } } reg.SetUseJSONNamesForFields(true) for _, data := range tests { actual := templateToOpenAPIPath(data.input, reg, generateFieldsForJSONReservedName(), generateMsgsForJSONReservedName(), make(map[string]string)) if data.expected != actual { t.Errorf("Expected templateToOpenAPIPath(%v) = %v, actual: %v", data.input, data.expected, actual) } } } func TestSchemaOfField(t *testing.T) { type test struct { field *descriptor.Field refs refMap expected openapiSchemaObject openAPIOptions *openapiconfig.OpenAPIOptions useJSONNamesForFields bool } jsonSchema := &openapi_options.JSONSchema{ Title: "field title", Description: "field description", } jsonSchemaWithOptions := &openapi_options.JSONSchema{ Title: "field title", Description: "field description", MultipleOf: 100, Maximum: 101, ExclusiveMaximum: true, Minimum: 1, ExclusiveMinimum: true, MaxLength: 10, MinLength: 3, Pattern: "[a-z]+", MaxItems: 20, MinItems: 2, UniqueItems: true, MaxProperties: 33, MinProperties: 22, Required: []string{"req"}, ReadOnly: true, } jsonSchemaRequired := &openapi_options.JSONSchema{ Required: []string{"required_via_json_schema"}, } jsonSchemaWithFormat := &openapi_options.JSONSchema{ Format: "uuid", } fieldOptions := new(descriptorpb.FieldOptions) proto.SetExtension(fieldOptions, openapi_options.E_Openapiv2Field, jsonSchema) requiredField := []annotations.FieldBehavior{annotations.FieldBehavior_REQUIRED} requiredFieldOptions := new(descriptorpb.FieldOptions) proto.SetExtension(requiredFieldOptions, annotations.E_FieldBehavior, requiredField) outputOnlyField := []annotations.FieldBehavior{annotations.FieldBehavior_OUTPUT_ONLY} outputOnlyOptions := new(descriptorpb.FieldOptions) proto.SetExtension(outputOnlyOptions, annotations.E_FieldBehavior, outputOnlyField) tests := []test{ { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("primitive_field"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("repeated_primitive_field"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Label: descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum(), }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "array", Items: &openapiItemsObject{ schemaCore: schemaCore{ Type: "string", }, }, }, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("empty_field"), TypeName: proto.String(".google.protobuf.Empty"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "object", }, Properties: &openapiSchemaObjectProperties{}, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("wrapped_field"), TypeName: proto.String(".google.protobuf.FieldMask"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("wrapped_field"), TypeName: proto.String(".google.protobuf.Timestamp"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", Format: "date-time", }, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("wrapped_field"), TypeName: proto.String(".google.protobuf.Duration"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("wrapped_field"), TypeName: proto.String(".google.protobuf.StringValue"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("repeated_wrapped_field"), TypeName: proto.String(".google.protobuf.StringValue"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), Label: descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum(), }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "array", Items: &openapiItemsObject{ schemaCore: schemaCore{ Type: "string", }, }, }, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("wrapped_field"), TypeName: proto.String(".google.protobuf.BytesValue"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", Format: "byte", }, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("wrapped_field"), TypeName: proto.String(".google.protobuf.Int32Value"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "integer", Format: "int32", }, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("wrapped_field"), TypeName: proto.String(".google.protobuf.UInt32Value"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "integer", Format: "int64", }, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("wrapped_field"), TypeName: proto.String(".google.protobuf.Int64Value"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", Format: "int64", }, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("wrapped_field"), TypeName: proto.String(".google.protobuf.UInt64Value"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", Format: "uint64", }, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("wrapped_field"), TypeName: proto.String(".google.protobuf.FloatValue"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "number", Format: "float", }, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("wrapped_field"), TypeName: proto.String(".google.protobuf.DoubleValue"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "number", Format: "double", }, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("wrapped_field"), TypeName: proto.String(".google.protobuf.BoolValue"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "boolean", }, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("wrapped_field"), TypeName: proto.String(".google.protobuf.Struct"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "object", }, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("wrapped_field"), TypeName: proto.String(".google.protobuf.Value"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{}, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("wrapped_field"), TypeName: proto.String(".google.protobuf.ListValue"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "array", Items: &openapiItemsObject{schemaCore: schemaCore{ Type: "object", }}, }, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("wrapped_field"), TypeName: proto.String(".google.protobuf.NullValue"), Type: descriptorpb.FieldDescriptorProto_TYPE_ENUM.Enum(), }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("message_field"), TypeName: proto.String(".example.Message"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), }, }, refs: refMap{".example.Message": struct{}{}}, expected: openapiSchemaObject{ schemaCore: schemaCore{ Ref: "#/definitions/exampleMessage", }, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("map_field"), Label: descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.Message.MapFieldEntry"), Options: fieldOptions, }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "object", }, AdditionalProperties: &openapiSchemaObject{ schemaCore: schemaCore{Type: "string"}, }, Title: "field title", Description: "field description", }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("array_field"), Label: descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Options: fieldOptions, }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "array", Items: &openapiItemsObject{schemaCore: schemaCore{ Type: "string", }}, }, Title: "field title", Description: "field description", }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("primitive_field"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_INT32.Enum(), Options: fieldOptions, }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "integer", Format: "int32", }, Title: "field title", Description: "field description", }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("message_field"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.Empty"), Options: fieldOptions, }, }, refs: refMap{".example.Empty": struct{}{}}, expected: openapiSchemaObject{ schemaCore: schemaCore{ Ref: "#/definitions/exampleEmpty", }, Title: "field title", Description: "field description", }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("map_field"), // should be called map_field_option but it's not valid map field name Label: descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.Message.MapFieldEntry"), }, }, openAPIOptions: &openapiconfig.OpenAPIOptions{ Field: []*openapiconfig.OpenAPIFieldOption{ { Field: "example.Message.map_field", Option: jsonSchema, }, }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "object", }, AdditionalProperties: &openapiSchemaObject{ schemaCore: schemaCore{Type: "string"}, }, Title: "field title", Description: "field description", }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("array_field_option"), Label: descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), }, }, openAPIOptions: &openapiconfig.OpenAPIOptions{ Field: []*openapiconfig.OpenAPIFieldOption{ { Field: "example.Message.array_field_option", Option: jsonSchema, }, }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "array", Items: &openapiItemsObject{schemaCore: schemaCore{ Type: "string", }}, }, Title: "field title", Description: "field description", }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("primitive_field_option"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_INT32.Enum(), }, }, openAPIOptions: &openapiconfig.OpenAPIOptions{ Field: []*openapiconfig.OpenAPIFieldOption{ { Field: "example.Message.primitive_field_option", Option: jsonSchema, }, }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "integer", Format: "int32", }, Title: "field title", Description: "field description", }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("primitive_field_option"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum().Enum(), }, }, openAPIOptions: &openapiconfig.OpenAPIOptions{ Field: []*openapiconfig.OpenAPIFieldOption{ { Field: "example.Message.primitive_field_option", Option: &openapi_options.JSONSchema{ Title: "field title", Description: "field description", Format: "uuid", }, }, }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", Format: "uuid", }, Title: "field title", Description: "field description", }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("message_field_option"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.Empty"), }, }, openAPIOptions: &openapiconfig.OpenAPIOptions{ Field: []*openapiconfig.OpenAPIFieldOption{ { Field: "example.Message.message_field_option", Option: jsonSchema, }, }, }, refs: refMap{".example.Empty": struct{}{}}, expected: openapiSchemaObject{ schemaCore: schemaCore{ Ref: "#/definitions/exampleEmpty", }, Title: "field title", Description: "field description", }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("required_via_field_behavior_field"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Options: requiredFieldOptions, }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, Required: []string{"required_via_field_behavior_field"}, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("readonly_via_field_behavior_field"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Options: outputOnlyOptions, }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, ReadOnly: true, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("required_message_field"), TypeName: proto.String(".example.Message"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), Options: requiredFieldOptions, }, }, refs: refMap{".example.Message": struct{}{}}, expected: openapiSchemaObject{ schemaCore: schemaCore{ Ref: "#/definitions/exampleMessage", }, Required: []string{"required_message_field"}, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("array_field_option"), Label: descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), }, }, openAPIOptions: &openapiconfig.OpenAPIOptions{ Field: []*openapiconfig.OpenAPIFieldOption{ { Field: "example.Message.array_field_option", Option: jsonSchemaWithOptions, }, }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "array", Items: &openapiItemsObject{ schemaCore: schemaCore{ Type: "string", }, MultipleOf: 100, Maximum: 101, ExclusiveMaximum: true, Minimum: 1, ExclusiveMinimum: true, MaxLength: 10, MinLength: 3, Pattern: "[a-z]+", MaxProperties: 33, MinProperties: 22, Required: []string{"req"}, ReadOnly: true, }, }, Title: "field title", Description: "field description", UniqueItems: true, MaxItems: 20, MinItems: 2, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("array_field_option"), Label: descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_INT64.Enum(), }, }, openAPIOptions: &openapiconfig.OpenAPIOptions{ Field: []*openapiconfig.OpenAPIFieldOption{ { Field: "example.Message.array_field_option", Option: jsonSchemaWithOptions, }, }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "array", Items: &openapiItemsObject{ schemaCore: schemaCore{ Type: "string", Format: "int64", }, MultipleOf: 100, Maximum: 101, ExclusiveMaximum: true, Minimum: 1, ExclusiveMinimum: true, MaxLength: 10, MinLength: 3, Pattern: "[a-z]+", MaxProperties: 33, MinProperties: 22, Required: []string{"req"}, ReadOnly: true, }, }, Title: "field title", Description: "field description", UniqueItems: true, MaxItems: 20, MinItems: 2, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("array_field_format"), Label: descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), }, }, openAPIOptions: &openapiconfig.OpenAPIOptions{ Field: []*openapiconfig.OpenAPIFieldOption{ { Field: "example.Message.array_field_format", Option: jsonSchemaWithFormat, }, }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "array", Items: &openapiItemsObject{ schemaCore: schemaCore{ Type: "string", Format: "uuid", }, }, }, }, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("required_via_field_behavior_field_json_name"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), JsonName: proto.String("required_field_custom_name"), Options: requiredFieldOptions, }, }, refs: make(refMap), expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, Required: []string{"required_field_custom_name"}, }, useJSONNamesForFields: true, }, { field: &descriptor.Field{ FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("required_via_json_schema"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), JsonName: proto.String("required_via_json_schema_json_name"), }, }, openAPIOptions: &openapiconfig.OpenAPIOptions{ Field: []*openapiconfig.OpenAPIFieldOption{ { Field: "example.Message.required_via_json_schema", Option: jsonSchemaRequired, }, }, }, refs: make(refMap), useJSONNamesForFields: true, expected: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, Required: []string{"required_via_json_schema_json_name"}, }, }, } for _, test := range tests { reg := descriptor.NewRegistry() reg.SetUseJSONNamesForFields(test.useJSONNamesForFields) req := &pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{ { Name: proto.String("third_party/google.proto"), Package: proto.String("google.protobuf"), Options: &descriptorpb.FileOptions{ GoPackage: proto.String("third_party/google"), }, MessageType: []*descriptorpb.DescriptorProto{ protodesc.ToDescriptorProto((&emptypb.Empty{}).ProtoReflect().Descriptor()), protodesc.ToDescriptorProto((&structpb.Struct{}).ProtoReflect().Descriptor()), protodesc.ToDescriptorProto((&structpb.Value{}).ProtoReflect().Descriptor()), protodesc.ToDescriptorProto((&structpb.ListValue{}).ProtoReflect().Descriptor()), protodesc.ToDescriptorProto((&field_mask.FieldMask{}).ProtoReflect().Descriptor()), protodesc.ToDescriptorProto((×tamppb.Timestamp{}).ProtoReflect().Descriptor()), protodesc.ToDescriptorProto((&durationpb.Duration{}).ProtoReflect().Descriptor()), protodesc.ToDescriptorProto((&wrapperspb.StringValue{}).ProtoReflect().Descriptor()), protodesc.ToDescriptorProto((&wrapperspb.BytesValue{}).ProtoReflect().Descriptor()), protodesc.ToDescriptorProto((&wrapperspb.Int32Value{}).ProtoReflect().Descriptor()), protodesc.ToDescriptorProto((&wrapperspb.UInt32Value{}).ProtoReflect().Descriptor()), protodesc.ToDescriptorProto((&wrapperspb.Int64Value{}).ProtoReflect().Descriptor()), protodesc.ToDescriptorProto((&wrapperspb.UInt64Value{}).ProtoReflect().Descriptor()), protodesc.ToDescriptorProto((&wrapperspb.FloatValue{}).ProtoReflect().Descriptor()), protodesc.ToDescriptorProto((&wrapperspb.DoubleValue{}).ProtoReflect().Descriptor()), protodesc.ToDescriptorProto((&wrapperspb.BoolValue{}).ProtoReflect().Descriptor()), }, EnumType: []*descriptorpb.EnumDescriptorProto{ protodesc.ToEnumDescriptorProto(structpb.NullValue(0).Descriptor()), }, }, { SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), Dependency: []string{"third_party/google.proto"}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, MessageType: []*descriptorpb.DescriptorProto{ { Name: proto.String("Message"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("value"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, func() *descriptorpb.FieldDescriptorProto { fd := test.field.FieldDescriptorProto fd.Number = proto.Int32(2) return fd }(), }, NestedType: []*descriptorpb.DescriptorProto{ { Name: proto.String("MapFieldEntry"), Options: &descriptorpb.MessageOptions{MapEntry: proto.Bool(true)}, Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("key"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("value"), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), }, }, }, }, }, { Name: proto.String("Empty"), }, }, EnumType: []*descriptorpb.EnumDescriptorProto{ { Name: proto.String("MessageType"), Value: []*descriptorpb.EnumValueDescriptorProto{ { Name: proto.String("MESSAGE_TYPE_1"), Number: proto.Int32(0), }, }, }, }, Service: []*descriptorpb.ServiceDescriptorProto{}, }, }, } err := reg.Load(req) if err != nil { t.Errorf("failed to reg.Load(req): %v", err) } // set field's parent message pointer to message so field can resolve its FQFN test.field.Message = &descriptor.Message{ DescriptorProto: req.ProtoFile[1].MessageType[0], File: &descriptor.File{ FileDescriptorProto: req.ProtoFile[1], }, } if test.openAPIOptions != nil { if err := reg.RegisterOpenAPIOptions(test.openAPIOptions); err != nil { t.Fatalf("failed to register OpenAPI options: %s", err) } } refs := make(refMap) actual := schemaOfField(test.field, reg, refs) expectedSchemaObject := test.expected if e, a := expectedSchemaObject, actual; !reflect.DeepEqual(a, e) { t.Errorf("Expected schemaOfField(%v) = \n%#+v, actual: \n%#+v", test.field, e, a) } if !reflect.DeepEqual(refs, test.refs) { t.Errorf("Expected schemaOfField(%v) to add refs %v, not %v", test.field, test.refs, refs) } } } func TestRenderMessagesAsDefinition(t *testing.T) { jsonSchema := &openapi_options.JSONSchema{ Title: "field title", Description: "field description", Required: []string{"aRequiredField"}, } requiredField := new(descriptorpb.FieldOptions) proto.SetExtension(requiredField, openapi_options.E_Openapiv2Field, jsonSchema) fieldBehaviorRequired := []annotations.FieldBehavior{annotations.FieldBehavior_REQUIRED} requiredFieldOptions := new(descriptorpb.FieldOptions) proto.SetExtension(requiredFieldOptions, annotations.E_FieldBehavior, fieldBehaviorRequired) fieldBehaviorOutputOnlyField := []annotations.FieldBehavior{annotations.FieldBehavior_OUTPUT_ONLY} fieldBehaviorOutputOnlyOptions := new(descriptorpb.FieldOptions) proto.SetExtension(fieldBehaviorOutputOnlyOptions, annotations.E_FieldBehavior, fieldBehaviorOutputOnlyField) fieldVisibilityFieldInternal := &visibility.VisibilityRule{Restriction: "INTERNAL"} fieldVisibilityInternalOption := new(descriptorpb.FieldOptions) proto.SetExtension(fieldVisibilityInternalOption, visibility.E_FieldVisibility, fieldVisibilityFieldInternal) fieldVisibilityFieldPreview := &visibility.VisibilityRule{Restriction: "INTERNAL,PREVIEW"} fieldVisibilityPreviewOption := new(descriptorpb.FieldOptions) proto.SetExtension(fieldVisibilityPreviewOption, visibility.E_FieldVisibility, fieldVisibilityFieldPreview) tests := []struct { descr string msgDescs []*descriptorpb.DescriptorProto schema map[string]*openapi_options.Schema // per-message schema to add defs openapiDefinitionsObject openAPIOptions *openapiconfig.OpenAPIOptions pathParams []descriptor.Parameter UseJSONNamesForFields bool UseAllOfForRefs bool }{ { descr: "no OpenAPI options", msgDescs: []*descriptorpb.DescriptorProto{ {Name: proto.String("Message")}, }, schema: map[string]*openapi_options.Schema{}, defs: map[string]openapiSchemaObject{ "Message": {schemaCore: schemaCore{Type: "object"}}, }, }, { descr: "example option", msgDescs: []*descriptorpb.DescriptorProto{ {Name: proto.String("Message")}, }, schema: map[string]*openapi_options.Schema{ "Message": { Example: `{"foo":"bar"}`, }, }, defs: map[string]openapiSchemaObject{ "Message": {schemaCore: schemaCore{ Type: "object", Example: RawExample(`{"foo":"bar"}`), }}, }, }, { descr: "example option with something non-json", msgDescs: []*descriptorpb.DescriptorProto{ {Name: proto.String("Message")}, }, schema: map[string]*openapi_options.Schema{ "Message": { Example: `XXXX anything goes XXXX`, }, }, defs: map[string]openapiSchemaObject{ "Message": {schemaCore: schemaCore{ Type: "object", Example: RawExample(`XXXX anything goes XXXX`), }}, }, }, { descr: "external docs option", msgDescs: []*descriptorpb.DescriptorProto{ {Name: proto.String("Message")}, }, schema: map[string]*openapi_options.Schema{ "Message": { ExternalDocs: &openapi_options.ExternalDocumentation{ Description: "glorious docs", Url: "https://nada", }, }, }, defs: map[string]openapiSchemaObject{ "Message": { schemaCore: schemaCore{ Type: "object", }, ExternalDocs: &openapiExternalDocumentationObject{ Description: "glorious docs", URL: "https://nada", }, }, }, }, { descr: "JSONSchema options", msgDescs: []*descriptorpb.DescriptorProto{ {Name: proto.String("Message")}, }, schema: map[string]*openapi_options.Schema{ "Message": { JsonSchema: &openapi_options.JSONSchema{ Title: "title", Description: "desc", MultipleOf: 100, Maximum: 101, ExclusiveMaximum: true, Minimum: 1, ExclusiveMinimum: true, MaxLength: 10, MinLength: 3, Pattern: "[a-z]+", MaxItems: 20, MinItems: 2, UniqueItems: true, MaxProperties: 33, MinProperties: 22, Required: []string{"req"}, ReadOnly: true, }, }, }, defs: map[string]openapiSchemaObject{ "Message": { schemaCore: schemaCore{ Type: "object", }, Title: "title", Description: "desc", MultipleOf: 100, Maximum: 101, ExclusiveMaximum: true, Minimum: 1, ExclusiveMinimum: true, MaxLength: 10, MinLength: 3, Pattern: "[a-z]+", MaxItems: 20, MinItems: 2, UniqueItems: true, MaxProperties: 33, MinProperties: 22, Required: []string{"req"}, ReadOnly: true, }, }, }, { descr: "JSONSchema options from registry", msgDescs: []*descriptorpb.DescriptorProto{ {Name: proto.String("Message")}, }, openAPIOptions: &openapiconfig.OpenAPIOptions{ Message: []*openapiconfig.OpenAPIMessageOption{ { Message: "example.Message", Option: &openapi_options.Schema{ JsonSchema: &openapi_options.JSONSchema{ Title: "title", Description: "desc", MultipleOf: 100, Maximum: 101, ExclusiveMaximum: true, Minimum: 1, ExclusiveMinimum: true, MaxLength: 10, MinLength: 3, Pattern: "[a-z]+", MaxItems: 20, MinItems: 2, UniqueItems: true, MaxProperties: 33, MinProperties: 22, Required: []string{"req"}, ReadOnly: true, }, }, }, }, }, defs: map[string]openapiSchemaObject{ "Message": { schemaCore: schemaCore{ Type: "object", }, Title: "title", Description: "desc", MultipleOf: 100, Maximum: 101, ExclusiveMaximum: true, Minimum: 1, ExclusiveMinimum: true, MaxLength: 10, MinLength: 3, Pattern: "[a-z]+", MaxItems: 20, MinItems: 2, UniqueItems: true, MaxProperties: 33, MinProperties: 22, Required: []string{"req"}, ReadOnly: true, }, }, }, { descr: "JSONSchema with required properties", msgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("Message"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("FieldOne"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("FieldTwo"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), Options: requiredFieldOptions, }, { Name: proto.String("FieldThree"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(3), Options: requiredFieldOptions, }, }, }, }, schema: map[string]*openapi_options.Schema{ "Message": { JsonSchema: &openapi_options.JSONSchema{ Title: "title", Description: "desc", Required: []string{"FieldOne", "FieldTwo"}, }, }, }, defs: map[string]openapiSchemaObject{ "Message": { schemaCore: schemaCore{ Type: "object", }, Title: "title", Description: "desc", Required: []string{"FieldOne", "FieldTwo", "FieldThree"}, Properties: &openapiSchemaObjectProperties{ { Key: "FieldOne", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, }, }, { Key: "FieldTwo", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, }, }, { Key: "FieldThree", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, }, }, }, }, }, }, { descr: "JSONSchema with required properties", msgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("Message"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("FieldOne"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(3), Options: requiredFieldOptions, }, }, }, }, schema: map[string]*openapi_options.Schema{ "Message": { JsonSchema: &openapi_options.JSONSchema{ Title: "title", Description: "desc", }, }, }, defs: map[string]openapiSchemaObject{ "Message": { schemaCore: schemaCore{ Type: "object", }, Title: "title", Description: "desc", Required: []string{"FieldOne"}, Properties: &openapiSchemaObjectProperties{ { Key: "FieldOne", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, }, }, }, }, }, }, { descr: "JSONSchema with required properties by using annotations", msgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("Message"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("FieldOne"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), Options: requiredFieldOptions, }, }, }, }, schema: map[string]*openapi_options.Schema{ "Message": { JsonSchema: &openapi_options.JSONSchema{ Title: "title", Description: "desc", }, }, }, defs: map[string]openapiSchemaObject{ "Message": { schemaCore: schemaCore{ Type: "object", }, Title: "title", Description: "desc", Required: []string{"FieldOne"}, Properties: &openapiSchemaObjectProperties{ { Key: "FieldOne", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, }, }, }, }, }, }, { descr: "JSONSchema with hidden properties", msgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("Message"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("aInternalField"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), Options: fieldVisibilityInternalOption, }, { Name: proto.String("aPreviewField"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), Options: fieldVisibilityPreviewOption, }, { Name: proto.String("aVisibleField"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(3), }, }, }, }, schema: map[string]*openapi_options.Schema{ "Message": { JsonSchema: &openapi_options.JSONSchema{ Title: "title", Description: "desc", Required: []string{"req"}, }, }, }, defs: map[string]openapiSchemaObject{ "Message": { schemaCore: schemaCore{ Type: "object", }, Title: "title", Description: "desc", Required: []string{"req"}, Properties: &openapiSchemaObjectProperties{ { Key: "aPreviewField", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, }, }, { Key: "aVisibleField", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, }, }, }, }, }, }, { descr: "JSONSchema with path parameters", msgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("Message"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("aRequiredField"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), Options: requiredField, }, { Name: proto.String("aPathParameter"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), }, }, }, }, schema: map[string]*openapi_options.Schema{ "Message": { JsonSchema: &openapi_options.JSONSchema{ Title: "title", Description: "desc", Required: []string{"req"}, }, }, }, defs: map[string]openapiSchemaObject{ "Message": { schemaCore: schemaCore{ Type: "object", }, Title: "title", Description: "desc", Required: []string{"req", "aRequiredField"}, Properties: &openapiSchemaObjectProperties{ { Key: "aRequiredField", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, Description: "field description", Title: "field title", }, }, }, }, }, pathParams: []descriptor.Parameter{ { FieldPath: descriptor.FieldPath{ descriptor.FieldPathComponent{ Name: ("aPathParameter"), }, }, }, }, }, { descr: "JSONSchema with required properties via field_behavior", msgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("Message"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("aRequiredField"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), Options: requiredFieldOptions, }, { Name: proto.String("aOutputOnlyField"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), Options: fieldBehaviorOutputOnlyOptions, }, }, }, }, schema: map[string]*openapi_options.Schema{ "Message": { JsonSchema: &openapi_options.JSONSchema{ Title: "title", Description: "desc", Required: []string{"req"}, }, }, }, defs: map[string]openapiSchemaObject{ "Message": { schemaCore: schemaCore{ Type: "object", }, Title: "title", Description: "desc", Required: []string{"req", "aRequiredField"}, Properties: &openapiSchemaObjectProperties{ { Key: "aRequiredField", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, }, }, { Key: "aOutputOnlyField", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, ReadOnly: true, }, }, }, }, }, }, { descr: "JSONSchema with required properties and fields with json_name", msgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("Message"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("FieldOne"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), JsonName: proto.String("custom_json_1"), }, { Name: proto.String("FieldTwo"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), JsonName: proto.String("custom_json_2"), Options: requiredFieldOptions, }, { Name: proto.String("FieldThree"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(3), JsonName: proto.String("custom_json_3"), Options: requiredFieldOptions, }, }, }, }, schema: map[string]*openapi_options.Schema{ "Message": { JsonSchema: &openapi_options.JSONSchema{ Title: "title", Description: "desc", Required: []string{"FieldOne", "FieldTwo"}, }, }, }, defs: map[string]openapiSchemaObject{ "Message": { schemaCore: schemaCore{ Type: "object", }, Title: "title", Description: "desc", Required: []string{"custom_json_1", "custom_json_2", "custom_json_3"}, Properties: &openapiSchemaObjectProperties{ { Key: "custom_json_1", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, }, }, { Key: "custom_json_2", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, }, }, { Key: "custom_json_3", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, }, }, }, }, }, UseJSONNamesForFields: true, }, { descr: "JSONSchema with a read_only nested field", msgDescs: []*descriptorpb.DescriptorProto{ { Name: proto.String("Message"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("nested"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.Message.Nested"), Number: proto.Int32(1), Options: fieldBehaviorOutputOnlyOptions, }, }, NestedType: []*descriptorpb.DescriptorProto{{ Name: proto.String("Nested"), }}, }, }, UseAllOfForRefs: true, schema: map[string]*openapi_options.Schema{ "Message": { JsonSchema: &openapi_options.JSONSchema{ Title: "title", Description: "desc", Required: []string{}, }, }, }, openAPIOptions: &openapiconfig.OpenAPIOptions{ Field: []*openapiconfig.OpenAPIFieldOption{ { Field: "example.Message.nested", Option: &openapi_options.JSONSchema{ Title: "nested field title", Description: "nested field desc", Example: `"ok":"TRUE"`, }, }, }, }, defs: map[string]openapiSchemaObject{ "exampleMessage": { schemaCore: schemaCore{ Type: "object", }, Title: "title", Description: "desc", Required: nil, Properties: &openapiSchemaObjectProperties{ { Key: "nested", Value: openapiSchemaObject{ AllOf: []allOfEntry{{Ref: "#/definitions/MessageNested"}}, ReadOnly: true, schemaCore: schemaCore{ Example: RawExample(`"ok":"TRUE"`), }, Title: "nested field title", Description: "nested field desc", }, }, }, }, }, }, } for _, test := range tests { t.Run(test.descr, func(t *testing.T) { msgs := []*descriptor.Message{} for _, msgdesc := range test.msgDescs { msgdesc.Options = &descriptorpb.MessageOptions{} msgs = append(msgs, &descriptor.Message{DescriptorProto: msgdesc}) } reg := descriptor.NewRegistry() file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), Dependency: []string{}, MessageType: test.msgDescs, EnumType: []*descriptorpb.EnumDescriptorProto{}, Service: []*descriptorpb.ServiceDescriptorProto{}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, Messages: msgs, } err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}, }) reg.SetVisibilityRestrictionSelectors([]string{"PREVIEW"}) if test.UseJSONNamesForFields { reg.SetUseJSONNamesForFields(true) } if test.UseAllOfForRefs { reg.SetUseAllOfForRefs(true) } if err != nil { t.Fatalf("failed to load code generator request: %v", err) } msgMap := map[string]*descriptor.Message{} for _, d := range test.msgDescs { name := d.GetName() msg, err := reg.LookupMsg("example", name) if err != nil { t.Fatalf("lookup message %v: %v", name, err) } msgMap[msg.FQMN()] = msg if schema, ok := test.schema[name]; ok { proto.SetExtension(d.Options, openapi_options.E_Openapiv2Schema, schema) } } if test.openAPIOptions != nil { if err := reg.RegisterOpenAPIOptions(test.openAPIOptions); err != nil { t.Fatalf("failed to register OpenAPI options: %s", err) } } refs := make(refMap) actual := make(openapiDefinitionsObject) if err := renderMessagesAsDefinition(msgMap, actual, reg, refs, test.pathParams); err != nil { t.Errorf("renderMessagesAsDefinition failed with: %s", err) } if !reflect.DeepEqual(actual, test.defs) { t.Errorf("Expected renderMessagesAsDefinition() to add defs %+v, not %+v", test.defs, actual) } }) } } func TestUpdateOpenAPIDataFromComments(t *testing.T) { tests := []struct { descr string openapiSwaggerObject interface{} comments string expectedError error expectedOpenAPIObject interface{} useGoTemplate bool goTemplateArgs []string }{ { descr: "empty comments", openapiSwaggerObject: nil, expectedOpenAPIObject: nil, comments: "", expectedError: nil, }, { descr: "set field to read only", openapiSwaggerObject: &openapiSchemaObject{}, expectedOpenAPIObject: &openapiSchemaObject{ ReadOnly: true, Description: "... Output only. ...", }, comments: "... Output only. ...", expectedError: nil, }, { descr: "set title", openapiSwaggerObject: &openapiSchemaObject{}, expectedOpenAPIObject: &openapiSchemaObject{ Title: "Comment with no trailing dot", }, comments: "Comment with no trailing dot", expectedError: nil, }, { descr: "set description", openapiSwaggerObject: &openapiSchemaObject{}, expectedOpenAPIObject: &openapiSchemaObject{ Description: "Comment with trailing dot.", }, comments: "Comment with trailing dot.", expectedError: nil, }, { descr: "use info object", openapiSwaggerObject: &openapiSwaggerObject{ Info: openapiInfoObject{}, }, expectedOpenAPIObject: &openapiSwaggerObject{ Info: openapiInfoObject{ Description: "Comment with trailing dot.", }, }, comments: "Comment with trailing dot.", expectedError: nil, }, { descr: "multi line comment with title", openapiSwaggerObject: &openapiSchemaObject{}, expectedOpenAPIObject: &openapiSchemaObject{ Title: "First line", Description: "Second line", }, comments: "First line\n\nSecond line", expectedError: nil, }, { descr: "multi line comment no title", openapiSwaggerObject: &openapiSchemaObject{}, expectedOpenAPIObject: &openapiSchemaObject{ Description: "First line.\n\nSecond line", }, comments: "First line.\n\nSecond line", expectedError: nil, }, { descr: "multi line comment with summary with dot", openapiSwaggerObject: &openapiOperationObject{}, expectedOpenAPIObject: &openapiOperationObject{ Summary: "First line.", Description: "Second line", }, comments: "First line.\n\nSecond line", expectedError: nil, }, { descr: "multi line comment with summary no dot", openapiSwaggerObject: &openapiOperationObject{}, expectedOpenAPIObject: &openapiOperationObject{ Summary: "First line", Description: "Second line", }, comments: "First line\n\nSecond line", expectedError: nil, }, { descr: "multi line comment with summary no dot", openapiSwaggerObject: &schemaCore{}, expectedOpenAPIObject: &schemaCore{}, comments: "Any comment", expectedError: errors.New("no description nor summary property"), }, { descr: "without use_go_template", openapiSwaggerObject: &openapiSchemaObject{}, expectedOpenAPIObject: &openapiSchemaObject{ Title: "First line", Description: "{{import \"documentation.md\"}}", }, comments: "First line\n\n{{import \"documentation.md\"}}", expectedError: nil, }, { descr: "error with use_go_template", openapiSwaggerObject: &openapiSchemaObject{}, expectedOpenAPIObject: &openapiSchemaObject{ Title: "First line", Description: "open noneexistingfile.txt: no such file or directory", }, comments: "First line\n\n{{import \"noneexistingfile.txt\"}}", expectedError: nil, useGoTemplate: true, }, { descr: "template with use_go_template", openapiSwaggerObject: &openapiSchemaObject{}, expectedOpenAPIObject: &openapiSchemaObject{ Title: "Template", Description: `Description "which means nothing"`, }, comments: "Template\n\nDescription {{with \"which means nothing\"}}{{printf \"%q\" .}}{{end}}", expectedError: nil, useGoTemplate: true, }, { descr: "template with use_go_template and go_template_args", openapiSwaggerObject: &openapiSchemaObject{}, expectedOpenAPIObject: &openapiSchemaObject{ Title: "Template", Description: `Description "which means nothing" for environment test with value my_value`, }, comments: "Template\n\nDescription {{with \"which means nothing\"}}{{printf \"%q\" .}}{{end}} for " + "environment {{arg \"environment\"}} with value {{arg \"my_key\"}}", expectedError: nil, useGoTemplate: true, goTemplateArgs: []string{"my_key=my_value", "environment=test"}, }, { descr: "template with use_go_template and undefined go_template_args", openapiSwaggerObject: &openapiSchemaObject{}, expectedOpenAPIObject: &openapiSchemaObject{ Title: "Template", Description: `Description "which means nothing" for environment test with value ` + `goTemplateArg something_undefined not found`, }, comments: "Template\n\nDescription {{with \"which means nothing\"}}{{printf \"%q\" .}}{{end}} for " + "environment {{arg \"environment\"}} with value {{arg \"something_undefined\"}}", expectedError: nil, useGoTemplate: true, goTemplateArgs: []string{"environment=test"}, }, } for _, test := range tests { t.Run(test.descr, func(t *testing.T) { reg := descriptor.NewRegistry() if test.useGoTemplate { reg.SetUseGoTemplate(true) } if len(test.goTemplateArgs) > 0 { reg.SetGoTemplateArgs(test.goTemplateArgs) } err := updateOpenAPIDataFromComments(reg, test.openapiSwaggerObject, nil, test.comments, false) if test.expectedError == nil { if err != nil { t.Errorf("unexpected error '%v'", err) } if !reflect.DeepEqual(test.openapiSwaggerObject, test.expectedOpenAPIObject) { t.Errorf("openapiSwaggerObject was not updated correctly, expected '%+v', got '%+v'", test.expectedOpenAPIObject, test.openapiSwaggerObject) } } else { if err == nil { t.Error("expected update error not returned") } if !reflect.DeepEqual(test.openapiSwaggerObject, test.expectedOpenAPIObject) { t.Errorf("openapiSwaggerObject was not updated correctly, expected '%+v', got '%+v'", test.expectedOpenAPIObject, test.openapiSwaggerObject) } if err.Error() != test.expectedError.Error() { t.Errorf("expected error malformed, expected %q, got %q", test.expectedError.Error(), err.Error()) } } }) } } func TestMessageOptionsWithGoTemplate(t *testing.T) { tests := []struct { descr string msgDescs []*descriptorpb.DescriptorProto schema map[string]*openapi_options.Schema // per-message schema to add defs openapiDefinitionsObject openAPIOptions *openapiconfig.OpenAPIOptions useGoTemplate bool goTemplateArgs []string }{ { descr: "external docs option", msgDescs: []*descriptorpb.DescriptorProto{ {Name: proto.String("Message")}, }, schema: map[string]*openapi_options.Schema{ "Message": { JsonSchema: &openapi_options.JSONSchema{ Title: "{{.Name}}", Description: "Description {{with \"which means nothing\"}}{{printf \"%q\" .}}{{end}}", }, ExternalDocs: &openapi_options.ExternalDocumentation{ Description: "Description {{with \"which means nothing\"}}{{printf \"%q\" .}}{{end}}", }, }, }, defs: map[string]openapiSchemaObject{ "Message": { schemaCore: schemaCore{ Type: "object", }, Title: "Message", Description: `Description "which means nothing"`, ExternalDocs: &openapiExternalDocumentationObject{ Description: `Description "which means nothing"`, }, }, }, useGoTemplate: true, }, { descr: "external docs option", msgDescs: []*descriptorpb.DescriptorProto{ {Name: proto.String("Message")}, }, schema: map[string]*openapi_options.Schema{ "Message": { JsonSchema: &openapi_options.JSONSchema{ Title: "{{.Name}}", Description: "Description {{with \"which means nothing\"}}{{printf \"%q\" .}}{{end}}", }, ExternalDocs: &openapi_options.ExternalDocumentation{ Description: "Description {{with \"which means nothing\"}}{{printf \"%q\" .}}{{end}}", }, }, }, defs: map[string]openapiSchemaObject{ "Message": { schemaCore: schemaCore{ Type: "object", }, Title: "{{.Name}}", Description: "Description {{with \"which means nothing\"}}{{printf \"%q\" .}}{{end}}", ExternalDocs: &openapiExternalDocumentationObject{ Description: "Description {{with \"which means nothing\"}}{{printf \"%q\" .}}{{end}}", }, }, }, useGoTemplate: false, }, { descr: "external docs option with go template args", msgDescs: []*descriptorpb.DescriptorProto{ {Name: proto.String("Message")}, }, schema: map[string]*openapi_options.Schema{ "Message": { JsonSchema: &openapi_options.JSONSchema{ Title: "{{.Name}}", Description: "Description {{with \"which means nothing\"}}{{printf \"%q\" .}}{{end}} " + "{{arg \"my_key\"}}", }, ExternalDocs: &openapi_options.ExternalDocumentation{ Description: "Description {{with \"which means nothing\"}}{{printf \"%q\" .}}{{end}} " + "{{arg \"my_key\"}}", }, }, }, defs: map[string]openapiSchemaObject{ "Message": { schemaCore: schemaCore{ Type: "object", }, Title: "Message", Description: `Description "which means nothing" too`, ExternalDocs: &openapiExternalDocumentationObject{ Description: `Description "which means nothing" too`, }, }, }, useGoTemplate: true, goTemplateArgs: []string{"my_key=too"}, }, { descr: "registered OpenAPIOption", msgDescs: []*descriptorpb.DescriptorProto{ {Name: proto.String("Message")}, }, openAPIOptions: &openapiconfig.OpenAPIOptions{ Message: []*openapiconfig.OpenAPIMessageOption{ { Message: "example.Message", Option: &openapi_options.Schema{ JsonSchema: &openapi_options.JSONSchema{ Title: "{{.Name}}", Description: "Description {{with \"which means nothing\"}}{{printf \"%q\" .}}{{end}}", }, ExternalDocs: &openapi_options.ExternalDocumentation{ Description: "Description {{with \"which means nothing\"}}{{printf \"%q\" .}}{{end}}", }, }, }, }, }, defs: map[string]openapiSchemaObject{ "Message": { schemaCore: schemaCore{ Type: "object", }, Title: "Message", Description: `Description "which means nothing"`, ExternalDocs: &openapiExternalDocumentationObject{ Description: `Description "which means nothing"`, }, }, }, useGoTemplate: true, }, { descr: "registered OpenAPIOption with go template args", msgDescs: []*descriptorpb.DescriptorProto{ {Name: proto.String("Message")}, }, openAPIOptions: &openapiconfig.OpenAPIOptions{ Message: []*openapiconfig.OpenAPIMessageOption{ { Message: "example.Message", Option: &openapi_options.Schema{ JsonSchema: &openapi_options.JSONSchema{ Title: "{{.Name}}", Description: "Description {{with \"which means nothing\"}}{{printf \"%q\" .}}{{end}} " + "{{arg \"my_key\"}}", }, ExternalDocs: &openapi_options.ExternalDocumentation{ Description: "Description {{with \"which means nothing\"}}{{printf \"%q\" .}}{{end}} " + "{{arg \"my_key\"}}", }, }, }, }, }, defs: map[string]openapiSchemaObject{ "Message": { schemaCore: schemaCore{ Type: "object", }, Title: "Message", Description: `Description "which means nothing" too`, ExternalDocs: &openapiExternalDocumentationObject{ Description: `Description "which means nothing" too`, }, }, }, useGoTemplate: true, goTemplateArgs: []string{"my_key=too"}, }, } for _, test := range tests { t.Run(test.descr, func(t *testing.T) { msgs := []*descriptor.Message{} for _, msgdesc := range test.msgDescs { msgdesc.Options = &descriptorpb.MessageOptions{} msgs = append(msgs, &descriptor.Message{DescriptorProto: msgdesc}) } reg := descriptor.NewRegistry() reg.SetUseGoTemplate(test.useGoTemplate) reg.SetGoTemplateArgs(test.goTemplateArgs) file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), Dependency: []string{}, MessageType: test.msgDescs, EnumType: []*descriptorpb.EnumDescriptorProto{}, Service: []*descriptorpb.ServiceDescriptorProto{}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, Messages: msgs, } err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}, }) if err != nil { t.Fatalf("failed to load code generator request: %v", err) } msgMap := map[string]*descriptor.Message{} for _, d := range test.msgDescs { name := d.GetName() msg, err := reg.LookupMsg("example", name) if err != nil { t.Fatalf("lookup message %v: %v", name, err) } msgMap[msg.FQMN()] = msg if schema, ok := test.schema[name]; ok { proto.SetExtension(d.Options, openapi_options.E_Openapiv2Schema, schema) } } if test.openAPIOptions != nil { if err := reg.RegisterOpenAPIOptions(test.openAPIOptions); err != nil { t.Fatalf("failed to register OpenAPI options: %s", err) } } refs := make(refMap) actual := make(openapiDefinitionsObject) if err := renderMessagesAsDefinition(msgMap, actual, reg, refs, nil); err != nil { t.Errorf("renderMessagesAsDefinition failed with: %s", err) } if !reflect.DeepEqual(actual, test.defs) { t.Errorf("Expected renderMessagesAsDefinition() to add defs %+v, not %+v", test.defs, actual) } }) } } func TestTagsWithGoTemplate(t *testing.T) { reg := descriptor.NewRegistry() reg.SetUseGoTemplate(true) reg.SetGoTemplateArgs([]string{"my_key=my_value"}) svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Options: &descriptorpb.ServiceOptions{}, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), Dependency: []string{}, MessageType: []*descriptorpb.DescriptorProto{}, EnumType: []*descriptorpb.EnumDescriptorProto{}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, Messages: []*descriptor.Message{}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, }, }, } // Set tag through service extension proto.SetExtension(file.GetService()[0].Options, openapi_options.E_Openapiv2Tag, &openapi_options.Tag{ Name: "service tag", Description: "{{ .Name }}!", }) // Set tags through file extension swagger := openapi_options.Swagger{ Tags: []*openapi_options.Tag{ { Name: "not a service tag", Description: "{{ import \"file\" }}", }, { Name: "ExampleService", Description: "ExampleService!", }, { Name: "not a service tag 2", Description: "{{ import \"file\" }}", }, { Name: "Service with my_key", Description: "the {{arg \"my_key\"}}", }, }, } proto.SetExtension(proto.Message(file.FileDescriptorProto.Options), openapi_options.E_Openapiv2Swagger, &swagger) actual, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } expectedTags := []openapiTagObject{ { Name: "not a service tag", Description: "open file: no such file or directory", }, { Name: "ExampleService", Description: "ExampleService!", }, { Name: "not a service tag 2", Description: "open file: no such file or directory", }, { Name: "Service with my_key", Description: "the my_value", }, { Name: "service tag", Description: "ExampleService!", }, } if !reflect.DeepEqual(actual.Tags, expectedTags) { t.Errorf("Expected tags %+v, not %+v", expectedTags, actual.Tags) } } func TestTemplateWithoutErrorDefinition(t *testing.T) { msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{}, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Echo"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } msg := &descriptor.Message{ DescriptorProto: msgdesc, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgdesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/echo", }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{}), }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() err := reg.Load(&pluginpb.CodeGeneratorRequest{ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}}) if err != nil { t.Errorf("failed to reg.Load(): %v", err) return } result, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } defRsp, ok := result.getPathItemObject("/v1/echo").Post.Responses["default"] if !ok { return } ref := defRsp.Schema.schemaCore.Ref refName := strings.TrimPrefix(ref, "#/definitions/") if refName == "" { t.Fatal("created default Error response with empty reflink") } if _, ok := result.Definitions[refName]; !ok { t.Errorf("default Error response with reflink '%v', but its definition was not found", refName) } } func TestSingleServiceTemplateWithDuplicateHttp1Operations(t *testing.T) { fieldType := descriptorpb.FieldDescriptorProto_TYPE_STRING field1 := &descriptorpb.FieldDescriptorProto{ Name: proto.String("name"), Number: proto.Int32(1), Type: &fieldType, } getFooMsgDesc := &descriptorpb.DescriptorProto{ Name: proto.String("GetFooRequest"), Field: []*descriptorpb.FieldDescriptorProto{ field1, }, } getFooMsg := &descriptor.Message{ DescriptorProto: getFooMsgDesc, } deleteFooMsgDesc := &descriptorpb.DescriptorProto{ Name: proto.String("DeleteFooRequest"), Field: []*descriptorpb.FieldDescriptorProto{ field1, }, } deleteFooMsg := &descriptor.Message{ DescriptorProto: deleteFooMsgDesc, } getFoo := &descriptorpb.MethodDescriptorProto{ Name: proto.String("GetFoo"), InputType: proto.String("GetFooRequest"), OutputType: proto.String("EmptyMessage"), } deleteFoo := &descriptorpb.MethodDescriptorProto{ Name: proto.String("DeleteFoo"), InputType: proto.String("DeleteFooRequest"), OutputType: proto.String("EmptyMessage"), } getBarMsgDesc := &descriptorpb.DescriptorProto{ Name: proto.String("GetBarRequest"), Field: []*descriptorpb.FieldDescriptorProto{ field1, }, } getBarMsg := &descriptor.Message{ DescriptorProto: getBarMsgDesc, } deleteBarMsgDesc := &descriptorpb.DescriptorProto{ Name: proto.String("DeleteBarRequest"), Field: []*descriptorpb.FieldDescriptorProto{ field1, }, } deleteBarMsg := &descriptor.Message{ DescriptorProto: deleteBarMsgDesc, } getBar := &descriptorpb.MethodDescriptorProto{ Name: proto.String("GetBar"), InputType: proto.String("GetBarRequest"), OutputType: proto.String("EmptyMessage"), } deleteBar := &descriptorpb.MethodDescriptorProto{ Name: proto.String("DeleteBar"), InputType: proto.String("DeleteBarRequest"), OutputType: proto.String("EmptyMessage"), } svc1 := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("Service1"), Method: []*descriptorpb.MethodDescriptorProto{getFoo, deleteFoo, getBar, deleteBar}, } emptyMsgDesc := &descriptorpb.DescriptorProto{ Name: proto.String("EmptyMessage"), } emptyMsg := &descriptor.Message{ DescriptorProto: emptyMsgDesc, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("service1.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{getBarMsgDesc, deleteBarMsgDesc, getFooMsgDesc, deleteFooMsgDesc, emptyMsgDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc1}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{getFooMsg, deleteFooMsg, getBarMsg, deleteBarMsg, emptyMsg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc1, Methods: []*descriptor.Method{ { MethodDescriptorProto: getFoo, RequestType: getFooMsg, ResponseType: getFooMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "GET", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/{name=foos/*}", }, PathParams: []descriptor.Parameter{ { Target: &descriptor.Field{ FieldDescriptorProto: field1, Message: getFooMsg, }, FieldPath: descriptor.FieldPath{ { Name: "name", }, }, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{}), }, }, }, }, { MethodDescriptorProto: deleteFoo, RequestType: deleteFooMsg, ResponseType: emptyMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "DELETE", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/{name=foos/*}", }, PathParams: []descriptor.Parameter{ { Target: &descriptor.Field{ FieldDescriptorProto: field1, Message: deleteFooMsg, }, FieldPath: descriptor.FieldPath{ { Name: "name", }, }, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{}), }, }, }, }, { MethodDescriptorProto: getBar, RequestType: getBarMsg, ResponseType: getBarMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "GET", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/{name=bars/*}", }, PathParams: []descriptor.Parameter{ { Target: &descriptor.Field{ FieldDescriptorProto: field1, Message: getBarMsg, }, FieldPath: descriptor.FieldPath{ { Name: "name", }, }, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{}), }, }, }, }, { MethodDescriptorProto: deleteBar, RequestType: deleteBarMsg, ResponseType: emptyMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "DELETE", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/{name=bars/*}", }, PathParams: []descriptor.Parameter{ { Target: &descriptor.Field{ FieldDescriptorProto: field1, Message: deleteBarMsg, }, FieldPath: descriptor.FieldPath{ { Name: "name", }, }, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{}), }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() err := reg.Load(reqFromFile(&file)) if err != nil { t.Fatalf("failed to reg.Load(): %v", err) } result, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } if got, want := len(result.Paths), 2; got != want { t.Fatalf("Results path length differed, got %d want %d", got, want) } firstOpGet := result.getPathItemObject("/v1/{name}").Get if got, want := firstOpGet.OperationID, "Service1_GetFoo"; got != want { t.Fatalf("First operation GET id differed, got %s want %s", got, want) } if got, want := len(firstOpGet.Parameters), 2; got != want { t.Fatalf("First operation GET params length differed, got %d want %d", got, want) } if got, want := firstOpGet.Parameters[0].Name, "name"; got != want { t.Fatalf("First operation GET first param name differed, got %s want %s", got, want) } if got, want := firstOpGet.Parameters[0].Pattern, "foos/[^/]+"; got != want { t.Fatalf("First operation GET first param pattern differed, got %s want %s", got, want) } if got, want := firstOpGet.Parameters[1].In, "body"; got != want { t.Fatalf("First operation GET second param 'in' differed, got %s want %s", got, want) } firstOpDelete := result.getPathItemObject("/v1/{name}").Delete if got, want := firstOpDelete.OperationID, "Service1_DeleteFoo"; got != want { t.Fatalf("First operation id DELETE differed, got %s want %s", got, want) } if got, want := len(firstOpDelete.Parameters), 2; got != want { t.Fatalf("First operation DELETE params length differed, got %d want %d", got, want) } if got, want := firstOpDelete.Parameters[0].Name, "name"; got != want { t.Fatalf("First operation DELETE first param name differed, got %s want %s", got, want) } if got, want := firstOpDelete.Parameters[0].Pattern, "foos/[^/]+"; got != want { t.Fatalf("First operation DELETE first param pattern differed, got %s want %s", got, want) } if got, want := firstOpDelete.Parameters[1].In, "body"; got != want { t.Fatalf("First operation DELETE second param 'in' differed, got %s want %s", got, want) } secondOpGet := result.getPathItemObject("/v1/{name" + pathParamUniqueSuffixDeliminator + "1}").Get if got, want := secondOpGet.OperationID, "Service1_GetBar"; got != want { t.Fatalf("Second operation id GET differed, got %s want %s", got, want) } if got, want := len(secondOpGet.Parameters), 2; got != want { t.Fatalf("Second operation GET params length differed, got %d want %d", got, want) } if got, want := secondOpGet.Parameters[0].Name, "name"+pathParamUniqueSuffixDeliminator+"1"; got != want { t.Fatalf("Second operation GET first param name differed, got %s want %s", got, want) } if got, want := secondOpGet.Parameters[0].Pattern, "bars/[^/]+"; got != want { t.Fatalf("Second operation GET first param pattern differed, got %s want %s", got, want) } if got, want := secondOpGet.Parameters[1].In, "body"; got != want { t.Fatalf("Second operation GET second param 'in' differed, got %s want %s", got, want) } secondOpDelete := result.getPathItemObject("/v1/{name" + pathParamUniqueSuffixDeliminator + "1}").Delete if got, want := secondOpDelete.OperationID, "Service1_DeleteBar"; got != want { t.Fatalf("Second operation id differed, got %s want %s", got, want) } if got, want := len(secondOpDelete.Parameters), 2; got != want { t.Fatalf("Second operation params length differed, got %d want %d", got, want) } if got, want := secondOpDelete.Parameters[0].Name, "name"+pathParamUniqueSuffixDeliminator+"1"; got != want { t.Fatalf("Second operation first param name differed, got %s want %s", got, want) } if got, want := secondOpDelete.Parameters[0].Pattern, "bars/[^/]+"; got != want { t.Fatalf("Second operation first param pattern differed, got %s want %s", got, want) } if got, want := secondOpDelete.Parameters[1].In, "body"; got != want { t.Fatalf("Second operation third param 'in' differed, got %s want %s", got, want) } } func getOperation(pathItem openapiPathItemObject, httpMethod string) *openapiOperationObject { switch httpMethod { case "GET": return pathItem.Get case "POST": return pathItem.Post case "PUT": return pathItem.Put case "DELETE": return pathItem.Delete case "PATCH": return pathItem.Patch case "HEAD": return pathItem.Head case "OPTIONS": return pathItem.Options default: return nil } } func TestSingleServiceTemplateWithDuplicateInAllSupportedHttp1Operations(t *testing.T) { supportedMethods := []string{"GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"} for _, method := range supportedMethods { fieldType := descriptorpb.FieldDescriptorProto_TYPE_STRING field1 := &descriptorpb.FieldDescriptorProto{ Name: proto.String("name"), Number: proto.Int32(1), Type: &fieldType, } methodFooMsgDesc := &descriptorpb.DescriptorProto{ Name: proto.String(method + "FooRequest"), Field: []*descriptorpb.FieldDescriptorProto{ field1, }, } methodFooMsg := &descriptor.Message{ DescriptorProto: methodFooMsgDesc, } methodFoo := &descriptorpb.MethodDescriptorProto{ Name: proto.String(method + "Foo"), InputType: proto.String(method + "FooRequest"), OutputType: proto.String("EmptyMessage"), } methodBarMsgDesc := &descriptorpb.DescriptorProto{ Name: proto.String(method + "BarRequest"), Field: []*descriptorpb.FieldDescriptorProto{ field1, }, } methodBarMsg := &descriptor.Message{ DescriptorProto: methodBarMsgDesc, } methodBar := &descriptorpb.MethodDescriptorProto{ Name: proto.String(method + "Bar"), InputType: proto.String(method + "BarRequest"), OutputType: proto.String("EmptyMessage"), } svc1 := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("Service1"), Method: []*descriptorpb.MethodDescriptorProto{methodFoo, methodBar}, } emptyMsgDesc := &descriptorpb.DescriptorProto{ Name: proto.String("EmptyMessage"), } emptyMsg := &descriptor.Message{ DescriptorProto: emptyMsgDesc, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("service1.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{methodBarMsgDesc, methodFooMsgDesc, emptyMsgDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc1}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{methodFooMsg, methodBarMsg, emptyMsg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc1, Methods: []*descriptor.Method{ { MethodDescriptorProto: methodFoo, RequestType: methodFooMsg, ResponseType: methodFooMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: method, PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/{name=foos/*}", }, PathParams: []descriptor.Parameter{ { Target: &descriptor.Field{ FieldDescriptorProto: field1, Message: methodFooMsg, }, FieldPath: descriptor.FieldPath{ { Name: "name", }, }, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{}), }, }, }, }, { MethodDescriptorProto: methodBar, RequestType: methodBarMsg, ResponseType: methodBarMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: method, PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/{name=bars/*}", }, PathParams: []descriptor.Parameter{ { Target: &descriptor.Field{ FieldDescriptorProto: field1, Message: methodBarMsg, }, FieldPath: descriptor.FieldPath{ { Name: "name", }, }, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{}), }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() err := reg.Load(reqFromFile(&file)) if err != nil { t.Fatalf("failed to reg.Load(): %v", err) } result, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } if got, want := len(result.Paths), 2; got != want { t.Fatalf("Results path length differed, got %d want %d", got, want) } firstOpMethod := getOperation(result.getPathItemObject("/v1/{name}"), method) if got, want := firstOpMethod.OperationID, "Service1_"+method+"Foo"; got != want { t.Fatalf("First operation %s id differed, got %s want %s", method, got, want) } if got, want := len(firstOpMethod.Parameters), 2; got != want { t.Fatalf("First operation %s params length differed, got %d want %d", method, got, want) } if got, want := firstOpMethod.Parameters[0].Name, "name"; got != want { t.Fatalf("First operation %s first param name differed, got %s want %s", method, got, want) } if got, want := firstOpMethod.Parameters[0].Pattern, "foos/[^/]+"; got != want { t.Fatalf("First operation %s first param pattern differed, got %s want %s", method, got, want) } if got, want := firstOpMethod.Parameters[1].In, "body"; got != want { t.Fatalf("First operation %s second param 'in' differed, got %s want %s", method, got, want) } secondOpMethod := getOperation(result.getPathItemObject("/v1/{name"+pathParamUniqueSuffixDeliminator+"1}"), method) if got, want := secondOpMethod.OperationID, "Service1_"+method+"Bar"; got != want { t.Fatalf("Second operation id %s differed, got %s want %s", method, got, want) } if got, want := len(secondOpMethod.Parameters), 2; got != want { t.Fatalf("Second operation %s params length differed, got %d want %d", method, got, want) } if got, want := secondOpMethod.Parameters[0].Name, "name"+pathParamUniqueSuffixDeliminator+"1"; got != want { t.Fatalf("Second operation %s first param name differed, got %s want %s", method, got, want) } if got, want := secondOpMethod.Parameters[0].Pattern, "bars/[^/]+"; got != want { t.Fatalf("Second operation %s first param pattern differed, got %s want %s", method, got, want) } if got, want := secondOpMethod.Parameters[1].In, "body"; got != want { t.Fatalf("Second operation %s second param 'in' differed, got %s want %s", method, got, want) } } } func TestSingleServiceTemplateWithDuplicateHttp1UnsupportedOperations(t *testing.T) { fieldType := descriptorpb.FieldDescriptorProto_TYPE_STRING field1 := &descriptorpb.FieldDescriptorProto{ Name: proto.String("name"), Number: proto.Int32(1), Type: &fieldType, } unsupportedFooMsgDesc := &descriptorpb.DescriptorProto{ Name: proto.String("UnsupportedFooRequest"), Field: []*descriptorpb.FieldDescriptorProto{ field1, }, } unsupportedFooMsg := &descriptor.Message{ DescriptorProto: unsupportedFooMsgDesc, } unsupportedFoo := &descriptorpb.MethodDescriptorProto{ Name: proto.String("UnsupportedFoo"), InputType: proto.String("UnsupportedFooRequest"), OutputType: proto.String("EmptyMessage"), } unsupportedBarMsgDesc := &descriptorpb.DescriptorProto{ Name: proto.String("UnsupportedBarRequest"), Field: []*descriptorpb.FieldDescriptorProto{ field1, }, } unsupportedBarMsg := &descriptor.Message{ DescriptorProto: unsupportedBarMsgDesc, } unsupportedBar := &descriptorpb.MethodDescriptorProto{ Name: proto.String("UnsupportedBar"), InputType: proto.String("UnsupportedBarRequest"), OutputType: proto.String("EmptyMessage"), } svc1 := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("Service1"), Method: []*descriptorpb.MethodDescriptorProto{unsupportedFoo, unsupportedBar}, } emptyMsgDesc := &descriptorpb.DescriptorProto{ Name: proto.String("EmptyMessage"), } emptyMsg := &descriptor.Message{ DescriptorProto: emptyMsgDesc, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("service1.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{unsupportedBarMsgDesc, unsupportedFooMsgDesc, emptyMsgDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc1}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{unsupportedFooMsg, unsupportedBarMsg, emptyMsg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc1, Methods: []*descriptor.Method{ { MethodDescriptorProto: unsupportedFoo, RequestType: unsupportedFooMsg, ResponseType: unsupportedFooMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "UNSUPPORTED", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/{name=foos/*}", }, PathParams: []descriptor.Parameter{ { Target: &descriptor.Field{ FieldDescriptorProto: field1, Message: unsupportedFooMsg, }, FieldPath: descriptor.FieldPath{ { Name: "name", }, }, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{}), }, }, }, }, { MethodDescriptorProto: unsupportedBar, RequestType: unsupportedBarMsg, ResponseType: unsupportedBarMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "UNSUPPORTED", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/{name=bars/*}", }, PathParams: []descriptor.Parameter{ { Target: &descriptor.Field{ FieldDescriptorProto: field1, Message: unsupportedBarMsg, }, FieldPath: descriptor.FieldPath{ { Name: "name", }, }, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{}), }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() err := reg.Load(reqFromFile(&file)) if err != nil { t.Fatalf("failed to reg.Load(): %v", err) } result, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } // Just should not crash, no special handling of unsupported HTTP methods if got, want := len(result.Paths), 1; got != want { t.Fatalf("Results path length differed, got %d want %d", got, want) } } func TestTemplateWithDuplicateHttp1Operations(t *testing.T) { fieldType := descriptorpb.FieldDescriptorProto_TYPE_STRING field1 := &descriptorpb.FieldDescriptorProto{ Name: proto.String("name"), Number: proto.Int32(1), Type: &fieldType, } field2 := &descriptorpb.FieldDescriptorProto{ Name: proto.String("role"), Number: proto.Int32(2), Type: &fieldType, } msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ field1, field2, }, } meth1 := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Method1"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), } meth2 := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Method2"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), } svc1 := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("Service1"), Method: []*descriptorpb.MethodDescriptorProto{meth1, meth2}, } meth3 := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Method3"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), } meth4 := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Method4"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), } svc2 := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("Service2"), Method: []*descriptorpb.MethodDescriptorProto{meth3, meth4}, } msg := &descriptor.Message{ DescriptorProto: msgdesc, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("service1.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgdesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc1, svc2}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc1, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth1, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "GET", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/{name=organizations/*}/{role=roles/*}", }, PathParams: []descriptor.Parameter{ { Target: &descriptor.Field{ FieldDescriptorProto: field1, Message: msg, }, FieldPath: descriptor.FieldPath{ { Name: "name", }, }, }, { Target: &descriptor.Field{ FieldDescriptorProto: field2, Message: msg, }, FieldPath: descriptor.FieldPath{ { Name: "role", }, }, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{}), }, }, }, }, { MethodDescriptorProto: meth2, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "GET", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/{name=users/*}/{role=roles/*}", }, PathParams: []descriptor.Parameter{ { Target: &descriptor.Field{ FieldDescriptorProto: field1, Message: msg, }, FieldPath: descriptor.FieldPath{ { Name: "name", }, }, }, { Target: &descriptor.Field{ FieldDescriptorProto: field2, Message: msg, }, FieldPath: descriptor.FieldPath{ { Name: "role", }, }, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{}), }, }, }, }, }, }, { ServiceDescriptorProto: svc2, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth3, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "GET", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/{name=users/*}/roles", }, PathParams: []descriptor.Parameter{ { Target: &descriptor.Field{ FieldDescriptorProto: field1, Message: msg, }, FieldPath: descriptor.FieldPath{ { Name: "name", }, }, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{}), }, }, }, }, { MethodDescriptorProto: meth4, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "GET", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/{name=groups/*}/{role=roles/*}", }, PathParams: []descriptor.Parameter{ { Target: &descriptor.Field{ FieldDescriptorProto: field1, Message: msg, }, FieldPath: descriptor.FieldPath{ { Name: "name", }, }, }, { Target: &descriptor.Field{ FieldDescriptorProto: field2, Message: msg, }, FieldPath: descriptor.FieldPath{ { Name: "role", }, }, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{}), }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() err := reg.Load(reqFromFile(&file)) if err != nil { t.Fatalf("failed to reg.Load(): %v", err) } result, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } if got, want := len(result.Paths), 4; got != want { t.Fatalf("Results path length differed, got %d want %d", got, want) } firstOp := result.getPathItemObject("/v1/{name}/{role}").Get if got, want := firstOp.OperationID, "Service1_Method1"; got != want { t.Fatalf("First operation id differed, got %s want %s", got, want) } if got, want := len(firstOp.Parameters), 3; got != want { t.Fatalf("First operation params length differed, got %d want %d", got, want) } if got, want := firstOp.Parameters[0].Name, "name"; got != want { t.Fatalf("First operation first param name differed, got %s want %s", got, want) } if got, want := firstOp.Parameters[0].Pattern, "organizations/[^/]+"; got != want { t.Fatalf("First operation first param pattern differed, got %s want %s", got, want) } if got, want := firstOp.Parameters[1].Name, "role"; got != want { t.Fatalf("First operation second param name differed, got %s want %s", got, want) } if got, want := firstOp.Parameters[1].Pattern, "roles/[^/]+"; got != want { t.Fatalf("First operation second param pattern differed, got %s want %s", got, want) } if got, want := firstOp.Parameters[2].In, "body"; got != want { t.Fatalf("First operation third param 'in' differed, got %s want %s", got, want) } secondOp := result.getPathItemObject("/v1/{name" + pathParamUniqueSuffixDeliminator + "1}/{role}").Get if got, want := secondOp.OperationID, "Service1_Method2"; got != want { t.Fatalf("Second operation id differed, got %s want %s", got, want) } if got, want := len(secondOp.Parameters), 3; got != want { t.Fatalf("Second operation params length differed, got %d want %d", got, want) } if got, want := secondOp.Parameters[0].Name, "name"+pathParamUniqueSuffixDeliminator+"1"; got != want { t.Fatalf("Second operation first param name differed, got %s want %s", got, want) } if got, want := secondOp.Parameters[0].Pattern, "users/[^/]+"; got != want { t.Fatalf("Second operation first param pattern differed, got %s want %s", got, want) } if got, want := secondOp.Parameters[1].Name, "role"; got != want { t.Fatalf("Second operation second param name differed, got %s want %s", got, want) } if got, want := secondOp.Parameters[1].Pattern, "roles/[^/]+"; got != want { t.Fatalf("Second operation second param pattern differed, got %s want %s", got, want) } if got, want := secondOp.Parameters[2].In, "body"; got != want { t.Fatalf("Second operation third param 'in' differed, got %s want %s", got, want) } thirdOp := result.getPathItemObject("/v1/{name}/roles").Get if got, want := thirdOp.OperationID, "Service2_Method3"; got != want { t.Fatalf("Third operation id differed, got %s want %s", got, want) } if got, want := len(thirdOp.Parameters), 2; got != want { t.Fatalf("Third operation params length differed, got %d want %d", got, want) } if got, want := thirdOp.Parameters[0].Name, "name"; got != want { t.Fatalf("Third operation first param name differed, got %s want %s", got, want) } if got, want := thirdOp.Parameters[0].Pattern, "users/[^/]+"; got != want { t.Fatalf("Third operation first param pattern differed, got %s want %s", got, want) } if got, want := thirdOp.Parameters[1].In, "body"; got != want { t.Fatalf("Third operation second param 'in' differed, got %s want %s", got, want) } forthOp := result.getPathItemObject("/v1/{name" + pathParamUniqueSuffixDeliminator + "2}/{role}").Get if got, want := forthOp.OperationID, "Service2_Method4"; got != want { t.Fatalf("Fourth operation id differed, got %s want %s", got, want) } if got, want := len(forthOp.Parameters), 3; got != want { t.Fatalf("Fourth operation params length differed, got %d want %d", got, want) } if got, want := forthOp.Parameters[0].Name, "name"+pathParamUniqueSuffixDeliminator+"2"; got != want { t.Fatalf("Fourth operation first param name differed, got %s want %s", got, want) } if got, want := forthOp.Parameters[0].Pattern, "groups/[^/]+"; got != want { t.Fatalf("Fourth operation first param pattern differed, got %s want %s", got, want) } if got, want := forthOp.Parameters[1].Name, "role"; got != want { t.Fatalf("Fourth operation second param name differed, got %s want %s", got, want) } if got, want := forthOp.Parameters[1].Pattern, "roles/[^/]+"; got != want { t.Fatalf("Fourth operation second param pattern differed, got %s want %s", got, want) } if got, want := forthOp.Parameters[2].In, "body"; got != want { t.Fatalf("Fourth operation second param 'in' differed, got %s want %s", got, want) } } func Test_getReservedJsonName(t *testing.T) { type args struct { fieldName string messageNameToFieldsToJSONName map[string]map[string]string fieldNameToType map[string]string } tests := []struct { name string args args want string }{ { "test case 1: single dot use case", args{ fieldName: "abc.a_1", messageNameToFieldsToJSONName: map[string]map[string]string{ "Msg": { "a_1": "a1JSONNAME", "b_1": "b1JSONNAME", }, }, fieldNameToType: map[string]string{ "abc": "pkg1.test.Msg", "bcd": "pkg1.test.Msg", }, }, "a1JSONNAME", }, { "test case 2: single dot use case with no existing field", args{ fieldName: "abc.d_1", messageNameToFieldsToJSONName: map[string]map[string]string{ "Msg": { "a_1": "a1JSONNAME", "b_1": "b1JSONNAME", }, }, fieldNameToType: map[string]string{ "abc": "pkg1.test.Msg", "bcd": "pkg1.test.Msg", }, }, "", }, { "test case 3: double dot use case", args{ fieldName: "pkg.abc.a_1", messageNameToFieldsToJSONName: map[string]map[string]string{ "Msg": { "a_1": "a1JSONNAME", "b_1": "b1JSONNAME", }, }, fieldNameToType: map[string]string{ "abc": "pkg1.test.Msg", "bcd": "pkg1.test.Msg", }, }, "a1JSONNAME", }, { "test case 4: double dot use case with a not existed field", args{ fieldName: "pkg.abc.c_1", messageNameToFieldsToJSONName: map[string]map[string]string{ "Msg": { "a_1": "a1JSONNAME", "b_1": "b1JSONNAME", }, }, fieldNameToType: map[string]string{ "abc": "pkg1.test.Msg", "bcd": "pkg1.test.Msg", }, }, "", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := getReservedJSONName(tt.args.fieldName, tt.args.messageNameToFieldsToJSONName, tt.args.fieldNameToType); got != tt.want { t.Errorf("getReservedJSONName() = %v, want %v", got, tt.want) } }) } } func TestParseIncompleteSecurityRequirement(t *testing.T) { swagger := openapi_options.Swagger{ Security: []*openapi_options.SecurityRequirement{ { SecurityRequirement: map[string]*openapi_options.SecurityRequirement_SecurityRequirementValue{ "key": nil, }, }, }, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, } proto.SetExtension(proto.Message(file.FileDescriptorProto.Options), openapi_options.E_Openapiv2Swagger, &swagger) reg := descriptor.NewRegistry() err := reg.Load(&pluginpb.CodeGeneratorRequest{ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}}) if err != nil { t.Errorf("failed to reg.Load(): %v", err) return } _, err = applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err == nil { t.Errorf("applyTemplate(%#v) did not error as expected", file) return } } func TestSubPathParams(t *testing.T) { outerParams := []descriptor.Parameter{ { FieldPath: []descriptor.FieldPathComponent{ { Name: "prefix", }, { Name: "first", }, }, }, { FieldPath: []descriptor.FieldPathComponent{ { Name: "prefix", }, { Name: "second", }, { Name: "deeper", }, }, }, { FieldPath: []descriptor.FieldPathComponent{ { Name: "otherprefix", }, { Name: "third", }, }, }, } subParams := subPathParams("prefix", outerParams) if got, want := len(subParams), 2; got != want { t.Fatalf("Wrong number of path params, got %d want %d", got, want) } if got, want := len(subParams[0].FieldPath), 1; got != want { t.Fatalf("Wrong length of path param 0, got %d want %d", got, want) } if got, want := subParams[0].FieldPath[0].Name, "first"; got != want { t.Fatalf("Wrong path param 0, element 0, got %s want %s", got, want) } if got, want := len(subParams[1].FieldPath), 2; got != want { t.Fatalf("Wrong length of path param 1 got %d want %d", got, want) } if got, want := subParams[1].FieldPath[0].Name, "second"; got != want { t.Fatalf("Wrong path param 1, element 0, got %s want %s", got, want) } if got, want := subParams[1].FieldPath[1].Name, "deeper"; got != want { t.Fatalf("Wrong path param 1, element 1, got %s want %s", got, want) } } func TestRenderServicesParameterDescriptionNoFieldBody(t *testing.T) { optionsRaw := `{ "[grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema]": { "jsonSchema": { "title": "aMessage title", "description": "aMessage description" } } }` options := &descriptorpb.MessageOptions{} err := protojson.Unmarshal([]byte(optionsRaw), options) if err != nil { t.Fatalf("Error while unmarshalling options: %s", err.Error()) } aMessageDesc := &descriptorpb.DescriptorProto{ Name: proto.String("AMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("project_id"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("other_field"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), }, }, Options: options, } someResponseDesc := &descriptorpb.DescriptorProto{ Name: proto.String("SomeResponse"), } aMeth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("AMethod"), InputType: proto.String("AMessage"), OutputType: proto.String("SomeResponse"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("Test"), Method: []*descriptorpb.MethodDescriptorProto{aMeth}, } aMessage := &descriptor.Message{ DescriptorProto: aMessageDesc, } someResponseMessage := &descriptor.Message{ DescriptorProto: someResponseDesc, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Package: proto.String("api"), Name: proto.String("test.proto"), MessageType: []*descriptorpb.DescriptorProto{aMessageDesc, someResponseDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{aMessage, someResponseMessage}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: aMeth, RequestType: aMessage, ResponseType: someResponseMessage, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/projects/someotherpath", }, Body: &descriptor.Body{}, }, }, }, }, }, }, } reg := descriptor.NewRegistry() reg.SetUseJSONNamesForFields(true) err = reg.Load(&pluginpb.CodeGeneratorRequest{ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}}) if err != nil { t.Fatalf("failed to reg.Load(): %v", err) } result, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } got := result.getPathItemObject("/v1/projects/someotherpath").Post.Parameters[0].Description want := "aMessage description" if got != want { t.Fatalf("Wrong description for body parameter, got %s want %s", got, want) } } func TestRenderServicesWithBodyFieldNameInCamelCase(t *testing.T) { userDesc := &descriptorpb.DescriptorProto{ Name: proto.String("User"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("name"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("role"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), }, }, } updateDesc := &descriptorpb.DescriptorProto{ Name: proto.String("UpdateUserRequest"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("user_object"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.User"), Number: proto.Int32(1), }, }, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("UpdateUser"), InputType: proto.String("UpdateUserRequest"), OutputType: proto.String("User"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("UserService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } userMsg := &descriptor.Message{ DescriptorProto: userDesc, } updateMsg := &descriptor.Message{ DescriptorProto: updateDesc, } nameField := &descriptor.Field{ Message: userMsg, FieldDescriptorProto: userMsg.GetField()[0], } nameField.JsonName = proto.String("name") roleField := &descriptor.Field{ Message: userMsg, FieldDescriptorProto: userMsg.GetField()[1], } roleField.JsonName = proto.String("role") userMsg.Fields = []*descriptor.Field{nameField, roleField} userField := &descriptor.Field{ Message: updateMsg, FieldMessage: userMsg, FieldDescriptorProto: updateMsg.GetField()[0], } userField.JsonName = proto.String("userObject") updateMsg.Fields = []*descriptor.Field{userField} file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Package: proto.String("example"), Name: proto.String("user_service.proto"), MessageType: []*descriptorpb.DescriptorProto{userDesc, updateDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{userMsg, updateMsg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: updateMsg, ResponseType: userMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/users/{user_object.name}", }, PathParams: []descriptor.Parameter{ { FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "user_object", }, { Name: "name", }, }), Target: nameField, }, }, Body: &descriptor.Body{ FieldPath: []descriptor.FieldPathComponent{ { Name: "user_object", Target: userField, }, }, }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() reg.SetUseJSONNamesForFields(true) err := reg.Load(&pluginpb.CodeGeneratorRequest{ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}}) if err != nil { t.Fatalf("failed to reg.Load(): %v", err) } result, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } paths := GetPaths(result) if got, want := len(paths), 1; got != want { t.Fatalf("Results path length differed, got %d want %d", got, want) } if got, want := paths[0], "/v1/users/{userObject.name}"; got != want { t.Fatalf("Wrong results path, got %s want %s", got, want) } operation := *result.getPathItemObject("/v1/users/{userObject.name}").Post if got, want := len(operation.Parameters), 2; got != want { t.Fatalf("Parameters length differed, got %d want %d", got, want) } if got, want := operation.Parameters[0].Name, "userObject.name"; got != want { t.Fatalf("Wrong parameter name, got %s want %s", got, want) } if got, want := operation.Parameters[0].In, "path"; got != want { t.Fatalf("Wrong parameter location, got %s want %s", got, want) } if got, want := operation.Parameters[1].Name, "userObject"; got != want { t.Fatalf("Wrong parameter name, got %s want %s", got, want) } if got, want := operation.Parameters[1].In, "body"; got != want { t.Fatalf("Wrong parameter location, got %s want %s", got, want) } // The body parameter should be inlined and not contain 'name', as this is a path parameter. schema := operation.Parameters[1].Schema if got, want := schema.Ref, ""; got != want { t.Fatalf("Wrong reference, got %s want %s", got, want) } props := schema.Properties if props == nil { t.Fatal("No properties on body parameter") } if got, want := len(*props), 1; got != want { t.Fatalf("Properties length differed, got %d want %d", got, want) } for _, v := range *props { if got, want := v.Key, "role"; got != want { t.Fatalf("Wrong key for property, got %s want %s", got, want) } } } func TestRenderServicesWithBodyFieldHasFieldMask(t *testing.T) { userDesc := &descriptorpb.DescriptorProto{ Name: proto.String("User"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("name"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("role"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), }, }, } updateDesc := &descriptorpb.DescriptorProto{ Name: proto.String("UpdateUserRequest"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("user_object"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.User"), Number: proto.Int32(1), }, { Name: proto.String("update_mask"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".google.protobuf.FieldMask"), Number: proto.Int32(2), }, }, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("UpdateUser"), InputType: proto.String("UpdateUserRequest"), OutputType: proto.String("User"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("UserService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } userMsg := &descriptor.Message{ DescriptorProto: userDesc, } updateMsg := &descriptor.Message{ DescriptorProto: updateDesc, } nameField := &descriptor.Field{ Message: userMsg, FieldDescriptorProto: userMsg.GetField()[0], } nameField.JsonName = proto.String("name") roleField := &descriptor.Field{ Message: userMsg, FieldDescriptorProto: userMsg.GetField()[1], } roleField.JsonName = proto.String("role") userMsg.Fields = []*descriptor.Field{nameField, roleField} userField := &descriptor.Field{ Message: updateMsg, FieldMessage: userMsg, FieldDescriptorProto: updateMsg.GetField()[0], } userField.JsonName = proto.String("userObject") updateMaskField := &descriptor.Field{ Message: updateMsg, FieldDescriptorProto: updateMsg.GetField()[1], } updateMaskField.JsonName = proto.String("updateMask") updateMsg.Fields = []*descriptor.Field{userField, updateMaskField} file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Package: proto.String("example"), Name: proto.String("user_service.proto"), Dependency: []string{"google/well_known.proto"}, MessageType: []*descriptorpb.DescriptorProto{userDesc, updateDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{userMsg, updateMsg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: updateMsg, ResponseType: userMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "PATCH", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/users/{user_object.name}", }, PathParams: []descriptor.Parameter{ { FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "user_object", }, { Name: "name", }, }), Target: nameField, }, }, Body: &descriptor.Body{ FieldPath: []descriptor.FieldPathComponent{ { Name: "user_object", Target: userField, }, }, }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() reg.SetUseJSONNamesForFields(true) reg.SetAllowPatchFeature(true) err := reg.Load(&pluginpb.CodeGeneratorRequest{ProtoFile: []*descriptorpb.FileDescriptorProto{ { SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("google/well_known.proto"), Package: proto.String("google.protobuf"), Dependency: []string{}, MessageType: []*descriptorpb.DescriptorProto{ protodesc.ToDescriptorProto((&field_mask.FieldMask{}).ProtoReflect().Descriptor()), }, Service: []*descriptorpb.ServiceDescriptorProto{}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("google/well_known"), }, }, file.FileDescriptorProto, }}) if err != nil { t.Fatalf("failed to reg.Load(): %v", err) } result, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } paths := GetPaths(result) if got, want := len(paths), 1; got != want { t.Fatalf("Results path length differed, got %d want %d", got, want) } if got, want := paths[0], "/v1/users/{userObject.name}"; got != want { t.Fatalf("Wrong results path, got %s want %s", got, want) } operation := *result.getPathItemObject("/v1/users/{userObject.name}").Patch if got, want := len(operation.Parameters), 2; got != want { t.Fatalf("Parameters length differed, got %d want %d", got, want) } if got, want := operation.Parameters[0].Name, "userObject.name"; got != want { t.Fatalf("Wrong parameter name, got %s want %s", got, want) } if got, want := operation.Parameters[0].In, "path"; got != want { t.Fatalf("Wrong parameter location, got %s want %s", got, want) } if got, want := operation.Parameters[1].Name, "userObject"; got != want { t.Fatalf("Wrong parameter name, got %s want %s", got, want) } if got, want := operation.Parameters[1].In, "body"; got != want { t.Fatalf("Wrong parameter location, got %s want %s", got, want) } } func TestRenderServicesWithBodyFieldHasRequiredField(t *testing.T) { fieldBehaviorRequired := []annotations.FieldBehavior{annotations.FieldBehavior_REQUIRED} requiredFieldOptions := new(descriptorpb.FieldOptions) proto.SetExtension(requiredFieldOptions, annotations.E_FieldBehavior, fieldBehaviorRequired) userDesc := &descriptorpb.DescriptorProto{ Name: proto.String("User"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("name"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), Options: requiredFieldOptions, }, { Name: proto.String("role"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), Options: requiredFieldOptions, }, }, } createDesc := &descriptorpb.DescriptorProto{ Name: proto.String("CreateUserRequest"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("user_object"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.User"), Number: proto.Int32(1), Options: requiredFieldOptions, }, }, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("CreateUser"), InputType: proto.String("CreateUserRequest"), OutputType: proto.String("User"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("UserService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } userMsg := &descriptor.Message{ DescriptorProto: userDesc, } createMsg := &descriptor.Message{ DescriptorProto: createDesc, } nameField := &descriptor.Field{ Message: userMsg, FieldDescriptorProto: userMsg.GetField()[0], } nameField.JsonName = proto.String("name") roleField := &descriptor.Field{ Message: userMsg, FieldDescriptorProto: userMsg.GetField()[1], } roleField.JsonName = proto.String("role") userMsg.Fields = []*descriptor.Field{nameField, roleField} userField := &descriptor.Field{ Message: createMsg, FieldMessage: userMsg, FieldDescriptorProto: createMsg.GetField()[0], } userField.JsonName = proto.String("userObject") file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Package: proto.String("example"), Name: proto.String("user_service.proto"), MessageType: []*descriptorpb.DescriptorProto{userDesc, createDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{userMsg, createMsg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: createMsg, ResponseType: userMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/users", }, Body: &descriptor.Body{ FieldPath: []descriptor.FieldPathComponent{ { Name: "user_object", Target: userField, }, }, }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() reg.SetUseJSONNamesForFields(true) err := reg.Load(reqFromFile(&file)) if err != nil { t.Fatalf("failed to reg.Load(): %v", err) } result, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } paths := GetPaths(result) if got, want := len(paths), 1; got != want { t.Fatalf("Results path length differed, got %d want %d", got, want) } if got, want := paths[0], "/v1/users"; got != want { t.Fatalf("Wrong results path, got %s want %s", got, want) } operation := *result.getPathItemObject("/v1/users").Post if got, want := len(operation.Parameters), 1; got != want { t.Fatalf("Parameters length differed, got %d want %d", got, want) } if got, want := operation.Parameters[0].Name, "userObject"; got != want { t.Fatalf("Wrong parameter name, got %s want %s", got, want) } if got, want := operation.Parameters[0].In, "body"; got != want { t.Fatalf("Wrong parameter location, got %s want %s", got, want) } if got := operation.Parameters[0].Required; got != true { t.Fatalf("Wrong parameter required, got %v want %v", got, true) } if got, want := len(operation.Parameters[0].Schema.Required), 0; got != want { t.Fatalf("Wrong parameter schema required, got %v want %v", got, want) } } func TestRenderServicesWithColonInPath(t *testing.T) { jsonSchema := &openapi_options.JSONSchema{ FieldConfiguration: &openapi_options.JSONSchema_FieldConfiguration{ PathParamName: "overrideField", }, } fieldOptions := new(descriptorpb.FieldOptions) proto.SetExtension(fieldOptions, openapi_options.E_Openapiv2Field, jsonSchema) reqDesc := &descriptorpb.DescriptorProto{ Name: proto.String("MyRequest"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("field"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), Options: fieldOptions, }, }, } resDesc := &descriptorpb.DescriptorProto{ Name: proto.String("MyResponse"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("field"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, }, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("MyMethod"), InputType: proto.String("MyRequest"), OutputType: proto.String("MyResponse"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("MyService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } reqMsg := &descriptor.Message{ DescriptorProto: reqDesc, } resMsg := &descriptor.Message{ DescriptorProto: resDesc, } reqField := &descriptor.Field{ Message: reqMsg, FieldDescriptorProto: reqMsg.GetField()[0], } resField := &descriptor.Field{ Message: resMsg, FieldDescriptorProto: resMsg.GetField()[0], } reqField.JsonName = proto.String("field") resField.JsonName = proto.String("field") reqMsg.Fields = []*descriptor.Field{reqField} resMsg.Fields = []*descriptor.Field{resField} file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Package: proto.String("example"), Name: proto.String(",my_service.proto"), MessageType: []*descriptorpb.DescriptorProto{reqDesc, resDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{reqMsg, resMsg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: reqMsg, ResponseType: resMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/my/{field}:foo", }, PathParams: []descriptor.Parameter{ { FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "field", }, }), Target: reqField, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{}), }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() reg.SetUseJSONNamesForFields(true) err := reg.Load(reqFromFile(&file)) if err != nil { t.Fatalf("failed to reg.Load(): %v", err) } result, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } paths := GetPaths(result) if got, want := len(paths), 1; got != want { t.Fatalf("Results path length differed, got %d want %d", got, want) } if got, want := paths[0], "/my/{overrideField}:foo"; got != want { t.Fatalf("Wrong results path, got %s want %s", got, want) } operation := *result.getPathItemObject("/my/{overrideField}:foo").Post if got, want := len(operation.Parameters), 2; got != want { t.Fatalf("Parameters length differed, got %d want %d", got, want) } if got, want := operation.Parameters[0].Name, "overrideField"; got != want { t.Fatalf("Wrong parameter name, got %s want %s", got, want) } if got, want := operation.Parameters[0].In, "path"; got != want { t.Fatalf("Wrong parameter location, got %s want %s", got, want) } if got, want := operation.Parameters[0].Type, "string"; got != want { t.Fatalf("Wrong parameter type, got %s want %s", got, want) } if got, want := operation.Parameters[1].Name, "body"; got != want { t.Fatalf("Wrong parameter name, got %s want %s", got, want) } if got, want := operation.Parameters[1].In, "body"; got != want { t.Fatalf("Wrong parameter location, got %s want %s", got, want) } } func TestRenderServicesWithDoubleColonInPath(t *testing.T) { reqDesc := &descriptorpb.DescriptorProto{ Name: proto.String("MyRequest"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("field"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, }, } resDesc := &descriptorpb.DescriptorProto{ Name: proto.String("MyResponse"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("field"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, }, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("MyMethod"), InputType: proto.String("MyRequest"), OutputType: proto.String("MyResponse"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("MyService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } reqMsg := &descriptor.Message{ DescriptorProto: reqDesc, } resMsg := &descriptor.Message{ DescriptorProto: resDesc, } reqField := &descriptor.Field{ Message: reqMsg, FieldDescriptorProto: reqMsg.GetField()[0], } resField := &descriptor.Field{ Message: resMsg, FieldDescriptorProto: resMsg.GetField()[0], } reqField.JsonName = proto.String("field") resField.JsonName = proto.String("field") reqMsg.Fields = []*descriptor.Field{reqField} resMsg.Fields = []*descriptor.Field{resField} file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Package: proto.String("example"), Name: proto.String(",my_service.proto"), MessageType: []*descriptorpb.DescriptorProto{reqDesc, resDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{reqMsg, resMsg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: reqMsg, ResponseType: resMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/my/{field}:foo:bar", }, PathParams: []descriptor.Parameter{ { FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "field", }, }), Target: reqField, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{}), }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() reg.SetUseJSONNamesForFields(true) err := reg.Load(reqFromFile(&file)) if err != nil { t.Fatalf("failed to reg.Load(): %v", err) } result, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } paths := GetPaths(result) if got, want := len(paths), 1; got != want { t.Fatalf("Results path length differed, got %d want %d", got, want) } if got, want := paths[0], "/my/{field}:foo:bar"; got != want { t.Fatalf("Wrong results path, got %s want %s", got, want) } operation := *result.getPathItemObject("/my/{field}:foo:bar").Post if got, want := len(operation.Parameters), 2; got != want { t.Fatalf("Parameters length differed, got %d want %d", got, want) } if got, want := operation.Parameters[0].Name, "field"; got != want { t.Fatalf("Wrong parameter name, got %s want %s", got, want) } if got, want := operation.Parameters[0].In, "path"; got != want { t.Fatalf("Wrong parameter location, got %s want %s", got, want) } if got, want := operation.Parameters[0].Type, "string"; got != want { t.Fatalf("Wrong parameter type, got %s want %s", got, want) } if got, want := operation.Parameters[1].Name, "body"; got != want { t.Fatalf("Wrong parameter name, got %s want %s", got, want) } if got, want := operation.Parameters[1].In, "body"; got != want { t.Fatalf("Wrong parameter location, got %s want %s", got, want) } } func TestRenderServicesWithColonLastInPath(t *testing.T) { reqDesc := &descriptorpb.DescriptorProto{ Name: proto.String("MyRequest"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("field"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, }, } resDesc := &descriptorpb.DescriptorProto{ Name: proto.String("MyResponse"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("field"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, }, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("MyMethod"), InputType: proto.String("MyRequest"), OutputType: proto.String("MyResponse"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("MyService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } reqMsg := &descriptor.Message{ DescriptorProto: reqDesc, } resMsg := &descriptor.Message{ DescriptorProto: resDesc, } reqField := &descriptor.Field{ Message: reqMsg, FieldDescriptorProto: reqMsg.GetField()[0], } resField := &descriptor.Field{ Message: resMsg, FieldDescriptorProto: resMsg.GetField()[0], } reqField.JsonName = proto.String("field") resField.JsonName = proto.String("field") reqMsg.Fields = []*descriptor.Field{reqField} resMsg.Fields = []*descriptor.Field{resField} file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Package: proto.String("example"), Name: proto.String(",my_service.proto"), MessageType: []*descriptorpb.DescriptorProto{reqDesc, resDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{reqMsg, resMsg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: reqMsg, ResponseType: resMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/my/{field}:", }, PathParams: []descriptor.Parameter{ { FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "field", }, }), Target: reqField, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{}), }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() reg.SetUseJSONNamesForFields(true) err := reg.Load(reqFromFile(&file)) if err != nil { t.Fatalf("failed to reg.Load(): %v", err) } result, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } paths := GetPaths(result) if got, want := len(paths), 1; got != want { t.Fatalf("Results path length differed, got %d want %d", got, want) } if got, want := paths[0], "/my/{field}:"; got != want { t.Fatalf("Wrong results path, got %s want %s", got, want) } operation := *result.getPathItemObject("/my/{field}:").Post if got, want := len(operation.Parameters), 2; got != want { t.Fatalf("Parameters length differed, got %d want %d", got, want) } if got, want := operation.Parameters[0].Name, "field"; got != want { t.Fatalf("Wrong parameter name, got %s want %s", got, want) } if got, want := operation.Parameters[0].In, "path"; got != want { t.Fatalf("Wrong parameter location, got %s want %s", got, want) } if got, want := operation.Parameters[0].Type, "string"; got != want { t.Fatalf("Wrong parameter type, got %s want %s", got, want) } if got, want := operation.Parameters[1].Name, "body"; got != want { t.Fatalf("Wrong parameter name, got %s want %s", got, want) } if got, want := operation.Parameters[1].In, "body"; got != want { t.Fatalf("Wrong parameter location, got %s want %s", got, want) } } func TestRenderServicesWithColonInSegment(t *testing.T) { reqDesc := &descriptorpb.DescriptorProto{ Name: proto.String("MyRequest"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("field"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, }, } resDesc := &descriptorpb.DescriptorProto{ Name: proto.String("MyResponse"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("field"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, }, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("MyMethod"), InputType: proto.String("MyRequest"), OutputType: proto.String("MyResponse"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("MyService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } reqMsg := &descriptor.Message{ DescriptorProto: reqDesc, } resMsg := &descriptor.Message{ DescriptorProto: resDesc, } reqField := &descriptor.Field{ Message: reqMsg, FieldDescriptorProto: reqMsg.GetField()[0], } resField := &descriptor.Field{ Message: resMsg, FieldDescriptorProto: resMsg.GetField()[0], } reqField.JsonName = proto.String("field") resField.JsonName = proto.String("field") reqMsg.Fields = []*descriptor.Field{reqField} resMsg.Fields = []*descriptor.Field{resField} file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Package: proto.String("example"), Name: proto.String(",my_service.proto"), MessageType: []*descriptorpb.DescriptorProto{reqDesc, resDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{reqMsg, resMsg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: reqMsg, ResponseType: resMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/my/{field=segment/wi:th}", }, PathParams: []descriptor.Parameter{ { FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "field", }, }), Target: reqField, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{}), }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() reg.SetUseJSONNamesForFields(true) err := reg.Load(reqFromFile(&file)) if err != nil { t.Fatalf("failed to reg.Load(): %v", err) } result, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } paths := GetPaths(result) if got, want := len(paths), 1; got != want { t.Fatalf("Results path length differed, got %d want %d", got, want) } if got, want := paths[0], "/my/{field}"; got != want { t.Fatalf("Wrong results path, got %s want %s", got, want) } operation := *result.getPathItemObject("/my/{field}").Post if got, want := len(operation.Parameters), 2; got != want { t.Fatalf("Parameters length differed, got %d want %d", got, want) } if got, want := operation.Parameters[0].Name, "field"; got != want { t.Fatalf("Wrong parameter name, got %s want %s", got, want) } if got, want := operation.Parameters[0].In, "path"; got != want { t.Fatalf("Wrong parameter location, got %s want %s", got, want) } if got, want := operation.Parameters[0].Type, "string"; got != want { t.Fatalf("Wrong parameter type, got %s want %s", got, want) } if got, want := operation.Parameters[1].Name, "body"; got != want { t.Fatalf("Wrong parameter name, got %s want %s", got, want) } if got, want := operation.Parameters[1].In, "body"; got != want { t.Fatalf("Wrong parameter location, got %s want %s", got, want) } } func TestRenderServiceWithHeaderParameters(t *testing.T) { file := func() descriptor.File { msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Example"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), Options: &descriptorpb.MethodOptions{}, } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } msg := &descriptor.Message{ DescriptorProto: msgdesc, } return descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgdesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "GET", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/echo", }, }, }, }, }, }, }, } } type test struct { file func() descriptor.File openapiOperation *openapi_options.Operation parameters openapiParametersObject } tests := map[string]*test{ "type string": { file: file, openapiOperation: &openapi_options.Operation{ Parameters: &openapi_options.Parameters{ Headers: []*openapi_options.HeaderParameter{ { Name: "X-Custom-Header", Type: openapi_options.HeaderParameter_STRING, }, }, }, }, parameters: openapiParametersObject{ { Name: "X-Custom-Header", In: "header", Type: "string", }, }, }, "type string with format": { file: file, openapiOperation: &openapi_options.Operation{ Parameters: &openapi_options.Parameters{ Headers: []*openapi_options.HeaderParameter{ { Name: "X-Custom-Header", Type: openapi_options.HeaderParameter_STRING, Format: "uuid", }, }, }, }, parameters: openapiParametersObject{ { Name: "X-Custom-Header", In: "header", Type: "string", Format: "uuid", }, }, }, "type integer": { file: file, openapiOperation: &openapi_options.Operation{ Parameters: &openapi_options.Parameters{ Headers: []*openapi_options.HeaderParameter{ { Name: "X-Custom-Header", Type: openapi_options.HeaderParameter_INTEGER, }, }, }, }, parameters: openapiParametersObject{ { Name: "X-Custom-Header", In: "header", Type: "integer", }, }, }, "type number": { file: file, openapiOperation: &openapi_options.Operation{ Parameters: &openapi_options.Parameters{ Headers: []*openapi_options.HeaderParameter{ { Name: "X-Custom-Header", Type: openapi_options.HeaderParameter_NUMBER, }, }, }, }, parameters: openapiParametersObject{ { Name: "X-Custom-Header", In: "header", Type: "number", }, }, }, "type boolean": { file: file, openapiOperation: &openapi_options.Operation{ Parameters: &openapi_options.Parameters{ Headers: []*openapi_options.HeaderParameter{ { Name: "X-Custom-Header", Type: openapi_options.HeaderParameter_BOOLEAN, }, }, }, }, parameters: openapiParametersObject{ { Name: "X-Custom-Header", In: "header", Type: "boolean", }, }, }, "header required": { file: file, openapiOperation: &openapi_options.Operation{ Parameters: &openapi_options.Parameters{ Headers: []*openapi_options.HeaderParameter{ { Name: "X-Custom-Header", Required: true, Type: openapi_options.HeaderParameter_STRING, }, }, }, }, parameters: openapiParametersObject{ { Name: "X-Custom-Header", In: "header", Required: true, Type: "string", }, }, }, } for name, test := range tests { test := test t.Run(name, func(t *testing.T) { file := test.file() proto.SetExtension( proto.Message(file.Services[0].Methods[0].Options), openapi_options.E_Openapiv2Operation, test.openapiOperation) reg := descriptor.NewRegistry() fileCL := crossLinkFixture(&file) err := reg.Load(reqFromFile(fileCL)) if err != nil { t.Errorf("reg.Load(%#v) failed with %v; want success", file, err) } result, err := applyTemplate(param{File: fileCL, reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } params := result.getPathItemObject("/v1/echo").Get.Parameters if !reflect.DeepEqual(params, test.parameters) { t.Errorf("expected %+v, got %+v", test.parameters, params) } }) } } func GetPaths(req *openapiSwaggerObject) []string { paths := make([]string, len(req.Paths)) i := 0 for _, k := range req.Paths { paths[i] = k.Path i++ } return paths } func TestRenderServicesOpenapiPathsOrderPreserved(t *testing.T) { reqDesc := &descriptorpb.DescriptorProto{ Name: proto.String("MyRequest"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("field"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, }, } resDesc := &descriptorpb.DescriptorProto{ Name: proto.String("MyResponse"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("field"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, }, } meth1 := &descriptorpb.MethodDescriptorProto{ Name: proto.String("MyMethod1"), InputType: proto.String("MyRequest"), OutputType: proto.String("MyResponse"), } meth2 := &descriptorpb.MethodDescriptorProto{ Name: proto.String("MyMethod2"), InputType: proto.String("MyRequest"), OutputType: proto.String("MyResponse"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("MyService"), Method: []*descriptorpb.MethodDescriptorProto{meth1, meth2}, } reqMsg := &descriptor.Message{ DescriptorProto: reqDesc, } resMsg := &descriptor.Message{ DescriptorProto: resDesc, } reqField := &descriptor.Field{ Message: reqMsg, FieldDescriptorProto: reqMsg.GetField()[0], } resField := &descriptor.Field{ Message: resMsg, FieldDescriptorProto: resMsg.GetField()[0], } reqField.JsonName = proto.String("field") resField.JsonName = proto.String("field") reqMsg.Fields = []*descriptor.Field{reqField} resMsg.Fields = []*descriptor.Field{resField} file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Package: proto.String("example"), Name: proto.String(",my_service.proto"), MessageType: []*descriptorpb.DescriptorProto{reqDesc, resDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{reqMsg, resMsg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth1, RequestType: reqMsg, ResponseType: resMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/c/cpath", }, }, }, }, { MethodDescriptorProto: meth2, RequestType: reqMsg, ResponseType: resMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/b/bpath", }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() reg.SetPreserveRPCOrder(true) err := reg.Load(&pluginpb.CodeGeneratorRequest{ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}}) if err != nil { t.Fatalf("failed to reg.Load(): %v", err) } result, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } paths := result.Paths firstRPCPath := file.Services[0].Methods[0].Bindings[0].PathTmpl.Template secondRPCPath := file.Services[0].Methods[1].Bindings[0].PathTmpl.Template for i, pathData := range paths { switch i { case 0: if got, want := pathData.Path, firstRPCPath; got != want { t.Fatalf("RPC path order not preserved, got %s want %s", got, want) } case 1: if got, want := pathData.Path, secondRPCPath; got != want { t.Fatalf("RPC path order not preserved, got %s want %s", got, want) } } } } func TestRenderServicesOpenapiPathsOrderPreservedMultipleServices(t *testing.T) { reqDesc := &descriptorpb.DescriptorProto{ Name: proto.String("MyRequest"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("field"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, }, } resDesc := &descriptorpb.DescriptorProto{ Name: proto.String("MyResponse"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("field"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, }, } meth1 := &descriptorpb.MethodDescriptorProto{ Name: proto.String("MyMethod1"), InputType: proto.String("MyRequest"), OutputType: proto.String("MyResponse"), } meth2 := &descriptorpb.MethodDescriptorProto{ Name: proto.String("MyMethod2"), InputType: proto.String("MyRequest"), OutputType: proto.String("MyResponse"), } meth3 := &descriptorpb.MethodDescriptorProto{ Name: proto.String("MyMethod3"), InputType: proto.String("MyRequest"), OutputType: proto.String("MyResponse"), } meth4 := &descriptorpb.MethodDescriptorProto{ Name: proto.String("MyMethod4"), InputType: proto.String("MyRequest"), OutputType: proto.String("MyResponse"), } svc1 := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("MyServiceOne"), Method: []*descriptorpb.MethodDescriptorProto{meth1, meth2}, } svc2 := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("MyServiceTwo"), Method: []*descriptorpb.MethodDescriptorProto{meth3, meth4}, } reqMsg := &descriptor.Message{ DescriptorProto: reqDesc, } resMsg := &descriptor.Message{ DescriptorProto: resDesc, } reqField := &descriptor.Field{ Message: reqMsg, FieldDescriptorProto: reqMsg.GetField()[0], } resField := &descriptor.Field{ Message: resMsg, FieldDescriptorProto: resMsg.GetField()[0], } reqField.JsonName = proto.String("field") resField.JsonName = proto.String("field") reqMsg.Fields = []*descriptor.Field{reqField} resMsg.Fields = []*descriptor.Field{resField} file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Package: proto.String("example"), Name: proto.String(",my_service.proto"), MessageType: []*descriptorpb.DescriptorProto{reqDesc, resDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc1, svc2}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{reqMsg, resMsg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc1, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth1, RequestType: reqMsg, ResponseType: resMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/g/gpath", }, }, }, }, { MethodDescriptorProto: meth2, RequestType: reqMsg, ResponseType: resMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/f/fpath", }, }, }, }, }, }, { ServiceDescriptorProto: svc1, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth3, RequestType: reqMsg, ResponseType: resMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/c/cpath", }, }, }, }, { MethodDescriptorProto: meth4, RequestType: reqMsg, ResponseType: resMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/b/bpath", }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() reg.SetPreserveRPCOrder(true) reg.SetUseJSONNamesForFields(true) err := reg.Load(&pluginpb.CodeGeneratorRequest{ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}}) if err != nil { t.Fatalf("failed to reg.Load(): %v", err) } result, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } paths := result.Paths firstRPCPath := file.Services[0].Methods[0].Bindings[0].PathTmpl.Template secondRPCPath := file.Services[0].Methods[1].Bindings[0].PathTmpl.Template thirdRPCPath := file.Services[1].Methods[0].Bindings[0].PathTmpl.Template fourthRPCPath := file.Services[1].Methods[1].Bindings[0].PathTmpl.Template for i, pathData := range paths { switch i { case 0: if got, want := pathData.Path, firstRPCPath; got != want { t.Fatalf("RPC path order not preserved, got %s want %s", got, want) } case 1: if got, want := pathData.Path, secondRPCPath; got != want { t.Fatalf("RPC path order not preserved, got %s want %s", got, want) } case 2: if got, want := pathData.Path, thirdRPCPath; got != want { t.Fatalf("RPC path order not preserved, got %s want %s", got, want) } case 3: if got, want := pathData.Path, fourthRPCPath; got != want { t.Fatalf("RPC path order not preserved, got %s want %s", got, want) } } } } func TestRenderServicesOpenapiPathsOrderPreservedAdditionalBindings(t *testing.T) { reqDesc := &descriptorpb.DescriptorProto{ Name: proto.String("MyRequest"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("field"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, }, } resDesc := &descriptorpb.DescriptorProto{ Name: proto.String("MyResponse"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("field"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, }, } meth1 := &descriptorpb.MethodDescriptorProto{ Name: proto.String("MyMethod1"), InputType: proto.String("MyRequest"), OutputType: proto.String("MyResponse"), } meth2 := &descriptorpb.MethodDescriptorProto{ Name: proto.String("MyMethod2"), InputType: proto.String("MyRequest"), OutputType: proto.String("MyResponse"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("MyService"), Method: []*descriptorpb.MethodDescriptorProto{meth1, meth2}, } reqMsg := &descriptor.Message{ DescriptorProto: reqDesc, } resMsg := &descriptor.Message{ DescriptorProto: resDesc, } reqField := &descriptor.Field{ Message: reqMsg, FieldDescriptorProto: reqMsg.GetField()[0], } resField := &descriptor.Field{ Message: resMsg, FieldDescriptorProto: resMsg.GetField()[0], } reqField.JsonName = proto.String("field") resField.JsonName = proto.String("field") reqMsg.Fields = []*descriptor.Field{reqField} resMsg.Fields = []*descriptor.Field{resField} file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Package: proto.String("example"), Name: proto.String(",my_service.proto"), MessageType: []*descriptorpb.DescriptorProto{reqDesc, resDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{reqMsg, resMsg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth1, RequestType: reqMsg, ResponseType: resMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/c/cpath", }, }, { HTTPMethod: "GET", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/additionalbinding", }, }, }, }, { MethodDescriptorProto: meth2, RequestType: reqMsg, ResponseType: resMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/b/bpath", }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() reg.SetPreserveRPCOrder(true) reg.SetUseJSONNamesForFields(true) err := reg.Load(&pluginpb.CodeGeneratorRequest{ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}}) if err != nil { t.Fatalf("failed to reg.Load(): %v", err) } result, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } paths := result.Paths if err != nil { t.Fatalf("failed to obtain extension paths: %v", err) } firstRPCPath := file.Services[0].Methods[0].Bindings[0].PathTmpl.Template firstRPCPathAdditionalBinding := file.Services[0].Methods[0].Bindings[1].PathTmpl.Template secondRPCPath := file.Services[0].Methods[1].Bindings[0].PathTmpl.Template for i, pathData := range paths { switch i { case 0: if got, want := pathData.Path, firstRPCPath; got != want { t.Fatalf("RPC path order not preserved, got %s want %s", got, want) } case 1: if got, want := pathData.Path, firstRPCPathAdditionalBinding; got != want { t.Fatalf("RPC path order not preserved, got %s want %s", got, want) } case 2: if got, want := pathData.Path, secondRPCPath; got != want { t.Fatalf("RPC path order not preserved, got %s want %s", got, want) } } } } func TestRenderServicesOpenapiRequiredBodyFieldContainingPathParam(t *testing.T) { fieldBehaviorRequired := []annotations.FieldBehavior{annotations.FieldBehavior_REQUIRED} requiredFieldOptions := new(descriptorpb.FieldOptions) proto.SetExtension(requiredFieldOptions, annotations.E_FieldBehavior, fieldBehaviorRequired) bookDesc := &descriptorpb.DescriptorProto{ Name: proto.String("Book"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("name"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("type"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), }, }, } addBookReqDesc := &descriptorpb.DescriptorProto{ Name: proto.String("AddBookReq"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("book"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".Book"), Number: proto.Int32(1), Options: requiredFieldOptions, }, { Name: proto.String("libraryId"), Type: descriptorpb.FieldDescriptorProto_TYPE_UINT32.Enum(), Number: proto.Int32(2), Options: requiredFieldOptions, }, { Name: proto.String("isLatestEdition"), Type: descriptorpb.FieldDescriptorProto_TYPE_BOOL.Enum(), Number: proto.Int32(3), }, }, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("AddBook"), InputType: proto.String("AddBookReq"), OutputType: proto.String("Book"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("BookService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } bookMsg := &descriptor.Message{ DescriptorProto: bookDesc, } addBookReqMsg := &descriptor.Message{ DescriptorProto: addBookReqDesc, } nameField := &descriptor.Field{ Message: bookMsg, FieldDescriptorProto: bookMsg.GetField()[0], } typeField := &descriptor.Field{ Message: bookMsg, FieldDescriptorProto: bookMsg.GetField()[1], } bookMsg.Fields = []*descriptor.Field{nameField, typeField} bookField := &descriptor.Field{ Message: addBookReqMsg, FieldMessage: bookMsg, FieldDescriptorProto: addBookReqMsg.GetField()[0], } libraryIdField := &descriptor.Field{ Message: addBookReqMsg, FieldDescriptorProto: addBookReqMsg.GetField()[1], } isLatestEditionField := &descriptor.Field{ Message: addBookReqMsg, FieldDescriptorProto: addBookReqMsg.GetField()[2], } addBookReqMsg.Fields = []*descriptor.Field{bookField, libraryIdField, isLatestEditionField} file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("book.proto"), MessageType: []*descriptorpb.DescriptorProto{bookDesc, addBookReqDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{bookMsg, addBookReqMsg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: addBookReqMsg, ResponseType: bookMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/books/{book.type}", }, PathParams: []descriptor.Parameter{ { FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "book", }, { Name: "type", }, }), Target: typeField, }, }, Body: &descriptor.Body{ FieldPath: []descriptor.FieldPathComponent{}, }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() fileCL := crossLinkFixture(&file) err := reg.Load(reqFromFile(fileCL)) if err != nil { t.Errorf("reg.Load(%#v) failed with %v; want success", file, err) return } result, err := applyTemplate(param{File: fileCL, reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } paths := GetPaths(result) if got, want := len(paths), 1; got != want { t.Fatalf("Results path length differed, got %d want %d", got, want) } if got, want := paths[0], "/v1/books/{book.type}"; got != want { t.Fatalf("Wrong results path, got %s want %s", got, want) } operation := *result.getPathItemObject("/v1/books/{book.type}").Post if got, want := operation.Parameters[0].Name, "book.type"; got != want { t.Fatalf("Wrong parameter name 0, got %s want %s", got, want) } if got, want := operation.Parameters[0].In, "path"; got != want { t.Fatalf("Wrong parameter location 0, got %s want %s", got, want) } if got, want := operation.Parameters[1].Name, "body"; got != want { t.Fatalf("Wrong parameter name 1, got %s want %s", got, want) } if got, want := operation.Parameters[1].In, "body"; got != want { t.Fatalf("Wrong parameter location 1, got %s want %s", got, want) } if want, is, name := "#/definitions/BookServiceAddBookBody", operation.Parameters[1].Schema.schemaCore.Ref, "operation.Parameters[1].Schema.schemaCore.Ref"; !reflect.DeepEqual(is, want) { t.Fatalf("%s = %s want to be %s", name, want, is) } definition, found := result.Definitions["BookServiceAddBookBody"] if !found { t.Fatalf("expecting definition to contain BookServiceAddBookBody") } if want, is, name := 3, len(*definition.Properties), "len(*definition.Properties)"; !reflect.DeepEqual(is, want) { t.Fatalf("%s = %d want to be %d", name, want, is) } for index, keyValue := range []string{"book", "libraryId", "isLatestEdition"} { if got, want := (*definition.Properties)[index].Key, keyValue; got != want { t.Fatalf("Wrong definition property %d, got %s want %s", index, got, want) } } correctRequiredFields := []string{"book", "libraryId"} if got, want := definition.Required, correctRequiredFields; !reflect.DeepEqual(got, want) { t.Fatalf("Wrong required fields in body definition, got = %s, want = %s", got, want) } } func TestArrayMessageItemsType(t *testing.T) { msgDesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("children"), Label: descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.ExampleMessage"), Number: proto.Int32(1), JsonName: proto.String("children"), }, }, } nestDesc := &descriptorpb.DescriptorProto{ Name: proto.String("NestDescMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("children"), Label: descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.ExampleMessage"), Number: proto.Int32(1), JsonName: proto.String("children"), }, }, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Example"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("NestDescMessage"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } msg := &descriptor.Message{ DescriptorProto: msgDesc, } nsg := &descriptor.Message{ DescriptorProto: nestDesc, } msg.Fields = []*descriptor.Field{ { Message: msg, FieldDescriptorProto: msg.GetField()[0], }, } nsg.Fields = []*descriptor.Field{ { Message: nsg, FieldDescriptorProto: nsg.GetField()[0], }, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgDesc, nestDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg, nsg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: nsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{}), }, PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/echo", // TODO(achew22): Figure out what this should really be }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() reg.SetUseJSONNamesForFields(true) if err := AddErrorDefs(reg); err != nil { t.Errorf("AddErrorDefs(%#v) failed with %v; want success", reg, err) return } fileCL := crossLinkFixture(&file) if err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{ { SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("acme/example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgDesc, nestDesc}, Service: []*descriptorpb.ServiceDescriptorProto{}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("acme/example"), }, }, }, }); err != nil { t.Errorf("reg.Load(%#v) failed with %v; want success", reg, err) return } expect := openapiDefinitionsObject{ "rpcStatus": openapiSchemaObject{ schemaCore: schemaCore{ Type: "object", }, Properties: &openapiSchemaObjectProperties{ keyVal{ Key: "code", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "integer", Format: "int32", }, }, }, keyVal{ Key: "message", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, }, }, keyVal{ Key: "details", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "array", Items: &openapiItemsObject{ schemaCore: schemaCore{ Type: "object", Ref: "#/definitions/protobufAny", }, }, }, }, }, }, }, "exampleExampleMessage": openapiSchemaObject{ schemaCore: schemaCore{ Type: "object", }, Properties: &openapiSchemaObjectProperties{ keyVal{ Key: "children", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "array", Items: &openapiItemsObject{ schemaCore: schemaCore{ Type: "object", Ref: "#/definitions/exampleExampleMessage", }, }, }, }, }, }, }, "exampleNestDescMessage": openapiSchemaObject{ schemaCore: schemaCore{ Type: "object", }, Properties: &openapiSchemaObjectProperties{ keyVal{ Key: "children", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "array", Items: &openapiItemsObject{ schemaCore: schemaCore{ Type: "object", Ref: "#/definitions/exampleExampleMessage", }, }, }, }, }, }, }, "protobufAny": openapiSchemaObject{ schemaCore: schemaCore{ Type: "object", }, Properties: &openapiSchemaObjectProperties{ keyVal{ Key: "@type", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, }, }, }, AdditionalProperties: &openapiSchemaObject{}, }, } result, err := applyTemplate(param{File: fileCL, reg: reg}) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", reg, err) return } if want, is, name := []string{"application/json"}, result.Produces, "Produces"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } if want, is, name := expect, result.Definitions, "Produces"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %v want to be %v", file, name, is, want) } // If there was a failure, print out the input and the json result for debugging. if t.Failed() { t.Errorf("had: %s", file) t.Errorf("got: %s", fmt.Sprint(result)) } } func TestArrayMessageItemsTypeOmitWhenRefSibling(t *testing.T) { msgDesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("children"), Label: descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.ExampleMessage"), Number: proto.Int32(1), JsonName: proto.String("children"), }, }, } nestDesc := &descriptorpb.DescriptorProto{ Name: proto.String("NestDescMessage"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("children"), Label: descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.ExampleMessage"), Number: proto.Int32(1), JsonName: proto.String("children"), }, }, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Example"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("NestDescMessage"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } msg := &descriptor.Message{ DescriptorProto: msgDesc, } nsg := &descriptor.Message{ DescriptorProto: nestDesc, } msg.Fields = []*descriptor.Field{ { Message: msg, FieldDescriptorProto: msg.GetField()[0], }, } nsg.Fields = []*descriptor.Field{ { Message: nsg, FieldDescriptorProto: nsg.GetField()[0], }, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgDesc, nestDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg, nsg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: nsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{}), }, PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/echo", }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() reg.SetUseJSONNamesForFields(true) // Enable the flag to omit type when $ref is present reg.SetOmitArrayItemTypeWhenRefSibling(true) if err := AddErrorDefs(reg); err != nil { t.Errorf("AddErrorDefs(%#v) failed with %v; want success", reg, err) return } fileCL := crossLinkFixture(&file) if err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{ { SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("acme/example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgDesc, nestDesc}, Service: []*descriptorpb.ServiceDescriptorProto{}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("acme/example"), }, }, }, }); err != nil { t.Errorf("reg.Load(%#v) failed with %v; want success", reg, err) return } expect := openapiDefinitionsObject{ "rpcStatus": openapiSchemaObject{ schemaCore: schemaCore{ Type: "object", }, Properties: &openapiSchemaObjectProperties{ keyVal{ Key: "code", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "integer", Format: "int32", }, }, }, keyVal{ Key: "message", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, }, }, keyVal{ Key: "details", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "array", Items: &openapiItemsObject{ schemaCore: schemaCore{ // Type should be omitted when flag is enabled Ref: "#/definitions/protobufAny", }, }, }, }, }, }, }, "exampleExampleMessage": openapiSchemaObject{ schemaCore: schemaCore{ Type: "object", }, Properties: &openapiSchemaObjectProperties{ keyVal{ Key: "children", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "array", Items: &openapiItemsObject{ schemaCore: schemaCore{ // Type should be omitted when flag is enabled Ref: "#/definitions/exampleExampleMessage", }, }, }, }, }, }, }, "exampleNestDescMessage": openapiSchemaObject{ schemaCore: schemaCore{ Type: "object", }, Properties: &openapiSchemaObjectProperties{ keyVal{ Key: "children", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "array", Items: &openapiItemsObject{ schemaCore: schemaCore{ // Type should be omitted when flag is enabled Ref: "#/definitions/exampleExampleMessage", }, }, }, }, }, }, }, "protobufAny": openapiSchemaObject{ schemaCore: schemaCore{ Type: "object", }, Properties: &openapiSchemaObjectProperties{ keyVal{ Key: "@type", Value: openapiSchemaObject{ schemaCore: schemaCore{ Type: "string", }, }, }, }, AdditionalProperties: &openapiSchemaObject{}, }, } result, err := applyTemplate(param{File: fileCL, reg: reg}) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", reg, err) return } if want, is, name := []string{"application/json"}, result.Produces, "Produces"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } if want, is, name := expect, result.Definitions, "Produces"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %v want to be %v", file, name, is, want) } // If there was a failure, print out the input and the json result for debugging. if t.Failed() { t.Errorf("had: %s", file) t.Errorf("got: %s", fmt.Sprint(result)) } } func TestQueryParameterType(t *testing.T) { ntDesc := &descriptorpb.DescriptorProto{ Name: proto.String("AddressEntry"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("key"), Number: proto.Int32(1), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), JsonName: proto.String("key"), }, { Name: proto.String("value"), Number: proto.Int32(2), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_INT32.Enum(), JsonName: proto.String("value"), }, }, Options: &descriptorpb.MessageOptions{ MapEntry: proto.Bool(true), }, } msgDesc := &descriptorpb.DescriptorProto{ Name: proto.String("Person"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("Address"), Number: proto.Int32(1), Label: descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".example.com.Person.AddressEntry"), JsonName: proto.String("Address"), }, }, NestedType: []*descriptorpb.DescriptorProto{ ntDesc, }, } nesteDesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleResponse"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("Key"), Number: proto.Int32(1), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), JsonName: proto.String("Key"), }, { Name: proto.String("Value"), Number: proto.Int32(2), Label: descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(), Type: descriptorpb.FieldDescriptorProto_TYPE_INT32.Enum(), JsonName: proto.String("Value"), }, }, } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Example"), InputType: proto.String("Person"), OutputType: proto.String("ExampleResponse"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } msg := &descriptor.Message{ DescriptorProto: msgDesc, } nt := &descriptor.Message{ DescriptorProto: ntDesc, } nest := &descriptor.Message{ DescriptorProto: nesteDesc, } msg.Fields = []*descriptor.Field{ { Message: msg, FieldDescriptorProto: msg.GetField()[0], }, } nt.Fields = []*descriptor.Field{ { Message: nt, FieldDescriptorProto: msg.GetField()[0], }, } nest.Fields = []*descriptor.Field{ { Message: nest, FieldDescriptorProto: nest.GetField()[0], }, { Message: nest, FieldDescriptorProto: nest.GetField()[1], }, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("person.proto"), Package: proto.String("example.com"), MessageType: []*descriptorpb.DescriptorProto{msgDesc, nesteDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg, nest}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: nest, Bindings: []*descriptor.Binding{ { HTTPMethod: "GET", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/echo", }, }, }, }, }, }, }, } expect := openapiPathsObject{{ Path: "/v1/echo", PathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Parameters: openapiParametersObject{ { Name: "Address[string]", In: "query", Type: "integer", }, }, }, }, }} reg := descriptor.NewRegistry() reg.SetUseJSONNamesForFields(false) if err := AddErrorDefs(reg); err != nil { t.Errorf("AddErrorDefs(%#v) failed with %v; want success", reg, err) return } fileCL := crossLinkFixture(&file) err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{ { Name: proto.String("person.proto"), Package: proto.String("example.com"), SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, MessageType: []*descriptorpb.DescriptorProto{msgDesc, nesteDesc}, Service: []*descriptorpb.ServiceDescriptorProto{}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("person.proto"), }, }, }, }) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } result, err := applyTemplate(param{File: fileCL, reg: reg}) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } if want, is, name := []string{"application/json"}, result.Produces, "Produces"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, is, want) } if want, is, name := expect[0].PathItemObject.Get.Parameters, result.getPathItemObject("/v1/echo").Get.Parameters, "Produces"; !reflect.DeepEqual(is, want) { t.Errorf("applyTemplate(%#v).%s = %v want to be %v", file, name, is, want) } // If there was a failure, print out the input and the json result for debugging. if t.Failed() { t.Errorf("had: %s", file) t.Errorf("got: %s", fmt.Sprint(result)) } } func TestApplyTemplateRequestWithServerStreamingHttpBody(t *testing.T) { meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Echo"), InputType: proto.String(".google.api.HttpBody"), OutputType: proto.String(".google.api.HttpBody"), ClientStreaming: proto.Bool(false), ServerStreaming: proto.Bool(true), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } httpBodyFile, err := protoregistry.GlobalFiles.FindFileByPath("google/api/httpbody.proto") if err != nil { t.Fatal(err) } httpBodyFile.SourceLocations() desc, err := protoregistry.GlobalFiles.FindDescriptorByName("google.api.HttpBody") if err != nil { t.Fatal(err) } msg := &descriptor.Message{ DescriptorProto: protodesc.ToDescriptorProto(desc.(protoreflect.MessageDescriptor)), File: &descriptor.File{ FileDescriptorProto: protodesc.ToFileDescriptorProto(httpBodyFile), }, } anyFile, err := protoregistry.GlobalFiles.FindFileByPath("google/protobuf/any.proto") if err != nil { t.Fatal(err) } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), Dependency: []string{ "google/api/httpbody.proto", }, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "POST", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/echo", }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() if err := AddErrorDefs(reg); err != nil { t.Errorf("AddErrorDefs(%#v) failed with %v; want success", reg, err) return } err = reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{ protodesc.ToFileDescriptorProto(anyFile), protodesc.ToFileDescriptorProto(httpBodyFile), file.FileDescriptorProto, }, }) if err != nil { t.Fatalf("failed to load code generator request: %v", err) } result, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Errorf("applyTemplate(%#v) failed with %v; want success", file, err) return } if want, got, name := 3, len(result.Definitions), "len(Definitions)"; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %d want to be %d", file, name, got, want) } if _, ok := result.getPathItemObject("/v1/echo").Post.Responses["200"]; !ok { t.Errorf("applyTemplate(%#v).%s = expected 200 response to be defined", file, `result.getPathItemObject("/v1/echo").Post.Responses["200"]`) } else { if want, got, name := "A successful response.(streaming responses)", result.getPathItemObject("/v1/echo").Post.Responses["200"].Description, `result.getPathItemObject("/v1/echo").Post.Responses["200"].Description`; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, got, want) } streamExampleExampleMessage := result.getPathItemObject("/v1/echo").Post.Responses["200"].Schema if want, got, name := "string", streamExampleExampleMessage.Type, `result.getPathItemObject("/v1/echo").Post.Responses["200"].Schema.Type`; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, got, want) } if want, got, name := "binary", streamExampleExampleMessage.Format, `result.getPathItemObject("/v1/echo").Post.Responses["200"].Schema.Format`; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, got, want) } if want, got, name := "Free form byte stream", streamExampleExampleMessage.Title, `result.getPathItemObject("/v1/echo").Post.Responses["200"].Schema.Title`; !reflect.DeepEqual(got, want) { t.Errorf("applyTemplate(%#v).%s = %s want to be %s", file, name, got, want) } if len(*streamExampleExampleMessage.Properties) != 0 { t.Errorf("applyTemplate(%#v).Properties should be empty", file) } } // If there was a failure, print out the input and the json result for debugging. if t.Failed() { t.Errorf("had: %s", file) t.Errorf("got: %s", fmt.Sprint(result)) } } // Returns the openapiPathItemObject associated with a path. func (so openapiSwaggerObject) getPathItemObject(path string) openapiPathItemObject { for _, pathData := range so.Paths { if pathData.Path == path { return pathData.PathItemObject } } return openapiPathItemObject{} } func TestGetPathItemObjectSwaggerObjectMethod(t *testing.T) { testCases := [...]struct { testName string swaggerObject openapiSwaggerObject path string expectedPathItemObject openapiPathItemObject }{ { testName: "Path present in swagger object", swaggerObject: openapiSwaggerObject{Paths: openapiPathsObject{{ Path: "a/path", PathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Description: "A testful description", }, }, }}}, path: "a/path", expectedPathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Description: "A testful description", }, }, }, { testName: "Path not present in swaggerObject", swaggerObject: openapiSwaggerObject{Paths: openapiPathsObject{{ Path: "a/path", PathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Description: "A testful description", }, }, }}}, path: "b/path", expectedPathItemObject: openapiPathItemObject{}, }, { testName: "Path present in swaggerPathsObject with multiple paths", swaggerObject: openapiSwaggerObject{Paths: openapiPathsObject{{ Path: "a/path", PathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Description: "A testful description", }, }, }, { Path: "another/path", PathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Description: "Another testful description", }, }, }}}, path: "another/path", expectedPathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Description: "Another testful description", }, }, }, { testName: "Path not present in swaggerObject with no paths", swaggerObject: openapiSwaggerObject{}, path: "b/path", expectedPathItemObject: openapiPathItemObject{}, }, } for _, tc := range testCases { tc := tc t.Run(tc.testName, func(t *testing.T) { actualPathItemObject := tc.swaggerObject.getPathItemObject(tc.path) if isEqual := reflect.DeepEqual(actualPathItemObject, tc.expectedPathItemObject); !isEqual { t.Fatalf("Got pathItemObject: %#v, want pathItemObject: %#v", actualPathItemObject, tc.expectedPathItemObject) } }) } } func TestGetPathItemObjectFunction(t *testing.T) { testCases := [...]struct { testName string paths openapiPathsObject path string expectedPathItemObject openapiPathItemObject expectedIsPathPresent bool }{ { testName: "Path present in openapiPathsObject", paths: openapiPathsObject{{ Path: "a/path", PathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Description: "A testful description", }, }, }}, path: "a/path", expectedPathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Description: "A testful description", }, }, expectedIsPathPresent: true, }, { testName: "Path not present in openapiPathsObject", paths: openapiPathsObject{{ Path: "a/path", PathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Description: "A testful description", }, }, }}, path: "b/path", expectedPathItemObject: openapiPathItemObject{}, expectedIsPathPresent: false, }, { testName: "Path present in openapiPathsObject with multiple paths", paths: openapiPathsObject{{ Path: "a/path", PathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Description: "A testful description", }, }, }, { Path: "another/path", PathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Description: "Another testful description", }, }, }}, path: "another/path", expectedPathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Description: "Another testful description", }, }, expectedIsPathPresent: true, }, { testName: "Path not present in empty openapiPathsObject", paths: openapiPathsObject{}, path: "b/path", expectedPathItemObject: openapiPathItemObject{}, expectedIsPathPresent: false, }, } for _, tc := range testCases { tc := tc t.Run(tc.testName, func(t *testing.T) { actualPathItemObject, actualIsPathPresent := getPathItemObject(tc.paths, tc.path) if isEqual := reflect.DeepEqual(actualPathItemObject, tc.expectedPathItemObject); !isEqual { t.Fatalf("Got pathItemObject: %#v, want pathItemObject: %#v", actualPathItemObject, tc.expectedPathItemObject) } if actualIsPathPresent != tc.expectedIsPathPresent { t.Fatalf("Got isPathPresent bool: %t, want isPathPresent bool: %t", actualIsPathPresent, tc.expectedIsPathPresent) } }) } } func TestUpdatePaths(t *testing.T) { testCases := [...]struct { testName string paths openapiPathsObject pathToUpdate string newPathItemObject openapiPathItemObject expectedUpdatedPaths openapiPathsObject }{ { testName: "Path present in openapiPathsObject, pathItemObject updated.", paths: openapiPathsObject{{ Path: "a/path", PathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Description: "A testful description", }, }, }}, pathToUpdate: "a/path", newPathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Description: "A newly updated testful description", }, }, expectedUpdatedPaths: openapiPathsObject{{ Path: "a/path", PathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Description: "A newly updated testful description", }, }, }}, }, { testName: "Path not present in openapiPathsObject, new path data appended.", paths: openapiPathsObject{{ Path: "c/path", PathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Description: "A testful description", }, }, }}, pathToUpdate: "b/path", newPathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Description: "A new testful description to add", }, }, expectedUpdatedPaths: openapiPathsObject{{ Path: "c/path", PathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Description: "A testful description", }, }, }, { Path: "b/path", PathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Description: "A new testful description to add", }, }, }}, }, { testName: "No paths present in openapiPathsObject, new path data appended.", paths: openapiPathsObject{}, pathToUpdate: "b/path", newPathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Description: "A new testful description to add", }, }, expectedUpdatedPaths: openapiPathsObject{{ Path: "b/path", PathItemObject: openapiPathItemObject{ Get: &openapiOperationObject{ Description: "A new testful description to add", }, }, }}, }, } for _, tc := range testCases { tc := tc t.Run(tc.testName, func(t *testing.T) { updatePaths(&tc.paths, tc.pathToUpdate, tc.newPathItemObject) if pathsCorrectlyUpdated := reflect.DeepEqual(tc.paths, tc.expectedUpdatedPaths); !pathsCorrectlyUpdated { t.Fatalf("Paths not correctly updated. Want %#v, got %#v", tc.expectedUpdatedPaths, tc.paths) } }) } } // Test that enum values have internal comments removed func TestEnumValueProtoComments(t *testing.T) { reg := descriptor.NewRegistry() name := "kind" comments := "(-- this is a comment --)" enum := &descriptor.Enum{ EnumDescriptorProto: &descriptorpb.EnumDescriptorProto{ Name: &name, }, File: &descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ Name: new(string), Package: new(string), SourceCodeInfo: &descriptorpb.SourceCodeInfo{ Location: []*descriptorpb.SourceCodeInfo_Location{ { LeadingComments: &comments, }, }, }, }, }, } comments = enumValueProtoComments(reg, enum) if comments != "" { t.Errorf("expected '', got '%v'", comments) } } func MustMarshal(v interface{}) []byte { b, err := json.Marshal(v) if err != nil { panic(err) } return b } func TestMergeTags(t *testing.T) { testCases := [...]struct { testName string existingTags []openapiTagObject newTags []openapiTagObject expectedMergedTags []openapiTagObject }{ { testName: "Simple merge.", existingTags: []openapiTagObject{{ Name: "tag1", Description: "tag1 description", }}, newTags: []openapiTagObject{{ Name: "tag2", Description: "tag2 description", }}, expectedMergedTags: []openapiTagObject{{ Name: "tag1", Description: "tag1 description", }, { Name: "tag2", Description: "tag2 description", }}, }, { testName: "Merge description", existingTags: []openapiTagObject{{ Name: "tag1", Description: "tag1 description", }, { Name: "tag2", }, { Name: "tag3", Description: "tag3 description", }}, newTags: []openapiTagObject{{ Name: "tag2", Description: "tag2 description", }}, expectedMergedTags: []openapiTagObject{{ Name: "tag1", Description: "tag1 description", }, { Name: "tag2", Description: "tag2 description", }, { Name: "tag3", Description: "tag3 description", }}, }, { testName: "Merge external docs", existingTags: []openapiTagObject{{ Name: "tag1", ExternalDocs: &openapiExternalDocumentationObject{}, }, { Name: "tag2", }, { Name: "tag3", ExternalDocs: &openapiExternalDocumentationObject{ Description: "tag3 description", }, }, { Name: "tag4", ExternalDocs: &openapiExternalDocumentationObject{ URL: "tag4 url", }, }}, newTags: []openapiTagObject{{ Name: "tag1", ExternalDocs: &openapiExternalDocumentationObject{ Description: "tag1 description", }, }, { Name: "tag2", ExternalDocs: &openapiExternalDocumentationObject{ Description: "tag2 description", URL: "tag2 url", }, }, { Name: "tag3", ExternalDocs: &openapiExternalDocumentationObject{ Description: "ignored tag3 description", URL: "tag3 url", }, }, { Name: "tag4", ExternalDocs: &openapiExternalDocumentationObject{ Description: "tag4 description", }, }}, expectedMergedTags: []openapiTagObject{{ Name: "tag1", ExternalDocs: &openapiExternalDocumentationObject{ Description: "tag1 description", }, }, { Name: "tag2", ExternalDocs: &openapiExternalDocumentationObject{ Description: "tag2 description", URL: "tag2 url", }, }, { Name: "tag3", ExternalDocs: &openapiExternalDocumentationObject{ Description: "tag3 description", URL: "tag3 url", }, }, { Name: "tag4", ExternalDocs: &openapiExternalDocumentationObject{ Description: "tag4 description", URL: "tag4 url", }, }}, }, { testName: "Merge extensions", existingTags: []openapiTagObject{{ Name: "tag1", extensions: []extension{{key: "x-key1", value: MustMarshal("key1 extension")}}, }, { Name: "tag2", extensions: []extension{ {key: "x-key1", value: MustMarshal("key1 extension")}, {key: "x-key2", value: MustMarshal("key2 extension")}, }, }, { Name: "tag3", extensions: []extension{ {key: "x-key1", value: MustMarshal("key1 extension")}, }, }, { Name: "tag4", extensions: nil, }}, newTags: []openapiTagObject{{ Name: "tag1", extensions: []extension{{key: "x-key2", value: MustMarshal("key2 extension")}}, }, { Name: "tag2", extensions: []extension{ {key: "x-key1", value: MustMarshal("key1 extension")}, {key: "x-key2", value: MustMarshal("ignored key2 extension")}, {key: "x-key3", value: MustMarshal("key3 extension")}, }, }, { Name: "tag3", extensions: nil, }, { Name: "tag4", extensions: []extension{ {key: "x-key1", value: MustMarshal("key1 extension")}, }, }}, expectedMergedTags: []openapiTagObject{{ Name: "tag1", extensions: []extension{ {key: "x-key1", value: MustMarshal("key1 extension")}, {key: "x-key2", value: MustMarshal("key2 extension")}, }, }, { Name: "tag2", extensions: []extension{ {key: "x-key1", value: MustMarshal("key1 extension")}, {key: "x-key2", value: MustMarshal("key2 extension")}, {key: "x-key3", value: MustMarshal("key3 extension")}, }, }, { Name: "tag3", extensions: []extension{ {key: "x-key1", value: MustMarshal("key1 extension")}, }, }, { Name: "tag4", extensions: []extension{ {key: "x-key1", value: MustMarshal("key1 extension")}, }, }}, }, } for _, tc := range testCases { tc := tc t.Run(tc.testName, func(t *testing.T) { mergedTags := mergeTags(tc.existingTags, tc.newTags) if !reflect.DeepEqual(tc.expectedMergedTags, mergedTags) { t.Fatalf("%s: Tags not correctly merged. Want %#v, got %#v", tc.testName, tc.expectedMergedTags, mergedTags) } }) } } func TestApiVisibilityOption(t *testing.T) { reg := descriptor.NewRegistry() msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), } msg := &descriptor.Message{ DescriptorProto: msgdesc, } methodExample := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Example"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), } serviceOptions := &descriptorpb.ServiceOptions{} proto.SetExtension(serviceOptions, visibility.E_ApiVisibility, &visibility.VisibilityRule{ Restriction: "INTERNAL", }) svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Options: serviceOptions, Method: []*descriptorpb.MethodDescriptorProto{methodExample}, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgdesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: methodExample, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "GET", Body: &descriptor.Body{FieldPath: nil}, PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/example", }, }, }, }, }, }, }, } err := reg.Load(&pluginpb.CodeGeneratorRequest{ ProtoFile: []*descriptorpb.FileDescriptorProto{file.FileDescriptorProto}, }) if err != nil { t.Errorf("failed to reg.Load(req): %v", err) } actual, err := applyTemplate(param{File: crossLinkFixture(&file), reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } if len(actual.Definitions) != 0 { t.Fatal("Definition should be excluded by api visibility option") } } func TestRenderServicesOptionDeprecated(t *testing.T) { testCases := [...]struct { testName string methodOptions descriptorpb.MethodOptions openapiOperation *openapi_options.Operation expectedDeprecated bool }{ { testName: "method option", methodOptions: descriptorpb.MethodOptions{ Deprecated: proto.Bool(true), }, expectedDeprecated: true, }, { testName: "openapi option", openapiOperation: &openapi_options.Operation{ Deprecated: true, }, expectedDeprecated: true, }, { testName: "empty openapi doesn't override method option", methodOptions: descriptorpb.MethodOptions{ Deprecated: proto.Bool(true), }, openapiOperation: &openapi_options.Operation{}, expectedDeprecated: true, }, } for _, tc := range testCases { tc := tc t.Run(tc.testName, func(t *testing.T) { msgdesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleMessage"), } meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("Example"), InputType: proto.String("ExampleMessage"), OutputType: proto.String("ExampleMessage"), Options: &tc.methodOptions, } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } msg := &descriptor.Message{ DescriptorProto: msgdesc, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{msgdesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{msg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: msg, ResponseType: msg, Bindings: []*descriptor.Binding{ { HTTPMethod: "GET", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/v1/echo", }, }, }, }, }, }, }, } if tc.openapiOperation != nil { proto.SetExtension( proto.Message(file.Services[0].Methods[0].Options), openapi_options.E_Openapiv2Operation, tc.openapiOperation, ) } reg := descriptor.NewRegistry() reg.SetEnableRpcDeprecation(true) fileCL := crossLinkFixture(&file) if err := reg.Load(reqFromFile(fileCL)); err != nil { t.Errorf("reg.Load(%#v) failed with %v; want success", file, err) } result, err := applyTemplate(param{File: fileCL, reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } got := result.getPathItemObject("/v1/echo").Get.Deprecated if got != tc.expectedDeprecated { t.Fatalf("Wrong deprecated field, got %v want %v", got, tc.expectedDeprecated) } }) } } func TestRenderServicesMarksDeprecatedParameters(t *testing.T) { cases := []struct { name string fieldDeprecated bool enableFieldDeprecation bool fieldConfigDeprecated bool expectedDeprecated bool }{ { name: "proto field deprecated but feature disabled", fieldDeprecated: true, enableFieldDeprecation: false, expectedDeprecated: false, }, { name: "proto field deprecated with feature enabled", fieldDeprecated: true, enableFieldDeprecation: true, expectedDeprecated: true, }, { name: "field config annotation deprecated", fieldConfigDeprecated: true, expectedDeprecated: true, }, { name: "non-deprecated field", expectedDeprecated: false, }, } for _, tc := range cases { tc := tc t.Run(tc.name, func(t *testing.T) { var fieldOptions *descriptorpb.FieldOptions if tc.fieldDeprecated || tc.fieldConfigDeprecated { fieldOptions = &descriptorpb.FieldOptions{} if tc.fieldDeprecated { fieldOptions.Deprecated = proto.Bool(true) } if tc.fieldConfigDeprecated { proto.SetExtension(fieldOptions, openapi_options.E_Openapiv2Field, &openapi_options.JSONSchema{ FieldConfiguration: &openapi_options.JSONSchema_FieldConfiguration{ Deprecated: true, }, }) } } fieldDesc := &descriptorpb.FieldDescriptorProto{ Name: proto.String("name"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), Options: fieldOptions, JsonName: proto.String("name"), } reqMsgDesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleRequest"), Field: []*descriptorpb.FieldDescriptorProto{fieldDesc}, } respMsgDesc := &descriptorpb.DescriptorProto{ Name: proto.String("ExampleResponse"), } reqMsg := &descriptor.Message{ DescriptorProto: reqMsgDesc, } respMsg := &descriptor.Message{ DescriptorProto: respMsgDesc, } field := &descriptor.Field{ FieldDescriptorProto: fieldDesc, Message: reqMsg, } reqMsg.Fields = []*descriptor.Field{field} method := &descriptorpb.MethodDescriptorProto{ Name: proto.String("GetExample"), InputType: proto.String(".example.ExampleRequest"), OutputType: proto.String(".example.ExampleResponse"), } compiler, err := httprule.Parse("/v1/{name}") if err != nil { t.Fatalf("failed to parse path template: %v", err) } pathTemplate := compiler.Compile() binding := &descriptor.Binding{ HTTPMethod: "GET", PathTmpl: pathTemplate, PathParams: []descriptor.Parameter{ { Target: field, FieldPath: descriptor.FieldPath{ { Name: "name", Target: field, }, }, }, }, } methodDesc := &descriptor.Method{ MethodDescriptorProto: method, RequestType: reqMsg, ResponseType: respMsg, Bindings: []*descriptor.Binding{binding}, } service := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("ExampleService"), Method: []*descriptorpb.MethodDescriptorProto{method}, } serviceDesc := &descriptor.Service{ ServiceDescriptorProto: service, Methods: []*descriptor.Method{methodDesc}, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("example.proto"), Package: proto.String("example"), MessageType: []*descriptorpb.DescriptorProto{reqMsgDesc, respMsgDesc}, Service: []*descriptorpb.ServiceDescriptorProto{service}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/grpc-ecosystem/grpc-gateway/runtime/internal/examplepb;example"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/example/example.pb", Name: "example_pb", }, Messages: []*descriptor.Message{reqMsg, respMsg}, Services: []*descriptor.Service{serviceDesc}, } reg := descriptor.NewRegistry() reg.SetEnableFieldDeprecation(tc.enableFieldDeprecation) fileCL := crossLinkFixture(&file) if err := reg.Load(reqFromFile(fileCL)); err != nil { t.Fatalf("failed to load code generator request: %v", err) } result, err := applyTemplate(param{File: fileCL, reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } operation := result.getPathItemObject("/v1/{name}").Get if operation == nil { t.Fatalf("expected GET operation to be generated for /v1/{name}") } found := false for _, param := range operation.Parameters { if param.In == "path" && param.Name == "name" { found = true if param.Deprecated != tc.expectedDeprecated { t.Fatalf("expected deprecated flag to be %v, got %v", tc.expectedDeprecated, param.Deprecated) } } } if !found { t.Fatalf("expected to find path parameter named 'name'") } }) } } func Test_updateSwaggerObjectFromFieldBehavior(t *testing.T) { type args struct { s *openapiSchemaObject j []annotations.FieldBehavior reg *descriptor.Registry field *descriptor.Field } regWithNoProto3FieldSemantics := &descriptor.Registry{} regWithProto3FieldSemantics := &descriptor.Registry{} regWithProto3FieldSemantics.SetUseProto3FieldSemantics(true) proto3Field := &descriptor.Field{FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("name"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }} boolTrue := true proto3FieldOptional := &descriptor.Field{FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("name"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), Proto3Optional: &boolTrue, }} oneofIndex := int32(0) proto3FieldOneof := &descriptor.Field{FieldDescriptorProto: &descriptorpb.FieldDescriptorProto{ Name: proto.String("name"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), OneofIndex: &oneofIndex, }} tests := []struct { name string args args required []string }{ { name: "FieldBehavior_REQUIRED", args: args{ s: &openapiSchemaObject{}, j: []annotations.FieldBehavior{ annotations.FieldBehavior_REQUIRED, }, reg: regWithNoProto3FieldSemantics, field: proto3FieldOptional, }, required: []string{"name"}, }, { name: "No Required No Proto3 Optional", args: args{ s: &openapiSchemaObject{}, j: []annotations.FieldBehavior{}, reg: regWithNoProto3FieldSemantics, field: proto3FieldOptional, }, required: nil, }, { name: "No Required Has Proto3 Optional", args: args{ s: &openapiSchemaObject{}, j: []annotations.FieldBehavior{}, reg: regWithProto3FieldSemantics, field: proto3FieldOptional, }, required: nil, }, { name: "No Required Has Proto3 Required", args: args{ s: &openapiSchemaObject{}, j: []annotations.FieldBehavior{}, reg: regWithProto3FieldSemantics, field: proto3Field, }, required: []string{"name"}, }, { name: "Oneof field not required with proto3 field semantics", args: args{ s: &openapiSchemaObject{}, j: []annotations.FieldBehavior{}, reg: regWithProto3FieldSemantics, field: proto3FieldOneof, }, required: nil, }, { name: "Oneof field not required without proto3 field semantics", args: args{ s: &openapiSchemaObject{}, j: []annotations.FieldBehavior{}, reg: regWithNoProto3FieldSemantics, field: proto3FieldOneof, }, required: nil, }, { name: "Oneof field required when explicitly annotated REQUIRED", args: args{ s: &openapiSchemaObject{}, j: []annotations.FieldBehavior{ annotations.FieldBehavior_REQUIRED, }, reg: regWithProto3FieldSemantics, field: proto3FieldOneof, }, required: []string{"name"}, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { updateSwaggerObjectFromFieldBehavior(tt.args.s, tt.args.j, tt.args.reg, tt.args.field) if !reflect.DeepEqual(tt.args.s.Required, tt.required) { t.Errorf("updateSwaggerObjectFromFieldBehavior() = %v, want %v", tt.args.s.Required, tt.required) } }) } } // TestBodyParameterRequiredFieldBug tests the bug where the body parameter name // is incorrectly added to the schema's required array when using body: "field_name" func TestBodyParameterRequiredFieldBug(t *testing.T) { fieldBehaviorRequired := []annotations.FieldBehavior{annotations.FieldBehavior_REQUIRED} requiredFieldOptions := new(descriptorpb.FieldOptions) proto.SetExtension(requiredFieldOptions, annotations.E_FieldBehavior, fieldBehaviorRequired) // Define the Comment message with REQUIRED fields including one named "comment" commentDesc := &descriptorpb.DescriptorProto{ Name: proto.String("Comment"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("name"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("comment"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), Options: requiredFieldOptions, // comment field is REQUIRED }, { Name: proto.String("resource"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(3), Options: requiredFieldOptions, // resource is REQUIRED }, { Name: proto.String("author"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(4), Options: requiredFieldOptions, // author is REQUIRED }, }, } // Define the UpdateCommentRequest message updateCommentReqDesc := &descriptorpb.DescriptorProto{ Name: proto.String("UpdateCommentRequest"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("comment"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".test.Comment"), Number: proto.Int32(1), Options: requiredFieldOptions, // comment field is REQUIRED }, }, } commentMsg := &descriptor.Message{ DescriptorProto: commentDesc, } updateCommentReqMsg := &descriptor.Message{ DescriptorProto: updateCommentReqDesc, } nameField := &descriptor.Field{ Message: commentMsg, FieldDescriptorProto: commentMsg.GetField()[0], } commentField := &descriptor.Field{ Message: commentMsg, FieldDescriptorProto: commentMsg.GetField()[1], } resourceField := &descriptor.Field{ Message: commentMsg, FieldDescriptorProto: commentMsg.GetField()[2], } authorField := &descriptor.Field{ Message: commentMsg, FieldDescriptorProto: commentMsg.GetField()[3], } commentMsg.Fields = []*descriptor.Field{nameField, commentField, resourceField, authorField} commentReqField := &descriptor.Field{ Message: updateCommentReqMsg, FieldMessage: commentMsg, FieldDescriptorProto: updateCommentReqMsg.GetField()[0], } updateCommentReqMsg.Fields = []*descriptor.Field{commentReqField} meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("UpdateComment"), InputType: proto.String("UpdateCommentRequest"), OutputType: proto.String("Comment"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("CommentService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("comment.proto"), Package: proto.String("test"), MessageType: []*descriptorpb.DescriptorProto{commentDesc, updateCommentReqDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/example/test;test"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/test/test.pb", Name: "test_pb", }, Messages: []*descriptor.Message{commentMsg, updateCommentReqMsg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: updateCommentReqMsg, ResponseType: commentMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "PATCH", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/api/v1/{comment.name}", }, PathParams: []descriptor.Parameter{ { FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "comment", }, { Name: "name", }, }), Target: nameField, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "comment", Target: commentReqField, }, }), }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() fileCL := crossLinkFixture(&file) err := reg.Load(reqFromFile(fileCL)) if err != nil { t.Errorf("reg.Load(%#v) failed with %v; want success", file, err) return } result, err := applyTemplate(param{File: fileCL, reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } paths := GetPaths(result) if got, want := len(paths), 1; got != want { t.Fatalf("Results path length differed, got %d want %d", got, want) } if got, want := paths[0], "/api/v1/{comment.name}"; got != want { t.Fatalf("Wrong results path, got %s want %s", got, want) } operation := *result.getPathItemObject("/api/v1/{comment.name}").Patch if len(operation.Parameters) < 2 { t.Fatalf("Expected at least 2 parameters, got %d", len(operation.Parameters)) } // Find the body parameter var bodyParam *openapiParameterObject for i := range operation.Parameters { if operation.Parameters[i].In == "body" { bodyParam = &operation.Parameters[i] break } } if bodyParam == nil { t.Fatal("Body parameter not found") } if bodyParam.Name != "comment" { t.Fatalf("Wrong body parameter name, got %s want comment", bodyParam.Name) } if bodyParam.Schema == nil { t.Fatal("Body parameter schema is nil") } // Check the required array // Expected: ["comment", "resource", "author"] (each appears once) // Bug: ["comment", "resource", "author", "comment"] (comment appears twice) expectedRequired := []string{"comment", "resource", "author"} // Check for duplicates seen := make(map[string]int) for _, req := range bodyParam.Schema.Required { seen[req]++ } var duplicates []string for field, count := range seen { if count > 1 { duplicates = append(duplicates, field) } } if len(duplicates) > 0 { t.Errorf("BUG REPRODUCED: Duplicate entries in required array: %v", duplicates) t.Errorf("Full required array: %v", bodyParam.Schema.Required) } // Also check that we don't have extra fields that aren't properties if bodyParam.Schema.Properties != nil { propertyNames := make(map[string]bool) for _, prop := range *bodyParam.Schema.Properties { propertyNames[prop.Key] = true } var invalidRequired []string for _, req := range bodyParam.Schema.Required { if !propertyNames[req] { invalidRequired = append(invalidRequired, req) } } if len(invalidRequired) > 0 { t.Errorf("BUG: Required array contains fields that are not properties: %v", invalidRequired) } } // Verify the required array matches expectations (no duplicates, all valid) requiredUnique := make([]string, 0, len(bodyParam.Schema.Required)) seenMap := make(map[string]bool) for _, req := range bodyParam.Schema.Required { if !seenMap[req] { seenMap[req] = true requiredUnique = append(requiredUnique, req) } } if !reflect.DeepEqual(requiredUnique, expectedRequired) { t.Errorf("Required array (after deduplication) doesn't match expected:\n"+ " got = %v\n"+ " want = %v\n"+ " diff = %s", requiredUnique, expectedRequired, cmp.Diff(expectedRequired, requiredUnique)) } } // TestNestedRequiredFieldsNotHoisted tests the bug where nested required fields // are incorrectly hoisted to the parent body schema's required array when path // parameters reference nested fields func TestNestedRequiredFieldsNotHoisted(t *testing.T) { fieldBehaviorRequired := []annotations.FieldBehavior{annotations.FieldBehavior_REQUIRED} requiredFieldOptions := new(descriptorpb.FieldOptions) proto.SetExtension(requiredFieldOptions, annotations.E_FieldBehavior, fieldBehaviorRequired) // Define the nested message (Foo) with REQUIRED fields fooDesc := &descriptorpb.DescriptorProto{ Name: proto.String("Foo"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("name"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), Options: requiredFieldOptions, // name is REQUIRED }, { Name: proto.String("value"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), Options: requiredFieldOptions, // value is REQUIRED }, }, } // Define the request message (UpdateFooRequest) updateFooReqDesc := &descriptorpb.DescriptorProto{ Name: proto.String("UpdateFooRequest"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("thing"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".test.Foo"), Number: proto.Int32(1), Options: requiredFieldOptions, // thing is REQUIRED }, { Name: proto.String("update_mask"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), // Simplified - normally FieldMask Number: proto.Int32(2), }, }, } fooMsg := &descriptor.Message{ DescriptorProto: fooDesc, } updateFooReqMsg := &descriptor.Message{ DescriptorProto: updateFooReqDesc, } nameField := &descriptor.Field{ Message: fooMsg, FieldDescriptorProto: fooMsg.GetField()[0], } valueField := &descriptor.Field{ Message: fooMsg, FieldDescriptorProto: fooMsg.GetField()[1], } fooMsg.Fields = []*descriptor.Field{nameField, valueField} thingField := &descriptor.Field{ Message: updateFooReqMsg, FieldMessage: fooMsg, FieldDescriptorProto: updateFooReqMsg.GetField()[0], } updateMaskField := &descriptor.Field{ Message: updateFooReqMsg, FieldDescriptorProto: updateFooReqMsg.GetField()[1], } updateFooReqMsg.Fields = []*descriptor.Field{thingField, updateMaskField} meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("UpdateFoo"), InputType: proto.String("UpdateFooRequest"), OutputType: proto.String("Foo"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("FooService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("foo.proto"), Package: proto.String("test"), MessageType: []*descriptorpb.DescriptorProto{fooDesc, updateFooReqDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/example/test;test"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/test/test.pb", Name: "test_pb", }, Messages: []*descriptor.Message{fooMsg, updateFooReqMsg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: updateFooReqMsg, ResponseType: fooMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "PATCH", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/api/v1/{thing.name}", }, PathParams: []descriptor.Parameter{ { FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "thing", }, { Name: "name", }, }), Target: nameField, }, }, Body: &descriptor.Body{ FieldPath: []descriptor.FieldPathComponent{}, // body: "*" }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() fileCL := crossLinkFixture(&file) err := reg.Load(reqFromFile(fileCL)) if err != nil { t.Errorf("reg.Load(%#v) failed with %v; want success", file, err) return } result, err := applyTemplate(param{File: fileCL, reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } paths := GetPaths(result) if got, want := len(paths), 1; got != want { t.Fatalf("Results path length differed, got %d want %d", got, want) } if got, want := paths[0], "/api/v1/{thing.name}"; got != want { t.Fatalf("Wrong results path, got %s want %s", got, want) } operation := *result.getPathItemObject("/api/v1/{thing.name}").Patch if len(operation.Parameters) < 2 { t.Fatalf("Expected at least 2 parameters, got %d", len(operation.Parameters)) } if got, want := operation.Parameters[0].Name, "thing.name"; got != want { t.Fatalf("Wrong parameter name 0, got %s want %s", got, want) } if got, want := operation.Parameters[0].In, "path"; got != want { t.Fatalf("Wrong parameter location 0, got %s want %s", got, want) } if got, want := operation.Parameters[1].Name, "body"; got != want { t.Fatalf("Wrong parameter name 1, got %s want %s", got, want) } if got, want := operation.Parameters[1].In, "body"; got != want { t.Fatalf("Wrong parameter location 1, got %s want %s", got, want) } bodySchemaRef := operation.Parameters[1].Schema.schemaCore.Ref if bodySchemaRef == "" { t.Fatal("Body schema reference is empty") } defName := strings.TrimPrefix(bodySchemaRef, "#/definitions/") definition, found := result.Definitions[defName] if !found { t.Fatalf("expecting definition to contain %s", defName) } // Verify that nested required fields are NOT hoisted to parent level correctRequiredFields := []string{"thing"} if got, want := definition.Required, correctRequiredFields; !reflect.DeepEqual(got, want) { t.Errorf("Nested required fields were incorrectly hoisted to parent level.\n"+ "Body definition required fields:\n"+ " got = %v\n"+ " want = %v (only top-level field names)\n"+ "Nested field 'value' should be in 'thing' property's required array, not parent's.", got, want) } var thingKV *keyVal if definition.Properties != nil { for i := range *definition.Properties { if (*definition.Properties)[i].Key == "thing" { thingKV = &(*definition.Properties)[i] break } } } if thingKV == nil { t.Fatal("'thing' property not found in body definition") } if _, ok := thingKV.Value.(openapiSchemaObject); !ok { t.Fatal("'thing' property value is not an openapiSchemaObject") } } // TestBodyParameterSelfReferentialBug tests the bug where the body parameter name // is added to the required array even though it's not a property of the schema func TestBodyParameterSelfReferentialBug(t *testing.T) { fieldBehaviorRequired := []annotations.FieldBehavior{annotations.FieldBehavior_REQUIRED} requiredFieldOptions := new(descriptorpb.FieldOptions) proto.SetExtension(requiredFieldOptions, annotations.E_FieldBehavior, fieldBehaviorRequired) // Define the Direction message with REQUIRED fields (but NO field named "direction") directionDesc := &descriptorpb.DescriptorProto{ Name: proto.String("Direction"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("name"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(1), }, { Name: proto.String("title"), Type: descriptorpb.FieldDescriptorProto_TYPE_STRING.Enum(), Number: proto.Int32(2), Options: requiredFieldOptions, }, }, } // Define the UpdateDirectionRequest message updateDirectionReqDesc := &descriptorpb.DescriptorProto{ Name: proto.String("UpdateDirectionRequest"), Field: []*descriptorpb.FieldDescriptorProto{ { Name: proto.String("direction"), Type: descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum(), TypeName: proto.String(".test.Direction"), Number: proto.Int32(1), Options: requiredFieldOptions, // direction field is REQUIRED }, }, } directionMsg := &descriptor.Message{ DescriptorProto: directionDesc, } updateDirectionReqMsg := &descriptor.Message{ DescriptorProto: updateDirectionReqDesc, } nameField := &descriptor.Field{ Message: directionMsg, FieldDescriptorProto: directionMsg.GetField()[0], } titleField := &descriptor.Field{ Message: directionMsg, FieldDescriptorProto: directionMsg.GetField()[1], } directionMsg.Fields = []*descriptor.Field{nameField, titleField} directionReqField := &descriptor.Field{ Message: updateDirectionReqMsg, FieldMessage: directionMsg, FieldDescriptorProto: updateDirectionReqMsg.GetField()[0], } updateDirectionReqMsg.Fields = []*descriptor.Field{directionReqField} meth := &descriptorpb.MethodDescriptorProto{ Name: proto.String("UpdateDirection"), InputType: proto.String("UpdateDirectionRequest"), OutputType: proto.String("Direction"), } svc := &descriptorpb.ServiceDescriptorProto{ Name: proto.String("DirectionService"), Method: []*descriptorpb.MethodDescriptorProto{meth}, } file := descriptor.File{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, Name: proto.String("direction.proto"), Package: proto.String("test"), MessageType: []*descriptorpb.DescriptorProto{directionDesc, updateDirectionReqDesc}, Service: []*descriptorpb.ServiceDescriptorProto{svc}, Options: &descriptorpb.FileOptions{ GoPackage: proto.String("github.com/example/test;test"), }, }, GoPkg: descriptor.GoPackage{ Path: "example.com/path/to/test/test.pb", Name: "test_pb", }, Messages: []*descriptor.Message{directionMsg, updateDirectionReqMsg}, Services: []*descriptor.Service{ { ServiceDescriptorProto: svc, Methods: []*descriptor.Method{ { MethodDescriptorProto: meth, RequestType: updateDirectionReqMsg, ResponseType: directionMsg, Bindings: []*descriptor.Binding{ { HTTPMethod: "PATCH", PathTmpl: httprule.Template{ Version: 1, OpCodes: []int{0, 0}, Template: "/api/v1/{direction.name}", }, PathParams: []descriptor.Parameter{ { FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "direction", }, { Name: "name", }, }), Target: nameField, }, }, Body: &descriptor.Body{ FieldPath: descriptor.FieldPath([]descriptor.FieldPathComponent{ { Name: "direction", Target: directionReqField, }, }), }, }, }, }, }, }, }, } reg := descriptor.NewRegistry() fileCL := crossLinkFixture(&file) err := reg.Load(reqFromFile(fileCL)) if err != nil { t.Errorf("reg.Load(%#v) failed with %v; want success", file, err) return } result, err := applyTemplate(param{File: fileCL, reg: reg}) if err != nil { t.Fatalf("applyTemplate(%#v) failed with %v; want success", file, err) } paths := GetPaths(result) if got, want := len(paths), 1; got != want { t.Fatalf("Results path length differed, got %d want %d", got, want) } operation := *result.getPathItemObject("/api/v1/{direction.name}").Patch // Find the body parameter var bodyParam *openapiParameterObject for i := range operation.Parameters { if operation.Parameters[i].In == "body" { bodyParam = &operation.Parameters[i] break } } if bodyParam == nil { t.Fatal("Body parameter not found") } if bodyParam.Schema == nil { t.Fatal("Body parameter schema is nil") } // Check that we don't have the parameter name in the required array // when it's not actually a property of the schema expectedRequired := []string{"title"} if bodyParam.Schema.Properties != nil { propertyNames := make(map[string]bool) for _, prop := range *bodyParam.Schema.Properties { propertyNames[prop.Key] = true } var invalidRequired []string for _, req := range bodyParam.Schema.Required { if !propertyNames[req] { invalidRequired = append(invalidRequired, req) } } if len(invalidRequired) > 0 { t.Errorf("BUG REPRODUCED: Required array contains fields that are not properties: %v", invalidRequired) t.Errorf("Full required array: %v", bodyParam.Schema.Required) t.Errorf("Available properties: %v", func() []string { keys := make([]string, 0, len(*bodyParam.Schema.Properties)) for _, prop := range *bodyParam.Schema.Properties { keys = append(keys, prop.Key) } return keys }()) } } if !reflect.DeepEqual(bodyParam.Schema.Required, expectedRequired) { t.Errorf("Required array doesn't match expected:\n"+ " got = %v\n"+ " want = %v\n"+ " diff = %s", bodyParam.Schema.Required, expectedRequired, cmp.Diff(expectedRequired, bodyParam.Schema.Required)) } } func TestFieldCommentsWithNewlines(t *testing.T) { tests := []struct { name string comments string expectedTitle string expectedDesc string }{ { name: "single line comment goes to title", comments: "Short comment without newlines", expectedTitle: "Short comment without newlines", expectedDesc: "", }, { name: "two paragraphs - first goes to title", comments: "Short title\n\nLonger description here", expectedTitle: "Short title", expectedDesc: "Longer description here", }, { name: "multi-line first paragraph goes to description only", comments: "a comment about my body parameter that is quite long\nand may have multiple lines\nthat should become the description", expectedTitle: "", expectedDesc: "a comment about my body parameter that is quite long\nand may have multiple lines\nthat should become the description", }, { name: "multi-line first paragraph with second paragraph", comments: "first line\nstill first paragraph\n\nsecond paragraph", expectedTitle: "", expectedDesc: "first line\nstill first paragraph\n\nsecond paragraph", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { var title, desc string comments := tt.comments if len(comments) > 0 { paragraphs := strings.Split(comments, paragraphDeliminator) firstParagraph := strings.TrimSpace(paragraphs[0]) if !strings.Contains(firstParagraph, "\n") { title = firstParagraph desc = strings.TrimSpace(strings.Join(paragraphs[1:], paragraphDeliminator)) } else { desc = strings.TrimSpace(comments) } } if title != tt.expectedTitle { t.Errorf("Title mismatch: got %q, want %q", title, tt.expectedTitle) } if desc != tt.expectedDesc { t.Errorf("Description mismatch: got %q, want %q", desc, tt.expectedDesc) } }) } } ================================================ FILE: protoc-gen-openapiv2/internal/genopenapi/testdata/generator/path_item_object.prototext ================================================ file_to_generate: "your/service/v1/your_service.proto" proto_file: { name: "your/service/v1/your_service.proto" package: "your.service.v1" message_type: { name: "StringMessage" field: { name: "value" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "value" } } service: { name: "YourService" method: { name: "Echo" input_type: ".your.service.v1.StringMessage" output_type: ".your.service.v1.StringMessage" options: { [google.api.http]: { post: "/api/echo" } } } } options: { go_package: "github.com/yourorg/yourprotos/gen/go/your/service/v1" } syntax: "proto3" } ================================================ FILE: protoc-gen-openapiv2/internal/genopenapi/testdata/generator/path_item_object.swagger.yaml ================================================ swagger: "2.0" info: title: your/service/v1/your_service.proto version: version not set tags: - name: YourService consumes: - application/json produces: - application/json paths: /api/echo: post: operationId: YourService_Echo responses: "200": description: A successful response. schema: $ref: '#/definitions/v1StringMessage' parameters: - name: value in: query required: false type: string tags: - YourService definitions: v1StringMessage: type: object properties: value: type: string ================================================ FILE: protoc-gen-openapiv2/internal/genopenapi/testdata/generator/x_go_type.prototext ================================================ file_to_generate: "test/service/v1/service.proto" proto_file: { name: "test/service/v1/service.proto" package: "test.service.v1" message_type: { name: "TestMessage" field: { name: "value" number: 1 label: LABEL_OPTIONAL type: TYPE_STRING json_name: "value" } } service: { name: "TestService" method: { name: "Test" input_type: ".test.service.v1.TestMessage" output_type: ".test.service.v1.TestMessage" options: { [google.api.http]: { post: "/v1/test" body: "*" } } } } options: { go_package: "github.com/grpc-ecosystem/grpc-gateway/v2/test/service/v1;servicev1" } } ================================================ FILE: protoc-gen-openapiv2/internal/genopenapi/testdata/generator/x_go_type.swagger.yaml ================================================ swagger: "2.0" info: title: test/service/v1/service.proto version: version not set tags: - name: TestService consumes: - application/json produces: - application/json paths: /v1/test: post: operationId: TestService_Test responses: "200": description: A successful response. schema: $ref: '#/definitions/v1TestMessage' parameters: - name: body in: body required: true schema: $ref: '#/definitions/v1TestMessage' tags: - TestService definitions: v1TestMessage: type: object properties: value: type: string x-go-type: import: package: "github.com/grpc-ecosystem/grpc-gateway/v2/test/service/v1" type: "TestMessage" ================================================ FILE: protoc-gen-openapiv2/internal/genopenapi/types.go ================================================ package genopenapi import ( "bytes" "encoding/json" "fmt" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor" "go.yaml.in/yaml/v3" ) type param struct { *descriptor.File reg *descriptor.Registry } // http://swagger.io/specification/#infoObject type openapiInfoObject struct { Title string `json:"title" yaml:"title"` Description string `json:"description,omitempty" yaml:"description,omitempty"` TermsOfService string `json:"termsOfService,omitempty" yaml:"termsOfService,omitempty"` Version string `json:"version" yaml:"version"` Contact *openapiContactObject `json:"contact,omitempty" yaml:"contact,omitempty"` License *openapiLicenseObject `json:"license,omitempty" yaml:"license,omitempty"` extensions []extension `json:"-" yaml:"-"` } // https://swagger.io/specification/#tagObject type openapiTagObject struct { Name string `json:"name" yaml:"name"` Description string `json:"description,omitempty" yaml:"description,omitempty"` ExternalDocs *openapiExternalDocumentationObject `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"` extensions []extension `json:"-" yaml:"-"` } // http://swagger.io/specification/#contactObject type openapiContactObject struct { Name string `json:"name,omitempty" yaml:"name,omitempty"` URL string `json:"url,omitempty" yaml:"url,omitempty"` Email string `json:"email,omitempty" yaml:"email,omitempty"` } // http://swagger.io/specification/#licenseObject type openapiLicenseObject struct { Name string `json:"name,omitempty" yaml:"name,omitempty"` URL string `json:"url,omitempty" yaml:"url,omitempty"` } // http://swagger.io/specification/#externalDocumentationObject type openapiExternalDocumentationObject struct { Description string `json:"description,omitempty" yaml:"description,omitempty"` URL string `json:"url,omitempty" yaml:"url,omitempty"` } type extension struct { key string `json:"-" yaml:"-"` value json.RawMessage `json:"-" yaml:"-"` } // http://swagger.io/specification/#swaggerObject type openapiSwaggerObject struct { Swagger string `json:"swagger" yaml:"swagger"` Info openapiInfoObject `json:"info" yaml:"info"` Tags []openapiTagObject `json:"tags,omitempty" yaml:"tags,omitempty"` Host string `json:"host,omitempty" yaml:"host,omitempty"` BasePath string `json:"basePath,omitempty" yaml:"basePath,omitempty"` Schemes []string `json:"schemes,omitempty" yaml:"schemes,omitempty"` Consumes []string `json:"consumes" yaml:"consumes"` Produces []string `json:"produces" yaml:"produces"` Paths openapiPathsObject `json:"paths" yaml:"paths"` Definitions openapiDefinitionsObject `json:"definitions" yaml:"definitions"` SecurityDefinitions openapiSecurityDefinitionsObject `json:"securityDefinitions,omitempty" yaml:"securityDefinitions,omitempty"` Security []openapiSecurityRequirementObject `json:"security,omitempty" yaml:"security,omitempty"` ExternalDocs *openapiExternalDocumentationObject `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"` extensions []extension `json:"-" yaml:"-"` } // http://swagger.io/specification/#securityDefinitionsObject type openapiSecurityDefinitionsObject map[string]openapiSecuritySchemeObject // http://swagger.io/specification/#securitySchemeObject type openapiSecuritySchemeObject struct { Type string `json:"type" yaml:"type"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` In string `json:"in,omitempty" yaml:"in,omitempty"` Flow string `json:"flow,omitempty" yaml:"flow,omitempty"` AuthorizationURL string `json:"authorizationUrl,omitempty" yaml:"authorizationUrl,omitempty"` TokenURL string `json:"tokenUrl,omitempty" yaml:"tokenUrl,omitempty"` Scopes openapiScopesObject `json:"scopes,omitempty" yaml:"scopes,omitempty"` extensions []extension `json:"-" yaml:"-"` } // http://swagger.io/specification/#scopesObject type openapiScopesObject map[string]string // http://swagger.io/specification/#securityRequirementObject type openapiSecurityRequirementObject map[string][]string // http://swagger.io/specification/#pathsObject type openapiPathsObject []pathData type pathData struct { Path string PathItemObject openapiPathItemObject } // http://swagger.io/specification/#pathItemObject type openapiPathItemObject struct { Get *openapiOperationObject `json:"get,omitempty" yaml:"get,omitempty"` Delete *openapiOperationObject `json:"delete,omitempty" yaml:"delete,omitempty"` Post *openapiOperationObject `json:"post,omitempty" yaml:"post,omitempty"` Put *openapiOperationObject `json:"put,omitempty" yaml:"put,omitempty"` Patch *openapiOperationObject `json:"patch,omitempty" yaml:"patch,omitempty"` Head *openapiOperationObject `json:"head,omitempty" yaml:"head,omitempty"` Options *openapiOperationObject `json:"options,omitempty" yaml:"options,omitempty"` // While TRACE is supported in OpenAPI v3, it is not supported in OpenAPI v2 // Trace *openapiOperationObject `json:"trace,omitempty" yaml:"trace,omitempty"` } // http://swagger.io/specification/#operationObject type openapiOperationObject struct { Summary string `json:"summary,omitempty" yaml:"summary,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` OperationID string `json:"operationId" yaml:"operationId"` Responses openapiResponsesObject `json:"responses" yaml:"responses"` Parameters openapiParametersObject `json:"parameters,omitempty" yaml:"parameters,omitempty"` Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"` Deprecated bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` Consumes []string `json:"consumes,omitempty" yaml:"consumes,omitempty"` Produces []string `json:"produces,omitempty" yaml:"produces,omitempty"` Security *[]openapiSecurityRequirementObject `json:"security,omitempty" yaml:"security,omitempty"` ExternalDocs *openapiExternalDocumentationObject `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"` extensions []extension `json:"-" yaml:"-"` } type openapiParametersObject []openapiParameterObject // http://swagger.io/specification/#parameterObject type openapiParameterObject struct { Name string `json:"name" yaml:"name"` Description string `json:"description,omitempty" yaml:"description,omitempty"` In string `json:"in,omitempty" yaml:"in,omitempty"` Required bool `json:"required" yaml:"required"` Deprecated bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` Type string `json:"type,omitempty" yaml:"type,omitempty"` Format string `json:"format,omitempty" yaml:"format,omitempty"` UniqueItems bool `json:"uniqueItems,omitempty" yaml:"uniqueItems,omitempty"` Items *openapiItemsObject `json:"items,omitempty" yaml:"items,omitempty"` Enum interface{} `json:"enum,omitempty" yaml:"enum,omitempty"` CollectionFormat string `json:"collectionFormat,omitempty" yaml:"collectionFormat,omitempty"` Default interface{} `json:"default,omitempty" yaml:"default,omitempty"` MinItems *int `json:"minItems,omitempty" yaml:"minItems,omitempty"` Pattern string `json:"pattern,omitempty" yaml:"pattern,omitempty"` // Or you can explicitly refer to another type. If this is defined all // other fields should be empty Schema *openapiSchemaObject `json:"schema,omitempty" yaml:"schema,omitempty"` extensions []extension } // core part of schema, which is common to itemsObject and schemaObject. // http://swagger.io/specification/v2/#itemsObject // The OAS3 spec (https://swagger.io/specification/#schemaObject) defines the // `nullable` field as part of a Schema Object. This behavior has been // "back-ported" to OAS2 as the Specification Extension `x-nullable`, and is // supported by generation tools such as swagger-codegen and go-swagger. // For protoc-gen-openapiv3, we'd want to add `nullable` instead. type schemaCore struct { Type string `json:"type,omitempty" yaml:"type,omitempty"` Format string `json:"format,omitempty" yaml:"format,omitempty"` Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"` XNullable bool `json:"x-nullable,omitempty" yaml:"x-nullable,omitempty"` Example RawExample `json:"example,omitempty" yaml:"example,omitempty"` Items *openapiItemsObject `json:"items,omitempty" yaml:"items,omitempty"` // If the item is an enumeration include a list of all the *NAMES* of the // enum values. I'm not sure how well this will work but assuming all enums // start from 0 index it will be great. I don't think that is a good assumption. Enum interface{} `json:"enum,omitempty" yaml:"enum,omitempty"` Default interface{} `json:"default,omitempty" yaml:"default,omitempty"` } type allOfEntry struct { Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"` } type RawExample json.RawMessage func (m RawExample) MarshalJSON() ([]byte, error) { return (json.RawMessage)(m).MarshalJSON() } func (m *RawExample) UnmarshalJSON(data []byte) error { return (*json.RawMessage)(m).UnmarshalJSON(data) } // MarshalYAML implements yaml.Marshaler interface. // // It converts RawExample to one of yaml-supported types and returns it. // // From yaml.Marshaler docs: The Marshaler interface may be implemented // by types to customize their behavior when being marshaled into a YAML // document. The returned value is marshaled in place of the original // value implementing Marshaler. func (e RawExample) MarshalYAML() (interface{}, error) { // From docs, json.Unmarshal will store one of next types to data: // - bool, for JSON booleans; // - float64, for JSON numbers; // - string, for JSON strings; // - []interface{}, for JSON arrays; // - map[string]interface{}, for JSON objects; // - nil for JSON null. var data interface{} if err := json.Unmarshal(e, &data); err != nil { return nil, err } return data, nil } func (s *schemaCore) setRefFromFQN(ref string, reg *descriptor.Registry) error { name, ok := fullyQualifiedNameToOpenAPIName(ref, reg) if !ok { return fmt.Errorf("setRefFromFQN: can't resolve OpenAPI name from %q", ref) } s.Ref = fmt.Sprintf("#/definitions/%s", name) return nil } type openapiItemsObject openapiSchemaObject // http://swagger.io/specification/#responsesObject type openapiResponsesObject map[string]openapiResponseObject // http://swagger.io/specification/#responseObject type openapiResponseObject struct { Description string `json:"description" yaml:"description"` Schema openapiSchemaObject `json:"schema" yaml:"schema"` Examples map[string]interface{} `json:"examples,omitempty" yaml:"examples,omitempty"` Headers openapiHeadersObject `json:"headers,omitempty" yaml:"headers,omitempty"` extensions []extension `json:"-" yaml:"-"` } type openapiHeadersObject map[string]openapiHeaderObject // http://swagger.io/specification/#headerObject type openapiHeaderObject struct { Description string `json:"description,omitempty" yaml:"description,omitempty"` Type string `json:"type,omitempty" yaml:"type,omitempty"` Format string `json:"format,omitempty" yaml:"format,omitempty"` Default RawExample `json:"default,omitempty" yaml:"default,omitempty"` Pattern string `json:"pattern,omitempty" yaml:"pattern,omitempty"` } type keyVal struct { Key string Value interface{} } type openapiSchemaObjectProperties []keyVal func (p openapiSchemaObjectProperties) MarshalYAML() (interface{}, error) { n := yaml.Node{ Kind: yaml.MappingNode, Content: make([]*yaml.Node, len(p)*2), } for i, v := range p { keyNode := yaml.Node{} if err := keyNode.Encode(v.Key); err != nil { return nil, err } valueNode := yaml.Node{} if err := valueNode.Encode(v.Value); err != nil { return nil, err } n.Content[i*2+0] = &keyNode n.Content[i*2+1] = &valueNode } return n, nil } func (op openapiSchemaObjectProperties) MarshalJSON() ([]byte, error) { var buf bytes.Buffer buf.WriteString("{") for i, kv := range op { if i != 0 { buf.WriteString(",") } key, err := json.Marshal(kv.Key) if err != nil { return nil, err } buf.Write(key) buf.WriteString(":") val, err := json.Marshal(kv.Value) if err != nil { return nil, err } buf.Write(val) } buf.WriteString("}") return buf.Bytes(), nil } // http://swagger.io/specification/#schemaObject type openapiSchemaObject struct { schemaCore `yaml:",inline"` // Properties can be recursively defined Properties *openapiSchemaObjectProperties `json:"properties,omitempty" yaml:"properties,omitempty"` AdditionalProperties *openapiSchemaObject `json:"additionalProperties,omitempty" yaml:"additionalProperties,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Title string `json:"title,omitempty" yaml:"title,omitempty"` ExternalDocs *openapiExternalDocumentationObject `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"` ReadOnly bool `json:"readOnly,omitempty" yaml:"readOnly,omitempty"` MultipleOf float64 `json:"multipleOf,omitempty" yaml:"multipleOf,omitempty"` Maximum float64 `json:"maximum,omitempty" yaml:"maximum,omitempty"` ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty" yaml:"exclusiveMaximum,omitempty"` Minimum float64 `json:"minimum,omitempty" yaml:"minimum,omitempty"` ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty" yaml:"exclusiveMinimum,omitempty"` MaxLength uint64 `json:"maxLength,omitempty" yaml:"maxLength,omitempty"` MinLength uint64 `json:"minLength,omitempty" yaml:"minLength,omitempty"` Pattern string `json:"pattern,omitempty" yaml:"pattern,omitempty"` MaxItems uint64 `json:"maxItems,omitempty" yaml:"maxItems,omitempty"` MinItems uint64 `json:"minItems,omitempty" yaml:"minItems,omitempty"` UniqueItems bool `json:"uniqueItems,omitempty" yaml:"uniqueItems,omitempty"` MaxProperties uint64 `json:"maxProperties,omitempty" yaml:"maxProperties,omitempty"` MinProperties uint64 `json:"minProperties,omitempty" yaml:"minProperties,omitempty"` Required []string `json:"required,omitempty" yaml:"required,omitempty"` extensions []extension AllOf []allOfEntry `json:"allOf,omitempty" yaml:"allOf,omitempty"` } // http://swagger.io/specification/#definitionsObject type openapiDefinitionsObject map[string]openapiSchemaObject // Internal type mapping from FQMN to descriptor.Message. Used as a set by the // findServiceMessages function. type messageMap map[string]*descriptor.Message // Internal type mapping from FQEN to descriptor.Enum. Used as a set by the // findServiceMessages function. type enumMap map[string]*descriptor.Enum // Internal type to store used references. type refMap map[string]struct{} ================================================ FILE: protoc-gen-openapiv2/internal/genopenapi/types_test.go ================================================ package genopenapi import ( "encoding/json" "strings" "testing" "go.yaml.in/yaml/v3" ) func newSpaceReplacer() *strings.Replacer { return strings.NewReplacer(" ", "", "\n", "", "\t", "") } func TestRawExample(t *testing.T) { t.Parallel() testCases := [...]struct { In RawExample Exp string }{{ In: RawExample(`1`), Exp: `1`, }, { In: RawExample(`"1"`), Exp: `"1"`, }, { In: RawExample(`{"hello":"worldr"}`), Exp: ` hello: worldr `, }} sr := newSpaceReplacer() for _, tc := range testCases { tc := tc t.Run(string(tc.In), func(t *testing.T) { t.Parallel() ex := tc.In out, err := yaml.Marshal(ex) switch { case err != nil: t.Fatalf("expect no yaml marshal error, got: %s", err) case !json.Valid(tc.In): t.Fatalf("json is invalid: %#q", tc.In) case sr.Replace(tc.Exp) != sr.Replace(string(out)): t.Fatalf("expected: %s, actual: %s", tc.Exp, out) } out, err = json.Marshal(tc.In) switch { case err != nil: t.Fatalf("expect no json marshal error, got: %s", err) case sr.Replace(string(tc.In)) != sr.Replace(string(out)): t.Fatalf("expected: %s, actual: %s", tc.In, out) } }) } } func TestOpenapiSchemaObjectProperties(t *testing.T) { t.Parallel() v := map[string]interface{}{ "example": openapiSchemaObjectProperties{{ Key: "test1", Value: 1, }, { Key: "test2", Value: 2, }}, } t.Run("yaml", func(t *testing.T) { t.Parallel() const exp = ` example: test1: 1 test2: 2 ` sr := newSpaceReplacer() out, err := yaml.Marshal(v) switch { case err != nil: t.Fatalf("expect no marshal error, got: %s", err) case sr.Replace(exp) != sr.Replace(string(out)): t.Fatalf("expected: %s, actual: %s", exp, out) } }) t.Run("json", func(t *testing.T) { t.Parallel() const exp = `{"example":{"test1":1,"test2":2}}` got, err := json.Marshal(v) switch { case err != nil: t.Fatalf("expect no marshal error, got: %s", err) case exp != string(got): t.Fatalf("expected: %s, actual: %s", exp, got) } }) } ================================================ FILE: protoc-gen-openapiv2/main.go ================================================ package main import ( "flag" "fmt" "os" "runtime/debug" "strings" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/codegenerator" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/descriptor" "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/internal/genopenapi" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc/grpclog" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/pluginpb" ) var ( importPrefix = flag.String("import_prefix", "", "prefix to be added to go package paths for imported proto files") file = flag.String("file", "-", "where to load data from") allowDeleteBody = flag.Bool("allow_delete_body", false, "unless set, HTTP DELETE methods may not have a body") grpcAPIConfiguration = flag.String("grpc_api_configuration", "", "path to file which describes the gRPC API Configuration in YAML format") allowMerge = flag.Bool("allow_merge", false, "if set, generation one OpenAPI file out of multiple protos") mergeFileName = flag.String("merge_file_name", "apidocs", "target OpenAPI file name prefix after merge") useJSONNamesForFields = flag.Bool("json_names_for_fields", true, "if disabled, the original proto name will be used for generating OpenAPI definitions") repeatedPathParamSeparator = flag.String("repeated_path_param_separator", "csv", "configures how repeated fields should be split. Allowed values are `csv`, `pipes`, `ssv` and `tsv`") versionFlag = flag.Bool("version", false, "print the current version") _ = flag.Bool("allow_repeated_fields_in_body", true, "allows to use repeated field in `body` and `response_body` field of `google.api.http` annotation option. DEPRECATED: the value is ignored and always behaves as `true`.") includePackageInTags = flag.Bool("include_package_in_tags", false, "if unset, the gRPC service name is added to the `Tags` field of each operation. If set and the `package` directive is shown in the proto file, the package name will be prepended to the service name") useFQNForOpenAPIName = flag.Bool("fqn_for_openapi_name", false, "if set, the object's OpenAPI names will use the fully qualified names from the proto definition (ie my.package.MyMessage.MyInnerMessage). DEPRECATED: prefer `openapi_naming_strategy=fqn`") openAPINamingStrategy = flag.String("openapi_naming_strategy", "", "use the given OpenAPI naming strategy. Allowed values are `legacy`, `fqn`, `simple`, `package`. If unset, either `legacy` or `fqn` are selected, depending on the value of the `fqn_for_openapi_name` flag") useGoTemplate = flag.Bool("use_go_templates", false, "if set, you can use Go templates in protofile comments") goTemplateArgs = utilities.StringArrayFlag(flag.CommandLine, "go_template_args", "provide a custom value that can override a key in the Go template. Requires the `use_go_templates` option to be set") ignoreComments = flag.Bool("ignore_comments", false, "if set, all protofile comments are excluded from output") removeInternalComments = flag.Bool("remove_internal_comments", false, "if set, removes all substrings in comments that start with `(--` and end with `--)` as specified in https://google.aip.dev/192#internal-comments") disableDefaultErrors = flag.Bool("disable_default_errors", false, "if set, disables generation of default errors. This is useful if you have defined custom error handling") enumsAsInts = flag.Bool("enums_as_ints", false, "whether to render enum values as integers, as opposed to string values") simpleOperationIDs = flag.Bool("simple_operation_ids", false, "whether to remove the service prefix in the operationID generation. Can introduce duplicate operationIDs, use with caution.") proto3OptionalNullable = flag.Bool("proto3_optional_nullable", false, "whether Proto3 Optional fields should be marked as x-nullable") openAPIConfiguration = flag.String("openapi_configuration", "", "path to file which describes the OpenAPI Configuration in YAML format") generateUnboundMethods = flag.Bool("generate_unbound_methods", false, "generate swagger metadata even for RPC methods that have no HttpRule annotation") recursiveDepth = flag.Int("recursive-depth", 1000, "maximum recursion count allowed for a field type") omitEnumDefaultValue = flag.Bool("omit_enum_default_value", false, "if set, omit default enum value") outputFormat = flag.String("output_format", string(genopenapi.FormatJSON), fmt.Sprintf("output content format. Allowed values are: `%s`, `%s`", genopenapi.FormatJSON, genopenapi.FormatYAML)) visibilityRestrictionSelectors = utilities.StringArrayFlag(flag.CommandLine, "visibility_restriction_selectors", "list of `google.api.VisibilityRule` visibility labels to include in the generated output when a visibility annotation is defined. Repeat this option to supply multiple values. Elements without visibility annotations are unaffected by this setting.") disableServiceTags = flag.Bool("disable_service_tags", false, "if set, disables generation of service tags. This is useful if you do not want to expose the names of your backend grpc services.") disableDefaultResponses = flag.Bool("disable_default_responses", false, "if set, disables generation of default responses. Useful if you have to support custom response codes that are not 200.") useAllOfForRefs = flag.Bool("use_allof_for_refs", false, "if set, will use allOf as container for $ref to preserve same-level properties.") omitArrayItemTypeWhenRefSibling = flag.Bool("omit_array_item_type_when_ref_sibling", false, "if set, will omit 'type: object' in array items when $ref is present to avoid strict no-$ref-siblings rule violations.") allowPatchFeature = flag.Bool("allow_patch_feature", true, "whether to hide update_mask fields in PATCH requests from the generated swagger file.") preserveRPCOrder = flag.Bool("preserve_rpc_order", false, "if true, will ensure the order of paths emitted in openapi swagger files mirror the order of RPC methods found in proto files. If false, emitted paths will be ordered alphabetically.") enableRpcDeprecation = flag.Bool("enable_rpc_deprecation", false, "whether to process grpc method's deprecated option.") enableFieldDeprecation = flag.Bool("enable_field_deprecation", false, "whether to process proto field's deprecated option.") expandSlashedPathPatterns = flag.Bool("expand_slashed_path_patterns", false, "if set, expands path parameters with URI sub-paths into the URI. For example, \"/v1/{name=projects/*}/resource\" becomes \"/v1/projects/{project}/resource\".") useProto3FieldSemantics = flag.Bool("use_proto3_field_semantics", false, "if set, uses proto3 field semantics for the OpenAPI schema. This means that fields are required by default.") generateXGoType = flag.Bool("generate_x_go_type", false, "if set, generates x-go-type extension using the go_package option from proto files") _ = flag.Bool("logtostderr", false, "Legacy glog compatibility. This flag is a no-op, you can safely remove it") ) // Variables set by goreleaser at build time var ( version = "dev" commit = "unknown" date = "unknown" ) func main() { flag.Parse() if *versionFlag { if commit == "unknown" { buildInfo, ok := debug.ReadBuildInfo() if ok { version = buildInfo.Main.Version for _, setting := range buildInfo.Settings { if setting.Key == "vcs.revision" { commit = setting.Value } if setting.Key == "vcs.time" { date = setting.Value } } } } fmt.Printf("Version %v, commit %v, built at %v\n", version, commit, date) os.Exit(0) } reg := descriptor.NewRegistry() if grpclog.V(1) { grpclog.Info("Processing code generator request") } f := os.Stdin if *file != "-" { var err error f, err = os.Open(*file) if err != nil { grpclog.Fatal(err) } } if grpclog.V(1) { grpclog.Info("Parsing code generator request") } req, err := codegenerator.ParseRequest(f) if err != nil { grpclog.Fatal(err) } if grpclog.V(1) { grpclog.Info("Parsed code generator request") } pkgMap := make(map[string]string) if req.Parameter != nil { if err := parseReqParam(req.GetParameter(), flag.CommandLine, pkgMap); err != nil { grpclog.Fatalf("Error parsing flags: %v", err) } } reg.SetPrefix(*importPrefix) reg.SetAllowDeleteBody(*allowDeleteBody) reg.SetAllowMerge(*allowMerge) reg.SetMergeFileName(*mergeFileName) reg.SetUseJSONNamesForFields(*useJSONNamesForFields) reg.SetUseProto3FieldSemantics(*useProto3FieldSemantics) flag.Visit(func(f *flag.Flag) { if f.Name == "allow_repeated_fields_in_body" { grpclog.Warning("The `allow_repeated_fields_in_body` flag is deprecated and will always behave as `true`.") } }) reg.SetIncludePackageInTags(*includePackageInTags) reg.SetUseFQNForOpenAPIName(*useFQNForOpenAPIName) // Set the naming strategy either directly from the flag, or via the value of the legacy fqn_for_openapi_name // flag. namingStrategy := *openAPINamingStrategy if *useFQNForOpenAPIName { if namingStrategy != "" { grpclog.Fatal("The deprecated `fqn_for_openapi_name` flag must remain unset if `openapi_naming_strategy` is set.") } grpclog.Warning("The `fqn_for_openapi_name` flag is deprecated. Please use `openapi_naming_strategy=fqn` instead.") namingStrategy = "fqn" } else if namingStrategy == "" { namingStrategy = "legacy" } if strategyFn := genopenapi.LookupNamingStrategy(namingStrategy); strategyFn == nil { emitError(fmt.Errorf("invalid naming strategy %q", namingStrategy)) return } if *useGoTemplate && *ignoreComments { emitError(fmt.Errorf("`ignore_comments` and `use_go_templates` are mutually exclusive and cannot be enabled at the same time")) return } reg.SetUseGoTemplate(*useGoTemplate) reg.SetIgnoreComments(*ignoreComments) reg.SetRemoveInternalComments(*removeInternalComments) if len(*goTemplateArgs) > 0 && !*useGoTemplate { emitError(fmt.Errorf("`go_template_args` requires `use_go_templates` to be enabled")) return } reg.SetGoTemplateArgs(*goTemplateArgs) reg.SetOpenAPINamingStrategy(namingStrategy) reg.SetEnumsAsInts(*enumsAsInts) reg.SetDisableDefaultErrors(*disableDefaultErrors) reg.SetSimpleOperationIDs(*simpleOperationIDs) reg.SetProto3OptionalNullable(*proto3OptionalNullable) reg.SetGenerateUnboundMethods(*generateUnboundMethods) reg.SetRecursiveDepth(*recursiveDepth) reg.SetOmitEnumDefaultValue(*omitEnumDefaultValue) reg.SetVisibilityRestrictionSelectors(*visibilityRestrictionSelectors) reg.SetDisableServiceTags(*disableServiceTags) reg.SetDisableDefaultResponses(*disableDefaultResponses) reg.SetUseAllOfForRefs(*useAllOfForRefs) reg.SetOmitArrayItemTypeWhenRefSibling(*omitArrayItemTypeWhenRefSibling) reg.SetAllowPatchFeature(*allowPatchFeature) reg.SetPreserveRPCOrder(*preserveRPCOrder) reg.SetEnableRpcDeprecation(*enableRpcDeprecation) reg.SetEnableFieldDeprecation(*enableFieldDeprecation) reg.SetExpandSlashedPathPatterns(*expandSlashedPathPatterns) reg.SetGenerateXGoType(*generateXGoType) if err := reg.SetRepeatedPathParamSeparator(*repeatedPathParamSeparator); err != nil { emitError(err) return } for k, v := range pkgMap { reg.AddPkgMap(k, v) } if *grpcAPIConfiguration != "" { if err := reg.LoadGrpcAPIServiceFromYAML(*grpcAPIConfiguration); err != nil { emitError(err) return } } format := genopenapi.Format(*outputFormat) if err := format.Validate(); err != nil { emitError(err) return } g := genopenapi.New(reg, format) if err := genopenapi.AddErrorDefs(reg); err != nil { emitError(err) return } if err := reg.Load(req); err != nil { emitError(err) return } if *openAPIConfiguration != "" { if err := reg.LoadOpenAPIConfigFromYAML(*openAPIConfiguration); err != nil { emitError(err) return } } targets := make([]*descriptor.File, 0, len(req.FileToGenerate)) for _, target := range req.FileToGenerate { f, err := reg.LookupFile(target) if err != nil { grpclog.Fatal(err) } targets = append(targets, f) } out, err := g.Generate(targets) if grpclog.V(1) { grpclog.Info("Processed code generator request") } if err != nil { emitError(err) return } emitFiles(out) } func emitFiles(out []*descriptor.ResponseFile) { files := make([]*pluginpb.CodeGeneratorResponse_File, len(out)) for idx, item := range out { files[idx] = item.CodeGeneratorResponse_File } resp := &pluginpb.CodeGeneratorResponse{File: files} codegenerator.SetSupportedFeaturesOnCodeGeneratorResponse(resp) emitResp(resp) } func emitError(err error) { emitResp(&pluginpb.CodeGeneratorResponse{Error: proto.String(err.Error())}) } func emitResp(resp *pluginpb.CodeGeneratorResponse) { buf, err := proto.Marshal(resp) if err != nil { grpclog.Fatal(err) } if _, err := os.Stdout.Write(buf); err != nil { grpclog.Fatal(err) } } // parseReqParam parses a CodeGeneratorRequest parameter and adds the // extracted values to the given FlagSet and pkgMap. Returns a non-nil // error if setting a flag failed. func parseReqParam(param string, f *flag.FlagSet, pkgMap map[string]string) error { if param == "" { return nil } for _, p := range strings.Split(param, ",") { spec := strings.SplitN(p, "=", 2) if len(spec) == 1 { switch spec[0] { case "allow_delete_body": if err := f.Set(spec[0], "true"); err != nil { return fmt.Errorf("cannot set flag %s: %w", p, err) } continue case "allow_merge": if err := f.Set(spec[0], "true"); err != nil { return fmt.Errorf("cannot set flag %s: %w", p, err) } continue case "allow_repeated_fields_in_body": if err := f.Set(spec[0], "true"); err != nil { return fmt.Errorf("cannot set flag %s: %w", p, err) } continue case "include_package_in_tags": if err := f.Set(spec[0], "true"); err != nil { return fmt.Errorf("cannot set flag %s: %w", p, err) } continue } if err := f.Set(spec[0], ""); err != nil { return fmt.Errorf("cannot set flag %s: %w", p, err) } continue } name, value := spec[0], spec[1] if strings.HasPrefix(name, "M") { pkgMap[name[1:]] = value continue } if err := f.Set(name, value); err != nil { return fmt.Errorf("cannot set flag %s: %w", p, err) } } return nil } ================================================ FILE: protoc-gen-openapiv2/main_test.go ================================================ package main import ( "errors" "flag" "reflect" "testing" ) func TestParseReqParam(t *testing.T) { testcases := []struct { name string expected map[string]string request string expectedError error allowDeleteBodyV bool allowMergeV bool includePackageInTagsV bool fileV string importPathV string mergeFileNameV string useFQNForOpenAPINameV bool openAPINamingStrategyV string }{ { // this one must be first - with no leading clearFlags call it // verifies our expectation of default values as we reset by // clearFlags name: "Test 0", expected: map[string]string{}, request: "", allowDeleteBodyV: false, allowMergeV: false, includePackageInTagsV: false, fileV: "-", importPathV: "", mergeFileNameV: "apidocs", }, { name: "Test 1", expected: map[string]string{"google/api/annotations.proto": "github.com/googleapis/googleapis/google/api"}, request: "allow_delete_body,allow_merge,allow_repeated_fields_in_body,include_package_in_tags,file=./foo.pb,import_prefix=/bar/baz,Mgoogle/api/annotations.proto=github.com/googleapis/googleapis/google/api", allowDeleteBodyV: true, allowMergeV: true, includePackageInTagsV: true, fileV: "./foo.pb", importPathV: "/bar/baz", mergeFileNameV: "apidocs", }, { name: "Test 2", expected: map[string]string{"google/api/annotations.proto": "github.com/googleapis/googleapis/google/api"}, request: "allow_delete_body=true,allow_merge=true,allow_repeated_fields_in_body=true,include_package_in_tags=true,merge_file_name=test_name,file=./foo.pb,import_prefix=/bar/baz,Mgoogle/api/annotations.proto=github.com/googleapis/googleapis/google/api", allowDeleteBodyV: true, allowMergeV: true, includePackageInTagsV: true, fileV: "./foo.pb", importPathV: "/bar/baz", mergeFileNameV: "test_name", }, { name: "Test 3", expected: map[string]string{"a/b/c.proto": "github.com/x/y/z", "f/g/h.proto": "github.com/1/2/3/"}, request: "allow_delete_body=false,allow_merge=false,Ma/b/c.proto=github.com/x/y/z,Mf/g/h.proto=github.com/1/2/3/", allowDeleteBodyV: false, allowMergeV: false, includePackageInTagsV: false, fileV: "stdin", importPathV: "", mergeFileNameV: "apidocs", }, { name: "Test 4", expected: map[string]string{}, request: "", allowDeleteBodyV: false, allowMergeV: false, includePackageInTagsV: false, fileV: "stdin", importPathV: "", mergeFileNameV: "apidocs", }, { name: "Test 5", expected: map[string]string{}, request: "unknown_param=17", expectedError: errors.New("cannot set flag unknown_param=17: no such flag -unknown_param"), allowDeleteBodyV: false, allowMergeV: false, includePackageInTagsV: false, fileV: "stdin", importPathV: "", mergeFileNameV: "apidocs", }, { name: "Test 6", expected: map[string]string{}, request: "Mfoo", expectedError: errors.New("cannot set flag Mfoo: no such flag -Mfoo"), allowDeleteBodyV: false, allowMergeV: false, includePackageInTagsV: false, fileV: "stdin", importPathV: "", mergeFileNameV: "apidocs", }, { name: "Test 7", expected: map[string]string{}, request: "allow_delete_body,file,import_prefix,allow_merge,allow_repeated_fields_in_body,include_package_in_tags,merge_file_name", allowDeleteBodyV: true, allowMergeV: true, includePackageInTagsV: true, fileV: "", importPathV: "", mergeFileNameV: "", }, { name: "Test 8", expected: map[string]string{}, request: "allow_delete_body,file,import_prefix,allow_merge,allow_repeated_fields_in_body=3,merge_file_name", expectedError: errors.New(`cannot set flag allow_repeated_fields_in_body=3: parse error`), allowDeleteBodyV: true, allowMergeV: true, includePackageInTagsV: false, fileV: "", importPathV: "", mergeFileNameV: "apidocs", }, { name: "Test 9", expected: map[string]string{}, request: "include_package_in_tags=3", expectedError: errors.New(`cannot set flag include_package_in_tags=3: parse error`), allowDeleteBodyV: false, allowMergeV: false, includePackageInTagsV: false, fileV: "stdin", importPathV: "", mergeFileNameV: "apidocs", }, { name: "Test 10", expected: map[string]string{}, request: "fqn_for_openapi_name=3", expectedError: errors.New(`cannot set flag fqn_for_openapi_name=3: parse error`), allowDeleteBodyV: false, allowMergeV: false, includePackageInTagsV: false, useFQNForOpenAPINameV: false, fileV: "stdin", importPathV: "", mergeFileNameV: "apidocs", }, { name: "Test 11", expected: map[string]string{}, request: "fqn_for_openapi_name=true", allowDeleteBodyV: false, allowMergeV: false, includePackageInTagsV: false, useFQNForOpenAPINameV: true, fileV: "stdin", importPathV: "", mergeFileNameV: "apidocs", }, { name: "Test 12", expected: map[string]string{}, request: "openapi_naming_strategy=simple", allowDeleteBodyV: false, allowMergeV: false, includePackageInTagsV: false, useFQNForOpenAPINameV: false, openAPINamingStrategyV: "simple", fileV: "stdin", importPathV: "", mergeFileNameV: "apidocs", }, } for i, tc := range testcases { t.Run(tc.name, func(tt *testing.T) { f := flag.CommandLine pkgMap := make(map[string]string) err := parseReqParam(tc.request, f, pkgMap) if tc.expectedError == nil { if err != nil { tt.Errorf("unexpected parse error '%v'", err) } if !reflect.DeepEqual(pkgMap, tc.expected) { tt.Errorf("pkgMap parse error, expected '%v', got '%v'", tc.expected, pkgMap) } } else { if err == nil { tt.Error("expected parse error not returned") } if !reflect.DeepEqual(pkgMap, tc.expected) { tt.Errorf("pkgMap parse error, expected '%v', got '%v'", tc.expected, pkgMap) } if err.Error() != tc.expectedError.Error() { tt.Errorf("expected error malformed, expected %q, got %q", tc.expectedError.Error(), err.Error()) } } checkFlags(tc.allowDeleteBodyV, tc.allowMergeV, tc.includePackageInTagsV, tc.useFQNForOpenAPINameV, tc.openAPINamingStrategyV, tc.fileV, tc.importPathV, tc.mergeFileNameV, tt, i) clearFlags() }) } } func checkFlags( allowDeleteV, allowMergeV, includePackageInTagsV bool, useFQNForOpenAPINameV bool, openAPINamingStrategyV, fileV, importPathV, mergeFileNameV string, t *testing.T, tid int, ) { if *importPrefix != importPathV { t.Errorf("Test %v: import_prefix misparsed, expected '%v', got '%v'", tid, importPathV, *importPrefix) } if *file != fileV { t.Errorf("Test %v: file misparsed, expected '%v', got '%v'", tid, fileV, *file) } if *allowDeleteBody != allowDeleteV { t.Errorf("Test %v: allow_delete_body misparsed, expected '%v', got '%v'", tid, allowDeleteV, *allowDeleteBody) } if *allowMerge != allowMergeV { t.Errorf("Test %v: allow_merge misparsed, expected '%v', got '%v'", tid, allowMergeV, *allowMerge) } if *mergeFileName != mergeFileNameV { t.Errorf("Test %v: merge_file_name misparsed, expected '%v', got '%v'", tid, mergeFileNameV, *mergeFileName) } if *includePackageInTags != includePackageInTagsV { t.Errorf("Test %v: include_package_in_tags misparsed, expected '%v', got '%v'", tid, includePackageInTagsV, *includePackageInTags) } if *useFQNForOpenAPIName != useFQNForOpenAPINameV { t.Errorf("Test %v: fqn_for_openapi_name misparsed, expected '%v', got '%v'", tid, useFQNForOpenAPINameV, *useFQNForOpenAPIName) } if *openAPINamingStrategy != openAPINamingStrategyV { t.Errorf("Test %v: openapi_naming_strategy misparsed, expected '%v', got '%v'", tid, openAPINamingStrategyV, *openAPINamingStrategy) } } func clearFlags() { *importPrefix = "" *file = "stdin" *allowDeleteBody = false *allowMerge = false *includePackageInTags = false *mergeFileName = "apidocs" *useFQNForOpenAPIName = false *openAPINamingStrategy = "" } ================================================ FILE: protoc-gen-openapiv2/options/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library") load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") load("@rules_proto//proto:defs.bzl", "proto_library") package(default_visibility = ["//visibility:public"]) filegroup( name = "options_proto_files", srcs = [ "annotations.proto", "openapiv2.proto", ], ) go_library( name = "options", embed = [":options_go_proto"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options", ) proto_library( name = "options_proto", srcs = [ "annotations.proto", "openapiv2.proto", ], deps = [ "@com_google_protobuf//:descriptor_proto", "@com_google_protobuf//:struct_proto", ], ) go_proto_library( name = "options_go_proto", compilers = ["//:go_apiv2"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options", proto = ":options_proto", ) alias( name = "go_default_library", actual = ":options", visibility = ["//visibility:public"], ) ================================================ FILE: protoc-gen-openapiv2/options/annotations.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.0 // protoc (unknown) // source: protoc-gen-openapiv2/options/annotations.proto //go:build !protoopaque package options import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" descriptorpb "google.golang.org/protobuf/types/descriptorpb" reflect "reflect" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) var file_protoc_gen_openapiv2_options_annotations_proto_extTypes = []protoimpl.ExtensionInfo{ { ExtendedType: (*descriptorpb.FileOptions)(nil), ExtensionType: (*Swagger)(nil), Field: 1042, Name: "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger", Tag: "bytes,1042,opt,name=openapiv2_swagger", Filename: "protoc-gen-openapiv2/options/annotations.proto", }, { ExtendedType: (*descriptorpb.MethodOptions)(nil), ExtensionType: (*Operation)(nil), Field: 1042, Name: "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation", Tag: "bytes,1042,opt,name=openapiv2_operation", Filename: "protoc-gen-openapiv2/options/annotations.proto", }, { ExtendedType: (*descriptorpb.MessageOptions)(nil), ExtensionType: (*Schema)(nil), Field: 1042, Name: "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema", Tag: "bytes,1042,opt,name=openapiv2_schema", Filename: "protoc-gen-openapiv2/options/annotations.proto", }, { ExtendedType: (*descriptorpb.EnumOptions)(nil), ExtensionType: (*EnumSchema)(nil), Field: 1042, Name: "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_enum", Tag: "bytes,1042,opt,name=openapiv2_enum", Filename: "protoc-gen-openapiv2/options/annotations.proto", }, { ExtendedType: (*descriptorpb.ServiceOptions)(nil), ExtensionType: (*Tag)(nil), Field: 1042, Name: "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag", Tag: "bytes,1042,opt,name=openapiv2_tag", Filename: "protoc-gen-openapiv2/options/annotations.proto", }, { ExtendedType: (*descriptorpb.FieldOptions)(nil), ExtensionType: (*JSONSchema)(nil), Field: 1042, Name: "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field", Tag: "bytes,1042,opt,name=openapiv2_field", Filename: "protoc-gen-openapiv2/options/annotations.proto", }, } // Extension fields to descriptorpb.FileOptions. var ( // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. // // All IDs are the same, as assigned. It is okay that they are the same, as they extend // different descriptor messages. // // optional grpc.gateway.protoc_gen_openapiv2.options.Swagger openapiv2_swagger = 1042; E_Openapiv2Swagger = &file_protoc_gen_openapiv2_options_annotations_proto_extTypes[0] ) // Extension fields to descriptorpb.MethodOptions. var ( // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. // // All IDs are the same, as assigned. It is okay that they are the same, as they extend // different descriptor messages. // // optional grpc.gateway.protoc_gen_openapiv2.options.Operation openapiv2_operation = 1042; E_Openapiv2Operation = &file_protoc_gen_openapiv2_options_annotations_proto_extTypes[1] ) // Extension fields to descriptorpb.MessageOptions. var ( // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. // // All IDs are the same, as assigned. It is okay that they are the same, as they extend // different descriptor messages. // // optional grpc.gateway.protoc_gen_openapiv2.options.Schema openapiv2_schema = 1042; E_Openapiv2Schema = &file_protoc_gen_openapiv2_options_annotations_proto_extTypes[2] ) // Extension fields to descriptorpb.EnumOptions. var ( // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. // // All IDs are the same, as assigned. It is okay that they are the same, as they extend // different descriptor messages. // // optional grpc.gateway.protoc_gen_openapiv2.options.EnumSchema openapiv2_enum = 1042; E_Openapiv2Enum = &file_protoc_gen_openapiv2_options_annotations_proto_extTypes[3] ) // Extension fields to descriptorpb.ServiceOptions. var ( // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. // // All IDs are the same, as assigned. It is okay that they are the same, as they extend // different descriptor messages. // // optional grpc.gateway.protoc_gen_openapiv2.options.Tag openapiv2_tag = 1042; E_Openapiv2Tag = &file_protoc_gen_openapiv2_options_annotations_proto_extTypes[4] ) // Extension fields to descriptorpb.FieldOptions. var ( // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. // // All IDs are the same, as assigned. It is okay that they are the same, as they extend // different descriptor messages. // // optional grpc.gateway.protoc_gen_openapiv2.options.JSONSchema openapiv2_field = 1042; E_Openapiv2Field = &file_protoc_gen_openapiv2_options_annotations_proto_extTypes[5] ) var File_protoc_gen_openapiv2_options_annotations_proto protoreflect.FileDescriptor var file_protoc_gen_openapiv2_options_annotations_proto_rawDesc = []byte{ 0x0a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x29, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3a, 0x7e, 0x0a, 0x11, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x5f, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x92, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x52, 0x10, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x3a, 0x86, 0x01, 0x0a, 0x13, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x5f, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x92, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x12, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x7e, 0x0a, 0x10, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x92, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x0f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x3a, 0x7b, 0x0a, 0x0e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x92, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x0d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x45, 0x6e, 0x75, 0x6d, 0x3a, 0x75, 0x0a, 0x0d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x5f, 0x74, 0x61, 0x67, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x92, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x54, 0x61, 0x67, 0x52, 0x0c, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x54, 0x61, 0x67, 0x3a, 0x7e, 0x0a, 0x0f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x92, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4a, 0x53, 0x4f, 0x4e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x0e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var file_protoc_gen_openapiv2_options_annotations_proto_goTypes = []any{ (*descriptorpb.FileOptions)(nil), // 0: google.protobuf.FileOptions (*descriptorpb.MethodOptions)(nil), // 1: google.protobuf.MethodOptions (*descriptorpb.MessageOptions)(nil), // 2: google.protobuf.MessageOptions (*descriptorpb.EnumOptions)(nil), // 3: google.protobuf.EnumOptions (*descriptorpb.ServiceOptions)(nil), // 4: google.protobuf.ServiceOptions (*descriptorpb.FieldOptions)(nil), // 5: google.protobuf.FieldOptions (*Swagger)(nil), // 6: grpc.gateway.protoc_gen_openapiv2.options.Swagger (*Operation)(nil), // 7: grpc.gateway.protoc_gen_openapiv2.options.Operation (*Schema)(nil), // 8: grpc.gateway.protoc_gen_openapiv2.options.Schema (*EnumSchema)(nil), // 9: grpc.gateway.protoc_gen_openapiv2.options.EnumSchema (*Tag)(nil), // 10: grpc.gateway.protoc_gen_openapiv2.options.Tag (*JSONSchema)(nil), // 11: grpc.gateway.protoc_gen_openapiv2.options.JSONSchema } var file_protoc_gen_openapiv2_options_annotations_proto_depIdxs = []int32{ 0, // 0: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger:extendee -> google.protobuf.FileOptions 1, // 1: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation:extendee -> google.protobuf.MethodOptions 2, // 2: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema:extendee -> google.protobuf.MessageOptions 3, // 3: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_enum:extendee -> google.protobuf.EnumOptions 4, // 4: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag:extendee -> google.protobuf.ServiceOptions 5, // 5: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field:extendee -> google.protobuf.FieldOptions 6, // 6: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Swagger 7, // 7: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Operation 8, // 8: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Schema 9, // 9: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_enum:type_name -> grpc.gateway.protoc_gen_openapiv2.options.EnumSchema 10, // 10: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Tag 11, // 11: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field:type_name -> grpc.gateway.protoc_gen_openapiv2.options.JSONSchema 12, // [12:12] is the sub-list for method output_type 12, // [12:12] is the sub-list for method input_type 6, // [6:12] is the sub-list for extension type_name 0, // [0:6] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name } func init() { file_protoc_gen_openapiv2_options_annotations_proto_init() } func file_protoc_gen_openapiv2_options_annotations_proto_init() { if File_protoc_gen_openapiv2_options_annotations_proto != nil { return } file_protoc_gen_openapiv2_options_openapiv2_proto_init() type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_protoc_gen_openapiv2_options_annotations_proto_rawDesc, NumEnums: 0, NumMessages: 0, NumExtensions: 6, NumServices: 0, }, GoTypes: file_protoc_gen_openapiv2_options_annotations_proto_goTypes, DependencyIndexes: file_protoc_gen_openapiv2_options_annotations_proto_depIdxs, ExtensionInfos: file_protoc_gen_openapiv2_options_annotations_proto_extTypes, }.Build() File_protoc_gen_openapiv2_options_annotations_proto = out.File file_protoc_gen_openapiv2_options_annotations_proto_rawDesc = nil file_protoc_gen_openapiv2_options_annotations_proto_goTypes = nil file_protoc_gen_openapiv2_options_annotations_proto_depIdxs = nil } ================================================ FILE: protoc-gen-openapiv2/options/annotations.proto ================================================ syntax = "proto3"; package grpc.gateway.protoc_gen_openapiv2.options; import "google/protobuf/descriptor.proto"; import "protoc-gen-openapiv2/options/openapiv2.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"; extend google.protobuf.FileOptions { // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. // // All IDs are the same, as assigned. It is okay that they are the same, as they extend // different descriptor messages. Swagger openapiv2_swagger = 1042; } extend google.protobuf.MethodOptions { // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. // // All IDs are the same, as assigned. It is okay that they are the same, as they extend // different descriptor messages. Operation openapiv2_operation = 1042; } extend google.protobuf.MessageOptions { // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. // // All IDs are the same, as assigned. It is okay that they are the same, as they extend // different descriptor messages. Schema openapiv2_schema = 1042; } extend google.protobuf.EnumOptions { // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. // // All IDs are the same, as assigned. It is okay that they are the same, as they extend // different descriptor messages. EnumSchema openapiv2_enum = 1042; } extend google.protobuf.ServiceOptions { // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. // // All IDs are the same, as assigned. It is okay that they are the same, as they extend // different descriptor messages. Tag openapiv2_tag = 1042; } extend google.protobuf.FieldOptions { // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. // // All IDs are the same, as assigned. It is okay that they are the same, as they extend // different descriptor messages. JSONSchema openapiv2_field = 1042; } ================================================ FILE: protoc-gen-openapiv2/options/annotations_protoopaque.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.0 // protoc (unknown) // source: protoc-gen-openapiv2/options/annotations.proto //go:build protoopaque package options import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" descriptorpb "google.golang.org/protobuf/types/descriptorpb" reflect "reflect" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) var file_protoc_gen_openapiv2_options_annotations_proto_extTypes = []protoimpl.ExtensionInfo{ { ExtendedType: (*descriptorpb.FileOptions)(nil), ExtensionType: (*Swagger)(nil), Field: 1042, Name: "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger", Tag: "bytes,1042,opt,name=openapiv2_swagger", Filename: "protoc-gen-openapiv2/options/annotations.proto", }, { ExtendedType: (*descriptorpb.MethodOptions)(nil), ExtensionType: (*Operation)(nil), Field: 1042, Name: "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation", Tag: "bytes,1042,opt,name=openapiv2_operation", Filename: "protoc-gen-openapiv2/options/annotations.proto", }, { ExtendedType: (*descriptorpb.MessageOptions)(nil), ExtensionType: (*Schema)(nil), Field: 1042, Name: "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema", Tag: "bytes,1042,opt,name=openapiv2_schema", Filename: "protoc-gen-openapiv2/options/annotations.proto", }, { ExtendedType: (*descriptorpb.EnumOptions)(nil), ExtensionType: (*EnumSchema)(nil), Field: 1042, Name: "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_enum", Tag: "bytes,1042,opt,name=openapiv2_enum", Filename: "protoc-gen-openapiv2/options/annotations.proto", }, { ExtendedType: (*descriptorpb.ServiceOptions)(nil), ExtensionType: (*Tag)(nil), Field: 1042, Name: "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag", Tag: "bytes,1042,opt,name=openapiv2_tag", Filename: "protoc-gen-openapiv2/options/annotations.proto", }, { ExtendedType: (*descriptorpb.FieldOptions)(nil), ExtensionType: (*JSONSchema)(nil), Field: 1042, Name: "grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field", Tag: "bytes,1042,opt,name=openapiv2_field", Filename: "protoc-gen-openapiv2/options/annotations.proto", }, } // Extension fields to descriptorpb.FileOptions. var ( // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. // // All IDs are the same, as assigned. It is okay that they are the same, as they extend // different descriptor messages. // // optional grpc.gateway.protoc_gen_openapiv2.options.Swagger openapiv2_swagger = 1042; E_Openapiv2Swagger = &file_protoc_gen_openapiv2_options_annotations_proto_extTypes[0] ) // Extension fields to descriptorpb.MethodOptions. var ( // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. // // All IDs are the same, as assigned. It is okay that they are the same, as they extend // different descriptor messages. // // optional grpc.gateway.protoc_gen_openapiv2.options.Operation openapiv2_operation = 1042; E_Openapiv2Operation = &file_protoc_gen_openapiv2_options_annotations_proto_extTypes[1] ) // Extension fields to descriptorpb.MessageOptions. var ( // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. // // All IDs are the same, as assigned. It is okay that they are the same, as they extend // different descriptor messages. // // optional grpc.gateway.protoc_gen_openapiv2.options.Schema openapiv2_schema = 1042; E_Openapiv2Schema = &file_protoc_gen_openapiv2_options_annotations_proto_extTypes[2] ) // Extension fields to descriptorpb.EnumOptions. var ( // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. // // All IDs are the same, as assigned. It is okay that they are the same, as they extend // different descriptor messages. // // optional grpc.gateway.protoc_gen_openapiv2.options.EnumSchema openapiv2_enum = 1042; E_Openapiv2Enum = &file_protoc_gen_openapiv2_options_annotations_proto_extTypes[3] ) // Extension fields to descriptorpb.ServiceOptions. var ( // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. // // All IDs are the same, as assigned. It is okay that they are the same, as they extend // different descriptor messages. // // optional grpc.gateway.protoc_gen_openapiv2.options.Tag openapiv2_tag = 1042; E_Openapiv2Tag = &file_protoc_gen_openapiv2_options_annotations_proto_extTypes[4] ) // Extension fields to descriptorpb.FieldOptions. var ( // ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project. // // All IDs are the same, as assigned. It is okay that they are the same, as they extend // different descriptor messages. // // optional grpc.gateway.protoc_gen_openapiv2.options.JSONSchema openapiv2_field = 1042; E_Openapiv2Field = &file_protoc_gen_openapiv2_options_annotations_proto_extTypes[5] ) var File_protoc_gen_openapiv2_options_annotations_proto protoreflect.FileDescriptor var file_protoc_gen_openapiv2_options_annotations_proto_rawDesc = []byte{ 0x0a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x29, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3a, 0x7e, 0x0a, 0x11, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x5f, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x92, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x52, 0x10, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x3a, 0x86, 0x01, 0x0a, 0x13, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x5f, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x92, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x12, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x7e, 0x0a, 0x10, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x92, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x0f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x3a, 0x7b, 0x0a, 0x0e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x92, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x0d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x45, 0x6e, 0x75, 0x6d, 0x3a, 0x75, 0x0a, 0x0d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x5f, 0x74, 0x61, 0x67, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x92, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x54, 0x61, 0x67, 0x52, 0x0c, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x54, 0x61, 0x67, 0x3a, 0x7e, 0x0a, 0x0f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x92, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4a, 0x53, 0x4f, 0x4e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x0e, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var file_protoc_gen_openapiv2_options_annotations_proto_goTypes = []any{ (*descriptorpb.FileOptions)(nil), // 0: google.protobuf.FileOptions (*descriptorpb.MethodOptions)(nil), // 1: google.protobuf.MethodOptions (*descriptorpb.MessageOptions)(nil), // 2: google.protobuf.MessageOptions (*descriptorpb.EnumOptions)(nil), // 3: google.protobuf.EnumOptions (*descriptorpb.ServiceOptions)(nil), // 4: google.protobuf.ServiceOptions (*descriptorpb.FieldOptions)(nil), // 5: google.protobuf.FieldOptions (*Swagger)(nil), // 6: grpc.gateway.protoc_gen_openapiv2.options.Swagger (*Operation)(nil), // 7: grpc.gateway.protoc_gen_openapiv2.options.Operation (*Schema)(nil), // 8: grpc.gateway.protoc_gen_openapiv2.options.Schema (*EnumSchema)(nil), // 9: grpc.gateway.protoc_gen_openapiv2.options.EnumSchema (*Tag)(nil), // 10: grpc.gateway.protoc_gen_openapiv2.options.Tag (*JSONSchema)(nil), // 11: grpc.gateway.protoc_gen_openapiv2.options.JSONSchema } var file_protoc_gen_openapiv2_options_annotations_proto_depIdxs = []int32{ 0, // 0: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger:extendee -> google.protobuf.FileOptions 1, // 1: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation:extendee -> google.protobuf.MethodOptions 2, // 2: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema:extendee -> google.protobuf.MessageOptions 3, // 3: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_enum:extendee -> google.protobuf.EnumOptions 4, // 4: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag:extendee -> google.protobuf.ServiceOptions 5, // 5: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field:extendee -> google.protobuf.FieldOptions 6, // 6: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Swagger 7, // 7: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Operation 8, // 8: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Schema 9, // 9: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_enum:type_name -> grpc.gateway.protoc_gen_openapiv2.options.EnumSchema 10, // 10: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Tag 11, // 11: grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field:type_name -> grpc.gateway.protoc_gen_openapiv2.options.JSONSchema 12, // [12:12] is the sub-list for method output_type 12, // [12:12] is the sub-list for method input_type 6, // [6:12] is the sub-list for extension type_name 0, // [0:6] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name } func init() { file_protoc_gen_openapiv2_options_annotations_proto_init() } func file_protoc_gen_openapiv2_options_annotations_proto_init() { if File_protoc_gen_openapiv2_options_annotations_proto != nil { return } file_protoc_gen_openapiv2_options_openapiv2_proto_init() type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_protoc_gen_openapiv2_options_annotations_proto_rawDesc, NumEnums: 0, NumMessages: 0, NumExtensions: 6, NumServices: 0, }, GoTypes: file_protoc_gen_openapiv2_options_annotations_proto_goTypes, DependencyIndexes: file_protoc_gen_openapiv2_options_annotations_proto_depIdxs, ExtensionInfos: file_protoc_gen_openapiv2_options_annotations_proto_extTypes, }.Build() File_protoc_gen_openapiv2_options_annotations_proto = out.File file_protoc_gen_openapiv2_options_annotations_proto_rawDesc = nil file_protoc_gen_openapiv2_options_annotations_proto_goTypes = nil file_protoc_gen_openapiv2_options_annotations_proto_depIdxs = nil } ================================================ FILE: protoc-gen-openapiv2/options/buf.gen.yaml ================================================ version: v2 plugins: - remote: buf.build/protocolbuffers/go:v1.36.0 out: . opt: - paths=source_relative - default_api_level=API_HYBRID ================================================ FILE: protoc-gen-openapiv2/options/openapiv2.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.0 // protoc (unknown) // source: protoc-gen-openapiv2/options/openapiv2.proto //go:build !protoopaque package options import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" structpb "google.golang.org/protobuf/types/known/structpb" reflect "reflect" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) // Scheme describes the schemes supported by the OpenAPI Swagger // and Operation objects. type Scheme int32 const ( Scheme_UNKNOWN Scheme = 0 Scheme_HTTP Scheme = 1 Scheme_HTTPS Scheme = 2 Scheme_WS Scheme = 3 Scheme_WSS Scheme = 4 ) // Enum value maps for Scheme. var ( Scheme_name = map[int32]string{ 0: "UNKNOWN", 1: "HTTP", 2: "HTTPS", 3: "WS", 4: "WSS", } Scheme_value = map[string]int32{ "UNKNOWN": 0, "HTTP": 1, "HTTPS": 2, "WS": 3, "WSS": 4, } ) func (x Scheme) Enum() *Scheme { p := new(Scheme) *p = x return p } func (x Scheme) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (Scheme) Descriptor() protoreflect.EnumDescriptor { return file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[0].Descriptor() } func (Scheme) Type() protoreflect.EnumType { return &file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[0] } func (x Scheme) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // `Type` is a supported HTTP header type. // See https://swagger.io/specification/v2/#parameterType. type HeaderParameter_Type int32 const ( HeaderParameter_UNKNOWN HeaderParameter_Type = 0 HeaderParameter_STRING HeaderParameter_Type = 1 HeaderParameter_NUMBER HeaderParameter_Type = 2 HeaderParameter_INTEGER HeaderParameter_Type = 3 HeaderParameter_BOOLEAN HeaderParameter_Type = 4 ) // Enum value maps for HeaderParameter_Type. var ( HeaderParameter_Type_name = map[int32]string{ 0: "UNKNOWN", 1: "STRING", 2: "NUMBER", 3: "INTEGER", 4: "BOOLEAN", } HeaderParameter_Type_value = map[string]int32{ "UNKNOWN": 0, "STRING": 1, "NUMBER": 2, "INTEGER": 3, "BOOLEAN": 4, } ) func (x HeaderParameter_Type) Enum() *HeaderParameter_Type { p := new(HeaderParameter_Type) *p = x return p } func (x HeaderParameter_Type) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (HeaderParameter_Type) Descriptor() protoreflect.EnumDescriptor { return file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[1].Descriptor() } func (HeaderParameter_Type) Type() protoreflect.EnumType { return &file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[1] } func (x HeaderParameter_Type) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } type JSONSchema_JSONSchemaSimpleTypes int32 const ( JSONSchema_UNKNOWN JSONSchema_JSONSchemaSimpleTypes = 0 JSONSchema_ARRAY JSONSchema_JSONSchemaSimpleTypes = 1 JSONSchema_BOOLEAN JSONSchema_JSONSchemaSimpleTypes = 2 JSONSchema_INTEGER JSONSchema_JSONSchemaSimpleTypes = 3 JSONSchema_NULL JSONSchema_JSONSchemaSimpleTypes = 4 JSONSchema_NUMBER JSONSchema_JSONSchemaSimpleTypes = 5 JSONSchema_OBJECT JSONSchema_JSONSchemaSimpleTypes = 6 JSONSchema_STRING JSONSchema_JSONSchemaSimpleTypes = 7 ) // Enum value maps for JSONSchema_JSONSchemaSimpleTypes. var ( JSONSchema_JSONSchemaSimpleTypes_name = map[int32]string{ 0: "UNKNOWN", 1: "ARRAY", 2: "BOOLEAN", 3: "INTEGER", 4: "NULL", 5: "NUMBER", 6: "OBJECT", 7: "STRING", } JSONSchema_JSONSchemaSimpleTypes_value = map[string]int32{ "UNKNOWN": 0, "ARRAY": 1, "BOOLEAN": 2, "INTEGER": 3, "NULL": 4, "NUMBER": 5, "OBJECT": 6, "STRING": 7, } ) func (x JSONSchema_JSONSchemaSimpleTypes) Enum() *JSONSchema_JSONSchemaSimpleTypes { p := new(JSONSchema_JSONSchemaSimpleTypes) *p = x return p } func (x JSONSchema_JSONSchemaSimpleTypes) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (JSONSchema_JSONSchemaSimpleTypes) Descriptor() protoreflect.EnumDescriptor { return file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[2].Descriptor() } func (JSONSchema_JSONSchemaSimpleTypes) Type() protoreflect.EnumType { return &file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[2] } func (x JSONSchema_JSONSchemaSimpleTypes) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // The type of the security scheme. Valid values are "basic", // "apiKey" or "oauth2". type SecurityScheme_Type int32 const ( SecurityScheme_TYPE_INVALID SecurityScheme_Type = 0 SecurityScheme_TYPE_BASIC SecurityScheme_Type = 1 SecurityScheme_TYPE_API_KEY SecurityScheme_Type = 2 SecurityScheme_TYPE_OAUTH2 SecurityScheme_Type = 3 ) // Enum value maps for SecurityScheme_Type. var ( SecurityScheme_Type_name = map[int32]string{ 0: "TYPE_INVALID", 1: "TYPE_BASIC", 2: "TYPE_API_KEY", 3: "TYPE_OAUTH2", } SecurityScheme_Type_value = map[string]int32{ "TYPE_INVALID": 0, "TYPE_BASIC": 1, "TYPE_API_KEY": 2, "TYPE_OAUTH2": 3, } ) func (x SecurityScheme_Type) Enum() *SecurityScheme_Type { p := new(SecurityScheme_Type) *p = x return p } func (x SecurityScheme_Type) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (SecurityScheme_Type) Descriptor() protoreflect.EnumDescriptor { return file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[3].Descriptor() } func (SecurityScheme_Type) Type() protoreflect.EnumType { return &file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[3] } func (x SecurityScheme_Type) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // The location of the API key. Valid values are "query" or "header". type SecurityScheme_In int32 const ( SecurityScheme_IN_INVALID SecurityScheme_In = 0 SecurityScheme_IN_QUERY SecurityScheme_In = 1 SecurityScheme_IN_HEADER SecurityScheme_In = 2 ) // Enum value maps for SecurityScheme_In. var ( SecurityScheme_In_name = map[int32]string{ 0: "IN_INVALID", 1: "IN_QUERY", 2: "IN_HEADER", } SecurityScheme_In_value = map[string]int32{ "IN_INVALID": 0, "IN_QUERY": 1, "IN_HEADER": 2, } ) func (x SecurityScheme_In) Enum() *SecurityScheme_In { p := new(SecurityScheme_In) *p = x return p } func (x SecurityScheme_In) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (SecurityScheme_In) Descriptor() protoreflect.EnumDescriptor { return file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[4].Descriptor() } func (SecurityScheme_In) Type() protoreflect.EnumType { return &file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[4] } func (x SecurityScheme_In) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // The flow used by the OAuth2 security scheme. Valid values are // "implicit", "password", "application" or "accessCode". type SecurityScheme_Flow int32 const ( SecurityScheme_FLOW_INVALID SecurityScheme_Flow = 0 SecurityScheme_FLOW_IMPLICIT SecurityScheme_Flow = 1 SecurityScheme_FLOW_PASSWORD SecurityScheme_Flow = 2 SecurityScheme_FLOW_APPLICATION SecurityScheme_Flow = 3 SecurityScheme_FLOW_ACCESS_CODE SecurityScheme_Flow = 4 ) // Enum value maps for SecurityScheme_Flow. var ( SecurityScheme_Flow_name = map[int32]string{ 0: "FLOW_INVALID", 1: "FLOW_IMPLICIT", 2: "FLOW_PASSWORD", 3: "FLOW_APPLICATION", 4: "FLOW_ACCESS_CODE", } SecurityScheme_Flow_value = map[string]int32{ "FLOW_INVALID": 0, "FLOW_IMPLICIT": 1, "FLOW_PASSWORD": 2, "FLOW_APPLICATION": 3, "FLOW_ACCESS_CODE": 4, } ) func (x SecurityScheme_Flow) Enum() *SecurityScheme_Flow { p := new(SecurityScheme_Flow) *p = x return p } func (x SecurityScheme_Flow) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (SecurityScheme_Flow) Descriptor() protoreflect.EnumDescriptor { return file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[5].Descriptor() } func (SecurityScheme_Flow) Type() protoreflect.EnumType { return &file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[5] } func (x SecurityScheme_Flow) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // `Swagger` is a representation of OpenAPI v2 specification's Swagger object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#swaggerObject // // Example: // // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { // info: { // title: "Echo API"; // version: "1.0"; // description: ""; // contact: { // name: "gRPC-Gateway project"; // url: "https://github.com/grpc-ecosystem/grpc-gateway"; // email: "none@example.com"; // }; // license: { // name: "BSD 3-Clause License"; // url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE"; // }; // }; // schemes: HTTPS; // consumes: "application/json"; // produces: "application/json"; // }; type Swagger struct { state protoimpl.MessageState `protogen:"hybrid.v1"` // Specifies the OpenAPI Specification version being used. It can be // used by the OpenAPI UI and other clients to interpret the API listing. The // value MUST be "2.0". Swagger string `protobuf:"bytes,1,opt,name=swagger,proto3" json:"swagger,omitempty"` // Provides metadata about the API. The metadata can be used by the // clients if needed. Info *Info `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` // The host (name or ip) serving the API. This MUST be the host only and does // not include the scheme nor sub-paths. It MAY include a port. If the host is // not included, the host serving the documentation is to be used (including // the port). The host does not support path templating. Host string `protobuf:"bytes,3,opt,name=host,proto3" json:"host,omitempty"` // The base path on which the API is served, which is relative to the host. If // it is not included, the API is served directly under the host. The value // MUST start with a leading slash (/). The basePath does not support path // templating. // Note that using `base_path` does not change the endpoint paths that are // generated in the resulting OpenAPI file. If you wish to use `base_path` // with relatively generated OpenAPI paths, the `base_path` prefix must be // manually removed from your `google.api.http` paths and your code changed to // serve the API from the `base_path`. BasePath string `protobuf:"bytes,4,opt,name=base_path,json=basePath,proto3" json:"base_path,omitempty"` // The transfer protocol of the API. Values MUST be from the list: "http", // "https", "ws", "wss". If the schemes is not included, the default scheme to // be used is the one used to access the OpenAPI definition itself. Schemes []Scheme `protobuf:"varint,5,rep,packed,name=schemes,proto3,enum=grpc.gateway.protoc_gen_openapiv2.options.Scheme" json:"schemes,omitempty"` // A list of MIME types the APIs can consume. This is global to all APIs but // can be overridden on specific API calls. Value MUST be as described under // Mime Types. Consumes []string `protobuf:"bytes,6,rep,name=consumes,proto3" json:"consumes,omitempty"` // A list of MIME types the APIs can produce. This is global to all APIs but // can be overridden on specific API calls. Value MUST be as described under // Mime Types. Produces []string `protobuf:"bytes,7,rep,name=produces,proto3" json:"produces,omitempty"` // An object to hold responses that can be used across operations. This // property does not define global responses for all operations. Responses map[string]*Response `protobuf:"bytes,10,rep,name=responses,proto3" json:"responses,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // Security scheme definitions that can be used across the specification. SecurityDefinitions *SecurityDefinitions `protobuf:"bytes,11,opt,name=security_definitions,json=securityDefinitions,proto3" json:"security_definitions,omitempty"` // A declaration of which security schemes are applied for the API as a whole. // The list of values describes alternative security schemes that can be used // (that is, there is a logical OR between the security requirements). // Individual operations can override this definition. Security []*SecurityRequirement `protobuf:"bytes,12,rep,name=security,proto3" json:"security,omitempty"` // A list of tags for API documentation control. Tags can be used for logical // grouping of operations by resources or any other qualifier. Tags []*Tag `protobuf:"bytes,13,rep,name=tags,proto3" json:"tags,omitempty"` // Additional external documentation. ExternalDocs *ExternalDocumentation `protobuf:"bytes,14,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value `protobuf:"bytes,15,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Swagger) Reset() { *x = Swagger{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Swagger) String() string { return protoimpl.X.MessageStringOf(x) } func (*Swagger) ProtoMessage() {} func (x *Swagger) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *Swagger) GetSwagger() string { if x != nil { return x.Swagger } return "" } func (x *Swagger) GetInfo() *Info { if x != nil { return x.Info } return nil } func (x *Swagger) GetHost() string { if x != nil { return x.Host } return "" } func (x *Swagger) GetBasePath() string { if x != nil { return x.BasePath } return "" } func (x *Swagger) GetSchemes() []Scheme { if x != nil { return x.Schemes } return nil } func (x *Swagger) GetConsumes() []string { if x != nil { return x.Consumes } return nil } func (x *Swagger) GetProduces() []string { if x != nil { return x.Produces } return nil } func (x *Swagger) GetResponses() map[string]*Response { if x != nil { return x.Responses } return nil } func (x *Swagger) GetSecurityDefinitions() *SecurityDefinitions { if x != nil { return x.SecurityDefinitions } return nil } func (x *Swagger) GetSecurity() []*SecurityRequirement { if x != nil { return x.Security } return nil } func (x *Swagger) GetTags() []*Tag { if x != nil { return x.Tags } return nil } func (x *Swagger) GetExternalDocs() *ExternalDocumentation { if x != nil { return x.ExternalDocs } return nil } func (x *Swagger) GetExtensions() map[string]*structpb.Value { if x != nil { return x.Extensions } return nil } func (x *Swagger) SetSwagger(v string) { x.Swagger = v } func (x *Swagger) SetInfo(v *Info) { x.Info = v } func (x *Swagger) SetHost(v string) { x.Host = v } func (x *Swagger) SetBasePath(v string) { x.BasePath = v } func (x *Swagger) SetSchemes(v []Scheme) { x.Schemes = v } func (x *Swagger) SetConsumes(v []string) { x.Consumes = v } func (x *Swagger) SetProduces(v []string) { x.Produces = v } func (x *Swagger) SetResponses(v map[string]*Response) { x.Responses = v } func (x *Swagger) SetSecurityDefinitions(v *SecurityDefinitions) { x.SecurityDefinitions = v } func (x *Swagger) SetSecurity(v []*SecurityRequirement) { x.Security = v } func (x *Swagger) SetTags(v []*Tag) { x.Tags = v } func (x *Swagger) SetExternalDocs(v *ExternalDocumentation) { x.ExternalDocs = v } func (x *Swagger) SetExtensions(v map[string]*structpb.Value) { x.Extensions = v } func (x *Swagger) HasInfo() bool { if x == nil { return false } return x.Info != nil } func (x *Swagger) HasSecurityDefinitions() bool { if x == nil { return false } return x.SecurityDefinitions != nil } func (x *Swagger) HasExternalDocs() bool { if x == nil { return false } return x.ExternalDocs != nil } func (x *Swagger) ClearInfo() { x.Info = nil } func (x *Swagger) ClearSecurityDefinitions() { x.SecurityDefinitions = nil } func (x *Swagger) ClearExternalDocs() { x.ExternalDocs = nil } type Swagger_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // Specifies the OpenAPI Specification version being used. It can be // used by the OpenAPI UI and other clients to interpret the API listing. The // value MUST be "2.0". Swagger string // Provides metadata about the API. The metadata can be used by the // clients if needed. Info *Info // The host (name or ip) serving the API. This MUST be the host only and does // not include the scheme nor sub-paths. It MAY include a port. If the host is // not included, the host serving the documentation is to be used (including // the port). The host does not support path templating. Host string // The base path on which the API is served, which is relative to the host. If // it is not included, the API is served directly under the host. The value // MUST start with a leading slash (/). The basePath does not support path // templating. // Note that using `base_path` does not change the endpoint paths that are // generated in the resulting OpenAPI file. If you wish to use `base_path` // with relatively generated OpenAPI paths, the `base_path` prefix must be // manually removed from your `google.api.http` paths and your code changed to // serve the API from the `base_path`. BasePath string // The transfer protocol of the API. Values MUST be from the list: "http", // "https", "ws", "wss". If the schemes is not included, the default scheme to // be used is the one used to access the OpenAPI definition itself. Schemes []Scheme // A list of MIME types the APIs can consume. This is global to all APIs but // can be overridden on specific API calls. Value MUST be as described under // Mime Types. Consumes []string // A list of MIME types the APIs can produce. This is global to all APIs but // can be overridden on specific API calls. Value MUST be as described under // Mime Types. Produces []string // An object to hold responses that can be used across operations. This // property does not define global responses for all operations. Responses map[string]*Response // Security scheme definitions that can be used across the specification. SecurityDefinitions *SecurityDefinitions // A declaration of which security schemes are applied for the API as a whole. // The list of values describes alternative security schemes that can be used // (that is, there is a logical OR between the security requirements). // Individual operations can override this definition. Security []*SecurityRequirement // A list of tags for API documentation control. Tags can be used for logical // grouping of operations by resources or any other qualifier. Tags []*Tag // Additional external documentation. ExternalDocs *ExternalDocumentation // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value } func (b0 Swagger_builder) Build() *Swagger { m0 := &Swagger{} b, x := &b0, m0 _, _ = b, x x.Swagger = b.Swagger x.Info = b.Info x.Host = b.Host x.BasePath = b.BasePath x.Schemes = b.Schemes x.Consumes = b.Consumes x.Produces = b.Produces x.Responses = b.Responses x.SecurityDefinitions = b.SecurityDefinitions x.Security = b.Security x.Tags = b.Tags x.ExternalDocs = b.ExternalDocs x.Extensions = b.Extensions return m0 } // `Operation` is a representation of OpenAPI v2 specification's Operation object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#operationObject // // Example: // // service EchoService { // rpc Echo(SimpleMessage) returns (SimpleMessage) { // option (google.api.http) = { // get: "/v1/example/echo/{id}" // }; // // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { // summary: "Get a message."; // operation_id: "getMessage"; // tags: "echo"; // responses: { // key: "200" // value: { // description: "OK"; // } // } // }; // } // } type Operation struct { state protoimpl.MessageState `protogen:"hybrid.v1"` // A list of tags for API documentation control. Tags can be used for logical // grouping of operations by resources or any other qualifier. Tags []string `protobuf:"bytes,1,rep,name=tags,proto3" json:"tags,omitempty"` // A short summary of what the operation does. For maximum readability in the // swagger-ui, this field SHOULD be less than 120 characters. Summary string `protobuf:"bytes,2,opt,name=summary,proto3" json:"summary,omitempty"` // A verbose explanation of the operation behavior. GFM syntax can be used for // rich text representation. Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` // Additional external documentation for this operation. ExternalDocs *ExternalDocumentation `protobuf:"bytes,4,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` // Unique string used to identify the operation. The id MUST be unique among // all operations described in the API. Tools and libraries MAY use the // operationId to uniquely identify an operation, therefore, it is recommended // to follow common programming naming conventions. OperationId string `protobuf:"bytes,5,opt,name=operation_id,json=operationId,proto3" json:"operation_id,omitempty"` // A list of MIME types the operation can consume. This overrides the consumes // definition at the OpenAPI Object. An empty value MAY be used to clear the // global definition. Value MUST be as described under Mime Types. Consumes []string `protobuf:"bytes,6,rep,name=consumes,proto3" json:"consumes,omitempty"` // A list of MIME types the operation can produce. This overrides the produces // definition at the OpenAPI Object. An empty value MAY be used to clear the // global definition. Value MUST be as described under Mime Types. Produces []string `protobuf:"bytes,7,rep,name=produces,proto3" json:"produces,omitempty"` // The list of possible responses as they are returned from executing this // operation. Responses map[string]*Response `protobuf:"bytes,9,rep,name=responses,proto3" json:"responses,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // The transfer protocol for the operation. Values MUST be from the list: // "http", "https", "ws", "wss". The value overrides the OpenAPI Object // schemes definition. Schemes []Scheme `protobuf:"varint,10,rep,packed,name=schemes,proto3,enum=grpc.gateway.protoc_gen_openapiv2.options.Scheme" json:"schemes,omitempty"` // Declares this operation to be deprecated. Usage of the declared operation // should be refrained. Default value is false. Deprecated bool `protobuf:"varint,11,opt,name=deprecated,proto3" json:"deprecated,omitempty"` // A declaration of which security schemes are applied for this operation. The // list of values describes alternative security schemes that can be used // (that is, there is a logical OR between the security requirements). This // definition overrides any declared top-level security. To remove a top-level // security declaration, an empty array can be used. Security []*SecurityRequirement `protobuf:"bytes,12,rep,name=security,proto3" json:"security,omitempty"` // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value `protobuf:"bytes,13,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // Custom parameters such as HTTP request headers. // See: https://swagger.io/docs/specification/2-0/describing-parameters/ // and https://swagger.io/specification/v2/#parameter-object. Parameters *Parameters `protobuf:"bytes,14,opt,name=parameters,proto3" json:"parameters,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Operation) Reset() { *x = Operation{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Operation) String() string { return protoimpl.X.MessageStringOf(x) } func (*Operation) ProtoMessage() {} func (x *Operation) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *Operation) GetTags() []string { if x != nil { return x.Tags } return nil } func (x *Operation) GetSummary() string { if x != nil { return x.Summary } return "" } func (x *Operation) GetDescription() string { if x != nil { return x.Description } return "" } func (x *Operation) GetExternalDocs() *ExternalDocumentation { if x != nil { return x.ExternalDocs } return nil } func (x *Operation) GetOperationId() string { if x != nil { return x.OperationId } return "" } func (x *Operation) GetConsumes() []string { if x != nil { return x.Consumes } return nil } func (x *Operation) GetProduces() []string { if x != nil { return x.Produces } return nil } func (x *Operation) GetResponses() map[string]*Response { if x != nil { return x.Responses } return nil } func (x *Operation) GetSchemes() []Scheme { if x != nil { return x.Schemes } return nil } func (x *Operation) GetDeprecated() bool { if x != nil { return x.Deprecated } return false } func (x *Operation) GetSecurity() []*SecurityRequirement { if x != nil { return x.Security } return nil } func (x *Operation) GetExtensions() map[string]*structpb.Value { if x != nil { return x.Extensions } return nil } func (x *Operation) GetParameters() *Parameters { if x != nil { return x.Parameters } return nil } func (x *Operation) SetTags(v []string) { x.Tags = v } func (x *Operation) SetSummary(v string) { x.Summary = v } func (x *Operation) SetDescription(v string) { x.Description = v } func (x *Operation) SetExternalDocs(v *ExternalDocumentation) { x.ExternalDocs = v } func (x *Operation) SetOperationId(v string) { x.OperationId = v } func (x *Operation) SetConsumes(v []string) { x.Consumes = v } func (x *Operation) SetProduces(v []string) { x.Produces = v } func (x *Operation) SetResponses(v map[string]*Response) { x.Responses = v } func (x *Operation) SetSchemes(v []Scheme) { x.Schemes = v } func (x *Operation) SetDeprecated(v bool) { x.Deprecated = v } func (x *Operation) SetSecurity(v []*SecurityRequirement) { x.Security = v } func (x *Operation) SetExtensions(v map[string]*structpb.Value) { x.Extensions = v } func (x *Operation) SetParameters(v *Parameters) { x.Parameters = v } func (x *Operation) HasExternalDocs() bool { if x == nil { return false } return x.ExternalDocs != nil } func (x *Operation) HasParameters() bool { if x == nil { return false } return x.Parameters != nil } func (x *Operation) ClearExternalDocs() { x.ExternalDocs = nil } func (x *Operation) ClearParameters() { x.Parameters = nil } type Operation_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // A list of tags for API documentation control. Tags can be used for logical // grouping of operations by resources or any other qualifier. Tags []string // A short summary of what the operation does. For maximum readability in the // swagger-ui, this field SHOULD be less than 120 characters. Summary string // A verbose explanation of the operation behavior. GFM syntax can be used for // rich text representation. Description string // Additional external documentation for this operation. ExternalDocs *ExternalDocumentation // Unique string used to identify the operation. The id MUST be unique among // all operations described in the API. Tools and libraries MAY use the // operationId to uniquely identify an operation, therefore, it is recommended // to follow common programming naming conventions. OperationId string // A list of MIME types the operation can consume. This overrides the consumes // definition at the OpenAPI Object. An empty value MAY be used to clear the // global definition. Value MUST be as described under Mime Types. Consumes []string // A list of MIME types the operation can produce. This overrides the produces // definition at the OpenAPI Object. An empty value MAY be used to clear the // global definition. Value MUST be as described under Mime Types. Produces []string // The list of possible responses as they are returned from executing this // operation. Responses map[string]*Response // The transfer protocol for the operation. Values MUST be from the list: // "http", "https", "ws", "wss". The value overrides the OpenAPI Object // schemes definition. Schemes []Scheme // Declares this operation to be deprecated. Usage of the declared operation // should be refrained. Default value is false. Deprecated bool // A declaration of which security schemes are applied for this operation. The // list of values describes alternative security schemes that can be used // (that is, there is a logical OR between the security requirements). This // definition overrides any declared top-level security. To remove a top-level // security declaration, an empty array can be used. Security []*SecurityRequirement // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value // Custom parameters such as HTTP request headers. // See: https://swagger.io/docs/specification/2-0/describing-parameters/ // and https://swagger.io/specification/v2/#parameter-object. Parameters *Parameters } func (b0 Operation_builder) Build() *Operation { m0 := &Operation{} b, x := &b0, m0 _, _ = b, x x.Tags = b.Tags x.Summary = b.Summary x.Description = b.Description x.ExternalDocs = b.ExternalDocs x.OperationId = b.OperationId x.Consumes = b.Consumes x.Produces = b.Produces x.Responses = b.Responses x.Schemes = b.Schemes x.Deprecated = b.Deprecated x.Security = b.Security x.Extensions = b.Extensions x.Parameters = b.Parameters return m0 } // `Parameters` is a representation of OpenAPI v2 specification's parameters object. // Note: This technically breaks compatibility with the OpenAPI 2 definition structure as we only // allow header parameters to be set here since we do not want users specifying custom non-header // parameters beyond those inferred from the Protobuf schema. // See: https://swagger.io/specification/v2/#parameter-object type Parameters struct { state protoimpl.MessageState `protogen:"hybrid.v1"` // `Headers` is one or more HTTP header parameter. // See: https://swagger.io/docs/specification/2-0/describing-parameters/#header-parameters Headers []*HeaderParameter `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Parameters) Reset() { *x = Parameters{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Parameters) String() string { return protoimpl.X.MessageStringOf(x) } func (*Parameters) ProtoMessage() {} func (x *Parameters) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *Parameters) GetHeaders() []*HeaderParameter { if x != nil { return x.Headers } return nil } func (x *Parameters) SetHeaders(v []*HeaderParameter) { x.Headers = v } type Parameters_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // `Headers` is one or more HTTP header parameter. // See: https://swagger.io/docs/specification/2-0/describing-parameters/#header-parameters Headers []*HeaderParameter } func (b0 Parameters_builder) Build() *Parameters { m0 := &Parameters{} b, x := &b0, m0 _, _ = b, x x.Headers = b.Headers return m0 } // `HeaderParameter` a HTTP header parameter. // See: https://swagger.io/specification/v2/#parameter-object type HeaderParameter struct { state protoimpl.MessageState `protogen:"hybrid.v1"` // `Name` is the header name. Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // `Description` is a short description of the header. Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` // `Type` is the type of the object. The value MUST be one of "string", "number", "integer", or "boolean". The "array" type is not supported. // See: https://swagger.io/specification/v2/#parameterType. Type HeaderParameter_Type `protobuf:"varint,3,opt,name=type,proto3,enum=grpc.gateway.protoc_gen_openapiv2.options.HeaderParameter_Type" json:"type,omitempty"` // `Format` The extending format for the previously mentioned type. Format string `protobuf:"bytes,4,opt,name=format,proto3" json:"format,omitempty"` // `Required` indicates if the header is optional Required bool `protobuf:"varint,5,opt,name=required,proto3" json:"required,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *HeaderParameter) Reset() { *x = HeaderParameter{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *HeaderParameter) String() string { return protoimpl.X.MessageStringOf(x) } func (*HeaderParameter) ProtoMessage() {} func (x *HeaderParameter) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *HeaderParameter) GetName() string { if x != nil { return x.Name } return "" } func (x *HeaderParameter) GetDescription() string { if x != nil { return x.Description } return "" } func (x *HeaderParameter) GetType() HeaderParameter_Type { if x != nil { return x.Type } return HeaderParameter_UNKNOWN } func (x *HeaderParameter) GetFormat() string { if x != nil { return x.Format } return "" } func (x *HeaderParameter) GetRequired() bool { if x != nil { return x.Required } return false } func (x *HeaderParameter) SetName(v string) { x.Name = v } func (x *HeaderParameter) SetDescription(v string) { x.Description = v } func (x *HeaderParameter) SetType(v HeaderParameter_Type) { x.Type = v } func (x *HeaderParameter) SetFormat(v string) { x.Format = v } func (x *HeaderParameter) SetRequired(v bool) { x.Required = v } type HeaderParameter_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // `Name` is the header name. Name string // `Description` is a short description of the header. Description string // `Type` is the type of the object. The value MUST be one of "string", "number", "integer", or "boolean". The "array" type is not supported. // See: https://swagger.io/specification/v2/#parameterType. Type HeaderParameter_Type // `Format` The extending format for the previously mentioned type. Format string // `Required` indicates if the header is optional Required bool } func (b0 HeaderParameter_builder) Build() *HeaderParameter { m0 := &HeaderParameter{} b, x := &b0, m0 _, _ = b, x x.Name = b.Name x.Description = b.Description x.Type = b.Type x.Format = b.Format x.Required = b.Required return m0 } // `Header` is a representation of OpenAPI v2 specification's Header object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#headerObject type Header struct { state protoimpl.MessageState `protogen:"hybrid.v1"` // `Description` is a short description of the header. Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` // The type of the object. The value MUST be one of "string", "number", "integer", or "boolean". The "array" type is not supported. Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` // `Format` The extending format for the previously mentioned type. Format string `protobuf:"bytes,3,opt,name=format,proto3" json:"format,omitempty"` // `Default` Declares the value of the header that the server will use if none is provided. // See: https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-6.2. // Unlike JSON Schema this value MUST conform to the defined type for the header. Default string `protobuf:"bytes,6,opt,name=default,proto3" json:"default,omitempty"` // 'Pattern' See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.2.3. Pattern string `protobuf:"bytes,13,opt,name=pattern,proto3" json:"pattern,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Header) Reset() { *x = Header{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Header) String() string { return protoimpl.X.MessageStringOf(x) } func (*Header) ProtoMessage() {} func (x *Header) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *Header) GetDescription() string { if x != nil { return x.Description } return "" } func (x *Header) GetType() string { if x != nil { return x.Type } return "" } func (x *Header) GetFormat() string { if x != nil { return x.Format } return "" } func (x *Header) GetDefault() string { if x != nil { return x.Default } return "" } func (x *Header) GetPattern() string { if x != nil { return x.Pattern } return "" } func (x *Header) SetDescription(v string) { x.Description = v } func (x *Header) SetType(v string) { x.Type = v } func (x *Header) SetFormat(v string) { x.Format = v } func (x *Header) SetDefault(v string) { x.Default = v } func (x *Header) SetPattern(v string) { x.Pattern = v } type Header_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // `Description` is a short description of the header. Description string // The type of the object. The value MUST be one of "string", "number", "integer", or "boolean". The "array" type is not supported. Type string // `Format` The extending format for the previously mentioned type. Format string // `Default` Declares the value of the header that the server will use if none is provided. // See: https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-6.2. // Unlike JSON Schema this value MUST conform to the defined type for the header. Default string // 'Pattern' See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.2.3. Pattern string } func (b0 Header_builder) Build() *Header { m0 := &Header{} b, x := &b0, m0 _, _ = b, x x.Description = b.Description x.Type = b.Type x.Format = b.Format x.Default = b.Default x.Pattern = b.Pattern return m0 } // `Response` is a representation of OpenAPI v2 specification's Response object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#responseObject type Response struct { state protoimpl.MessageState `protogen:"hybrid.v1"` // `Description` is a short description of the response. // GFM syntax can be used for rich text representation. Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` // `Schema` optionally defines the structure of the response. // If `Schema` is not provided, it means there is no content to the response. Schema *Schema `protobuf:"bytes,2,opt,name=schema,proto3" json:"schema,omitempty"` // `Headers` A list of headers that are sent with the response. // `Header` name is expected to be a string in the canonical format of the MIME header key // See: https://golang.org/pkg/net/textproto/#CanonicalMIMEHeaderKey Headers map[string]*Header `protobuf:"bytes,3,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // `Examples` gives per-mimetype response examples. // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#example-object Examples map[string]string `protobuf:"bytes,4,rep,name=examples,proto3" json:"examples,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value `protobuf:"bytes,5,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Response) Reset() { *x = Response{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Response) String() string { return protoimpl.X.MessageStringOf(x) } func (*Response) ProtoMessage() {} func (x *Response) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *Response) GetDescription() string { if x != nil { return x.Description } return "" } func (x *Response) GetSchema() *Schema { if x != nil { return x.Schema } return nil } func (x *Response) GetHeaders() map[string]*Header { if x != nil { return x.Headers } return nil } func (x *Response) GetExamples() map[string]string { if x != nil { return x.Examples } return nil } func (x *Response) GetExtensions() map[string]*structpb.Value { if x != nil { return x.Extensions } return nil } func (x *Response) SetDescription(v string) { x.Description = v } func (x *Response) SetSchema(v *Schema) { x.Schema = v } func (x *Response) SetHeaders(v map[string]*Header) { x.Headers = v } func (x *Response) SetExamples(v map[string]string) { x.Examples = v } func (x *Response) SetExtensions(v map[string]*structpb.Value) { x.Extensions = v } func (x *Response) HasSchema() bool { if x == nil { return false } return x.Schema != nil } func (x *Response) ClearSchema() { x.Schema = nil } type Response_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // `Description` is a short description of the response. // GFM syntax can be used for rich text representation. Description string // `Schema` optionally defines the structure of the response. // If `Schema` is not provided, it means there is no content to the response. Schema *Schema // `Headers` A list of headers that are sent with the response. // `Header` name is expected to be a string in the canonical format of the MIME header key // See: https://golang.org/pkg/net/textproto/#CanonicalMIMEHeaderKey Headers map[string]*Header // `Examples` gives per-mimetype response examples. // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#example-object Examples map[string]string // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value } func (b0 Response_builder) Build() *Response { m0 := &Response{} b, x := &b0, m0 _, _ = b, x x.Description = b.Description x.Schema = b.Schema x.Headers = b.Headers x.Examples = b.Examples x.Extensions = b.Extensions return m0 } // `Info` is a representation of OpenAPI v2 specification's Info object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#infoObject // // Example: // // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { // info: { // title: "Echo API"; // version: "1.0"; // description: ""; // contact: { // name: "gRPC-Gateway project"; // url: "https://github.com/grpc-ecosystem/grpc-gateway"; // email: "none@example.com"; // }; // license: { // name: "BSD 3-Clause License"; // url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE"; // }; // }; // ... // }; type Info struct { state protoimpl.MessageState `protogen:"hybrid.v1"` // The title of the application. Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` // A short description of the application. GFM syntax can be used for rich // text representation. Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` // The Terms of Service for the API. TermsOfService string `protobuf:"bytes,3,opt,name=terms_of_service,json=termsOfService,proto3" json:"terms_of_service,omitempty"` // The contact information for the exposed API. Contact *Contact `protobuf:"bytes,4,opt,name=contact,proto3" json:"contact,omitempty"` // The license information for the exposed API. License *License `protobuf:"bytes,5,opt,name=license,proto3" json:"license,omitempty"` // Provides the version of the application API (not to be confused // with the specification version). Version string `protobuf:"bytes,6,opt,name=version,proto3" json:"version,omitempty"` // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value `protobuf:"bytes,7,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Info) Reset() { *x = Info{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Info) String() string { return protoimpl.X.MessageStringOf(x) } func (*Info) ProtoMessage() {} func (x *Info) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *Info) GetTitle() string { if x != nil { return x.Title } return "" } func (x *Info) GetDescription() string { if x != nil { return x.Description } return "" } func (x *Info) GetTermsOfService() string { if x != nil { return x.TermsOfService } return "" } func (x *Info) GetContact() *Contact { if x != nil { return x.Contact } return nil } func (x *Info) GetLicense() *License { if x != nil { return x.License } return nil } func (x *Info) GetVersion() string { if x != nil { return x.Version } return "" } func (x *Info) GetExtensions() map[string]*structpb.Value { if x != nil { return x.Extensions } return nil } func (x *Info) SetTitle(v string) { x.Title = v } func (x *Info) SetDescription(v string) { x.Description = v } func (x *Info) SetTermsOfService(v string) { x.TermsOfService = v } func (x *Info) SetContact(v *Contact) { x.Contact = v } func (x *Info) SetLicense(v *License) { x.License = v } func (x *Info) SetVersion(v string) { x.Version = v } func (x *Info) SetExtensions(v map[string]*structpb.Value) { x.Extensions = v } func (x *Info) HasContact() bool { if x == nil { return false } return x.Contact != nil } func (x *Info) HasLicense() bool { if x == nil { return false } return x.License != nil } func (x *Info) ClearContact() { x.Contact = nil } func (x *Info) ClearLicense() { x.License = nil } type Info_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // The title of the application. Title string // A short description of the application. GFM syntax can be used for rich // text representation. Description string // The Terms of Service for the API. TermsOfService string // The contact information for the exposed API. Contact *Contact // The license information for the exposed API. License *License // Provides the version of the application API (not to be confused // with the specification version). Version string // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value } func (b0 Info_builder) Build() *Info { m0 := &Info{} b, x := &b0, m0 _, _ = b, x x.Title = b.Title x.Description = b.Description x.TermsOfService = b.TermsOfService x.Contact = b.Contact x.License = b.License x.Version = b.Version x.Extensions = b.Extensions return m0 } // `Contact` is a representation of OpenAPI v2 specification's Contact object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#contactObject // // Example: // // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { // info: { // ... // contact: { // name: "gRPC-Gateway project"; // url: "https://github.com/grpc-ecosystem/grpc-gateway"; // email: "none@example.com"; // }; // ... // }; // ... // }; type Contact struct { state protoimpl.MessageState `protogen:"hybrid.v1"` // The identifying name of the contact person/organization. Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // The URL pointing to the contact information. MUST be in the format of a // URL. Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` // The email address of the contact person/organization. MUST be in the format // of an email address. Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Contact) Reset() { *x = Contact{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Contact) String() string { return protoimpl.X.MessageStringOf(x) } func (*Contact) ProtoMessage() {} func (x *Contact) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *Contact) GetName() string { if x != nil { return x.Name } return "" } func (x *Contact) GetUrl() string { if x != nil { return x.Url } return "" } func (x *Contact) GetEmail() string { if x != nil { return x.Email } return "" } func (x *Contact) SetName(v string) { x.Name = v } func (x *Contact) SetUrl(v string) { x.Url = v } func (x *Contact) SetEmail(v string) { x.Email = v } type Contact_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // The identifying name of the contact person/organization. Name string // The URL pointing to the contact information. MUST be in the format of a // URL. Url string // The email address of the contact person/organization. MUST be in the format // of an email address. Email string } func (b0 Contact_builder) Build() *Contact { m0 := &Contact{} b, x := &b0, m0 _, _ = b, x x.Name = b.Name x.Url = b.Url x.Email = b.Email return m0 } // `License` is a representation of OpenAPI v2 specification's License object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#licenseObject // // Example: // // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { // info: { // ... // license: { // name: "BSD 3-Clause License"; // url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE"; // }; // ... // }; // ... // }; type License struct { state protoimpl.MessageState `protogen:"hybrid.v1"` // The license name used for the API. Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // A URL to the license used for the API. MUST be in the format of a URL. Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *License) Reset() { *x = License{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *License) String() string { return protoimpl.X.MessageStringOf(x) } func (*License) ProtoMessage() {} func (x *License) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *License) GetName() string { if x != nil { return x.Name } return "" } func (x *License) GetUrl() string { if x != nil { return x.Url } return "" } func (x *License) SetName(v string) { x.Name = v } func (x *License) SetUrl(v string) { x.Url = v } type License_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // The license name used for the API. Name string // A URL to the license used for the API. MUST be in the format of a URL. Url string } func (b0 License_builder) Build() *License { m0 := &License{} b, x := &b0, m0 _, _ = b, x x.Name = b.Name x.Url = b.Url return m0 } // `ExternalDocumentation` is a representation of OpenAPI v2 specification's // ExternalDocumentation object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#externalDocumentationObject // // Example: // // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { // ... // external_docs: { // description: "More about gRPC-Gateway"; // url: "https://github.com/grpc-ecosystem/grpc-gateway"; // } // ... // }; type ExternalDocumentation struct { state protoimpl.MessageState `protogen:"hybrid.v1"` // A short description of the target documentation. GFM syntax can be used for // rich text representation. Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` // The URL for the target documentation. Value MUST be in the format // of a URL. Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *ExternalDocumentation) Reset() { *x = ExternalDocumentation{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *ExternalDocumentation) String() string { return protoimpl.X.MessageStringOf(x) } func (*ExternalDocumentation) ProtoMessage() {} func (x *ExternalDocumentation) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *ExternalDocumentation) GetDescription() string { if x != nil { return x.Description } return "" } func (x *ExternalDocumentation) GetUrl() string { if x != nil { return x.Url } return "" } func (x *ExternalDocumentation) SetDescription(v string) { x.Description = v } func (x *ExternalDocumentation) SetUrl(v string) { x.Url = v } type ExternalDocumentation_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // A short description of the target documentation. GFM syntax can be used for // rich text representation. Description string // The URL for the target documentation. Value MUST be in the format // of a URL. Url string } func (b0 ExternalDocumentation_builder) Build() *ExternalDocumentation { m0 := &ExternalDocumentation{} b, x := &b0, m0 _, _ = b, x x.Description = b.Description x.Url = b.Url return m0 } // `Schema` is a representation of OpenAPI v2 specification's Schema object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject type Schema struct { state protoimpl.MessageState `protogen:"hybrid.v1"` JsonSchema *JSONSchema `protobuf:"bytes,1,opt,name=json_schema,json=jsonSchema,proto3" json:"json_schema,omitempty"` // Adds support for polymorphism. The discriminator is the schema property // name that is used to differentiate between other schema that inherit this // schema. The property name used MUST be defined at this schema and it MUST // be in the required property list. When used, the value MUST be the name of // this schema or any schema that inherits it. Discriminator string `protobuf:"bytes,2,opt,name=discriminator,proto3" json:"discriminator,omitempty"` // Relevant only for Schema "properties" definitions. Declares the property as // "read only". This means that it MAY be sent as part of a response but MUST // NOT be sent as part of the request. Properties marked as readOnly being // true SHOULD NOT be in the required list of the defined schema. Default // value is false. ReadOnly bool `protobuf:"varint,3,opt,name=read_only,json=readOnly,proto3" json:"read_only,omitempty"` // Additional external documentation for this schema. ExternalDocs *ExternalDocumentation `protobuf:"bytes,5,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` // A free-form property to include an example of an instance for this schema in JSON. // This is copied verbatim to the output. Example string `protobuf:"bytes,6,opt,name=example,proto3" json:"example,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Schema) Reset() { *x = Schema{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Schema) String() string { return protoimpl.X.MessageStringOf(x) } func (*Schema) ProtoMessage() {} func (x *Schema) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *Schema) GetJsonSchema() *JSONSchema { if x != nil { return x.JsonSchema } return nil } func (x *Schema) GetDiscriminator() string { if x != nil { return x.Discriminator } return "" } func (x *Schema) GetReadOnly() bool { if x != nil { return x.ReadOnly } return false } func (x *Schema) GetExternalDocs() *ExternalDocumentation { if x != nil { return x.ExternalDocs } return nil } func (x *Schema) GetExample() string { if x != nil { return x.Example } return "" } func (x *Schema) SetJsonSchema(v *JSONSchema) { x.JsonSchema = v } func (x *Schema) SetDiscriminator(v string) { x.Discriminator = v } func (x *Schema) SetReadOnly(v bool) { x.ReadOnly = v } func (x *Schema) SetExternalDocs(v *ExternalDocumentation) { x.ExternalDocs = v } func (x *Schema) SetExample(v string) { x.Example = v } func (x *Schema) HasJsonSchema() bool { if x == nil { return false } return x.JsonSchema != nil } func (x *Schema) HasExternalDocs() bool { if x == nil { return false } return x.ExternalDocs != nil } func (x *Schema) ClearJsonSchema() { x.JsonSchema = nil } func (x *Schema) ClearExternalDocs() { x.ExternalDocs = nil } type Schema_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. JsonSchema *JSONSchema // Adds support for polymorphism. The discriminator is the schema property // name that is used to differentiate between other schema that inherit this // schema. The property name used MUST be defined at this schema and it MUST // be in the required property list. When used, the value MUST be the name of // this schema or any schema that inherits it. Discriminator string // Relevant only for Schema "properties" definitions. Declares the property as // "read only". This means that it MAY be sent as part of a response but MUST // NOT be sent as part of the request. Properties marked as readOnly being // true SHOULD NOT be in the required list of the defined schema. Default // value is false. ReadOnly bool // Additional external documentation for this schema. ExternalDocs *ExternalDocumentation // A free-form property to include an example of an instance for this schema in JSON. // This is copied verbatim to the output. Example string } func (b0 Schema_builder) Build() *Schema { m0 := &Schema{} b, x := &b0, m0 _, _ = b, x x.JsonSchema = b.JsonSchema x.Discriminator = b.Discriminator x.ReadOnly = b.ReadOnly x.ExternalDocs = b.ExternalDocs x.Example = b.Example return m0 } // `EnumSchema` is subset of fields from the OpenAPI v2 specification's Schema object. // Only fields that are applicable to Enums are included // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject // // Example: // // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_enum) = { // ... // title: "MyEnum"; // description:"This is my nice enum"; // example: "ZERO"; // required: true; // ... // }; type EnumSchema struct { state protoimpl.MessageState `protogen:"hybrid.v1"` // A short description of the schema. Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` Default string `protobuf:"bytes,2,opt,name=default,proto3" json:"default,omitempty"` // The title of the schema. Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"` Required bool `protobuf:"varint,4,opt,name=required,proto3" json:"required,omitempty"` ReadOnly bool `protobuf:"varint,5,opt,name=read_only,json=readOnly,proto3" json:"read_only,omitempty"` // Additional external documentation for this schema. ExternalDocs *ExternalDocumentation `protobuf:"bytes,6,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` Example string `protobuf:"bytes,7,opt,name=example,proto3" json:"example,omitempty"` // Ref is used to define an external reference to include in the message. // This could be a fully qualified proto message reference, and that type must // be imported into the protofile. If no message is identified, the Ref will // be used verbatim in the output. // For example: // // `ref: ".google.protobuf.Timestamp"`. Ref string `protobuf:"bytes,8,opt,name=ref,proto3" json:"ref,omitempty"` // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value `protobuf:"bytes,9,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *EnumSchema) Reset() { *x = EnumSchema{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *EnumSchema) String() string { return protoimpl.X.MessageStringOf(x) } func (*EnumSchema) ProtoMessage() {} func (x *EnumSchema) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *EnumSchema) GetDescription() string { if x != nil { return x.Description } return "" } func (x *EnumSchema) GetDefault() string { if x != nil { return x.Default } return "" } func (x *EnumSchema) GetTitle() string { if x != nil { return x.Title } return "" } func (x *EnumSchema) GetRequired() bool { if x != nil { return x.Required } return false } func (x *EnumSchema) GetReadOnly() bool { if x != nil { return x.ReadOnly } return false } func (x *EnumSchema) GetExternalDocs() *ExternalDocumentation { if x != nil { return x.ExternalDocs } return nil } func (x *EnumSchema) GetExample() string { if x != nil { return x.Example } return "" } func (x *EnumSchema) GetRef() string { if x != nil { return x.Ref } return "" } func (x *EnumSchema) GetExtensions() map[string]*structpb.Value { if x != nil { return x.Extensions } return nil } func (x *EnumSchema) SetDescription(v string) { x.Description = v } func (x *EnumSchema) SetDefault(v string) { x.Default = v } func (x *EnumSchema) SetTitle(v string) { x.Title = v } func (x *EnumSchema) SetRequired(v bool) { x.Required = v } func (x *EnumSchema) SetReadOnly(v bool) { x.ReadOnly = v } func (x *EnumSchema) SetExternalDocs(v *ExternalDocumentation) { x.ExternalDocs = v } func (x *EnumSchema) SetExample(v string) { x.Example = v } func (x *EnumSchema) SetRef(v string) { x.Ref = v } func (x *EnumSchema) SetExtensions(v map[string]*structpb.Value) { x.Extensions = v } func (x *EnumSchema) HasExternalDocs() bool { if x == nil { return false } return x.ExternalDocs != nil } func (x *EnumSchema) ClearExternalDocs() { x.ExternalDocs = nil } type EnumSchema_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // A short description of the schema. Description string Default string // The title of the schema. Title string Required bool ReadOnly bool // Additional external documentation for this schema. ExternalDocs *ExternalDocumentation Example string // Ref is used to define an external reference to include in the message. // This could be a fully qualified proto message reference, and that type must // be imported into the protofile. If no message is identified, the Ref will // be used verbatim in the output. // For example: // // `ref: ".google.protobuf.Timestamp"`. Ref string // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value } func (b0 EnumSchema_builder) Build() *EnumSchema { m0 := &EnumSchema{} b, x := &b0, m0 _, _ = b, x x.Description = b.Description x.Default = b.Default x.Title = b.Title x.Required = b.Required x.ReadOnly = b.ReadOnly x.ExternalDocs = b.ExternalDocs x.Example = b.Example x.Ref = b.Ref x.Extensions = b.Extensions return m0 } // `JSONSchema` represents properties from JSON Schema taken, and as used, in // the OpenAPI v2 spec. // // This includes changes made by OpenAPI v2. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject // // See also: https://cswr.github.io/JsonSchema/spec/basic_types/, // https://github.com/json-schema-org/json-schema-spec/blob/master/schema.json // // Example: // // message SimpleMessage { // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { // json_schema: { // title: "SimpleMessage" // description: "A simple message." // required: ["id"] // } // }; // // // Id represents the message identifier. // string id = 1; [ // (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { // description: "The unique identifier of the simple message." // }]; // } type JSONSchema struct { state protoimpl.MessageState `protogen:"hybrid.v1"` // Ref is used to define an external reference to include in the message. // This could be a fully qualified proto message reference, and that type must // be imported into the protofile. If no message is identified, the Ref will // be used verbatim in the output. // For example: // // `ref: ".google.protobuf.Timestamp"`. Ref string `protobuf:"bytes,3,opt,name=ref,proto3" json:"ref,omitempty"` // The title of the schema. Title string `protobuf:"bytes,5,opt,name=title,proto3" json:"title,omitempty"` // A short description of the schema. Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` Default string `protobuf:"bytes,7,opt,name=default,proto3" json:"default,omitempty"` ReadOnly bool `protobuf:"varint,8,opt,name=read_only,json=readOnly,proto3" json:"read_only,omitempty"` // A free-form property to include a JSON example of this field. This is copied // verbatim to the output swagger.json. Quotes must be escaped. // This property is the same for 2.0 and 3.0.0 https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/3.0.0.md#schemaObject https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject Example string `protobuf:"bytes,9,opt,name=example,proto3" json:"example,omitempty"` MultipleOf float64 `protobuf:"fixed64,10,opt,name=multiple_of,json=multipleOf,proto3" json:"multiple_of,omitempty"` // Maximum represents an inclusive upper limit for a numeric instance. The // value of MUST be a number, Maximum float64 `protobuf:"fixed64,11,opt,name=maximum,proto3" json:"maximum,omitempty"` ExclusiveMaximum bool `protobuf:"varint,12,opt,name=exclusive_maximum,json=exclusiveMaximum,proto3" json:"exclusive_maximum,omitempty"` // minimum represents an inclusive lower limit for a numeric instance. The // value of MUST be a number, Minimum float64 `protobuf:"fixed64,13,opt,name=minimum,proto3" json:"minimum,omitempty"` ExclusiveMinimum bool `protobuf:"varint,14,opt,name=exclusive_minimum,json=exclusiveMinimum,proto3" json:"exclusive_minimum,omitempty"` MaxLength uint64 `protobuf:"varint,15,opt,name=max_length,json=maxLength,proto3" json:"max_length,omitempty"` MinLength uint64 `protobuf:"varint,16,opt,name=min_length,json=minLength,proto3" json:"min_length,omitempty"` Pattern string `protobuf:"bytes,17,opt,name=pattern,proto3" json:"pattern,omitempty"` MaxItems uint64 `protobuf:"varint,20,opt,name=max_items,json=maxItems,proto3" json:"max_items,omitempty"` MinItems uint64 `protobuf:"varint,21,opt,name=min_items,json=minItems,proto3" json:"min_items,omitempty"` UniqueItems bool `protobuf:"varint,22,opt,name=unique_items,json=uniqueItems,proto3" json:"unique_items,omitempty"` MaxProperties uint64 `protobuf:"varint,24,opt,name=max_properties,json=maxProperties,proto3" json:"max_properties,omitempty"` MinProperties uint64 `protobuf:"varint,25,opt,name=min_properties,json=minProperties,proto3" json:"min_properties,omitempty"` Required []string `protobuf:"bytes,26,rep,name=required,proto3" json:"required,omitempty"` // Items in 'array' must be unique. Array []string `protobuf:"bytes,34,rep,name=array,proto3" json:"array,omitempty"` Type []JSONSchema_JSONSchemaSimpleTypes `protobuf:"varint,35,rep,packed,name=type,proto3,enum=grpc.gateway.protoc_gen_openapiv2.options.JSONSchema_JSONSchemaSimpleTypes" json:"type,omitempty"` // `Format` Format string `protobuf:"bytes,36,opt,name=format,proto3" json:"format,omitempty"` // Items in `enum` must be unique https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.1 Enum []string `protobuf:"bytes,46,rep,name=enum,proto3" json:"enum,omitempty"` // Additional field level properties used when generating the OpenAPI v2 file. FieldConfiguration *JSONSchema_FieldConfiguration `protobuf:"bytes,1001,opt,name=field_configuration,json=fieldConfiguration,proto3" json:"field_configuration,omitempty"` // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value `protobuf:"bytes,48,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *JSONSchema) Reset() { *x = JSONSchema{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *JSONSchema) String() string { return protoimpl.X.MessageStringOf(x) } func (*JSONSchema) ProtoMessage() {} func (x *JSONSchema) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *JSONSchema) GetRef() string { if x != nil { return x.Ref } return "" } func (x *JSONSchema) GetTitle() string { if x != nil { return x.Title } return "" } func (x *JSONSchema) GetDescription() string { if x != nil { return x.Description } return "" } func (x *JSONSchema) GetDefault() string { if x != nil { return x.Default } return "" } func (x *JSONSchema) GetReadOnly() bool { if x != nil { return x.ReadOnly } return false } func (x *JSONSchema) GetExample() string { if x != nil { return x.Example } return "" } func (x *JSONSchema) GetMultipleOf() float64 { if x != nil { return x.MultipleOf } return 0 } func (x *JSONSchema) GetMaximum() float64 { if x != nil { return x.Maximum } return 0 } func (x *JSONSchema) GetExclusiveMaximum() bool { if x != nil { return x.ExclusiveMaximum } return false } func (x *JSONSchema) GetMinimum() float64 { if x != nil { return x.Minimum } return 0 } func (x *JSONSchema) GetExclusiveMinimum() bool { if x != nil { return x.ExclusiveMinimum } return false } func (x *JSONSchema) GetMaxLength() uint64 { if x != nil { return x.MaxLength } return 0 } func (x *JSONSchema) GetMinLength() uint64 { if x != nil { return x.MinLength } return 0 } func (x *JSONSchema) GetPattern() string { if x != nil { return x.Pattern } return "" } func (x *JSONSchema) GetMaxItems() uint64 { if x != nil { return x.MaxItems } return 0 } func (x *JSONSchema) GetMinItems() uint64 { if x != nil { return x.MinItems } return 0 } func (x *JSONSchema) GetUniqueItems() bool { if x != nil { return x.UniqueItems } return false } func (x *JSONSchema) GetMaxProperties() uint64 { if x != nil { return x.MaxProperties } return 0 } func (x *JSONSchema) GetMinProperties() uint64 { if x != nil { return x.MinProperties } return 0 } func (x *JSONSchema) GetRequired() []string { if x != nil { return x.Required } return nil } func (x *JSONSchema) GetArray() []string { if x != nil { return x.Array } return nil } func (x *JSONSchema) GetType() []JSONSchema_JSONSchemaSimpleTypes { if x != nil { return x.Type } return nil } func (x *JSONSchema) GetFormat() string { if x != nil { return x.Format } return "" } func (x *JSONSchema) GetEnum() []string { if x != nil { return x.Enum } return nil } func (x *JSONSchema) GetFieldConfiguration() *JSONSchema_FieldConfiguration { if x != nil { return x.FieldConfiguration } return nil } func (x *JSONSchema) GetExtensions() map[string]*structpb.Value { if x != nil { return x.Extensions } return nil } func (x *JSONSchema) SetRef(v string) { x.Ref = v } func (x *JSONSchema) SetTitle(v string) { x.Title = v } func (x *JSONSchema) SetDescription(v string) { x.Description = v } func (x *JSONSchema) SetDefault(v string) { x.Default = v } func (x *JSONSchema) SetReadOnly(v bool) { x.ReadOnly = v } func (x *JSONSchema) SetExample(v string) { x.Example = v } func (x *JSONSchema) SetMultipleOf(v float64) { x.MultipleOf = v } func (x *JSONSchema) SetMaximum(v float64) { x.Maximum = v } func (x *JSONSchema) SetExclusiveMaximum(v bool) { x.ExclusiveMaximum = v } func (x *JSONSchema) SetMinimum(v float64) { x.Minimum = v } func (x *JSONSchema) SetExclusiveMinimum(v bool) { x.ExclusiveMinimum = v } func (x *JSONSchema) SetMaxLength(v uint64) { x.MaxLength = v } func (x *JSONSchema) SetMinLength(v uint64) { x.MinLength = v } func (x *JSONSchema) SetPattern(v string) { x.Pattern = v } func (x *JSONSchema) SetMaxItems(v uint64) { x.MaxItems = v } func (x *JSONSchema) SetMinItems(v uint64) { x.MinItems = v } func (x *JSONSchema) SetUniqueItems(v bool) { x.UniqueItems = v } func (x *JSONSchema) SetMaxProperties(v uint64) { x.MaxProperties = v } func (x *JSONSchema) SetMinProperties(v uint64) { x.MinProperties = v } func (x *JSONSchema) SetRequired(v []string) { x.Required = v } func (x *JSONSchema) SetArray(v []string) { x.Array = v } func (x *JSONSchema) SetType(v []JSONSchema_JSONSchemaSimpleTypes) { x.Type = v } func (x *JSONSchema) SetFormat(v string) { x.Format = v } func (x *JSONSchema) SetEnum(v []string) { x.Enum = v } func (x *JSONSchema) SetFieldConfiguration(v *JSONSchema_FieldConfiguration) { x.FieldConfiguration = v } func (x *JSONSchema) SetExtensions(v map[string]*structpb.Value) { x.Extensions = v } func (x *JSONSchema) HasFieldConfiguration() bool { if x == nil { return false } return x.FieldConfiguration != nil } func (x *JSONSchema) ClearFieldConfiguration() { x.FieldConfiguration = nil } type JSONSchema_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // Ref is used to define an external reference to include in the message. // This could be a fully qualified proto message reference, and that type must // be imported into the protofile. If no message is identified, the Ref will // be used verbatim in the output. // For example: // // `ref: ".google.protobuf.Timestamp"`. Ref string // The title of the schema. Title string // A short description of the schema. Description string Default string ReadOnly bool // A free-form property to include a JSON example of this field. This is copied // verbatim to the output swagger.json. Quotes must be escaped. // This property is the same for 2.0 and 3.0.0 https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/3.0.0.md#schemaObject https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject Example string MultipleOf float64 // Maximum represents an inclusive upper limit for a numeric instance. The // value of MUST be a number, Maximum float64 ExclusiveMaximum bool // minimum represents an inclusive lower limit for a numeric instance. The // value of MUST be a number, Minimum float64 ExclusiveMinimum bool MaxLength uint64 MinLength uint64 Pattern string MaxItems uint64 MinItems uint64 UniqueItems bool MaxProperties uint64 MinProperties uint64 Required []string // Items in 'array' must be unique. Array []string Type []JSONSchema_JSONSchemaSimpleTypes // `Format` Format string // Items in `enum` must be unique https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.1 Enum []string // Additional field level properties used when generating the OpenAPI v2 file. FieldConfiguration *JSONSchema_FieldConfiguration // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value } func (b0 JSONSchema_builder) Build() *JSONSchema { m0 := &JSONSchema{} b, x := &b0, m0 _, _ = b, x x.Ref = b.Ref x.Title = b.Title x.Description = b.Description x.Default = b.Default x.ReadOnly = b.ReadOnly x.Example = b.Example x.MultipleOf = b.MultipleOf x.Maximum = b.Maximum x.ExclusiveMaximum = b.ExclusiveMaximum x.Minimum = b.Minimum x.ExclusiveMinimum = b.ExclusiveMinimum x.MaxLength = b.MaxLength x.MinLength = b.MinLength x.Pattern = b.Pattern x.MaxItems = b.MaxItems x.MinItems = b.MinItems x.UniqueItems = b.UniqueItems x.MaxProperties = b.MaxProperties x.MinProperties = b.MinProperties x.Required = b.Required x.Array = b.Array x.Type = b.Type x.Format = b.Format x.Enum = b.Enum x.FieldConfiguration = b.FieldConfiguration x.Extensions = b.Extensions return m0 } // `Tag` is a representation of OpenAPI v2 specification's Tag object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#tagObject type Tag struct { state protoimpl.MessageState `protogen:"hybrid.v1"` // The name of the tag. Use it to allow override of the name of a // global Tag object, then use that name to reference the tag throughout the // OpenAPI file. Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // A short description for the tag. GFM syntax can be used for rich text // representation. Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` // Additional external documentation for this tag. ExternalDocs *ExternalDocumentation `protobuf:"bytes,3,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value `protobuf:"bytes,4,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Tag) Reset() { *x = Tag{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Tag) String() string { return protoimpl.X.MessageStringOf(x) } func (*Tag) ProtoMessage() {} func (x *Tag) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *Tag) GetName() string { if x != nil { return x.Name } return "" } func (x *Tag) GetDescription() string { if x != nil { return x.Description } return "" } func (x *Tag) GetExternalDocs() *ExternalDocumentation { if x != nil { return x.ExternalDocs } return nil } func (x *Tag) GetExtensions() map[string]*structpb.Value { if x != nil { return x.Extensions } return nil } func (x *Tag) SetName(v string) { x.Name = v } func (x *Tag) SetDescription(v string) { x.Description = v } func (x *Tag) SetExternalDocs(v *ExternalDocumentation) { x.ExternalDocs = v } func (x *Tag) SetExtensions(v map[string]*structpb.Value) { x.Extensions = v } func (x *Tag) HasExternalDocs() bool { if x == nil { return false } return x.ExternalDocs != nil } func (x *Tag) ClearExternalDocs() { x.ExternalDocs = nil } type Tag_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // The name of the tag. Use it to allow override of the name of a // global Tag object, then use that name to reference the tag throughout the // OpenAPI file. Name string // A short description for the tag. GFM syntax can be used for rich text // representation. Description string // Additional external documentation for this tag. ExternalDocs *ExternalDocumentation // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value } func (b0 Tag_builder) Build() *Tag { m0 := &Tag{} b, x := &b0, m0 _, _ = b, x x.Name = b.Name x.Description = b.Description x.ExternalDocs = b.ExternalDocs x.Extensions = b.Extensions return m0 } // `SecurityDefinitions` is a representation of OpenAPI v2 specification's // Security Definitions object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityDefinitionsObject // // A declaration of the security schemes available to be used in the // specification. This does not enforce the security schemes on the operations // and only serves to provide the relevant details for each scheme. type SecurityDefinitions struct { state protoimpl.MessageState `protogen:"hybrid.v1"` // A single security scheme definition, mapping a "name" to the scheme it // defines. Security map[string]*SecurityScheme `protobuf:"bytes,1,rep,name=security,proto3" json:"security,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *SecurityDefinitions) Reset() { *x = SecurityDefinitions{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *SecurityDefinitions) String() string { return protoimpl.X.MessageStringOf(x) } func (*SecurityDefinitions) ProtoMessage() {} func (x *SecurityDefinitions) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *SecurityDefinitions) GetSecurity() map[string]*SecurityScheme { if x != nil { return x.Security } return nil } func (x *SecurityDefinitions) SetSecurity(v map[string]*SecurityScheme) { x.Security = v } type SecurityDefinitions_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // A single security scheme definition, mapping a "name" to the scheme it // defines. Security map[string]*SecurityScheme } func (b0 SecurityDefinitions_builder) Build() *SecurityDefinitions { m0 := &SecurityDefinitions{} b, x := &b0, m0 _, _ = b, x x.Security = b.Security return m0 } // `SecurityScheme` is a representation of OpenAPI v2 specification's // Security Scheme object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securitySchemeObject // // Allows the definition of a security scheme that can be used by the // operations. Supported schemes are basic authentication, an API key (either as // a header or as a query parameter) and OAuth2's common flows (implicit, // password, application and access code). type SecurityScheme struct { state protoimpl.MessageState `protogen:"hybrid.v1"` // The type of the security scheme. Valid values are "basic", // "apiKey" or "oauth2". Type SecurityScheme_Type `protobuf:"varint,1,opt,name=type,proto3,enum=grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme_Type" json:"type,omitempty"` // A short description for security scheme. Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` // The name of the header or query parameter to be used. // Valid for apiKey. Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` // The location of the API key. Valid values are "query" or // "header". // Valid for apiKey. In SecurityScheme_In `protobuf:"varint,4,opt,name=in,proto3,enum=grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme_In" json:"in,omitempty"` // The flow used by the OAuth2 security scheme. Valid values are // "implicit", "password", "application" or "accessCode". // Valid for oauth2. Flow SecurityScheme_Flow `protobuf:"varint,5,opt,name=flow,proto3,enum=grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme_Flow" json:"flow,omitempty"` // The authorization URL to be used for this flow. This SHOULD be in // the form of a URL. // Valid for oauth2/implicit and oauth2/accessCode. AuthorizationUrl string `protobuf:"bytes,6,opt,name=authorization_url,json=authorizationUrl,proto3" json:"authorization_url,omitempty"` // The token URL to be used for this flow. This SHOULD be in the // form of a URL. // Valid for oauth2/password, oauth2/application and oauth2/accessCode. TokenUrl string `protobuf:"bytes,7,opt,name=token_url,json=tokenUrl,proto3" json:"token_url,omitempty"` // The available scopes for the OAuth2 security scheme. // Valid for oauth2. Scopes *Scopes `protobuf:"bytes,8,opt,name=scopes,proto3" json:"scopes,omitempty"` // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value `protobuf:"bytes,9,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *SecurityScheme) Reset() { *x = SecurityScheme{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *SecurityScheme) String() string { return protoimpl.X.MessageStringOf(x) } func (*SecurityScheme) ProtoMessage() {} func (x *SecurityScheme) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *SecurityScheme) GetType() SecurityScheme_Type { if x != nil { return x.Type } return SecurityScheme_TYPE_INVALID } func (x *SecurityScheme) GetDescription() string { if x != nil { return x.Description } return "" } func (x *SecurityScheme) GetName() string { if x != nil { return x.Name } return "" } func (x *SecurityScheme) GetIn() SecurityScheme_In { if x != nil { return x.In } return SecurityScheme_IN_INVALID } func (x *SecurityScheme) GetFlow() SecurityScheme_Flow { if x != nil { return x.Flow } return SecurityScheme_FLOW_INVALID } func (x *SecurityScheme) GetAuthorizationUrl() string { if x != nil { return x.AuthorizationUrl } return "" } func (x *SecurityScheme) GetTokenUrl() string { if x != nil { return x.TokenUrl } return "" } func (x *SecurityScheme) GetScopes() *Scopes { if x != nil { return x.Scopes } return nil } func (x *SecurityScheme) GetExtensions() map[string]*structpb.Value { if x != nil { return x.Extensions } return nil } func (x *SecurityScheme) SetType(v SecurityScheme_Type) { x.Type = v } func (x *SecurityScheme) SetDescription(v string) { x.Description = v } func (x *SecurityScheme) SetName(v string) { x.Name = v } func (x *SecurityScheme) SetIn(v SecurityScheme_In) { x.In = v } func (x *SecurityScheme) SetFlow(v SecurityScheme_Flow) { x.Flow = v } func (x *SecurityScheme) SetAuthorizationUrl(v string) { x.AuthorizationUrl = v } func (x *SecurityScheme) SetTokenUrl(v string) { x.TokenUrl = v } func (x *SecurityScheme) SetScopes(v *Scopes) { x.Scopes = v } func (x *SecurityScheme) SetExtensions(v map[string]*structpb.Value) { x.Extensions = v } func (x *SecurityScheme) HasScopes() bool { if x == nil { return false } return x.Scopes != nil } func (x *SecurityScheme) ClearScopes() { x.Scopes = nil } type SecurityScheme_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // The type of the security scheme. Valid values are "basic", // "apiKey" or "oauth2". Type SecurityScheme_Type // A short description for security scheme. Description string // The name of the header or query parameter to be used. // Valid for apiKey. Name string // The location of the API key. Valid values are "query" or // "header". // Valid for apiKey. In SecurityScheme_In // The flow used by the OAuth2 security scheme. Valid values are // "implicit", "password", "application" or "accessCode". // Valid for oauth2. Flow SecurityScheme_Flow // The authorization URL to be used for this flow. This SHOULD be in // the form of a URL. // Valid for oauth2/implicit and oauth2/accessCode. AuthorizationUrl string // The token URL to be used for this flow. This SHOULD be in the // form of a URL. // Valid for oauth2/password, oauth2/application and oauth2/accessCode. TokenUrl string // The available scopes for the OAuth2 security scheme. // Valid for oauth2. Scopes *Scopes // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value } func (b0 SecurityScheme_builder) Build() *SecurityScheme { m0 := &SecurityScheme{} b, x := &b0, m0 _, _ = b, x x.Type = b.Type x.Description = b.Description x.Name = b.Name x.In = b.In x.Flow = b.Flow x.AuthorizationUrl = b.AuthorizationUrl x.TokenUrl = b.TokenUrl x.Scopes = b.Scopes x.Extensions = b.Extensions return m0 } // `SecurityRequirement` is a representation of OpenAPI v2 specification's // Security Requirement object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityRequirementObject // // Lists the required security schemes to execute this operation. The object can // have multiple security schemes declared in it which are all required (that // is, there is a logical AND between the schemes). // // The name used for each property MUST correspond to a security scheme // declared in the Security Definitions. type SecurityRequirement struct { state protoimpl.MessageState `protogen:"hybrid.v1"` // Each name must correspond to a security scheme which is declared in // the Security Definitions. If the security scheme is of type "oauth2", // then the value is a list of scope names required for the execution. // For other security scheme types, the array MUST be empty. SecurityRequirement map[string]*SecurityRequirement_SecurityRequirementValue `protobuf:"bytes,1,rep,name=security_requirement,json=securityRequirement,proto3" json:"security_requirement,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *SecurityRequirement) Reset() { *x = SecurityRequirement{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *SecurityRequirement) String() string { return protoimpl.X.MessageStringOf(x) } func (*SecurityRequirement) ProtoMessage() {} func (x *SecurityRequirement) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *SecurityRequirement) GetSecurityRequirement() map[string]*SecurityRequirement_SecurityRequirementValue { if x != nil { return x.SecurityRequirement } return nil } func (x *SecurityRequirement) SetSecurityRequirement(v map[string]*SecurityRequirement_SecurityRequirementValue) { x.SecurityRequirement = v } type SecurityRequirement_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // Each name must correspond to a security scheme which is declared in // the Security Definitions. If the security scheme is of type "oauth2", // then the value is a list of scope names required for the execution. // For other security scheme types, the array MUST be empty. SecurityRequirement map[string]*SecurityRequirement_SecurityRequirementValue } func (b0 SecurityRequirement_builder) Build() *SecurityRequirement { m0 := &SecurityRequirement{} b, x := &b0, m0 _, _ = b, x x.SecurityRequirement = b.SecurityRequirement return m0 } // `Scopes` is a representation of OpenAPI v2 specification's Scopes object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#scopesObject // // Lists the available scopes for an OAuth2 security scheme. type Scopes struct { state protoimpl.MessageState `protogen:"hybrid.v1"` // Maps between a name of a scope to a short description of it (as the value // of the property). Scope map[string]string `protobuf:"bytes,1,rep,name=scope,proto3" json:"scope,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Scopes) Reset() { *x = Scopes{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Scopes) String() string { return protoimpl.X.MessageStringOf(x) } func (*Scopes) ProtoMessage() {} func (x *Scopes) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *Scopes) GetScope() map[string]string { if x != nil { return x.Scope } return nil } func (x *Scopes) SetScope(v map[string]string) { x.Scope = v } type Scopes_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // Maps between a name of a scope to a short description of it (as the value // of the property). Scope map[string]string } func (b0 Scopes_builder) Build() *Scopes { m0 := &Scopes{} b, x := &b0, m0 _, _ = b, x x.Scope = b.Scope return m0 } // 'FieldConfiguration' provides additional field level properties used when generating the OpenAPI v2 file. // These properties are not defined by OpenAPIv2, but they are used to control the generation. type JSONSchema_FieldConfiguration struct { state protoimpl.MessageState `protogen:"hybrid.v1"` // Alternative parameter name when used as path parameter. If set, this will // be used as the complete parameter name when this field is used as a path // parameter. Use this to avoid having auto generated path parameter names // for overlapping paths. PathParamName string `protobuf:"bytes,47,opt,name=path_param_name,json=pathParamName,proto3" json:"path_param_name,omitempty"` // Declares this field to be deprecated. Allows for the generated OpenAPI // parameter to be marked as deprecated without affecting the proto field. Deprecated bool `protobuf:"varint,49,opt,name=deprecated,proto3" json:"deprecated,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *JSONSchema_FieldConfiguration) Reset() { *x = JSONSchema_FieldConfiguration{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *JSONSchema_FieldConfiguration) String() string { return protoimpl.X.MessageStringOf(x) } func (*JSONSchema_FieldConfiguration) ProtoMessage() {} func (x *JSONSchema_FieldConfiguration) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[27] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *JSONSchema_FieldConfiguration) GetPathParamName() string { if x != nil { return x.PathParamName } return "" } func (x *JSONSchema_FieldConfiguration) GetDeprecated() bool { if x != nil { return x.Deprecated } return false } func (x *JSONSchema_FieldConfiguration) SetPathParamName(v string) { x.PathParamName = v } func (x *JSONSchema_FieldConfiguration) SetDeprecated(v bool) { x.Deprecated = v } type JSONSchema_FieldConfiguration_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // Alternative parameter name when used as path parameter. If set, this will // be used as the complete parameter name when this field is used as a path // parameter. Use this to avoid having auto generated path parameter names // for overlapping paths. PathParamName string // Declares this field to be deprecated. Allows for the generated OpenAPI // parameter to be marked as deprecated without affecting the proto field. Deprecated bool } func (b0 JSONSchema_FieldConfiguration_builder) Build() *JSONSchema_FieldConfiguration { m0 := &JSONSchema_FieldConfiguration{} b, x := &b0, m0 _, _ = b, x x.PathParamName = b.PathParamName x.Deprecated = b.Deprecated return m0 } // If the security scheme is of type "oauth2", then the value is a list of // scope names required for the execution. For other security scheme types, // the array MUST be empty. type SecurityRequirement_SecurityRequirementValue struct { state protoimpl.MessageState `protogen:"hybrid.v1"` Scope []string `protobuf:"bytes,1,rep,name=scope,proto3" json:"scope,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *SecurityRequirement_SecurityRequirementValue) Reset() { *x = SecurityRequirement_SecurityRequirementValue{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[32] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *SecurityRequirement_SecurityRequirementValue) String() string { return protoimpl.X.MessageStringOf(x) } func (*SecurityRequirement_SecurityRequirementValue) ProtoMessage() {} func (x *SecurityRequirement_SecurityRequirementValue) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[32] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *SecurityRequirement_SecurityRequirementValue) GetScope() []string { if x != nil { return x.Scope } return nil } func (x *SecurityRequirement_SecurityRequirementValue) SetScope(v []string) { x.Scope = v } type SecurityRequirement_SecurityRequirementValue_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Scope []string } func (b0 SecurityRequirement_SecurityRequirementValue_builder) Build() *SecurityRequirement_SecurityRequirementValue { m0 := &SecurityRequirement_SecurityRequirementValue{} b, x := &b0, m0 _, _ = b, x x.Scope = b.Scope return m0 } var File_protoc_gen_openapiv2_options_openapiv2_proto protoreflect.FileDescriptor var file_protoc_gen_openapiv2_options_openapiv2_proto_rawDesc = []byte{ 0x0a, 0x2c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x29, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb3, 0x08, 0x0a, 0x07, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x12, 0x43, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x62, 0x61, 0x73, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12, 0x4b, 0x0a, 0x07, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x31, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x52, 0x07, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x73, 0x12, 0x5f, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x41, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x12, 0x71, 0x0a, 0x14, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x5f, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x3e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x44, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x13, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x44, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x5a, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x12, 0x42, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x54, 0x61, 0x67, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x65, 0x0a, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x6f, 0x63, 0x73, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x73, 0x12, 0x62, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x42, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x71, 0x0a, 0x0e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x49, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x55, 0x0a, 0x0f, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x4a, 0x04, 0x08, 0x08, 0x10, 0x09, 0x4a, 0x04, 0x08, 0x09, 0x10, 0x0a, 0x22, 0xd6, 0x07, 0x0a, 0x09, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x65, 0x0a, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x6f, 0x63, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x73, 0x12, 0x61, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x43, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x12, 0x4b, 0x0a, 0x07, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x31, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x52, 0x07, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x5a, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x12, 0x64, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x44, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x55, 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x1a, 0x71, 0x0a, 0x0e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x49, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x55, 0x0a, 0x0f, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x4a, 0x04, 0x08, 0x08, 0x10, 0x09, 0x22, 0x62, 0x0a, 0x0a, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x54, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x22, 0xa3, 0x02, 0x0a, 0x0f, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x53, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x22, 0x45, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x4e, 0x55, 0x4d, 0x42, 0x45, 0x52, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x54, 0x45, 0x47, 0x45, 0x52, 0x10, 0x03, 0x12, 0x0b, 0x0a, 0x07, 0x42, 0x4f, 0x4f, 0x4c, 0x45, 0x41, 0x4e, 0x10, 0x04, 0x4a, 0x04, 0x08, 0x06, 0x10, 0x07, 0x4a, 0x04, 0x08, 0x07, 0x10, 0x08, 0x22, 0xd8, 0x01, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x04, 0x08, 0x05, 0x10, 0x06, 0x4a, 0x04, 0x08, 0x07, 0x10, 0x08, 0x4a, 0x04, 0x08, 0x08, 0x10, 0x09, 0x4a, 0x04, 0x08, 0x09, 0x10, 0x0a, 0x4a, 0x04, 0x08, 0x0a, 0x10, 0x0b, 0x4a, 0x04, 0x08, 0x0b, 0x10, 0x0c, 0x4a, 0x04, 0x08, 0x0c, 0x10, 0x0d, 0x4a, 0x04, 0x08, 0x0e, 0x10, 0x0f, 0x4a, 0x04, 0x08, 0x0f, 0x10, 0x10, 0x4a, 0x04, 0x08, 0x10, 0x10, 0x11, 0x4a, 0x04, 0x08, 0x11, 0x10, 0x12, 0x4a, 0x04, 0x08, 0x12, 0x10, 0x13, 0x22, 0x9a, 0x05, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x49, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x5a, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x5d, 0x0a, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x41, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x12, 0x63, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x43, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x6d, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x47, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3b, 0x0a, 0x0d, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x55, 0x0a, 0x0f, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xd6, 0x03, 0x0a, 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x65, 0x72, 0x6d, 0x73, 0x5f, 0x6f, 0x66, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x74, 0x65, 0x72, 0x6d, 0x73, 0x4f, 0x66, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4c, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x12, 0x4c, 0x0a, 0x07, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x52, 0x07, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x5f, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x55, 0x0a, 0x0f, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x45, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x22, 0x2f, 0x0a, 0x07, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x22, 0x4b, 0x0a, 0x15, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x22, 0xaa, 0x02, 0x0a, 0x06, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x56, 0x0a, 0x0b, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4a, 0x53, 0x4f, 0x4e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x0a, 0x6a, 0x73, 0x6f, 0x6e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x24, 0x0a, 0x0d, 0x64, 0x69, 0x73, 0x63, 0x72, 0x69, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x64, 0x69, 0x73, 0x63, 0x72, 0x69, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x65, 0x0a, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x6f, 0x63, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x22, 0xe8, 0x03, 0x0a, 0x0a, 0x45, 0x6e, 0x75, 0x6d, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x65, 0x0a, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x6f, 0x63, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x65, 0x66, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x72, 0x65, 0x66, 0x12, 0x65, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x45, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x55, 0x0a, 0x0f, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xf7, 0x0a, 0x0a, 0x0a, 0x4a, 0x53, 0x4f, 0x4e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x65, 0x66, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x72, 0x65, 0x66, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x5f, 0x6f, 0x66, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0a, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x4f, 0x66, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x01, 0x52, 0x07, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x12, 0x2b, 0x0a, 0x11, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x76, 0x65, 0x4d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x01, 0x52, 0x07, 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x12, 0x2b, 0x0a, 0x11, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x76, 0x65, 0x5f, 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x76, 0x65, 0x4d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x61, 0x78, 0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x6d, 0x61, 0x78, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x69, 0x6e, 0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x10, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x6d, 0x69, 0x6e, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x61, 0x78, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x14, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x6d, 0x61, 0x78, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x69, 0x6e, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x15, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x6d, 0x69, 0x6e, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x16, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x18, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x6d, 0x69, 0x6e, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x19, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x6d, 0x69, 0x6e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x18, 0x1a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x72, 0x72, 0x61, 0x79, 0x18, 0x22, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x61, 0x72, 0x72, 0x61, 0x79, 0x12, 0x5f, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x23, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x4b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4a, 0x53, 0x4f, 0x4e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x4a, 0x53, 0x4f, 0x4e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x73, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x24, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x65, 0x6e, 0x75, 0x6d, 0x18, 0x2e, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x65, 0x6e, 0x75, 0x6d, 0x12, 0x7a, 0x0a, 0x13, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe9, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x48, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4a, 0x53, 0x4f, 0x4e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x12, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x65, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x30, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x45, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4a, 0x53, 0x4f, 0x4e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x5c, 0x0a, 0x12, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x26, 0x0a, 0x0f, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x2f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, 0x61, 0x74, 0x68, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x31, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x1a, 0x55, 0x0a, 0x0f, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x77, 0x0a, 0x15, 0x4a, 0x53, 0x4f, 0x4e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x73, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x52, 0x52, 0x41, 0x59, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x42, 0x4f, 0x4f, 0x4c, 0x45, 0x41, 0x4e, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x54, 0x45, 0x47, 0x45, 0x52, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x55, 0x4c, 0x4c, 0x10, 0x04, 0x12, 0x0a, 0x0a, 0x06, 0x4e, 0x55, 0x4d, 0x42, 0x45, 0x52, 0x10, 0x05, 0x12, 0x0a, 0x0a, 0x06, 0x4f, 0x42, 0x4a, 0x45, 0x43, 0x54, 0x10, 0x06, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x10, 0x07, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x4a, 0x04, 0x08, 0x02, 0x10, 0x03, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x04, 0x08, 0x12, 0x10, 0x13, 0x4a, 0x04, 0x08, 0x13, 0x10, 0x14, 0x4a, 0x04, 0x08, 0x17, 0x10, 0x18, 0x4a, 0x04, 0x08, 0x1b, 0x10, 0x1c, 0x4a, 0x04, 0x08, 0x1c, 0x10, 0x1d, 0x4a, 0x04, 0x08, 0x1d, 0x10, 0x1e, 0x4a, 0x04, 0x08, 0x1e, 0x10, 0x22, 0x4a, 0x04, 0x08, 0x25, 0x10, 0x2a, 0x4a, 0x04, 0x08, 0x2a, 0x10, 0x2b, 0x4a, 0x04, 0x08, 0x2b, 0x10, 0x2e, 0x22, 0xd9, 0x02, 0x0a, 0x03, 0x54, 0x61, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x65, 0x0a, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x6f, 0x63, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x73, 0x12, 0x5e, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x54, 0x61, 0x67, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x55, 0x0a, 0x0f, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xf7, 0x01, 0x0a, 0x13, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x44, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x68, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x4c, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x44, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x1a, 0x76, 0x0a, 0x0d, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x4f, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x39, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xff, 0x06, 0x0a, 0x0e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x12, 0x52, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x4c, 0x0a, 0x02, 0x69, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3c, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x2e, 0x49, 0x6e, 0x52, 0x02, 0x69, 0x6e, 0x12, 0x52, 0x0a, 0x04, 0x66, 0x6c, 0x6f, 0x77, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x2e, 0x46, 0x6c, 0x6f, 0x77, 0x52, 0x04, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x2b, 0x0a, 0x11, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x72, 0x6c, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x55, 0x72, 0x6c, 0x12, 0x49, 0x0a, 0x06, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x52, 0x06, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x12, 0x69, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x49, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x55, 0x0a, 0x0f, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x4b, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x0c, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x42, 0x41, 0x53, 0x49, 0x43, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x41, 0x50, 0x49, 0x5f, 0x4b, 0x45, 0x59, 0x10, 0x02, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4f, 0x41, 0x55, 0x54, 0x48, 0x32, 0x10, 0x03, 0x22, 0x31, 0x0a, 0x02, 0x49, 0x6e, 0x12, 0x0e, 0x0a, 0x0a, 0x49, 0x4e, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x49, 0x4e, 0x5f, 0x51, 0x55, 0x45, 0x52, 0x59, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x49, 0x4e, 0x5f, 0x48, 0x45, 0x41, 0x44, 0x45, 0x52, 0x10, 0x02, 0x22, 0x6a, 0x0a, 0x04, 0x46, 0x6c, 0x6f, 0x77, 0x12, 0x10, 0x0a, 0x0c, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x49, 0x4d, 0x50, 0x4c, 0x49, 0x43, 0x49, 0x54, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x50, 0x41, 0x53, 0x53, 0x57, 0x4f, 0x52, 0x44, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x41, 0x50, 0x50, 0x4c, 0x49, 0x43, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x03, 0x12, 0x14, 0x0a, 0x10, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x41, 0x43, 0x43, 0x45, 0x53, 0x53, 0x5f, 0x43, 0x4f, 0x44, 0x45, 0x10, 0x04, 0x22, 0xf6, 0x02, 0x0a, 0x13, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x8a, 0x01, 0x0a, 0x14, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x57, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x13, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x1a, 0x30, 0x0a, 0x18, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x1a, 0x9f, 0x01, 0x0a, 0x18, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x6d, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x57, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x96, 0x01, 0x0a, 0x06, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x12, 0x52, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3c, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2e, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x1a, 0x38, 0x0a, 0x0a, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x2a, 0x3b, 0x0a, 0x06, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x48, 0x54, 0x54, 0x50, 0x53, 0x10, 0x02, 0x12, 0x06, 0x0a, 0x02, 0x57, 0x53, 0x10, 0x03, 0x12, 0x07, 0x0a, 0x03, 0x57, 0x53, 0x53, 0x10, 0x04, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes = make([]protoimpl.EnumInfo, 6) var file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes = make([]protoimpl.MessageInfo, 35) var file_protoc_gen_openapiv2_options_openapiv2_proto_goTypes = []any{ (Scheme)(0), // 0: grpc.gateway.protoc_gen_openapiv2.options.Scheme (HeaderParameter_Type)(0), // 1: grpc.gateway.protoc_gen_openapiv2.options.HeaderParameter.Type (JSONSchema_JSONSchemaSimpleTypes)(0), // 2: grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.JSONSchemaSimpleTypes (SecurityScheme_Type)(0), // 3: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.Type (SecurityScheme_In)(0), // 4: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.In (SecurityScheme_Flow)(0), // 5: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.Flow (*Swagger)(nil), // 6: grpc.gateway.protoc_gen_openapiv2.options.Swagger (*Operation)(nil), // 7: grpc.gateway.protoc_gen_openapiv2.options.Operation (*Parameters)(nil), // 8: grpc.gateway.protoc_gen_openapiv2.options.Parameters (*HeaderParameter)(nil), // 9: grpc.gateway.protoc_gen_openapiv2.options.HeaderParameter (*Header)(nil), // 10: grpc.gateway.protoc_gen_openapiv2.options.Header (*Response)(nil), // 11: grpc.gateway.protoc_gen_openapiv2.options.Response (*Info)(nil), // 12: grpc.gateway.protoc_gen_openapiv2.options.Info (*Contact)(nil), // 13: grpc.gateway.protoc_gen_openapiv2.options.Contact (*License)(nil), // 14: grpc.gateway.protoc_gen_openapiv2.options.License (*ExternalDocumentation)(nil), // 15: grpc.gateway.protoc_gen_openapiv2.options.ExternalDocumentation (*Schema)(nil), // 16: grpc.gateway.protoc_gen_openapiv2.options.Schema (*EnumSchema)(nil), // 17: grpc.gateway.protoc_gen_openapiv2.options.EnumSchema (*JSONSchema)(nil), // 18: grpc.gateway.protoc_gen_openapiv2.options.JSONSchema (*Tag)(nil), // 19: grpc.gateway.protoc_gen_openapiv2.options.Tag (*SecurityDefinitions)(nil), // 20: grpc.gateway.protoc_gen_openapiv2.options.SecurityDefinitions (*SecurityScheme)(nil), // 21: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme (*SecurityRequirement)(nil), // 22: grpc.gateway.protoc_gen_openapiv2.options.SecurityRequirement (*Scopes)(nil), // 23: grpc.gateway.protoc_gen_openapiv2.options.Scopes nil, // 24: grpc.gateway.protoc_gen_openapiv2.options.Swagger.ResponsesEntry nil, // 25: grpc.gateway.protoc_gen_openapiv2.options.Swagger.ExtensionsEntry nil, // 26: grpc.gateway.protoc_gen_openapiv2.options.Operation.ResponsesEntry nil, // 27: grpc.gateway.protoc_gen_openapiv2.options.Operation.ExtensionsEntry nil, // 28: grpc.gateway.protoc_gen_openapiv2.options.Response.HeadersEntry nil, // 29: grpc.gateway.protoc_gen_openapiv2.options.Response.ExamplesEntry nil, // 30: grpc.gateway.protoc_gen_openapiv2.options.Response.ExtensionsEntry nil, // 31: grpc.gateway.protoc_gen_openapiv2.options.Info.ExtensionsEntry nil, // 32: grpc.gateway.protoc_gen_openapiv2.options.EnumSchema.ExtensionsEntry (*JSONSchema_FieldConfiguration)(nil), // 33: grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.FieldConfiguration nil, // 34: grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.ExtensionsEntry nil, // 35: grpc.gateway.protoc_gen_openapiv2.options.Tag.ExtensionsEntry nil, // 36: grpc.gateway.protoc_gen_openapiv2.options.SecurityDefinitions.SecurityEntry nil, // 37: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.ExtensionsEntry (*SecurityRequirement_SecurityRequirementValue)(nil), // 38: grpc.gateway.protoc_gen_openapiv2.options.SecurityRequirement.SecurityRequirementValue nil, // 39: grpc.gateway.protoc_gen_openapiv2.options.SecurityRequirement.SecurityRequirementEntry nil, // 40: grpc.gateway.protoc_gen_openapiv2.options.Scopes.ScopeEntry (*structpb.Value)(nil), // 41: google.protobuf.Value } var file_protoc_gen_openapiv2_options_openapiv2_proto_depIdxs = []int32{ 12, // 0: grpc.gateway.protoc_gen_openapiv2.options.Swagger.info:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Info 0, // 1: grpc.gateway.protoc_gen_openapiv2.options.Swagger.schemes:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Scheme 24, // 2: grpc.gateway.protoc_gen_openapiv2.options.Swagger.responses:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Swagger.ResponsesEntry 20, // 3: grpc.gateway.protoc_gen_openapiv2.options.Swagger.security_definitions:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityDefinitions 22, // 4: grpc.gateway.protoc_gen_openapiv2.options.Swagger.security:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityRequirement 19, // 5: grpc.gateway.protoc_gen_openapiv2.options.Swagger.tags:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Tag 15, // 6: grpc.gateway.protoc_gen_openapiv2.options.Swagger.external_docs:type_name -> grpc.gateway.protoc_gen_openapiv2.options.ExternalDocumentation 25, // 7: grpc.gateway.protoc_gen_openapiv2.options.Swagger.extensions:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Swagger.ExtensionsEntry 15, // 8: grpc.gateway.protoc_gen_openapiv2.options.Operation.external_docs:type_name -> grpc.gateway.protoc_gen_openapiv2.options.ExternalDocumentation 26, // 9: grpc.gateway.protoc_gen_openapiv2.options.Operation.responses:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Operation.ResponsesEntry 0, // 10: grpc.gateway.protoc_gen_openapiv2.options.Operation.schemes:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Scheme 22, // 11: grpc.gateway.protoc_gen_openapiv2.options.Operation.security:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityRequirement 27, // 12: grpc.gateway.protoc_gen_openapiv2.options.Operation.extensions:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Operation.ExtensionsEntry 8, // 13: grpc.gateway.protoc_gen_openapiv2.options.Operation.parameters:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Parameters 9, // 14: grpc.gateway.protoc_gen_openapiv2.options.Parameters.headers:type_name -> grpc.gateway.protoc_gen_openapiv2.options.HeaderParameter 1, // 15: grpc.gateway.protoc_gen_openapiv2.options.HeaderParameter.type:type_name -> grpc.gateway.protoc_gen_openapiv2.options.HeaderParameter.Type 16, // 16: grpc.gateway.protoc_gen_openapiv2.options.Response.schema:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Schema 28, // 17: grpc.gateway.protoc_gen_openapiv2.options.Response.headers:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Response.HeadersEntry 29, // 18: grpc.gateway.protoc_gen_openapiv2.options.Response.examples:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Response.ExamplesEntry 30, // 19: grpc.gateway.protoc_gen_openapiv2.options.Response.extensions:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Response.ExtensionsEntry 13, // 20: grpc.gateway.protoc_gen_openapiv2.options.Info.contact:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Contact 14, // 21: grpc.gateway.protoc_gen_openapiv2.options.Info.license:type_name -> grpc.gateway.protoc_gen_openapiv2.options.License 31, // 22: grpc.gateway.protoc_gen_openapiv2.options.Info.extensions:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Info.ExtensionsEntry 18, // 23: grpc.gateway.protoc_gen_openapiv2.options.Schema.json_schema:type_name -> grpc.gateway.protoc_gen_openapiv2.options.JSONSchema 15, // 24: grpc.gateway.protoc_gen_openapiv2.options.Schema.external_docs:type_name -> grpc.gateway.protoc_gen_openapiv2.options.ExternalDocumentation 15, // 25: grpc.gateway.protoc_gen_openapiv2.options.EnumSchema.external_docs:type_name -> grpc.gateway.protoc_gen_openapiv2.options.ExternalDocumentation 32, // 26: grpc.gateway.protoc_gen_openapiv2.options.EnumSchema.extensions:type_name -> grpc.gateway.protoc_gen_openapiv2.options.EnumSchema.ExtensionsEntry 2, // 27: grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.type:type_name -> grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.JSONSchemaSimpleTypes 33, // 28: grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.field_configuration:type_name -> grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.FieldConfiguration 34, // 29: grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.extensions:type_name -> grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.ExtensionsEntry 15, // 30: grpc.gateway.protoc_gen_openapiv2.options.Tag.external_docs:type_name -> grpc.gateway.protoc_gen_openapiv2.options.ExternalDocumentation 35, // 31: grpc.gateway.protoc_gen_openapiv2.options.Tag.extensions:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Tag.ExtensionsEntry 36, // 32: grpc.gateway.protoc_gen_openapiv2.options.SecurityDefinitions.security:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityDefinitions.SecurityEntry 3, // 33: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.type:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.Type 4, // 34: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.in:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.In 5, // 35: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.flow:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.Flow 23, // 36: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.scopes:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Scopes 37, // 37: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.extensions:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.ExtensionsEntry 39, // 38: grpc.gateway.protoc_gen_openapiv2.options.SecurityRequirement.security_requirement:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityRequirement.SecurityRequirementEntry 40, // 39: grpc.gateway.protoc_gen_openapiv2.options.Scopes.scope:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Scopes.ScopeEntry 11, // 40: grpc.gateway.protoc_gen_openapiv2.options.Swagger.ResponsesEntry.value:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Response 41, // 41: grpc.gateway.protoc_gen_openapiv2.options.Swagger.ExtensionsEntry.value:type_name -> google.protobuf.Value 11, // 42: grpc.gateway.protoc_gen_openapiv2.options.Operation.ResponsesEntry.value:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Response 41, // 43: grpc.gateway.protoc_gen_openapiv2.options.Operation.ExtensionsEntry.value:type_name -> google.protobuf.Value 10, // 44: grpc.gateway.protoc_gen_openapiv2.options.Response.HeadersEntry.value:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Header 41, // 45: grpc.gateway.protoc_gen_openapiv2.options.Response.ExtensionsEntry.value:type_name -> google.protobuf.Value 41, // 46: grpc.gateway.protoc_gen_openapiv2.options.Info.ExtensionsEntry.value:type_name -> google.protobuf.Value 41, // 47: grpc.gateway.protoc_gen_openapiv2.options.EnumSchema.ExtensionsEntry.value:type_name -> google.protobuf.Value 41, // 48: grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.ExtensionsEntry.value:type_name -> google.protobuf.Value 41, // 49: grpc.gateway.protoc_gen_openapiv2.options.Tag.ExtensionsEntry.value:type_name -> google.protobuf.Value 21, // 50: grpc.gateway.protoc_gen_openapiv2.options.SecurityDefinitions.SecurityEntry.value:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme 41, // 51: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.ExtensionsEntry.value:type_name -> google.protobuf.Value 38, // 52: grpc.gateway.protoc_gen_openapiv2.options.SecurityRequirement.SecurityRequirementEntry.value:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityRequirement.SecurityRequirementValue 53, // [53:53] is the sub-list for method output_type 53, // [53:53] is the sub-list for method input_type 53, // [53:53] is the sub-list for extension type_name 53, // [53:53] is the sub-list for extension extendee 0, // [0:53] is the sub-list for field type_name } func init() { file_protoc_gen_openapiv2_options_openapiv2_proto_init() } func file_protoc_gen_openapiv2_options_openapiv2_proto_init() { if File_protoc_gen_openapiv2_options_openapiv2_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_protoc_gen_openapiv2_options_openapiv2_proto_rawDesc, NumEnums: 6, NumMessages: 35, NumExtensions: 0, NumServices: 0, }, GoTypes: file_protoc_gen_openapiv2_options_openapiv2_proto_goTypes, DependencyIndexes: file_protoc_gen_openapiv2_options_openapiv2_proto_depIdxs, EnumInfos: file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes, MessageInfos: file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes, }.Build() File_protoc_gen_openapiv2_options_openapiv2_proto = out.File file_protoc_gen_openapiv2_options_openapiv2_proto_rawDesc = nil file_protoc_gen_openapiv2_options_openapiv2_proto_goTypes = nil file_protoc_gen_openapiv2_options_openapiv2_proto_depIdxs = nil } ================================================ FILE: protoc-gen-openapiv2/options/openapiv2.proto ================================================ syntax = "proto3"; package grpc.gateway.protoc_gen_openapiv2.options; import "google/protobuf/struct.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"; // Scheme describes the schemes supported by the OpenAPI Swagger // and Operation objects. enum Scheme { UNKNOWN = 0; HTTP = 1; HTTPS = 2; WS = 3; WSS = 4; } // `Swagger` is a representation of OpenAPI v2 specification's Swagger object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#swaggerObject // // Example: // // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { // info: { // title: "Echo API"; // version: "1.0"; // description: ""; // contact: { // name: "gRPC-Gateway project"; // url: "https://github.com/grpc-ecosystem/grpc-gateway"; // email: "none@example.com"; // }; // license: { // name: "BSD 3-Clause License"; // url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE"; // }; // }; // schemes: HTTPS; // consumes: "application/json"; // produces: "application/json"; // }; // message Swagger { // Specifies the OpenAPI Specification version being used. It can be // used by the OpenAPI UI and other clients to interpret the API listing. The // value MUST be "2.0". string swagger = 1; // Provides metadata about the API. The metadata can be used by the // clients if needed. Info info = 2; // The host (name or ip) serving the API. This MUST be the host only and does // not include the scheme nor sub-paths. It MAY include a port. If the host is // not included, the host serving the documentation is to be used (including // the port). The host does not support path templating. string host = 3; // The base path on which the API is served, which is relative to the host. If // it is not included, the API is served directly under the host. The value // MUST start with a leading slash (/). The basePath does not support path // templating. // Note that using `base_path` does not change the endpoint paths that are // generated in the resulting OpenAPI file. If you wish to use `base_path` // with relatively generated OpenAPI paths, the `base_path` prefix must be // manually removed from your `google.api.http` paths and your code changed to // serve the API from the `base_path`. string base_path = 4; // The transfer protocol of the API. Values MUST be from the list: "http", // "https", "ws", "wss". If the schemes is not included, the default scheme to // be used is the one used to access the OpenAPI definition itself. repeated Scheme schemes = 5; // A list of MIME types the APIs can consume. This is global to all APIs but // can be overridden on specific API calls. Value MUST be as described under // Mime Types. repeated string consumes = 6; // A list of MIME types the APIs can produce. This is global to all APIs but // can be overridden on specific API calls. Value MUST be as described under // Mime Types. repeated string produces = 7; // field 8 is reserved for 'paths'. reserved 8; // field 9 is reserved for 'definitions', which at this time are already // exposed as and customizable as proto messages. reserved 9; // An object to hold responses that can be used across operations. This // property does not define global responses for all operations. map responses = 10; // Security scheme definitions that can be used across the specification. SecurityDefinitions security_definitions = 11; // A declaration of which security schemes are applied for the API as a whole. // The list of values describes alternative security schemes that can be used // (that is, there is a logical OR between the security requirements). // Individual operations can override this definition. repeated SecurityRequirement security = 12; // A list of tags for API documentation control. Tags can be used for logical // grouping of operations by resources or any other qualifier. repeated Tag tags = 13; // Additional external documentation. ExternalDocumentation external_docs = 14; // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ map extensions = 15; } // `Operation` is a representation of OpenAPI v2 specification's Operation object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#operationObject // // Example: // // service EchoService { // rpc Echo(SimpleMessage) returns (SimpleMessage) { // option (google.api.http) = { // get: "/v1/example/echo/{id}" // }; // // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { // summary: "Get a message."; // operation_id: "getMessage"; // tags: "echo"; // responses: { // key: "200" // value: { // description: "OK"; // } // } // }; // } // } message Operation { // A list of tags for API documentation control. Tags can be used for logical // grouping of operations by resources or any other qualifier. repeated string tags = 1; // A short summary of what the operation does. For maximum readability in the // swagger-ui, this field SHOULD be less than 120 characters. string summary = 2; // A verbose explanation of the operation behavior. GFM syntax can be used for // rich text representation. string description = 3; // Additional external documentation for this operation. ExternalDocumentation external_docs = 4; // Unique string used to identify the operation. The id MUST be unique among // all operations described in the API. Tools and libraries MAY use the // operationId to uniquely identify an operation, therefore, it is recommended // to follow common programming naming conventions. string operation_id = 5; // A list of MIME types the operation can consume. This overrides the consumes // definition at the OpenAPI Object. An empty value MAY be used to clear the // global definition. Value MUST be as described under Mime Types. repeated string consumes = 6; // A list of MIME types the operation can produce. This overrides the produces // definition at the OpenAPI Object. An empty value MAY be used to clear the // global definition. Value MUST be as described under Mime Types. repeated string produces = 7; // field 8 is reserved for 'parameters'. reserved 8; // The list of possible responses as they are returned from executing this // operation. map responses = 9; // The transfer protocol for the operation. Values MUST be from the list: // "http", "https", "ws", "wss". The value overrides the OpenAPI Object // schemes definition. repeated Scheme schemes = 10; // Declares this operation to be deprecated. Usage of the declared operation // should be refrained. Default value is false. bool deprecated = 11; // A declaration of which security schemes are applied for this operation. The // list of values describes alternative security schemes that can be used // (that is, there is a logical OR between the security requirements). This // definition overrides any declared top-level security. To remove a top-level // security declaration, an empty array can be used. repeated SecurityRequirement security = 12; // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ map extensions = 13; // Custom parameters such as HTTP request headers. // See: https://swagger.io/docs/specification/2-0/describing-parameters/ // and https://swagger.io/specification/v2/#parameter-object. Parameters parameters = 14; } // `Parameters` is a representation of OpenAPI v2 specification's parameters object. // Note: This technically breaks compatibility with the OpenAPI 2 definition structure as we only // allow header parameters to be set here since we do not want users specifying custom non-header // parameters beyond those inferred from the Protobuf schema. // See: https://swagger.io/specification/v2/#parameter-object message Parameters { // `Headers` is one or more HTTP header parameter. // See: https://swagger.io/docs/specification/2-0/describing-parameters/#header-parameters repeated HeaderParameter headers = 1; } // `HeaderParameter` a HTTP header parameter. // See: https://swagger.io/specification/v2/#parameter-object message HeaderParameter { // `Type` is a supported HTTP header type. // See https://swagger.io/specification/v2/#parameterType. enum Type { UNKNOWN = 0; STRING = 1; NUMBER = 2; INTEGER = 3; BOOLEAN = 4; } // `Name` is the header name. string name = 1; // `Description` is a short description of the header. string description = 2; // `Type` is the type of the object. The value MUST be one of "string", "number", "integer", or "boolean". The "array" type is not supported. // See: https://swagger.io/specification/v2/#parameterType. Type type = 3; // `Format` The extending format for the previously mentioned type. string format = 4; // `Required` indicates if the header is optional bool required = 5; // field 6 is reserved for 'items', but in OpenAPI-specific way. reserved 6; // field 7 is reserved `Collection Format`. Determines the format of the array if type array is used. reserved 7; } // `Header` is a representation of OpenAPI v2 specification's Header object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#headerObject // message Header { // `Description` is a short description of the header. string description = 1; // The type of the object. The value MUST be one of "string", "number", "integer", or "boolean". The "array" type is not supported. string type = 2; // `Format` The extending format for the previously mentioned type. string format = 3; // field 4 is reserved for 'items', but in OpenAPI-specific way. reserved 4; // field 5 is reserved `Collection Format` Determines the format of the array if type array is used. reserved 5; // `Default` Declares the value of the header that the server will use if none is provided. // See: https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-6.2. // Unlike JSON Schema this value MUST conform to the defined type for the header. string default = 6; // field 7 is reserved for 'maximum'. reserved 7; // field 8 is reserved for 'exclusiveMaximum'. reserved 8; // field 9 is reserved for 'minimum'. reserved 9; // field 10 is reserved for 'exclusiveMinimum'. reserved 10; // field 11 is reserved for 'maxLength'. reserved 11; // field 12 is reserved for 'minLength'. reserved 12; // 'Pattern' See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.2.3. string pattern = 13; // field 14 is reserved for 'maxItems'. reserved 14; // field 15 is reserved for 'minItems'. reserved 15; // field 16 is reserved for 'uniqueItems'. reserved 16; // field 17 is reserved for 'enum'. reserved 17; // field 18 is reserved for 'multipleOf'. reserved 18; } // `Response` is a representation of OpenAPI v2 specification's Response object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#responseObject // message Response { // `Description` is a short description of the response. // GFM syntax can be used for rich text representation. string description = 1; // `Schema` optionally defines the structure of the response. // If `Schema` is not provided, it means there is no content to the response. Schema schema = 2; // `Headers` A list of headers that are sent with the response. // `Header` name is expected to be a string in the canonical format of the MIME header key // See: https://golang.org/pkg/net/textproto/#CanonicalMIMEHeaderKey map headers = 3; // `Examples` gives per-mimetype response examples. // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#example-object map examples = 4; // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ map extensions = 5; } // `Info` is a representation of OpenAPI v2 specification's Info object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#infoObject // // Example: // // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { // info: { // title: "Echo API"; // version: "1.0"; // description: ""; // contact: { // name: "gRPC-Gateway project"; // url: "https://github.com/grpc-ecosystem/grpc-gateway"; // email: "none@example.com"; // }; // license: { // name: "BSD 3-Clause License"; // url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE"; // }; // }; // ... // }; // message Info { // The title of the application. string title = 1; // A short description of the application. GFM syntax can be used for rich // text representation. string description = 2; // The Terms of Service for the API. string terms_of_service = 3; // The contact information for the exposed API. Contact contact = 4; // The license information for the exposed API. License license = 5; // Provides the version of the application API (not to be confused // with the specification version). string version = 6; // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ map extensions = 7; } // `Contact` is a representation of OpenAPI v2 specification's Contact object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#contactObject // // Example: // // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { // info: { // ... // contact: { // name: "gRPC-Gateway project"; // url: "https://github.com/grpc-ecosystem/grpc-gateway"; // email: "none@example.com"; // }; // ... // }; // ... // }; // message Contact { // The identifying name of the contact person/organization. string name = 1; // The URL pointing to the contact information. MUST be in the format of a // URL. string url = 2; // The email address of the contact person/organization. MUST be in the format // of an email address. string email = 3; } // `License` is a representation of OpenAPI v2 specification's License object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#licenseObject // // Example: // // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { // info: { // ... // license: { // name: "BSD 3-Clause License"; // url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE"; // }; // ... // }; // ... // }; // message License { // The license name used for the API. string name = 1; // A URL to the license used for the API. MUST be in the format of a URL. string url = 2; } // `ExternalDocumentation` is a representation of OpenAPI v2 specification's // ExternalDocumentation object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#externalDocumentationObject // // Example: // // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { // ... // external_docs: { // description: "More about gRPC-Gateway"; // url: "https://github.com/grpc-ecosystem/grpc-gateway"; // } // ... // }; // message ExternalDocumentation { // A short description of the target documentation. GFM syntax can be used for // rich text representation. string description = 1; // The URL for the target documentation. Value MUST be in the format // of a URL. string url = 2; } // `Schema` is a representation of OpenAPI v2 specification's Schema object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject // message Schema { JSONSchema json_schema = 1; // Adds support for polymorphism. The discriminator is the schema property // name that is used to differentiate between other schema that inherit this // schema. The property name used MUST be defined at this schema and it MUST // be in the required property list. When used, the value MUST be the name of // this schema or any schema that inherits it. string discriminator = 2; // Relevant only for Schema "properties" definitions. Declares the property as // "read only". This means that it MAY be sent as part of a response but MUST // NOT be sent as part of the request. Properties marked as readOnly being // true SHOULD NOT be in the required list of the defined schema. Default // value is false. bool read_only = 3; // field 4 is reserved for 'xml'. reserved 4; // Additional external documentation for this schema. ExternalDocumentation external_docs = 5; // A free-form property to include an example of an instance for this schema in JSON. // This is copied verbatim to the output. string example = 6; } // `EnumSchema` is subset of fields from the OpenAPI v2 specification's Schema object. // Only fields that are applicable to Enums are included // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject // // Example: // // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_enum) = { // ... // title: "MyEnum"; // description:"This is my nice enum"; // example: "ZERO"; // required: true; // ... // }; // message EnumSchema { // A short description of the schema. string description = 1; string default = 2; // The title of the schema. string title = 3; bool required = 4; bool read_only = 5; // Additional external documentation for this schema. ExternalDocumentation external_docs = 6; string example = 7; // Ref is used to define an external reference to include in the message. // This could be a fully qualified proto message reference, and that type must // be imported into the protofile. If no message is identified, the Ref will // be used verbatim in the output. // For example: // `ref: ".google.protobuf.Timestamp"`. string ref = 8; // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ map extensions = 9; } // `JSONSchema` represents properties from JSON Schema taken, and as used, in // the OpenAPI v2 spec. // // This includes changes made by OpenAPI v2. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject // // See also: https://cswr.github.io/JsonSchema/spec/basic_types/, // https://github.com/json-schema-org/json-schema-spec/blob/master/schema.json // // Example: // // message SimpleMessage { // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { // json_schema: { // title: "SimpleMessage" // description: "A simple message." // required: ["id"] // } // }; // // // Id represents the message identifier. // string id = 1; [ // (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { // description: "The unique identifier of the simple message." // }]; // } // message JSONSchema { // field 1 is reserved for '$id', omitted from OpenAPI v2. reserved 1; // field 2 is reserved for '$schema', omitted from OpenAPI v2. reserved 2; // Ref is used to define an external reference to include in the message. // This could be a fully qualified proto message reference, and that type must // be imported into the protofile. If no message is identified, the Ref will // be used verbatim in the output. // For example: // `ref: ".google.protobuf.Timestamp"`. string ref = 3; // field 4 is reserved for '$comment', omitted from OpenAPI v2. reserved 4; // The title of the schema. string title = 5; // A short description of the schema. string description = 6; string default = 7; bool read_only = 8; // A free-form property to include a JSON example of this field. This is copied // verbatim to the output swagger.json. Quotes must be escaped. // This property is the same for 2.0 and 3.0.0 https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/3.0.0.md#schemaObject https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject string example = 9; double multiple_of = 10; // Maximum represents an inclusive upper limit for a numeric instance. The // value of MUST be a number, double maximum = 11; bool exclusive_maximum = 12; // minimum represents an inclusive lower limit for a numeric instance. The // value of MUST be a number, double minimum = 13; bool exclusive_minimum = 14; uint64 max_length = 15; uint64 min_length = 16; string pattern = 17; // field 18 is reserved for 'additionalItems', omitted from OpenAPI v2. reserved 18; // field 19 is reserved for 'items', but in OpenAPI-specific way. // TODO(ivucica): add 'items'? reserved 19; uint64 max_items = 20; uint64 min_items = 21; bool unique_items = 22; // field 23 is reserved for 'contains', omitted from OpenAPI v2. reserved 23; uint64 max_properties = 24; uint64 min_properties = 25; repeated string required = 26; // field 27 is reserved for 'additionalProperties', but in OpenAPI-specific // way. TODO(ivucica): add 'additionalProperties'? reserved 27; // field 28 is reserved for 'definitions', omitted from OpenAPI v2. reserved 28; // field 29 is reserved for 'properties', but in OpenAPI-specific way. // TODO(ivucica): add 'additionalProperties'? reserved 29; // following fields are reserved, as the properties have been omitted from // OpenAPI v2: // patternProperties, dependencies, propertyNames, const reserved 30 to 33; // Items in 'array' must be unique. repeated string array = 34; enum JSONSchemaSimpleTypes { UNKNOWN = 0; ARRAY = 1; BOOLEAN = 2; INTEGER = 3; NULL = 4; NUMBER = 5; OBJECT = 6; STRING = 7; } repeated JSONSchemaSimpleTypes type = 35; // `Format` string format = 36; // following fields are reserved, as the properties have been omitted from // OpenAPI v2: contentMediaType, contentEncoding, if, then, else reserved 37 to 41; // field 42 is reserved for 'allOf', but in OpenAPI-specific way. // TODO(ivucica): add 'allOf'? reserved 42; // following fields are reserved, as the properties have been omitted from // OpenAPI v2: // anyOf, oneOf, not reserved 43 to 45; // Items in `enum` must be unique https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.1 repeated string enum = 46; // Additional field level properties used when generating the OpenAPI v2 file. FieldConfiguration field_configuration = 1001; // 'FieldConfiguration' provides additional field level properties used when generating the OpenAPI v2 file. // These properties are not defined by OpenAPIv2, but they are used to control the generation. message FieldConfiguration { // Alternative parameter name when used as path parameter. If set, this will // be used as the complete parameter name when this field is used as a path // parameter. Use this to avoid having auto generated path parameter names // for overlapping paths. string path_param_name = 47; // Declares this field to be deprecated. Allows for the generated OpenAPI // parameter to be marked as deprecated without affecting the proto field. bool deprecated = 49; } // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ map extensions = 48; } // `Tag` is a representation of OpenAPI v2 specification's Tag object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#tagObject // message Tag { // The name of the tag. Use it to allow override of the name of a // global Tag object, then use that name to reference the tag throughout the // OpenAPI file. string name = 1; // A short description for the tag. GFM syntax can be used for rich text // representation. string description = 2; // Additional external documentation for this tag. ExternalDocumentation external_docs = 3; // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ map extensions = 4; } // `SecurityDefinitions` is a representation of OpenAPI v2 specification's // Security Definitions object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityDefinitionsObject // // A declaration of the security schemes available to be used in the // specification. This does not enforce the security schemes on the operations // and only serves to provide the relevant details for each scheme. message SecurityDefinitions { // A single security scheme definition, mapping a "name" to the scheme it // defines. map security = 1; } // `SecurityScheme` is a representation of OpenAPI v2 specification's // Security Scheme object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securitySchemeObject // // Allows the definition of a security scheme that can be used by the // operations. Supported schemes are basic authentication, an API key (either as // a header or as a query parameter) and OAuth2's common flows (implicit, // password, application and access code). message SecurityScheme { // The type of the security scheme. Valid values are "basic", // "apiKey" or "oauth2". enum Type { TYPE_INVALID = 0; TYPE_BASIC = 1; TYPE_API_KEY = 2; TYPE_OAUTH2 = 3; } // The location of the API key. Valid values are "query" or "header". enum In { IN_INVALID = 0; IN_QUERY = 1; IN_HEADER = 2; } // The flow used by the OAuth2 security scheme. Valid values are // "implicit", "password", "application" or "accessCode". enum Flow { FLOW_INVALID = 0; FLOW_IMPLICIT = 1; FLOW_PASSWORD = 2; FLOW_APPLICATION = 3; FLOW_ACCESS_CODE = 4; } // The type of the security scheme. Valid values are "basic", // "apiKey" or "oauth2". Type type = 1; // A short description for security scheme. string description = 2; // The name of the header or query parameter to be used. // Valid for apiKey. string name = 3; // The location of the API key. Valid values are "query" or // "header". // Valid for apiKey. In in = 4; // The flow used by the OAuth2 security scheme. Valid values are // "implicit", "password", "application" or "accessCode". // Valid for oauth2. Flow flow = 5; // The authorization URL to be used for this flow. This SHOULD be in // the form of a URL. // Valid for oauth2/implicit and oauth2/accessCode. string authorization_url = 6; // The token URL to be used for this flow. This SHOULD be in the // form of a URL. // Valid for oauth2/password, oauth2/application and oauth2/accessCode. string token_url = 7; // The available scopes for the OAuth2 security scheme. // Valid for oauth2. Scopes scopes = 8; // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ map extensions = 9; } // `SecurityRequirement` is a representation of OpenAPI v2 specification's // Security Requirement object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityRequirementObject // // Lists the required security schemes to execute this operation. The object can // have multiple security schemes declared in it which are all required (that // is, there is a logical AND between the schemes). // // The name used for each property MUST correspond to a security scheme // declared in the Security Definitions. message SecurityRequirement { // If the security scheme is of type "oauth2", then the value is a list of // scope names required for the execution. For other security scheme types, // the array MUST be empty. message SecurityRequirementValue { repeated string scope = 1; } // Each name must correspond to a security scheme which is declared in // the Security Definitions. If the security scheme is of type "oauth2", // then the value is a list of scope names required for the execution. // For other security scheme types, the array MUST be empty. map security_requirement = 1; } // `Scopes` is a representation of OpenAPI v2 specification's Scopes object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#scopesObject // // Lists the available scopes for an OAuth2 security scheme. message Scopes { // Maps between a name of a scope to a short description of it (as the value // of the property). map scope = 1; } ================================================ FILE: protoc-gen-openapiv2/options/openapiv2_protoopaque.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.0 // protoc (unknown) // source: protoc-gen-openapiv2/options/openapiv2.proto //go:build protoopaque package options import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" structpb "google.golang.org/protobuf/types/known/structpb" reflect "reflect" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) // Scheme describes the schemes supported by the OpenAPI Swagger // and Operation objects. type Scheme int32 const ( Scheme_UNKNOWN Scheme = 0 Scheme_HTTP Scheme = 1 Scheme_HTTPS Scheme = 2 Scheme_WS Scheme = 3 Scheme_WSS Scheme = 4 ) // Enum value maps for Scheme. var ( Scheme_name = map[int32]string{ 0: "UNKNOWN", 1: "HTTP", 2: "HTTPS", 3: "WS", 4: "WSS", } Scheme_value = map[string]int32{ "UNKNOWN": 0, "HTTP": 1, "HTTPS": 2, "WS": 3, "WSS": 4, } ) func (x Scheme) Enum() *Scheme { p := new(Scheme) *p = x return p } func (x Scheme) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (Scheme) Descriptor() protoreflect.EnumDescriptor { return file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[0].Descriptor() } func (Scheme) Type() protoreflect.EnumType { return &file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[0] } func (x Scheme) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // `Type` is a supported HTTP header type. // See https://swagger.io/specification/v2/#parameterType. type HeaderParameter_Type int32 const ( HeaderParameter_UNKNOWN HeaderParameter_Type = 0 HeaderParameter_STRING HeaderParameter_Type = 1 HeaderParameter_NUMBER HeaderParameter_Type = 2 HeaderParameter_INTEGER HeaderParameter_Type = 3 HeaderParameter_BOOLEAN HeaderParameter_Type = 4 ) // Enum value maps for HeaderParameter_Type. var ( HeaderParameter_Type_name = map[int32]string{ 0: "UNKNOWN", 1: "STRING", 2: "NUMBER", 3: "INTEGER", 4: "BOOLEAN", } HeaderParameter_Type_value = map[string]int32{ "UNKNOWN": 0, "STRING": 1, "NUMBER": 2, "INTEGER": 3, "BOOLEAN": 4, } ) func (x HeaderParameter_Type) Enum() *HeaderParameter_Type { p := new(HeaderParameter_Type) *p = x return p } func (x HeaderParameter_Type) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (HeaderParameter_Type) Descriptor() protoreflect.EnumDescriptor { return file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[1].Descriptor() } func (HeaderParameter_Type) Type() protoreflect.EnumType { return &file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[1] } func (x HeaderParameter_Type) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } type JSONSchema_JSONSchemaSimpleTypes int32 const ( JSONSchema_UNKNOWN JSONSchema_JSONSchemaSimpleTypes = 0 JSONSchema_ARRAY JSONSchema_JSONSchemaSimpleTypes = 1 JSONSchema_BOOLEAN JSONSchema_JSONSchemaSimpleTypes = 2 JSONSchema_INTEGER JSONSchema_JSONSchemaSimpleTypes = 3 JSONSchema_NULL JSONSchema_JSONSchemaSimpleTypes = 4 JSONSchema_NUMBER JSONSchema_JSONSchemaSimpleTypes = 5 JSONSchema_OBJECT JSONSchema_JSONSchemaSimpleTypes = 6 JSONSchema_STRING JSONSchema_JSONSchemaSimpleTypes = 7 ) // Enum value maps for JSONSchema_JSONSchemaSimpleTypes. var ( JSONSchema_JSONSchemaSimpleTypes_name = map[int32]string{ 0: "UNKNOWN", 1: "ARRAY", 2: "BOOLEAN", 3: "INTEGER", 4: "NULL", 5: "NUMBER", 6: "OBJECT", 7: "STRING", } JSONSchema_JSONSchemaSimpleTypes_value = map[string]int32{ "UNKNOWN": 0, "ARRAY": 1, "BOOLEAN": 2, "INTEGER": 3, "NULL": 4, "NUMBER": 5, "OBJECT": 6, "STRING": 7, } ) func (x JSONSchema_JSONSchemaSimpleTypes) Enum() *JSONSchema_JSONSchemaSimpleTypes { p := new(JSONSchema_JSONSchemaSimpleTypes) *p = x return p } func (x JSONSchema_JSONSchemaSimpleTypes) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (JSONSchema_JSONSchemaSimpleTypes) Descriptor() protoreflect.EnumDescriptor { return file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[2].Descriptor() } func (JSONSchema_JSONSchemaSimpleTypes) Type() protoreflect.EnumType { return &file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[2] } func (x JSONSchema_JSONSchemaSimpleTypes) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // The type of the security scheme. Valid values are "basic", // "apiKey" or "oauth2". type SecurityScheme_Type int32 const ( SecurityScheme_TYPE_INVALID SecurityScheme_Type = 0 SecurityScheme_TYPE_BASIC SecurityScheme_Type = 1 SecurityScheme_TYPE_API_KEY SecurityScheme_Type = 2 SecurityScheme_TYPE_OAUTH2 SecurityScheme_Type = 3 ) // Enum value maps for SecurityScheme_Type. var ( SecurityScheme_Type_name = map[int32]string{ 0: "TYPE_INVALID", 1: "TYPE_BASIC", 2: "TYPE_API_KEY", 3: "TYPE_OAUTH2", } SecurityScheme_Type_value = map[string]int32{ "TYPE_INVALID": 0, "TYPE_BASIC": 1, "TYPE_API_KEY": 2, "TYPE_OAUTH2": 3, } ) func (x SecurityScheme_Type) Enum() *SecurityScheme_Type { p := new(SecurityScheme_Type) *p = x return p } func (x SecurityScheme_Type) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (SecurityScheme_Type) Descriptor() protoreflect.EnumDescriptor { return file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[3].Descriptor() } func (SecurityScheme_Type) Type() protoreflect.EnumType { return &file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[3] } func (x SecurityScheme_Type) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // The location of the API key. Valid values are "query" or "header". type SecurityScheme_In int32 const ( SecurityScheme_IN_INVALID SecurityScheme_In = 0 SecurityScheme_IN_QUERY SecurityScheme_In = 1 SecurityScheme_IN_HEADER SecurityScheme_In = 2 ) // Enum value maps for SecurityScheme_In. var ( SecurityScheme_In_name = map[int32]string{ 0: "IN_INVALID", 1: "IN_QUERY", 2: "IN_HEADER", } SecurityScheme_In_value = map[string]int32{ "IN_INVALID": 0, "IN_QUERY": 1, "IN_HEADER": 2, } ) func (x SecurityScheme_In) Enum() *SecurityScheme_In { p := new(SecurityScheme_In) *p = x return p } func (x SecurityScheme_In) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (SecurityScheme_In) Descriptor() protoreflect.EnumDescriptor { return file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[4].Descriptor() } func (SecurityScheme_In) Type() protoreflect.EnumType { return &file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[4] } func (x SecurityScheme_In) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // The flow used by the OAuth2 security scheme. Valid values are // "implicit", "password", "application" or "accessCode". type SecurityScheme_Flow int32 const ( SecurityScheme_FLOW_INVALID SecurityScheme_Flow = 0 SecurityScheme_FLOW_IMPLICIT SecurityScheme_Flow = 1 SecurityScheme_FLOW_PASSWORD SecurityScheme_Flow = 2 SecurityScheme_FLOW_APPLICATION SecurityScheme_Flow = 3 SecurityScheme_FLOW_ACCESS_CODE SecurityScheme_Flow = 4 ) // Enum value maps for SecurityScheme_Flow. var ( SecurityScheme_Flow_name = map[int32]string{ 0: "FLOW_INVALID", 1: "FLOW_IMPLICIT", 2: "FLOW_PASSWORD", 3: "FLOW_APPLICATION", 4: "FLOW_ACCESS_CODE", } SecurityScheme_Flow_value = map[string]int32{ "FLOW_INVALID": 0, "FLOW_IMPLICIT": 1, "FLOW_PASSWORD": 2, "FLOW_APPLICATION": 3, "FLOW_ACCESS_CODE": 4, } ) func (x SecurityScheme_Flow) Enum() *SecurityScheme_Flow { p := new(SecurityScheme_Flow) *p = x return p } func (x SecurityScheme_Flow) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (SecurityScheme_Flow) Descriptor() protoreflect.EnumDescriptor { return file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[5].Descriptor() } func (SecurityScheme_Flow) Type() protoreflect.EnumType { return &file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes[5] } func (x SecurityScheme_Flow) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // `Swagger` is a representation of OpenAPI v2 specification's Swagger object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#swaggerObject // // Example: // // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { // info: { // title: "Echo API"; // version: "1.0"; // description: ""; // contact: { // name: "gRPC-Gateway project"; // url: "https://github.com/grpc-ecosystem/grpc-gateway"; // email: "none@example.com"; // }; // license: { // name: "BSD 3-Clause License"; // url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE"; // }; // }; // schemes: HTTPS; // consumes: "application/json"; // produces: "application/json"; // }; type Swagger struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Swagger string `protobuf:"bytes,1,opt,name=swagger,proto3" json:"swagger,omitempty"` xxx_hidden_Info *Info `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` xxx_hidden_Host string `protobuf:"bytes,3,opt,name=host,proto3" json:"host,omitempty"` xxx_hidden_BasePath string `protobuf:"bytes,4,opt,name=base_path,json=basePath,proto3" json:"base_path,omitempty"` xxx_hidden_Schemes []Scheme `protobuf:"varint,5,rep,packed,name=schemes,proto3,enum=grpc.gateway.protoc_gen_openapiv2.options.Scheme" json:"schemes,omitempty"` xxx_hidden_Consumes []string `protobuf:"bytes,6,rep,name=consumes,proto3" json:"consumes,omitempty"` xxx_hidden_Produces []string `protobuf:"bytes,7,rep,name=produces,proto3" json:"produces,omitempty"` xxx_hidden_Responses map[string]*Response `protobuf:"bytes,10,rep,name=responses,proto3" json:"responses,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` xxx_hidden_SecurityDefinitions *SecurityDefinitions `protobuf:"bytes,11,opt,name=security_definitions,json=securityDefinitions,proto3" json:"security_definitions,omitempty"` xxx_hidden_Security *[]*SecurityRequirement `protobuf:"bytes,12,rep,name=security,proto3" json:"security,omitempty"` xxx_hidden_Tags *[]*Tag `protobuf:"bytes,13,rep,name=tags,proto3" json:"tags,omitempty"` xxx_hidden_ExternalDocs *ExternalDocumentation `protobuf:"bytes,14,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` xxx_hidden_Extensions map[string]*structpb.Value `protobuf:"bytes,15,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Swagger) Reset() { *x = Swagger{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Swagger) String() string { return protoimpl.X.MessageStringOf(x) } func (*Swagger) ProtoMessage() {} func (x *Swagger) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *Swagger) GetSwagger() string { if x != nil { return x.xxx_hidden_Swagger } return "" } func (x *Swagger) GetInfo() *Info { if x != nil { return x.xxx_hidden_Info } return nil } func (x *Swagger) GetHost() string { if x != nil { return x.xxx_hidden_Host } return "" } func (x *Swagger) GetBasePath() string { if x != nil { return x.xxx_hidden_BasePath } return "" } func (x *Swagger) GetSchemes() []Scheme { if x != nil { return x.xxx_hidden_Schemes } return nil } func (x *Swagger) GetConsumes() []string { if x != nil { return x.xxx_hidden_Consumes } return nil } func (x *Swagger) GetProduces() []string { if x != nil { return x.xxx_hidden_Produces } return nil } func (x *Swagger) GetResponses() map[string]*Response { if x != nil { return x.xxx_hidden_Responses } return nil } func (x *Swagger) GetSecurityDefinitions() *SecurityDefinitions { if x != nil { return x.xxx_hidden_SecurityDefinitions } return nil } func (x *Swagger) GetSecurity() []*SecurityRequirement { if x != nil { if x.xxx_hidden_Security != nil { return *x.xxx_hidden_Security } } return nil } func (x *Swagger) GetTags() []*Tag { if x != nil { if x.xxx_hidden_Tags != nil { return *x.xxx_hidden_Tags } } return nil } func (x *Swagger) GetExternalDocs() *ExternalDocumentation { if x != nil { return x.xxx_hidden_ExternalDocs } return nil } func (x *Swagger) GetExtensions() map[string]*structpb.Value { if x != nil { return x.xxx_hidden_Extensions } return nil } func (x *Swagger) SetSwagger(v string) { x.xxx_hidden_Swagger = v } func (x *Swagger) SetInfo(v *Info) { x.xxx_hidden_Info = v } func (x *Swagger) SetHost(v string) { x.xxx_hidden_Host = v } func (x *Swagger) SetBasePath(v string) { x.xxx_hidden_BasePath = v } func (x *Swagger) SetSchemes(v []Scheme) { x.xxx_hidden_Schemes = v } func (x *Swagger) SetConsumes(v []string) { x.xxx_hidden_Consumes = v } func (x *Swagger) SetProduces(v []string) { x.xxx_hidden_Produces = v } func (x *Swagger) SetResponses(v map[string]*Response) { x.xxx_hidden_Responses = v } func (x *Swagger) SetSecurityDefinitions(v *SecurityDefinitions) { x.xxx_hidden_SecurityDefinitions = v } func (x *Swagger) SetSecurity(v []*SecurityRequirement) { x.xxx_hidden_Security = &v } func (x *Swagger) SetTags(v []*Tag) { x.xxx_hidden_Tags = &v } func (x *Swagger) SetExternalDocs(v *ExternalDocumentation) { x.xxx_hidden_ExternalDocs = v } func (x *Swagger) SetExtensions(v map[string]*structpb.Value) { x.xxx_hidden_Extensions = v } func (x *Swagger) HasInfo() bool { if x == nil { return false } return x.xxx_hidden_Info != nil } func (x *Swagger) HasSecurityDefinitions() bool { if x == nil { return false } return x.xxx_hidden_SecurityDefinitions != nil } func (x *Swagger) HasExternalDocs() bool { if x == nil { return false } return x.xxx_hidden_ExternalDocs != nil } func (x *Swagger) ClearInfo() { x.xxx_hidden_Info = nil } func (x *Swagger) ClearSecurityDefinitions() { x.xxx_hidden_SecurityDefinitions = nil } func (x *Swagger) ClearExternalDocs() { x.xxx_hidden_ExternalDocs = nil } type Swagger_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // Specifies the OpenAPI Specification version being used. It can be // used by the OpenAPI UI and other clients to interpret the API listing. The // value MUST be "2.0". Swagger string // Provides metadata about the API. The metadata can be used by the // clients if needed. Info *Info // The host (name or ip) serving the API. This MUST be the host only and does // not include the scheme nor sub-paths. It MAY include a port. If the host is // not included, the host serving the documentation is to be used (including // the port). The host does not support path templating. Host string // The base path on which the API is served, which is relative to the host. If // it is not included, the API is served directly under the host. The value // MUST start with a leading slash (/). The basePath does not support path // templating. // Note that using `base_path` does not change the endpoint paths that are // generated in the resulting OpenAPI file. If you wish to use `base_path` // with relatively generated OpenAPI paths, the `base_path` prefix must be // manually removed from your `google.api.http` paths and your code changed to // serve the API from the `base_path`. BasePath string // The transfer protocol of the API. Values MUST be from the list: "http", // "https", "ws", "wss". If the schemes is not included, the default scheme to // be used is the one used to access the OpenAPI definition itself. Schemes []Scheme // A list of MIME types the APIs can consume. This is global to all APIs but // can be overridden on specific API calls. Value MUST be as described under // Mime Types. Consumes []string // A list of MIME types the APIs can produce. This is global to all APIs but // can be overridden on specific API calls. Value MUST be as described under // Mime Types. Produces []string // An object to hold responses that can be used across operations. This // property does not define global responses for all operations. Responses map[string]*Response // Security scheme definitions that can be used across the specification. SecurityDefinitions *SecurityDefinitions // A declaration of which security schemes are applied for the API as a whole. // The list of values describes alternative security schemes that can be used // (that is, there is a logical OR between the security requirements). // Individual operations can override this definition. Security []*SecurityRequirement // A list of tags for API documentation control. Tags can be used for logical // grouping of operations by resources or any other qualifier. Tags []*Tag // Additional external documentation. ExternalDocs *ExternalDocumentation // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value } func (b0 Swagger_builder) Build() *Swagger { m0 := &Swagger{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Swagger = b.Swagger x.xxx_hidden_Info = b.Info x.xxx_hidden_Host = b.Host x.xxx_hidden_BasePath = b.BasePath x.xxx_hidden_Schemes = b.Schemes x.xxx_hidden_Consumes = b.Consumes x.xxx_hidden_Produces = b.Produces x.xxx_hidden_Responses = b.Responses x.xxx_hidden_SecurityDefinitions = b.SecurityDefinitions x.xxx_hidden_Security = &b.Security x.xxx_hidden_Tags = &b.Tags x.xxx_hidden_ExternalDocs = b.ExternalDocs x.xxx_hidden_Extensions = b.Extensions return m0 } // `Operation` is a representation of OpenAPI v2 specification's Operation object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#operationObject // // Example: // // service EchoService { // rpc Echo(SimpleMessage) returns (SimpleMessage) { // option (google.api.http) = { // get: "/v1/example/echo/{id}" // }; // // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { // summary: "Get a message."; // operation_id: "getMessage"; // tags: "echo"; // responses: { // key: "200" // value: { // description: "OK"; // } // } // }; // } // } type Operation struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Tags []string `protobuf:"bytes,1,rep,name=tags,proto3" json:"tags,omitempty"` xxx_hidden_Summary string `protobuf:"bytes,2,opt,name=summary,proto3" json:"summary,omitempty"` xxx_hidden_Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` xxx_hidden_ExternalDocs *ExternalDocumentation `protobuf:"bytes,4,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` xxx_hidden_OperationId string `protobuf:"bytes,5,opt,name=operation_id,json=operationId,proto3" json:"operation_id,omitempty"` xxx_hidden_Consumes []string `protobuf:"bytes,6,rep,name=consumes,proto3" json:"consumes,omitempty"` xxx_hidden_Produces []string `protobuf:"bytes,7,rep,name=produces,proto3" json:"produces,omitempty"` xxx_hidden_Responses map[string]*Response `protobuf:"bytes,9,rep,name=responses,proto3" json:"responses,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` xxx_hidden_Schemes []Scheme `protobuf:"varint,10,rep,packed,name=schemes,proto3,enum=grpc.gateway.protoc_gen_openapiv2.options.Scheme" json:"schemes,omitempty"` xxx_hidden_Deprecated bool `protobuf:"varint,11,opt,name=deprecated,proto3" json:"deprecated,omitempty"` xxx_hidden_Security *[]*SecurityRequirement `protobuf:"bytes,12,rep,name=security,proto3" json:"security,omitempty"` xxx_hidden_Extensions map[string]*structpb.Value `protobuf:"bytes,13,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` xxx_hidden_Parameters *Parameters `protobuf:"bytes,14,opt,name=parameters,proto3" json:"parameters,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Operation) Reset() { *x = Operation{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Operation) String() string { return protoimpl.X.MessageStringOf(x) } func (*Operation) ProtoMessage() {} func (x *Operation) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *Operation) GetTags() []string { if x != nil { return x.xxx_hidden_Tags } return nil } func (x *Operation) GetSummary() string { if x != nil { return x.xxx_hidden_Summary } return "" } func (x *Operation) GetDescription() string { if x != nil { return x.xxx_hidden_Description } return "" } func (x *Operation) GetExternalDocs() *ExternalDocumentation { if x != nil { return x.xxx_hidden_ExternalDocs } return nil } func (x *Operation) GetOperationId() string { if x != nil { return x.xxx_hidden_OperationId } return "" } func (x *Operation) GetConsumes() []string { if x != nil { return x.xxx_hidden_Consumes } return nil } func (x *Operation) GetProduces() []string { if x != nil { return x.xxx_hidden_Produces } return nil } func (x *Operation) GetResponses() map[string]*Response { if x != nil { return x.xxx_hidden_Responses } return nil } func (x *Operation) GetSchemes() []Scheme { if x != nil { return x.xxx_hidden_Schemes } return nil } func (x *Operation) GetDeprecated() bool { if x != nil { return x.xxx_hidden_Deprecated } return false } func (x *Operation) GetSecurity() []*SecurityRequirement { if x != nil { if x.xxx_hidden_Security != nil { return *x.xxx_hidden_Security } } return nil } func (x *Operation) GetExtensions() map[string]*structpb.Value { if x != nil { return x.xxx_hidden_Extensions } return nil } func (x *Operation) GetParameters() *Parameters { if x != nil { return x.xxx_hidden_Parameters } return nil } func (x *Operation) SetTags(v []string) { x.xxx_hidden_Tags = v } func (x *Operation) SetSummary(v string) { x.xxx_hidden_Summary = v } func (x *Operation) SetDescription(v string) { x.xxx_hidden_Description = v } func (x *Operation) SetExternalDocs(v *ExternalDocumentation) { x.xxx_hidden_ExternalDocs = v } func (x *Operation) SetOperationId(v string) { x.xxx_hidden_OperationId = v } func (x *Operation) SetConsumes(v []string) { x.xxx_hidden_Consumes = v } func (x *Operation) SetProduces(v []string) { x.xxx_hidden_Produces = v } func (x *Operation) SetResponses(v map[string]*Response) { x.xxx_hidden_Responses = v } func (x *Operation) SetSchemes(v []Scheme) { x.xxx_hidden_Schemes = v } func (x *Operation) SetDeprecated(v bool) { x.xxx_hidden_Deprecated = v } func (x *Operation) SetSecurity(v []*SecurityRequirement) { x.xxx_hidden_Security = &v } func (x *Operation) SetExtensions(v map[string]*structpb.Value) { x.xxx_hidden_Extensions = v } func (x *Operation) SetParameters(v *Parameters) { x.xxx_hidden_Parameters = v } func (x *Operation) HasExternalDocs() bool { if x == nil { return false } return x.xxx_hidden_ExternalDocs != nil } func (x *Operation) HasParameters() bool { if x == nil { return false } return x.xxx_hidden_Parameters != nil } func (x *Operation) ClearExternalDocs() { x.xxx_hidden_ExternalDocs = nil } func (x *Operation) ClearParameters() { x.xxx_hidden_Parameters = nil } type Operation_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // A list of tags for API documentation control. Tags can be used for logical // grouping of operations by resources or any other qualifier. Tags []string // A short summary of what the operation does. For maximum readability in the // swagger-ui, this field SHOULD be less than 120 characters. Summary string // A verbose explanation of the operation behavior. GFM syntax can be used for // rich text representation. Description string // Additional external documentation for this operation. ExternalDocs *ExternalDocumentation // Unique string used to identify the operation. The id MUST be unique among // all operations described in the API. Tools and libraries MAY use the // operationId to uniquely identify an operation, therefore, it is recommended // to follow common programming naming conventions. OperationId string // A list of MIME types the operation can consume. This overrides the consumes // definition at the OpenAPI Object. An empty value MAY be used to clear the // global definition. Value MUST be as described under Mime Types. Consumes []string // A list of MIME types the operation can produce. This overrides the produces // definition at the OpenAPI Object. An empty value MAY be used to clear the // global definition. Value MUST be as described under Mime Types. Produces []string // The list of possible responses as they are returned from executing this // operation. Responses map[string]*Response // The transfer protocol for the operation. Values MUST be from the list: // "http", "https", "ws", "wss". The value overrides the OpenAPI Object // schemes definition. Schemes []Scheme // Declares this operation to be deprecated. Usage of the declared operation // should be refrained. Default value is false. Deprecated bool // A declaration of which security schemes are applied for this operation. The // list of values describes alternative security schemes that can be used // (that is, there is a logical OR between the security requirements). This // definition overrides any declared top-level security. To remove a top-level // security declaration, an empty array can be used. Security []*SecurityRequirement // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value // Custom parameters such as HTTP request headers. // See: https://swagger.io/docs/specification/2-0/describing-parameters/ // and https://swagger.io/specification/v2/#parameter-object. Parameters *Parameters } func (b0 Operation_builder) Build() *Operation { m0 := &Operation{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Tags = b.Tags x.xxx_hidden_Summary = b.Summary x.xxx_hidden_Description = b.Description x.xxx_hidden_ExternalDocs = b.ExternalDocs x.xxx_hidden_OperationId = b.OperationId x.xxx_hidden_Consumes = b.Consumes x.xxx_hidden_Produces = b.Produces x.xxx_hidden_Responses = b.Responses x.xxx_hidden_Schemes = b.Schemes x.xxx_hidden_Deprecated = b.Deprecated x.xxx_hidden_Security = &b.Security x.xxx_hidden_Extensions = b.Extensions x.xxx_hidden_Parameters = b.Parameters return m0 } // `Parameters` is a representation of OpenAPI v2 specification's parameters object. // Note: This technically breaks compatibility with the OpenAPI 2 definition structure as we only // allow header parameters to be set here since we do not want users specifying custom non-header // parameters beyond those inferred from the Protobuf schema. // See: https://swagger.io/specification/v2/#parameter-object type Parameters struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Headers *[]*HeaderParameter `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Parameters) Reset() { *x = Parameters{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Parameters) String() string { return protoimpl.X.MessageStringOf(x) } func (*Parameters) ProtoMessage() {} func (x *Parameters) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *Parameters) GetHeaders() []*HeaderParameter { if x != nil { if x.xxx_hidden_Headers != nil { return *x.xxx_hidden_Headers } } return nil } func (x *Parameters) SetHeaders(v []*HeaderParameter) { x.xxx_hidden_Headers = &v } type Parameters_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // `Headers` is one or more HTTP header parameter. // See: https://swagger.io/docs/specification/2-0/describing-parameters/#header-parameters Headers []*HeaderParameter } func (b0 Parameters_builder) Build() *Parameters { m0 := &Parameters{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Headers = &b.Headers return m0 } // `HeaderParameter` a HTTP header parameter. // See: https://swagger.io/specification/v2/#parameter-object type HeaderParameter struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` xxx_hidden_Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` xxx_hidden_Type HeaderParameter_Type `protobuf:"varint,3,opt,name=type,proto3,enum=grpc.gateway.protoc_gen_openapiv2.options.HeaderParameter_Type" json:"type,omitempty"` xxx_hidden_Format string `protobuf:"bytes,4,opt,name=format,proto3" json:"format,omitempty"` xxx_hidden_Required bool `protobuf:"varint,5,opt,name=required,proto3" json:"required,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *HeaderParameter) Reset() { *x = HeaderParameter{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *HeaderParameter) String() string { return protoimpl.X.MessageStringOf(x) } func (*HeaderParameter) ProtoMessage() {} func (x *HeaderParameter) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *HeaderParameter) GetName() string { if x != nil { return x.xxx_hidden_Name } return "" } func (x *HeaderParameter) GetDescription() string { if x != nil { return x.xxx_hidden_Description } return "" } func (x *HeaderParameter) GetType() HeaderParameter_Type { if x != nil { return x.xxx_hidden_Type } return HeaderParameter_UNKNOWN } func (x *HeaderParameter) GetFormat() string { if x != nil { return x.xxx_hidden_Format } return "" } func (x *HeaderParameter) GetRequired() bool { if x != nil { return x.xxx_hidden_Required } return false } func (x *HeaderParameter) SetName(v string) { x.xxx_hidden_Name = v } func (x *HeaderParameter) SetDescription(v string) { x.xxx_hidden_Description = v } func (x *HeaderParameter) SetType(v HeaderParameter_Type) { x.xxx_hidden_Type = v } func (x *HeaderParameter) SetFormat(v string) { x.xxx_hidden_Format = v } func (x *HeaderParameter) SetRequired(v bool) { x.xxx_hidden_Required = v } type HeaderParameter_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // `Name` is the header name. Name string // `Description` is a short description of the header. Description string // `Type` is the type of the object. The value MUST be one of "string", "number", "integer", or "boolean". The "array" type is not supported. // See: https://swagger.io/specification/v2/#parameterType. Type HeaderParameter_Type // `Format` The extending format for the previously mentioned type. Format string // `Required` indicates if the header is optional Required bool } func (b0 HeaderParameter_builder) Build() *HeaderParameter { m0 := &HeaderParameter{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Name = b.Name x.xxx_hidden_Description = b.Description x.xxx_hidden_Type = b.Type x.xxx_hidden_Format = b.Format x.xxx_hidden_Required = b.Required return m0 } // `Header` is a representation of OpenAPI v2 specification's Header object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#headerObject type Header struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` xxx_hidden_Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` xxx_hidden_Format string `protobuf:"bytes,3,opt,name=format,proto3" json:"format,omitempty"` xxx_hidden_Default string `protobuf:"bytes,6,opt,name=default,proto3" json:"default,omitempty"` xxx_hidden_Pattern string `protobuf:"bytes,13,opt,name=pattern,proto3" json:"pattern,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Header) Reset() { *x = Header{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Header) String() string { return protoimpl.X.MessageStringOf(x) } func (*Header) ProtoMessage() {} func (x *Header) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *Header) GetDescription() string { if x != nil { return x.xxx_hidden_Description } return "" } func (x *Header) GetType() string { if x != nil { return x.xxx_hidden_Type } return "" } func (x *Header) GetFormat() string { if x != nil { return x.xxx_hidden_Format } return "" } func (x *Header) GetDefault() string { if x != nil { return x.xxx_hidden_Default } return "" } func (x *Header) GetPattern() string { if x != nil { return x.xxx_hidden_Pattern } return "" } func (x *Header) SetDescription(v string) { x.xxx_hidden_Description = v } func (x *Header) SetType(v string) { x.xxx_hidden_Type = v } func (x *Header) SetFormat(v string) { x.xxx_hidden_Format = v } func (x *Header) SetDefault(v string) { x.xxx_hidden_Default = v } func (x *Header) SetPattern(v string) { x.xxx_hidden_Pattern = v } type Header_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // `Description` is a short description of the header. Description string // The type of the object. The value MUST be one of "string", "number", "integer", or "boolean". The "array" type is not supported. Type string // `Format` The extending format for the previously mentioned type. Format string // `Default` Declares the value of the header that the server will use if none is provided. // See: https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-6.2. // Unlike JSON Schema this value MUST conform to the defined type for the header. Default string // 'Pattern' See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.2.3. Pattern string } func (b0 Header_builder) Build() *Header { m0 := &Header{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Description = b.Description x.xxx_hidden_Type = b.Type x.xxx_hidden_Format = b.Format x.xxx_hidden_Default = b.Default x.xxx_hidden_Pattern = b.Pattern return m0 } // `Response` is a representation of OpenAPI v2 specification's Response object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#responseObject type Response struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` xxx_hidden_Schema *Schema `protobuf:"bytes,2,opt,name=schema,proto3" json:"schema,omitempty"` xxx_hidden_Headers map[string]*Header `protobuf:"bytes,3,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` xxx_hidden_Examples map[string]string `protobuf:"bytes,4,rep,name=examples,proto3" json:"examples,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` xxx_hidden_Extensions map[string]*structpb.Value `protobuf:"bytes,5,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Response) Reset() { *x = Response{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Response) String() string { return protoimpl.X.MessageStringOf(x) } func (*Response) ProtoMessage() {} func (x *Response) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *Response) GetDescription() string { if x != nil { return x.xxx_hidden_Description } return "" } func (x *Response) GetSchema() *Schema { if x != nil { return x.xxx_hidden_Schema } return nil } func (x *Response) GetHeaders() map[string]*Header { if x != nil { return x.xxx_hidden_Headers } return nil } func (x *Response) GetExamples() map[string]string { if x != nil { return x.xxx_hidden_Examples } return nil } func (x *Response) GetExtensions() map[string]*structpb.Value { if x != nil { return x.xxx_hidden_Extensions } return nil } func (x *Response) SetDescription(v string) { x.xxx_hidden_Description = v } func (x *Response) SetSchema(v *Schema) { x.xxx_hidden_Schema = v } func (x *Response) SetHeaders(v map[string]*Header) { x.xxx_hidden_Headers = v } func (x *Response) SetExamples(v map[string]string) { x.xxx_hidden_Examples = v } func (x *Response) SetExtensions(v map[string]*structpb.Value) { x.xxx_hidden_Extensions = v } func (x *Response) HasSchema() bool { if x == nil { return false } return x.xxx_hidden_Schema != nil } func (x *Response) ClearSchema() { x.xxx_hidden_Schema = nil } type Response_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // `Description` is a short description of the response. // GFM syntax can be used for rich text representation. Description string // `Schema` optionally defines the structure of the response. // If `Schema` is not provided, it means there is no content to the response. Schema *Schema // `Headers` A list of headers that are sent with the response. // `Header` name is expected to be a string in the canonical format of the MIME header key // See: https://golang.org/pkg/net/textproto/#CanonicalMIMEHeaderKey Headers map[string]*Header // `Examples` gives per-mimetype response examples. // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#example-object Examples map[string]string // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value } func (b0 Response_builder) Build() *Response { m0 := &Response{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Description = b.Description x.xxx_hidden_Schema = b.Schema x.xxx_hidden_Headers = b.Headers x.xxx_hidden_Examples = b.Examples x.xxx_hidden_Extensions = b.Extensions return m0 } // `Info` is a representation of OpenAPI v2 specification's Info object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#infoObject // // Example: // // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { // info: { // title: "Echo API"; // version: "1.0"; // description: ""; // contact: { // name: "gRPC-Gateway project"; // url: "https://github.com/grpc-ecosystem/grpc-gateway"; // email: "none@example.com"; // }; // license: { // name: "BSD 3-Clause License"; // url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE"; // }; // }; // ... // }; type Info struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` xxx_hidden_Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` xxx_hidden_TermsOfService string `protobuf:"bytes,3,opt,name=terms_of_service,json=termsOfService,proto3" json:"terms_of_service,omitempty"` xxx_hidden_Contact *Contact `protobuf:"bytes,4,opt,name=contact,proto3" json:"contact,omitempty"` xxx_hidden_License *License `protobuf:"bytes,5,opt,name=license,proto3" json:"license,omitempty"` xxx_hidden_Version string `protobuf:"bytes,6,opt,name=version,proto3" json:"version,omitempty"` xxx_hidden_Extensions map[string]*structpb.Value `protobuf:"bytes,7,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Info) Reset() { *x = Info{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Info) String() string { return protoimpl.X.MessageStringOf(x) } func (*Info) ProtoMessage() {} func (x *Info) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *Info) GetTitle() string { if x != nil { return x.xxx_hidden_Title } return "" } func (x *Info) GetDescription() string { if x != nil { return x.xxx_hidden_Description } return "" } func (x *Info) GetTermsOfService() string { if x != nil { return x.xxx_hidden_TermsOfService } return "" } func (x *Info) GetContact() *Contact { if x != nil { return x.xxx_hidden_Contact } return nil } func (x *Info) GetLicense() *License { if x != nil { return x.xxx_hidden_License } return nil } func (x *Info) GetVersion() string { if x != nil { return x.xxx_hidden_Version } return "" } func (x *Info) GetExtensions() map[string]*structpb.Value { if x != nil { return x.xxx_hidden_Extensions } return nil } func (x *Info) SetTitle(v string) { x.xxx_hidden_Title = v } func (x *Info) SetDescription(v string) { x.xxx_hidden_Description = v } func (x *Info) SetTermsOfService(v string) { x.xxx_hidden_TermsOfService = v } func (x *Info) SetContact(v *Contact) { x.xxx_hidden_Contact = v } func (x *Info) SetLicense(v *License) { x.xxx_hidden_License = v } func (x *Info) SetVersion(v string) { x.xxx_hidden_Version = v } func (x *Info) SetExtensions(v map[string]*structpb.Value) { x.xxx_hidden_Extensions = v } func (x *Info) HasContact() bool { if x == nil { return false } return x.xxx_hidden_Contact != nil } func (x *Info) HasLicense() bool { if x == nil { return false } return x.xxx_hidden_License != nil } func (x *Info) ClearContact() { x.xxx_hidden_Contact = nil } func (x *Info) ClearLicense() { x.xxx_hidden_License = nil } type Info_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // The title of the application. Title string // A short description of the application. GFM syntax can be used for rich // text representation. Description string // The Terms of Service for the API. TermsOfService string // The contact information for the exposed API. Contact *Contact // The license information for the exposed API. License *License // Provides the version of the application API (not to be confused // with the specification version). Version string // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value } func (b0 Info_builder) Build() *Info { m0 := &Info{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Title = b.Title x.xxx_hidden_Description = b.Description x.xxx_hidden_TermsOfService = b.TermsOfService x.xxx_hidden_Contact = b.Contact x.xxx_hidden_License = b.License x.xxx_hidden_Version = b.Version x.xxx_hidden_Extensions = b.Extensions return m0 } // `Contact` is a representation of OpenAPI v2 specification's Contact object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#contactObject // // Example: // // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { // info: { // ... // contact: { // name: "gRPC-Gateway project"; // url: "https://github.com/grpc-ecosystem/grpc-gateway"; // email: "none@example.com"; // }; // ... // }; // ... // }; type Contact struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` xxx_hidden_Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` xxx_hidden_Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Contact) Reset() { *x = Contact{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Contact) String() string { return protoimpl.X.MessageStringOf(x) } func (*Contact) ProtoMessage() {} func (x *Contact) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *Contact) GetName() string { if x != nil { return x.xxx_hidden_Name } return "" } func (x *Contact) GetUrl() string { if x != nil { return x.xxx_hidden_Url } return "" } func (x *Contact) GetEmail() string { if x != nil { return x.xxx_hidden_Email } return "" } func (x *Contact) SetName(v string) { x.xxx_hidden_Name = v } func (x *Contact) SetUrl(v string) { x.xxx_hidden_Url = v } func (x *Contact) SetEmail(v string) { x.xxx_hidden_Email = v } type Contact_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // The identifying name of the contact person/organization. Name string // The URL pointing to the contact information. MUST be in the format of a // URL. Url string // The email address of the contact person/organization. MUST be in the format // of an email address. Email string } func (b0 Contact_builder) Build() *Contact { m0 := &Contact{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Name = b.Name x.xxx_hidden_Url = b.Url x.xxx_hidden_Email = b.Email return m0 } // `License` is a representation of OpenAPI v2 specification's License object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#licenseObject // // Example: // // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { // info: { // ... // license: { // name: "BSD 3-Clause License"; // url: "https://github.com/grpc-ecosystem/grpc-gateway/blob/main/LICENSE"; // }; // ... // }; // ... // }; type License struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` xxx_hidden_Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *License) Reset() { *x = License{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *License) String() string { return protoimpl.X.MessageStringOf(x) } func (*License) ProtoMessage() {} func (x *License) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *License) GetName() string { if x != nil { return x.xxx_hidden_Name } return "" } func (x *License) GetUrl() string { if x != nil { return x.xxx_hidden_Url } return "" } func (x *License) SetName(v string) { x.xxx_hidden_Name = v } func (x *License) SetUrl(v string) { x.xxx_hidden_Url = v } type License_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // The license name used for the API. Name string // A URL to the license used for the API. MUST be in the format of a URL. Url string } func (b0 License_builder) Build() *License { m0 := &License{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Name = b.Name x.xxx_hidden_Url = b.Url return m0 } // `ExternalDocumentation` is a representation of OpenAPI v2 specification's // ExternalDocumentation object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#externalDocumentationObject // // Example: // // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { // ... // external_docs: { // description: "More about gRPC-Gateway"; // url: "https://github.com/grpc-ecosystem/grpc-gateway"; // } // ... // }; type ExternalDocumentation struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` xxx_hidden_Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *ExternalDocumentation) Reset() { *x = ExternalDocumentation{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *ExternalDocumentation) String() string { return protoimpl.X.MessageStringOf(x) } func (*ExternalDocumentation) ProtoMessage() {} func (x *ExternalDocumentation) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *ExternalDocumentation) GetDescription() string { if x != nil { return x.xxx_hidden_Description } return "" } func (x *ExternalDocumentation) GetUrl() string { if x != nil { return x.xxx_hidden_Url } return "" } func (x *ExternalDocumentation) SetDescription(v string) { x.xxx_hidden_Description = v } func (x *ExternalDocumentation) SetUrl(v string) { x.xxx_hidden_Url = v } type ExternalDocumentation_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // A short description of the target documentation. GFM syntax can be used for // rich text representation. Description string // The URL for the target documentation. Value MUST be in the format // of a URL. Url string } func (b0 ExternalDocumentation_builder) Build() *ExternalDocumentation { m0 := &ExternalDocumentation{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Description = b.Description x.xxx_hidden_Url = b.Url return m0 } // `Schema` is a representation of OpenAPI v2 specification's Schema object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject type Schema struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_JsonSchema *JSONSchema `protobuf:"bytes,1,opt,name=json_schema,json=jsonSchema,proto3" json:"json_schema,omitempty"` xxx_hidden_Discriminator string `protobuf:"bytes,2,opt,name=discriminator,proto3" json:"discriminator,omitempty"` xxx_hidden_ReadOnly bool `protobuf:"varint,3,opt,name=read_only,json=readOnly,proto3" json:"read_only,omitempty"` xxx_hidden_ExternalDocs *ExternalDocumentation `protobuf:"bytes,5,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` xxx_hidden_Example string `protobuf:"bytes,6,opt,name=example,proto3" json:"example,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Schema) Reset() { *x = Schema{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Schema) String() string { return protoimpl.X.MessageStringOf(x) } func (*Schema) ProtoMessage() {} func (x *Schema) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *Schema) GetJsonSchema() *JSONSchema { if x != nil { return x.xxx_hidden_JsonSchema } return nil } func (x *Schema) GetDiscriminator() string { if x != nil { return x.xxx_hidden_Discriminator } return "" } func (x *Schema) GetReadOnly() bool { if x != nil { return x.xxx_hidden_ReadOnly } return false } func (x *Schema) GetExternalDocs() *ExternalDocumentation { if x != nil { return x.xxx_hidden_ExternalDocs } return nil } func (x *Schema) GetExample() string { if x != nil { return x.xxx_hidden_Example } return "" } func (x *Schema) SetJsonSchema(v *JSONSchema) { x.xxx_hidden_JsonSchema = v } func (x *Schema) SetDiscriminator(v string) { x.xxx_hidden_Discriminator = v } func (x *Schema) SetReadOnly(v bool) { x.xxx_hidden_ReadOnly = v } func (x *Schema) SetExternalDocs(v *ExternalDocumentation) { x.xxx_hidden_ExternalDocs = v } func (x *Schema) SetExample(v string) { x.xxx_hidden_Example = v } func (x *Schema) HasJsonSchema() bool { if x == nil { return false } return x.xxx_hidden_JsonSchema != nil } func (x *Schema) HasExternalDocs() bool { if x == nil { return false } return x.xxx_hidden_ExternalDocs != nil } func (x *Schema) ClearJsonSchema() { x.xxx_hidden_JsonSchema = nil } func (x *Schema) ClearExternalDocs() { x.xxx_hidden_ExternalDocs = nil } type Schema_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. JsonSchema *JSONSchema // Adds support for polymorphism. The discriminator is the schema property // name that is used to differentiate between other schema that inherit this // schema. The property name used MUST be defined at this schema and it MUST // be in the required property list. When used, the value MUST be the name of // this schema or any schema that inherits it. Discriminator string // Relevant only for Schema "properties" definitions. Declares the property as // "read only". This means that it MAY be sent as part of a response but MUST // NOT be sent as part of the request. Properties marked as readOnly being // true SHOULD NOT be in the required list of the defined schema. Default // value is false. ReadOnly bool // Additional external documentation for this schema. ExternalDocs *ExternalDocumentation // A free-form property to include an example of an instance for this schema in JSON. // This is copied verbatim to the output. Example string } func (b0 Schema_builder) Build() *Schema { m0 := &Schema{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_JsonSchema = b.JsonSchema x.xxx_hidden_Discriminator = b.Discriminator x.xxx_hidden_ReadOnly = b.ReadOnly x.xxx_hidden_ExternalDocs = b.ExternalDocs x.xxx_hidden_Example = b.Example return m0 } // `EnumSchema` is subset of fields from the OpenAPI v2 specification's Schema object. // Only fields that are applicable to Enums are included // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject // // Example: // // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_enum) = { // ... // title: "MyEnum"; // description:"This is my nice enum"; // example: "ZERO"; // required: true; // ... // }; type EnumSchema struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` xxx_hidden_Default string `protobuf:"bytes,2,opt,name=default,proto3" json:"default,omitempty"` xxx_hidden_Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"` xxx_hidden_Required bool `protobuf:"varint,4,opt,name=required,proto3" json:"required,omitempty"` xxx_hidden_ReadOnly bool `protobuf:"varint,5,opt,name=read_only,json=readOnly,proto3" json:"read_only,omitempty"` xxx_hidden_ExternalDocs *ExternalDocumentation `protobuf:"bytes,6,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` xxx_hidden_Example string `protobuf:"bytes,7,opt,name=example,proto3" json:"example,omitempty"` xxx_hidden_Ref string `protobuf:"bytes,8,opt,name=ref,proto3" json:"ref,omitempty"` xxx_hidden_Extensions map[string]*structpb.Value `protobuf:"bytes,9,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *EnumSchema) Reset() { *x = EnumSchema{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *EnumSchema) String() string { return protoimpl.X.MessageStringOf(x) } func (*EnumSchema) ProtoMessage() {} func (x *EnumSchema) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *EnumSchema) GetDescription() string { if x != nil { return x.xxx_hidden_Description } return "" } func (x *EnumSchema) GetDefault() string { if x != nil { return x.xxx_hidden_Default } return "" } func (x *EnumSchema) GetTitle() string { if x != nil { return x.xxx_hidden_Title } return "" } func (x *EnumSchema) GetRequired() bool { if x != nil { return x.xxx_hidden_Required } return false } func (x *EnumSchema) GetReadOnly() bool { if x != nil { return x.xxx_hidden_ReadOnly } return false } func (x *EnumSchema) GetExternalDocs() *ExternalDocumentation { if x != nil { return x.xxx_hidden_ExternalDocs } return nil } func (x *EnumSchema) GetExample() string { if x != nil { return x.xxx_hidden_Example } return "" } func (x *EnumSchema) GetRef() string { if x != nil { return x.xxx_hidden_Ref } return "" } func (x *EnumSchema) GetExtensions() map[string]*structpb.Value { if x != nil { return x.xxx_hidden_Extensions } return nil } func (x *EnumSchema) SetDescription(v string) { x.xxx_hidden_Description = v } func (x *EnumSchema) SetDefault(v string) { x.xxx_hidden_Default = v } func (x *EnumSchema) SetTitle(v string) { x.xxx_hidden_Title = v } func (x *EnumSchema) SetRequired(v bool) { x.xxx_hidden_Required = v } func (x *EnumSchema) SetReadOnly(v bool) { x.xxx_hidden_ReadOnly = v } func (x *EnumSchema) SetExternalDocs(v *ExternalDocumentation) { x.xxx_hidden_ExternalDocs = v } func (x *EnumSchema) SetExample(v string) { x.xxx_hidden_Example = v } func (x *EnumSchema) SetRef(v string) { x.xxx_hidden_Ref = v } func (x *EnumSchema) SetExtensions(v map[string]*structpb.Value) { x.xxx_hidden_Extensions = v } func (x *EnumSchema) HasExternalDocs() bool { if x == nil { return false } return x.xxx_hidden_ExternalDocs != nil } func (x *EnumSchema) ClearExternalDocs() { x.xxx_hidden_ExternalDocs = nil } type EnumSchema_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // A short description of the schema. Description string Default string // The title of the schema. Title string Required bool ReadOnly bool // Additional external documentation for this schema. ExternalDocs *ExternalDocumentation Example string // Ref is used to define an external reference to include in the message. // This could be a fully qualified proto message reference, and that type must // be imported into the protofile. If no message is identified, the Ref will // be used verbatim in the output. // For example: // // `ref: ".google.protobuf.Timestamp"`. Ref string // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value } func (b0 EnumSchema_builder) Build() *EnumSchema { m0 := &EnumSchema{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Description = b.Description x.xxx_hidden_Default = b.Default x.xxx_hidden_Title = b.Title x.xxx_hidden_Required = b.Required x.xxx_hidden_ReadOnly = b.ReadOnly x.xxx_hidden_ExternalDocs = b.ExternalDocs x.xxx_hidden_Example = b.Example x.xxx_hidden_Ref = b.Ref x.xxx_hidden_Extensions = b.Extensions return m0 } // `JSONSchema` represents properties from JSON Schema taken, and as used, in // the OpenAPI v2 spec. // // This includes changes made by OpenAPI v2. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject // // See also: https://cswr.github.io/JsonSchema/spec/basic_types/, // https://github.com/json-schema-org/json-schema-spec/blob/master/schema.json // // Example: // // message SimpleMessage { // option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { // json_schema: { // title: "SimpleMessage" // description: "A simple message." // required: ["id"] // } // }; // // // Id represents the message identifier. // string id = 1; [ // (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = { // description: "The unique identifier of the simple message." // }]; // } type JSONSchema struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Ref string `protobuf:"bytes,3,opt,name=ref,proto3" json:"ref,omitempty"` xxx_hidden_Title string `protobuf:"bytes,5,opt,name=title,proto3" json:"title,omitempty"` xxx_hidden_Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` xxx_hidden_Default string `protobuf:"bytes,7,opt,name=default,proto3" json:"default,omitempty"` xxx_hidden_ReadOnly bool `protobuf:"varint,8,opt,name=read_only,json=readOnly,proto3" json:"read_only,omitempty"` xxx_hidden_Example string `protobuf:"bytes,9,opt,name=example,proto3" json:"example,omitempty"` xxx_hidden_MultipleOf float64 `protobuf:"fixed64,10,opt,name=multiple_of,json=multipleOf,proto3" json:"multiple_of,omitempty"` xxx_hidden_Maximum float64 `protobuf:"fixed64,11,opt,name=maximum,proto3" json:"maximum,omitempty"` xxx_hidden_ExclusiveMaximum bool `protobuf:"varint,12,opt,name=exclusive_maximum,json=exclusiveMaximum,proto3" json:"exclusive_maximum,omitempty"` xxx_hidden_Minimum float64 `protobuf:"fixed64,13,opt,name=minimum,proto3" json:"minimum,omitempty"` xxx_hidden_ExclusiveMinimum bool `protobuf:"varint,14,opt,name=exclusive_minimum,json=exclusiveMinimum,proto3" json:"exclusive_minimum,omitempty"` xxx_hidden_MaxLength uint64 `protobuf:"varint,15,opt,name=max_length,json=maxLength,proto3" json:"max_length,omitempty"` xxx_hidden_MinLength uint64 `protobuf:"varint,16,opt,name=min_length,json=minLength,proto3" json:"min_length,omitempty"` xxx_hidden_Pattern string `protobuf:"bytes,17,opt,name=pattern,proto3" json:"pattern,omitempty"` xxx_hidden_MaxItems uint64 `protobuf:"varint,20,opt,name=max_items,json=maxItems,proto3" json:"max_items,omitempty"` xxx_hidden_MinItems uint64 `protobuf:"varint,21,opt,name=min_items,json=minItems,proto3" json:"min_items,omitempty"` xxx_hidden_UniqueItems bool `protobuf:"varint,22,opt,name=unique_items,json=uniqueItems,proto3" json:"unique_items,omitempty"` xxx_hidden_MaxProperties uint64 `protobuf:"varint,24,opt,name=max_properties,json=maxProperties,proto3" json:"max_properties,omitempty"` xxx_hidden_MinProperties uint64 `protobuf:"varint,25,opt,name=min_properties,json=minProperties,proto3" json:"min_properties,omitempty"` xxx_hidden_Required []string `protobuf:"bytes,26,rep,name=required,proto3" json:"required,omitempty"` xxx_hidden_Array []string `protobuf:"bytes,34,rep,name=array,proto3" json:"array,omitempty"` xxx_hidden_Type []JSONSchema_JSONSchemaSimpleTypes `protobuf:"varint,35,rep,packed,name=type,proto3,enum=grpc.gateway.protoc_gen_openapiv2.options.JSONSchema_JSONSchemaSimpleTypes" json:"type,omitempty"` xxx_hidden_Format string `protobuf:"bytes,36,opt,name=format,proto3" json:"format,omitempty"` xxx_hidden_Enum []string `protobuf:"bytes,46,rep,name=enum,proto3" json:"enum,omitempty"` xxx_hidden_FieldConfiguration *JSONSchema_FieldConfiguration `protobuf:"bytes,1001,opt,name=field_configuration,json=fieldConfiguration,proto3" json:"field_configuration,omitempty"` xxx_hidden_Extensions map[string]*structpb.Value `protobuf:"bytes,48,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *JSONSchema) Reset() { *x = JSONSchema{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *JSONSchema) String() string { return protoimpl.X.MessageStringOf(x) } func (*JSONSchema) ProtoMessage() {} func (x *JSONSchema) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *JSONSchema) GetRef() string { if x != nil { return x.xxx_hidden_Ref } return "" } func (x *JSONSchema) GetTitle() string { if x != nil { return x.xxx_hidden_Title } return "" } func (x *JSONSchema) GetDescription() string { if x != nil { return x.xxx_hidden_Description } return "" } func (x *JSONSchema) GetDefault() string { if x != nil { return x.xxx_hidden_Default } return "" } func (x *JSONSchema) GetReadOnly() bool { if x != nil { return x.xxx_hidden_ReadOnly } return false } func (x *JSONSchema) GetExample() string { if x != nil { return x.xxx_hidden_Example } return "" } func (x *JSONSchema) GetMultipleOf() float64 { if x != nil { return x.xxx_hidden_MultipleOf } return 0 } func (x *JSONSchema) GetMaximum() float64 { if x != nil { return x.xxx_hidden_Maximum } return 0 } func (x *JSONSchema) GetExclusiveMaximum() bool { if x != nil { return x.xxx_hidden_ExclusiveMaximum } return false } func (x *JSONSchema) GetMinimum() float64 { if x != nil { return x.xxx_hidden_Minimum } return 0 } func (x *JSONSchema) GetExclusiveMinimum() bool { if x != nil { return x.xxx_hidden_ExclusiveMinimum } return false } func (x *JSONSchema) GetMaxLength() uint64 { if x != nil { return x.xxx_hidden_MaxLength } return 0 } func (x *JSONSchema) GetMinLength() uint64 { if x != nil { return x.xxx_hidden_MinLength } return 0 } func (x *JSONSchema) GetPattern() string { if x != nil { return x.xxx_hidden_Pattern } return "" } func (x *JSONSchema) GetMaxItems() uint64 { if x != nil { return x.xxx_hidden_MaxItems } return 0 } func (x *JSONSchema) GetMinItems() uint64 { if x != nil { return x.xxx_hidden_MinItems } return 0 } func (x *JSONSchema) GetUniqueItems() bool { if x != nil { return x.xxx_hidden_UniqueItems } return false } func (x *JSONSchema) GetMaxProperties() uint64 { if x != nil { return x.xxx_hidden_MaxProperties } return 0 } func (x *JSONSchema) GetMinProperties() uint64 { if x != nil { return x.xxx_hidden_MinProperties } return 0 } func (x *JSONSchema) GetRequired() []string { if x != nil { return x.xxx_hidden_Required } return nil } func (x *JSONSchema) GetArray() []string { if x != nil { return x.xxx_hidden_Array } return nil } func (x *JSONSchema) GetType() []JSONSchema_JSONSchemaSimpleTypes { if x != nil { return x.xxx_hidden_Type } return nil } func (x *JSONSchema) GetFormat() string { if x != nil { return x.xxx_hidden_Format } return "" } func (x *JSONSchema) GetEnum() []string { if x != nil { return x.xxx_hidden_Enum } return nil } func (x *JSONSchema) GetFieldConfiguration() *JSONSchema_FieldConfiguration { if x != nil { return x.xxx_hidden_FieldConfiguration } return nil } func (x *JSONSchema) GetExtensions() map[string]*structpb.Value { if x != nil { return x.xxx_hidden_Extensions } return nil } func (x *JSONSchema) SetRef(v string) { x.xxx_hidden_Ref = v } func (x *JSONSchema) SetTitle(v string) { x.xxx_hidden_Title = v } func (x *JSONSchema) SetDescription(v string) { x.xxx_hidden_Description = v } func (x *JSONSchema) SetDefault(v string) { x.xxx_hidden_Default = v } func (x *JSONSchema) SetReadOnly(v bool) { x.xxx_hidden_ReadOnly = v } func (x *JSONSchema) SetExample(v string) { x.xxx_hidden_Example = v } func (x *JSONSchema) SetMultipleOf(v float64) { x.xxx_hidden_MultipleOf = v } func (x *JSONSchema) SetMaximum(v float64) { x.xxx_hidden_Maximum = v } func (x *JSONSchema) SetExclusiveMaximum(v bool) { x.xxx_hidden_ExclusiveMaximum = v } func (x *JSONSchema) SetMinimum(v float64) { x.xxx_hidden_Minimum = v } func (x *JSONSchema) SetExclusiveMinimum(v bool) { x.xxx_hidden_ExclusiveMinimum = v } func (x *JSONSchema) SetMaxLength(v uint64) { x.xxx_hidden_MaxLength = v } func (x *JSONSchema) SetMinLength(v uint64) { x.xxx_hidden_MinLength = v } func (x *JSONSchema) SetPattern(v string) { x.xxx_hidden_Pattern = v } func (x *JSONSchema) SetMaxItems(v uint64) { x.xxx_hidden_MaxItems = v } func (x *JSONSchema) SetMinItems(v uint64) { x.xxx_hidden_MinItems = v } func (x *JSONSchema) SetUniqueItems(v bool) { x.xxx_hidden_UniqueItems = v } func (x *JSONSchema) SetMaxProperties(v uint64) { x.xxx_hidden_MaxProperties = v } func (x *JSONSchema) SetMinProperties(v uint64) { x.xxx_hidden_MinProperties = v } func (x *JSONSchema) SetRequired(v []string) { x.xxx_hidden_Required = v } func (x *JSONSchema) SetArray(v []string) { x.xxx_hidden_Array = v } func (x *JSONSchema) SetType(v []JSONSchema_JSONSchemaSimpleTypes) { x.xxx_hidden_Type = v } func (x *JSONSchema) SetFormat(v string) { x.xxx_hidden_Format = v } func (x *JSONSchema) SetEnum(v []string) { x.xxx_hidden_Enum = v } func (x *JSONSchema) SetFieldConfiguration(v *JSONSchema_FieldConfiguration) { x.xxx_hidden_FieldConfiguration = v } func (x *JSONSchema) SetExtensions(v map[string]*structpb.Value) { x.xxx_hidden_Extensions = v } func (x *JSONSchema) HasFieldConfiguration() bool { if x == nil { return false } return x.xxx_hidden_FieldConfiguration != nil } func (x *JSONSchema) ClearFieldConfiguration() { x.xxx_hidden_FieldConfiguration = nil } type JSONSchema_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // Ref is used to define an external reference to include in the message. // This could be a fully qualified proto message reference, and that type must // be imported into the protofile. If no message is identified, the Ref will // be used verbatim in the output. // For example: // // `ref: ".google.protobuf.Timestamp"`. Ref string // The title of the schema. Title string // A short description of the schema. Description string Default string ReadOnly bool // A free-form property to include a JSON example of this field. This is copied // verbatim to the output swagger.json. Quotes must be escaped. // This property is the same for 2.0 and 3.0.0 https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/3.0.0.md#schemaObject https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject Example string MultipleOf float64 // Maximum represents an inclusive upper limit for a numeric instance. The // value of MUST be a number, Maximum float64 ExclusiveMaximum bool // minimum represents an inclusive lower limit for a numeric instance. The // value of MUST be a number, Minimum float64 ExclusiveMinimum bool MaxLength uint64 MinLength uint64 Pattern string MaxItems uint64 MinItems uint64 UniqueItems bool MaxProperties uint64 MinProperties uint64 Required []string // Items in 'array' must be unique. Array []string Type []JSONSchema_JSONSchemaSimpleTypes // `Format` Format string // Items in `enum` must be unique https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.1 Enum []string // Additional field level properties used when generating the OpenAPI v2 file. FieldConfiguration *JSONSchema_FieldConfiguration // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value } func (b0 JSONSchema_builder) Build() *JSONSchema { m0 := &JSONSchema{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Ref = b.Ref x.xxx_hidden_Title = b.Title x.xxx_hidden_Description = b.Description x.xxx_hidden_Default = b.Default x.xxx_hidden_ReadOnly = b.ReadOnly x.xxx_hidden_Example = b.Example x.xxx_hidden_MultipleOf = b.MultipleOf x.xxx_hidden_Maximum = b.Maximum x.xxx_hidden_ExclusiveMaximum = b.ExclusiveMaximum x.xxx_hidden_Minimum = b.Minimum x.xxx_hidden_ExclusiveMinimum = b.ExclusiveMinimum x.xxx_hidden_MaxLength = b.MaxLength x.xxx_hidden_MinLength = b.MinLength x.xxx_hidden_Pattern = b.Pattern x.xxx_hidden_MaxItems = b.MaxItems x.xxx_hidden_MinItems = b.MinItems x.xxx_hidden_UniqueItems = b.UniqueItems x.xxx_hidden_MaxProperties = b.MaxProperties x.xxx_hidden_MinProperties = b.MinProperties x.xxx_hidden_Required = b.Required x.xxx_hidden_Array = b.Array x.xxx_hidden_Type = b.Type x.xxx_hidden_Format = b.Format x.xxx_hidden_Enum = b.Enum x.xxx_hidden_FieldConfiguration = b.FieldConfiguration x.xxx_hidden_Extensions = b.Extensions return m0 } // `Tag` is a representation of OpenAPI v2 specification's Tag object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#tagObject type Tag struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` xxx_hidden_Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` xxx_hidden_ExternalDocs *ExternalDocumentation `protobuf:"bytes,3,opt,name=external_docs,json=externalDocs,proto3" json:"external_docs,omitempty"` xxx_hidden_Extensions map[string]*structpb.Value `protobuf:"bytes,4,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Tag) Reset() { *x = Tag{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Tag) String() string { return protoimpl.X.MessageStringOf(x) } func (*Tag) ProtoMessage() {} func (x *Tag) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *Tag) GetName() string { if x != nil { return x.xxx_hidden_Name } return "" } func (x *Tag) GetDescription() string { if x != nil { return x.xxx_hidden_Description } return "" } func (x *Tag) GetExternalDocs() *ExternalDocumentation { if x != nil { return x.xxx_hidden_ExternalDocs } return nil } func (x *Tag) GetExtensions() map[string]*structpb.Value { if x != nil { return x.xxx_hidden_Extensions } return nil } func (x *Tag) SetName(v string) { x.xxx_hidden_Name = v } func (x *Tag) SetDescription(v string) { x.xxx_hidden_Description = v } func (x *Tag) SetExternalDocs(v *ExternalDocumentation) { x.xxx_hidden_ExternalDocs = v } func (x *Tag) SetExtensions(v map[string]*structpb.Value) { x.xxx_hidden_Extensions = v } func (x *Tag) HasExternalDocs() bool { if x == nil { return false } return x.xxx_hidden_ExternalDocs != nil } func (x *Tag) ClearExternalDocs() { x.xxx_hidden_ExternalDocs = nil } type Tag_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // The name of the tag. Use it to allow override of the name of a // global Tag object, then use that name to reference the tag throughout the // OpenAPI file. Name string // A short description for the tag. GFM syntax can be used for rich text // representation. Description string // Additional external documentation for this tag. ExternalDocs *ExternalDocumentation // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value } func (b0 Tag_builder) Build() *Tag { m0 := &Tag{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Name = b.Name x.xxx_hidden_Description = b.Description x.xxx_hidden_ExternalDocs = b.ExternalDocs x.xxx_hidden_Extensions = b.Extensions return m0 } // `SecurityDefinitions` is a representation of OpenAPI v2 specification's // Security Definitions object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityDefinitionsObject // // A declaration of the security schemes available to be used in the // specification. This does not enforce the security schemes on the operations // and only serves to provide the relevant details for each scheme. type SecurityDefinitions struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Security map[string]*SecurityScheme `protobuf:"bytes,1,rep,name=security,proto3" json:"security,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *SecurityDefinitions) Reset() { *x = SecurityDefinitions{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *SecurityDefinitions) String() string { return protoimpl.X.MessageStringOf(x) } func (*SecurityDefinitions) ProtoMessage() {} func (x *SecurityDefinitions) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *SecurityDefinitions) GetSecurity() map[string]*SecurityScheme { if x != nil { return x.xxx_hidden_Security } return nil } func (x *SecurityDefinitions) SetSecurity(v map[string]*SecurityScheme) { x.xxx_hidden_Security = v } type SecurityDefinitions_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // A single security scheme definition, mapping a "name" to the scheme it // defines. Security map[string]*SecurityScheme } func (b0 SecurityDefinitions_builder) Build() *SecurityDefinitions { m0 := &SecurityDefinitions{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Security = b.Security return m0 } // `SecurityScheme` is a representation of OpenAPI v2 specification's // Security Scheme object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securitySchemeObject // // Allows the definition of a security scheme that can be used by the // operations. Supported schemes are basic authentication, an API key (either as // a header or as a query parameter) and OAuth2's common flows (implicit, // password, application and access code). type SecurityScheme struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Type SecurityScheme_Type `protobuf:"varint,1,opt,name=type,proto3,enum=grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme_Type" json:"type,omitempty"` xxx_hidden_Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` xxx_hidden_Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` xxx_hidden_In SecurityScheme_In `protobuf:"varint,4,opt,name=in,proto3,enum=grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme_In" json:"in,omitempty"` xxx_hidden_Flow SecurityScheme_Flow `protobuf:"varint,5,opt,name=flow,proto3,enum=grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme_Flow" json:"flow,omitempty"` xxx_hidden_AuthorizationUrl string `protobuf:"bytes,6,opt,name=authorization_url,json=authorizationUrl,proto3" json:"authorization_url,omitempty"` xxx_hidden_TokenUrl string `protobuf:"bytes,7,opt,name=token_url,json=tokenUrl,proto3" json:"token_url,omitempty"` xxx_hidden_Scopes *Scopes `protobuf:"bytes,8,opt,name=scopes,proto3" json:"scopes,omitempty"` xxx_hidden_Extensions map[string]*structpb.Value `protobuf:"bytes,9,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *SecurityScheme) Reset() { *x = SecurityScheme{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *SecurityScheme) String() string { return protoimpl.X.MessageStringOf(x) } func (*SecurityScheme) ProtoMessage() {} func (x *SecurityScheme) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *SecurityScheme) GetType() SecurityScheme_Type { if x != nil { return x.xxx_hidden_Type } return SecurityScheme_TYPE_INVALID } func (x *SecurityScheme) GetDescription() string { if x != nil { return x.xxx_hidden_Description } return "" } func (x *SecurityScheme) GetName() string { if x != nil { return x.xxx_hidden_Name } return "" } func (x *SecurityScheme) GetIn() SecurityScheme_In { if x != nil { return x.xxx_hidden_In } return SecurityScheme_IN_INVALID } func (x *SecurityScheme) GetFlow() SecurityScheme_Flow { if x != nil { return x.xxx_hidden_Flow } return SecurityScheme_FLOW_INVALID } func (x *SecurityScheme) GetAuthorizationUrl() string { if x != nil { return x.xxx_hidden_AuthorizationUrl } return "" } func (x *SecurityScheme) GetTokenUrl() string { if x != nil { return x.xxx_hidden_TokenUrl } return "" } func (x *SecurityScheme) GetScopes() *Scopes { if x != nil { return x.xxx_hidden_Scopes } return nil } func (x *SecurityScheme) GetExtensions() map[string]*structpb.Value { if x != nil { return x.xxx_hidden_Extensions } return nil } func (x *SecurityScheme) SetType(v SecurityScheme_Type) { x.xxx_hidden_Type = v } func (x *SecurityScheme) SetDescription(v string) { x.xxx_hidden_Description = v } func (x *SecurityScheme) SetName(v string) { x.xxx_hidden_Name = v } func (x *SecurityScheme) SetIn(v SecurityScheme_In) { x.xxx_hidden_In = v } func (x *SecurityScheme) SetFlow(v SecurityScheme_Flow) { x.xxx_hidden_Flow = v } func (x *SecurityScheme) SetAuthorizationUrl(v string) { x.xxx_hidden_AuthorizationUrl = v } func (x *SecurityScheme) SetTokenUrl(v string) { x.xxx_hidden_TokenUrl = v } func (x *SecurityScheme) SetScopes(v *Scopes) { x.xxx_hidden_Scopes = v } func (x *SecurityScheme) SetExtensions(v map[string]*structpb.Value) { x.xxx_hidden_Extensions = v } func (x *SecurityScheme) HasScopes() bool { if x == nil { return false } return x.xxx_hidden_Scopes != nil } func (x *SecurityScheme) ClearScopes() { x.xxx_hidden_Scopes = nil } type SecurityScheme_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // The type of the security scheme. Valid values are "basic", // "apiKey" or "oauth2". Type SecurityScheme_Type // A short description for security scheme. Description string // The name of the header or query parameter to be used. // Valid for apiKey. Name string // The location of the API key. Valid values are "query" or // "header". // Valid for apiKey. In SecurityScheme_In // The flow used by the OAuth2 security scheme. Valid values are // "implicit", "password", "application" or "accessCode". // Valid for oauth2. Flow SecurityScheme_Flow // The authorization URL to be used for this flow. This SHOULD be in // the form of a URL. // Valid for oauth2/implicit and oauth2/accessCode. AuthorizationUrl string // The token URL to be used for this flow. This SHOULD be in the // form of a URL. // Valid for oauth2/password, oauth2/application and oauth2/accessCode. TokenUrl string // The available scopes for the OAuth2 security scheme. // Valid for oauth2. Scopes *Scopes // Custom properties that start with "x-" such as "x-foo" used to describe // extra functionality that is not covered by the standard OpenAPI Specification. // See: https://swagger.io/docs/specification/2-0/swagger-extensions/ Extensions map[string]*structpb.Value } func (b0 SecurityScheme_builder) Build() *SecurityScheme { m0 := &SecurityScheme{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Type = b.Type x.xxx_hidden_Description = b.Description x.xxx_hidden_Name = b.Name x.xxx_hidden_In = b.In x.xxx_hidden_Flow = b.Flow x.xxx_hidden_AuthorizationUrl = b.AuthorizationUrl x.xxx_hidden_TokenUrl = b.TokenUrl x.xxx_hidden_Scopes = b.Scopes x.xxx_hidden_Extensions = b.Extensions return m0 } // `SecurityRequirement` is a representation of OpenAPI v2 specification's // Security Requirement object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityRequirementObject // // Lists the required security schemes to execute this operation. The object can // have multiple security schemes declared in it which are all required (that // is, there is a logical AND between the schemes). // // The name used for each property MUST correspond to a security scheme // declared in the Security Definitions. type SecurityRequirement struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_SecurityRequirement map[string]*SecurityRequirement_SecurityRequirementValue `protobuf:"bytes,1,rep,name=security_requirement,json=securityRequirement,proto3" json:"security_requirement,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *SecurityRequirement) Reset() { *x = SecurityRequirement{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *SecurityRequirement) String() string { return protoimpl.X.MessageStringOf(x) } func (*SecurityRequirement) ProtoMessage() {} func (x *SecurityRequirement) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *SecurityRequirement) GetSecurityRequirement() map[string]*SecurityRequirement_SecurityRequirementValue { if x != nil { return x.xxx_hidden_SecurityRequirement } return nil } func (x *SecurityRequirement) SetSecurityRequirement(v map[string]*SecurityRequirement_SecurityRequirementValue) { x.xxx_hidden_SecurityRequirement = v } type SecurityRequirement_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // Each name must correspond to a security scheme which is declared in // the Security Definitions. If the security scheme is of type "oauth2", // then the value is a list of scope names required for the execution. // For other security scheme types, the array MUST be empty. SecurityRequirement map[string]*SecurityRequirement_SecurityRequirementValue } func (b0 SecurityRequirement_builder) Build() *SecurityRequirement { m0 := &SecurityRequirement{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_SecurityRequirement = b.SecurityRequirement return m0 } // `Scopes` is a representation of OpenAPI v2 specification's Scopes object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#scopesObject // // Lists the available scopes for an OAuth2 security scheme. type Scopes struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Scope map[string]string `protobuf:"bytes,1,rep,name=scope,proto3" json:"scope,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Scopes) Reset() { *x = Scopes{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Scopes) String() string { return protoimpl.X.MessageStringOf(x) } func (*Scopes) ProtoMessage() {} func (x *Scopes) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *Scopes) GetScope() map[string]string { if x != nil { return x.xxx_hidden_Scope } return nil } func (x *Scopes) SetScope(v map[string]string) { x.xxx_hidden_Scope = v } type Scopes_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // Maps between a name of a scope to a short description of it (as the value // of the property). Scope map[string]string } func (b0 Scopes_builder) Build() *Scopes { m0 := &Scopes{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Scope = b.Scope return m0 } // 'FieldConfiguration' provides additional field level properties used when generating the OpenAPI v2 file. // These properties are not defined by OpenAPIv2, but they are used to control the generation. type JSONSchema_FieldConfiguration struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_PathParamName string `protobuf:"bytes,47,opt,name=path_param_name,json=pathParamName,proto3" json:"path_param_name,omitempty"` xxx_hidden_Deprecated bool `protobuf:"varint,49,opt,name=deprecated,proto3" json:"deprecated,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *JSONSchema_FieldConfiguration) Reset() { *x = JSONSchema_FieldConfiguration{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *JSONSchema_FieldConfiguration) String() string { return protoimpl.X.MessageStringOf(x) } func (*JSONSchema_FieldConfiguration) ProtoMessage() {} func (x *JSONSchema_FieldConfiguration) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[27] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *JSONSchema_FieldConfiguration) GetPathParamName() string { if x != nil { return x.xxx_hidden_PathParamName } return "" } func (x *JSONSchema_FieldConfiguration) GetDeprecated() bool { if x != nil { return x.xxx_hidden_Deprecated } return false } func (x *JSONSchema_FieldConfiguration) SetPathParamName(v string) { x.xxx_hidden_PathParamName = v } func (x *JSONSchema_FieldConfiguration) SetDeprecated(v bool) { x.xxx_hidden_Deprecated = v } type JSONSchema_FieldConfiguration_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. // Alternative parameter name when used as path parameter. If set, this will // be used as the complete parameter name when this field is used as a path // parameter. Use this to avoid having auto generated path parameter names // for overlapping paths. PathParamName string // Declares this field to be deprecated. Allows for the generated OpenAPI // parameter to be marked as deprecated without affecting the proto field. Deprecated bool } func (b0 JSONSchema_FieldConfiguration_builder) Build() *JSONSchema_FieldConfiguration { m0 := &JSONSchema_FieldConfiguration{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_PathParamName = b.PathParamName x.xxx_hidden_Deprecated = b.Deprecated return m0 } // If the security scheme is of type "oauth2", then the value is a list of // scope names required for the execution. For other security scheme types, // the array MUST be empty. type SecurityRequirement_SecurityRequirementValue struct { state protoimpl.MessageState `protogen:"opaque.v1"` xxx_hidden_Scope []string `protobuf:"bytes,1,rep,name=scope,proto3" json:"scope,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *SecurityRequirement_SecurityRequirementValue) Reset() { *x = SecurityRequirement_SecurityRequirementValue{} mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[32] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *SecurityRequirement_SecurityRequirementValue) String() string { return protoimpl.X.MessageStringOf(x) } func (*SecurityRequirement_SecurityRequirementValue) ProtoMessage() {} func (x *SecurityRequirement_SecurityRequirementValue) ProtoReflect() protoreflect.Message { mi := &file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes[32] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } func (x *SecurityRequirement_SecurityRequirementValue) GetScope() []string { if x != nil { return x.xxx_hidden_Scope } return nil } func (x *SecurityRequirement_SecurityRequirementValue) SetScope(v []string) { x.xxx_hidden_Scope = v } type SecurityRequirement_SecurityRequirementValue_builder struct { _ [0]func() // Prevents comparability and use of unkeyed literals for the builder. Scope []string } func (b0 SecurityRequirement_SecurityRequirementValue_builder) Build() *SecurityRequirement_SecurityRequirementValue { m0 := &SecurityRequirement_SecurityRequirementValue{} b, x := &b0, m0 _, _ = b, x x.xxx_hidden_Scope = b.Scope return m0 } var File_protoc_gen_openapiv2_options_openapiv2_proto protoreflect.FileDescriptor var file_protoc_gen_openapiv2_options_openapiv2_proto_rawDesc = []byte{ 0x0a, 0x2c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x29, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb3, 0x08, 0x0a, 0x07, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x12, 0x43, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x62, 0x61, 0x73, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12, 0x4b, 0x0a, 0x07, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x31, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x52, 0x07, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x73, 0x12, 0x5f, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x41, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x12, 0x71, 0x0a, 0x14, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x5f, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x3e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x44, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x13, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x44, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x5a, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x12, 0x42, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x54, 0x61, 0x67, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x65, 0x0a, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x6f, 0x63, 0x73, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x73, 0x12, 0x62, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x42, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x71, 0x0a, 0x0e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x49, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x55, 0x0a, 0x0f, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x4a, 0x04, 0x08, 0x08, 0x10, 0x09, 0x4a, 0x04, 0x08, 0x09, 0x10, 0x0a, 0x22, 0xd6, 0x07, 0x0a, 0x09, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x65, 0x0a, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x6f, 0x63, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x73, 0x12, 0x61, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x43, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x12, 0x4b, 0x0a, 0x07, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x31, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x52, 0x07, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x5a, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x12, 0x64, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x44, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x55, 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x1a, 0x71, 0x0a, 0x0e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x49, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x33, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x55, 0x0a, 0x0f, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x4a, 0x04, 0x08, 0x08, 0x10, 0x09, 0x22, 0x62, 0x0a, 0x0a, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x54, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x22, 0xa3, 0x02, 0x0a, 0x0f, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x53, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x22, 0x45, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x4e, 0x55, 0x4d, 0x42, 0x45, 0x52, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x54, 0x45, 0x47, 0x45, 0x52, 0x10, 0x03, 0x12, 0x0b, 0x0a, 0x07, 0x42, 0x4f, 0x4f, 0x4c, 0x45, 0x41, 0x4e, 0x10, 0x04, 0x4a, 0x04, 0x08, 0x06, 0x10, 0x07, 0x4a, 0x04, 0x08, 0x07, 0x10, 0x08, 0x22, 0xd8, 0x01, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x04, 0x08, 0x05, 0x10, 0x06, 0x4a, 0x04, 0x08, 0x07, 0x10, 0x08, 0x4a, 0x04, 0x08, 0x08, 0x10, 0x09, 0x4a, 0x04, 0x08, 0x09, 0x10, 0x0a, 0x4a, 0x04, 0x08, 0x0a, 0x10, 0x0b, 0x4a, 0x04, 0x08, 0x0b, 0x10, 0x0c, 0x4a, 0x04, 0x08, 0x0c, 0x10, 0x0d, 0x4a, 0x04, 0x08, 0x0e, 0x10, 0x0f, 0x4a, 0x04, 0x08, 0x0f, 0x10, 0x10, 0x4a, 0x04, 0x08, 0x10, 0x10, 0x11, 0x4a, 0x04, 0x08, 0x11, 0x10, 0x12, 0x4a, 0x04, 0x08, 0x12, 0x10, 0x13, 0x22, 0x9a, 0x05, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x49, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x5a, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x5d, 0x0a, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x41, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x12, 0x63, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x43, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x6d, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x47, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3b, 0x0a, 0x0d, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x55, 0x0a, 0x0f, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xd6, 0x03, 0x0a, 0x04, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x65, 0x72, 0x6d, 0x73, 0x5f, 0x6f, 0x66, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x74, 0x65, 0x72, 0x6d, 0x73, 0x4f, 0x66, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4c, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x12, 0x4c, 0x0a, 0x07, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x52, 0x07, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x5f, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x55, 0x0a, 0x0f, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x45, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x22, 0x2f, 0x0a, 0x07, 0x4c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x22, 0x4b, 0x0a, 0x15, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x22, 0xaa, 0x02, 0x0a, 0x06, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x56, 0x0a, 0x0b, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4a, 0x53, 0x4f, 0x4e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x0a, 0x6a, 0x73, 0x6f, 0x6e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x24, 0x0a, 0x0d, 0x64, 0x69, 0x73, 0x63, 0x72, 0x69, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x64, 0x69, 0x73, 0x63, 0x72, 0x69, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x65, 0x0a, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x6f, 0x63, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x22, 0xe8, 0x03, 0x0a, 0x0a, 0x45, 0x6e, 0x75, 0x6d, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x65, 0x0a, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x6f, 0x63, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x65, 0x66, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x72, 0x65, 0x66, 0x12, 0x65, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x45, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x55, 0x0a, 0x0f, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xf7, 0x0a, 0x0a, 0x0a, 0x4a, 0x53, 0x4f, 0x4e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x65, 0x66, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x72, 0x65, 0x66, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x61, 0x64, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x5f, 0x6f, 0x66, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0a, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x4f, 0x66, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x01, 0x52, 0x07, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x12, 0x2b, 0x0a, 0x11, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x76, 0x65, 0x5f, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x76, 0x65, 0x4d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x01, 0x52, 0x07, 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x12, 0x2b, 0x0a, 0x11, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x76, 0x65, 0x5f, 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x76, 0x65, 0x4d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x61, 0x78, 0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x6d, 0x61, 0x78, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x69, 0x6e, 0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x10, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x6d, 0x69, 0x6e, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x61, 0x78, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x14, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x6d, 0x61, 0x78, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x69, 0x6e, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x15, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x6d, 0x69, 0x6e, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x16, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x18, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x6d, 0x69, 0x6e, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x19, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x6d, 0x69, 0x6e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x18, 0x1a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x72, 0x72, 0x61, 0x79, 0x18, 0x22, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x61, 0x72, 0x72, 0x61, 0x79, 0x12, 0x5f, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x23, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x4b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4a, 0x53, 0x4f, 0x4e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x4a, 0x53, 0x4f, 0x4e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x73, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x24, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x65, 0x6e, 0x75, 0x6d, 0x18, 0x2e, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x65, 0x6e, 0x75, 0x6d, 0x12, 0x7a, 0x0a, 0x13, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe9, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x48, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4a, 0x53, 0x4f, 0x4e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x12, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x65, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x30, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x45, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4a, 0x53, 0x4f, 0x4e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x5c, 0x0a, 0x12, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x26, 0x0a, 0x0f, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x2f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, 0x61, 0x74, 0x68, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x31, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x1a, 0x55, 0x0a, 0x0f, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x77, 0x0a, 0x15, 0x4a, 0x53, 0x4f, 0x4e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x73, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x52, 0x52, 0x41, 0x59, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x42, 0x4f, 0x4f, 0x4c, 0x45, 0x41, 0x4e, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x54, 0x45, 0x47, 0x45, 0x52, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x55, 0x4c, 0x4c, 0x10, 0x04, 0x12, 0x0a, 0x0a, 0x06, 0x4e, 0x55, 0x4d, 0x42, 0x45, 0x52, 0x10, 0x05, 0x12, 0x0a, 0x0a, 0x06, 0x4f, 0x42, 0x4a, 0x45, 0x43, 0x54, 0x10, 0x06, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x10, 0x07, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x4a, 0x04, 0x08, 0x02, 0x10, 0x03, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x04, 0x08, 0x12, 0x10, 0x13, 0x4a, 0x04, 0x08, 0x13, 0x10, 0x14, 0x4a, 0x04, 0x08, 0x17, 0x10, 0x18, 0x4a, 0x04, 0x08, 0x1b, 0x10, 0x1c, 0x4a, 0x04, 0x08, 0x1c, 0x10, 0x1d, 0x4a, 0x04, 0x08, 0x1d, 0x10, 0x1e, 0x4a, 0x04, 0x08, 0x1e, 0x10, 0x22, 0x4a, 0x04, 0x08, 0x25, 0x10, 0x2a, 0x4a, 0x04, 0x08, 0x2a, 0x10, 0x2b, 0x4a, 0x04, 0x08, 0x2b, 0x10, 0x2e, 0x22, 0xd9, 0x02, 0x0a, 0x03, 0x54, 0x61, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x65, 0x0a, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x6f, 0x63, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x44, 0x6f, 0x63, 0x73, 0x12, 0x5e, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x54, 0x61, 0x67, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x55, 0x0a, 0x0f, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xf7, 0x01, 0x0a, 0x13, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x44, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x68, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x4c, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x44, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x1a, 0x76, 0x0a, 0x0d, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x4f, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x39, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xff, 0x06, 0x0a, 0x0e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x12, 0x52, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x4c, 0x0a, 0x02, 0x69, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3c, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x2e, 0x49, 0x6e, 0x52, 0x02, 0x69, 0x6e, 0x12, 0x52, 0x0a, 0x04, 0x66, 0x6c, 0x6f, 0x77, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x3e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x2e, 0x46, 0x6c, 0x6f, 0x77, 0x52, 0x04, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x2b, 0x0a, 0x11, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x72, 0x6c, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x55, 0x72, 0x6c, 0x12, 0x49, 0x0a, 0x06, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x52, 0x06, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x12, 0x69, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x49, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x55, 0x0a, 0x0f, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x4b, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, 0x0c, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x42, 0x41, 0x53, 0x49, 0x43, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x41, 0x50, 0x49, 0x5f, 0x4b, 0x45, 0x59, 0x10, 0x02, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4f, 0x41, 0x55, 0x54, 0x48, 0x32, 0x10, 0x03, 0x22, 0x31, 0x0a, 0x02, 0x49, 0x6e, 0x12, 0x0e, 0x0a, 0x0a, 0x49, 0x4e, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x49, 0x4e, 0x5f, 0x51, 0x55, 0x45, 0x52, 0x59, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x49, 0x4e, 0x5f, 0x48, 0x45, 0x41, 0x44, 0x45, 0x52, 0x10, 0x02, 0x22, 0x6a, 0x0a, 0x04, 0x46, 0x6c, 0x6f, 0x77, 0x12, 0x10, 0x0a, 0x0c, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x49, 0x4d, 0x50, 0x4c, 0x49, 0x43, 0x49, 0x54, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x50, 0x41, 0x53, 0x53, 0x57, 0x4f, 0x52, 0x44, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x41, 0x50, 0x50, 0x4c, 0x49, 0x43, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x03, 0x12, 0x14, 0x0a, 0x10, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x41, 0x43, 0x43, 0x45, 0x53, 0x53, 0x5f, 0x43, 0x4f, 0x44, 0x45, 0x10, 0x04, 0x22, 0xf6, 0x02, 0x0a, 0x13, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x8a, 0x01, 0x0a, 0x14, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x57, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x13, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x1a, 0x30, 0x0a, 0x18, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x1a, 0x9f, 0x01, 0x0a, 0x18, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x6d, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x57, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x96, 0x01, 0x0a, 0x06, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x12, 0x52, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3c, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x5f, 0x67, 0x65, 0x6e, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x2e, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x1a, 0x38, 0x0a, 0x0a, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x2a, 0x3b, 0x0a, 0x06, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x48, 0x54, 0x54, 0x50, 0x53, 0x10, 0x02, 0x12, 0x06, 0x0a, 0x02, 0x57, 0x53, 0x10, 0x03, 0x12, 0x07, 0x0a, 0x03, 0x57, 0x53, 0x53, 0x10, 0x04, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes = make([]protoimpl.EnumInfo, 6) var file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes = make([]protoimpl.MessageInfo, 35) var file_protoc_gen_openapiv2_options_openapiv2_proto_goTypes = []any{ (Scheme)(0), // 0: grpc.gateway.protoc_gen_openapiv2.options.Scheme (HeaderParameter_Type)(0), // 1: grpc.gateway.protoc_gen_openapiv2.options.HeaderParameter.Type (JSONSchema_JSONSchemaSimpleTypes)(0), // 2: grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.JSONSchemaSimpleTypes (SecurityScheme_Type)(0), // 3: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.Type (SecurityScheme_In)(0), // 4: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.In (SecurityScheme_Flow)(0), // 5: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.Flow (*Swagger)(nil), // 6: grpc.gateway.protoc_gen_openapiv2.options.Swagger (*Operation)(nil), // 7: grpc.gateway.protoc_gen_openapiv2.options.Operation (*Parameters)(nil), // 8: grpc.gateway.protoc_gen_openapiv2.options.Parameters (*HeaderParameter)(nil), // 9: grpc.gateway.protoc_gen_openapiv2.options.HeaderParameter (*Header)(nil), // 10: grpc.gateway.protoc_gen_openapiv2.options.Header (*Response)(nil), // 11: grpc.gateway.protoc_gen_openapiv2.options.Response (*Info)(nil), // 12: grpc.gateway.protoc_gen_openapiv2.options.Info (*Contact)(nil), // 13: grpc.gateway.protoc_gen_openapiv2.options.Contact (*License)(nil), // 14: grpc.gateway.protoc_gen_openapiv2.options.License (*ExternalDocumentation)(nil), // 15: grpc.gateway.protoc_gen_openapiv2.options.ExternalDocumentation (*Schema)(nil), // 16: grpc.gateway.protoc_gen_openapiv2.options.Schema (*EnumSchema)(nil), // 17: grpc.gateway.protoc_gen_openapiv2.options.EnumSchema (*JSONSchema)(nil), // 18: grpc.gateway.protoc_gen_openapiv2.options.JSONSchema (*Tag)(nil), // 19: grpc.gateway.protoc_gen_openapiv2.options.Tag (*SecurityDefinitions)(nil), // 20: grpc.gateway.protoc_gen_openapiv2.options.SecurityDefinitions (*SecurityScheme)(nil), // 21: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme (*SecurityRequirement)(nil), // 22: grpc.gateway.protoc_gen_openapiv2.options.SecurityRequirement (*Scopes)(nil), // 23: grpc.gateway.protoc_gen_openapiv2.options.Scopes nil, // 24: grpc.gateway.protoc_gen_openapiv2.options.Swagger.ResponsesEntry nil, // 25: grpc.gateway.protoc_gen_openapiv2.options.Swagger.ExtensionsEntry nil, // 26: grpc.gateway.protoc_gen_openapiv2.options.Operation.ResponsesEntry nil, // 27: grpc.gateway.protoc_gen_openapiv2.options.Operation.ExtensionsEntry nil, // 28: grpc.gateway.protoc_gen_openapiv2.options.Response.HeadersEntry nil, // 29: grpc.gateway.protoc_gen_openapiv2.options.Response.ExamplesEntry nil, // 30: grpc.gateway.protoc_gen_openapiv2.options.Response.ExtensionsEntry nil, // 31: grpc.gateway.protoc_gen_openapiv2.options.Info.ExtensionsEntry nil, // 32: grpc.gateway.protoc_gen_openapiv2.options.EnumSchema.ExtensionsEntry (*JSONSchema_FieldConfiguration)(nil), // 33: grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.FieldConfiguration nil, // 34: grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.ExtensionsEntry nil, // 35: grpc.gateway.protoc_gen_openapiv2.options.Tag.ExtensionsEntry nil, // 36: grpc.gateway.protoc_gen_openapiv2.options.SecurityDefinitions.SecurityEntry nil, // 37: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.ExtensionsEntry (*SecurityRequirement_SecurityRequirementValue)(nil), // 38: grpc.gateway.protoc_gen_openapiv2.options.SecurityRequirement.SecurityRequirementValue nil, // 39: grpc.gateway.protoc_gen_openapiv2.options.SecurityRequirement.SecurityRequirementEntry nil, // 40: grpc.gateway.protoc_gen_openapiv2.options.Scopes.ScopeEntry (*structpb.Value)(nil), // 41: google.protobuf.Value } var file_protoc_gen_openapiv2_options_openapiv2_proto_depIdxs = []int32{ 12, // 0: grpc.gateway.protoc_gen_openapiv2.options.Swagger.info:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Info 0, // 1: grpc.gateway.protoc_gen_openapiv2.options.Swagger.schemes:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Scheme 24, // 2: grpc.gateway.protoc_gen_openapiv2.options.Swagger.responses:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Swagger.ResponsesEntry 20, // 3: grpc.gateway.protoc_gen_openapiv2.options.Swagger.security_definitions:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityDefinitions 22, // 4: grpc.gateway.protoc_gen_openapiv2.options.Swagger.security:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityRequirement 19, // 5: grpc.gateway.protoc_gen_openapiv2.options.Swagger.tags:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Tag 15, // 6: grpc.gateway.protoc_gen_openapiv2.options.Swagger.external_docs:type_name -> grpc.gateway.protoc_gen_openapiv2.options.ExternalDocumentation 25, // 7: grpc.gateway.protoc_gen_openapiv2.options.Swagger.extensions:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Swagger.ExtensionsEntry 15, // 8: grpc.gateway.protoc_gen_openapiv2.options.Operation.external_docs:type_name -> grpc.gateway.protoc_gen_openapiv2.options.ExternalDocumentation 26, // 9: grpc.gateway.protoc_gen_openapiv2.options.Operation.responses:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Operation.ResponsesEntry 0, // 10: grpc.gateway.protoc_gen_openapiv2.options.Operation.schemes:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Scheme 22, // 11: grpc.gateway.protoc_gen_openapiv2.options.Operation.security:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityRequirement 27, // 12: grpc.gateway.protoc_gen_openapiv2.options.Operation.extensions:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Operation.ExtensionsEntry 8, // 13: grpc.gateway.protoc_gen_openapiv2.options.Operation.parameters:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Parameters 9, // 14: grpc.gateway.protoc_gen_openapiv2.options.Parameters.headers:type_name -> grpc.gateway.protoc_gen_openapiv2.options.HeaderParameter 1, // 15: grpc.gateway.protoc_gen_openapiv2.options.HeaderParameter.type:type_name -> grpc.gateway.protoc_gen_openapiv2.options.HeaderParameter.Type 16, // 16: grpc.gateway.protoc_gen_openapiv2.options.Response.schema:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Schema 28, // 17: grpc.gateway.protoc_gen_openapiv2.options.Response.headers:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Response.HeadersEntry 29, // 18: grpc.gateway.protoc_gen_openapiv2.options.Response.examples:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Response.ExamplesEntry 30, // 19: grpc.gateway.protoc_gen_openapiv2.options.Response.extensions:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Response.ExtensionsEntry 13, // 20: grpc.gateway.protoc_gen_openapiv2.options.Info.contact:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Contact 14, // 21: grpc.gateway.protoc_gen_openapiv2.options.Info.license:type_name -> grpc.gateway.protoc_gen_openapiv2.options.License 31, // 22: grpc.gateway.protoc_gen_openapiv2.options.Info.extensions:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Info.ExtensionsEntry 18, // 23: grpc.gateway.protoc_gen_openapiv2.options.Schema.json_schema:type_name -> grpc.gateway.protoc_gen_openapiv2.options.JSONSchema 15, // 24: grpc.gateway.protoc_gen_openapiv2.options.Schema.external_docs:type_name -> grpc.gateway.protoc_gen_openapiv2.options.ExternalDocumentation 15, // 25: grpc.gateway.protoc_gen_openapiv2.options.EnumSchema.external_docs:type_name -> grpc.gateway.protoc_gen_openapiv2.options.ExternalDocumentation 32, // 26: grpc.gateway.protoc_gen_openapiv2.options.EnumSchema.extensions:type_name -> grpc.gateway.protoc_gen_openapiv2.options.EnumSchema.ExtensionsEntry 2, // 27: grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.type:type_name -> grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.JSONSchemaSimpleTypes 33, // 28: grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.field_configuration:type_name -> grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.FieldConfiguration 34, // 29: grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.extensions:type_name -> grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.ExtensionsEntry 15, // 30: grpc.gateway.protoc_gen_openapiv2.options.Tag.external_docs:type_name -> grpc.gateway.protoc_gen_openapiv2.options.ExternalDocumentation 35, // 31: grpc.gateway.protoc_gen_openapiv2.options.Tag.extensions:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Tag.ExtensionsEntry 36, // 32: grpc.gateway.protoc_gen_openapiv2.options.SecurityDefinitions.security:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityDefinitions.SecurityEntry 3, // 33: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.type:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.Type 4, // 34: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.in:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.In 5, // 35: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.flow:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.Flow 23, // 36: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.scopes:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Scopes 37, // 37: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.extensions:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.ExtensionsEntry 39, // 38: grpc.gateway.protoc_gen_openapiv2.options.SecurityRequirement.security_requirement:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityRequirement.SecurityRequirementEntry 40, // 39: grpc.gateway.protoc_gen_openapiv2.options.Scopes.scope:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Scopes.ScopeEntry 11, // 40: grpc.gateway.protoc_gen_openapiv2.options.Swagger.ResponsesEntry.value:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Response 41, // 41: grpc.gateway.protoc_gen_openapiv2.options.Swagger.ExtensionsEntry.value:type_name -> google.protobuf.Value 11, // 42: grpc.gateway.protoc_gen_openapiv2.options.Operation.ResponsesEntry.value:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Response 41, // 43: grpc.gateway.protoc_gen_openapiv2.options.Operation.ExtensionsEntry.value:type_name -> google.protobuf.Value 10, // 44: grpc.gateway.protoc_gen_openapiv2.options.Response.HeadersEntry.value:type_name -> grpc.gateway.protoc_gen_openapiv2.options.Header 41, // 45: grpc.gateway.protoc_gen_openapiv2.options.Response.ExtensionsEntry.value:type_name -> google.protobuf.Value 41, // 46: grpc.gateway.protoc_gen_openapiv2.options.Info.ExtensionsEntry.value:type_name -> google.protobuf.Value 41, // 47: grpc.gateway.protoc_gen_openapiv2.options.EnumSchema.ExtensionsEntry.value:type_name -> google.protobuf.Value 41, // 48: grpc.gateway.protoc_gen_openapiv2.options.JSONSchema.ExtensionsEntry.value:type_name -> google.protobuf.Value 41, // 49: grpc.gateway.protoc_gen_openapiv2.options.Tag.ExtensionsEntry.value:type_name -> google.protobuf.Value 21, // 50: grpc.gateway.protoc_gen_openapiv2.options.SecurityDefinitions.SecurityEntry.value:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme 41, // 51: grpc.gateway.protoc_gen_openapiv2.options.SecurityScheme.ExtensionsEntry.value:type_name -> google.protobuf.Value 38, // 52: grpc.gateway.protoc_gen_openapiv2.options.SecurityRequirement.SecurityRequirementEntry.value:type_name -> grpc.gateway.protoc_gen_openapiv2.options.SecurityRequirement.SecurityRequirementValue 53, // [53:53] is the sub-list for method output_type 53, // [53:53] is the sub-list for method input_type 53, // [53:53] is the sub-list for extension type_name 53, // [53:53] is the sub-list for extension extendee 0, // [0:53] is the sub-list for field type_name } func init() { file_protoc_gen_openapiv2_options_openapiv2_proto_init() } func file_protoc_gen_openapiv2_options_openapiv2_proto_init() { if File_protoc_gen_openapiv2_options_openapiv2_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_protoc_gen_openapiv2_options_openapiv2_proto_rawDesc, NumEnums: 6, NumMessages: 35, NumExtensions: 0, NumServices: 0, }, GoTypes: file_protoc_gen_openapiv2_options_openapiv2_proto_goTypes, DependencyIndexes: file_protoc_gen_openapiv2_options_openapiv2_proto_depIdxs, EnumInfos: file_protoc_gen_openapiv2_options_openapiv2_proto_enumTypes, MessageInfos: file_protoc_gen_openapiv2_options_openapiv2_proto_msgTypes, }.Build() File_protoc_gen_openapiv2_options_openapiv2_proto = out.File file_protoc_gen_openapiv2_options_openapiv2_proto_rawDesc = nil file_protoc_gen_openapiv2_options_openapiv2_proto_goTypes = nil file_protoc_gen_openapiv2_options_openapiv2_proto_depIdxs = nil } ================================================ FILE: renovate.json ================================================ { "extends": [ "config:base", "helpers:pinGitHubActionDigests" ], "baseBranches": [ "main" ], "postUpdateOptions": [ "gomodTidy" ], "packageRules": [ { "updateTypes": [ "minor", "patch", "pin", "digest" ], "automerge": true }, { "baseBranchList": [ "main" ], "packageNames": [ "github.com/golang/protobuf", "google.golang.org/protobuf" ], "groupName": "golang/protobuf" }, { "packagePatterns": [ "jekyll.*", "github-pages" ], "enabled": false }, { "matchManagers": [ "github-actions" ], "matchPackageNames": [ "slsa-framework/slsa-github-generator" ], "pinDigests": false } ] } ================================================ FILE: repositories.bzl ================================================ load("@bazel_gazelle//:deps.bzl", "go_repository") def go_repositories(): go_repository( name = "co_honnef_go_tools", importpath = "honnef.co/go/tools", sum = "h1:/hemPrYIhOhy8zYrNj+069zDB68us2sMGsfkFJO0iZs=", version = "v0.0.0-20190523083050-ea95bdfd59fc", ) go_repository( name = "com_github_alecthomas_template", importpath = "github.com/alecthomas/template", sum = "h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU=", version = "v0.0.0-20160405071501-a0175ee3bccc", ) go_repository( name = "com_github_alecthomas_units", importpath = "github.com/alecthomas/units", sum = "h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=", version = "v0.0.0-20151022065526-2efee857e7cf", ) go_repository( name = "com_github_antihax_optional", importpath = "github.com/antihax/optional", sum = "h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwcg=", version = "v1.0.0", ) go_repository( name = "com_github_armon_circbuf", importpath = "github.com/armon/circbuf", sum = "h1:QEF07wC0T1rKkctt1RINW/+RMTVmiwxETico2l3gxJA=", version = "v0.0.0-20150827004946-bbbad097214e", ) go_repository( name = "com_github_armon_go_metrics", importpath = "github.com/armon/go-metrics", sum = "h1:8GUt8eRujhVEGZFFEjBj46YV4rDjvGrNxb0KMWYkL2I=", version = "v0.0.0-20180917152333-f0300d1749da", ) go_repository( name = "com_github_armon_go_radix", importpath = "github.com/armon/go-radix", sum = "h1:BUAU3CGlLvorLI26FmByPp2eC2qla6E1Tw+scpcg/to=", version = "v0.0.0-20180808171621-7fddfc383310", ) go_repository( name = "com_github_beorn7_perks", importpath = "github.com/beorn7/perks", sum = "h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0=", version = "v1.0.0", ) go_repository( name = "com_github_bgentry_go_netrc", importpath = "github.com/bgentry/go-netrc", sum = "h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas=", version = "v0.0.0-20140422174119-9fd32a8b3d3d", ) go_repository( name = "com_github_bgentry_speakeasy", importpath = "github.com/bgentry/speakeasy", sum = "h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=", version = "v0.1.0", ) go_repository( name = "com_github_bketelsen_crypt", importpath = "github.com/bketelsen/crypt", sum = "h1:+0HFd5KSZ/mm3JmhmrDukiId5iR6w4+BdFtfSy4yWIc=", version = "v0.0.3-0.20200106085610-5cbc8cc4026c", ) go_repository( name = "com_github_bufbuild_buf", importpath = "github.com/bufbuild/buf", sum = "h1:11zJVA0D4uJVGOC9h+oOVHrKKoBgMYIqJJ0d1Xt6oeQ=", version = "v0.37.0", ) go_repository( name = "com_github_burntsushi_toml", importpath = "github.com/BurntSushi/toml", sum = "h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=", version = "v0.3.1", ) go_repository( name = "com_github_burntsushi_xgb", importpath = "github.com/BurntSushi/xgb", sum = "h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc=", version = "v0.0.0-20160522181843-27f122750802", ) go_repository( name = "com_github_census_instrumentation_opencensus_proto", importpath = "github.com/census-instrumentation/opencensus-proto", sum = "h1:iKLQ0xPNFxR/2hzXZMrBo8f1j86j5WHzznCCQxV/b8g=", version = "v0.4.1", ) go_repository( name = "com_github_cespare_xxhash", importpath = "github.com/cespare/xxhash", sum = "h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=", version = "v1.1.0", ) go_repository( name = "com_github_cespare_xxhash_v2", importpath = "github.com/cespare/xxhash/v2", sum = "h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=", version = "v2.3.0", ) go_repository( name = "com_github_chzyer_logex", importpath = "github.com/chzyer/logex", sum = "h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=", version = "v1.1.10", ) go_repository( name = "com_github_chzyer_readline", importpath = "github.com/chzyer/readline", sum = "h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8=", version = "v0.0.0-20180603132655-2972be24d48e", ) go_repository( name = "com_github_chzyer_test", importpath = "github.com/chzyer/test", sum = "h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=", version = "v0.0.0-20180213035817-a1ea475d72b1", ) go_repository( name = "com_github_client9_misspell", importpath = "github.com/client9/misspell", sum = "h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=", version = "v0.3.4", ) go_repository( name = "com_github_cncf_udpa_go", importpath = "github.com/cncf/udpa/go", sum = "h1:QQ3GSy+MqSHxm/d8nCtnAiZdYFd45cYZPs8vOOIYKfk=", version = "v0.0.0-20220112060539-c52dc94e7fbe", ) go_repository( name = "com_github_cncf_xds_go", importpath = "github.com/cncf/xds/go", sum = "h1:6xNmx7iTtyBRev0+D/Tv1FZd4SCg8axKApyNyRsAt/w=", version = "v0.0.0-20251210132809-ee656c7534f5", ) go_repository( name = "com_github_coreos_bbolt", importpath = "github.com/coreos/bbolt", sum = "h1:wZwiHHUieZCquLkDL0B8UhzreNWsPHooDAG3q34zk0s=", version = "v1.3.2", ) go_repository( name = "com_github_coreos_etcd", importpath = "github.com/coreos/etcd", sum = "h1:8F3hqu9fGYLBifCmRCJsicFqDx/D68Rt3q1JMazcgBQ=", version = "v3.3.13+incompatible", ) go_repository( name = "com_github_coreos_go_semver", importpath = "github.com/coreos/go-semver", sum = "h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=", version = "v0.3.0", ) go_repository( name = "com_github_coreos_go_systemd", importpath = "github.com/coreos/go-systemd", sum = "h1:Wf6HqHfScWJN9/ZjdUKyjop4mf3Qdd+1TvvltAvM3m8=", version = "v0.0.0-20190321100706-95778dfbb74e", ) go_repository( name = "com_github_coreos_pkg", importpath = "github.com/coreos/pkg", sum = "h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg=", version = "v0.0.0-20180928190104-399ea9e2e55f", ) go_repository( name = "com_github_cpuguy83_go_md2man_v2", importpath = "github.com/cpuguy83/go-md2man/v2", sum = "h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=", version = "v2.0.0", ) go_repository( name = "com_github_creack_pty", importpath = "github.com/creack/pty", sum = "h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w=", version = "v1.1.9", ) go_repository( name = "com_github_davecgh_go_spew", importpath = "github.com/davecgh/go-spew", sum = "h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=", version = "v1.1.0", ) go_repository( name = "com_github_dgrijalva_jwt_go", importpath = "github.com/dgrijalva/jwt-go", sum = "h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=", version = "v3.2.0+incompatible", ) go_repository( name = "com_github_dgryski_go_sip13", importpath = "github.com/dgryski/go-sip13", sum = "h1:RMLoZVzv4GliuWafOuPuQDKSm1SJph7uCRnnS61JAn4=", version = "v0.0.0-20181026042036-e10d5fee7954", ) go_repository( name = "com_github_envoyproxy_go_control_plane", importpath = "github.com/envoyproxy/go-control-plane", sum = "h1:hbG2kr4RuFj222B6+7T83thSPqLjwBIfQawTkC++2HA=", version = "v0.14.0", ) go_repository( name = "com_github_envoyproxy_go_control_plane_envoy", importpath = "github.com/envoyproxy/go-control-plane/envoy", sum = "h1:yg/JjO5E7ubRyKX3m07GF3reDNEnfOboJ0QySbH736g=", version = "v1.36.0", ) go_repository( name = "com_github_envoyproxy_go_control_plane_ratelimit", importpath = "github.com/envoyproxy/go-control-plane/ratelimit", sum = "h1:/G9QYbddjL25KvtKTv3an9lx6VBE2cnb8wp1vEGNYGI=", version = "v0.1.0", ) go_repository( name = "com_github_envoyproxy_protoc_gen_validate", importpath = "github.com/envoyproxy/protoc-gen-validate", sum = "h1:TvGH1wof4H33rezVKWSpqKz5NXWg5VPuZ0uONDT6eb4=", version = "v1.3.0", ) go_repository( name = "com_github_fatih_color", importpath = "github.com/fatih/color", sum = "h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=", version = "v1.7.0", ) go_repository( name = "com_github_fsnotify_fsnotify", importpath = "github.com/fsnotify/fsnotify", sum = "h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=", version = "v1.4.7", ) go_repository( name = "com_github_ghodss_yaml", importpath = "github.com/ghodss/yaml", sum = "h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=", version = "v1.0.0", ) go_repository( name = "com_github_go_gl_glfw", importpath = "github.com/go-gl/glfw", sum = "h1:QbL/5oDUmRBzO9/Z7Seo6zf912W/a6Sr4Eu0G/3Jho0=", version = "v0.0.0-20190409004039-e6da0acd62b1", ) go_repository( name = "com_github_go_gl_glfw_v3_3_glfw", importpath = "github.com/go-gl/glfw/v3.3/glfw", sum = "h1:WtGNWLvXpe6ZudgnXrq0barxBImvnnJoMEhXAzcbM0I=", version = "v0.0.0-20200222043503-6f7a984d4dc4", ) go_repository( name = "com_github_go_jose_go_jose_v4", importpath = "github.com/go-jose/go-jose/v4", sum = "h1:CVLmWDhDVRa6Mi/IgCgaopNosCaHz7zrMeF9MlZRkrs=", version = "v4.1.3", ) go_repository( name = "com_github_go_kit_kit", importpath = "github.com/go-kit/kit", sum = "h1:Wz+5lgoB0kkuqLEc6NVmwRknTKP6dTGbSqvhZtBI/j0=", version = "v0.8.0", ) go_repository( name = "com_github_go_logfmt_logfmt", importpath = "github.com/go-logfmt/logfmt", sum = "h1:MP4Eh7ZCb31lleYCFuwm0oe4/YGak+5l1vA2NOE80nA=", version = "v0.4.0", ) go_repository( name = "com_github_go_logr_logr", importpath = "github.com/go-logr/logr", sum = "h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=", version = "v1.4.3", ) go_repository( name = "com_github_go_logr_stdr", importpath = "github.com/go-logr/stdr", sum = "h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=", version = "v1.2.2", ) go_repository( name = "com_github_go_stack_stack", importpath = "github.com/go-stack/stack", sum = "h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=", version = "v1.8.0", ) go_repository( name = "com_github_gofrs_flock", importpath = "github.com/gofrs/flock", sum = "h1:MSdYClljsF3PbENUUEx85nkWfJSGfzYI9yEBZOJz6CY=", version = "v0.8.0", ) go_repository( name = "com_github_gofrs_uuid", importpath = "github.com/gofrs/uuid", sum = "h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=", version = "v4.0.0+incompatible", ) go_repository( name = "com_github_gogo_protobuf", importpath = "github.com/gogo/protobuf", sum = "h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE=", version = "v1.2.1", ) go_repository( name = "com_github_golang_glog", importpath = "github.com/golang/glog", sum = "h1:DrW6hGnjIhtvhOIiAKT6Psh/Kd/ldepEa81DKeiRJ5I=", version = "v1.2.5", ) go_repository( name = "com_github_golang_groupcache", importpath = "github.com/golang/groupcache", sum = "h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY=", version = "v0.0.0-20200121045136-8c9f03a8e57e", ) go_repository( name = "com_github_golang_mock", importpath = "github.com/golang/mock", sum = "h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8=", version = "v1.1.1", ) go_repository( name = "com_github_golang_protobuf", importpath = "github.com/golang/protobuf", sum = "h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=", version = "v1.5.4", ) go_repository( name = "com_github_google_btree", importpath = "github.com/google/btree", sum = "h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=", version = "v1.0.0", ) go_repository( name = "com_github_google_go_cmp", importpath = "github.com/google/go-cmp", sum = "h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=", version = "v0.7.0", ) go_repository( name = "com_github_google_martian", importpath = "github.com/google/martian", sum = "h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=", version = "v2.1.0+incompatible", ) go_repository( name = "com_github_google_martian_v3", importpath = "github.com/google/martian/v3", sum = "h1:pMen7vLs8nvgEYhywH3KDWJIJTeEr2ULsVWHWYHQyBs=", version = "v3.0.0", ) go_repository( name = "com_github_google_pprof", importpath = "github.com/google/pprof", sum = "h1:Ak8CrdlwwXwAZxzS66vgPt4U8yUZX7JwLvVR58FN5jM=", version = "v0.0.0-20200708004538-1a94d8640e99", ) go_repository( name = "com_github_google_renameio", importpath = "github.com/google/renameio", sum = "h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA=", version = "v0.1.0", ) go_repository( name = "com_github_google_uuid", importpath = "github.com/google/uuid", sum = "h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=", version = "v1.6.0", ) go_repository( name = "com_github_googleapis_gax_go_v2", importpath = "github.com/googleapis/gax-go/v2", sum = "h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM=", version = "v2.0.5", ) go_repository( name = "com_github_googlecloudplatform_opentelemetry_operations_go_detectors_gcp", importpath = "github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp", sum = "h1:sBEjpZlNHzK1voKq9695PJSX2o5NEXl7/OL3coiIY0c=", version = "v1.30.0", ) go_repository( name = "com_github_gopherjs_gopherjs", importpath = "github.com/gopherjs/gopherjs", sum = "h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=", version = "v0.0.0-20181017120253-0766667cb4d1", ) go_repository( name = "com_github_gordonklaus_ineffassign", importpath = "github.com/gordonklaus/ineffassign", sum = "h1:vc7Dmrk4JwS0ZPS6WZvWlwDflgDTA26jItmbSj83nug=", version = "v0.0.0-20200309095847-7953dde2c7bf", ) go_repository( name = "com_github_gorilla_websocket", importpath = "github.com/gorilla/websocket", sum = "h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=", version = "v1.4.2", ) go_repository( name = "com_github_grpc_ecosystem_go_grpc_middleware", importpath = "github.com/grpc-ecosystem/go-grpc-middleware", sum = "h1:Iju5GlWwrvL6UBg4zJJt3btmonfrMlCDdsejg4CZE7c=", version = "v1.0.0", ) go_repository( name = "com_github_grpc_ecosystem_go_grpc_prometheus", importpath = "github.com/grpc-ecosystem/go-grpc-prometheus", sum = "h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=", version = "v1.2.0", ) go_repository( name = "com_github_grpc_ecosystem_grpc_gateway", importpath = "github.com/grpc-ecosystem/grpc-gateway", sum = "h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=", version = "v1.16.0", ) go_repository( name = "com_github_hashicorp_consul_api", importpath = "github.com/hashicorp/consul/api", sum = "h1:BNQPM9ytxj6jbjjdRPioQ94T6YXriSopn0i8COv6SRA=", version = "v1.1.0", ) go_repository( name = "com_github_hashicorp_consul_sdk", importpath = "github.com/hashicorp/consul/sdk", sum = "h1:LnuDWGNsoajlhGyHJvuWW6FVqRl8JOTPqS6CPTsYjhY=", version = "v0.1.1", ) go_repository( name = "com_github_hashicorp_errwrap", importpath = "github.com/hashicorp/errwrap", sum = "h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=", version = "v1.0.0", ) go_repository( name = "com_github_hashicorp_go_cleanhttp", importpath = "github.com/hashicorp/go-cleanhttp", sum = "h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM=", version = "v0.5.1", ) go_repository( name = "com_github_hashicorp_go_immutable_radix", importpath = "github.com/hashicorp/go-immutable-radix", sum = "h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0=", version = "v1.0.0", ) go_repository( name = "com_github_hashicorp_go_msgpack", importpath = "github.com/hashicorp/go-msgpack", sum = "h1:zKjpN5BK/P5lMYrLmBHdBULWbJ0XpYR+7NGzqkZzoD4=", version = "v0.5.3", ) go_repository( name = "com_github_hashicorp_go_multierror", importpath = "github.com/hashicorp/go-multierror", sum = "h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o=", version = "v1.0.0", ) go_repository( name = "com_github_hashicorp_go_net", importpath = "github.com/hashicorp/go.net", sum = "h1:sNCoNyDEvN1xa+X0baata4RdcpKwcMS6DH+xwfqPgjw=", version = "v0.0.1", ) go_repository( name = "com_github_hashicorp_go_rootcerts", importpath = "github.com/hashicorp/go-rootcerts", sum = "h1:Rqb66Oo1X/eSV1x66xbDccZjhJigjg0+e82kpwzSwCI=", version = "v1.0.0", ) go_repository( name = "com_github_hashicorp_go_sockaddr", importpath = "github.com/hashicorp/go-sockaddr", sum = "h1:GeH6tui99pF4NJgfnhp+L6+FfobzVW3Ah46sLo0ICXs=", version = "v1.0.0", ) go_repository( name = "com_github_hashicorp_go_syslog", importpath = "github.com/hashicorp/go-syslog", sum = "h1:KaodqZuhUoZereWVIYmpUgZysurB1kBLX2j0MwMrUAE=", version = "v1.0.0", ) go_repository( name = "com_github_hashicorp_go_uuid", importpath = "github.com/hashicorp/go-uuid", sum = "h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE=", version = "v1.0.1", ) go_repository( name = "com_github_hashicorp_golang_lru", importpath = "github.com/hashicorp/golang-lru", sum = "h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU=", version = "v0.5.1", ) go_repository( name = "com_github_hashicorp_hcl", importpath = "github.com/hashicorp/hcl", sum = "h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=", version = "v1.0.0", ) go_repository( name = "com_github_hashicorp_logutils", importpath = "github.com/hashicorp/logutils", sum = "h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=", version = "v1.0.0", ) go_repository( name = "com_github_hashicorp_mdns", importpath = "github.com/hashicorp/mdns", sum = "h1:WhIgCr5a7AaVH6jPUwjtRuuE7/RDufnUvzIr48smyxs=", version = "v1.0.0", ) go_repository( name = "com_github_hashicorp_memberlist", importpath = "github.com/hashicorp/memberlist", sum = "h1:EmmoJme1matNzb+hMpDuR/0sbJSUisxyqBGG676r31M=", version = "v0.1.3", ) go_repository( name = "com_github_hashicorp_serf", importpath = "github.com/hashicorp/serf", sum = "h1:YZ7UKsJv+hKjqGVUUbtE3HNj79Eln2oQ75tniF6iPt0=", version = "v0.8.2", ) go_repository( name = "com_github_ianlancetaylor_demangle", importpath = "github.com/ianlancetaylor/demangle", sum = "h1:UDMh68UUwekSh5iP2OMhRRZJiiBccgV7axzUG8vi56c=", version = "v0.0.0-20181102032728-5e5cf60278f6", ) go_repository( name = "com_github_inconshreveable_mousetrap", importpath = "github.com/inconshreveable/mousetrap", sum = "h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=", version = "v1.0.0", ) go_repository( name = "com_github_jhump_protoreflect", importpath = "github.com/jhump/protoreflect", sum = "h1:z7Ciiz3Bz37zSd485fbiTW8ABafIasyOWZI0N9EUUdo=", version = "v1.8.1", ) go_repository( name = "com_github_jonboulle_clockwork", importpath = "github.com/jonboulle/clockwork", sum = "h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo=", version = "v0.1.0", ) go_repository( name = "com_github_json_iterator_go", importpath = "github.com/json-iterator/go", sum = "h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs=", version = "v1.1.6", ) go_repository( name = "com_github_jstemmer_go_junit_report", importpath = "github.com/jstemmer/go-junit-report", sum = "h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o=", version = "v0.9.1", ) go_repository( name = "com_github_jtolds_gls", importpath = "github.com/jtolds/gls", sum = "h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=", version = "v4.20.0+incompatible", ) go_repository( name = "com_github_julienschmidt_httprouter", importpath = "github.com/julienschmidt/httprouter", sum = "h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g=", version = "v1.2.0", ) go_repository( name = "com_github_kisielk_errcheck", importpath = "github.com/kisielk/errcheck", sum = "h1:ZqfnKyx9KGpRcW04j5nnPDgRgoXUeLh2YFBeFzphcA0=", version = "v1.1.0", ) go_repository( name = "com_github_kisielk_gotool", importpath = "github.com/kisielk/gotool", sum = "h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=", version = "v1.0.0", ) go_repository( name = "com_github_klauspost_compress", importpath = "github.com/klauspost/compress", sum = "h1:0hzRabrMN4tSTvMfnL3SCv1ZGeAP23ynzodBgaHeMeg=", version = "v1.11.7", ) go_repository( name = "com_github_klauspost_pgzip", importpath = "github.com/klauspost/pgzip", sum = "h1:qnWYvvKqedOF2ulHpMG72XQol4ILEJ8k2wwRl/Km8oE=", version = "v1.2.5", ) go_repository( name = "com_github_konsorten_go_windows_terminal_sequences", importpath = "github.com/konsorten/go-windows-terminal-sequences", sum = "h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=", version = "v1.0.1", ) go_repository( name = "com_github_kr_logfmt", importpath = "github.com/kr/logfmt", sum = "h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY=", version = "v0.0.0-20140226030751-b84e30acd515", ) go_repository( name = "com_github_kr_pretty", importpath = "github.com/kr/pretty", sum = "h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=", version = "v0.3.1", ) go_repository( name = "com_github_kr_pty", importpath = "github.com/kr/pty", sum = "h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=", version = "v1.1.1", ) go_repository( name = "com_github_kr_text", importpath = "github.com/kr/text", sum = "h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=", version = "v0.2.0", ) go_repository( name = "com_github_magiconair_properties", importpath = "github.com/magiconair/properties", sum = "h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=", version = "v1.8.1", ) go_repository( name = "com_github_mattn_go_colorable", importpath = "github.com/mattn/go-colorable", sum = "h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=", version = "v0.0.9", ) go_repository( name = "com_github_mattn_go_isatty", importpath = "github.com/mattn/go-isatty", sum = "h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI=", version = "v0.0.3", ) go_repository( name = "com_github_matttproud_golang_protobuf_extensions", importpath = "github.com/matttproud/golang_protobuf_extensions", sum = "h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=", version = "v1.0.1", ) go_repository( name = "com_github_miekg_dns", importpath = "github.com/miekg/dns", sum = "h1:9jZdLNd/P4+SfEJ0TNyxYpsK8N4GtfylBLqtbYN1sbA=", version = "v1.0.14", ) go_repository( name = "com_github_mitchellh_cli", importpath = "github.com/mitchellh/cli", sum = "h1:iGBIsUe3+HZ/AD/Vd7DErOt5sU9fa8Uj7A2s1aggv1Y=", version = "v1.0.0", ) go_repository( name = "com_github_mitchellh_go_homedir", importpath = "github.com/mitchellh/go-homedir", sum = "h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=", version = "v1.1.0", ) go_repository( name = "com_github_mitchellh_go_testing_interface", importpath = "github.com/mitchellh/go-testing-interface", sum = "h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0=", version = "v1.0.0", ) go_repository( name = "com_github_mitchellh_gox", importpath = "github.com/mitchellh/gox", sum = "h1:lfGJxY7ToLJQjHHwi0EX6uYBdK78egf954SQl13PQJc=", version = "v0.4.0", ) go_repository( name = "com_github_mitchellh_iochan", importpath = "github.com/mitchellh/iochan", sum = "h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY=", version = "v1.0.0", ) go_repository( name = "com_github_mitchellh_mapstructure", importpath = "github.com/mitchellh/mapstructure", sum = "h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=", version = "v1.1.2", ) go_repository( name = "com_github_modern_go_concurrent", importpath = "github.com/modern-go/concurrent", sum = "h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=", version = "v0.0.0-20180306012644-bacd9c7ef1dd", ) go_repository( name = "com_github_modern_go_reflect2", importpath = "github.com/modern-go/reflect2", sum = "h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=", version = "v1.0.1", ) go_repository( name = "com_github_mwitkow_go_conntrack", importpath = "github.com/mwitkow/go-conntrack", sum = "h1:F9x/1yl3T2AeKLr2AMdilSD8+f9bvMnNN8VS5iDtovc=", version = "v0.0.0-20161129095857-cc309e4a2223", ) go_repository( name = "com_github_nishanths_predeclared", importpath = "github.com/nishanths/predeclared", sum = "h1:3f0nxAmdj/VoCGN/ijdMy7bj6SBagaqYg1B0hu8clMA=", version = "v0.0.0-20200524104333-86fad755b4d3", ) go_repository( name = "com_github_oklog_ulid", importpath = "github.com/oklog/ulid", sum = "h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=", version = "v1.3.1", ) go_repository( name = "com_github_oneofone_xxhash", importpath = "github.com/OneOfOne/xxhash", sum = "h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=", version = "v1.2.2", ) go_repository( name = "com_github_pascaldekloe_goe", importpath = "github.com/pascaldekloe/goe", sum = "h1:Lgl0gzECD8GnQ5QCWA8o6BtfL6mDH5rQgM4/fX3avOs=", version = "v0.0.0-20180627143212-57f6aae5913c", ) go_repository( name = "com_github_pelletier_go_toml", importpath = "github.com/pelletier/go-toml", sum = "h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=", version = "v1.2.0", ) go_repository( name = "com_github_pkg_diff", importpath = "github.com/pkg/diff", sum = "h1:aoZm08cpOy4WuID//EZDgcC4zIxODThtZNPirFr42+A=", version = "v0.0.0-20210226163009-20ebb0f2a09e", ) go_repository( name = "com_github_pkg_errors", importpath = "github.com/pkg/errors", sum = "h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=", version = "v0.9.1", ) go_repository( name = "com_github_pkg_profile", importpath = "github.com/pkg/profile", sum = "h1:042Buzk+NhDI+DeSAA62RwJL8VAuZUMQZUjCsRz1Mug=", version = "v1.5.0", ) go_repository( name = "com_github_planetscale_vtprotobuf", importpath = "github.com/planetscale/vtprotobuf", sum = "h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo=", version = "v0.6.1-0.20240319094008-0393e58bdf10", ) go_repository( name = "com_github_pmezard_go_difflib", importpath = "github.com/pmezard/go-difflib", sum = "h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=", version = "v1.0.0", ) go_repository( name = "com_github_posener_complete", importpath = "github.com/posener/complete", sum = "h1:ccV59UEOTzVDnDUEFdT95ZzHVZ+5+158q8+SJb2QV5w=", version = "v1.1.1", ) go_repository( name = "com_github_prometheus_client_golang", importpath = "github.com/prometheus/client_golang", sum = "h1:9iH4JKXLzFbOAdtqv/a+j8aewx2Y8lAjAydhbaScPF8=", version = "v0.9.3", ) go_repository( name = "com_github_prometheus_client_model", importpath = "github.com/prometheus/client_model", sum = "h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM=", version = "v0.0.0-20190812154241-14fe0d1b01d4", ) go_repository( name = "com_github_prometheus_common", importpath = "github.com/prometheus/common", sum = "h1:7etb9YClo3a6HjLzfl6rIQaU+FDfi0VSX39io3aQ+DM=", version = "v0.4.0", ) go_repository( name = "com_github_prometheus_procfs", importpath = "github.com/prometheus/procfs", sum = "h1:sofwID9zm4tzrgykg80hfFph1mryUeLRsUfoocVVmRY=", version = "v0.0.0-20190507164030-5867b95ac084", ) go_repository( name = "com_github_prometheus_tsdb", importpath = "github.com/prometheus/tsdb", sum = "h1:YZcsG11NqnK4czYLrWd9mpEuAJIHVQLwdrleYfszMAA=", version = "v0.7.1", ) go_repository( name = "com_github_rogpeppe_fastuuid", importpath = "github.com/rogpeppe/fastuuid", sum = "h1:Ppwyp6VYCF1nvBTXL3trRso7mXMlRrw9ooo375wvi2s=", version = "v1.2.0", ) go_repository( name = "com_github_rogpeppe_go_internal", importpath = "github.com/rogpeppe/go-internal", sum = "h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=", version = "v1.9.0", ) go_repository( name = "com_github_russross_blackfriday_v2", importpath = "github.com/russross/blackfriday/v2", sum = "h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=", version = "v2.0.1", ) go_repository( name = "com_github_ryanuber_columnize", importpath = "github.com/ryanuber/columnize", sum = "h1:UFr9zpz4xgTnIE5yIMtWAMngCdZ9p/+q6lTbgelo80M=", version = "v0.0.0-20160712163229-9b3edd62028f", ) go_repository( name = "com_github_sean_seed", importpath = "github.com/sean-/seed", sum = "h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I=", version = "v0.0.0-20170313163322-e2103e2c3529", ) go_repository( name = "com_github_shurcool_sanitized_anchor_name", importpath = "github.com/shurcooL/sanitized_anchor_name", sum = "h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=", version = "v1.0.0", ) go_repository( name = "com_github_sirupsen_logrus", importpath = "github.com/sirupsen/logrus", sum = "h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=", version = "v1.2.0", ) go_repository( name = "com_github_smartystreets_assertions", importpath = "github.com/smartystreets/assertions", sum = "h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=", version = "v0.0.0-20180927180507-b2de0cb4f26d", ) go_repository( name = "com_github_smartystreets_goconvey", importpath = "github.com/smartystreets/goconvey", sum = "h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=", version = "v1.6.4", ) go_repository( name = "com_github_soheilhy_cmux", importpath = "github.com/soheilhy/cmux", sum = "h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E=", version = "v0.1.4", ) go_repository( name = "com_github_spaolacci_murmur3", importpath = "github.com/spaolacci/murmur3", sum = "h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ=", version = "v0.0.0-20180118202830-f09979ecbc72", ) go_repository( name = "com_github_spf13_afero", importpath = "github.com/spf13/afero", sum = "h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=", version = "v1.1.2", ) go_repository( name = "com_github_spf13_cast", importpath = "github.com/spf13/cast", sum = "h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=", version = "v1.3.0", ) go_repository( name = "com_github_spf13_cobra", importpath = "github.com/spf13/cobra", sum = "h1:O63eWlXlvyw4YdsuatjRIU6emvJ2fqz+PTdMEoxIT2s=", version = "v1.0.1-0.20201006035406-b97b5ead31f7", ) go_repository( name = "com_github_spf13_jwalterweatherman", importpath = "github.com/spf13/jwalterweatherman", sum = "h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=", version = "v1.0.0", ) go_repository( name = "com_github_spf13_pflag", importpath = "github.com/spf13/pflag", sum = "h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=", version = "v1.0.5", ) go_repository( name = "com_github_spf13_viper", importpath = "github.com/spf13/viper", sum = "h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM=", version = "v1.7.0", ) go_repository( name = "com_github_spiffe_go_spiffe_v2", importpath = "github.com/spiffe/go-spiffe/v2", sum = "h1:l+DolpxNWYgruGQVV0xsfeya3CsC7m8iBzDnMpsbLuo=", version = "v2.6.0", ) go_repository( name = "com_github_stretchr_objx", importpath = "github.com/stretchr/objx", sum = "h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=", version = "v0.1.0", ) go_repository( name = "com_github_stretchr_testify", importpath = "github.com/stretchr/testify", sum = "h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=", version = "v1.7.0", ) go_repository( name = "com_github_subosito_gotenv", importpath = "github.com/subosito/gotenv", sum = "h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=", version = "v1.2.0", ) go_repository( name = "com_github_tmc_grpc_websocket_proxy", importpath = "github.com/tmc/grpc-websocket-proxy", sum = "h1:LnC5Kc/wtumK+WB441p7ynQJzVuNRJiqddSIE3IlSEQ=", version = "v0.0.0-20190109142713-0ad062ec5ee5", ) go_repository( name = "com_github_twitchtv_twirp", importpath = "github.com/twitchtv/twirp", sum = "h1:3fNSDoSPyq+fTrifIvGue9XM/tptzuhiGY83rxPVNUg=", version = "v7.1.0+incompatible", ) go_repository( name = "com_github_xiang90_probing", importpath = "github.com/xiang90/probing", sum = "h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=", version = "v0.0.0-20190116061207-43a291ad63a2", ) go_repository( name = "com_github_yuin_goldmark", importpath = "github.com/yuin/goldmark", sum = "h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=", version = "v1.4.13", ) go_repository( name = "com_github_zeebo_errs", importpath = "github.com/zeebo/errs", sum = "h1:XNdoD/RRMKP7HD0UhJnIzUy74ISdGGxURlYG8HSWSfM=", version = "v1.4.0", ) go_repository( name = "com_google_cloud_go", importpath = "cloud.google.com/go", sum = "h1:tpFCD7hpHFlQ8yPwT3x+QeXqc2T6+n6T+hmABHfDUSM=", version = "v0.112.0", ) go_repository( name = "com_google_cloud_go_accessapproval", importpath = "cloud.google.com/go/accessapproval", sum = "h1:uzmAMSgYcnlHa9X9YSQZ4Q1wlfl4NNkZyQgho1Z6p04=", version = "v1.7.5", ) go_repository( name = "com_google_cloud_go_accesscontextmanager", importpath = "cloud.google.com/go/accesscontextmanager", sum = "h1:2GLNaNu9KRJhJBFTIVRoPwk6xE5mUDgD47abBq4Zp/I=", version = "v1.8.5", ) go_repository( name = "com_google_cloud_go_aiplatform", importpath = "cloud.google.com/go/aiplatform", sum = "h1:0cSrii1ZeLr16MbBoocyy5KVnrSdiQ3KN/vtrTe7RqE=", version = "v1.60.0", ) go_repository( name = "com_google_cloud_go_analytics", importpath = "cloud.google.com/go/analytics", sum = "h1:Q+y94XH84jM8SK8O7qiY/PJRexb6n7dRbQ6PiUa4YGM=", version = "v0.23.0", ) go_repository( name = "com_google_cloud_go_apigateway", importpath = "cloud.google.com/go/apigateway", sum = "h1:sPXnpk+6TneKIrjCjcpX5YGsAKy3PTdpIchoj8/74OE=", version = "v1.6.5", ) go_repository( name = "com_google_cloud_go_apigeeconnect", importpath = "cloud.google.com/go/apigeeconnect", sum = "h1:CrfIKv9Go3fh/QfQgisU3MeP90Ww7l/sVGmr3TpECo8=", version = "v1.6.5", ) go_repository( name = "com_google_cloud_go_apigeeregistry", importpath = "cloud.google.com/go/apigeeregistry", sum = "h1:C+QU2K+DzDjk4g074ouwHQGkoff1h5OMQp6sblCVreQ=", version = "v0.8.3", ) go_repository( name = "com_google_cloud_go_apikeys", importpath = "cloud.google.com/go/apikeys", sum = "h1:B9CdHFZTFjVti89tmyXXrO+7vSNo2jvZuHG8zD5trdQ=", version = "v0.6.0", ) go_repository( name = "com_google_cloud_go_appengine", importpath = "cloud.google.com/go/appengine", sum = "h1:l2SviT44zWQiOv8bPoMBzW0vOcMO22iO0s+nVtVhdts=", version = "v1.8.5", ) go_repository( name = "com_google_cloud_go_area120", importpath = "cloud.google.com/go/area120", sum = "h1:vTs08KPLN/iMzTbxpu5ciL06KcsrVPMjz4IwcQyZ4uY=", version = "v0.8.5", ) go_repository( name = "com_google_cloud_go_artifactregistry", importpath = "cloud.google.com/go/artifactregistry", sum = "h1:W9sVlyb1VRcUf83w7aM3yMsnp4HS4PoyGqYQNG0O5lI=", version = "v1.14.7", ) go_repository( name = "com_google_cloud_go_asset", importpath = "cloud.google.com/go/asset", sum = "h1:xgFnBP3luSbUcC9RWJvb3Zkt+y/wW6PKwPHr3ssnIP8=", version = "v1.17.2", ) go_repository( name = "com_google_cloud_go_assuredworkloads", importpath = "cloud.google.com/go/assuredworkloads", sum = "h1:gCrN3IyvqY3cP0wh2h43d99CgH3G+WYs9CeuFVKChR8=", version = "v1.11.5", ) go_repository( name = "com_google_cloud_go_automl", importpath = "cloud.google.com/go/automl", sum = "h1:ijiJy9sYWh75WrqImXsfWc1e3HR3iO+ef9fvW03Ig/4=", version = "v1.13.5", ) go_repository( name = "com_google_cloud_go_baremetalsolution", importpath = "cloud.google.com/go/baremetalsolution", sum = "h1:LFydisRmS7hQk9P/YhekwuZGqb45TW4QavcrMToWo5A=", version = "v1.2.4", ) go_repository( name = "com_google_cloud_go_batch", importpath = "cloud.google.com/go/batch", sum = "h1:2HK4JerwVaIcCh/lJiHwh6+uswPthiMMWhiSWLELayk=", version = "v1.8.0", ) go_repository( name = "com_google_cloud_go_beyondcorp", importpath = "cloud.google.com/go/beyondcorp", sum = "h1:qs0J0O9Ol2h1yA0AU+r7l3hOCPzs2MjE1d6d/kaHIKo=", version = "v1.0.4", ) go_repository( name = "com_google_cloud_go_bigquery", importpath = "cloud.google.com/go/bigquery", sum = "h1:CpT+/njKuKT3CEmswm6IbhNu9u35zt5dO4yPDLW+nG4=", version = "v1.59.1", ) go_repository( name = "com_google_cloud_go_billing", importpath = "cloud.google.com/go/billing", sum = "h1:oWUEQvuC4JvtnqLZ35zgzdbuHt4Itbftvzbe6aEyFdE=", version = "v1.18.2", ) go_repository( name = "com_google_cloud_go_binaryauthorization", importpath = "cloud.google.com/go/binaryauthorization", sum = "h1:1jcyh2uIUwSZkJ/JmL8kd5SUkL/Krbv8zmYLEbAz6kY=", version = "v1.8.1", ) go_repository( name = "com_google_cloud_go_certificatemanager", importpath = "cloud.google.com/go/certificatemanager", sum = "h1:UMBr/twXvH3jcT5J5/YjRxf2tvwTYIfrpemTebe0txc=", version = "v1.7.5", ) go_repository( name = "com_google_cloud_go_channel", importpath = "cloud.google.com/go/channel", sum = "h1:/omiBnyFjm4S1ETHoOmJbL7LH7Ljcei4rYG6Sj3hc80=", version = "v1.17.5", ) go_repository( name = "com_google_cloud_go_cloudbuild", importpath = "cloud.google.com/go/cloudbuild", sum = "h1:ZB6oOmJo+MTov9n629fiCrO9YZPOg25FZvQ7gIHu5ng=", version = "v1.15.1", ) go_repository( name = "com_google_cloud_go_clouddms", importpath = "cloud.google.com/go/clouddms", sum = "h1:Sr0Zo5EAcPQiCBgHWICg3VGkcdS/LLP1d9SR7qQBM/s=", version = "v1.7.4", ) go_repository( name = "com_google_cloud_go_cloudtasks", importpath = "cloud.google.com/go/cloudtasks", sum = "h1:EUt1hIZ9bLv8Iz9yWaCrqgMnIU+Tdh0yXM1MMVGhjfE=", version = "v1.12.6", ) go_repository( name = "com_google_cloud_go_compute", importpath = "cloud.google.com/go/compute", sum = "h1:ZRpHJedLtTpKgr3RV1Fx23NuaAEN1Zfx9hw1u4aJdjU=", version = "v1.25.1", ) go_repository( name = "com_google_cloud_go_compute_metadata", importpath = "cloud.google.com/go/compute/metadata", sum = "h1:pDUj4QMoPejqq20dK0Pg2N4yG9zIkYGdBtwLoEkH9Zs=", version = "v0.9.0", ) go_repository( name = "com_google_cloud_go_contactcenterinsights", importpath = "cloud.google.com/go/contactcenterinsights", sum = "h1:6Vs/YnDG5STGjlWMEjN/xtmft7MrOTOnOZYUZtGTx0w=", version = "v1.13.0", ) go_repository( name = "com_google_cloud_go_container", importpath = "cloud.google.com/go/container", sum = "h1:MAaNH7VRNPWEhvqOypq2j+7ONJKrKzon4v9nS3nLZe0=", version = "v1.31.0", ) go_repository( name = "com_google_cloud_go_containeranalysis", importpath = "cloud.google.com/go/containeranalysis", sum = "h1:doJ0M1ljS4hS0D2UbHywlHGwB7sQLNrt9vFk9Zyi7vY=", version = "v0.11.4", ) go_repository( name = "com_google_cloud_go_datacatalog", importpath = "cloud.google.com/go/datacatalog", sum = "h1:A0vKYCQdxQuV4Pi0LL9p39Vwvg4jH5yYveMv50gU5Tw=", version = "v1.19.3", ) go_repository( name = "com_google_cloud_go_dataflow", importpath = "cloud.google.com/go/dataflow", sum = "h1:RYHtcPhmE664+F0Je46p+NvFbG8z//KCXp+uEqB4jZU=", version = "v0.9.5", ) go_repository( name = "com_google_cloud_go_dataform", importpath = "cloud.google.com/go/dataform", sum = "h1:5e4eqGrd0iDTCg4Q+VlAao5j2naKAA7xRurNtwmUknU=", version = "v0.9.2", ) go_repository( name = "com_google_cloud_go_datafusion", importpath = "cloud.google.com/go/datafusion", sum = "h1:HQ/BUOP8OIGJxuztpYvNvlb+/U+/Bfs9SO8tQbh61fk=", version = "v1.7.5", ) go_repository( name = "com_google_cloud_go_datalabeling", importpath = "cloud.google.com/go/datalabeling", sum = "h1:GpIFRdm0qIZNsxqURFJwHt0ZBJZ0nF/mUVEigR7PH/8=", version = "v0.8.5", ) go_repository( name = "com_google_cloud_go_dataplex", importpath = "cloud.google.com/go/dataplex", sum = "h1:fxIfdU8fxzR3clhOoNI7XFppvAmndxDu1AMH+qX9WKQ=", version = "v1.14.2", ) go_repository( name = "com_google_cloud_go_dataproc", importpath = "cloud.google.com/go/dataproc", sum = "h1:W47qHL3W4BPkAIbk4SWmIERwsWBaNnWm0P2sdx3YgGU=", version = "v1.12.0", ) go_repository( name = "com_google_cloud_go_dataproc_v2", importpath = "cloud.google.com/go/dataproc/v2", sum = "h1:/u81Fd+BvCLp+xjctI1DiWVJn6cn9/s3Akc8xPH02yk=", version = "v2.4.0", ) go_repository( name = "com_google_cloud_go_dataqna", importpath = "cloud.google.com/go/dataqna", sum = "h1:9ybXs3nr9BzxSGC04SsvtuXaHY0qmJSLIpIAbZo9GqQ=", version = "v0.8.5", ) go_repository( name = "com_google_cloud_go_datastore", importpath = "cloud.google.com/go/datastore", sum = "h1:0P9WcsQeTWjuD1H14JIY7XQscIPQ4Laje8ti96IC5vg=", version = "v1.15.0", ) go_repository( name = "com_google_cloud_go_datastream", importpath = "cloud.google.com/go/datastream", sum = "h1:o1QDKMo/hk0FN7vhoUQURREuA0rgKmnYapB+1M+7Qz4=", version = "v1.10.4", ) go_repository( name = "com_google_cloud_go_deploy", importpath = "cloud.google.com/go/deploy", sum = "h1:m27Ojwj03gvpJqCbodLYiVmE9x4/LrHGGMjzc0LBfM4=", version = "v1.17.1", ) go_repository( name = "com_google_cloud_go_dialogflow", importpath = "cloud.google.com/go/dialogflow", sum = "h1:KqG0oxGE71qo0lRVyAoeBozefCvsMfcDzDjoLYSY0F4=", version = "v1.49.0", ) go_repository( name = "com_google_cloud_go_dlp", importpath = "cloud.google.com/go/dlp", sum = "h1:lTipOuJaSjlYnnotPMbEhKURLC6GzCMDDzVbJAEbmYM=", version = "v1.11.2", ) go_repository( name = "com_google_cloud_go_documentai", importpath = "cloud.google.com/go/documentai", sum = "h1:lI62GMEEPO6vXJI9hj+G9WjOvnR0hEjvjokrnex4cxA=", version = "v1.25.0", ) go_repository( name = "com_google_cloud_go_domains", importpath = "cloud.google.com/go/domains", sum = "h1:Mml/R6s3vQQvFPpi/9oX3O5dRirgjyJ8cksK8N19Y7g=", version = "v0.9.5", ) go_repository( name = "com_google_cloud_go_edgecontainer", importpath = "cloud.google.com/go/edgecontainer", sum = "h1:tBY32km78ScpK2aOP84JoW/+wtpx5WluyPUSEE3270U=", version = "v1.1.5", ) go_repository( name = "com_google_cloud_go_errorreporting", importpath = "cloud.google.com/go/errorreporting", sum = "h1:kj1XEWMu8P0qlLhm3FwcaFsUvXChV/OraZwA70trRR0=", version = "v0.3.0", ) go_repository( name = "com_google_cloud_go_essentialcontacts", importpath = "cloud.google.com/go/essentialcontacts", sum = "h1:13eHn5qBnsawxI7mIrv4jRIEmQ1xg0Ztqw5ZGqtUNfA=", version = "v1.6.6", ) go_repository( name = "com_google_cloud_go_eventarc", importpath = "cloud.google.com/go/eventarc", sum = "h1:ORkd6/UV5FIdA8KZQDLNZYKS7BBOrj0p01DXPmT4tE4=", version = "v1.13.4", ) go_repository( name = "com_google_cloud_go_filestore", importpath = "cloud.google.com/go/filestore", sum = "h1:X5G4y/vrUo1B8Nsz93qSWTMAcM8LXbGUldq33OdcdCw=", version = "v1.8.1", ) go_repository( name = "com_google_cloud_go_firestore", importpath = "cloud.google.com/go/firestore", sum = "h1:8aLcKnMPoldYU3YHgu4t2exrKhLQkqaXAGqT0ljrFVw=", version = "v1.14.0", ) go_repository( name = "com_google_cloud_go_functions", importpath = "cloud.google.com/go/functions", sum = "h1:IWVylmK5F6hJ3R5zaRW7jI5PrWhCvtBVU4axQLmXSo4=", version = "v1.16.0", ) go_repository( name = "com_google_cloud_go_gaming", importpath = "cloud.google.com/go/gaming", sum = "h1:5qZmZEWzMf8GEFgm9NeC3bjFRpt7x4S6U7oLbxaf7N8=", version = "v1.10.1", ) go_repository( name = "com_google_cloud_go_gkebackup", importpath = "cloud.google.com/go/gkebackup", sum = "h1:iuE8KNtTsPOc79qeWoNS8zOWoXPD9SAdOmwgxtlCmh8=", version = "v1.3.5", ) go_repository( name = "com_google_cloud_go_gkeconnect", importpath = "cloud.google.com/go/gkeconnect", sum = "h1:17d+ZSSXKqG/RwZCq3oFMIWLPI8Zw3b8+a9/BEVlwH0=", version = "v0.8.5", ) go_repository( name = "com_google_cloud_go_gkehub", importpath = "cloud.google.com/go/gkehub", sum = "h1:RboLNFzf9wEMSo7DrKVBlf+YhK/A/jrLN454L5Tz99Q=", version = "v0.14.5", ) go_repository( name = "com_google_cloud_go_gkemulticloud", importpath = "cloud.google.com/go/gkemulticloud", sum = "h1:rsSZAGLhyjyE/bE2ToT5fqo1qSW7S+Ubsc9jFOcbhSI=", version = "v1.1.1", ) go_repository( name = "com_google_cloud_go_gsuiteaddons", importpath = "cloud.google.com/go/gsuiteaddons", sum = "h1:CZEbaBwmbYdhFw21Fwbo+C35HMe36fTE0FBSR4KSfWg=", version = "v1.6.5", ) go_repository( name = "com_google_cloud_go_iam", importpath = "cloud.google.com/go/iam", sum = "h1:bEa06k05IO4f4uJonbB5iAgKTPpABy1ayxaIZV/GHVc=", version = "v1.1.6", ) go_repository( name = "com_google_cloud_go_iap", importpath = "cloud.google.com/go/iap", sum = "h1:94zirc2r4t6KzhAMW0R6Dme005eTP6yf7g6vN4IhRrA=", version = "v1.9.4", ) go_repository( name = "com_google_cloud_go_ids", importpath = "cloud.google.com/go/ids", sum = "h1:xd4U7pgl3GHV+MABnv1BF4/Vy/zBF7CYC8XngkOLzag=", version = "v1.4.5", ) go_repository( name = "com_google_cloud_go_iot", importpath = "cloud.google.com/go/iot", sum = "h1:munTeBlbqI33iuTYgXy7S8lW2TCgi5l1hA4roSIY+EE=", version = "v1.7.5", ) go_repository( name = "com_google_cloud_go_kms", importpath = "cloud.google.com/go/kms", sum = "h1:7caV9K3yIxvlQPAcaFffhlT7d1qpxjB1wHBtjWa13SM=", version = "v1.15.7", ) go_repository( name = "com_google_cloud_go_language", importpath = "cloud.google.com/go/language", sum = "h1:iaJZg6K4j/2PvZZVcjeO/btcWWIllVRBhuTFjGO4LXs=", version = "v1.12.3", ) go_repository( name = "com_google_cloud_go_lifesciences", importpath = "cloud.google.com/go/lifesciences", sum = "h1:gXvN70m2p+4zgJFzaz6gMKaxTuF9WJ0USYoMLWAOm8g=", version = "v0.9.5", ) go_repository( name = "com_google_cloud_go_logging", importpath = "cloud.google.com/go/logging", sum = "h1:iEIOXFO9EmSiTjDmfpbRjOxECO7R8C7b8IXUGOj7xZw=", version = "v1.9.0", ) go_repository( name = "com_google_cloud_go_longrunning", importpath = "cloud.google.com/go/longrunning", sum = "h1:GOE6pZFdSrTb4KAiKnXsJBtlE6mEyaW44oKyMILWnOg=", version = "v0.5.5", ) go_repository( name = "com_google_cloud_go_managedidentities", importpath = "cloud.google.com/go/managedidentities", sum = "h1:+bpih1piZVLxla/XBqeSUzJBp8gv9plGHIMAI7DLpDM=", version = "v1.6.5", ) go_repository( name = "com_google_cloud_go_maps", importpath = "cloud.google.com/go/maps", sum = "h1:EVCZAiDvog9So46460BGbCasPhi613exoaQbpilMVlk=", version = "v1.6.4", ) go_repository( name = "com_google_cloud_go_mediatranslation", importpath = "cloud.google.com/go/mediatranslation", sum = "h1:c76KdIXljQHSCb/Cy47S8H4s05A4zbK3pAFGzwcczZo=", version = "v0.8.5", ) go_repository( name = "com_google_cloud_go_memcache", importpath = "cloud.google.com/go/memcache", sum = "h1:yeDv5qxRedFosvpMSEswrqUsJM5OdWvssPHFliNFTc4=", version = "v1.10.5", ) go_repository( name = "com_google_cloud_go_metastore", importpath = "cloud.google.com/go/metastore", sum = "h1:dR7vqWXlK6IYR8Wbu9mdFfwlVjodIBhd1JRrpZftTEg=", version = "v1.13.4", ) go_repository( name = "com_google_cloud_go_monitoring", importpath = "cloud.google.com/go/monitoring", sum = "h1:NfkDLQDG2UR3WYZVQE8kwSbUIEyIqJUPl+aOQdFH1T4=", version = "v1.18.0", ) go_repository( name = "com_google_cloud_go_networkconnectivity", importpath = "cloud.google.com/go/networkconnectivity", sum = "h1:GBfXFhLyPspnaBE3nI/BRjdhW8vcbpT9QjE/4kDCDdc=", version = "v1.14.4", ) go_repository( name = "com_google_cloud_go_networkmanagement", importpath = "cloud.google.com/go/networkmanagement", sum = "h1:aLV5GcosBNmd6M8+a0ekB0XlLRexv4fvnJJrYnqeBcg=", version = "v1.9.4", ) go_repository( name = "com_google_cloud_go_networksecurity", importpath = "cloud.google.com/go/networksecurity", sum = "h1:+caSxBTj0E8OYVh/5wElFdjEMO1S/rZtE1152Cepchc=", version = "v0.9.5", ) go_repository( name = "com_google_cloud_go_notebooks", importpath = "cloud.google.com/go/notebooks", sum = "h1:FH48boYmrWVQ6k0Mx/WrnNafXncT5iSYxA8CNyWTgy0=", version = "v1.11.3", ) go_repository( name = "com_google_cloud_go_optimization", importpath = "cloud.google.com/go/optimization", sum = "h1:63NZaWyN+5rZEKHPX4ACpw3BjgyeuY8+rCehiCMaGPY=", version = "v1.6.3", ) go_repository( name = "com_google_cloud_go_orchestration", importpath = "cloud.google.com/go/orchestration", sum = "h1:YHgWMlrPttIVGItgGfuvO2KM7x+y9ivN/Yk92pMm1a4=", version = "v1.8.5", ) go_repository( name = "com_google_cloud_go_orgpolicy", importpath = "cloud.google.com/go/orgpolicy", sum = "h1:2JbXigqBJVp8Dx5dONUttFqewu4fP0p3pgOdIZAhpYU=", version = "v1.12.1", ) go_repository( name = "com_google_cloud_go_osconfig", importpath = "cloud.google.com/go/osconfig", sum = "h1:Mo5jGAxOMKH/PmDY7fgY19yFcVbvwREb5D5zMPQjFfo=", version = "v1.12.5", ) go_repository( name = "com_google_cloud_go_oslogin", importpath = "cloud.google.com/go/oslogin", sum = "h1:1K4nOT5VEZNt7XkhaTXupBYos5HjzvJMfhvyD2wWdFs=", version = "v1.13.1", ) go_repository( name = "com_google_cloud_go_phishingprotection", importpath = "cloud.google.com/go/phishingprotection", sum = "h1:DH3WFLzEoJdW/6xgsmoDqOwT1xddFi7gKu0QGZQhpGU=", version = "v0.8.5", ) go_repository( name = "com_google_cloud_go_policytroubleshooter", importpath = "cloud.google.com/go/policytroubleshooter", sum = "h1:c0WOzC6hz964QWNBkyKfna8A2jOIx1zzZa43Gx/P09o=", version = "v1.10.3", ) go_repository( name = "com_google_cloud_go_privatecatalog", importpath = "cloud.google.com/go/privatecatalog", sum = "h1:UZ0assTnATXSggoxUIh61RjTQ4P9zCMk/kEMbn0nMYA=", version = "v0.9.5", ) go_repository( name = "com_google_cloud_go_pubsub", importpath = "cloud.google.com/go/pubsub", sum = "h1:dfEPuGCHGbWUhaMCTHUFjfroILEkx55iUmKBZTP5f+Y=", version = "v1.36.1", ) go_repository( name = "com_google_cloud_go_pubsublite", importpath = "cloud.google.com/go/pubsublite", sum = "h1:pX+idpWMIH30/K7c0epN6V703xpIcMXWRjKJsz0tYGY=", version = "v1.8.1", ) go_repository( name = "com_google_cloud_go_recaptchaenterprise_v2", importpath = "cloud.google.com/go/recaptchaenterprise/v2", sum = "h1:U3Wfq12X9cVMuTpsWDSURnXF0Z9hSPTHj+xsnXDRLsw=", version = "v2.9.2", ) go_repository( name = "com_google_cloud_go_recommendationengine", importpath = "cloud.google.com/go/recommendationengine", sum = "h1:ineqLswaCSBY0csYv5/wuXJMBlxATK6Xc5jJkpiTEdM=", version = "v0.8.5", ) go_repository( name = "com_google_cloud_go_recommender", importpath = "cloud.google.com/go/recommender", sum = "h1:LVLYS3r3u0MSCxQSDUtLSkporEGi9OAE6hGvayrZNPs=", version = "v1.12.1", ) go_repository( name = "com_google_cloud_go_redis", importpath = "cloud.google.com/go/redis", sum = "h1:QF0maEdVv0Fj/2roU8sX3NpiDBzP9ICYTO+5F32gQNo=", version = "v1.14.2", ) go_repository( name = "com_google_cloud_go_resourcemanager", importpath = "cloud.google.com/go/resourcemanager", sum = "h1:AZWr1vWVDKGwfLsVhcN+vcwOz3xqqYxtmMa0aABCMms=", version = "v1.9.5", ) go_repository( name = "com_google_cloud_go_resourcesettings", importpath = "cloud.google.com/go/resourcesettings", sum = "h1:BTr5MVykJwClASci/7Og4Qfx70aQ4n3epsNLj94ZYgw=", version = "v1.6.5", ) go_repository( name = "com_google_cloud_go_retail", importpath = "cloud.google.com/go/retail", sum = "h1:Fn1GuAua1c6crCGqfJ1qMxG1Xh10Tg/x5EUODEHMqkw=", version = "v1.16.0", ) go_repository( name = "com_google_cloud_go_run", importpath = "cloud.google.com/go/run", sum = "h1:m9WDA7DzTpczhZggwYlZcBWgCRb+kgSIisWn1sbw2rQ=", version = "v1.3.4", ) go_repository( name = "com_google_cloud_go_scheduler", importpath = "cloud.google.com/go/scheduler", sum = "h1:5U8iXLoQ03qOB+ZXlAecU7fiE33+u3QiM9nh4cd0eTE=", version = "v1.10.6", ) go_repository( name = "com_google_cloud_go_secretmanager", importpath = "cloud.google.com/go/secretmanager", sum = "h1:82fpF5vBBvu9XW4qj0FU2C6qVMtj1RM/XHwKXUEAfYY=", version = "v1.11.5", ) go_repository( name = "com_google_cloud_go_security", importpath = "cloud.google.com/go/security", sum = "h1:wTKJQ10j8EYgvE8Y+KhovxDRVDk2iv/OsxZ6GrLP3kE=", version = "v1.15.5", ) go_repository( name = "com_google_cloud_go_securitycenter", importpath = "cloud.google.com/go/securitycenter", sum = "h1:/5jjkZ+uGe8hZ7pvd7pO30VW/a+pT2MrrdgOqjyucKQ=", version = "v1.24.4", ) go_repository( name = "com_google_cloud_go_servicecontrol", importpath = "cloud.google.com/go/servicecontrol", sum = "h1:d0uV7Qegtfaa7Z2ClDzr9HJmnbJW7jn0WhZ7wOX6hLE=", version = "v1.11.1", ) go_repository( name = "com_google_cloud_go_servicedirectory", importpath = "cloud.google.com/go/servicedirectory", sum = "h1:da7HFI1229kyzIyuVEzHXip0cw0d+E0s8mjQby0WN+k=", version = "v1.11.4", ) go_repository( name = "com_google_cloud_go_servicemanagement", importpath = "cloud.google.com/go/servicemanagement", sum = "h1:fopAQI/IAzlxnVeiKn/8WiV6zKndjFkvi+gzu+NjywY=", version = "v1.8.0", ) go_repository( name = "com_google_cloud_go_serviceusage", importpath = "cloud.google.com/go/serviceusage", sum = "h1:rXyq+0+RSIm3HFypctp7WoXxIA563rn206CfMWdqXX4=", version = "v1.6.0", ) go_repository( name = "com_google_cloud_go_shell", importpath = "cloud.google.com/go/shell", sum = "h1:3Fq2hzO0ZSyaqBboJrFkwwf/qMufDtqwwA6ep8EZxEI=", version = "v1.7.5", ) go_repository( name = "com_google_cloud_go_spanner", importpath = "cloud.google.com/go/spanner", sum = "h1:o/Cv7/zZ1WgRXVCd5g3Nc23ZI39p/1pWFqFwvg6Wcu8=", version = "v1.56.0", ) go_repository( name = "com_google_cloud_go_speech", importpath = "cloud.google.com/go/speech", sum = "h1:nuFc+Kj5B8de75nN4FdPyUbI2SiBoHZG6BLurXL56Q0=", version = "v1.21.1", ) go_repository( name = "com_google_cloud_go_storage", importpath = "cloud.google.com/go/storage", sum = "h1:STgFzyU5/8miMl0//zKh2aQeTyeaUH3WN9bSUiJ09bA=", version = "v1.10.0", ) go_repository( name = "com_google_cloud_go_storagetransfer", importpath = "cloud.google.com/go/storagetransfer", sum = "h1:dy4fL3wO0VABvzM05ycMUPFHxTPbJz9Em8ikAJVqSbI=", version = "v1.10.4", ) go_repository( name = "com_google_cloud_go_talent", importpath = "cloud.google.com/go/talent", sum = "h1:JssV0CE3FNujuSWn7SkosOzg7qrMxVnt6txOfGcMSa4=", version = "v1.6.6", ) go_repository( name = "com_google_cloud_go_texttospeech", importpath = "cloud.google.com/go/texttospeech", sum = "h1:dxY2Q5mHCbrGa3oPR2O3PCicdnvKa1JmwGQK36EFLOw=", version = "v1.7.5", ) go_repository( name = "com_google_cloud_go_tpu", importpath = "cloud.google.com/go/tpu", sum = "h1:C8YyYda8WtNdBoCgFwwBzZd+S6+EScHOxM/z1h0NNp8=", version = "v1.6.5", ) go_repository( name = "com_google_cloud_go_trace", importpath = "cloud.google.com/go/trace", sum = "h1:0pr4lIKJ5XZFYD9GtxXEWr0KkVeigc3wlGpZco0X1oA=", version = "v1.10.5", ) go_repository( name = "com_google_cloud_go_translate", importpath = "cloud.google.com/go/translate", sum = "h1:upovZ0wRMdzZvXnu+RPam41B0mRJ+coRXFP2cYFJ7ew=", version = "v1.10.1", ) go_repository( name = "com_google_cloud_go_video", importpath = "cloud.google.com/go/video", sum = "h1:TXwotxkShP1OqgKsbd+b8N5hrIHavSyLGvYnLGCZ7xc=", version = "v1.20.4", ) go_repository( name = "com_google_cloud_go_videointelligence", importpath = "cloud.google.com/go/videointelligence", sum = "h1:mYaWH8uhUCXLJCN3gdXswKzRa2+lK0zN6/KsIubm6pE=", version = "v1.11.5", ) go_repository( name = "com_google_cloud_go_vision_v2", importpath = "cloud.google.com/go/vision/v2", sum = "h1:W52z1b6LdGI66MVhE70g/NFty9zCYYcjdKuycqmlhtg=", version = "v2.8.0", ) go_repository( name = "com_google_cloud_go_vmmigration", importpath = "cloud.google.com/go/vmmigration", sum = "h1:5v9RT2vWyuw3pK2ox0HQpkoftO7Q7/8591dTxxQc79g=", version = "v1.7.5", ) go_repository( name = "com_google_cloud_go_vmwareengine", importpath = "cloud.google.com/go/vmwareengine", sum = "h1:EGdDi9QbqThfZq3ILcDK5g+m9jTevc34AY5tACx5v7k=", version = "v1.1.1", ) go_repository( name = "com_google_cloud_go_vpcaccess", importpath = "cloud.google.com/go/vpcaccess", sum = "h1:XyL6hTLtEM/eE4F1GEge8xUN9ZCkiVWn44K/YA7z1rQ=", version = "v1.7.5", ) go_repository( name = "com_google_cloud_go_webrisk", importpath = "cloud.google.com/go/webrisk", sum = "h1:251MvGuC8wisNN7+jqu9DDDZAi38KiMXxOpA/EWy4dE=", version = "v1.9.5", ) go_repository( name = "com_google_cloud_go_websecurityscanner", importpath = "cloud.google.com/go/websecurityscanner", sum = "h1:YqWZrZYabG88TZt7364XWRJGhxmxhony2ZUyZEYMF2k=", version = "v1.6.5", ) go_repository( name = "com_google_cloud_go_workflows", importpath = "cloud.google.com/go/workflows", sum = "h1:uHNmUiatTbPQ4H1pabwfzpfEYD4BBnqDHqMm2IesOh4=", version = "v1.12.4", ) go_repository( name = "com_shuralyov_dmitri_gpu_mtl", importpath = "dmitri.shuralyov.com/gpu/mtl", sum = "h1:VpgP7xuJadIUuKccphEpTJnWhS2jkQyMt6Y7pJCD7fY=", version = "v0.0.0-20190408044501-666a987793e9", ) go_repository( name = "dev_cel_expr", importpath = "cel.dev/expr", sum = "h1:1KrZg61W6TWSxuNZ37Xy49ps13NUovb66QLprthtwi4=", version = "v0.25.1", ) go_repository( name = "in_gopkg_alecthomas_kingpin_v2", importpath = "gopkg.in/alecthomas/kingpin.v2", sum = "h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=", version = "v2.2.6", ) go_repository( name = "in_gopkg_check_v1", importpath = "gopkg.in/check.v1", sum = "h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=", version = "v1.0.0-20201130134442-10cb98267c6c", ) go_repository( name = "in_gopkg_errgo_v2", importpath = "gopkg.in/errgo.v2", sum = "h1:0vLT13EuvQ0hNvakwLuFZ/jYrLp5F3kcWHXdRggjCE8=", version = "v2.1.0", ) go_repository( name = "in_gopkg_ini_v1", importpath = "gopkg.in/ini.v1", sum = "h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=", version = "v1.51.0", ) go_repository( name = "in_gopkg_resty_v1", importpath = "gopkg.in/resty.v1", sum = "h1:CuXP0Pjfw9rOuY6EP+UvtNvt5DSqHpIxILZKT/quCZI=", version = "v1.12.0", ) go_repository( name = "in_gopkg_yaml_v2", importpath = "gopkg.in/yaml.v2", sum = "h1:fvjTMHxHEw/mxHbtzPi3JCcKXQRAnQTBRo6YCJSVHKI=", version = "v2.2.3", ) go_repository( name = "in_gopkg_yaml_v3", importpath = "gopkg.in/yaml.v3", sum = "h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=", version = "v3.0.1", ) go_repository( name = "in_yaml_go_yaml_v3", importpath = "go.yaml.in/yaml/v3", sum = "h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=", version = "v3.0.4", ) go_repository( name = "io_etcd_go_bbolt", importpath = "go.etcd.io/bbolt", sum = "h1:Z/90sZLPOeCy2PwprqkFa25PdkusRzaj9P8zm/KNyvk=", version = "v1.3.2", ) go_repository( name = "io_opencensus_go", importpath = "go.opencensus.io", sum = "h1:LYy1Hy3MJdrCdMwwzxA/dRok4ejH+RwNGbuoD9fCjto=", version = "v0.22.4", ) go_repository( name = "io_opentelemetry_go_auto_sdk", importpath = "go.opentelemetry.io/auto/sdk", sum = "h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=", version = "v1.2.1", ) go_repository( name = "io_opentelemetry_go_contrib_detectors_gcp", importpath = "go.opentelemetry.io/contrib/detectors/gcp", sum = "h1:kWRNZMsfBHZ+uHjiH4y7Etn2FK26LAGkNFw7RHv1DhE=", version = "v1.39.0", ) go_repository( name = "io_opentelemetry_go_otel", importpath = "go.opentelemetry.io/otel", sum = "h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48=", version = "v1.39.0", ) go_repository( name = "io_opentelemetry_go_otel_metric", importpath = "go.opentelemetry.io/otel/metric", sum = "h1:d1UzonvEZriVfpNKEVmHXbdf909uGTOQjA0HF0Ls5Q0=", version = "v1.39.0", ) go_repository( name = "io_opentelemetry_go_otel_sdk", importpath = "go.opentelemetry.io/otel/sdk", sum = "h1:nMLYcjVsvdui1B/4FRkwjzoRVsMK8uL/cj0OyhKzt18=", version = "v1.39.0", ) go_repository( name = "io_opentelemetry_go_otel_sdk_metric", importpath = "go.opentelemetry.io/otel/sdk/metric", sum = "h1:cXMVVFVgsIf2YL6QkRF4Urbr/aMInf+2WKg+sEJTtB8=", version = "v1.39.0", ) go_repository( name = "io_opentelemetry_go_otel_trace", importpath = "go.opentelemetry.io/otel/trace", sum = "h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6/qCJI=", version = "v1.39.0", ) go_repository( name = "io_opentelemetry_go_proto_otlp", importpath = "go.opentelemetry.io/proto/otlp", sum = "h1:rwOQPCuKAKmwGKq2aVNnYIibI6wnV7EvzgfTCzcdGg8=", version = "v0.7.0", ) go_repository( name = "io_rsc_binaryregexp", importpath = "rsc.io/binaryregexp", sum = "h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE=", version = "v0.2.0", ) go_repository( name = "io_rsc_quote_v3", importpath = "rsc.io/quote/v3", sum = "h1:9JKUTTIUgS6kzR9mK1YuGKv6Nl+DijDNIc0ghT58FaY=", version = "v3.1.0", ) go_repository( name = "io_rsc_sampler", importpath = "rsc.io/sampler", sum = "h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=", version = "v1.3.0", ) go_repository( name = "org_golang_google_api", importpath = "google.golang.org/api", sum = "h1:yfrXXP61wVuLb0vBcG6qaOoIoqYEzOQS8jum51jkv2w=", version = "v0.30.0", ) go_repository( name = "org_golang_google_appengine", importpath = "google.golang.org/appengine", sum = "h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=", version = "v1.6.8", ) go_repository( name = "org_golang_google_genproto", importpath = "google.golang.org/genproto", sum = "h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY=", version = "v0.0.0-20240227224415-6ceb2ff114de", ) go_repository( name = "org_golang_google_genproto_googleapis_api", importpath = "google.golang.org/genproto/googleapis/api", sum = "h1:41r6JMbpzBMen0R/4TZeeAmGXSJC7DftGINUodzTkPI=", version = "v0.0.0-20260319201613-d00831a3d3e7", ) go_repository( name = "org_golang_google_genproto_googleapis_rpc", importpath = "google.golang.org/genproto/googleapis/rpc", sum = "h1:ndE4FoJqsIceKP2oYSnUZqhTdYufCYYkqwtFzfrhI7w=", version = "v0.0.0-20260319201613-d00831a3d3e7", ) go_repository( name = "org_golang_google_grpc", importpath = "google.golang.org/grpc", sum = "h1:sybAEdRIEtvcD68Gx7dmnwjZKlyfuc61Dyo9pGXXkKE=", version = "v1.79.3", ) go_repository( name = "org_golang_google_grpc_cmd_protoc_gen_go_grpc", importpath = "google.golang.org/grpc/cmd/protoc-gen-go-grpc", sum = "h1:lQ+dE99pFsb8osbJB3oRfE5eW4Hx6a/lZQr8Jh+eoT4=", version = "v1.0.0", ) go_repository( name = "org_golang_google_protobuf", importpath = "google.golang.org/protobuf", sum = "h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=", version = "v1.36.11", ) go_repository( name = "org_golang_x_crypto", importpath = "golang.org/x/crypto", sum = "h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=", version = "v0.46.0", ) go_repository( name = "org_golang_x_exp", importpath = "golang.org/x/exp", sum = "h1:c2HOrn5iMezYjSlGPncknSEr/8x5LELb/ilJbXi9DEA=", version = "v0.0.0-20190121172915-509febef88a4", ) go_repository( name = "org_golang_x_image", importpath = "golang.org/x/image", sum = "h1:+qEpEAPhDZ1o0x3tHzZTQDArnOixOzGD9HUJfcg0mb4=", version = "v0.0.0-20190802002840-cff245a6509b", ) go_repository( name = "org_golang_x_lint", importpath = "golang.org/x/lint", sum = "h1:XQyxROzUlZH+WIQwySDgnISgOivlhjIEwaQaJEJrrN0=", version = "v0.0.0-20190313153728-d0100b6bd8b3", ) go_repository( name = "org_golang_x_mobile", importpath = "golang.org/x/mobile", sum = "h1:4+4C/Iv2U4fMZBiMCc98MG1In4gJY5YRhtpDNeDeHWs=", version = "v0.0.0-20190719004257-d2bd2a29d028", ) go_repository( name = "org_golang_x_mod", importpath = "golang.org/x/mod", sum = "h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=", version = "v0.33.0", ) go_repository( name = "org_golang_x_net", importpath = "golang.org/x/net", sum = "h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=", version = "v0.48.0", ) go_repository( name = "org_golang_x_oauth2", importpath = "golang.org/x/oauth2", sum = "h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs=", version = "v0.36.0", ) go_repository( name = "org_golang_x_sync", importpath = "golang.org/x/sync", sum = "h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=", version = "v0.20.0", ) go_repository( name = "org_golang_x_sys", importpath = "golang.org/x/sys", sum = "h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=", version = "v0.39.0", ) go_repository( name = "org_golang_x_term", importpath = "golang.org/x/term", sum = "h1:PQ5pkm/rLO6HnxFR7N2lJHOZX6Kez5Y1gDSJla6jo7Q=", version = "v0.38.0", ) go_repository( name = "org_golang_x_text", importpath = "golang.org/x/text", sum = "h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8=", version = "v0.35.0", ) go_repository( name = "org_golang_x_time", importpath = "golang.org/x/time", sum = "h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=", version = "v0.0.0-20191024005414-555d28b269f0", ) go_repository( name = "org_golang_x_tools", importpath = "golang.org/x/tools", sum = "h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k=", version = "v0.42.0", ) go_repository( name = "org_golang_x_xerrors", importpath = "golang.org/x/xerrors", sum = "h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=", version = "v0.0.0-20191204190536-9bdfabe68543", ) go_repository( name = "org_gonum_v1_gonum", importpath = "gonum.org/v1/gonum", sum = "h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=", version = "v0.16.0", ) go_repository( name = "org_uber_go_atomic", importpath = "go.uber.org/atomic", sum = "h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=", version = "v1.7.0", ) go_repository( name = "org_uber_go_multierr", importpath = "go.uber.org/multierr", sum = "h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=", version = "v1.6.0", ) go_repository( name = "org_uber_go_tools", importpath = "go.uber.org/tools", sum = "h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4=", version = "v0.0.0-20190618225709-2cfd321de3ee", ) go_repository( name = "org_uber_go_zap", importpath = "go.uber.org/zap", sum = "h1:uFRZXykJGK9lLY4HtgSw44DnIcAM+kRBP7x5m+NpAOM=", version = "v1.16.0", ) ================================================ FILE: runtime/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") package(default_visibility = ["//visibility:public"]) go_library( name = "runtime", srcs = [ "context.go", "convert.go", "doc.go", "errors.go", "fieldmask.go", "handler.go", "marshal_httpbodyproto.go", "marshal_json.go", "marshal_jsonpb.go", "marshal_proto.go", "marshaler.go", "marshaler_registry.go", "mux.go", "pattern.go", "proto2_convert.go", "query.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/runtime", deps = [ "//internal/httprule", "//utilities", "@org_golang_google_genproto_googleapis_api//httpbody", "@org_golang_google_grpc//:grpc", "@org_golang_google_grpc//codes", "@org_golang_google_grpc//grpclog", "@org_golang_google_grpc//health/grpc_health_v1", "@org_golang_google_grpc//metadata", "@org_golang_google_grpc//status", "@org_golang_google_protobuf//encoding/protojson", "@org_golang_google_protobuf//proto", "@org_golang_google_protobuf//reflect/protoreflect", "@org_golang_google_protobuf//reflect/protoregistry", "@org_golang_google_protobuf//types/known/durationpb", "@org_golang_google_protobuf//types/known/fieldmaskpb", "@org_golang_google_protobuf//types/known/structpb", "@org_golang_google_protobuf//types/known/timestamppb", "@org_golang_google_protobuf//types/known/wrapperspb", ], ) go_test( name = "runtime_test", size = "small", srcs = [ "context_test.go", "convert_test.go", "errors_test.go", "fieldmask_test.go", "handler_test.go", "marshal_httpbodyproto_test.go", "marshal_json_test.go", "marshal_jsonpb_test.go", "marshal_proto_test.go", "marshaler_registry_test.go", "mux_internal_test.go", "mux_test.go", "pattern_test.go", "query_fuzz_test.go", "query_test.go", ], embed = [":runtime"], deps = [ "//runtime/internal/examplepb", "//utilities", "@com_github_google_go_cmp//cmp", "@com_github_google_go_cmp//cmp/cmpopts", "@org_golang_google_genproto_googleapis_api//httpbody", "@org_golang_google_genproto_googleapis_rpc//errdetails", "@org_golang_google_genproto_googleapis_rpc//status", "@org_golang_google_grpc//:grpc", "@org_golang_google_grpc//codes", "@org_golang_google_grpc//health/grpc_health_v1", "@org_golang_google_grpc//metadata", "@org_golang_google_grpc//status", "@org_golang_google_protobuf//encoding/protojson", "@org_golang_google_protobuf//proto", "@org_golang_google_protobuf//testing/protocmp", "@org_golang_google_protobuf//types/known/durationpb", "@org_golang_google_protobuf//types/known/emptypb", "@org_golang_google_protobuf//types/known/fieldmaskpb", "@org_golang_google_protobuf//types/known/structpb", "@org_golang_google_protobuf//types/known/timestamppb", "@org_golang_google_protobuf//types/known/wrapperspb", ], ) alias( name = "go_default_library", actual = ":runtime", visibility = ["//visibility:public"], ) ================================================ FILE: runtime/context.go ================================================ package runtime import ( "context" "encoding/base64" "fmt" "net" "net/http" "net/textproto" "strconv" "strings" "sync" "time" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) // MetadataHeaderPrefix is the http prefix that represents custom metadata // parameters to or from a gRPC call. const MetadataHeaderPrefix = "Grpc-Metadata-" // MetadataPrefix is prepended to permanent HTTP header keys (as specified // by the IANA) when added to the gRPC context. const MetadataPrefix = "grpcgateway-" // MetadataTrailerPrefix is prepended to gRPC metadata as it is converted to // HTTP headers in a response handled by grpc-gateway const MetadataTrailerPrefix = "Grpc-Trailer-" const metadataGrpcTimeout = "Grpc-Timeout" const metadataHeaderBinarySuffix = "-Bin" const xForwardedFor = "X-Forwarded-For" const xForwardedHost = "X-Forwarded-Host" // DefaultContextTimeout is used for gRPC call context.WithTimeout whenever a Grpc-Timeout inbound // header isn't present. If the value is 0 the sent `context` will not have a timeout. var DefaultContextTimeout = 0 * time.Second // malformedHTTPHeaders lists the headers that the gRPC server may reject outright as malformed. // See https://github.com/grpc/grpc-go/pull/4803#issuecomment-986093310 for more context. var malformedHTTPHeaders = map[string]struct{}{ "connection": {}, } type ( rpcMethodKey struct{} httpPathPatternKey struct{} httpPatternKey struct{} AnnotateContextOption func(ctx context.Context) context.Context ) func WithHTTPPathPattern(pattern string) AnnotateContextOption { return func(ctx context.Context) context.Context { return withHTTPPathPattern(ctx, pattern) } } func decodeBinHeader(v string) ([]byte, error) { if len(v)%4 == 0 { // Input was padded, or padding was not necessary. return base64.StdEncoding.DecodeString(v) } return base64.RawStdEncoding.DecodeString(v) } /* AnnotateContext adds context information such as metadata from the request. At a minimum, the RemoteAddr is included in the fashion of "X-Forwarded-For", except that the forwarded destination is not another HTTP service but rather a gRPC service. */ func AnnotateContext(ctx context.Context, mux *ServeMux, req *http.Request, rpcMethodName string, options ...AnnotateContextOption) (context.Context, error) { ctx, md, err := annotateContext(ctx, mux, req, rpcMethodName, options...) if err != nil { return nil, err } if md == nil { return ctx, nil } return metadata.NewOutgoingContext(ctx, md), nil } // AnnotateIncomingContext adds context information such as metadata from the request. // Attach metadata as incoming context. func AnnotateIncomingContext(ctx context.Context, mux *ServeMux, req *http.Request, rpcMethodName string, options ...AnnotateContextOption) (context.Context, error) { ctx, md, err := annotateContext(ctx, mux, req, rpcMethodName, options...) if err != nil { return nil, err } if md == nil { return ctx, nil } return metadata.NewIncomingContext(ctx, md), nil } func isValidGRPCMetadataKey(key string) bool { // Must be a valid gRPC "Header-Name" as defined here: // https://github.com/grpc/grpc/blob/4b05dc88b724214d0c725c8e7442cbc7a61b1374/doc/PROTOCOL-HTTP2.md // This means 0-9 a-z _ - . // Only lowercase letters are valid in the wire protocol, but the client library will normalize // uppercase ASCII to lowercase, so uppercase ASCII is also acceptable. bytes := []byte(key) // gRPC validates strings on the byte level, not Unicode. for _, ch := range bytes { validLowercaseLetter := ch >= 'a' && ch <= 'z' validUppercaseLetter := ch >= 'A' && ch <= 'Z' validDigit := ch >= '0' && ch <= '9' validOther := ch == '.' || ch == '-' || ch == '_' if !validLowercaseLetter && !validUppercaseLetter && !validDigit && !validOther { return false } } return true } func isValidGRPCMetadataTextValue(textValue string) bool { // Must be a valid gRPC "ASCII-Value" as defined here: // https://github.com/grpc/grpc/blob/4b05dc88b724214d0c725c8e7442cbc7a61b1374/doc/PROTOCOL-HTTP2.md // This means printable ASCII (including/plus spaces); 0x20 to 0x7E inclusive. bytes := []byte(textValue) // gRPC validates strings on the byte level, not Unicode. for _, ch := range bytes { if ch < 0x20 || ch > 0x7E { return false } } return true } func annotateContext(ctx context.Context, mux *ServeMux, req *http.Request, rpcMethodName string, options ...AnnotateContextOption) (context.Context, metadata.MD, error) { ctx = withRPCMethod(ctx, rpcMethodName) for _, o := range options { ctx = o(ctx) } timeout := DefaultContextTimeout if tm := req.Header.Get(metadataGrpcTimeout); tm != "" { var err error timeout, err = timeoutDecode(tm) if err != nil { return nil, nil, status.Errorf(codes.InvalidArgument, "invalid grpc-timeout: %s", tm) } } var pairs []string for key, vals := range req.Header { key = textproto.CanonicalMIMEHeaderKey(key) switch key { case xForwardedFor, xForwardedHost: // Handled separately below continue } for _, val := range vals { // For backwards-compatibility, pass through 'authorization' header with no prefix. if key == "Authorization" { pairs = append(pairs, "authorization", val) } if h, ok := mux.incomingHeaderMatcher(key); ok { if !isValidGRPCMetadataKey(h) { grpclog.Errorf("HTTP header name %q is not valid as gRPC metadata key; skipping", h) continue } // Handles "-bin" metadata in grpc, since grpc will do another base64 // encode before sending to server, we need to decode it first. if strings.HasSuffix(key, metadataHeaderBinarySuffix) { b, err := decodeBinHeader(val) if err != nil { return nil, nil, status.Errorf(codes.InvalidArgument, "invalid binary header %s: %s", key, err) } val = string(b) } else if !isValidGRPCMetadataTextValue(val) { grpclog.Errorf("Value of HTTP header %q contains non-ASCII value (not valid as gRPC metadata): skipping", h) continue } pairs = append(pairs, h, val) } } } if host := req.Header.Get(xForwardedHost); host != "" { pairs = append(pairs, strings.ToLower(xForwardedHost), host) } else if req.Host != "" { pairs = append(pairs, strings.ToLower(xForwardedHost), req.Host) } xff := req.Header.Values(xForwardedFor) if addr := req.RemoteAddr; addr != "" { if remoteIP, _, err := net.SplitHostPort(addr); err == nil { xff = append(xff, remoteIP) } } if len(xff) > 0 { pairs = append(pairs, strings.ToLower(xForwardedFor), strings.Join(xff, ", ")) } if timeout != 0 { ctx, _ = context.WithTimeout(ctx, timeout) } md := metadata.Pairs(pairs...) for _, mda := range mux.metadataAnnotators { md = metadata.Join(md, mda(ctx, req)) } if len(md) == 0 { return ctx, nil, nil } return ctx, md, nil } // ServerMetadata consists of metadata sent from gRPC server. type ServerMetadata struct { HeaderMD metadata.MD TrailerMD metadata.MD } type serverMetadataKey struct{} // NewServerMetadataContext creates a new context with ServerMetadata func NewServerMetadataContext(ctx context.Context, md ServerMetadata) context.Context { if ctx == nil { ctx = context.Background() } return context.WithValue(ctx, serverMetadataKey{}, md) } // ServerMetadataFromContext returns the ServerMetadata in ctx func ServerMetadataFromContext(ctx context.Context) (md ServerMetadata, ok bool) { if ctx == nil { return md, false } md, ok = ctx.Value(serverMetadataKey{}).(ServerMetadata) return } // ServerTransportStream implements grpc.ServerTransportStream. // It should only be used by the generated files to support grpc.SendHeader // outside of gRPC server use. type ServerTransportStream struct { mu sync.Mutex header metadata.MD trailer metadata.MD } // Method returns the method for the stream. func (s *ServerTransportStream) Method() string { return "" } // Header returns the header metadata of the stream. func (s *ServerTransportStream) Header() metadata.MD { s.mu.Lock() defer s.mu.Unlock() return s.header.Copy() } // SetHeader sets the header metadata. func (s *ServerTransportStream) SetHeader(md metadata.MD) error { if md.Len() == 0 { return nil } s.mu.Lock() s.header = metadata.Join(s.header, md) s.mu.Unlock() return nil } // SendHeader sets the header metadata. func (s *ServerTransportStream) SendHeader(md metadata.MD) error { return s.SetHeader(md) } // Trailer returns the cached trailer metadata. func (s *ServerTransportStream) Trailer() metadata.MD { s.mu.Lock() defer s.mu.Unlock() return s.trailer.Copy() } // SetTrailer sets the trailer metadata. func (s *ServerTransportStream) SetTrailer(md metadata.MD) error { if md.Len() == 0 { return nil } s.mu.Lock() s.trailer = metadata.Join(s.trailer, md) s.mu.Unlock() return nil } func timeoutDecode(s string) (time.Duration, error) { size := len(s) if size < 2 { return 0, fmt.Errorf("timeout string is too short: %q", s) } d, ok := timeoutUnitToDuration(s[size-1]) if !ok { return 0, fmt.Errorf("timeout unit is not recognized: %q", s) } t, err := strconv.ParseInt(s[:size-1], 10, 64) if err != nil { return 0, err } return d * time.Duration(t), nil } func timeoutUnitToDuration(u uint8) (d time.Duration, ok bool) { switch u { case 'H': return time.Hour, true case 'M': return time.Minute, true case 'S': return time.Second, true case 'm': return time.Millisecond, true case 'u': return time.Microsecond, true case 'n': return time.Nanosecond, true default: return } } // isPermanentHTTPHeader checks whether hdr belongs to the list of // permanent request headers maintained by IANA. // http://www.iana.org/assignments/message-headers/message-headers.xml func isPermanentHTTPHeader(hdr string) bool { switch hdr { case "Accept", "Accept-Charset", "Accept-Language", "Accept-Ranges", "Authorization", "Cache-Control", "Content-Type", "Cookie", "Date", "Expect", "From", "Host", "If-Match", "If-Modified-Since", "If-None-Match", "If-Schedule-Tag-Match", "If-Unmodified-Since", "Max-Forwards", "Origin", "Pragma", "Referer", "User-Agent", "Via", "Warning": return true } return false } // isMalformedHTTPHeader checks whether header belongs to the list of // "malformed headers" and would be rejected by the gRPC server. func isMalformedHTTPHeader(header string) bool { _, isMalformed := malformedHTTPHeaders[strings.ToLower(header)] return isMalformed } // RPCMethod returns the method string for the server context. The returned // string is in the format of "/package.service/method". func RPCMethod(ctx context.Context) (string, bool) { m := ctx.Value(rpcMethodKey{}) if m == nil { return "", false } ms, ok := m.(string) if !ok { return "", false } return ms, true } func withRPCMethod(ctx context.Context, rpcMethodName string) context.Context { return context.WithValue(ctx, rpcMethodKey{}, rpcMethodName) } // HTTPPathPattern returns the HTTP path pattern string relating to the HTTP handler, if one exists. // The format of the returned string is defined by the google.api.http path template type. func HTTPPathPattern(ctx context.Context) (string, bool) { m := ctx.Value(httpPathPatternKey{}) if m == nil { return "", false } ms, ok := m.(string) if !ok { return "", false } return ms, true } func withHTTPPathPattern(ctx context.Context, httpPathPattern string) context.Context { return context.WithValue(ctx, httpPathPatternKey{}, httpPathPattern) } // HTTPPattern returns the HTTP path pattern struct relating to the HTTP handler, if one exists. func HTTPPattern(ctx context.Context) (Pattern, bool) { v, ok := ctx.Value(httpPatternKey{}).(Pattern) return v, ok } func withHTTPPattern(ctx context.Context, httpPattern Pattern) context.Context { return context.WithValue(ctx, httpPatternKey{}, httpPattern) } ================================================ FILE: runtime/context_test.go ================================================ package runtime_test import ( "context" "encoding/base64" "net/http" "reflect" "testing" "time" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "google.golang.org/grpc/metadata" ) const ( emptyForwardMetaCount = 1 ) func TestAnnotateContext_WorksWithEmpty(t *testing.T) { ctx := context.Background() expectedRPCName := "/example.Example/Example" expectedHTTPPathPattern := "/v1" request, err := http.NewRequestWithContext(ctx, "GET", "http://www.example.com/v1", nil) if err != nil { t.Fatalf("http.NewRequestWithContext(ctx, %q, %q, nil) failed with %v; want success", "GET", "http://www.example.com", err) } request.Header.Add("Some-Irrelevant-Header", "some value") annotated, err := runtime.AnnotateContext(ctx, runtime.NewServeMux(), request, expectedRPCName, runtime.WithHTTPPathPattern(expectedHTTPPathPattern)) if err != nil { t.Errorf("runtime.AnnotateContext(ctx, %#v) failed with %v; want success", request, err) return } md, ok := metadata.FromOutgoingContext(annotated) if !ok || len(md) != emptyForwardMetaCount { t.Errorf("Expected %d metadata items in context; got %v", emptyForwardMetaCount, md) } } func TestAnnotateContext_WorksWithNoIncomingHeaders(t *testing.T) { ctx := context.Background() expectedRPCName := "/example.Example/Example" expectedHTTPPathPattern := "/v1" md1 := func(context.Context, *http.Request) metadata.MD { return metadata.New(map[string]string{"foo": "bar"}) } expected := metadata.New(map[string]string{"foo": "bar"}) request, err := http.NewRequestWithContext(ctx, "GET", "/v1", nil) if err != nil { t.Fatalf("http.NewRequestWithContext(ctx, %q, %q, nil) failed with %v; want success", "GET", "/v1", err) } serveMux := runtime.NewServeMux(runtime.WithMetadata(md1)) annotated, err := runtime.AnnotateContext(ctx, serveMux, request, expectedRPCName, runtime.WithHTTPPathPattern(expectedHTTPPathPattern)) if err != nil { t.Errorf("runtime.AnnotateContext(ctx, %#v) failed with %v; want success", request, err) return } actual, _ := metadata.FromOutgoingContext(annotated) for key, e := range expected { if a, ok := actual[key]; !ok || !reflect.DeepEqual(e, a) { t.Errorf("metadata.MD[%s] = %v; want %v", key, a, e) } } } func TestAnnotateContext_ForwardsGrpcMetadata(t *testing.T) { ctx := context.Background() expectedRPCName := "/example.Example/Example" expectedHTTPPathPattern := "/v1" request, err := http.NewRequestWithContext(ctx, "GET", "http://www.example.com/v1", nil) if err != nil { t.Fatalf("http.NewRequestWithContext(ctx, %q, %q, nil) failed with %v; want success", "GET", "http://www.example.com", err) } request.Header.Add("Some-Irrelevant-Header", "some value") request.Header.Add("Grpc-Metadata-FooBar", "Value1") request.Header.Add("Grpc-Metadata-Foo-BAZ", "Value2") request.Header.Add("Grpc-Metadata-foo-bAz", "Value3") request.Header.Add("Authorization", "Token 1234567890") annotated, err := runtime.AnnotateContext(ctx, runtime.NewServeMux(), request, expectedRPCName, runtime.WithHTTPPathPattern(expectedHTTPPathPattern)) if err != nil { t.Errorf("runtime.AnnotateContext(ctx, %#v) failed with %v; want success", request, err) return } md, ok := metadata.FromOutgoingContext(annotated) if got, want := len(md), emptyForwardMetaCount+4; !ok || got != want { t.Errorf("metadata items in context = %d want %d: %v", got, want, md) } if got, want := md["foobar"], []string{"Value1"}; !reflect.DeepEqual(got, want) { t.Errorf(`md["grpcgateway-foobar"] = %q; want %q`, got, want) } if got, want := md["foo-baz"], []string{"Value2", "Value3"}; !reflect.DeepEqual(got, want) { t.Errorf(`md["grpcgateway-foo-baz"] = %q want %q`, got, want) } if got, want := md["grpcgateway-authorization"], []string{"Token 1234567890"}; !reflect.DeepEqual(got, want) { t.Errorf(`md["grpcgateway-authorization"] = %q want %q`, got, want) } if got, want := md["authorization"], []string{"Token 1234567890"}; !reflect.DeepEqual(got, want) { t.Errorf(`md["authorization"] = %q want %q`, got, want) } if m, ok := runtime.RPCMethod(annotated); !ok { t.Errorf("runtime.RPCMethod(annotated) failed with no value; want %s", expectedRPCName) } else if m != expectedRPCName { t.Errorf("runtime.RPCMethod(annotated) failed with %s; want %s", m, expectedRPCName) } if m, ok := runtime.HTTPPathPattern(annotated); !ok { t.Errorf("runtime.HTTPPathPattern(annotated) failed with no value; want %s", expectedHTTPPathPattern) } else if m != expectedHTTPPathPattern { t.Errorf("runtime.HTTPPathPattern(annotated) failed with %s; want %s", m, expectedHTTPPathPattern) } } func TestAnnotateContext_ForwardGrpcBinaryMetadata(t *testing.T) { ctx := context.Background() expectedRPCName := "/example.Example/Example" request, err := http.NewRequestWithContext(ctx, "GET", "http://www.example.com", nil) if err != nil { t.Fatalf("http.NewRequestWithContext(ctx, %q, %q, nil) failed with %v; want success", "GET", "http://www.example.com", err) } binData := []byte("\x00test-binary-data") request.Header.Add("Grpc-Metadata-Test-Bin", base64.StdEncoding.EncodeToString(binData)) annotated, err := runtime.AnnotateContext(ctx, runtime.NewServeMux(), request, expectedRPCName) if err != nil { t.Errorf("runtime.AnnotateContext(ctx, %#v) failed with %v; want success", request, err) return } md, ok := metadata.FromOutgoingContext(annotated) if !ok || len(md) != emptyForwardMetaCount+1 { t.Errorf("Expected %d metadata items in context; got %v", emptyForwardMetaCount+1, md) } if got, want := md["test-bin"], []string{string(binData)}; !reflect.DeepEqual(got, want) { t.Errorf(`md["test-bin"] = %q want %q`, got, want) } if m, ok := runtime.RPCMethod(annotated); !ok { t.Errorf("runtime.RPCMethod(annotated) failed with no value; want %s", expectedRPCName) } else if m != expectedRPCName { t.Errorf("runtime.RPCMethod(annotated) failed with %s; want %s", m, expectedRPCName) } } func TestAnnotateContext_AddsXForwardedHeaders(t *testing.T) { ctx := context.Background() expectedRPCName := "/example.Example/Example" request, err := http.NewRequestWithContext(ctx, "GET", "http://bar.foo.example.com", nil) if err != nil { t.Fatalf("http.NewRequestWithContext(ctx, %q, %q, nil) failed with %v; want success", "GET", "http://bar.foo.example.com", err) } request.RemoteAddr = "192.0.2.100:12345" // client serveMux := runtime.NewServeMux(runtime.WithIncomingHeaderMatcher(func(key string) (string, bool) { return key, true })) annotated, err := runtime.AnnotateContext(ctx, serveMux, request, expectedRPCName) if err != nil { t.Errorf("runtime.AnnotateContext(ctx, %#v) failed with %v; want success", request, err) return } md, ok := metadata.FromOutgoingContext(annotated) if !ok || len(md) != emptyForwardMetaCount+1 { t.Errorf("Expected %d metadata items in context; got %v", emptyForwardMetaCount+1, md) } if got, want := md["x-forwarded-host"], []string{"bar.foo.example.com"}; !reflect.DeepEqual(got, want) { t.Errorf(`md["host"] = %v; want %v`, got, want) } if got, want := md["x-forwarded-for"], []string{"192.0.2.100"}; !reflect.DeepEqual(got, want) { t.Errorf(`md["x-forwarded-for"] = %v want %v`, got, want) } if m, ok := runtime.RPCMethod(annotated); !ok { t.Errorf("runtime.RPCMethod(annotated) failed with no value; want %s", expectedRPCName) } else if m != expectedRPCName { t.Errorf("runtime.RPCMethod(annotated) failed with %s; want %s", m, expectedRPCName) } } func TestAnnotateContext_AppendsToExistingXForwardedHeaders(t *testing.T) { ctx := context.Background() expectedRPCName := "/example.Example/Example" request, err := http.NewRequestWithContext(ctx, "GET", "http://bar.foo.example.com", nil) if err != nil { t.Fatalf("http.NewRequestWithContext(ctx, %q, %q, nil) failed with %v; want success", "GET", "http://bar.foo.example.com", err) } request.Header.Add("X-Forwarded-Host", "qux.example.com") request.Header.Add("X-Forwarded-For", "192.0.2.100") // client request.Header.Add("X-Forwarded-For", "192.0.2.101, 192.0.2.102") // intermediate proxies request.RemoteAddr = "192.0.2.200:12345" // final proxy serveMux := runtime.NewServeMux(runtime.WithIncomingHeaderMatcher(func(key string) (string, bool) { return key, true })) annotated, err := runtime.AnnotateContext(ctx, serveMux, request, expectedRPCName) if err != nil { t.Errorf("runtime.AnnotateContext(ctx, %#v) failed with %v; want success", request, err) return } md, ok := metadata.FromOutgoingContext(annotated) if !ok || len(md) != emptyForwardMetaCount+1 { t.Errorf("Expected %d metadata items in context; got %v", emptyForwardMetaCount+1, md) } if got, want := md["x-forwarded-host"], []string{"qux.example.com"}; !reflect.DeepEqual(got, want) { t.Errorf(`md["host"] = %v; want %v`, got, want) } // Note: it must be in order client, proxy1, proxy2 if got, want := md["x-forwarded-for"], []string{"192.0.2.100, 192.0.2.101, 192.0.2.102, 192.0.2.200"}; !reflect.DeepEqual(got, want) { t.Errorf(`md["x-forwarded-for"] = %v want %v`, got, want) } if m, ok := runtime.RPCMethod(annotated); !ok { t.Errorf("runtime.RPCMethod(annotated) failed with no value; want %s", expectedRPCName) } else if m != expectedRPCName { t.Errorf("runtime.RPCMethod(annotated) failed with %s; want %s", m, expectedRPCName) } } func TestAnnotateContext_SupportsTimeouts(t *testing.T) { ctx := context.Background() expectedRPCName := "/example.Example/Example" request, err := http.NewRequestWithContext(ctx, "GET", "http://example.com", nil) if err != nil { t.Fatalf(`http.NewRequestWithContext(ctx, "GET", "http://example.com", nil) failed with %v; want success`, err) } annotated, err := runtime.AnnotateContext(ctx, runtime.NewServeMux(), request, expectedRPCName) if err != nil { t.Errorf("runtime.AnnotateContext(ctx, %#v) failed with %v; want success", request, err) return } if _, ok := annotated.Deadline(); ok { // no deadline by default t.Errorf("annotated.Deadline() = _, true; want _, false") } const acceptableError = 50 * time.Millisecond runtime.DefaultContextTimeout = 10 * time.Second annotated, err = runtime.AnnotateContext(ctx, runtime.NewServeMux(), request, expectedRPCName) if err != nil { t.Errorf("runtime.AnnotateContext(ctx, %#v) failed with %v; want success", request, err) return } deadline, ok := annotated.Deadline() if !ok { t.Errorf("annotated.Deadline() = _, false; want _, true") } if got, want := time.Until(deadline), runtime.DefaultContextTimeout; got-want > acceptableError || got-want < -acceptableError { t.Errorf("time.Until(deadline) = %v; want %v; with error %v", got, want, acceptableError) } for _, spec := range []struct { timeout string want time.Duration }{ { timeout: "17H", want: 17 * time.Hour, }, { timeout: "19M", want: 19 * time.Minute, }, { timeout: "23S", want: 23 * time.Second, }, { timeout: "1009m", want: 1009 * time.Millisecond, }, { timeout: "1000003u", want: 1000003 * time.Microsecond, }, { timeout: "100000007n", want: 100000007 * time.Nanosecond, }, } { request.Header.Set("Grpc-Timeout", spec.timeout) annotated, err = runtime.AnnotateContext(ctx, runtime.NewServeMux(), request, expectedRPCName) if err != nil { t.Errorf("runtime.AnnotateContext(ctx, %#v) failed with %v; want success", request, err) return } deadline, ok := annotated.Deadline() if !ok { t.Errorf("annotated.Deadline() = _, false; want _, true; timeout = %q", spec.timeout) } if got, want := time.Until(deadline), spec.want; got-want > acceptableError || got-want < -acceptableError { t.Errorf("time.Until(deadline) = %v; want %v; with error %v; timeout= %q", got, want, acceptableError, spec.timeout) } if m, ok := runtime.RPCMethod(annotated); !ok { t.Errorf("runtime.RPCMethod(annotated) failed with no value; want %s", expectedRPCName) } else if m != expectedRPCName { t.Errorf("runtime.RPCMethod(annotated) failed with %s; want %s", m, expectedRPCName) } } } func TestAnnotateContext_SupportsCustomAnnotators(t *testing.T) { ctx := context.Background() md1 := func(context.Context, *http.Request) metadata.MD { return metadata.New(map[string]string{"foo": "bar"}) } md2 := func(context.Context, *http.Request) metadata.MD { return metadata.New(map[string]string{"baz": "qux"}) } expected := metadata.New(map[string]string{"foo": "bar", "baz": "qux"}) expectedRPCName := "/example.Example/Example" request, err := http.NewRequestWithContext(ctx, "GET", "http://example.com", nil) if err != nil { t.Fatalf(`http.NewRequestWithContext(ctx, "GET", "http://example.com", nil) failed with %v; want success`, err) } annotated, err := runtime.AnnotateContext(ctx, runtime.NewServeMux(runtime.WithMetadata(md1), runtime.WithMetadata(md2)), request, expectedRPCName) if err != nil { t.Errorf("runtime.AnnotateContext(ctx, %#v) failed with %v; want success", request, err) return } actual, _ := metadata.FromOutgoingContext(annotated) for key, e := range expected { if a, ok := actual[key]; !ok || !reflect.DeepEqual(e, a) { t.Errorf("metadata.MD[%s] = %v; want %v", key, a, e) } } if m, ok := runtime.RPCMethod(annotated); !ok { t.Errorf("runtime.RPCMethod(annotated) failed with no value; want %s", expectedRPCName) } else if m != expectedRPCName { t.Errorf("runtime.RPCMethod(annotated) failed with %s; want %s", m, expectedRPCName) } } func TestAnnotateIncomingContext_WorksWithEmpty(t *testing.T) { ctx := context.Background() expectedRPCName := "/example.Example/Example" expectedHTTPPathPattern := "/v1" request, err := http.NewRequestWithContext(ctx, "GET", "http://www.example.com/v1", nil) if err != nil { t.Fatalf("http.NewRequestWithContext(ctx, %q, %q, nil) failed with %v; want success", "GET", "http://www.example.com", err) } request.Header.Add("Some-Irrelevant-Header", "some value") annotated, err := runtime.AnnotateIncomingContext(ctx, runtime.NewServeMux(), request, expectedRPCName, runtime.WithHTTPPathPattern(expectedHTTPPathPattern)) if err != nil { t.Errorf("runtime.AnnotateIncomingContext(ctx, %#v) failed with %v; want success", request, err) return } md, ok := metadata.FromIncomingContext(annotated) if !ok || len(md) != emptyForwardMetaCount { t.Errorf("Expected %d metadata items in context; got %v", emptyForwardMetaCount, md) } if m, ok := runtime.RPCMethod(annotated); !ok { t.Errorf("runtime.RPCMethod(annotated) failed with no value; want %s", expectedRPCName) } else if m != expectedRPCName { t.Errorf("runtime.RPCMethod(annotated) failed with %s; want %s", m, expectedRPCName) } } func TestAnnotateIncomingContext_ForwardsGrpcMetadata(t *testing.T) { ctx := context.Background() expectedRPCName := "/example.Example/Example" expectedHTTPPathPattern := "/v1" request, err := http.NewRequestWithContext(ctx, "GET", "http://www.example.com/v1", nil) if err != nil { t.Fatalf("http.NewRequestWithContext(ctx, %q, %q, nil) failed with %v; want success", "GET", "http://www.example.com", err) } request.Header.Add("Some-Irrelevant-Header", "some value") request.Header.Add("Grpc-Metadata-FooBar", "Value1") request.Header.Add("Grpc-Metadata-Foo-BAZ", "Value2") request.Header.Add("Grpc-Metadata-foo-bAz", "Value3") request.Header.Add("Authorization", "Token 1234567890") annotated, err := runtime.AnnotateIncomingContext(ctx, runtime.NewServeMux(), request, expectedRPCName, runtime.WithHTTPPathPattern(expectedHTTPPathPattern)) if err != nil { t.Errorf("runtime.AnnotateIncomingContext(ctx, %#v) failed with %v; want success", request, err) return } md, ok := metadata.FromIncomingContext(annotated) if got, want := len(md), emptyForwardMetaCount+4; !ok || got != want { t.Errorf("metadata items in context = %d want %d: %v", got, want, md) } if got, want := md["foobar"], []string{"Value1"}; !reflect.DeepEqual(got, want) { t.Errorf(`md["grpcgateway-foobar"] = %q; want %q`, got, want) } if got, want := md["foo-baz"], []string{"Value2", "Value3"}; !reflect.DeepEqual(got, want) { t.Errorf(`md["grpcgateway-foo-baz"] = %q want %q`, got, want) } if got, want := md["grpcgateway-authorization"], []string{"Token 1234567890"}; !reflect.DeepEqual(got, want) { t.Errorf(`md["grpcgateway-authorization"] = %q want %q`, got, want) } if got, want := md["authorization"], []string{"Token 1234567890"}; !reflect.DeepEqual(got, want) { t.Errorf(`md["authorization"] = %q want %q`, got, want) } if m, ok := runtime.RPCMethod(annotated); !ok { t.Errorf("runtime.RPCMethod(annotated) failed with no value; want %s", expectedRPCName) } else if m != expectedRPCName { t.Errorf("runtime.RPCMethod(annotated) failed with %s; want %s", m, expectedRPCName) } if m, ok := runtime.HTTPPathPattern(annotated); !ok { t.Errorf("runtime.HTTPPathPattern(annotated) failed with no value; want %s", expectedHTTPPathPattern) } else if m != expectedHTTPPathPattern { t.Errorf("runtime.HTTPPathPattern(annotated) failed with %s; want %s", m, expectedHTTPPathPattern) } } func TestAnnotateIncomingContext_ForwardGrpcBinaryMetadata(t *testing.T) { ctx := context.Background() expectedRPCName := "/example.Example/Example" request, err := http.NewRequestWithContext(ctx, "GET", "http://www.example.com", nil) if err != nil { t.Fatalf("http.NewRequestWithContext(ctx, %q, %q, nil) failed with %v; want success", "GET", "http://www.example.com", err) } binData := []byte("\x00test-binary-data") request.Header.Add("Grpc-Metadata-Test-Bin", base64.StdEncoding.EncodeToString(binData)) annotated, err := runtime.AnnotateIncomingContext(ctx, runtime.NewServeMux(), request, expectedRPCName) if err != nil { t.Errorf("runtime.AnnotateIncomingContext(ctx, %#v) failed with %v; want success", request, err) return } md, ok := metadata.FromIncomingContext(annotated) if !ok || len(md) != emptyForwardMetaCount+1 { t.Errorf("Expected %d metadata items in context; got %v", emptyForwardMetaCount+1, md) } if got, want := md["test-bin"], []string{string(binData)}; !reflect.DeepEqual(got, want) { t.Errorf(`md["test-bin"] = %q want %q`, got, want) } if m, ok := runtime.RPCMethod(annotated); !ok { t.Errorf("runtime.RPCMethod(annotated) failed with no value; want %s", expectedRPCName) } else if m != expectedRPCName { t.Errorf("runtime.RPCMethod(annotated) failed with %s; want %s", m, expectedRPCName) } } func TestAnnotateIncomingContext_AddsXForwardedHeaders(t *testing.T) { ctx := context.Background() expectedRPCName := "/example.Example/Example" request, err := http.NewRequestWithContext(ctx, "GET", "http://bar.foo.example.com", nil) if err != nil { t.Fatalf("http.NewRequestWithContext(ctx, %q, %q, nil) failed with %v; want success", "GET", "http://bar.foo.example.com", err) } request.RemoteAddr = "192.0.2.100:12345" // client serveMux := runtime.NewServeMux(runtime.WithIncomingHeaderMatcher(func(key string) (string, bool) { return key, true })) annotated, err := runtime.AnnotateIncomingContext(ctx, serveMux, request, expectedRPCName) if err != nil { t.Errorf("runtime.AnnotateIncomingContext(ctx, %#v) failed with %v; want success", request, err) return } md, ok := metadata.FromIncomingContext(annotated) if !ok || len(md) != emptyForwardMetaCount+1 { t.Errorf("Expected %d metadata items in context; got %v", emptyForwardMetaCount+1, md) } if got, want := md["x-forwarded-host"], []string{"bar.foo.example.com"}; !reflect.DeepEqual(got, want) { t.Errorf(`md["host"] = %v; want %v`, got, want) } if got, want := md["x-forwarded-for"], []string{"192.0.2.100"}; !reflect.DeepEqual(got, want) { t.Errorf(`md["x-forwarded-for"] = %v want %v`, got, want) } if m, ok := runtime.RPCMethod(annotated); !ok { t.Errorf("runtime.RPCMethod(annotated) failed with no value; want %s", expectedRPCName) } else if m != expectedRPCName { t.Errorf("runtime.RPCMethod(annotated) failed with %s; want %s", m, expectedRPCName) } } func TestAnnotateIncomingContext_AppendsToExistingXForwardedHeaders(t *testing.T) { ctx := context.Background() expectedRPCName := "/example.Example/Example" request, err := http.NewRequestWithContext(ctx, "GET", "http://bar.foo.example.com", nil) if err != nil { t.Fatalf("http.NewRequestWithContext(ctx, %q, %q, nil) failed with %v; want success", "GET", "http://bar.foo.example.com", err) } request.Header.Add("X-Forwarded-Host", "qux.example.com") request.Header.Add("X-Forwarded-For", "192.0.2.100") // client request.Header.Add("X-Forwarded-For", "192.0.2.101, 192.0.2.102") // intermediate proxies request.RemoteAddr = "192.0.2.200:12345" // final proxy serveMux := runtime.NewServeMux(runtime.WithIncomingHeaderMatcher(func(key string) (string, bool) { return key, true })) annotated, err := runtime.AnnotateIncomingContext(ctx, serveMux, request, expectedRPCName) if err != nil { t.Errorf("runtime.AnnotateIncomingContext(ctx, %#v) failed with %v; want success", request, err) return } md, ok := metadata.FromIncomingContext(annotated) if !ok || len(md) != emptyForwardMetaCount+1 { t.Errorf("Expected %d metadata items in context; got %v", emptyForwardMetaCount+1, md) } if got, want := md["x-forwarded-host"], []string{"qux.example.com"}; !reflect.DeepEqual(got, want) { t.Errorf(`md["host"] = %v; want %v`, got, want) } // Note: it must be in order client, proxy1, proxy2 if got, want := md["x-forwarded-for"], []string{"192.0.2.100, 192.0.2.101, 192.0.2.102, 192.0.2.200"}; !reflect.DeepEqual(got, want) { t.Errorf(`md["x-forwarded-for"] = %v want %v`, got, want) } if m, ok := runtime.RPCMethod(annotated); !ok { t.Errorf("runtime.RPCMethod(annotated) failed with no value; want %s", expectedRPCName) } else if m != expectedRPCName { t.Errorf("runtime.RPCMethod(annotated) failed with %s; want %s", m, expectedRPCName) } } func TestAnnotateIncomingContext_SupportsTimeouts(t *testing.T) { // While run all test, TestAnnotateContext_SupportsTimeouts() will change the DefaultContextTimeout, so reset it to zero. runtime.DefaultContextTimeout = 0 * time.Second expectedRPCName := "/example.Example/Example" ctx := context.Background() request, err := http.NewRequestWithContext(ctx, "GET", "http://example.com", nil) if err != nil { t.Fatalf(`http.NewRequestWithContext(ctx, "GET", "http://example.com", nil) failed with %v; want success`, err) } annotated, err := runtime.AnnotateIncomingContext(ctx, runtime.NewServeMux(), request, expectedRPCName) if err != nil { t.Errorf("runtime.AnnotateIncomingContext(ctx, %#v) failed with %v; want success", request, err) return } if _, ok := annotated.Deadline(); ok { // no deadline by default t.Errorf("annotated.Deadline() = _, true; want _, false") } const acceptableError = 50 * time.Millisecond runtime.DefaultContextTimeout = 10 * time.Second annotated, err = runtime.AnnotateIncomingContext(ctx, runtime.NewServeMux(), request, expectedRPCName) if err != nil { t.Errorf("runtime.AnnotateIncomingContext(ctx, %#v) failed with %v; want success", request, err) return } deadline, ok := annotated.Deadline() if !ok { t.Errorf("annotated.Deadline() = _, false; want _, true") } if got, want := time.Until(deadline), runtime.DefaultContextTimeout; got-want > acceptableError || got-want < -acceptableError { t.Errorf("time.Until(deadline) = %v; want %v; with error %v", got, want, acceptableError) } for _, spec := range []struct { timeout string want time.Duration }{ { timeout: "17H", want: 17 * time.Hour, }, { timeout: "19M", want: 19 * time.Minute, }, { timeout: "23S", want: 23 * time.Second, }, { timeout: "1009m", want: 1009 * time.Millisecond, }, { timeout: "1000003u", want: 1000003 * time.Microsecond, }, { timeout: "100000007n", want: 100000007 * time.Nanosecond, }, } { request.Header.Set("Grpc-Timeout", spec.timeout) annotated, err = runtime.AnnotateIncomingContext(ctx, runtime.NewServeMux(), request, expectedRPCName) if err != nil { t.Errorf("runtime.AnnotateIncomingContext(ctx, %#v) failed with %v; want success", request, err) return } deadline, ok := annotated.Deadline() if !ok { t.Errorf("annotated.Deadline() = _, false; want _, true; timeout = %q", spec.timeout) } if got, want := time.Until(deadline), spec.want; got-want > acceptableError || got-want < -acceptableError { t.Errorf("time.Until(deadline) = %v; want %v; with error %v; timeout= %q", got, want, acceptableError, spec.timeout) } if m, ok := runtime.RPCMethod(annotated); !ok { t.Errorf("runtime.RPCMethod(annotated) failed with no value; want %s", expectedRPCName) } else if m != expectedRPCName { t.Errorf("runtime.RPCMethod(annotated) failed with %s; want %s", m, expectedRPCName) } } } func TestAnnotateIncomingContext_SupportsCustomAnnotators(t *testing.T) { ctx := context.Background() md1 := func(context.Context, *http.Request) metadata.MD { return metadata.New(map[string]string{"foo": "bar"}) } md2 := func(context.Context, *http.Request) metadata.MD { return metadata.New(map[string]string{"baz": "qux"}) } expected := metadata.New(map[string]string{"foo": "bar", "baz": "qux"}) expectedRPCName := "/example.Example/Example" request, err := http.NewRequestWithContext(ctx, "GET", "http://example.com", nil) if err != nil { t.Fatalf(`http.NewRequestWithContext(ctx, "GET", "http://example.com", nil) failed with %v; want success`, err) } annotated, err := runtime.AnnotateIncomingContext(ctx, runtime.NewServeMux(runtime.WithMetadata(md1), runtime.WithMetadata(md2)), request, expectedRPCName) if err != nil { t.Errorf("runtime.AnnotateIncomingContext(ctx, %#v) failed with %v; want success", request, err) return } actual, _ := metadata.FromIncomingContext(annotated) for key, e := range expected { if a, ok := actual[key]; !ok || !reflect.DeepEqual(e, a) { t.Errorf("metadata.MD[%s] = %v; want %v", key, a, e) } } if m, ok := runtime.RPCMethod(annotated); !ok { t.Errorf("runtime.RPCMethod(annotated) failed with no value; want %s", expectedRPCName) } else if m != expectedRPCName { t.Errorf("runtime.RPCMethod(annotated) failed with %s; want %s", m, expectedRPCName) } } ================================================ FILE: runtime/convert.go ================================================ package runtime import ( "encoding/base64" "fmt" "strconv" "strings" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/types/known/durationpb" "google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/wrapperspb" ) // String just returns the given string. // It is just for compatibility to other types. func String(val string) (string, error) { return val, nil } // StringSlice converts 'val' where individual strings are separated by // 'sep' into a string slice. func StringSlice(val, sep string) ([]string, error) { return strings.Split(val, sep), nil } // Bool converts the given string representation of a boolean value into bool. func Bool(val string) (bool, error) { return strconv.ParseBool(val) } // BoolSlice converts 'val' where individual booleans are separated by // 'sep' into a bool slice. func BoolSlice(val, sep string) ([]bool, error) { s := strings.Split(val, sep) values := make([]bool, len(s)) for i, v := range s { value, err := Bool(v) if err != nil { return nil, err } values[i] = value } return values, nil } // Float64 converts the given string representation into representation of a floating point number into float64. func Float64(val string) (float64, error) { return strconv.ParseFloat(val, 64) } // Float64Slice converts 'val' where individual floating point numbers are separated by // 'sep' into a float64 slice. func Float64Slice(val, sep string) ([]float64, error) { s := strings.Split(val, sep) values := make([]float64, len(s)) for i, v := range s { value, err := Float64(v) if err != nil { return nil, err } values[i] = value } return values, nil } // Float32 converts the given string representation of a floating point number into float32. func Float32(val string) (float32, error) { f, err := strconv.ParseFloat(val, 32) if err != nil { return 0, err } return float32(f), nil } // Float32Slice converts 'val' where individual floating point numbers are separated by // 'sep' into a float32 slice. func Float32Slice(val, sep string) ([]float32, error) { s := strings.Split(val, sep) values := make([]float32, len(s)) for i, v := range s { value, err := Float32(v) if err != nil { return nil, err } values[i] = value } return values, nil } // Int64 converts the given string representation of an integer into int64. func Int64(val string) (int64, error) { return strconv.ParseInt(val, 0, 64) } // Int64Slice converts 'val' where individual integers are separated by // 'sep' into an int64 slice. func Int64Slice(val, sep string) ([]int64, error) { s := strings.Split(val, sep) values := make([]int64, len(s)) for i, v := range s { value, err := Int64(v) if err != nil { return nil, err } values[i] = value } return values, nil } // Int32 converts the given string representation of an integer into int32. func Int32(val string) (int32, error) { i, err := strconv.ParseInt(val, 0, 32) if err != nil { return 0, err } return int32(i), nil } // Int32Slice converts 'val' where individual integers are separated by // 'sep' into an int32 slice. func Int32Slice(val, sep string) ([]int32, error) { s := strings.Split(val, sep) values := make([]int32, len(s)) for i, v := range s { value, err := Int32(v) if err != nil { return nil, err } values[i] = value } return values, nil } // Uint64 converts the given string representation of an integer into uint64. func Uint64(val string) (uint64, error) { return strconv.ParseUint(val, 0, 64) } // Uint64Slice converts 'val' where individual integers are separated by // 'sep' into a uint64 slice. func Uint64Slice(val, sep string) ([]uint64, error) { s := strings.Split(val, sep) values := make([]uint64, len(s)) for i, v := range s { value, err := Uint64(v) if err != nil { return nil, err } values[i] = value } return values, nil } // Uint32 converts the given string representation of an integer into uint32. func Uint32(val string) (uint32, error) { i, err := strconv.ParseUint(val, 0, 32) if err != nil { return 0, err } return uint32(i), nil } // Uint32Slice converts 'val' where individual integers are separated by // 'sep' into a uint32 slice. func Uint32Slice(val, sep string) ([]uint32, error) { s := strings.Split(val, sep) values := make([]uint32, len(s)) for i, v := range s { value, err := Uint32(v) if err != nil { return nil, err } values[i] = value } return values, nil } // Bytes converts the given string representation of a byte sequence into a slice of bytes // A bytes sequence is encoded in URL-safe base64 without padding func Bytes(val string) ([]byte, error) { b, err := base64.StdEncoding.DecodeString(val) if err != nil { b, err = base64.URLEncoding.DecodeString(val) if err != nil { return nil, err } } return b, nil } // BytesSlice converts 'val' where individual bytes sequences, encoded in URL-safe // base64 without padding, are separated by 'sep' into a slice of byte slices. func BytesSlice(val, sep string) ([][]byte, error) { s := strings.Split(val, sep) values := make([][]byte, len(s)) for i, v := range s { value, err := Bytes(v) if err != nil { return nil, err } values[i] = value } return values, nil } // Timestamp converts the given RFC3339 formatted string into a timestamp.Timestamp. func Timestamp(val string) (*timestamppb.Timestamp, error) { var r timestamppb.Timestamp val = strconv.Quote(strings.Trim(val, `"`)) unmarshaler := &protojson.UnmarshalOptions{} if err := unmarshaler.Unmarshal([]byte(val), &r); err != nil { return nil, err } return &r, nil } // Duration converts the given string into a timestamp.Duration. func Duration(val string) (*durationpb.Duration, error) { var r durationpb.Duration val = strconv.Quote(strings.Trim(val, `"`)) unmarshaler := &protojson.UnmarshalOptions{} if err := unmarshaler.Unmarshal([]byte(val), &r); err != nil { return nil, err } return &r, nil } // Enum converts the given string into an int32 that should be type casted into the // correct enum proto type. func Enum(val string, enumValMap map[string]int32) (int32, error) { e, ok := enumValMap[val] if ok { return e, nil } i, err := Int32(val) if err != nil { return 0, fmt.Errorf("%s is not valid", val) } for _, v := range enumValMap { if v == i { return i, nil } } return 0, fmt.Errorf("%s is not valid", val) } // EnumSlice converts 'val' where individual enums are separated by 'sep' // into a int32 slice. Each individual int32 should be type casted into the // correct enum proto type. func EnumSlice(val, sep string, enumValMap map[string]int32) ([]int32, error) { s := strings.Split(val, sep) values := make([]int32, len(s)) for i, v := range s { value, err := Enum(v, enumValMap) if err != nil { return nil, err } values[i] = value } return values, nil } // Support for google.protobuf.wrappers on top of primitive types // StringValue well-known type support as wrapper around string type func StringValue(val string) (*wrapperspb.StringValue, error) { return wrapperspb.String(val), nil } // FloatValue well-known type support as wrapper around float32 type func FloatValue(val string) (*wrapperspb.FloatValue, error) { parsedVal, err := Float32(val) return wrapperspb.Float(parsedVal), err } // DoubleValue well-known type support as wrapper around float64 type func DoubleValue(val string) (*wrapperspb.DoubleValue, error) { parsedVal, err := Float64(val) return wrapperspb.Double(parsedVal), err } // BoolValue well-known type support as wrapper around bool type func BoolValue(val string) (*wrapperspb.BoolValue, error) { parsedVal, err := Bool(val) return wrapperspb.Bool(parsedVal), err } // Int32Value well-known type support as wrapper around int32 type func Int32Value(val string) (*wrapperspb.Int32Value, error) { parsedVal, err := Int32(val) return wrapperspb.Int32(parsedVal), err } // UInt32Value well-known type support as wrapper around uint32 type func UInt32Value(val string) (*wrapperspb.UInt32Value, error) { parsedVal, err := Uint32(val) return wrapperspb.UInt32(parsedVal), err } // Int64Value well-known type support as wrapper around int64 type func Int64Value(val string) (*wrapperspb.Int64Value, error) { parsedVal, err := Int64(val) return wrapperspb.Int64(parsedVal), err } // UInt64Value well-known type support as wrapper around uint64 type func UInt64Value(val string) (*wrapperspb.UInt64Value, error) { parsedVal, err := Uint64(val) return wrapperspb.UInt64(parsedVal), err } // BytesValue well-known type support as wrapper around bytes[] type func BytesValue(val string) (*wrapperspb.BytesValue, error) { parsedVal, err := Bytes(val) return wrapperspb.Bytes(parsedVal), err } ================================================ FILE: runtime/convert_test.go ================================================ package runtime_test import ( "testing" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/durationpb" "google.golang.org/protobuf/types/known/timestamppb" ) func TestConvertTimestamp(t *testing.T) { specs := []struct { name string input string output *timestamppb.Timestamp wanterr bool }{ { name: "a valid RFC3339 timestamp", input: `"2016-05-10T10:19:13.123Z"`, output: ×tamppb.Timestamp{ Seconds: 1462875553, Nanos: 123000000, }, wanterr: false, }, { name: "a valid RFC3339 timestamp without double quotation", input: "2016-05-10T10:19:13.123Z", output: ×tamppb.Timestamp{ Seconds: 1462875553, Nanos: 123000000, }, wanterr: false, }, { name: "invalid timestamp", input: `"05-10-2016T10:19:13.123Z"`, output: nil, wanterr: true, }, { name: "JSON number", input: "123", output: nil, wanterr: true, }, { name: "JSON bool", input: "true", output: nil, wanterr: true, }, } for _, spec := range specs { t.Run(spec.name, func(t *testing.T) { ts, err := runtime.Timestamp(spec.input) switch { case err != nil && !spec.wanterr: t.Errorf("got unexpected error\n%#v", err) case err == nil && spec.wanterr: t.Errorf("did not error when expected") case !proto.Equal(ts, spec.output): t.Errorf( "when testing %s; got\n%#v\nexpected\n%#v", spec.name, ts, spec.output, ) } }) } } func TestConvertDuration(t *testing.T) { specs := []struct { name string input string output *durationpb.Duration wanterr bool }{ { name: "a valid duration", input: `"123.456s"`, output: &durationpb.Duration{ Seconds: 123, Nanos: 456000000, }, wanterr: false, }, { name: "a valid duration without double quotation", input: "123.456s", output: &durationpb.Duration{ Seconds: 123, Nanos: 456000000, }, wanterr: false, }, { name: "invalid duration", input: `"123years"`, output: nil, wanterr: true, }, { name: "JSON number", input: "123", output: nil, wanterr: true, }, { name: "JSON bool", input: "true", output: nil, wanterr: true, }, } for _, spec := range specs { t.Run(spec.name, func(t *testing.T) { ts, err := runtime.Duration(spec.input) switch { case err != nil && !spec.wanterr: t.Errorf("got unexpected error\n%#v", err) case err == nil && spec.wanterr: t.Errorf("did not error when expected") case !proto.Equal(ts, spec.output): t.Errorf( "when testing %s; got\n%#v\nexpected\n%#v", spec.name, ts, spec.output, ) } }) } } ================================================ FILE: runtime/doc.go ================================================ /* Package runtime contains runtime helper functions used by servers which protoc-gen-grpc-gateway generates. */ package runtime ================================================ FILE: runtime/errors.go ================================================ package runtime import ( "context" "errors" "io" "net/http" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/status" ) // ErrorHandlerFunc is the signature used to configure error handling. type ErrorHandlerFunc func(context.Context, *ServeMux, Marshaler, http.ResponseWriter, *http.Request, error) // StreamErrorHandlerFunc is the signature used to configure stream error handling. type StreamErrorHandlerFunc func(context.Context, error) *status.Status // RoutingErrorHandlerFunc is the signature used to configure error handling for routing errors. type RoutingErrorHandlerFunc func(context.Context, *ServeMux, Marshaler, http.ResponseWriter, *http.Request, int) // HTTPStatusError is the error to use when needing to provide a different HTTP status code for an error // passed to the DefaultRoutingErrorHandler. type HTTPStatusError struct { HTTPStatus int Err error } func (e *HTTPStatusError) Error() string { return e.Err.Error() } // HTTPStatusFromCode converts a gRPC error code into the corresponding HTTP response status. // See: https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto func HTTPStatusFromCode(code codes.Code) int { switch code { case codes.OK: return http.StatusOK case codes.Canceled: return 499 case codes.Unknown: return http.StatusInternalServerError case codes.InvalidArgument: return http.StatusBadRequest case codes.DeadlineExceeded: return http.StatusGatewayTimeout case codes.NotFound: return http.StatusNotFound case codes.AlreadyExists: return http.StatusConflict case codes.PermissionDenied: return http.StatusForbidden case codes.Unauthenticated: return http.StatusUnauthorized case codes.ResourceExhausted: return http.StatusTooManyRequests case codes.FailedPrecondition: // Note, this deliberately doesn't translate to the similarly named '412 Precondition Failed' HTTP response status. return http.StatusBadRequest case codes.Aborted: return http.StatusConflict case codes.OutOfRange: return http.StatusBadRequest case codes.Unimplemented: return http.StatusNotImplemented case codes.Internal: return http.StatusInternalServerError case codes.Unavailable: return http.StatusServiceUnavailable case codes.DataLoss: return http.StatusInternalServerError default: grpclog.Warningf("Unknown gRPC error code: %v", code) return http.StatusInternalServerError } } // HTTPError uses the mux-configured error handler. func HTTPError(ctx context.Context, mux *ServeMux, marshaler Marshaler, w http.ResponseWriter, r *http.Request, err error) { mux.errorHandler(ctx, mux, marshaler, w, r, err) } // HTTPStreamError uses the mux-configured stream error handler to notify error to the client without closing the connection. func HTTPStreamError(ctx context.Context, mux *ServeMux, marshaler Marshaler, w http.ResponseWriter, r *http.Request, err error) { st := mux.streamErrorHandler(ctx, err) msg := errorChunk(st) buf, err := marshaler.Marshal(msg) if err != nil { grpclog.Errorf("Failed to marshal an error: %v", err) return } if _, err := w.Write(buf); err != nil { grpclog.Errorf("Failed to notify error to client: %v", err) return } } // DefaultHTTPErrorHandler is the default error handler. // If "err" is a gRPC Status, the function replies with the status code mapped by HTTPStatusFromCode. // If "err" is a HTTPStatusError, the function replies with the status code provide by that struct. This is // intended to allow passing through of specific statuses via the function set via WithRoutingErrorHandler // for the ServeMux constructor to handle edge cases which the standard mappings in HTTPStatusFromCode // are insufficient for. // If otherwise, it replies with http.StatusInternalServerError. // // The response body written by this function is a Status message marshaled by the Marshaler. func DefaultHTTPErrorHandler(ctx context.Context, mux *ServeMux, marshaler Marshaler, w http.ResponseWriter, r *http.Request, err error) { // return Internal when Marshal failed const fallback = `{"code": 13, "message": "failed to marshal error message"}` const fallbackRewriter = `{"code": 13, "message": "failed to rewrite error message"}` var customStatus *HTTPStatusError if errors.As(err, &customStatus) { err = customStatus.Err } s := status.Convert(err) w.Header().Del("Trailer") w.Header().Del("Transfer-Encoding") respRw, err := mux.forwardResponseRewriter(ctx, s.Proto()) if err != nil { grpclog.Errorf("Failed to rewrite error message %q: %v", s, err) w.WriteHeader(http.StatusInternalServerError) if _, err := io.WriteString(w, fallbackRewriter); err != nil { grpclog.Errorf("Failed to write response: %v", err) } return } contentType := marshaler.ContentType(respRw) w.Header().Set("Content-Type", contentType) if s.Code() == codes.Unauthenticated { w.Header().Set("WWW-Authenticate", s.Message()) } buf, merr := marshaler.Marshal(respRw) if merr != nil { grpclog.Errorf("Failed to marshal error message %q: %v", s, merr) w.WriteHeader(http.StatusInternalServerError) if _, err := io.WriteString(w, fallback); err != nil { grpclog.Errorf("Failed to write response: %v", err) } return } md, ok := ServerMetadataFromContext(ctx) if ok { handleForwardResponseServerMetadata(w, mux, md) // RFC 7230 https://tools.ietf.org/html/rfc7230#section-4.1.2 // Unless the request includes a TE header field indicating "trailers" // is acceptable, as described in Section 4.3, a server SHOULD NOT // generate trailer fields that it believes are necessary for the user // agent to receive. doForwardTrailers := requestAcceptsTrailers(r) if doForwardTrailers { handleForwardResponseTrailerHeader(w, mux, md) w.Header().Set("Transfer-Encoding", "chunked") } } st := HTTPStatusFromCode(s.Code()) if customStatus != nil { st = customStatus.HTTPStatus } w.WriteHeader(st) if _, err := w.Write(buf); err != nil { grpclog.Errorf("Failed to write response: %v", err) } if ok && requestAcceptsTrailers(r) { handleForwardResponseTrailer(w, mux, md) } } func DefaultStreamErrorHandler(_ context.Context, err error) *status.Status { return status.Convert(err) } // DefaultRoutingErrorHandler is our default handler for routing errors. // By default http error codes mapped on the following error codes: // // NotFound -> grpc.NotFound // StatusBadRequest -> grpc.InvalidArgument // MethodNotAllowed -> grpc.Unimplemented // Other -> grpc.Internal, method is not expecting to be called for anything else func DefaultRoutingErrorHandler(ctx context.Context, mux *ServeMux, marshaler Marshaler, w http.ResponseWriter, r *http.Request, httpStatus int) { sterr := status.Error(codes.Internal, "Unexpected routing error") switch httpStatus { case http.StatusBadRequest: sterr = status.Error(codes.InvalidArgument, http.StatusText(httpStatus)) case http.StatusMethodNotAllowed: sterr = status.Error(codes.Unimplemented, http.StatusText(httpStatus)) case http.StatusNotFound: sterr = status.Error(codes.NotFound, http.StatusText(httpStatus)) } mux.errorHandler(ctx, mux, marshaler, w, r, sterr) } ================================================ FILE: runtime/errors_test.go ================================================ package runtime_test import ( "bytes" "context" "errors" "net/http" "net/http/httptest" "strconv" "strings" "testing" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "google.golang.org/genproto/googleapis/rpc/errdetails" statuspb "google.golang.org/genproto/googleapis/rpc/status" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) func TestDefaultHTTPError(t *testing.T) { ctx := context.Background() statusWithDetails, _ := status.New(codes.FailedPrecondition, "failed precondition").WithDetails( &errdetails.PreconditionFailure{}, ) for i, spec := range []struct { err error status int msg string marshaler runtime.Marshaler contentType string details string fordwardRespRewriter runtime.ForwardResponseRewriter extractMessage func(*testing.T) }{ { err: errors.New("example error"), status: http.StatusInternalServerError, marshaler: &runtime.JSONPb{}, contentType: "application/json", msg: "example error", }, { err: status.Error(codes.NotFound, "no such resource"), status: http.StatusNotFound, marshaler: &runtime.JSONPb{}, contentType: "application/json", msg: "no such resource", }, { err: statusWithDetails.Err(), status: http.StatusBadRequest, marshaler: &runtime.JSONPb{}, contentType: "application/json", msg: "failed precondition", details: "type.googleapis.com/google.rpc.PreconditionFailure", }, { err: errors.New("example error"), status: http.StatusInternalServerError, marshaler: &CustomMarshaler{&runtime.JSONPb{}}, contentType: "Custom-Content-Type", msg: "example error", }, { err: &runtime.HTTPStatusError{ HTTPStatus: http.StatusMethodNotAllowed, Err: status.Error(codes.Unimplemented, http.StatusText(http.StatusMethodNotAllowed)), }, status: http.StatusMethodNotAllowed, marshaler: &runtime.JSONPb{}, contentType: "application/json", msg: "Method Not Allowed", }, { err: status.Error(codes.InvalidArgument, "example error"), status: http.StatusBadRequest, marshaler: &runtime.JSONPb{}, contentType: "application/json", msg: "bad request: example error", fordwardRespRewriter: func(ctx context.Context, response proto.Message) (any, error) { if s, ok := response.(*statuspb.Status); ok && strings.HasPrefix(s.Message, "example") { return &statuspb.Status{ Code: s.Code, Message: "bad request: " + s.Message, Details: s.Details, }, nil } return response, nil }, }, } { t.Run(strconv.Itoa(i), func(t *testing.T) { w := httptest.NewRecorder() req, _ := http.NewRequestWithContext(ctx, "", "", nil) // Pass in an empty request to match the signature opts := []runtime.ServeMuxOption{} if spec.fordwardRespRewriter != nil { opts = append(opts, runtime.WithForwardResponseRewriter(spec.fordwardRespRewriter)) } mux := runtime.NewServeMux(opts...) runtime.HTTPError(ctx, mux, spec.marshaler, w, req, spec.err) if got, want := w.Header().Get("Content-Type"), spec.contentType; got != want { t.Errorf(`w.Header().Get("Content-Type") = %q; want %q; on spec.err=%v`, got, want, spec.err) } if got, want := w.Code, spec.status; got != want { t.Errorf("w.Code = %d; want %d", got, want) } var st statuspb.Status if err := spec.marshaler.Unmarshal(w.Body.Bytes(), &st); err != nil { t.Errorf("marshaler.Unmarshal(%q, &body) failed with %v; want success", w.Body.Bytes(), err) return } if got, want := st.Message, spec.msg; !strings.Contains(got, want) { t.Errorf(`st.Message = %q; want %q; on spec.err=%v`, got, want, spec.err) } if spec.details != "" { if len(st.Details) != 1 { t.Errorf(`len(st.Details) = %v; want 1`, len(st.Details)) return } if st.Details[0].TypeUrl != spec.details { t.Errorf(`details.type_url = %s; want %s`, st.Details[0].TypeUrl, spec.details) } } }) } } func TestHTTPStreamError(t *testing.T) { ctx := context.Background() for _, tc := range []struct { name string err error expectedStatus *status.Status expectedResponse []byte }{ { name: "Simple error", err: errors.New("simple error"), expectedStatus: status.New(codes.Unknown, "simple error"), expectedResponse: []byte(`{"error":{"code":2,"message":"simple error"}}`), }, { name: "Invalid request error", err: status.Error(codes.InvalidArgument, "invalid request"), expectedStatus: status.New(codes.InvalidArgument, "invalid request"), expectedResponse: []byte(`{"error":{"code":3,"message":"invalid request"}}`), }, } { t.Run(tc.name, func(t *testing.T) { w := httptest.NewRecorder() r := httptest.NewRequest("GET", "/", nil) mux := runtime.NewServeMux(runtime.WithStreamErrorHandler( runtime.DefaultStreamErrorHandler, )) marshaler := &runtime.JSONPb{} runtime.HTTPStreamError(ctx, mux, marshaler, w, r, tc.err) if w.Code != http.StatusOK { t.Errorf("Expected status code %d, got %d", http.StatusOK, w.Code) } if !proto.Equal(status.Convert(tc.err).Proto(), tc.expectedStatus.Proto()) { t.Errorf("Expected status %v, got %v", tc.expectedStatus, status.Convert(tc.err)) } if !bytes.Equal(w.Body.Bytes(), tc.expectedResponse) { t.Errorf("Expected response %s, got %s", tc.expectedResponse, w.Body.Bytes()) } }) } } ================================================ FILE: runtime/fieldmask.go ================================================ package runtime import ( "encoding/json" "errors" "fmt" "io" "sort" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" field_mask "google.golang.org/protobuf/types/known/fieldmaskpb" ) func getFieldByName(fields protoreflect.FieldDescriptors, name string) protoreflect.FieldDescriptor { fd := fields.ByName(protoreflect.Name(name)) if fd != nil { return fd } return fields.ByJSONName(name) } // FieldMaskFromRequestBody creates a FieldMask printing all complete paths from the JSON body. func FieldMaskFromRequestBody(r io.Reader, msg proto.Message) (*field_mask.FieldMask, error) { fm := &field_mask.FieldMask{} var root interface{} if err := json.NewDecoder(r).Decode(&root); err != nil { if errors.Is(err, io.EOF) { return fm, nil } return nil, err } queue := []fieldMaskPathItem{{node: root, msg: msg.ProtoReflect()}} for len(queue) > 0 { // dequeue an item item := queue[0] queue = queue[1:] m, ok := item.node.(map[string]interface{}) switch { case ok && len(m) > 0: // if the item is an object, then enqueue all of its children for k, v := range m { if item.msg == nil { return nil, errors.New("JSON structure did not match request type") } fd := getFieldByName(item.msg.Descriptor().Fields(), k) if fd == nil { return nil, fmt.Errorf("could not find field %q in %q", k, item.msg.Descriptor().FullName()) } if isDynamicProtoMessage(fd.Message()) { for _, p := range buildPathsBlindly(string(fd.FullName().Name()), v) { newPath := p if item.path != "" { newPath = item.path + "." + newPath } queue = append(queue, fieldMaskPathItem{path: newPath}) } continue } if isProtobufAnyMessage(fd.Message()) && !fd.IsList() { _, hasTypeField := v.(map[string]interface{})["@type"] if hasTypeField { queue = append(queue, fieldMaskPathItem{path: k}) continue } else { return nil, fmt.Errorf("could not find field @type in %q in message %q", k, item.msg.Descriptor().FullName()) } } child := fieldMaskPathItem{ node: v, } if item.path == "" { child.path = string(fd.FullName().Name()) } else { child.path = item.path + "." + string(fd.FullName().Name()) } switch { case fd.IsList(), fd.IsMap(): // As per: https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto#L85-L86 // Do not recurse into repeated fields. The repeated field goes on the end of the path and we stop. fm.Paths = append(fm.Paths, child.path) case fd.Message() != nil: child.msg = item.msg.Get(fd).Message() fallthrough default: queue = append(queue, child) } } case ok && len(m) == 0: fallthrough case len(item.path) > 0: // otherwise, it's a leaf node so print its path fm.Paths = append(fm.Paths, item.path) } } // Sort for deterministic output in the presence // of repeated fields. sort.Strings(fm.Paths) return fm, nil } func isProtobufAnyMessage(md protoreflect.MessageDescriptor) bool { return md != nil && (md.FullName() == "google.protobuf.Any") } func isDynamicProtoMessage(md protoreflect.MessageDescriptor) bool { return md != nil && (md.FullName() == "google.protobuf.Struct" || md.FullName() == "google.protobuf.Value") } // buildPathsBlindly does not attempt to match proto field names to the // json value keys. Instead it relies completely on the structure of // the unmarshalled json contained within in. // Returns a slice containing all subpaths with the root at the // passed in name and json value. func buildPathsBlindly(name string, in interface{}) []string { m, ok := in.(map[string]interface{}) if !ok { return []string{name} } var paths []string queue := []fieldMaskPathItem{{path: name, node: m}} for len(queue) > 0 { cur := queue[0] queue = queue[1:] m, ok := cur.node.(map[string]interface{}) if !ok { // This should never happen since we should always check that we only add // nodes of type map[string]interface{} to the queue. continue } for k, v := range m { if mi, ok := v.(map[string]interface{}); ok { queue = append(queue, fieldMaskPathItem{path: cur.path + "." + k, node: mi}) } else { // This is not a struct, so there are no more levels to descend. curPath := cur.path + "." + k paths = append(paths, curPath) } } } return paths } // fieldMaskPathItem stores an in-progress deconstruction of a path for a fieldmask type fieldMaskPathItem struct { // the list of prior fields leading up to node connected by dots path string // a generic decoded json object the current item to inspect for further path extraction node interface{} // parent message msg protoreflect.Message } ================================================ FILE: runtime/fieldmask_test.go ================================================ package runtime import ( "bytes" "errors" "testing" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime/internal/examplepb" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/testing/protocmp" field_mask "google.golang.org/protobuf/types/known/fieldmaskpb" ) func newFieldMask(paths ...string) *field_mask.FieldMask { return &field_mask.FieldMask{Paths: paths} } func TestFieldMaskFromRequestBody(t *testing.T) { for _, tc := range []struct { name string input string msg proto.Message expected *field_mask.FieldMask }{ { name: "empty", expected: newFieldMask(), }, { name: "EmptyMessage", msg: &examplepb.ABitOfEverything{}, input: `{"oneof_empty": {}}`, expected: newFieldMask("oneof_empty"), }, { name: "simple", msg: &examplepb.ABitOfEverything{}, input: `{"uuid":"1234", "floatValue":3.14}`, expected: newFieldMask("uuid", "float_value"), }, { name: "NonStandardMessage", msg: &examplepb.NonStandardMessage{}, input: `{"id":"foo", "thing":{"subThing":{"sub_value":"bar"}}}`, expected: newFieldMask("id", "thing.subThing.sub_value"), }, { name: "NonStandardMessageWithJSONNames", msg: &examplepb.NonStandardMessageWithJSONNames{}, input: `{"ID":"foo", "Thingy":{"SubThing":{"sub_Value":"bar"}}}`, expected: newFieldMask("id", "thing.subThing.sub_value"), }, { name: "nested", msg: &examplepb.ABitOfEverything{}, input: `{"single_nested": {"name":"bob", "amount": 2}, "uuid":"1234"}`, expected: newFieldMask("single_nested.name", "single_nested.amount", "uuid"), }, { name: "struct", msg: &examplepb.NonStandardMessage{}, input: `{"struct_field": {"name":{"first": "bob"}, "amount": 2}}`, expected: newFieldMask("struct_field.name.first", "struct_field.amount"), }, { name: "NonStandardMessageWithJSONNamesForStruct", msg: &examplepb.NonStandardMessage{}, input: `{"lineNum": 123, "structField": {"name":"bob"}}`, expected: newFieldMask("line_num", "struct_field.name"), }, { name: "value", msg: &examplepb.NonStandardMessage{}, input: `{"value_field": {"name":{"first": "bob"}, "amount": 2}}`, expected: newFieldMask("value_field.name.first", "value_field.amount"), }, { name: "map", msg: &examplepb.ABitOfEverything{}, input: `{"mapped_string_value": {"a": "x"}}`, expected: newFieldMask("mapped_string_value"), }, { name: "deeply-nested", msg: &examplepb.NestedOuter{}, input: `{"one":{"two":{"three":{"a":true, "b":false}}}}`, expected: newFieldMask("one.two.three.a", "one.two.three.b"), }, { name: "complex", input: ` { "single_nested": { "name": "bar", "amount": 10, "ok": "TRUE" }, "uuid": "6EC2446F-7E89-4127-B3E6-5C05E6BECBA7", "nested": [ { "name": "bar", "amount": 10 }, { "name": "baz", "amount": 20 } ], "float_value": 1.5, "double_value": 2.5, "int64_value": 4294967296, "int64_override_type": 12345, "int32_value": -2147483648, "uint64_value": 9223372036854775807, "uint32_value": 4294967295, "fixed64_value": 9223372036854775807, "fixed32_value": 4294967295, "sfixed64_value": -4611686018427387904, "sfixed32_value": 2147483647, "sint64_value": 4611686018427387903, "sint32_value": 2147483647, "bool_value": true, "string_value": "strprefix/foo", "bytes_value": "132456", "enum_value": "ONE", "oneof_string": "x", "nonConventionalNameValue": "camelCase", "timestamp_value": "2016-05-10T10:19:13.123Z", "enum_value_annotation": "ONE", "nested_annotation": { "name": "hoge", "amount": 10 } } `, msg: &examplepb.ABitOfEverything{}, expected: newFieldMask( "single_nested.name", "single_nested.amount", "single_nested.ok", "uuid", "float_value", "double_value", "int64_value", "int64_override_type", "int32_value", "uint64_value", "uint32_value", "fixed64_value", "fixed32_value", "sfixed64_value", "sfixed32_value", "sint64_value", "sint32_value", "bool_value", "string_value", "bytes_value", "enum_value", "oneof_string", "nonConventionalNameValue", "timestamp_value", "enum_value_annotation", "nested_annotation.name", "nested_annotation.amount", "nested", ), }, { name: "protobuf-any", msg: &examplepb.ABitOfEverything{}, input: `{"anytype":{"@type": "xx.xx/examplepb.NestedOuter", "one":{"two":{"three":{"a":true, "b":false}}}}}`, expected: newFieldMask("anytype"), //going deeper makes no sense }, { name: "repeated-protobuf-any", msg: &examplepb.ABitOfEverything{}, input: `{"repeated_anytype":[{"@type": "xx.xx/examplepb.NestedOuter", "one":{"two":{"three":{"a":true, "b":false}}}}]}`, expected: newFieldMask("repeated_anytype"), //going deeper makes no sense }, } { t.Run(tc.name, func(t *testing.T) { actual, err := FieldMaskFromRequestBody(bytes.NewReader([]byte(tc.input)), tc.msg) if err != nil { t.Fatalf("unexpected error: %v", err) } if diff := cmp.Diff(tc.expected, actual, protocmp.Transform(), cmpopts.SortSlices(func(x, y string) bool { return x < y })); diff != "" { t.Errorf("field masks differed:\n%s", diff) } }) } } func TestFieldMaskRepeatedFieldsLast(t *testing.T) { for _, tc := range []struct { name string input string expected *field_mask.FieldMask }{ { name: "map", input: `{"mapped_string_value": {"a": "x"}, "repeated_string_value": {"b": "y"}, "uuid":"1234"}`, expected: &field_mask.FieldMask{ Paths: []string{ "mapped_string_value", "repeated_string_value", "uuid", }, }, }, { name: "slice", input: ` { "nested": [ { "name": "bar", "amount": 10 }, { "name": "baz", "amount": 20 } ], "nested_annotation": [ { "name": "foo", "amount": 100 }, { "name": "widget", "amount": 200 } ], "uuid":"1234" }`, expected: &field_mask.FieldMask{ Paths: []string{ "nested", "nested_annotation", "uuid", }, }, }, } { t.Run(tc.name, func(t *testing.T) { actual, err := FieldMaskFromRequestBody(bytes.NewReader([]byte(tc.input)), &examplepb.ABitOfEverything{}) if err != nil { t.Fatalf("unexpected error: %v", err) } if diff := cmp.Diff(tc.expected, actual, protocmp.Transform()); diff != "" { t.Errorf("field masks differed:\n%s", diff) } }) } } func TestFieldMaskErrors(t *testing.T) { for _, tc := range []struct { name string input string expectedErr error }{ { name: "object under scalar", input: `{"uuid": {"a": "x"}}`, expectedErr: errors.New("JSON structure did not match request type"), }, } { t.Run(tc.name, func(t *testing.T) { _, err := FieldMaskFromRequestBody(bytes.NewReader([]byte(tc.input)), &examplepb.ABitOfEverything{}) if err.Error() != tc.expectedErr.Error() { t.Fatalf("errors did not match: got %q, wanted %q", err, tc.expectedErr) } }) } } // avoid compiler optimising benchmark away var result *field_mask.FieldMask func BenchmarkABEFieldMaskFromRequestBody(b *testing.B) { input := `{` + `"single_nested": {"name": "bar",` + ` "amount": 10,` + ` "ok": "TRUE"},` + `"uuid": "6EC2446F-7E89-4127-B3E6-5C05E6BECBA7",` + `"nested": [{"name": "bar",` + ` "amount": 10},` + ` {"name": "baz",` + ` "amount": 20}],` + `"float_value": 1.5,` + `"double_value": 2.5,` + `"int64_value": 4294967296,` + `"uint64_value": 9223372036854775807,` + `"int32_value": -2147483648,` + `"fixed64_value": 9223372036854775807,` + `"fixed32_value": 4294967295,` + `"bool_value": true,` + `"string_value": "strprefix/foo",` + `"bytes_value": "132456",` + `"uint32_value": 4294967295,` + `"enum_value": "ONE",` + `"path_enum_value": "DEF",` + `"nested_path_enum_value": "JKL",` + `"sfixed32_value": 2147483647,` + `"sfixed64_value": -4611686018427387904,` + `"sint32_value": 2147483647,` + `"sint64_value": 4611686018427387903,` + `"repeated_string_value": ["a", "b", "c"],` + `"oneof_value": {"oneof_string":"x"},` + `"map_value": {"a": "ONE",` + ` "b": "ZERO"},` + `"mapped_string_value": {"a": "x",` + ` "b": "y"},` + `"mapped_nested_value": {"a": {"name": "x", "amount": 1},` + ` "b": {"name": "y", "amount": 2}},` + `"nonConventionalNameValue": "camelCase",` + `"timestamp_value": "2016-05-10T10:19:13.123Z",` + `"repeated_enum_value": ["ONE", "ZERO"],` + `"repeated_enum_annotation": ["ONE", "ZERO"],` + `"enum_value_annotation": "ONE",` + `"repeated_string_annotation": ["a", "b"],` + `"repeated_nested_annotation": [{"name": "hoge",` + ` "amount": 10},` + ` {"name": "fuga",` + ` "amount": 20}],` + `"nested_annotation": {"name": "hoge",` + ` "amount": 10},` + `"int64_override_type": 12345` + `}` var r *field_mask.FieldMask var err error for i := 0; i < b.N; i++ { r, err = FieldMaskFromRequestBody(bytes.NewReader([]byte(input)), nil) } if err != nil { b.Error(err) } result = r } func BenchmarkNonStandardFieldMaskFromRequestBody(b *testing.B) { input := `{` + `"id": "foo",` + `"Num": 2,` + `"line_num": 3,` + `"langIdent": "bar",` + `"STATUS": "baz"` + `}` var r *field_mask.FieldMask var err error for i := 0; i < b.N; i++ { r, err = FieldMaskFromRequestBody(bytes.NewReader([]byte(input)), nil) } if err != nil { b.Error(err) } result = r } ================================================ FILE: runtime/handler.go ================================================ package runtime import ( "context" "errors" "fmt" "io" "net/http" "net/textproto" "strconv" "strings" "google.golang.org/genproto/googleapis/api/httpbody" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) // ForwardResponseStream forwards the stream from gRPC server to REST client. func ForwardResponseStream(ctx context.Context, mux *ServeMux, marshaler Marshaler, w http.ResponseWriter, req *http.Request, recv func() (proto.Message, error), opts ...func(context.Context, http.ResponseWriter, proto.Message) error) { rc := http.NewResponseController(w) md, ok := ServerMetadataFromContext(ctx) if !ok { grpclog.Error("Failed to extract ServerMetadata from context") http.Error(w, "unexpected error", http.StatusInternalServerError) return } handleForwardResponseServerMetadata(w, mux, md) if !mux.disableChunkedEncoding { w.Header().Set("Transfer-Encoding", "chunked") } if err := handleForwardResponseOptions(ctx, w, nil, opts); err != nil { HTTPError(ctx, mux, marshaler, w, req, err) return } var delimiter []byte if d, ok := marshaler.(Delimited); ok { delimiter = d.Delimiter() } else { delimiter = []byte("\n") } var wroteHeader bool for { resp, err := recv() if errors.Is(err, io.EOF) { return } if err != nil { handleForwardResponseStreamError(ctx, wroteHeader, marshaler, w, req, mux, err, delimiter) return } if err := handleForwardResponseOptions(ctx, w, resp, opts); err != nil { handleForwardResponseStreamError(ctx, wroteHeader, marshaler, w, req, mux, err, delimiter) return } respRw, err := mux.forwardResponseRewriter(ctx, resp) if err != nil { grpclog.Errorf("Rewrite error: %v", err) handleForwardResponseStreamError(ctx, wroteHeader, marshaler, w, req, mux, err, delimiter) return } if !wroteHeader { var contentType string if sct, ok := marshaler.(StreamContentType); ok { contentType = sct.StreamContentType(respRw) } else { contentType = marshaler.ContentType(respRw) } w.Header().Set("Content-Type", contentType) } var buf []byte httpBody, isHTTPBody := respRw.(*httpbody.HttpBody) switch { case respRw == nil: buf, err = marshaler.Marshal(errorChunk(status.New(codes.Internal, "empty response"))) case isHTTPBody: buf = httpBody.GetData() default: result := map[string]interface{}{"result": respRw} if rb, ok := respRw.(responseBody); ok { result["result"] = rb.XXX_ResponseBody() } buf, err = marshaler.Marshal(result) } if err != nil { grpclog.Errorf("Failed to marshal response chunk: %v", err) handleForwardResponseStreamError(ctx, wroteHeader, marshaler, w, req, mux, err, delimiter) return } if _, err := w.Write(buf); err != nil { grpclog.Errorf("Failed to send response chunk: %v", err) return } wroteHeader = true if _, err := w.Write(delimiter); err != nil { grpclog.Errorf("Failed to send delimiter chunk: %v", err) return } err = rc.Flush() if err != nil { if errors.Is(err, http.ErrNotSupported) { grpclog.Errorf("Flush not supported in %T", w) http.Error(w, "unexpected type of web server", http.StatusInternalServerError) return } grpclog.Errorf("Failed to flush response to client: %v", err) return } } } func handleForwardResponseServerMetadata(w http.ResponseWriter, mux *ServeMux, md ServerMetadata) { for k, vs := range md.HeaderMD { if h, ok := mux.outgoingHeaderMatcher(k); ok { for _, v := range vs { w.Header().Add(h, v) } } } } func handleForwardResponseTrailerHeader(w http.ResponseWriter, mux *ServeMux, md ServerMetadata) { for k := range md.TrailerMD { if h, ok := mux.outgoingTrailerMatcher(k); ok { w.Header().Add("Trailer", textproto.CanonicalMIMEHeaderKey(h)) } } } func handleForwardResponseTrailer(w http.ResponseWriter, mux *ServeMux, md ServerMetadata) { for k, vs := range md.TrailerMD { if h, ok := mux.outgoingTrailerMatcher(k); ok { for _, v := range vs { w.Header().Add(h, v) } } } } // responseBody interface contains method for getting field for marshaling to the response body // this method is generated for response struct from the value of `response_body` in the `google.api.HttpRule` type responseBody interface { XXX_ResponseBody() interface{} } // ForwardResponseMessage forwards the message "resp" from gRPC server to REST client. func ForwardResponseMessage(ctx context.Context, mux *ServeMux, marshaler Marshaler, w http.ResponseWriter, req *http.Request, resp proto.Message, opts ...func(context.Context, http.ResponseWriter, proto.Message) error) { md, ok := ServerMetadataFromContext(ctx) if ok { handleForwardResponseServerMetadata(w, mux, md) } // RFC 7230 https://tools.ietf.org/html/rfc7230#section-4.1.2 // Unless the request includes a TE header field indicating "trailers" // is acceptable, as described in Section 4.3, a server SHOULD NOT // generate trailer fields that it believes are necessary for the user // agent to receive. doForwardTrailers := requestAcceptsTrailers(req) if ok && doForwardTrailers { handleForwardResponseTrailerHeader(w, mux, md) w.Header().Set("Transfer-Encoding", "chunked") } contentType := marshaler.ContentType(resp) w.Header().Set("Content-Type", contentType) if err := handleForwardResponseOptions(ctx, w, resp, opts); err != nil { HTTPError(ctx, mux, marshaler, w, req, err) return } respRw, err := mux.forwardResponseRewriter(ctx, resp) if err != nil { grpclog.Errorf("Rewrite error: %v", err) HTTPError(ctx, mux, marshaler, w, req, err) return } var buf []byte if rb, ok := respRw.(responseBody); ok { buf, err = marshaler.Marshal(rb.XXX_ResponseBody()) } else { buf, err = marshaler.Marshal(respRw) } if err != nil { grpclog.Errorf("Marshal error: %v", err) HTTPError(ctx, mux, marshaler, w, req, err) return } if !doForwardTrailers && mux.writeContentLength { w.Header().Set("Content-Length", strconv.Itoa(len(buf))) } if _, err = w.Write(buf); err != nil && !errors.Is(err, http.ErrBodyNotAllowed) { grpclog.Errorf("Failed to write response: %v", err) } if ok && doForwardTrailers { handleForwardResponseTrailer(w, mux, md) } } func requestAcceptsTrailers(req *http.Request) bool { te := req.Header.Get("TE") return strings.Contains(strings.ToLower(te), "trailers") } func handleForwardResponseOptions(ctx context.Context, w http.ResponseWriter, resp proto.Message, opts []func(context.Context, http.ResponseWriter, proto.Message) error) error { if len(opts) == 0 { return nil } for _, opt := range opts { if err := opt(ctx, w, resp); err != nil { return fmt.Errorf("error handling ForwardResponseOptions: %w", err) } } return nil } func handleForwardResponseStreamError(ctx context.Context, wroteHeader bool, marshaler Marshaler, w http.ResponseWriter, req *http.Request, mux *ServeMux, err error, delimiter []byte) { st := mux.streamErrorHandler(ctx, err) msg := errorChunk(st) if !wroteHeader { w.Header().Set("Content-Type", marshaler.ContentType(msg)) w.WriteHeader(HTTPStatusFromCode(st.Code())) } buf, err := marshaler.Marshal(msg) if err != nil { grpclog.Errorf("Failed to marshal an error: %v", err) return } if _, err := w.Write(buf); err != nil { grpclog.Errorf("Failed to notify error to client: %v", err) return } if _, err := w.Write(delimiter); err != nil { grpclog.Errorf("Failed to send delimiter chunk: %v", err) return } } func errorChunk(st *status.Status) map[string]proto.Message { return map[string]proto.Message{"error": st.Proto()} } ================================================ FILE: runtime/handler_test.go ================================================ package runtime_test import ( "context" "io" "net/http" "net/http/httptest" "reflect" "sort" "testing" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" pb "github.com/grpc-ecosystem/grpc-gateway/v2/runtime/internal/examplepb" "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) type fakeResponseBodyWrapper struct { proto.Message } // XXX_ResponseBody returns id of SimpleMessage func (r fakeResponseBodyWrapper) XXX_ResponseBody() interface{} { resp := r.Message.(*pb.SimpleMessage) return resp.Id } func TestForwardResponseStream(t *testing.T) { type msg struct { pb proto.Message err error } tests := []struct { name string msgs []msg statusCode int responseBody bool disableChunkedEncoding bool }{{ name: "encoding", msgs: []msg{ {&pb.SimpleMessage{Id: "One"}, nil}, {&pb.SimpleMessage{Id: "Two"}, nil}, }, statusCode: http.StatusOK, }, { name: "empty", statusCode: http.StatusOK, }, { name: "error", msgs: []msg{{nil, status.Errorf(codes.OutOfRange, "400")}}, statusCode: http.StatusBadRequest, }, { name: "stream_error", msgs: []msg{ {&pb.SimpleMessage{Id: "One"}, nil}, {nil, status.Errorf(codes.OutOfRange, "400")}, }, statusCode: http.StatusOK, }, { name: "response body stream case", msgs: []msg{ {fakeResponseBodyWrapper{&pb.SimpleMessage{Id: "One"}}, nil}, {fakeResponseBodyWrapper{&pb.SimpleMessage{Id: "Two"}}, nil}, }, responseBody: true, statusCode: http.StatusOK, }, { name: "response body stream error case", msgs: []msg{ {fakeResponseBodyWrapper{&pb.SimpleMessage{Id: "One"}}, nil}, {nil, status.Errorf(codes.OutOfRange, "400")}, }, responseBody: true, statusCode: http.StatusOK, }, { name: "disable chunked encoding", msgs: []msg{ {&pb.SimpleMessage{Id: "One"}, nil}, }, statusCode: http.StatusOK, disableChunkedEncoding: true, }} newTestRecv := func(t *testing.T, msgs []msg) func() (proto.Message, error) { var count int return func() (proto.Message, error) { if count == len(msgs) { return nil, io.EOF } else if count > len(msgs) { t.Errorf("recv() called %d times for %d messages", count, len(msgs)) } count++ msg := msgs[count-1] return msg.pb, msg.err } } ctx := runtime.NewServerMetadataContext(context.Background(), runtime.ServerMetadata{}) marshaler := &runtime.JSONPb{} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { recv := newTestRecv(t, tt.msgs) req := httptest.NewRequest("GET", "http://example.com/foo", nil) resp := httptest.NewRecorder() mux := runtime.NewServeMux() if tt.disableChunkedEncoding { mux = runtime.NewServeMux(runtime.WithDisableChunkedEncoding()) } runtime.ForwardResponseStream(ctx, mux, marshaler, resp, req, recv) w := resp.Result() if w.StatusCode != tt.statusCode { t.Errorf("StatusCode %d want %d", w.StatusCode, tt.statusCode) } if !tt.disableChunkedEncoding { if h := w.Header.Get("Transfer-Encoding"); h != "chunked" { t.Errorf("ForwardResponseStream missing header chunked") } } else { if h := w.Header.Get("Transfer-Encoding"); h != "" { t.Errorf("ForwardResponseStream unexpected Transfer-Encoding header %s", h) } } body, err := io.ReadAll(w.Body) if err != nil { t.Errorf("Failed to read response body with %v", err) } w.Body.Close() if len(body) > 0 && w.Header.Get("Content-Type") != "application/json" { t.Errorf("Content-Type %s want application/json", w.Header.Get("Content-Type")) } var want []byte for i, msg := range tt.msgs { if msg.err != nil { if i == 0 { // Skip non-stream errors t.Skip("checking error encodings") } delimiter := marshaler.Delimiter() st := status.Convert(msg.err) b, err := marshaler.Marshal(map[string]proto.Message{ "error": st.Proto(), }) if err != nil { t.Errorf("marshaler.Marshal() failed %v", err) } errBytes := body[len(want):] if string(errBytes) != string(b)+string(delimiter) { t.Errorf("ForwardResponseStream() = \"%s\" want \"%s\"", errBytes, b) } return } var b []byte if tt.responseBody { // responseBody interface is in runtime package and test is in runtime_test package. hence can't use responseBody directly // So type casting to fakeResponseBodyWrapper struct to verify the data. rb, ok := msg.pb.(fakeResponseBodyWrapper) if !ok { t.Errorf("stream responseBody failed %v", err) } b, err = marshaler.Marshal(map[string]interface{}{"result": rb.XXX_ResponseBody()}) } else { b, err = marshaler.Marshal(map[string]interface{}{"result": msg.pb}) } if err != nil { t.Errorf("marshaler.Marshal() failed %v", err) } want = append(want, b...) want = append(want, marshaler.Delimiter()...) } if string(body) != string(want) { t.Errorf("ForwardResponseStream() = \"%s\" want \"%s\"", body, want) } }) } } // A custom marshaler implementation, that doesn't implement the delimited interface type CustomMarshaler struct { m *runtime.JSONPb } func (c *CustomMarshaler) Marshal(v interface{}) ([]byte, error) { return c.m.Marshal(v) } func (c *CustomMarshaler) Unmarshal(data []byte, v interface{}) error { return c.m.Unmarshal(data, v) } func (c *CustomMarshaler) NewDecoder(r io.Reader) runtime.Decoder { return c.m.NewDecoder(r) } func (c *CustomMarshaler) NewEncoder(w io.Writer) runtime.Encoder { return c.m.NewEncoder(w) } func (c *CustomMarshaler) ContentType(v interface{}) string { return "Custom-Content-Type" } // marshalerStreamContentType implements Marshaler, but with the addition of a custom StreamContentType. type marshalerStreamContentType struct { runtime.Marshaler CustomStreamContentType string } func (m marshalerStreamContentType) StreamContentType(interface{}) string { return m.CustomStreamContentType } func TestForwardResponseStreamCustomMarshaler(t *testing.T) { type msg struct { pb proto.Message err error } marshaler := &CustomMarshaler{&runtime.JSONPb{}} tests := []struct { name string marshaler runtime.Marshaler msgs []msg statusCode int wantContentType string }{{ name: "encoding", marshaler: marshaler, msgs: []msg{ {&pb.SimpleMessage{Id: "One"}, nil}, {&pb.SimpleMessage{Id: "Two"}, nil}, }, statusCode: http.StatusOK, wantContentType: "Custom-Content-Type", }, { name: "empty", marshaler: marshaler, statusCode: http.StatusOK, }, { name: "error", marshaler: marshaler, msgs: []msg{{nil, status.Errorf(codes.OutOfRange, "400")}}, statusCode: http.StatusBadRequest, wantContentType: "Custom-Content-Type", }, { name: "stream_error", marshaler: marshaler, msgs: []msg{ {&pb.SimpleMessage{Id: "One"}, nil}, {nil, status.Errorf(codes.OutOfRange, "400")}, }, statusCode: http.StatusOK, wantContentType: "Custom-Content-Type", }, { name: "stream_content_type", marshaler: marshalerStreamContentType{ Marshaler: marshaler, CustomStreamContentType: "Stream-Content-Type", }, msgs: []msg{ {&pb.SimpleMessage{Id: "One"}, nil}, }, statusCode: http.StatusOK, wantContentType: "Stream-Content-Type", }} newTestRecv := func(t *testing.T, msgs []msg) func() (proto.Message, error) { var count int return func() (proto.Message, error) { if count == len(msgs) { return nil, io.EOF } else if count > len(msgs) { t.Errorf("recv() called %d times for %d messages", count, len(msgs)) } count++ msg := msgs[count-1] return msg.pb, msg.err } } ctx := runtime.NewServerMetadataContext(context.Background(), runtime.ServerMetadata{}) for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { recv := newTestRecv(t, tt.msgs) req := httptest.NewRequest("GET", "http://example.com/foo", nil) resp := httptest.NewRecorder() runtime.ForwardResponseStream(ctx, runtime.NewServeMux(), tt.marshaler, resp, req, recv) w := resp.Result() if w.StatusCode != tt.statusCode { t.Errorf("StatusCode %d want %d", w.StatusCode, tt.statusCode) } if h := w.Header.Get("Transfer-Encoding"); h != "chunked" { t.Errorf("ForwardResponseStream missing header chunked") } body, err := io.ReadAll(w.Body) if err != nil { t.Errorf("Failed to read response body with %v", err) } w.Body.Close() if w.Header.Get("Content-Type") != tt.wantContentType { t.Errorf("Content-Type %q want %q", w.Header.Get("Content-Type"), tt.wantContentType) } var want []byte for _, msg := range tt.msgs { if msg.err != nil { t.Skip("checking error encodings") } b, err := tt.marshaler.Marshal(map[string]proto.Message{"result": msg.pb}) if err != nil { t.Errorf("marshaler.Marshal() failed %v", err) } want = append(want, b...) want = append(want, "\n"...) } if string(body) != string(want) { t.Errorf("ForwardResponseStream() = \"%s\" want \"%s\"", body, want) } }) } } func TestForwardResponseMessage(t *testing.T) { msg := &pb.SimpleMessage{Id: "One"} tests := []struct { name string marshaler runtime.Marshaler contentType string frw runtime.ForwardResponseRewriter getWantedResponse func(msg any) ([]byte, error) }{{ name: "standard marshaler", marshaler: &runtime.JSONPb{}, contentType: "application/json", }, { name: "httpbody marshaler", marshaler: &runtime.HTTPBodyMarshaler{&runtime.JSONPb{}}, contentType: "application/json", }, { name: "custom marshaler", marshaler: &CustomMarshaler{&runtime.JSONPb{}}, contentType: "Custom-Content-Type", }, { name: "custom forward response rewriter", marshaler: &runtime.JSONPb{}, contentType: "application/json", frw: func(ctx context.Context, response proto.Message) (any, error) { return map[string]any{ "ok": true, "data": response, }, nil }, getWantedResponse: func(msg any) ([]byte, error) { return new(runtime.JSONPb).Marshal(map[string]any{"ok": true, "data": msg}) }, }} ctx := runtime.NewServerMetadataContext(context.Background(), runtime.ServerMetadata{}) for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { req := httptest.NewRequest("GET", "http://example.com/foo", nil) resp := httptest.NewRecorder() opts := []runtime.ServeMuxOption{} if tt.frw != nil { opts = append(opts, runtime.WithForwardResponseRewriter(tt.frw)) } runtime.ForwardResponseMessage(ctx, runtime.NewServeMux(opts...), tt.marshaler, resp, req, msg) w := resp.Result() if w.StatusCode != http.StatusOK { t.Errorf("StatusCode %d want %d", w.StatusCode, http.StatusOK) } if h := w.Header.Get("Content-Type"); h != tt.contentType { t.Errorf("Content-Type %v want %v", h, tt.contentType) } body, err := io.ReadAll(w.Body) if err != nil { t.Errorf("Failed to read response body with %v", err) } w.Body.Close() if tt.getWantedResponse == nil { tt.getWantedResponse = tt.marshaler.Marshal } want, err := tt.getWantedResponse(msg) if err != nil { t.Errorf("marshaler.Marshal() failed %v", err) } if string(body) != string(want) { t.Errorf("ForwardResponseMessage() = \"%s\" want \"%s\"", body, want) } }) } } func TestOutgoingHeaderMatcher(t *testing.T) { t.Parallel() msg := &pb.SimpleMessage{Id: "foo"} for _, tc := range []struct { name string md runtime.ServerMetadata headers http.Header matcher runtime.HeaderMatcherFunc }{ { name: "default matcher", md: runtime.ServerMetadata{ HeaderMD: metadata.Pairs( "foo", "bar", "baz", "qux", ), }, headers: http.Header{ "Content-Type": []string{"application/json"}, "Grpc-Metadata-Foo": []string{"bar"}, "Grpc-Metadata-Baz": []string{"qux"}, }, }, { name: "custom matcher", md: runtime.ServerMetadata{ HeaderMD: metadata.Pairs( "foo", "bar", "baz", "qux", ), }, headers: http.Header{ "Content-Type": []string{"application/json"}, "Custom-Foo": []string{"bar"}, }, matcher: func(key string) (string, bool) { switch key { case "foo": return "custom-foo", true default: return "", false } }, }, } { tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() ctx := runtime.NewServerMetadataContext(context.Background(), tc.md) req := httptest.NewRequest("GET", "http://example.com/foo", nil) resp := httptest.NewRecorder() mux := runtime.NewServeMux( runtime.WithOutgoingHeaderMatcher(tc.matcher), ) runtime.ForwardResponseMessage(ctx, mux, &runtime.JSONPb{}, resp, req, msg) w := resp.Result() defer w.Body.Close() if w.StatusCode != http.StatusOK { t.Fatalf("StatusCode %d want %d", w.StatusCode, http.StatusOK) } if !reflect.DeepEqual(w.Header, tc.headers) { t.Fatalf("Header %v want %v", w.Header, tc.headers) } }) } } func TestOutgoingHeaderMatcherWithContentLength(t *testing.T) { t.Parallel() msg := &pb.SimpleMessage{Id: "foo"} for _, tc := range []struct { name string md runtime.ServerMetadata headers http.Header matcher runtime.HeaderMatcherFunc }{ { name: "default matcher", md: runtime.ServerMetadata{ HeaderMD: metadata.Pairs( "foo", "bar", "baz", "qux", ), }, headers: http.Header{ "Content-Length": []string{"12"}, "Content-Type": []string{"application/json"}, "Grpc-Metadata-Foo": []string{"bar"}, "Grpc-Metadata-Baz": []string{"qux"}, }, }, { name: "custom matcher", md: runtime.ServerMetadata{ HeaderMD: metadata.Pairs( "foo", "bar", "baz", "qux", ), }, headers: http.Header{ "Content-Length": []string{"12"}, "Content-Type": []string{"application/json"}, "Custom-Foo": []string{"bar"}, }, matcher: func(key string) (string, bool) { switch key { case "foo": return "custom-foo", true default: return "", false } }, }, } { tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() ctx := runtime.NewServerMetadataContext(context.Background(), tc.md) req := httptest.NewRequest("GET", "http://example.com/foo", nil) resp := httptest.NewRecorder() mux := runtime.NewServeMux( runtime.WithOutgoingHeaderMatcher(tc.matcher), runtime.WithWriteContentLength(), ) runtime.ForwardResponseMessage(ctx, mux, &runtime.JSONPb{}, resp, req, msg) w := resp.Result() defer w.Body.Close() if w.StatusCode != http.StatusOK { t.Fatalf("StatusCode %d want %d", w.StatusCode, http.StatusOK) } if !reflect.DeepEqual(w.Header, tc.headers) { t.Fatalf("Header %v want %v", w.Header, tc.headers) } }) } } func TestOutgoingTrailerMatcher(t *testing.T) { t.Parallel() msg := &pb.SimpleMessage{Id: "foo"} for _, tc := range []struct { name string md runtime.ServerMetadata caller http.Header headers http.Header trailer http.Header matcher runtime.HeaderMatcherFunc }{ { name: "default matcher, caller accepts", md: runtime.ServerMetadata{ TrailerMD: metadata.Pairs( "foo", "bar", "baz", "qux", ), }, caller: http.Header{ "Te": []string{"trailers"}, }, headers: http.Header{ "Transfer-Encoding": []string{"chunked"}, "Content-Type": []string{"application/json"}, "Trailer": []string{"Grpc-Trailer-Baz", "Grpc-Trailer-Foo"}, }, trailer: http.Header{ "Grpc-Trailer-Foo": []string{"bar"}, "Grpc-Trailer-Baz": []string{"qux"}, }, }, { name: "default matcher, caller rejects", md: runtime.ServerMetadata{ TrailerMD: metadata.Pairs( "foo", "bar", "baz", "qux", ), }, headers: http.Header{ "Content-Length": []string{"12"}, "Content-Type": []string{"application/json"}, }, }, { name: "custom matcher", md: runtime.ServerMetadata{ TrailerMD: metadata.Pairs( "foo", "bar", "baz", "qux", ), }, caller: http.Header{ "Te": []string{"trailers"}, }, headers: http.Header{ "Transfer-Encoding": []string{"chunked"}, "Content-Type": []string{"application/json"}, "Trailer": []string{"Custom-Trailer-Foo"}, }, trailer: http.Header{ "Custom-Trailer-Foo": []string{"bar"}, }, matcher: func(key string) (string, bool) { switch key { case "foo": return "custom-trailer-foo", true default: return "", false } }, }, } { tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() ctx := runtime.NewServerMetadataContext(context.Background(), tc.md) req := httptest.NewRequest("GET", "http://example.com/foo", nil) req.Header = tc.caller resp := httptest.NewRecorder() mux := runtime.NewServeMux( runtime.WithOutgoingTrailerMatcher(tc.matcher), runtime.WithWriteContentLength(), ) runtime.ForwardResponseMessage(ctx, mux, &runtime.JSONPb{}, resp, req, msg) w := resp.Result() _, _ = io.Copy(io.Discard, w.Body) defer w.Body.Close() if w.StatusCode != http.StatusOK { t.Fatalf("StatusCode %d want %d", w.StatusCode, http.StatusOK) } // Sort to the trailer headers to ensure the test is deterministic sort.Strings(w.Header["Trailer"]) if !reflect.DeepEqual(w.Header, tc.headers) { t.Fatalf("Header %v want %v", w.Header, tc.headers) } if !reflect.DeepEqual(w.Trailer, tc.trailer) { t.Fatalf("Trailer %v want %v", w.Trailer, tc.trailer) } }) } } ================================================ FILE: runtime/internal/examplepb/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library") load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") load("@rules_proto//proto:defs.bzl", "proto_library") # gazelle:exclude non_standard_names_grpc.pb.go package(default_visibility = ["//visibility:public"]) proto_library( name = "examplepb_proto", srcs = [ "example.proto", "non_standard_names.proto", "proto2.proto", "proto3.proto", ], deps = [ "@com_google_protobuf//:any_proto", "@com_google_protobuf//:duration_proto", "@com_google_protobuf//:empty_proto", "@com_google_protobuf//:field_mask_proto", "@com_google_protobuf//:struct_proto", "@com_google_protobuf//:timestamp_proto", "@com_google_protobuf//:wrappers_proto", "@googleapis//google/api:annotations_proto", ], ) go_proto_library( name = "examplepb_go_proto", compilers = [ "//:go_apiv2", "//:go_grpc", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/runtime/internal/examplepb", proto = ":examplepb_proto", deps = [ "@org_golang_google_genproto_googleapis_api//annotations", ], ) go_library( name = "examplepb", embed = [":examplepb_go_proto"], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/runtime/internal/examplepb", ) alias( name = "go_default_library", actual = ":examplepb", visibility = ["//runtime:__subpackages__"], ) ================================================ FILE: runtime/internal/examplepb/example.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: runtime/internal/examplepb/example.proto package examplepb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" emptypb "google.golang.org/protobuf/types/known/emptypb" fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" timestamppb "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) // NumericEnum is one or zero. type NumericEnum int32 const ( // ZERO means 0 NumericEnum_ZERO NumericEnum = 0 // ONE means 1 NumericEnum_ONE NumericEnum = 1 ) // Enum value maps for NumericEnum. var ( NumericEnum_name = map[int32]string{ 0: "ZERO", 1: "ONE", } NumericEnum_value = map[string]int32{ "ZERO": 0, "ONE": 1, } ) func (x NumericEnum) Enum() *NumericEnum { p := new(NumericEnum) *p = x return p } func (x NumericEnum) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (NumericEnum) Descriptor() protoreflect.EnumDescriptor { return file_runtime_internal_examplepb_example_proto_enumTypes[0].Descriptor() } func (NumericEnum) Type() protoreflect.EnumType { return &file_runtime_internal_examplepb_example_proto_enumTypes[0] } func (x NumericEnum) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use NumericEnum.Descriptor instead. func (NumericEnum) EnumDescriptor() ([]byte, []int) { return file_runtime_internal_examplepb_example_proto_rawDescGZIP(), []int{0} } // DeepEnum is one or zero. type ABitOfEverything_Nested_DeepEnum int32 const ( // FALSE is false. ABitOfEverything_Nested_FALSE ABitOfEverything_Nested_DeepEnum = 0 // TRUE is true. ABitOfEverything_Nested_TRUE ABitOfEverything_Nested_DeepEnum = 1 ) // Enum value maps for ABitOfEverything_Nested_DeepEnum. var ( ABitOfEverything_Nested_DeepEnum_name = map[int32]string{ 0: "FALSE", 1: "TRUE", } ABitOfEverything_Nested_DeepEnum_value = map[string]int32{ "FALSE": 0, "TRUE": 1, } ) func (x ABitOfEverything_Nested_DeepEnum) Enum() *ABitOfEverything_Nested_DeepEnum { p := new(ABitOfEverything_Nested_DeepEnum) *p = x return p } func (x ABitOfEverything_Nested_DeepEnum) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (ABitOfEverything_Nested_DeepEnum) Descriptor() protoreflect.EnumDescriptor { return file_runtime_internal_examplepb_example_proto_enumTypes[1].Descriptor() } func (ABitOfEverything_Nested_DeepEnum) Type() protoreflect.EnumType { return &file_runtime_internal_examplepb_example_proto_enumTypes[1] } func (x ABitOfEverything_Nested_DeepEnum) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use ABitOfEverything_Nested_DeepEnum.Descriptor instead. func (ABitOfEverything_Nested_DeepEnum) EnumDescriptor() ([]byte, []int) { return file_runtime_internal_examplepb_example_proto_rawDescGZIP(), []int{1, 0, 0} } type RepeatedResponseBodyOut_Response_ResponseType int32 const ( // UNKNOWN RepeatedResponseBodyOut_Response_UNKNOWN RepeatedResponseBodyOut_Response_ResponseType = 0 // A is 1 RepeatedResponseBodyOut_Response_A RepeatedResponseBodyOut_Response_ResponseType = 1 // B is 2 RepeatedResponseBodyOut_Response_B RepeatedResponseBodyOut_Response_ResponseType = 2 ) // Enum value maps for RepeatedResponseBodyOut_Response_ResponseType. var ( RepeatedResponseBodyOut_Response_ResponseType_name = map[int32]string{ 0: "UNKNOWN", 1: "A", 2: "B", } RepeatedResponseBodyOut_Response_ResponseType_value = map[string]int32{ "UNKNOWN": 0, "A": 1, "B": 2, } ) func (x RepeatedResponseBodyOut_Response_ResponseType) Enum() *RepeatedResponseBodyOut_Response_ResponseType { p := new(RepeatedResponseBodyOut_Response_ResponseType) *p = x return p } func (x RepeatedResponseBodyOut_Response_ResponseType) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (RepeatedResponseBodyOut_Response_ResponseType) Descriptor() protoreflect.EnumDescriptor { return file_runtime_internal_examplepb_example_proto_enumTypes[2].Descriptor() } func (RepeatedResponseBodyOut_Response_ResponseType) Type() protoreflect.EnumType { return &file_runtime_internal_examplepb_example_proto_enumTypes[2] } func (x RepeatedResponseBodyOut_Response_ResponseType) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use RepeatedResponseBodyOut_Response_ResponseType.Descriptor instead. func (RepeatedResponseBodyOut_Response_ResponseType) EnumDescriptor() ([]byte, []int) { return file_runtime_internal_examplepb_example_proto_rawDescGZIP(), []int{3, 0, 0} } // SimpleMessage represents a simple message sent to the Echo service. type SimpleMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` } func (x *SimpleMessage) Reset() { *x = SimpleMessage{} mi := &file_runtime_internal_examplepb_example_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *SimpleMessage) String() string { return protoimpl.X.MessageStringOf(x) } func (*SimpleMessage) ProtoMessage() {} func (x *SimpleMessage) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_example_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use SimpleMessage.ProtoReflect.Descriptor instead. func (*SimpleMessage) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_example_proto_rawDescGZIP(), []int{0} } func (x *SimpleMessage) GetId() string { if x != nil { return x.Id } return "" } type ABitOfEverything struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields SingleNested *ABitOfEverything_Nested `protobuf:"bytes,25,opt,name=single_nested,json=singleNested,proto3" json:"single_nested,omitempty"` Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` Nested []*ABitOfEverything_Nested `protobuf:"bytes,2,rep,name=nested,proto3" json:"nested,omitempty"` FloatValue float32 `protobuf:"fixed32,3,opt,name=float_value,json=floatValue,proto3" json:"float_value,omitempty"` DoubleValue float64 `protobuf:"fixed64,4,opt,name=double_value,json=doubleValue,proto3" json:"double_value,omitempty"` Int64Value int64 `protobuf:"varint,5,opt,name=int64_value,json=int64Value,proto3" json:"int64_value,omitempty"` Uint64Value uint64 `protobuf:"varint,6,opt,name=uint64_value,json=uint64Value,proto3" json:"uint64_value,omitempty"` Int32Value int32 `protobuf:"varint,7,opt,name=int32_value,json=int32Value,proto3" json:"int32_value,omitempty"` Fixed64Value uint64 `protobuf:"fixed64,8,opt,name=fixed64_value,json=fixed64Value,proto3" json:"fixed64_value,omitempty"` Fixed32Value uint32 `protobuf:"fixed32,9,opt,name=fixed32_value,json=fixed32Value,proto3" json:"fixed32_value,omitempty"` BoolValue bool `protobuf:"varint,10,opt,name=bool_value,json=boolValue,proto3" json:"bool_value,omitempty"` StringValue string `protobuf:"bytes,11,opt,name=string_value,json=stringValue,proto3" json:"string_value,omitempty"` BytesValue []byte `protobuf:"bytes,29,opt,name=bytes_value,json=bytesValue,proto3" json:"bytes_value,omitempty"` Uint32Value uint32 `protobuf:"varint,13,opt,name=uint32_value,json=uint32Value,proto3" json:"uint32_value,omitempty"` EnumValue NumericEnum `protobuf:"varint,14,opt,name=enum_value,json=enumValue,proto3,enum=grpc.gateway.runtime.internal.examplepb.NumericEnum" json:"enum_value,omitempty"` Sfixed32Value int32 `protobuf:"fixed32,15,opt,name=sfixed32_value,json=sfixed32Value,proto3" json:"sfixed32_value,omitempty"` Sfixed64Value int64 `protobuf:"fixed64,16,opt,name=sfixed64_value,json=sfixed64Value,proto3" json:"sfixed64_value,omitempty"` Sint32Value int32 `protobuf:"zigzag32,17,opt,name=sint32_value,json=sint32Value,proto3" json:"sint32_value,omitempty"` Sint64Value int64 `protobuf:"zigzag64,18,opt,name=sint64_value,json=sint64Value,proto3" json:"sint64_value,omitempty"` RepeatedStringValue []string `protobuf:"bytes,19,rep,name=repeated_string_value,json=repeatedStringValue,proto3" json:"repeated_string_value,omitempty"` // Types that are assignable to OneofValue: // // *ABitOfEverything_OneofEmpty // *ABitOfEverything_OneofString OneofValue isABitOfEverything_OneofValue `protobuf_oneof:"oneof_value"` MapValue map[string]NumericEnum `protobuf:"bytes,22,rep,name=map_value,json=mapValue,proto3" json:"map_value,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3,enum=grpc.gateway.runtime.internal.examplepb.NumericEnum"` MappedStringValue map[string]string `protobuf:"bytes,23,rep,name=mapped_string_value,json=mappedStringValue,proto3" json:"mapped_string_value,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` MappedNestedValue map[string]*ABitOfEverything_Nested `protobuf:"bytes,24,rep,name=mapped_nested_value,json=mappedNestedValue,proto3" json:"mapped_nested_value,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` NonConventionalNameValue string `protobuf:"bytes,26,opt,name=nonConventionalNameValue,proto3" json:"nonConventionalNameValue,omitempty"` TimestampValue *timestamppb.Timestamp `protobuf:"bytes,27,opt,name=timestamp_value,json=timestampValue,proto3" json:"timestamp_value,omitempty"` // repeated enum value. it is comma-separated in query RepeatedEnumValue []NumericEnum `protobuf:"varint,28,rep,packed,name=repeated_enum_value,json=repeatedEnumValue,proto3,enum=grpc.gateway.runtime.internal.examplepb.NumericEnum" json:"repeated_enum_value,omitempty"` // repeated numeric enum comment (This comment is overridden by the field // annotation) RepeatedEnumAnnotation []NumericEnum `protobuf:"varint,32,rep,packed,name=repeated_enum_annotation,json=repeatedEnumAnnotation,proto3,enum=grpc.gateway.runtime.internal.examplepb.NumericEnum" json:"repeated_enum_annotation,omitempty"` // numeric enum comment (This comment is overridden by the field annotation) EnumValueAnnotation NumericEnum `protobuf:"varint,33,opt,name=enum_value_annotation,json=enumValueAnnotation,proto3,enum=grpc.gateway.runtime.internal.examplepb.NumericEnum" json:"enum_value_annotation,omitempty"` // repeated string comment (This comment is overridden by the field // annotation) RepeatedStringAnnotation []string `protobuf:"bytes,34,rep,name=repeated_string_annotation,json=repeatedStringAnnotation,proto3" json:"repeated_string_annotation,omitempty"` // repeated nested object comment (This comment is overridden by the field // annotation) RepeatedNestedAnnotation []*ABitOfEverything_Nested `protobuf:"bytes,35,rep,name=repeated_nested_annotation,json=repeatedNestedAnnotation,proto3" json:"repeated_nested_annotation,omitempty"` // nested object comments (This comment is overridden by the field annotation) NestedAnnotation *ABitOfEverything_Nested `protobuf:"bytes,36,opt,name=nested_annotation,json=nestedAnnotation,proto3" json:"nested_annotation,omitempty"` Int64OverrideType int64 `protobuf:"varint,37,opt,name=int64_override_type,json=int64OverrideType,proto3" json:"int64_override_type,omitempty"` Anytype *anypb.Any `protobuf:"bytes,38,opt,name=anytype,proto3" json:"anytype,omitempty"` RepeatedAnytype []*anypb.Any `protobuf:"bytes,39,rep,name=repeated_anytype,json=repeatedAnytype,proto3" json:"repeated_anytype,omitempty"` } func (x *ABitOfEverything) Reset() { *x = ABitOfEverything{} mi := &file_runtime_internal_examplepb_example_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *ABitOfEverything) String() string { return protoimpl.X.MessageStringOf(x) } func (*ABitOfEverything) ProtoMessage() {} func (x *ABitOfEverything) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_example_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use ABitOfEverything.ProtoReflect.Descriptor instead. func (*ABitOfEverything) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_example_proto_rawDescGZIP(), []int{1} } func (x *ABitOfEverything) GetSingleNested() *ABitOfEverything_Nested { if x != nil { return x.SingleNested } return nil } func (x *ABitOfEverything) GetUuid() string { if x != nil { return x.Uuid } return "" } func (x *ABitOfEverything) GetNested() []*ABitOfEverything_Nested { if x != nil { return x.Nested } return nil } func (x *ABitOfEverything) GetFloatValue() float32 { if x != nil { return x.FloatValue } return 0 } func (x *ABitOfEverything) GetDoubleValue() float64 { if x != nil { return x.DoubleValue } return 0 } func (x *ABitOfEverything) GetInt64Value() int64 { if x != nil { return x.Int64Value } return 0 } func (x *ABitOfEverything) GetUint64Value() uint64 { if x != nil { return x.Uint64Value } return 0 } func (x *ABitOfEverything) GetInt32Value() int32 { if x != nil { return x.Int32Value } return 0 } func (x *ABitOfEverything) GetFixed64Value() uint64 { if x != nil { return x.Fixed64Value } return 0 } func (x *ABitOfEverything) GetFixed32Value() uint32 { if x != nil { return x.Fixed32Value } return 0 } func (x *ABitOfEverything) GetBoolValue() bool { if x != nil { return x.BoolValue } return false } func (x *ABitOfEverything) GetStringValue() string { if x != nil { return x.StringValue } return "" } func (x *ABitOfEverything) GetBytesValue() []byte { if x != nil { return x.BytesValue } return nil } func (x *ABitOfEverything) GetUint32Value() uint32 { if x != nil { return x.Uint32Value } return 0 } func (x *ABitOfEverything) GetEnumValue() NumericEnum { if x != nil { return x.EnumValue } return NumericEnum_ZERO } func (x *ABitOfEverything) GetSfixed32Value() int32 { if x != nil { return x.Sfixed32Value } return 0 } func (x *ABitOfEverything) GetSfixed64Value() int64 { if x != nil { return x.Sfixed64Value } return 0 } func (x *ABitOfEverything) GetSint32Value() int32 { if x != nil { return x.Sint32Value } return 0 } func (x *ABitOfEverything) GetSint64Value() int64 { if x != nil { return x.Sint64Value } return 0 } func (x *ABitOfEverything) GetRepeatedStringValue() []string { if x != nil { return x.RepeatedStringValue } return nil } func (m *ABitOfEverything) GetOneofValue() isABitOfEverything_OneofValue { if m != nil { return m.OneofValue } return nil } func (x *ABitOfEverything) GetOneofEmpty() *emptypb.Empty { if x, ok := x.GetOneofValue().(*ABitOfEverything_OneofEmpty); ok { return x.OneofEmpty } return nil } func (x *ABitOfEverything) GetOneofString() string { if x, ok := x.GetOneofValue().(*ABitOfEverything_OneofString); ok { return x.OneofString } return "" } func (x *ABitOfEverything) GetMapValue() map[string]NumericEnum { if x != nil { return x.MapValue } return nil } func (x *ABitOfEverything) GetMappedStringValue() map[string]string { if x != nil { return x.MappedStringValue } return nil } func (x *ABitOfEverything) GetMappedNestedValue() map[string]*ABitOfEverything_Nested { if x != nil { return x.MappedNestedValue } return nil } func (x *ABitOfEverything) GetNonConventionalNameValue() string { if x != nil { return x.NonConventionalNameValue } return "" } func (x *ABitOfEverything) GetTimestampValue() *timestamppb.Timestamp { if x != nil { return x.TimestampValue } return nil } func (x *ABitOfEverything) GetRepeatedEnumValue() []NumericEnum { if x != nil { return x.RepeatedEnumValue } return nil } func (x *ABitOfEverything) GetRepeatedEnumAnnotation() []NumericEnum { if x != nil { return x.RepeatedEnumAnnotation } return nil } func (x *ABitOfEverything) GetEnumValueAnnotation() NumericEnum { if x != nil { return x.EnumValueAnnotation } return NumericEnum_ZERO } func (x *ABitOfEverything) GetRepeatedStringAnnotation() []string { if x != nil { return x.RepeatedStringAnnotation } return nil } func (x *ABitOfEverything) GetRepeatedNestedAnnotation() []*ABitOfEverything_Nested { if x != nil { return x.RepeatedNestedAnnotation } return nil } func (x *ABitOfEverything) GetNestedAnnotation() *ABitOfEverything_Nested { if x != nil { return x.NestedAnnotation } return nil } func (x *ABitOfEverything) GetInt64OverrideType() int64 { if x != nil { return x.Int64OverrideType } return 0 } func (x *ABitOfEverything) GetAnytype() *anypb.Any { if x != nil { return x.Anytype } return nil } func (x *ABitOfEverything) GetRepeatedAnytype() []*anypb.Any { if x != nil { return x.RepeatedAnytype } return nil } type isABitOfEverything_OneofValue interface { isABitOfEverything_OneofValue() } type ABitOfEverything_OneofEmpty struct { OneofEmpty *emptypb.Empty `protobuf:"bytes,20,opt,name=oneof_empty,json=oneofEmpty,proto3,oneof"` } type ABitOfEverything_OneofString struct { OneofString string `protobuf:"bytes,21,opt,name=oneof_string,json=oneofString,proto3,oneof"` } func (*ABitOfEverything_OneofEmpty) isABitOfEverything_OneofValue() {} func (*ABitOfEverything_OneofString) isABitOfEverything_OneofValue() {} type ResponseBodyOut struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Response *ResponseBodyOut_Response `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"` } func (x *ResponseBodyOut) Reset() { *x = ResponseBodyOut{} mi := &file_runtime_internal_examplepb_example_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *ResponseBodyOut) String() string { return protoimpl.X.MessageStringOf(x) } func (*ResponseBodyOut) ProtoMessage() {} func (x *ResponseBodyOut) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_example_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use ResponseBodyOut.ProtoReflect.Descriptor instead. func (*ResponseBodyOut) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_example_proto_rawDescGZIP(), []int{2} } func (x *ResponseBodyOut) GetResponse() *ResponseBodyOut_Response { if x != nil { return x.Response } return nil } type RepeatedResponseBodyOut struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Response []*RepeatedResponseBodyOut_Response `protobuf:"bytes,2,rep,name=response,proto3" json:"response,omitempty"` } func (x *RepeatedResponseBodyOut) Reset() { *x = RepeatedResponseBodyOut{} mi := &file_runtime_internal_examplepb_example_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *RepeatedResponseBodyOut) String() string { return protoimpl.X.MessageStringOf(x) } func (*RepeatedResponseBodyOut) ProtoMessage() {} func (x *RepeatedResponseBodyOut) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_example_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use RepeatedResponseBodyOut.ProtoReflect.Descriptor instead. func (*RepeatedResponseBodyOut) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_example_proto_rawDescGZIP(), []int{3} } func (x *RepeatedResponseBodyOut) GetResponse() []*RepeatedResponseBodyOut_Response { if x != nil { return x.Response } return nil } type UpdateMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,1,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"` ABitOfEverything *ABitOfEverything `protobuf:"bytes,2,opt,name=a_bit_of_everything,json=aBitOfEverything,proto3" json:"a_bit_of_everything,omitempty"` } func (x *UpdateMessage) Reset() { *x = UpdateMessage{} mi := &file_runtime_internal_examplepb_example_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *UpdateMessage) String() string { return protoimpl.X.MessageStringOf(x) } func (*UpdateMessage) ProtoMessage() {} func (x *UpdateMessage) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_example_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use UpdateMessage.ProtoReflect.Descriptor instead. func (*UpdateMessage) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_example_proto_rawDescGZIP(), []int{4} } func (x *UpdateMessage) GetUpdateMask() *fieldmaskpb.FieldMask { if x != nil { return x.UpdateMask } return nil } func (x *UpdateMessage) GetABitOfEverything() *ABitOfEverything { if x != nil { return x.ABitOfEverything } return nil } type NestedOuter struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields One *NestedOne `protobuf:"bytes,1,opt,name=one,proto3" json:"one,omitempty"` } func (x *NestedOuter) Reset() { *x = NestedOuter{} mi := &file_runtime_internal_examplepb_example_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NestedOuter) String() string { return protoimpl.X.MessageStringOf(x) } func (*NestedOuter) ProtoMessage() {} func (x *NestedOuter) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_example_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NestedOuter.ProtoReflect.Descriptor instead. func (*NestedOuter) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_example_proto_rawDescGZIP(), []int{5} } func (x *NestedOuter) GetOne() *NestedOne { if x != nil { return x.One } return nil } type NestedOne struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Two *NestedTwo `protobuf:"bytes,1,opt,name=two,proto3" json:"two,omitempty"` } func (x *NestedOne) Reset() { *x = NestedOne{} mi := &file_runtime_internal_examplepb_example_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NestedOne) String() string { return protoimpl.X.MessageStringOf(x) } func (*NestedOne) ProtoMessage() {} func (x *NestedOne) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_example_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NestedOne.ProtoReflect.Descriptor instead. func (*NestedOne) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_example_proto_rawDescGZIP(), []int{6} } func (x *NestedOne) GetTwo() *NestedTwo { if x != nil { return x.Two } return nil } type NestedTwo struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Three *NestedThree `protobuf:"bytes,1,opt,name=three,proto3" json:"three,omitempty"` } func (x *NestedTwo) Reset() { *x = NestedTwo{} mi := &file_runtime_internal_examplepb_example_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NestedTwo) String() string { return protoimpl.X.MessageStringOf(x) } func (*NestedTwo) ProtoMessage() {} func (x *NestedTwo) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_example_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NestedTwo.ProtoReflect.Descriptor instead. func (*NestedTwo) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_example_proto_rawDescGZIP(), []int{7} } func (x *NestedTwo) GetThree() *NestedThree { if x != nil { return x.Three } return nil } type NestedThree struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields A bool `protobuf:"varint,1,opt,name=a,proto3" json:"a,omitempty"` B bool `protobuf:"varint,2,opt,name=b,proto3" json:"b,omitempty"` } func (x *NestedThree) Reset() { *x = NestedThree{} mi := &file_runtime_internal_examplepb_example_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NestedThree) String() string { return protoimpl.X.MessageStringOf(x) } func (*NestedThree) ProtoMessage() {} func (x *NestedThree) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_example_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NestedThree.ProtoReflect.Descriptor instead. func (*NestedThree) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_example_proto_rawDescGZIP(), []int{8} } func (x *NestedThree) GetA() bool { if x != nil { return x.A } return false } func (x *NestedThree) GetB() bool { if x != nil { return x.B } return false } type UpdateNestedRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Nested *NestedOuter `protobuf:"bytes,1,opt,name=nested,proto3" json:"nested,omitempty"` UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,2,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"` } func (x *UpdateNestedRequest) Reset() { *x = UpdateNestedRequest{} mi := &file_runtime_internal_examplepb_example_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *UpdateNestedRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*UpdateNestedRequest) ProtoMessage() {} func (x *UpdateNestedRequest) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_example_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use UpdateNestedRequest.ProtoReflect.Descriptor instead. func (*UpdateNestedRequest) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_example_proto_rawDescGZIP(), []int{9} } func (x *UpdateNestedRequest) GetNested() *NestedOuter { if x != nil { return x.Nested } return nil } func (x *UpdateNestedRequest) GetUpdateMask() *fieldmaskpb.FieldMask { if x != nil { return x.UpdateMask } return nil } // Nested is nested type. type ABitOfEverything_Nested struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // name is nested field. Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Amount uint32 `protobuf:"varint,2,opt,name=amount,proto3" json:"amount,omitempty"` // DeepEnum comment. Ok ABitOfEverything_Nested_DeepEnum `protobuf:"varint,3,opt,name=ok,proto3,enum=grpc.gateway.runtime.internal.examplepb.ABitOfEverything_Nested_DeepEnum" json:"ok,omitempty"` } func (x *ABitOfEverything_Nested) Reset() { *x = ABitOfEverything_Nested{} mi := &file_runtime_internal_examplepb_example_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *ABitOfEverything_Nested) String() string { return protoimpl.X.MessageStringOf(x) } func (*ABitOfEverything_Nested) ProtoMessage() {} func (x *ABitOfEverything_Nested) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_example_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use ABitOfEverything_Nested.ProtoReflect.Descriptor instead. func (*ABitOfEverything_Nested) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_example_proto_rawDescGZIP(), []int{1, 0} } func (x *ABitOfEverything_Nested) GetName() string { if x != nil { return x.Name } return "" } func (x *ABitOfEverything_Nested) GetAmount() uint32 { if x != nil { return x.Amount } return 0 } func (x *ABitOfEverything_Nested) GetOk() ABitOfEverything_Nested_DeepEnum { if x != nil { return x.Ok } return ABitOfEverything_Nested_FALSE } type ResponseBodyOut_Response struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Data string `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` } func (x *ResponseBodyOut_Response) Reset() { *x = ResponseBodyOut_Response{} mi := &file_runtime_internal_examplepb_example_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *ResponseBodyOut_Response) String() string { return protoimpl.X.MessageStringOf(x) } func (*ResponseBodyOut_Response) ProtoMessage() {} func (x *ResponseBodyOut_Response) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_example_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use ResponseBodyOut_Response.ProtoReflect.Descriptor instead. func (*ResponseBodyOut_Response) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_example_proto_rawDescGZIP(), []int{2, 0} } func (x *ResponseBodyOut_Response) GetData() string { if x != nil { return x.Data } return "" } type RepeatedResponseBodyOut_Response struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Data string `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` Type RepeatedResponseBodyOut_Response_ResponseType `protobuf:"varint,3,opt,name=type,proto3,enum=grpc.gateway.runtime.internal.examplepb.RepeatedResponseBodyOut_Response_ResponseType" json:"type,omitempty"` } func (x *RepeatedResponseBodyOut_Response) Reset() { *x = RepeatedResponseBodyOut_Response{} mi := &file_runtime_internal_examplepb_example_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *RepeatedResponseBodyOut_Response) String() string { return protoimpl.X.MessageStringOf(x) } func (*RepeatedResponseBodyOut_Response) ProtoMessage() {} func (x *RepeatedResponseBodyOut_Response) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_example_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use RepeatedResponseBodyOut_Response.ProtoReflect.Descriptor instead. func (*RepeatedResponseBodyOut_Response) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_example_proto_rawDescGZIP(), []int{3, 0} } func (x *RepeatedResponseBodyOut_Response) GetData() string { if x != nil { return x.Data } return "" } func (x *RepeatedResponseBodyOut_Response) GetType() RepeatedResponseBodyOut_Response_ResponseType { if x != nil { return x.Type } return RepeatedResponseBodyOut_Response_UNKNOWN } var File_runtime_internal_examplepb_example_proto protoreflect.FileDescriptor var file_runtime_internal_examplepb_example_proto_rawDesc = []byte{ 0x0a, 0x28, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x27, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1f, 0x0a, 0x0d, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0xdc, 0x15, 0x0a, 0x10, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x65, 0x0a, 0x0d, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x5f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x18, 0x19, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x0c, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x58, 0x0a, 0x06, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x06, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x52, 0x0a, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0b, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x06, 0x52, 0x0c, 0x66, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x07, 0x52, 0x0c, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x1d, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x62, 0x79, 0x74, 0x65, 0x73, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x53, 0x0a, 0x0a, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x09, 0x65, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0f, 0x52, 0x0d, 0x73, 0x66, 0x69, 0x78, 0x65, 0x64, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x66, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x10, 0x20, 0x01, 0x28, 0x10, 0x52, 0x0d, 0x73, 0x66, 0x69, 0x78, 0x65, 0x64, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x11, 0x20, 0x01, 0x28, 0x11, 0x52, 0x0b, 0x73, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x12, 0x20, 0x01, 0x28, 0x12, 0x52, 0x0b, 0x73, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x32, 0x0a, 0x15, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x13, 0x20, 0x03, 0x28, 0x09, 0x52, 0x13, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x39, 0x0a, 0x0b, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x5f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x48, 0x00, 0x52, 0x0a, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x23, 0x0a, 0x0c, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x15, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0b, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x64, 0x0a, 0x09, 0x6d, 0x61, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x16, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x47, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x6d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x80, 0x01, 0x0a, 0x13, 0x6d, 0x61, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x17, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x50, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x4d, 0x61, 0x70, 0x70, 0x65, 0x64, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x11, 0x6d, 0x61, 0x70, 0x70, 0x65, 0x64, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x80, 0x01, 0x0a, 0x13, 0x6d, 0x61, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x18, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x50, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x4d, 0x61, 0x70, 0x70, 0x65, 0x64, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x11, 0x6d, 0x61, 0x70, 0x70, 0x65, 0x64, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3a, 0x0a, 0x18, 0x6e, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x1a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x18, 0x6e, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x43, 0x0a, 0x0f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x1b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x64, 0x0a, 0x13, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x1c, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x11, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x45, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x6e, 0x0a, 0x18, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x20, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x16, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x45, 0x6e, 0x75, 0x6d, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x68, 0x0a, 0x15, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x21, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x13, 0x65, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3c, 0x0a, 0x1a, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x22, 0x20, 0x03, 0x28, 0x09, 0x52, 0x18, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x7e, 0x0a, 0x1a, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x23, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x18, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x6d, 0x0a, 0x11, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x24, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x10, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2e, 0x0a, 0x13, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x25, 0x20, 0x01, 0x28, 0x03, 0x52, 0x11, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2e, 0x0a, 0x07, 0x61, 0x6e, 0x79, 0x74, 0x79, 0x70, 0x65, 0x18, 0x26, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x07, 0x61, 0x6e, 0x79, 0x74, 0x79, 0x70, 0x65, 0x12, 0x3f, 0x0a, 0x10, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x6e, 0x79, 0x74, 0x79, 0x70, 0x65, 0x18, 0x27, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x0f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x6e, 0x79, 0x74, 0x79, 0x70, 0x65, 0x1a, 0xb0, 0x01, 0x0a, 0x06, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x59, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x49, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x2e, 0x44, 0x65, 0x65, 0x70, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x02, 0x6f, 0x6b, 0x22, 0x1f, 0x0a, 0x08, 0x44, 0x65, 0x65, 0x70, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x09, 0x0a, 0x05, 0x46, 0x41, 0x4c, 0x53, 0x45, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x54, 0x52, 0x55, 0x45, 0x10, 0x01, 0x1a, 0x71, 0x0a, 0x0d, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x4a, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x44, 0x0a, 0x16, 0x4d, 0x61, 0x70, 0x70, 0x65, 0x64, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x86, 0x01, 0x0a, 0x16, 0x4d, 0x61, 0x70, 0x70, 0x65, 0x64, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x56, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x40, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x0d, 0x0a, 0x0b, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x90, 0x01, 0x0a, 0x0f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x4f, 0x75, 0x74, 0x12, 0x5d, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x41, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x4f, 0x75, 0x74, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x1e, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xb8, 0x02, 0x0a, 0x17, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x4f, 0x75, 0x74, 0x12, 0x65, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x49, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x4f, 0x75, 0x74, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0xb5, 0x01, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x6a, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x56, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6f, 0x64, 0x79, 0x4f, 0x75, 0x74, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x29, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x05, 0x0a, 0x01, 0x41, 0x10, 0x01, 0x12, 0x05, 0x0a, 0x01, 0x42, 0x10, 0x02, 0x22, 0xb6, 0x01, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x3b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x6b, 0x12, 0x68, 0x0a, 0x13, 0x61, 0x5f, 0x62, 0x69, 0x74, 0x5f, 0x6f, 0x66, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x39, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x41, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x52, 0x10, 0x61, 0x42, 0x69, 0x74, 0x4f, 0x66, 0x45, 0x76, 0x65, 0x72, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x22, 0x53, 0x0a, 0x0b, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x4f, 0x75, 0x74, 0x65, 0x72, 0x12, 0x44, 0x0a, 0x03, 0x6f, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x4f, 0x6e, 0x65, 0x52, 0x03, 0x6f, 0x6e, 0x65, 0x22, 0x51, 0x0a, 0x09, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x4f, 0x6e, 0x65, 0x12, 0x44, 0x0a, 0x03, 0x74, 0x77, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x54, 0x77, 0x6f, 0x52, 0x03, 0x74, 0x77, 0x6f, 0x22, 0x57, 0x0a, 0x09, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x54, 0x77, 0x6f, 0x12, 0x4a, 0x0a, 0x05, 0x74, 0x68, 0x72, 0x65, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x54, 0x68, 0x72, 0x65, 0x65, 0x52, 0x05, 0x74, 0x68, 0x72, 0x65, 0x65, 0x22, 0x29, 0x0a, 0x0b, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x54, 0x68, 0x72, 0x65, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x01, 0x61, 0x12, 0x0c, 0x0a, 0x01, 0x62, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x01, 0x62, 0x22, 0xa0, 0x01, 0x0a, 0x13, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x4c, 0x0a, 0x06, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x4f, 0x75, 0x74, 0x65, 0x72, 0x52, 0x06, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x12, 0x3b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x6b, 0x2a, 0x20, 0x0a, 0x0b, 0x4e, 0x75, 0x6d, 0x65, 0x72, 0x69, 0x63, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x08, 0x0a, 0x04, 0x5a, 0x45, 0x52, 0x4f, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x4e, 0x45, 0x10, 0x01, 0x42, 0x46, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_runtime_internal_examplepb_example_proto_rawDescOnce sync.Once file_runtime_internal_examplepb_example_proto_rawDescData = file_runtime_internal_examplepb_example_proto_rawDesc ) func file_runtime_internal_examplepb_example_proto_rawDescGZIP() []byte { file_runtime_internal_examplepb_example_proto_rawDescOnce.Do(func() { file_runtime_internal_examplepb_example_proto_rawDescData = protoimpl.X.CompressGZIP(file_runtime_internal_examplepb_example_proto_rawDescData) }) return file_runtime_internal_examplepb_example_proto_rawDescData } var file_runtime_internal_examplepb_example_proto_enumTypes = make([]protoimpl.EnumInfo, 3) var file_runtime_internal_examplepb_example_proto_msgTypes = make([]protoimpl.MessageInfo, 16) var file_runtime_internal_examplepb_example_proto_goTypes = []any{ (NumericEnum)(0), // 0: grpc.gateway.runtime.internal.examplepb.NumericEnum (ABitOfEverything_Nested_DeepEnum)(0), // 1: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.Nested.DeepEnum (RepeatedResponseBodyOut_Response_ResponseType)(0), // 2: grpc.gateway.runtime.internal.examplepb.RepeatedResponseBodyOut.Response.ResponseType (*SimpleMessage)(nil), // 3: grpc.gateway.runtime.internal.examplepb.SimpleMessage (*ABitOfEverything)(nil), // 4: grpc.gateway.runtime.internal.examplepb.ABitOfEverything (*ResponseBodyOut)(nil), // 5: grpc.gateway.runtime.internal.examplepb.ResponseBodyOut (*RepeatedResponseBodyOut)(nil), // 6: grpc.gateway.runtime.internal.examplepb.RepeatedResponseBodyOut (*UpdateMessage)(nil), // 7: grpc.gateway.runtime.internal.examplepb.UpdateMessage (*NestedOuter)(nil), // 8: grpc.gateway.runtime.internal.examplepb.NestedOuter (*NestedOne)(nil), // 9: grpc.gateway.runtime.internal.examplepb.NestedOne (*NestedTwo)(nil), // 10: grpc.gateway.runtime.internal.examplepb.NestedTwo (*NestedThree)(nil), // 11: grpc.gateway.runtime.internal.examplepb.NestedThree (*UpdateNestedRequest)(nil), // 12: grpc.gateway.runtime.internal.examplepb.UpdateNestedRequest (*ABitOfEverything_Nested)(nil), // 13: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.Nested nil, // 14: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.MapValueEntry nil, // 15: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.MappedStringValueEntry nil, // 16: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.MappedNestedValueEntry (*ResponseBodyOut_Response)(nil), // 17: grpc.gateway.runtime.internal.examplepb.ResponseBodyOut.Response (*RepeatedResponseBodyOut_Response)(nil), // 18: grpc.gateway.runtime.internal.examplepb.RepeatedResponseBodyOut.Response (*emptypb.Empty)(nil), // 19: google.protobuf.Empty (*timestamppb.Timestamp)(nil), // 20: google.protobuf.Timestamp (*anypb.Any)(nil), // 21: google.protobuf.Any (*fieldmaskpb.FieldMask)(nil), // 22: google.protobuf.FieldMask } var file_runtime_internal_examplepb_example_proto_depIdxs = []int32{ 13, // 0: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.single_nested:type_name -> grpc.gateway.runtime.internal.examplepb.ABitOfEverything.Nested 13, // 1: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.nested:type_name -> grpc.gateway.runtime.internal.examplepb.ABitOfEverything.Nested 0, // 2: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.enum_value:type_name -> grpc.gateway.runtime.internal.examplepb.NumericEnum 19, // 3: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.oneof_empty:type_name -> google.protobuf.Empty 14, // 4: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.map_value:type_name -> grpc.gateway.runtime.internal.examplepb.ABitOfEverything.MapValueEntry 15, // 5: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.mapped_string_value:type_name -> grpc.gateway.runtime.internal.examplepb.ABitOfEverything.MappedStringValueEntry 16, // 6: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.mapped_nested_value:type_name -> grpc.gateway.runtime.internal.examplepb.ABitOfEverything.MappedNestedValueEntry 20, // 7: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.timestamp_value:type_name -> google.protobuf.Timestamp 0, // 8: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.repeated_enum_value:type_name -> grpc.gateway.runtime.internal.examplepb.NumericEnum 0, // 9: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.repeated_enum_annotation:type_name -> grpc.gateway.runtime.internal.examplepb.NumericEnum 0, // 10: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.enum_value_annotation:type_name -> grpc.gateway.runtime.internal.examplepb.NumericEnum 13, // 11: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.repeated_nested_annotation:type_name -> grpc.gateway.runtime.internal.examplepb.ABitOfEverything.Nested 13, // 12: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.nested_annotation:type_name -> grpc.gateway.runtime.internal.examplepb.ABitOfEverything.Nested 21, // 13: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.anytype:type_name -> google.protobuf.Any 21, // 14: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.repeated_anytype:type_name -> google.protobuf.Any 17, // 15: grpc.gateway.runtime.internal.examplepb.ResponseBodyOut.response:type_name -> grpc.gateway.runtime.internal.examplepb.ResponseBodyOut.Response 18, // 16: grpc.gateway.runtime.internal.examplepb.RepeatedResponseBodyOut.response:type_name -> grpc.gateway.runtime.internal.examplepb.RepeatedResponseBodyOut.Response 22, // 17: grpc.gateway.runtime.internal.examplepb.UpdateMessage.update_mask:type_name -> google.protobuf.FieldMask 4, // 18: grpc.gateway.runtime.internal.examplepb.UpdateMessage.a_bit_of_everything:type_name -> grpc.gateway.runtime.internal.examplepb.ABitOfEverything 9, // 19: grpc.gateway.runtime.internal.examplepb.NestedOuter.one:type_name -> grpc.gateway.runtime.internal.examplepb.NestedOne 10, // 20: grpc.gateway.runtime.internal.examplepb.NestedOne.two:type_name -> grpc.gateway.runtime.internal.examplepb.NestedTwo 11, // 21: grpc.gateway.runtime.internal.examplepb.NestedTwo.three:type_name -> grpc.gateway.runtime.internal.examplepb.NestedThree 8, // 22: grpc.gateway.runtime.internal.examplepb.UpdateNestedRequest.nested:type_name -> grpc.gateway.runtime.internal.examplepb.NestedOuter 22, // 23: grpc.gateway.runtime.internal.examplepb.UpdateNestedRequest.update_mask:type_name -> google.protobuf.FieldMask 1, // 24: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.Nested.ok:type_name -> grpc.gateway.runtime.internal.examplepb.ABitOfEverything.Nested.DeepEnum 0, // 25: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.MapValueEntry.value:type_name -> grpc.gateway.runtime.internal.examplepb.NumericEnum 13, // 26: grpc.gateway.runtime.internal.examplepb.ABitOfEverything.MappedNestedValueEntry.value:type_name -> grpc.gateway.runtime.internal.examplepb.ABitOfEverything.Nested 2, // 27: grpc.gateway.runtime.internal.examplepb.RepeatedResponseBodyOut.Response.type:type_name -> grpc.gateway.runtime.internal.examplepb.RepeatedResponseBodyOut.Response.ResponseType 28, // [28:28] is the sub-list for method output_type 28, // [28:28] is the sub-list for method input_type 28, // [28:28] is the sub-list for extension type_name 28, // [28:28] is the sub-list for extension extendee 0, // [0:28] is the sub-list for field type_name } func init() { file_runtime_internal_examplepb_example_proto_init() } func file_runtime_internal_examplepb_example_proto_init() { if File_runtime_internal_examplepb_example_proto != nil { return } file_runtime_internal_examplepb_example_proto_msgTypes[1].OneofWrappers = []any{ (*ABitOfEverything_OneofEmpty)(nil), (*ABitOfEverything_OneofString)(nil), } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_runtime_internal_examplepb_example_proto_rawDesc, NumEnums: 3, NumMessages: 16, NumExtensions: 0, NumServices: 0, }, GoTypes: file_runtime_internal_examplepb_example_proto_goTypes, DependencyIndexes: file_runtime_internal_examplepb_example_proto_depIdxs, EnumInfos: file_runtime_internal_examplepb_example_proto_enumTypes, MessageInfos: file_runtime_internal_examplepb_example_proto_msgTypes, }.Build() File_runtime_internal_examplepb_example_proto = out.File file_runtime_internal_examplepb_example_proto_rawDesc = nil file_runtime_internal_examplepb_example_proto_goTypes = nil file_runtime_internal_examplepb_example_proto_depIdxs = nil } ================================================ FILE: runtime/internal/examplepb/example.proto ================================================ syntax = "proto3"; package grpc.gateway.runtime.internal.examplepb; import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "google/protobuf/field_mask.proto"; import "google/protobuf/timestamp.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/runtime/internal/examplepb"; // SimpleMessage represents a simple message sent to the Echo service. message SimpleMessage { string id = 1; } message ABitOfEverything { // Nested is nested type. message Nested { // name is nested field. string name = 1; uint32 amount = 2; // DeepEnum is one or zero. enum DeepEnum { // FALSE is false. FALSE = 0; // TRUE is true. TRUE = 1; } // DeepEnum comment. DeepEnum ok = 3; } Nested single_nested = 25; string uuid = 1; repeated Nested nested = 2; float float_value = 3; double double_value = 4; int64 int64_value = 5; uint64 uint64_value = 6; int32 int32_value = 7; fixed64 fixed64_value = 8; fixed32 fixed32_value = 9; bool bool_value = 10; string string_value = 11; bytes bytes_value = 29; uint32 uint32_value = 13; NumericEnum enum_value = 14; sfixed32 sfixed32_value = 15; sfixed64 sfixed64_value = 16; sint32 sint32_value = 17; sint64 sint64_value = 18; repeated string repeated_string_value = 19; oneof oneof_value { google.protobuf.Empty oneof_empty = 20; string oneof_string = 21; } map map_value = 22; map mapped_string_value = 23; map mapped_nested_value = 24; string nonConventionalNameValue = 26; google.protobuf.Timestamp timestamp_value = 27; // repeated enum value. it is comma-separated in query repeated NumericEnum repeated_enum_value = 28; // repeated numeric enum comment (This comment is overridden by the field // annotation) repeated NumericEnum repeated_enum_annotation = 32; // numeric enum comment (This comment is overridden by the field annotation) NumericEnum enum_value_annotation = 33; // repeated string comment (This comment is overridden by the field // annotation) repeated string repeated_string_annotation = 34; // repeated nested object comment (This comment is overridden by the field // annotation) repeated Nested repeated_nested_annotation = 35; // nested object comments (This comment is overridden by the field annotation) Nested nested_annotation = 36; int64 int64_override_type = 37; google.protobuf.Any anytype = 38; repeated google.protobuf.Any repeated_anytype = 39; } // NumericEnum is one or zero. enum NumericEnum { // ZERO means 0 ZERO = 0; // ONE means 1 ONE = 1; } message ResponseBodyOut { message Response { string data = 1; } Response response = 2; } message RepeatedResponseBodyOut { message Response { string data = 1; enum ResponseType { // UNKNOWN UNKNOWN = 0; // A is 1 A = 1; // B is 2 B = 2; } ResponseType type = 3; } repeated Response response = 2; } message UpdateMessage { google.protobuf.FieldMask update_mask = 1; ABitOfEverything a_bit_of_everything = 2; } message NestedOuter { NestedOne one = 1; } message NestedOne { NestedTwo two = 1; } message NestedTwo { NestedThree three = 1; } message NestedThree { bool a = 1; bool b = 2; } message UpdateNestedRequest { NestedOuter nested = 1; google.protobuf.FieldMask update_mask = 2; } ================================================ FILE: runtime/internal/examplepb/example.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "runtime/internal/examplepb/example.proto", "version": "version not set" }, "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": {}, "definitions": { "protobufAny": { "type": "object", "properties": { "@type": { "type": "string", "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics." } }, "additionalProperties": {}, "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }" }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } } } } ================================================ FILE: runtime/internal/examplepb/non_standard_names.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: runtime/internal/examplepb/non_standard_names.proto package examplepb import ( _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" structpb "google.golang.org/protobuf/types/known/structpb" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) // NonStandardMessage has oddly named fields. type NonStandardMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Id represents the message identifier. Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Num int64 `protobuf:"varint,2,opt,name=Num,proto3" json:"Num,omitempty"` LineNum int64 `protobuf:"varint,3,opt,name=line_num,json=lineNum,proto3" json:"line_num,omitempty"` LangIdent string `protobuf:"bytes,4,opt,name=langIdent,proto3" json:"langIdent,omitempty"` STATUS string `protobuf:"bytes,5,opt,name=STATUS,proto3" json:"STATUS,omitempty"` En_GB int64 `protobuf:"varint,6,opt,name=en_GB,json=enGB,proto3" json:"en_GB,omitempty"` No string `protobuf:"bytes,7,opt,name=no,proto3" json:"no,omitempty"` Thing *NonStandardMessage_Thing `protobuf:"bytes,8,opt,name=thing,proto3" json:"thing,omitempty"` StructField *structpb.Struct `protobuf:"bytes,9,opt,name=struct_field,json=structField,proto3" json:"struct_field,omitempty"` ValueField *structpb.Value `protobuf:"bytes,10,opt,name=value_field,json=valueField,proto3" json:"value_field,omitempty"` } func (x *NonStandardMessage) Reset() { *x = NonStandardMessage{} mi := &file_runtime_internal_examplepb_non_standard_names_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NonStandardMessage) String() string { return protoimpl.X.MessageStringOf(x) } func (*NonStandardMessage) ProtoMessage() {} func (x *NonStandardMessage) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_non_standard_names_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NonStandardMessage.ProtoReflect.Descriptor instead. func (*NonStandardMessage) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_non_standard_names_proto_rawDescGZIP(), []int{0} } func (x *NonStandardMessage) GetId() string { if x != nil { return x.Id } return "" } func (x *NonStandardMessage) GetNum() int64 { if x != nil { return x.Num } return 0 } func (x *NonStandardMessage) GetLineNum() int64 { if x != nil { return x.LineNum } return 0 } func (x *NonStandardMessage) GetLangIdent() string { if x != nil { return x.LangIdent } return "" } func (x *NonStandardMessage) GetSTATUS() string { if x != nil { return x.STATUS } return "" } func (x *NonStandardMessage) GetEn_GB() int64 { if x != nil { return x.En_GB } return 0 } func (x *NonStandardMessage) GetNo() string { if x != nil { return x.No } return "" } func (x *NonStandardMessage) GetThing() *NonStandardMessage_Thing { if x != nil { return x.Thing } return nil } func (x *NonStandardMessage) GetStructField() *structpb.Struct { if x != nil { return x.StructField } return nil } func (x *NonStandardMessage) GetValueField() *structpb.Value { if x != nil { return x.ValueField } return nil } type NonStandardUpdateRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Body *NonStandardMessage `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"` UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,2,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"` } func (x *NonStandardUpdateRequest) Reset() { *x = NonStandardUpdateRequest{} mi := &file_runtime_internal_examplepb_non_standard_names_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NonStandardUpdateRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*NonStandardUpdateRequest) ProtoMessage() {} func (x *NonStandardUpdateRequest) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_non_standard_names_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NonStandardUpdateRequest.ProtoReflect.Descriptor instead. func (*NonStandardUpdateRequest) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_non_standard_names_proto_rawDescGZIP(), []int{1} } func (x *NonStandardUpdateRequest) GetBody() *NonStandardMessage { if x != nil { return x.Body } return nil } func (x *NonStandardUpdateRequest) GetUpdateMask() *fieldmaskpb.FieldMask { if x != nil { return x.UpdateMask } return nil } // NonStandardMessageWithJSONNames maps odd field names to odd JSON names for maximum confusion. type NonStandardMessageWithJSONNames struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Id represents the message identifier. Id string `protobuf:"bytes,1,opt,name=id,json=ID,proto3" json:"id,omitempty"` Num int64 `protobuf:"varint,2,opt,name=Num,proto3" json:"Num,omitempty"` LineNum int64 `protobuf:"varint,3,opt,name=line_num,json=LineNum,proto3" json:"line_num,omitempty"` LangIdent string `protobuf:"bytes,4,opt,name=langIdent,proto3" json:"langIdent,omitempty"` STATUS string `protobuf:"bytes,5,opt,name=STATUS,json=status,proto3" json:"STATUS,omitempty"` En_GB int64 `protobuf:"varint,6,opt,name=en_GB,json=En_GB,proto3" json:"en_GB,omitempty"` No string `protobuf:"bytes,7,opt,name=no,json=yes,proto3" json:"no,omitempty"` Thing *NonStandardMessageWithJSONNames_Thing `protobuf:"bytes,8,opt,name=thing,json=Thingy,proto3" json:"thing,omitempty"` StructField *structpb.Struct `protobuf:"bytes,9,opt,name=struct_field,json=StructField,proto3" json:"struct_field,omitempty"` ValueField *structpb.Value `protobuf:"bytes,10,opt,name=value_field,json=ValueField,proto3" json:"value_field,omitempty"` } func (x *NonStandardMessageWithJSONNames) Reset() { *x = NonStandardMessageWithJSONNames{} mi := &file_runtime_internal_examplepb_non_standard_names_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NonStandardMessageWithJSONNames) String() string { return protoimpl.X.MessageStringOf(x) } func (*NonStandardMessageWithJSONNames) ProtoMessage() {} func (x *NonStandardMessageWithJSONNames) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_non_standard_names_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NonStandardMessageWithJSONNames.ProtoReflect.Descriptor instead. func (*NonStandardMessageWithJSONNames) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_non_standard_names_proto_rawDescGZIP(), []int{2} } func (x *NonStandardMessageWithJSONNames) GetId() string { if x != nil { return x.Id } return "" } func (x *NonStandardMessageWithJSONNames) GetNum() int64 { if x != nil { return x.Num } return 0 } func (x *NonStandardMessageWithJSONNames) GetLineNum() int64 { if x != nil { return x.LineNum } return 0 } func (x *NonStandardMessageWithJSONNames) GetLangIdent() string { if x != nil { return x.LangIdent } return "" } func (x *NonStandardMessageWithJSONNames) GetSTATUS() string { if x != nil { return x.STATUS } return "" } func (x *NonStandardMessageWithJSONNames) GetEn_GB() int64 { if x != nil { return x.En_GB } return 0 } func (x *NonStandardMessageWithJSONNames) GetNo() string { if x != nil { return x.No } return "" } func (x *NonStandardMessageWithJSONNames) GetThing() *NonStandardMessageWithJSONNames_Thing { if x != nil { return x.Thing } return nil } func (x *NonStandardMessageWithJSONNames) GetStructField() *structpb.Struct { if x != nil { return x.StructField } return nil } func (x *NonStandardMessageWithJSONNames) GetValueField() *structpb.Value { if x != nil { return x.ValueField } return nil } type NonStandardWithJSONNamesUpdateRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields Body *NonStandardMessageWithJSONNames `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"` UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,2,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"` } func (x *NonStandardWithJSONNamesUpdateRequest) Reset() { *x = NonStandardWithJSONNamesUpdateRequest{} mi := &file_runtime_internal_examplepb_non_standard_names_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NonStandardWithJSONNamesUpdateRequest) String() string { return protoimpl.X.MessageStringOf(x) } func (*NonStandardWithJSONNamesUpdateRequest) ProtoMessage() {} func (x *NonStandardWithJSONNamesUpdateRequest) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_non_standard_names_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NonStandardWithJSONNamesUpdateRequest.ProtoReflect.Descriptor instead. func (*NonStandardWithJSONNamesUpdateRequest) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_non_standard_names_proto_rawDescGZIP(), []int{3} } func (x *NonStandardWithJSONNamesUpdateRequest) GetBody() *NonStandardMessageWithJSONNames { if x != nil { return x.Body } return nil } func (x *NonStandardWithJSONNamesUpdateRequest) GetUpdateMask() *fieldmaskpb.FieldMask { if x != nil { return x.UpdateMask } return nil } type NonStandardMessage_Thing struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields SubThing *NonStandardMessage_Thing_SubThing `protobuf:"bytes,1,opt,name=subThing,proto3" json:"subThing,omitempty"` } func (x *NonStandardMessage_Thing) Reset() { *x = NonStandardMessage_Thing{} mi := &file_runtime_internal_examplepb_non_standard_names_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NonStandardMessage_Thing) String() string { return protoimpl.X.MessageStringOf(x) } func (*NonStandardMessage_Thing) ProtoMessage() {} func (x *NonStandardMessage_Thing) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_non_standard_names_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NonStandardMessage_Thing.ProtoReflect.Descriptor instead. func (*NonStandardMessage_Thing) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_non_standard_names_proto_rawDescGZIP(), []int{0, 0} } func (x *NonStandardMessage_Thing) GetSubThing() *NonStandardMessage_Thing_SubThing { if x != nil { return x.SubThing } return nil } type NonStandardMessage_Thing_SubThing struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields SubValue string `protobuf:"bytes,1,opt,name=sub_value,json=subValue,proto3" json:"sub_value,omitempty"` } func (x *NonStandardMessage_Thing_SubThing) Reset() { *x = NonStandardMessage_Thing_SubThing{} mi := &file_runtime_internal_examplepb_non_standard_names_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NonStandardMessage_Thing_SubThing) String() string { return protoimpl.X.MessageStringOf(x) } func (*NonStandardMessage_Thing_SubThing) ProtoMessage() {} func (x *NonStandardMessage_Thing_SubThing) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_non_standard_names_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NonStandardMessage_Thing_SubThing.ProtoReflect.Descriptor instead. func (*NonStandardMessage_Thing_SubThing) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_non_standard_names_proto_rawDescGZIP(), []int{0, 0, 0} } func (x *NonStandardMessage_Thing_SubThing) GetSubValue() string { if x != nil { return x.SubValue } return "" } type NonStandardMessageWithJSONNames_Thing struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields SubThing *NonStandardMessageWithJSONNames_Thing_SubThing `protobuf:"bytes,1,opt,name=subThing,json=SubThing,proto3" json:"subThing,omitempty"` } func (x *NonStandardMessageWithJSONNames_Thing) Reset() { *x = NonStandardMessageWithJSONNames_Thing{} mi := &file_runtime_internal_examplepb_non_standard_names_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NonStandardMessageWithJSONNames_Thing) String() string { return protoimpl.X.MessageStringOf(x) } func (*NonStandardMessageWithJSONNames_Thing) ProtoMessage() {} func (x *NonStandardMessageWithJSONNames_Thing) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_non_standard_names_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NonStandardMessageWithJSONNames_Thing.ProtoReflect.Descriptor instead. func (*NonStandardMessageWithJSONNames_Thing) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_non_standard_names_proto_rawDescGZIP(), []int{2, 0} } func (x *NonStandardMessageWithJSONNames_Thing) GetSubThing() *NonStandardMessageWithJSONNames_Thing_SubThing { if x != nil { return x.SubThing } return nil } type NonStandardMessageWithJSONNames_Thing_SubThing struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields SubValue string `protobuf:"bytes,1,opt,name=sub_value,json=sub_Value,proto3" json:"sub_value,omitempty"` } func (x *NonStandardMessageWithJSONNames_Thing_SubThing) Reset() { *x = NonStandardMessageWithJSONNames_Thing_SubThing{} mi := &file_runtime_internal_examplepb_non_standard_names_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *NonStandardMessageWithJSONNames_Thing_SubThing) String() string { return protoimpl.X.MessageStringOf(x) } func (*NonStandardMessageWithJSONNames_Thing_SubThing) ProtoMessage() {} func (x *NonStandardMessageWithJSONNames_Thing_SubThing) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_non_standard_names_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use NonStandardMessageWithJSONNames_Thing_SubThing.ProtoReflect.Descriptor instead. func (*NonStandardMessageWithJSONNames_Thing_SubThing) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_non_standard_names_proto_rawDescGZIP(), []int{2, 0, 0} } func (x *NonStandardMessageWithJSONNames_Thing_SubThing) GetSubValue() string { if x != nil { return x.SubValue } return "" } var File_runtime_internal_examplepb_non_standard_names_proto protoreflect.FileDescriptor var file_runtime_internal_examplepb_non_standard_names_proto_rawDesc = []byte{ 0x0a, 0x33, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x6e, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x27, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x95, 0x04, 0x0a, 0x12, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x4e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x4e, 0x75, 0x6d, 0x12, 0x19, 0x0a, 0x08, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x6c, 0x69, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x6c, 0x61, 0x6e, 0x67, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6c, 0x61, 0x6e, 0x67, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x12, 0x13, 0x0a, 0x05, 0x65, 0x6e, 0x5f, 0x47, 0x42, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x65, 0x6e, 0x47, 0x42, 0x12, 0x0e, 0x0a, 0x02, 0x6e, 0x6f, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x6e, 0x6f, 0x12, 0x57, 0x0a, 0x05, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x41, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x3a, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x37, 0x0a, 0x0b, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x1a, 0x98, 0x01, 0x0a, 0x05, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x66, 0x0a, 0x08, 0x73, 0x75, 0x62, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x4a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x53, 0x75, 0x62, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x52, 0x08, 0x73, 0x75, 0x62, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x27, 0x0a, 0x08, 0x53, 0x75, 0x62, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x75, 0x62, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x75, 0x62, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xa8, 0x01, 0x0a, 0x18, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x4f, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x3b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x3b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x6b, 0x22, 0xc0, 0x04, 0x0a, 0x1f, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x57, 0x69, 0x74, 0x68, 0x4a, 0x53, 0x4f, 0x4e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x44, 0x12, 0x10, 0x0a, 0x03, 0x4e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x4e, 0x75, 0x6d, 0x12, 0x19, 0x0a, 0x08, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x4c, 0x69, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x6c, 0x61, 0x6e, 0x67, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6c, 0x61, 0x6e, 0x67, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6e, 0x5f, 0x47, 0x42, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x45, 0x6e, 0x5f, 0x47, 0x42, 0x12, 0x0f, 0x0a, 0x02, 0x6e, 0x6f, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x79, 0x65, 0x73, 0x12, 0x65, 0x0a, 0x05, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x4e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x57, 0x69, 0x74, 0x68, 0x4a, 0x53, 0x4f, 0x4e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x79, 0x12, 0x3a, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x0b, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x37, 0x0a, 0x0b, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x1a, 0xa6, 0x01, 0x0a, 0x05, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x73, 0x0a, 0x08, 0x73, 0x75, 0x62, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x57, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x57, 0x69, 0x74, 0x68, 0x4a, 0x53, 0x4f, 0x4e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x53, 0x75, 0x62, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x52, 0x08, 0x53, 0x75, 0x62, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x1a, 0x28, 0x0a, 0x08, 0x53, 0x75, 0x62, 0x54, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x75, 0x62, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x75, 0x62, 0x5f, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xc2, 0x01, 0x0a, 0x25, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x57, 0x69, 0x74, 0x68, 0x4a, 0x53, 0x4f, 0x4e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x5c, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x48, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x57, 0x69, 0x74, 0x68, 0x4a, 0x53, 0x4f, 0x4e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x3b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x6b, 0x32, 0xbf, 0x03, 0x0a, 0x12, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xb7, 0x01, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x41, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x2d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x27, 0x3a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x32, 0x1f, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x6e, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0xee, 0x01, 0x0a, 0x13, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x69, 0x74, 0x68, 0x4a, 0x53, 0x4f, 0x4e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12, 0x4e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x57, 0x69, 0x74, 0x68, 0x4a, 0x53, 0x4f, 0x4e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x48, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x57, 0x69, 0x74, 0x68, 0x4a, 0x53, 0x4f, 0x4e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x22, 0x3d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x37, 0x3a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x32, 0x2f, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x6e, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x42, 0x4d, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_runtime_internal_examplepb_non_standard_names_proto_rawDescOnce sync.Once file_runtime_internal_examplepb_non_standard_names_proto_rawDescData = file_runtime_internal_examplepb_non_standard_names_proto_rawDesc ) func file_runtime_internal_examplepb_non_standard_names_proto_rawDescGZIP() []byte { file_runtime_internal_examplepb_non_standard_names_proto_rawDescOnce.Do(func() { file_runtime_internal_examplepb_non_standard_names_proto_rawDescData = protoimpl.X.CompressGZIP(file_runtime_internal_examplepb_non_standard_names_proto_rawDescData) }) return file_runtime_internal_examplepb_non_standard_names_proto_rawDescData } var file_runtime_internal_examplepb_non_standard_names_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_runtime_internal_examplepb_non_standard_names_proto_goTypes = []any{ (*NonStandardMessage)(nil), // 0: grpc.gateway.runtime.internal.examplepb.NonStandardMessage (*NonStandardUpdateRequest)(nil), // 1: grpc.gateway.runtime.internal.examplepb.NonStandardUpdateRequest (*NonStandardMessageWithJSONNames)(nil), // 2: grpc.gateway.runtime.internal.examplepb.NonStandardMessageWithJSONNames (*NonStandardWithJSONNamesUpdateRequest)(nil), // 3: grpc.gateway.runtime.internal.examplepb.NonStandardWithJSONNamesUpdateRequest (*NonStandardMessage_Thing)(nil), // 4: grpc.gateway.runtime.internal.examplepb.NonStandardMessage.Thing (*NonStandardMessage_Thing_SubThing)(nil), // 5: grpc.gateway.runtime.internal.examplepb.NonStandardMessage.Thing.SubThing (*NonStandardMessageWithJSONNames_Thing)(nil), // 6: grpc.gateway.runtime.internal.examplepb.NonStandardMessageWithJSONNames.Thing (*NonStandardMessageWithJSONNames_Thing_SubThing)(nil), // 7: grpc.gateway.runtime.internal.examplepb.NonStandardMessageWithJSONNames.Thing.SubThing (*structpb.Struct)(nil), // 8: google.protobuf.Struct (*structpb.Value)(nil), // 9: google.protobuf.Value (*fieldmaskpb.FieldMask)(nil), // 10: google.protobuf.FieldMask } var file_runtime_internal_examplepb_non_standard_names_proto_depIdxs = []int32{ 4, // 0: grpc.gateway.runtime.internal.examplepb.NonStandardMessage.thing:type_name -> grpc.gateway.runtime.internal.examplepb.NonStandardMessage.Thing 8, // 1: grpc.gateway.runtime.internal.examplepb.NonStandardMessage.struct_field:type_name -> google.protobuf.Struct 9, // 2: grpc.gateway.runtime.internal.examplepb.NonStandardMessage.value_field:type_name -> google.protobuf.Value 0, // 3: grpc.gateway.runtime.internal.examplepb.NonStandardUpdateRequest.body:type_name -> grpc.gateway.runtime.internal.examplepb.NonStandardMessage 10, // 4: grpc.gateway.runtime.internal.examplepb.NonStandardUpdateRequest.update_mask:type_name -> google.protobuf.FieldMask 6, // 5: grpc.gateway.runtime.internal.examplepb.NonStandardMessageWithJSONNames.thing:type_name -> grpc.gateway.runtime.internal.examplepb.NonStandardMessageWithJSONNames.Thing 8, // 6: grpc.gateway.runtime.internal.examplepb.NonStandardMessageWithJSONNames.struct_field:type_name -> google.protobuf.Struct 9, // 7: grpc.gateway.runtime.internal.examplepb.NonStandardMessageWithJSONNames.value_field:type_name -> google.protobuf.Value 2, // 8: grpc.gateway.runtime.internal.examplepb.NonStandardWithJSONNamesUpdateRequest.body:type_name -> grpc.gateway.runtime.internal.examplepb.NonStandardMessageWithJSONNames 10, // 9: grpc.gateway.runtime.internal.examplepb.NonStandardWithJSONNamesUpdateRequest.update_mask:type_name -> google.protobuf.FieldMask 5, // 10: grpc.gateway.runtime.internal.examplepb.NonStandardMessage.Thing.subThing:type_name -> grpc.gateway.runtime.internal.examplepb.NonStandardMessage.Thing.SubThing 7, // 11: grpc.gateway.runtime.internal.examplepb.NonStandardMessageWithJSONNames.Thing.subThing:type_name -> grpc.gateway.runtime.internal.examplepb.NonStandardMessageWithJSONNames.Thing.SubThing 1, // 12: grpc.gateway.runtime.internal.examplepb.NonStandardService.Update:input_type -> grpc.gateway.runtime.internal.examplepb.NonStandardUpdateRequest 3, // 13: grpc.gateway.runtime.internal.examplepb.NonStandardService.UpdateWithJSONNames:input_type -> grpc.gateway.runtime.internal.examplepb.NonStandardWithJSONNamesUpdateRequest 0, // 14: grpc.gateway.runtime.internal.examplepb.NonStandardService.Update:output_type -> grpc.gateway.runtime.internal.examplepb.NonStandardMessage 2, // 15: grpc.gateway.runtime.internal.examplepb.NonStandardService.UpdateWithJSONNames:output_type -> grpc.gateway.runtime.internal.examplepb.NonStandardMessageWithJSONNames 14, // [14:16] is the sub-list for method output_type 12, // [12:14] is the sub-list for method input_type 12, // [12:12] is the sub-list for extension type_name 12, // [12:12] is the sub-list for extension extendee 0, // [0:12] is the sub-list for field type_name } func init() { file_runtime_internal_examplepb_non_standard_names_proto_init() } func file_runtime_internal_examplepb_non_standard_names_proto_init() { if File_runtime_internal_examplepb_non_standard_names_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_runtime_internal_examplepb_non_standard_names_proto_rawDesc, NumEnums: 0, NumMessages: 8, NumExtensions: 0, NumServices: 1, }, GoTypes: file_runtime_internal_examplepb_non_standard_names_proto_goTypes, DependencyIndexes: file_runtime_internal_examplepb_non_standard_names_proto_depIdxs, MessageInfos: file_runtime_internal_examplepb_non_standard_names_proto_msgTypes, }.Build() File_runtime_internal_examplepb_non_standard_names_proto = out.File file_runtime_internal_examplepb_non_standard_names_proto_rawDesc = nil file_runtime_internal_examplepb_non_standard_names_proto_goTypes = nil file_runtime_internal_examplepb_non_standard_names_proto_depIdxs = nil } ================================================ FILE: runtime/internal/examplepb/non_standard_names.proto ================================================ syntax = "proto3"; package grpc.gateway.runtime.internal.examplepb; import "google/api/annotations.proto"; import "google/protobuf/field_mask.proto"; import "google/protobuf/struct.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"; // NonStandardMessage has oddly named fields. message NonStandardMessage { // Id represents the message identifier. string id = 1; int64 Num = 2; int64 line_num = 3; string langIdent = 4; string STATUS = 5; int64 en_GB = 6; string no = 7; message Thing { message SubThing { string sub_value = 1; } SubThing subThing = 1; } Thing thing = 8; google.protobuf.Struct struct_field = 9; google.protobuf.Value value_field = 10; } message NonStandardUpdateRequest { NonStandardMessage body = 1; google.protobuf.FieldMask update_mask = 2; } // NonStandardMessageWithJSONNames maps odd field names to odd JSON names for maximum confusion. message NonStandardMessageWithJSONNames { // Id represents the message identifier. string id = 1 [json_name = "ID"]; int64 Num = 2 [json_name = "Num"]; int64 line_num = 3 [json_name = "LineNum"]; string langIdent = 4 [json_name = "langIdent"]; string STATUS = 5 [json_name = "status"]; int64 en_GB = 6 [json_name = "En_GB"]; string no = 7 [json_name = "yes"]; message Thing { message SubThing { string sub_value = 1 [json_name = "sub_Value"]; } SubThing subThing = 1 [json_name = "SubThing"]; } Thing thing = 8 [json_name = "Thingy"]; google.protobuf.Struct struct_field = 9 [json_name = "StructField"]; google.protobuf.Value value_field = 10 [json_name = "ValueField"]; } message NonStandardWithJSONNamesUpdateRequest { NonStandardMessageWithJSONNames body = 1; google.protobuf.FieldMask update_mask = 2; } // NonStandardService responds to incoming messages, applies a field mask and returns the masked response. service NonStandardService { // Apply field mask to empty NonStandardMessage and return result. rpc Update(NonStandardUpdateRequest) returns (NonStandardMessage) { option (google.api.http) = { patch: "/v1/example/non_standard/update" body: "body" }; } // Apply field mask to empty NonStandardMessageWithJSONNames and return result. rpc UpdateWithJSONNames(NonStandardWithJSONNamesUpdateRequest) returns (NonStandardMessageWithJSONNames) { option (google.api.http) = { patch: "/v1/example/non_standard/update_with_json_names" body: "body" }; } } ================================================ FILE: runtime/internal/examplepb/non_standard_names.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "runtime/internal/examplepb/non_standard_names.proto", "version": "version not set" }, "tags": [ { "name": "NonStandardService" } ], "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": { "/v1/example/non_standard/update": { "patch": { "summary": "Apply field mask to empty NonStandardMessage and return result.", "operationId": "NonStandardService_Update", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbNonStandardMessage" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbNonStandardMessage" } } ], "tags": [ "NonStandardService" ] } }, "/v1/example/non_standard/update_with_json_names": { "patch": { "summary": "Apply field mask to empty NonStandardMessageWithJSONNames and return result.", "operationId": "NonStandardService_UpdateWithJSONNames", "responses": { "200": { "description": "A successful response.", "schema": { "$ref": "#/definitions/examplepbNonStandardMessageWithJSONNames" } }, "default": { "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/rpcStatus" } } }, "parameters": [ { "name": "body", "in": "body", "required": true, "schema": { "$ref": "#/definitions/examplepbNonStandardMessageWithJSONNames" } } ], "tags": [ "NonStandardService" ] } } }, "definitions": { "examplepbNonStandardMessage": { "type": "object", "properties": { "id": { "type": "string", "description": "Id represents the message identifier." }, "Num": { "type": "string", "format": "int64" }, "lineNum": { "type": "string", "format": "int64" }, "langIdent": { "type": "string" }, "STATUS": { "type": "string" }, "enGB": { "type": "string", "format": "int64" }, "no": { "type": "string" }, "thing": { "$ref": "#/definitions/examplepbNonStandardMessageThing" }, "structField": { "type": "object" }, "valueField": {} }, "description": "NonStandardMessage has oddly named fields." }, "examplepbNonStandardMessageThing": { "type": "object", "properties": { "subThing": { "$ref": "#/definitions/examplepbNonStandardMessageThingSubThing" } } }, "examplepbNonStandardMessageThingSubThing": { "type": "object", "properties": { "subValue": { "type": "string" } } }, "examplepbNonStandardMessageWithJSONNames": { "type": "object", "properties": { "ID": { "type": "string", "description": "Id represents the message identifier." }, "Num": { "type": "string", "format": "int64" }, "LineNum": { "type": "string", "format": "int64" }, "langIdent": { "type": "string" }, "status": { "type": "string" }, "En_GB": { "type": "string", "format": "int64" }, "yes": { "type": "string" }, "Thingy": { "$ref": "#/definitions/examplepbNonStandardMessageWithJSONNamesThing" }, "StructField": { "type": "object" }, "ValueField": {} }, "description": "NonStandardMessageWithJSONNames maps odd field names to odd JSON names for maximum confusion." }, "examplepbNonStandardMessageWithJSONNamesThing": { "type": "object", "properties": { "SubThing": { "$ref": "#/definitions/examplepbNonStandardMessageWithJSONNamesThingSubThing" } } }, "examplepbNonStandardMessageWithJSONNamesThingSubThing": { "type": "object", "properties": { "sub_Value": { "type": "string" } } }, "protobufAny": { "type": "object", "properties": { "@type": { "type": "string", "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics." } }, "additionalProperties": {}, "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }" }, "protobufNullValue": { "type": "string", "enum": [ "NULL_VALUE" ], "default": "NULL_VALUE", "description": "`NullValue` is a singleton enumeration to represent the null value for the\n`Value` type union.\n\nThe JSON representation for `NullValue` is JSON `null`.\n\n - NULL_VALUE: Null value." }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } } } } ================================================ FILE: runtime/internal/examplepb/non_standard_names_grpc.pb.go ================================================ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: runtime/internal/examplepb/non_standard_names.proto package examplepb import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( NonStandardService_Update_FullMethodName = "/grpc.gateway.runtime.internal.examplepb.NonStandardService/Update" NonStandardService_UpdateWithJSONNames_FullMethodName = "/grpc.gateway.runtime.internal.examplepb.NonStandardService/UpdateWithJSONNames" ) // NonStandardServiceClient is the client API for NonStandardService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // // NonStandardService responds to incoming messages, applies a field mask and returns the masked response. type NonStandardServiceClient interface { // Apply field mask to empty NonStandardMessage and return result. Update(ctx context.Context, in *NonStandardUpdateRequest, opts ...grpc.CallOption) (*NonStandardMessage, error) // Apply field mask to empty NonStandardMessageWithJSONNames and return result. UpdateWithJSONNames(ctx context.Context, in *NonStandardWithJSONNamesUpdateRequest, opts ...grpc.CallOption) (*NonStandardMessageWithJSONNames, error) } type nonStandardServiceClient struct { cc grpc.ClientConnInterface } func NewNonStandardServiceClient(cc grpc.ClientConnInterface) NonStandardServiceClient { return &nonStandardServiceClient{cc} } func (c *nonStandardServiceClient) Update(ctx context.Context, in *NonStandardUpdateRequest, opts ...grpc.CallOption) (*NonStandardMessage, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(NonStandardMessage) err := c.cc.Invoke(ctx, NonStandardService_Update_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *nonStandardServiceClient) UpdateWithJSONNames(ctx context.Context, in *NonStandardWithJSONNamesUpdateRequest, opts ...grpc.CallOption) (*NonStandardMessageWithJSONNames, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(NonStandardMessageWithJSONNames) err := c.cc.Invoke(ctx, NonStandardService_UpdateWithJSONNames_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } // NonStandardServiceServer is the server API for NonStandardService service. // All implementations should embed UnimplementedNonStandardServiceServer // for forward compatibility. // // NonStandardService responds to incoming messages, applies a field mask and returns the masked response. type NonStandardServiceServer interface { // Apply field mask to empty NonStandardMessage and return result. Update(context.Context, *NonStandardUpdateRequest) (*NonStandardMessage, error) // Apply field mask to empty NonStandardMessageWithJSONNames and return result. UpdateWithJSONNames(context.Context, *NonStandardWithJSONNamesUpdateRequest) (*NonStandardMessageWithJSONNames, error) } // UnimplementedNonStandardServiceServer should be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedNonStandardServiceServer struct{} func (UnimplementedNonStandardServiceServer) Update(context.Context, *NonStandardUpdateRequest) (*NonStandardMessage, error) { return nil, status.Errorf(codes.Unimplemented, "method Update not implemented") } func (UnimplementedNonStandardServiceServer) UpdateWithJSONNames(context.Context, *NonStandardWithJSONNamesUpdateRequest) (*NonStandardMessageWithJSONNames, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateWithJSONNames not implemented") } func (UnimplementedNonStandardServiceServer) testEmbeddedByValue() {} // UnsafeNonStandardServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to NonStandardServiceServer will // result in compilation errors. type UnsafeNonStandardServiceServer interface { mustEmbedUnimplementedNonStandardServiceServer() } func RegisterNonStandardServiceServer(s grpc.ServiceRegistrar, srv NonStandardServiceServer) { // If the following call pancis, it indicates UnimplementedNonStandardServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&NonStandardService_ServiceDesc, srv) } func _NonStandardService_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(NonStandardUpdateRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(NonStandardServiceServer).Update(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: NonStandardService_Update_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(NonStandardServiceServer).Update(ctx, req.(*NonStandardUpdateRequest)) } return interceptor(ctx, in, info, handler) } func _NonStandardService_UpdateWithJSONNames_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(NonStandardWithJSONNamesUpdateRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(NonStandardServiceServer).UpdateWithJSONNames(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: NonStandardService_UpdateWithJSONNames_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(NonStandardServiceServer).UpdateWithJSONNames(ctx, req.(*NonStandardWithJSONNamesUpdateRequest)) } return interceptor(ctx, in, info, handler) } // NonStandardService_ServiceDesc is the grpc.ServiceDesc for NonStandardService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var NonStandardService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "grpc.gateway.runtime.internal.examplepb.NonStandardService", HandlerType: (*NonStandardServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Update", Handler: _NonStandardService_Update_Handler, }, { MethodName: "UpdateWithJSONNames", Handler: _NonStandardService_UpdateWithJSONNames_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "runtime/internal/examplepb/non_standard_names.proto", } ================================================ FILE: runtime/internal/examplepb/proto2.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: runtime/internal/examplepb/proto2.proto package examplepb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) type Proto2Message struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields FloatValue *float32 `protobuf:"fixed32,42,opt,name=float_value,json=floatValue" json:"float_value,omitempty"` DoubleValue *float64 `protobuf:"fixed64,43,opt,name=double_value,json=doubleValue" json:"double_value,omitempty"` Int64Value *int64 `protobuf:"varint,3,opt,name=int64_value,json=int64Value" json:"int64_value,omitempty"` Int32Value *int32 `protobuf:"varint,4,opt,name=int32_value,json=int32Value" json:"int32_value,omitempty"` Uint64Value *uint64 `protobuf:"varint,5,opt,name=uint64_value,json=uint64Value" json:"uint64_value,omitempty"` Uint32Value *uint32 `protobuf:"varint,6,opt,name=uint32_value,json=uint32Value" json:"uint32_value,omitempty"` BoolValue *bool `protobuf:"varint,7,opt,name=bool_value,json=boolValue" json:"bool_value,omitempty"` StringValue *string `protobuf:"bytes,8,opt,name=string_value,json=stringValue" json:"string_value,omitempty"` BytesValue []byte `protobuf:"bytes,9,opt,name=bytes_value,json=bytesValue" json:"bytes_value,omitempty"` RepeatedValue []string `protobuf:"bytes,10,rep,name=repeated_value,json=repeatedValue" json:"repeated_value,omitempty"` } func (x *Proto2Message) Reset() { *x = Proto2Message{} mi := &file_runtime_internal_examplepb_proto2_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Proto2Message) String() string { return protoimpl.X.MessageStringOf(x) } func (*Proto2Message) ProtoMessage() {} func (x *Proto2Message) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_proto2_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Proto2Message.ProtoReflect.Descriptor instead. func (*Proto2Message) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_proto2_proto_rawDescGZIP(), []int{0} } func (x *Proto2Message) GetFloatValue() float32 { if x != nil && x.FloatValue != nil { return *x.FloatValue } return 0 } func (x *Proto2Message) GetDoubleValue() float64 { if x != nil && x.DoubleValue != nil { return *x.DoubleValue } return 0 } func (x *Proto2Message) GetInt64Value() int64 { if x != nil && x.Int64Value != nil { return *x.Int64Value } return 0 } func (x *Proto2Message) GetInt32Value() int32 { if x != nil && x.Int32Value != nil { return *x.Int32Value } return 0 } func (x *Proto2Message) GetUint64Value() uint64 { if x != nil && x.Uint64Value != nil { return *x.Uint64Value } return 0 } func (x *Proto2Message) GetUint32Value() uint32 { if x != nil && x.Uint32Value != nil { return *x.Uint32Value } return 0 } func (x *Proto2Message) GetBoolValue() bool { if x != nil && x.BoolValue != nil { return *x.BoolValue } return false } func (x *Proto2Message) GetStringValue() string { if x != nil && x.StringValue != nil { return *x.StringValue } return "" } func (x *Proto2Message) GetBytesValue() []byte { if x != nil { return x.BytesValue } return nil } func (x *Proto2Message) GetRepeatedValue() []string { if x != nil { return x.RepeatedValue } return nil } var File_runtime_internal_examplepb_proto2_proto protoreflect.FileDescriptor var file_runtime_internal_examplepb_proto2_proto_rawDesc = []byte{ 0x0a, 0x27, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x27, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x22, 0xe5, 0x02, 0x0a, 0x0d, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x2a, 0x20, 0x01, 0x28, 0x02, 0x52, 0x0a, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x2b, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0b, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x62, 0x79, 0x74, 0x65, 0x73, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x46, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, } var ( file_runtime_internal_examplepb_proto2_proto_rawDescOnce sync.Once file_runtime_internal_examplepb_proto2_proto_rawDescData = file_runtime_internal_examplepb_proto2_proto_rawDesc ) func file_runtime_internal_examplepb_proto2_proto_rawDescGZIP() []byte { file_runtime_internal_examplepb_proto2_proto_rawDescOnce.Do(func() { file_runtime_internal_examplepb_proto2_proto_rawDescData = protoimpl.X.CompressGZIP(file_runtime_internal_examplepb_proto2_proto_rawDescData) }) return file_runtime_internal_examplepb_proto2_proto_rawDescData } var file_runtime_internal_examplepb_proto2_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_runtime_internal_examplepb_proto2_proto_goTypes = []any{ (*Proto2Message)(nil), // 0: grpc.gateway.runtime.internal.examplepb.Proto2Message } var file_runtime_internal_examplepb_proto2_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type 0, // [0:0] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name } func init() { file_runtime_internal_examplepb_proto2_proto_init() } func file_runtime_internal_examplepb_proto2_proto_init() { if File_runtime_internal_examplepb_proto2_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_runtime_internal_examplepb_proto2_proto_rawDesc, NumEnums: 0, NumMessages: 1, NumExtensions: 0, NumServices: 0, }, GoTypes: file_runtime_internal_examplepb_proto2_proto_goTypes, DependencyIndexes: file_runtime_internal_examplepb_proto2_proto_depIdxs, MessageInfos: file_runtime_internal_examplepb_proto2_proto_msgTypes, }.Build() File_runtime_internal_examplepb_proto2_proto = out.File file_runtime_internal_examplepb_proto2_proto_rawDesc = nil file_runtime_internal_examplepb_proto2_proto_goTypes = nil file_runtime_internal_examplepb_proto2_proto_depIdxs = nil } ================================================ FILE: runtime/internal/examplepb/proto2.proto ================================================ syntax = "proto2"; package grpc.gateway.runtime.internal.examplepb; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/runtime/internal/examplepb"; message Proto2Message { optional float float_value = 42; optional double double_value = 43; optional int64 int64_value = 3; optional int32 int32_value = 4; optional uint64 uint64_value = 5; optional uint32 uint32_value = 6; optional bool bool_value = 7; optional string string_value = 8; optional bytes bytes_value = 9; repeated string repeated_value = 10; } ================================================ FILE: runtime/internal/examplepb/proto2.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "runtime/internal/examplepb/proto2.proto", "version": "version not set" }, "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": {}, "definitions": { "protobufAny": { "type": "object", "properties": { "@type": { "type": "string", "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics." } }, "additionalProperties": {}, "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }" }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } } } } ================================================ FILE: runtime/internal/examplepb/proto3.pb.go ================================================ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 // protoc (unknown) // source: runtime/internal/examplepb/proto3.proto package examplepb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" durationpb "google.golang.org/protobuf/types/known/durationpb" fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" structpb "google.golang.org/protobuf/types/known/structpb" timestamppb "google.golang.org/protobuf/types/known/timestamppb" wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" reflect "reflect" sync "sync" ) const ( // Verify that this generated code is sufficiently up-to-date. _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) // Verify that runtime/protoimpl is sufficiently up-to-date. _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) type EnumValue int32 const ( EnumValue_X EnumValue = 0 EnumValue_Y EnumValue = 1 EnumValue_Z EnumValue = 2 ) // Enum value maps for EnumValue. var ( EnumValue_name = map[int32]string{ 0: "X", 1: "Y", 2: "Z", } EnumValue_value = map[string]int32{ "X": 0, "Y": 1, "Z": 2, } ) func (x EnumValue) Enum() *EnumValue { p := new(EnumValue) *p = x return p } func (x EnumValue) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } func (EnumValue) Descriptor() protoreflect.EnumDescriptor { return file_runtime_internal_examplepb_proto3_proto_enumTypes[0].Descriptor() } func (EnumValue) Type() protoreflect.EnumType { return &file_runtime_internal_examplepb_proto3_proto_enumTypes[0] } func (x EnumValue) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } // Deprecated: Use EnumValue.Descriptor instead. func (EnumValue) EnumDescriptor() ([]byte, []int) { return file_runtime_internal_examplepb_proto3_proto_rawDescGZIP(), []int{0} } type Proto3Message struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Next number: 51 Nested *Proto3Message `protobuf:"bytes,41,opt,name=nested,proto3" json:"nested,omitempty"` FloatValue float32 `protobuf:"fixed32,42,opt,name=float_value,json=floatValue,proto3" json:"float_value,omitempty"` DoubleValue float64 `protobuf:"fixed64,43,opt,name=double_value,json=doubleValue,proto3" json:"double_value,omitempty"` Int64Value int64 `protobuf:"varint,3,opt,name=int64_value,json=int64Value,proto3" json:"int64_value,omitempty"` Int32Value int32 `protobuf:"varint,4,opt,name=int32_value,json=int32Value,proto3" json:"int32_value,omitempty"` Uint64Value uint64 `protobuf:"varint,5,opt,name=uint64_value,json=uint64Value,proto3" json:"uint64_value,omitempty"` Uint32Value uint32 `protobuf:"varint,6,opt,name=uint32_value,json=uint32Value,proto3" json:"uint32_value,omitempty"` BoolValue bool `protobuf:"varint,7,opt,name=bool_value,json=boolValue,proto3" json:"bool_value,omitempty"` StringValue string `protobuf:"bytes,8,opt,name=string_value,json=stringValue,proto3" json:"string_value,omitempty"` BytesValue []byte `protobuf:"bytes,9,opt,name=bytes_value,json=bytesValue,proto3" json:"bytes_value,omitempty"` RepeatedValue []string `protobuf:"bytes,10,rep,name=repeated_value,json=repeatedValue,proto3" json:"repeated_value,omitempty"` OptionalValue *string `protobuf:"bytes,49,opt,name=optional_value,json=optionalValue,proto3,oneof" json:"optional_value,omitempty"` RepeatedMessage []*wrapperspb.UInt64Value `protobuf:"bytes,44,rep,name=repeated_message,json=repeatedMessage,proto3" json:"repeated_message,omitempty"` EnumValue EnumValue `protobuf:"varint,11,opt,name=enum_value,json=enumValue,proto3,enum=grpc.gateway.runtime.internal.examplepb.EnumValue" json:"enum_value,omitempty"` RepeatedEnum []EnumValue `protobuf:"varint,12,rep,packed,name=repeated_enum,json=repeatedEnum,proto3,enum=grpc.gateway.runtime.internal.examplepb.EnumValue" json:"repeated_enum,omitempty"` TimestampValue *timestamppb.Timestamp `protobuf:"bytes,13,opt,name=timestamp_value,json=timestampValue,proto3" json:"timestamp_value,omitempty"` DurationValue *durationpb.Duration `protobuf:"bytes,14,opt,name=duration_value,json=durationValue,proto3" json:"duration_value,omitempty"` FieldmaskValue *fieldmaskpb.FieldMask `protobuf:"bytes,15,opt,name=fieldmask_value,json=fieldmaskValue,proto3" json:"fieldmask_value,omitempty"` // Types that are assignable to OneofValue: // // *Proto3Message_OneofBoolValue // *Proto3Message_OneofStringValue OneofValue isProto3Message_OneofValue `protobuf_oneof:"oneof_value"` // Types that are assignable to NestedOneofValue: // // *Proto3Message_NestedOneofInt32Value // *Proto3Message_NestedOneofValueOne NestedOneofValue isProto3Message_NestedOneofValue `protobuf_oneof:"nested_oneof_value"` WrapperDoubleValue *wrapperspb.DoubleValue `protobuf:"bytes,17,opt,name=wrapper_double_value,json=wrapperDoubleValue,proto3" json:"wrapper_double_value,omitempty"` WrapperFloatValue *wrapperspb.FloatValue `protobuf:"bytes,18,opt,name=wrapper_float_value,json=wrapperFloatValue,proto3" json:"wrapper_float_value,omitempty"` WrapperInt64Value *wrapperspb.Int64Value `protobuf:"bytes,19,opt,name=wrapper_int64_value,json=wrapperInt64Value,proto3" json:"wrapper_int64_value,omitempty"` WrapperInt32Value *wrapperspb.Int32Value `protobuf:"bytes,20,opt,name=wrapper_int32_value,json=wrapperInt32Value,proto3" json:"wrapper_int32_value,omitempty"` WrapperUInt64Value *wrapperspb.UInt64Value `protobuf:"bytes,21,opt,name=wrapper_u_int64_value,json=wrapperUInt64Value,proto3" json:"wrapper_u_int64_value,omitempty"` WrapperUInt32Value *wrapperspb.UInt32Value `protobuf:"bytes,22,opt,name=wrapper_u_int32_value,json=wrapperUInt32Value,proto3" json:"wrapper_u_int32_value,omitempty"` WrapperBoolValue *wrapperspb.BoolValue `protobuf:"bytes,23,opt,name=wrapper_bool_value,json=wrapperBoolValue,proto3" json:"wrapper_bool_value,omitempty"` WrapperStringValue *wrapperspb.StringValue `protobuf:"bytes,24,opt,name=wrapper_string_value,json=wrapperStringValue,proto3" json:"wrapper_string_value,omitempty"` WrapperBytesValue *wrapperspb.BytesValue `protobuf:"bytes,25,opt,name=wrapper_bytes_value,json=wrapperBytesValue,proto3" json:"wrapper_bytes_value,omitempty"` MapValue map[string]string `protobuf:"bytes,26,rep,name=map_value,json=mapValue,proto3" json:"map_value,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` MapValue2 map[string]int32 `protobuf:"bytes,27,rep,name=map_value2,json=mapValue2,proto3" json:"map_value2,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` MapValue3 map[int32]string `protobuf:"bytes,28,rep,name=map_value3,json=mapValue3,proto3" json:"map_value3,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` MapValue4 map[string]int64 `protobuf:"bytes,29,rep,name=map_value4,json=mapValue4,proto3" json:"map_value4,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` MapValue5 map[int64]string `protobuf:"bytes,30,rep,name=map_value5,json=mapValue5,proto3" json:"map_value5,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` MapValue6 map[string]uint32 `protobuf:"bytes,31,rep,name=map_value6,json=mapValue6,proto3" json:"map_value6,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` MapValue7 map[uint32]string `protobuf:"bytes,32,rep,name=map_value7,json=mapValue7,proto3" json:"map_value7,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` MapValue8 map[string]uint64 `protobuf:"bytes,33,rep,name=map_value8,json=mapValue8,proto3" json:"map_value8,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` MapValue9 map[uint64]string `protobuf:"bytes,34,rep,name=map_value9,json=mapValue9,proto3" json:"map_value9,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` MapValue10 map[string]float32 `protobuf:"bytes,35,rep,name=map_value10,json=mapValue10,proto3" json:"map_value10,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"fixed32,2,opt,name=value,proto3"` MapValue12 map[string]float64 `protobuf:"bytes,37,rep,name=map_value12,json=mapValue12,proto3" json:"map_value12,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"fixed64,2,opt,name=value,proto3"` MapValue14 map[string]bool `protobuf:"bytes,39,rep,name=map_value14,json=mapValue14,proto3" json:"map_value14,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` MapValue15 map[bool]string `protobuf:"bytes,40,rep,name=map_value15,json=mapValue15,proto3" json:"map_value15,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` MapValue16 map[string]*wrapperspb.UInt64Value `protobuf:"bytes,45,rep,name=map_value16,json=mapValue16,proto3" json:"map_value16,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` StructValueValue *structpb.Value `protobuf:"bytes,47,opt,name=struct_value_value,json=structValueValue,proto3" json:"struct_value_value,omitempty"` StructValue *structpb.Struct `protobuf:"bytes,48,opt,name=struct_value,json=structValue,proto3" json:"struct_value,omitempty"` } func (x *Proto3Message) Reset() { *x = Proto3Message{} mi := &file_runtime_internal_examplepb_proto3_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } func (x *Proto3Message) String() string { return protoimpl.X.MessageStringOf(x) } func (*Proto3Message) ProtoMessage() {} func (x *Proto3Message) ProtoReflect() protoreflect.Message { mi := &file_runtime_internal_examplepb_proto3_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) } // Deprecated: Use Proto3Message.ProtoReflect.Descriptor instead. func (*Proto3Message) Descriptor() ([]byte, []int) { return file_runtime_internal_examplepb_proto3_proto_rawDescGZIP(), []int{0} } func (x *Proto3Message) GetNested() *Proto3Message { if x != nil { return x.Nested } return nil } func (x *Proto3Message) GetFloatValue() float32 { if x != nil { return x.FloatValue } return 0 } func (x *Proto3Message) GetDoubleValue() float64 { if x != nil { return x.DoubleValue } return 0 } func (x *Proto3Message) GetInt64Value() int64 { if x != nil { return x.Int64Value } return 0 } func (x *Proto3Message) GetInt32Value() int32 { if x != nil { return x.Int32Value } return 0 } func (x *Proto3Message) GetUint64Value() uint64 { if x != nil { return x.Uint64Value } return 0 } func (x *Proto3Message) GetUint32Value() uint32 { if x != nil { return x.Uint32Value } return 0 } func (x *Proto3Message) GetBoolValue() bool { if x != nil { return x.BoolValue } return false } func (x *Proto3Message) GetStringValue() string { if x != nil { return x.StringValue } return "" } func (x *Proto3Message) GetBytesValue() []byte { if x != nil { return x.BytesValue } return nil } func (x *Proto3Message) GetRepeatedValue() []string { if x != nil { return x.RepeatedValue } return nil } func (x *Proto3Message) GetOptionalValue() string { if x != nil && x.OptionalValue != nil { return *x.OptionalValue } return "" } func (x *Proto3Message) GetRepeatedMessage() []*wrapperspb.UInt64Value { if x != nil { return x.RepeatedMessage } return nil } func (x *Proto3Message) GetEnumValue() EnumValue { if x != nil { return x.EnumValue } return EnumValue_X } func (x *Proto3Message) GetRepeatedEnum() []EnumValue { if x != nil { return x.RepeatedEnum } return nil } func (x *Proto3Message) GetTimestampValue() *timestamppb.Timestamp { if x != nil { return x.TimestampValue } return nil } func (x *Proto3Message) GetDurationValue() *durationpb.Duration { if x != nil { return x.DurationValue } return nil } func (x *Proto3Message) GetFieldmaskValue() *fieldmaskpb.FieldMask { if x != nil { return x.FieldmaskValue } return nil } func (m *Proto3Message) GetOneofValue() isProto3Message_OneofValue { if m != nil { return m.OneofValue } return nil } func (x *Proto3Message) GetOneofBoolValue() bool { if x, ok := x.GetOneofValue().(*Proto3Message_OneofBoolValue); ok { return x.OneofBoolValue } return false } func (x *Proto3Message) GetOneofStringValue() string { if x, ok := x.GetOneofValue().(*Proto3Message_OneofStringValue); ok { return x.OneofStringValue } return "" } func (m *Proto3Message) GetNestedOneofValue() isProto3Message_NestedOneofValue { if m != nil { return m.NestedOneofValue } return nil } func (x *Proto3Message) GetNestedOneofInt32Value() int32 { if x, ok := x.GetNestedOneofValue().(*Proto3Message_NestedOneofInt32Value); ok { return x.NestedOneofInt32Value } return 0 } func (x *Proto3Message) GetNestedOneofValueOne() *Proto3Message { if x, ok := x.GetNestedOneofValue().(*Proto3Message_NestedOneofValueOne); ok { return x.NestedOneofValueOne } return nil } func (x *Proto3Message) GetWrapperDoubleValue() *wrapperspb.DoubleValue { if x != nil { return x.WrapperDoubleValue } return nil } func (x *Proto3Message) GetWrapperFloatValue() *wrapperspb.FloatValue { if x != nil { return x.WrapperFloatValue } return nil } func (x *Proto3Message) GetWrapperInt64Value() *wrapperspb.Int64Value { if x != nil { return x.WrapperInt64Value } return nil } func (x *Proto3Message) GetWrapperInt32Value() *wrapperspb.Int32Value { if x != nil { return x.WrapperInt32Value } return nil } func (x *Proto3Message) GetWrapperUInt64Value() *wrapperspb.UInt64Value { if x != nil { return x.WrapperUInt64Value } return nil } func (x *Proto3Message) GetWrapperUInt32Value() *wrapperspb.UInt32Value { if x != nil { return x.WrapperUInt32Value } return nil } func (x *Proto3Message) GetWrapperBoolValue() *wrapperspb.BoolValue { if x != nil { return x.WrapperBoolValue } return nil } func (x *Proto3Message) GetWrapperStringValue() *wrapperspb.StringValue { if x != nil { return x.WrapperStringValue } return nil } func (x *Proto3Message) GetWrapperBytesValue() *wrapperspb.BytesValue { if x != nil { return x.WrapperBytesValue } return nil } func (x *Proto3Message) GetMapValue() map[string]string { if x != nil { return x.MapValue } return nil } func (x *Proto3Message) GetMapValue2() map[string]int32 { if x != nil { return x.MapValue2 } return nil } func (x *Proto3Message) GetMapValue3() map[int32]string { if x != nil { return x.MapValue3 } return nil } func (x *Proto3Message) GetMapValue4() map[string]int64 { if x != nil { return x.MapValue4 } return nil } func (x *Proto3Message) GetMapValue5() map[int64]string { if x != nil { return x.MapValue5 } return nil } func (x *Proto3Message) GetMapValue6() map[string]uint32 { if x != nil { return x.MapValue6 } return nil } func (x *Proto3Message) GetMapValue7() map[uint32]string { if x != nil { return x.MapValue7 } return nil } func (x *Proto3Message) GetMapValue8() map[string]uint64 { if x != nil { return x.MapValue8 } return nil } func (x *Proto3Message) GetMapValue9() map[uint64]string { if x != nil { return x.MapValue9 } return nil } func (x *Proto3Message) GetMapValue10() map[string]float32 { if x != nil { return x.MapValue10 } return nil } func (x *Proto3Message) GetMapValue12() map[string]float64 { if x != nil { return x.MapValue12 } return nil } func (x *Proto3Message) GetMapValue14() map[string]bool { if x != nil { return x.MapValue14 } return nil } func (x *Proto3Message) GetMapValue15() map[bool]string { if x != nil { return x.MapValue15 } return nil } func (x *Proto3Message) GetMapValue16() map[string]*wrapperspb.UInt64Value { if x != nil { return x.MapValue16 } return nil } func (x *Proto3Message) GetStructValueValue() *structpb.Value { if x != nil { return x.StructValueValue } return nil } func (x *Proto3Message) GetStructValue() *structpb.Struct { if x != nil { return x.StructValue } return nil } type isProto3Message_OneofValue interface { isProto3Message_OneofValue() } type Proto3Message_OneofBoolValue struct { OneofBoolValue bool `protobuf:"varint,1,opt,name=oneof_bool_value,json=oneofBoolValue,proto3,oneof"` } type Proto3Message_OneofStringValue struct { OneofStringValue string `protobuf:"bytes,2,opt,name=oneof_string_value,json=oneofStringValue,proto3,oneof"` } func (*Proto3Message_OneofBoolValue) isProto3Message_OneofValue() {} func (*Proto3Message_OneofStringValue) isProto3Message_OneofValue() {} type isProto3Message_NestedOneofValue interface { isProto3Message_NestedOneofValue() } type Proto3Message_NestedOneofInt32Value struct { NestedOneofInt32Value int32 `protobuf:"varint,50,opt,name=nested_oneof_int32_value,json=nestedOneofInt32Value,proto3,oneof"` } type Proto3Message_NestedOneofValueOne struct { NestedOneofValueOne *Proto3Message `protobuf:"bytes,46,opt,name=nested_oneof_value_one,json=nestedOneofValueOne,proto3,oneof"` } func (*Proto3Message_NestedOneofInt32Value) isProto3Message_NestedOneofValue() {} func (*Proto3Message_NestedOneofValueOne) isProto3Message_NestedOneofValue() {} var File_runtime_internal_examplepb_proto3_proto protoreflect.FileDescriptor var file_runtime_internal_examplepb_proto3_proto_rawDesc = []byte{ 0x0a, 0x27, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x27, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc8, 0x22, 0x0a, 0x0d, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x4e, 0x0a, 0x06, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x18, 0x29, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x06, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x2a, 0x20, 0x01, 0x28, 0x02, 0x52, 0x0a, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x2b, 0x20, 0x01, 0x28, 0x01, 0x52, 0x0b, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x62, 0x79, 0x74, 0x65, 0x73, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x2a, 0x0a, 0x0e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x31, 0x20, 0x01, 0x28, 0x09, 0x48, 0x02, 0x52, 0x0d, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x88, 0x01, 0x01, 0x12, 0x47, 0x0a, 0x10, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x2c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0f, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x51, 0x0a, 0x0a, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x32, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x09, 0x65, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x57, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x32, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x43, 0x0a, 0x0f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x40, 0x0a, 0x0e, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x43, 0x0a, 0x0f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x6d, 0x61, 0x73, 0x6b, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x52, 0x0e, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x6d, 0x61, 0x73, 0x6b, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x2a, 0x0a, 0x10, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x5f, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x0e, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x42, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x2e, 0x0a, 0x12, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x10, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x39, 0x0a, 0x18, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x5f, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x32, 0x20, 0x01, 0x28, 0x05, 0x48, 0x01, 0x52, 0x15, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x4f, 0x6e, 0x65, 0x6f, 0x66, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x6d, 0x0a, 0x16, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x6f, 0x6e, 0x65, 0x18, 0x2e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x01, 0x52, 0x13, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x4f, 0x6e, 0x65, 0x6f, 0x66, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x4f, 0x6e, 0x65, 0x12, 0x4e, 0x0a, 0x14, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x5f, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x11, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x12, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x4b, 0x0a, 0x13, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x5f, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x12, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x11, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x4b, 0x0a, 0x13, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x13, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x11, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x4b, 0x0a, 0x13, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x11, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x4f, 0x0a, 0x15, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x5f, 0x75, 0x5f, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x12, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x4f, 0x0a, 0x15, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x5f, 0x75, 0x5f, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x16, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x12, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x55, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x48, 0x0a, 0x12, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x5f, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x17, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x10, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x42, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x4e, 0x0a, 0x14, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x18, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x12, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x4b, 0x0a, 0x13, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x19, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x42, 0x79, 0x74, 0x65, 0x73, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x11, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x42, 0x79, 0x74, 0x65, 0x73, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x61, 0x0a, 0x09, 0x6d, 0x61, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x1a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x44, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x6d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x64, 0x0a, 0x0a, 0x6d, 0x61, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x32, 0x18, 0x1b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x45, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x32, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x6d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x32, 0x12, 0x64, 0x0a, 0x0a, 0x6d, 0x61, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x33, 0x18, 0x1c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x45, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x33, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x6d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x33, 0x12, 0x64, 0x0a, 0x0a, 0x6d, 0x61, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x34, 0x18, 0x1d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x45, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x34, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x6d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x34, 0x12, 0x64, 0x0a, 0x0a, 0x6d, 0x61, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x35, 0x18, 0x1e, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x45, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x35, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x6d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x35, 0x12, 0x64, 0x0a, 0x0a, 0x6d, 0x61, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x36, 0x18, 0x1f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x45, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x36, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x6d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x36, 0x12, 0x64, 0x0a, 0x0a, 0x6d, 0x61, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x37, 0x18, 0x20, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x45, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x37, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x6d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x37, 0x12, 0x64, 0x0a, 0x0a, 0x6d, 0x61, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x38, 0x18, 0x21, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x45, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x38, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x6d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x38, 0x12, 0x64, 0x0a, 0x0a, 0x6d, 0x61, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x39, 0x18, 0x22, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x45, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x39, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x6d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x39, 0x12, 0x67, 0x0a, 0x0b, 0x6d, 0x61, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x31, 0x30, 0x18, 0x23, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x46, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x31, 0x30, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x6d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x31, 0x30, 0x12, 0x67, 0x0a, 0x0b, 0x6d, 0x61, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x31, 0x32, 0x18, 0x25, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x46, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x31, 0x32, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x6d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x31, 0x32, 0x12, 0x67, 0x0a, 0x0b, 0x6d, 0x61, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x31, 0x34, 0x18, 0x27, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x46, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x31, 0x34, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x6d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x31, 0x34, 0x12, 0x67, 0x0a, 0x0b, 0x6d, 0x61, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x31, 0x35, 0x18, 0x28, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x46, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x31, 0x35, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x6d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x31, 0x35, 0x12, 0x67, 0x0a, 0x0b, 0x6d, 0x61, 0x70, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x31, 0x36, 0x18, 0x2d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x46, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x31, 0x36, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x6d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x31, 0x36, 0x12, 0x44, 0x0a, 0x12, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x2f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x10, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3a, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x30, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x3b, 0x0a, 0x0d, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3c, 0x0a, 0x0e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x32, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3c, 0x0a, 0x0e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x33, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3c, 0x0a, 0x0e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x34, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3c, 0x0a, 0x0e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x35, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3c, 0x0a, 0x0e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x36, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3c, 0x0a, 0x0e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x37, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3c, 0x0a, 0x0e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x38, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3c, 0x0a, 0x0e, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x39, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3d, 0x0a, 0x0f, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x31, 0x30, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x02, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3d, 0x0a, 0x0f, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x31, 0x32, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3d, 0x0a, 0x0f, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x31, 0x34, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3d, 0x0a, 0x0f, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x31, 0x35, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x5b, 0x0a, 0x0f, 0x4d, 0x61, 0x70, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x31, 0x36, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x32, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x0d, 0x0a, 0x0b, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x14, 0x0a, 0x12, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2a, 0x20, 0x0a, 0x09, 0x45, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x05, 0x0a, 0x01, 0x58, 0x10, 0x00, 0x12, 0x05, 0x0a, 0x01, 0x59, 0x10, 0x01, 0x12, 0x05, 0x0a, 0x01, 0x5a, 0x10, 0x02, 0x42, 0x46, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x65, 0x63, 0x6f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2f, 0x76, 0x32, 0x2f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( file_runtime_internal_examplepb_proto3_proto_rawDescOnce sync.Once file_runtime_internal_examplepb_proto3_proto_rawDescData = file_runtime_internal_examplepb_proto3_proto_rawDesc ) func file_runtime_internal_examplepb_proto3_proto_rawDescGZIP() []byte { file_runtime_internal_examplepb_proto3_proto_rawDescOnce.Do(func() { file_runtime_internal_examplepb_proto3_proto_rawDescData = protoimpl.X.CompressGZIP(file_runtime_internal_examplepb_proto3_proto_rawDescData) }) return file_runtime_internal_examplepb_proto3_proto_rawDescData } var file_runtime_internal_examplepb_proto3_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_runtime_internal_examplepb_proto3_proto_msgTypes = make([]protoimpl.MessageInfo, 15) var file_runtime_internal_examplepb_proto3_proto_goTypes = []any{ (EnumValue)(0), // 0: grpc.gateway.runtime.internal.examplepb.EnumValue (*Proto3Message)(nil), // 1: grpc.gateway.runtime.internal.examplepb.Proto3Message nil, // 2: grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValueEntry nil, // 3: grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue2Entry nil, // 4: grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue3Entry nil, // 5: grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue4Entry nil, // 6: grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue5Entry nil, // 7: grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue6Entry nil, // 8: grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue7Entry nil, // 9: grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue8Entry nil, // 10: grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue9Entry nil, // 11: grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue10Entry nil, // 12: grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue12Entry nil, // 13: grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue14Entry nil, // 14: grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue15Entry nil, // 15: grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue16Entry (*wrapperspb.UInt64Value)(nil), // 16: google.protobuf.UInt64Value (*timestamppb.Timestamp)(nil), // 17: google.protobuf.Timestamp (*durationpb.Duration)(nil), // 18: google.protobuf.Duration (*fieldmaskpb.FieldMask)(nil), // 19: google.protobuf.FieldMask (*wrapperspb.DoubleValue)(nil), // 20: google.protobuf.DoubleValue (*wrapperspb.FloatValue)(nil), // 21: google.protobuf.FloatValue (*wrapperspb.Int64Value)(nil), // 22: google.protobuf.Int64Value (*wrapperspb.Int32Value)(nil), // 23: google.protobuf.Int32Value (*wrapperspb.UInt32Value)(nil), // 24: google.protobuf.UInt32Value (*wrapperspb.BoolValue)(nil), // 25: google.protobuf.BoolValue (*wrapperspb.StringValue)(nil), // 26: google.protobuf.StringValue (*wrapperspb.BytesValue)(nil), // 27: google.protobuf.BytesValue (*structpb.Value)(nil), // 28: google.protobuf.Value (*structpb.Struct)(nil), // 29: google.protobuf.Struct } var file_runtime_internal_examplepb_proto3_proto_depIdxs = []int32{ 1, // 0: grpc.gateway.runtime.internal.examplepb.Proto3Message.nested:type_name -> grpc.gateway.runtime.internal.examplepb.Proto3Message 16, // 1: grpc.gateway.runtime.internal.examplepb.Proto3Message.repeated_message:type_name -> google.protobuf.UInt64Value 0, // 2: grpc.gateway.runtime.internal.examplepb.Proto3Message.enum_value:type_name -> grpc.gateway.runtime.internal.examplepb.EnumValue 0, // 3: grpc.gateway.runtime.internal.examplepb.Proto3Message.repeated_enum:type_name -> grpc.gateway.runtime.internal.examplepb.EnumValue 17, // 4: grpc.gateway.runtime.internal.examplepb.Proto3Message.timestamp_value:type_name -> google.protobuf.Timestamp 18, // 5: grpc.gateway.runtime.internal.examplepb.Proto3Message.duration_value:type_name -> google.protobuf.Duration 19, // 6: grpc.gateway.runtime.internal.examplepb.Proto3Message.fieldmask_value:type_name -> google.protobuf.FieldMask 1, // 7: grpc.gateway.runtime.internal.examplepb.Proto3Message.nested_oneof_value_one:type_name -> grpc.gateway.runtime.internal.examplepb.Proto3Message 20, // 8: grpc.gateway.runtime.internal.examplepb.Proto3Message.wrapper_double_value:type_name -> google.protobuf.DoubleValue 21, // 9: grpc.gateway.runtime.internal.examplepb.Proto3Message.wrapper_float_value:type_name -> google.protobuf.FloatValue 22, // 10: grpc.gateway.runtime.internal.examplepb.Proto3Message.wrapper_int64_value:type_name -> google.protobuf.Int64Value 23, // 11: grpc.gateway.runtime.internal.examplepb.Proto3Message.wrapper_int32_value:type_name -> google.protobuf.Int32Value 16, // 12: grpc.gateway.runtime.internal.examplepb.Proto3Message.wrapper_u_int64_value:type_name -> google.protobuf.UInt64Value 24, // 13: grpc.gateway.runtime.internal.examplepb.Proto3Message.wrapper_u_int32_value:type_name -> google.protobuf.UInt32Value 25, // 14: grpc.gateway.runtime.internal.examplepb.Proto3Message.wrapper_bool_value:type_name -> google.protobuf.BoolValue 26, // 15: grpc.gateway.runtime.internal.examplepb.Proto3Message.wrapper_string_value:type_name -> google.protobuf.StringValue 27, // 16: grpc.gateway.runtime.internal.examplepb.Proto3Message.wrapper_bytes_value:type_name -> google.protobuf.BytesValue 2, // 17: grpc.gateway.runtime.internal.examplepb.Proto3Message.map_value:type_name -> grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValueEntry 3, // 18: grpc.gateway.runtime.internal.examplepb.Proto3Message.map_value2:type_name -> grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue2Entry 4, // 19: grpc.gateway.runtime.internal.examplepb.Proto3Message.map_value3:type_name -> grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue3Entry 5, // 20: grpc.gateway.runtime.internal.examplepb.Proto3Message.map_value4:type_name -> grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue4Entry 6, // 21: grpc.gateway.runtime.internal.examplepb.Proto3Message.map_value5:type_name -> grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue5Entry 7, // 22: grpc.gateway.runtime.internal.examplepb.Proto3Message.map_value6:type_name -> grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue6Entry 8, // 23: grpc.gateway.runtime.internal.examplepb.Proto3Message.map_value7:type_name -> grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue7Entry 9, // 24: grpc.gateway.runtime.internal.examplepb.Proto3Message.map_value8:type_name -> grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue8Entry 10, // 25: grpc.gateway.runtime.internal.examplepb.Proto3Message.map_value9:type_name -> grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue9Entry 11, // 26: grpc.gateway.runtime.internal.examplepb.Proto3Message.map_value10:type_name -> grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue10Entry 12, // 27: grpc.gateway.runtime.internal.examplepb.Proto3Message.map_value12:type_name -> grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue12Entry 13, // 28: grpc.gateway.runtime.internal.examplepb.Proto3Message.map_value14:type_name -> grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue14Entry 14, // 29: grpc.gateway.runtime.internal.examplepb.Proto3Message.map_value15:type_name -> grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue15Entry 15, // 30: grpc.gateway.runtime.internal.examplepb.Proto3Message.map_value16:type_name -> grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue16Entry 28, // 31: grpc.gateway.runtime.internal.examplepb.Proto3Message.struct_value_value:type_name -> google.protobuf.Value 29, // 32: grpc.gateway.runtime.internal.examplepb.Proto3Message.struct_value:type_name -> google.protobuf.Struct 16, // 33: grpc.gateway.runtime.internal.examplepb.Proto3Message.MapValue16Entry.value:type_name -> google.protobuf.UInt64Value 34, // [34:34] is the sub-list for method output_type 34, // [34:34] is the sub-list for method input_type 34, // [34:34] is the sub-list for extension type_name 34, // [34:34] is the sub-list for extension extendee 0, // [0:34] is the sub-list for field type_name } func init() { file_runtime_internal_examplepb_proto3_proto_init() } func file_runtime_internal_examplepb_proto3_proto_init() { if File_runtime_internal_examplepb_proto3_proto != nil { return } file_runtime_internal_examplepb_proto3_proto_msgTypes[0].OneofWrappers = []any{ (*Proto3Message_OneofBoolValue)(nil), (*Proto3Message_OneofStringValue)(nil), (*Proto3Message_NestedOneofInt32Value)(nil), (*Proto3Message_NestedOneofValueOne)(nil), } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_runtime_internal_examplepb_proto3_proto_rawDesc, NumEnums: 1, NumMessages: 15, NumExtensions: 0, NumServices: 0, }, GoTypes: file_runtime_internal_examplepb_proto3_proto_goTypes, DependencyIndexes: file_runtime_internal_examplepb_proto3_proto_depIdxs, EnumInfos: file_runtime_internal_examplepb_proto3_proto_enumTypes, MessageInfos: file_runtime_internal_examplepb_proto3_proto_msgTypes, }.Build() File_runtime_internal_examplepb_proto3_proto = out.File file_runtime_internal_examplepb_proto3_proto_rawDesc = nil file_runtime_internal_examplepb_proto3_proto_goTypes = nil file_runtime_internal_examplepb_proto3_proto_depIdxs = nil } ================================================ FILE: runtime/internal/examplepb/proto3.proto ================================================ syntax = "proto3"; package grpc.gateway.runtime.internal.examplepb; import "google/protobuf/duration.proto"; import "google/protobuf/field_mask.proto"; import "google/protobuf/struct.proto"; import "google/protobuf/timestamp.proto"; import "google/protobuf/wrappers.proto"; option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/runtime/internal/examplepb"; message Proto3Message { // Next number: 51 Proto3Message nested = 41; float float_value = 42; double double_value = 43; int64 int64_value = 3; int32 int32_value = 4; uint64 uint64_value = 5; uint32 uint32_value = 6; bool bool_value = 7; string string_value = 8; bytes bytes_value = 9; repeated string repeated_value = 10; optional string optional_value = 49; repeated google.protobuf.UInt64Value repeated_message = 44; EnumValue enum_value = 11; repeated EnumValue repeated_enum = 12; google.protobuf.Timestamp timestamp_value = 13; google.protobuf.Duration duration_value = 14; google.protobuf.FieldMask fieldmask_value = 15; oneof oneof_value { bool oneof_bool_value = 1; string oneof_string_value = 2; } oneof nested_oneof_value { int32 nested_oneof_int32_value = 50; Proto3Message nested_oneof_value_one = 46; } google.protobuf.DoubleValue wrapper_double_value = 17; google.protobuf.FloatValue wrapper_float_value = 18; google.protobuf.Int64Value wrapper_int64_value = 19; google.protobuf.Int32Value wrapper_int32_value = 20; google.protobuf.UInt64Value wrapper_u_int64_value = 21; google.protobuf.UInt32Value wrapper_u_int32_value = 22; google.protobuf.BoolValue wrapper_bool_value = 23; google.protobuf.StringValue wrapper_string_value = 24; google.protobuf.BytesValue wrapper_bytes_value = 25; map map_value = 26; map map_value2 = 27; map map_value3 = 28; map map_value4 = 29; map map_value5 = 30; map map_value6 = 31; map map_value7 = 32; map map_value8 = 33; map map_value9 = 34; map map_value10 = 35; map map_value12 = 37; map map_value14 = 39; map map_value15 = 40; map map_value16 = 45; google.protobuf.Value struct_value_value = 47; google.protobuf.Struct struct_value = 48; } enum EnumValue { X = 0; Y = 1; Z = 2; } ================================================ FILE: runtime/internal/examplepb/proto3.swagger.json ================================================ { "swagger": "2.0", "info": { "title": "runtime/internal/examplepb/proto3.proto", "version": "version not set" }, "consumes": [ "application/json" ], "produces": [ "application/json" ], "paths": {}, "definitions": { "protobufAny": { "type": "object", "properties": { "@type": { "type": "string", "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com. As of May 2023, there are no widely used type server\nimplementations and no plans to implement one.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics." } }, "additionalProperties": {}, "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n // or ...\n if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n foo = any.unpack(Foo.getDefaultInstance());\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := anypb.New(foo)\n if err != nil {\n ...\n }\n ...\n foo := \u0026pb.Foo{}\n if err := any.UnmarshalTo(foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }" }, "rpcStatus": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" }, "details": { "type": "array", "items": { "type": "object", "$ref": "#/definitions/protobufAny" } } } } } } ================================================ FILE: runtime/marshal_httpbodyproto.go ================================================ package runtime import ( "google.golang.org/genproto/googleapis/api/httpbody" ) // HTTPBodyMarshaler is a Marshaler which supports marshaling of a // google.api.HttpBody message as the full response body if it is // the actual message used as the response. If not, then this will // simply fallback to the Marshaler specified as its default Marshaler. type HTTPBodyMarshaler struct { Marshaler } // ContentType returns its specified content type in case v is a // google.api.HttpBody message, otherwise it will fall back to the default Marshalers // content type. func (h *HTTPBodyMarshaler) ContentType(v interface{}) string { if httpBody, ok := v.(*httpbody.HttpBody); ok { return httpBody.GetContentType() } return h.Marshaler.ContentType(v) } // Marshal marshals "v" by returning the body bytes if v is a // google.api.HttpBody message, otherwise it falls back to the default Marshaler. func (h *HTTPBodyMarshaler) Marshal(v interface{}) ([]byte, error) { if httpBody, ok := v.(*httpbody.HttpBody); ok { return httpBody.GetData(), nil } return h.Marshaler.Marshal(v) } ================================================ FILE: runtime/marshal_httpbodyproto_test.go ================================================ package runtime_test import ( "bytes" "testing" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "google.golang.org/genproto/googleapis/api/httpbody" "google.golang.org/protobuf/encoding/protojson" ) func TestHTTPBodyContentType(t *testing.T) { m := runtime.HTTPBodyMarshaler{ &runtime.JSONPb{ MarshalOptions: protojson.MarshalOptions{ UseProtoNames: true, }, }, } expected := "CustomContentType" message := &httpbody.HttpBody{ ContentType: expected, } res := m.ContentType(nil) if res != "application/json" { t.Errorf("content type not equal (%q, %q)", res, expected) } res = m.ContentType(message) if res != expected { t.Errorf("content type not equal (%q, %q)", res, expected) } } func TestHTTPBodyMarshal(t *testing.T) { m := runtime.HTTPBodyMarshaler{ &runtime.JSONPb{ MarshalOptions: protojson.MarshalOptions{ UseProtoNames: true, }, }, } expected := []byte("Some test") message := &httpbody.HttpBody{ Data: expected, } res, err := m.Marshal(message) if err != nil { t.Errorf("m.Marshal(%#v) failed with %v; want success", message, err) } if !bytes.Equal(res, expected) { t.Errorf("Marshalled data not equal (%q, %q)", res, expected) } } ================================================ FILE: runtime/marshal_json.go ================================================ package runtime import ( "encoding/json" "io" ) // JSONBuiltin is a Marshaler which marshals/unmarshals into/from JSON // with the standard "encoding/json" package of Golang. // Although it is generally faster for simple proto messages than JSONPb, // it does not support advanced features of protobuf, e.g. map, oneof, .... // // The NewEncoder and NewDecoder types return *json.Encoder and // *json.Decoder respectively. type JSONBuiltin struct{} // ContentType always Returns "application/json". func (*JSONBuiltin) ContentType(_ interface{}) string { return "application/json" } // Marshal marshals "v" into JSON func (j *JSONBuiltin) Marshal(v interface{}) ([]byte, error) { return json.Marshal(v) } // MarshalIndent is like Marshal but applies Indent to format the output func (j *JSONBuiltin) MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) { return json.MarshalIndent(v, prefix, indent) } // Unmarshal unmarshals JSON data into "v". func (j *JSONBuiltin) Unmarshal(data []byte, v interface{}) error { return json.Unmarshal(data, v) } // NewDecoder returns a Decoder which reads JSON stream from "r". func (j *JSONBuiltin) NewDecoder(r io.Reader) Decoder { return json.NewDecoder(r) } // NewEncoder returns an Encoder which writes JSON stream into "w". func (j *JSONBuiltin) NewEncoder(w io.Writer) Encoder { return json.NewEncoder(w) } // Delimiter for newline encoded JSON streams. func (j *JSONBuiltin) Delimiter() []byte { return []byte("\n") } ================================================ FILE: runtime/marshal_json_test.go ================================================ package runtime_test import ( "bytes" "encoding/json" "reflect" "strings" "testing" "github.com/google/go-cmp/cmp" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime/internal/examplepb" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/testing/protocmp" "google.golang.org/protobuf/types/known/emptypb" "google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/wrapperspb" ) func TestJSONBuiltinMarshal(t *testing.T) { var m runtime.JSONBuiltin msg := &examplepb.SimpleMessage{ Id: "foo", } buf, err := m.Marshal(msg) if err != nil { t.Errorf("m.Marshal(%v) failed with %v; want success", msg, err) } got := new(examplepb.SimpleMessage) if err := json.Unmarshal(buf, got); err != nil { t.Errorf("json.Unmarshal(%q, got) failed with %v; want success", buf, err) } if diff := cmp.Diff(got, msg, protocmp.Transform()); diff != "" { t.Error(diff) } } func TestJSONBuiltinMarshalField(t *testing.T) { var ( m runtime.JSONBuiltin buf []byte err error ) for _, fixt := range builtinFieldFixtures { if len(fixt.indent) == 0 { buf, err = m.Marshal(fixt.data) if err != nil { t.Errorf("m.Marshal(%v) failed with %v; want success", fixt.data, err) } } else { buf, err = m.MarshalIndent(fixt.data, "", fixt.indent) if err != nil { t.Errorf("m.MarshalIndent(%v, \"\", \"%s\") failed with %v; want success", fixt.data, fixt.indent, err) } } if got, want := string(buf), fixt.json; got != want { t.Errorf("got = %q; want %q; data = %#v", got, want, fixt.data) } } } func TestJSONBuiltinMarshalFieldKnownErrors(t *testing.T) { var m runtime.JSONBuiltin for _, fixt := range builtinKnownErrors { buf, err := m.Marshal(fixt.data) if err != nil { t.Errorf("m.Marshal(%v) failed with %v; want success", fixt.data, err) } if got, want := string(buf), fixt.json; got == want { t.Errorf("surprisingly got = %q; as want %q; data = %#v", got, want, fixt.data) } } } func TestJSONBuiltinsnmarshal(t *testing.T) { var ( m runtime.JSONBuiltin got = new(examplepb.SimpleMessage) data = []byte(`{"id": "foo"}`) ) if err := m.Unmarshal(data, got); err != nil { t.Errorf("m.Unmarshal(%q, got) failed with %v; want success", data, err) } want := &examplepb.SimpleMessage{ Id: "foo", } if diff := cmp.Diff(got, want, protocmp.Transform()); diff != "" { t.Error(diff) } } func TestJSONBuiltinUnmarshalField(t *testing.T) { var m runtime.JSONBuiltin for _, fixt := range builtinFieldFixtures { dest := alloc(reflect.TypeOf(fixt.data)) if err := m.Unmarshal([]byte(fixt.json), dest.Interface()); err != nil { t.Errorf("m.Unmarshal(%q, dest) failed with %v; want success", fixt.json, err) } got, want := dest.Elem().Interface(), fixt.data if diff := cmp.Diff(got, want, protocmp.Transform()); diff != "" { t.Error(diff) } } } func alloc(t reflect.Type) reflect.Value { if t == nil { return reflect.ValueOf(new(interface{})) } return reflect.New(t) } func TestJSONBuiltinUnmarshalFieldKnownErrors(t *testing.T) { var m runtime.JSONBuiltin for _, fixt := range builtinKnownErrors { dest := reflect.New(reflect.TypeOf(fixt.data)) if err := m.Unmarshal([]byte(fixt.json), dest.Interface()); err == nil { t.Errorf("m.Unmarshal(%q, dest) succeeded; want an error", fixt.json) } } } func TestJSONBuiltinEncoder(t *testing.T) { var m runtime.JSONBuiltin msg := &examplepb.SimpleMessage{ Id: "foo", } var buf bytes.Buffer enc := m.NewEncoder(&buf) if err := enc.Encode(msg); err != nil { t.Errorf("enc.Encode(%v) failed with %v; want success", msg, err) } got := new(examplepb.SimpleMessage) if err := json.Unmarshal(buf.Bytes(), got); err != nil { t.Errorf("json.Unmarshal(%q, got) failed with %v; want success", buf.String(), err) } if diff := cmp.Diff(got, msg, protocmp.Transform()); diff != "" { t.Error(diff) } } func TestJSONBuiltinEncoderFields(t *testing.T) { var m runtime.JSONBuiltin for _, fixt := range builtinFieldFixtures { var buf bytes.Buffer enc := m.NewEncoder(&buf) if fixt.indent != "" { if e, ok := enc.(*json.Encoder); ok { e.SetIndent("", fixt.indent) } else { // By default, JSONBuiltin.NewEncoder returns *json.Encoder as runtime.Encoder. // Otherwise it's better to fail the tests than skip fixtures with non empty indent t.Errorf("enc is not *json.Encoder, unable to set indentation settings. " + "This failure prevents testing the correctness of indentation in JSON output.") } } if err := enc.Encode(fixt.data); err != nil { t.Errorf("enc.Encode(%#v) failed with %v; want success", fixt.data, err) } if got, want := buf.String(), fixt.json+"\n"; got != want { t.Errorf("got = %q; want %q; data = %#v", got, want, fixt.data) } } } func TestJSONBuiltinDecoder(t *testing.T) { var ( m runtime.JSONBuiltin got = new(examplepb.SimpleMessage) data = `{"id": "foo"}` ) r := strings.NewReader(data) dec := m.NewDecoder(r) if err := dec.Decode(got); err != nil { t.Errorf("m.Unmarshal(got) failed with %v; want success", err) } want := &examplepb.SimpleMessage{ Id: "foo", } if diff := cmp.Diff(got, want, protocmp.Transform()); diff != "" { t.Errorf("got = %v; want = %v", got, want) } } func TestJSONBuiltinDecoderFields(t *testing.T) { var m runtime.JSONBuiltin for _, fixt := range builtinFieldFixtures { r := strings.NewReader(fixt.json) dec := m.NewDecoder(r) dest := alloc(reflect.TypeOf(fixt.data)) if err := dec.Decode(dest.Interface()); err != nil { t.Errorf("dec.Decode(dest) failed with %v; want success; data = %q", err, fixt.json) } got, want := dest.Elem().Interface(), fixt.data if diff := cmp.Diff(got, want, protocmp.Transform()); diff != "" { t.Error(diff) } } } var ( defaultIndent = " " builtinFieldFixtures = []struct { data interface{} indent string json string }{ {data: "", json: `""`}, {data: "", indent: defaultIndent, json: `""`}, {data: proto.String(""), json: `""`}, {data: proto.String(""), indent: defaultIndent, json: `""`}, {data: "foo", json: `"foo"`}, {data: "foo", indent: defaultIndent, json: `"foo"`}, {data: []byte("foo"), json: `"Zm9v"`}, {data: []byte("foo"), indent: defaultIndent, json: `"Zm9v"`}, {data: []byte{}, json: `""`}, {data: []byte{}, indent: defaultIndent, json: `""`}, {data: proto.String("foo"), json: `"foo"`}, {data: proto.String("foo"), indent: defaultIndent, json: `"foo"`}, {data: int32(-1), json: "-1"}, {data: int32(-1), indent: defaultIndent, json: "-1"}, {data: proto.Int32(-1), json: "-1"}, {data: proto.Int32(-1), indent: defaultIndent, json: "-1"}, {data: int64(-1), json: "-1"}, {data: int64(-1), indent: defaultIndent, json: "-1"}, {data: proto.Int64(-1), json: "-1"}, {data: proto.Int64(-1), indent: defaultIndent, json: "-1"}, {data: uint32(123), json: "123"}, {data: uint32(123), indent: defaultIndent, json: "123"}, {data: proto.Uint32(123), json: "123"}, {data: proto.Uint32(123), indent: defaultIndent, json: "123"}, {data: uint64(123), json: "123"}, {data: uint64(123), indent: defaultIndent, json: "123"}, {data: proto.Uint64(123), json: "123"}, {data: proto.Uint64(123), indent: defaultIndent, json: "123"}, {data: float32(-1.5), json: "-1.5"}, {data: float32(-1.5), indent: defaultIndent, json: "-1.5"}, {data: proto.Float32(-1.5), json: "-1.5"}, {data: proto.Float32(-1.5), indent: defaultIndent, json: "-1.5"}, {data: float64(-1.5), json: "-1.5"}, {data: float64(-1.5), indent: defaultIndent, json: "-1.5"}, {data: proto.Float64(-1.5), json: "-1.5"}, {data: proto.Float64(-1.5), indent: defaultIndent, json: "-1.5"}, {data: true, json: "true"}, {data: true, indent: defaultIndent, json: "true"}, {data: proto.Bool(true), json: "true"}, {data: proto.Bool(true), indent: defaultIndent, json: "true"}, {data: (*string)(nil), json: "null"}, {data: (*string)(nil), indent: defaultIndent, json: "null"}, {data: new(emptypb.Empty), json: "{}"}, {data: new(emptypb.Empty), indent: defaultIndent, json: "{}"}, {data: examplepb.NumericEnum_ONE, json: "1"}, {data: examplepb.NumericEnum_ONE, indent: defaultIndent, json: "1"}, {data: nil, json: "null"}, {data: nil, indent: defaultIndent, json: "null"}, {data: (*string)(nil), json: "null"}, {data: (*string)(nil), indent: defaultIndent, json: "null"}, {data: []interface{}{nil, "foo", -1.0, 1.234, true}, json: `[null,"foo",-1,1.234,true]`}, {data: []interface{}{nil, "foo", -1.0, 1.234, true}, indent: defaultIndent, json: "[\n null,\n \"foo\",\n -1,\n 1.234,\n true\n]"}, { data: map[string]interface{}{"bar": nil, "baz": -1.0, "fiz": 1.234, "foo": true}, json: `{"bar":null,"baz":-1,"fiz":1.234,"foo":true}`, }, { data: map[string]interface{}{"bar": nil, "baz": -1.0, "fiz": 1.234, "foo": true}, indent: defaultIndent, json: "{\n \"bar\": null,\n \"baz\": -1,\n \"fiz\": 1.234,\n \"foo\": true\n}", }, { data: (*examplepb.NumericEnum)(proto.Int32(int32(examplepb.NumericEnum_ONE))), json: "1", }, { data: (*examplepb.NumericEnum)(proto.Int32(int32(examplepb.NumericEnum_ONE))), indent: defaultIndent, json: "1", }, {data: map[string]int{"FOO": 0, "BAR": -1}, json: "{\"BAR\":-1,\"FOO\":0}"}, {data: map[string]int{"FOO": 0, "BAR": -1}, indent: defaultIndent, json: "{\n \"BAR\": -1,\n \"FOO\": 0\n}"}, {data: struct { A string B int C map[string]int }{A: "Go", B: 3, C: map[string]int{"FOO": 0, "BAR": -1}}, json: "{\"A\":\"Go\",\"B\":3,\"C\":{\"BAR\":-1,\"FOO\":0}}"}, {data: struct { A string B int C map[string]int }{A: "Go", B: 3, C: map[string]int{"FOO": 0, "BAR": -1}}, indent: defaultIndent, json: "{\n \"A\": \"Go\",\n \"B\": 3,\n \"C\": {\n \"BAR\": -1,\n \"FOO\": 0\n }\n}"}, } builtinKnownErrors = []struct { data interface{} json string }{ {data: examplepb.NumericEnum_ONE, json: "ONE"}, { data: (*examplepb.NumericEnum)(proto.Int32(int32(examplepb.NumericEnum_ONE))), json: "ONE", }, { data: &examplepb.ABitOfEverything_OneofString{OneofString: "abc"}, json: `"abc"`, }, { data: ×tamppb.Timestamp{ Seconds: 1462875553, Nanos: 123000000, }, json: `"2016-05-10T10:19:13.123Z"`, }, { data: wrapperspb.Int32(123), json: "123", }, } ) ================================================ FILE: runtime/marshal_jsonpb.go ================================================ package runtime import ( "bytes" "encoding/json" "fmt" "io" "reflect" "strconv" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" ) // JSONPb is a Marshaler which marshals/unmarshals into/from JSON // with the "google.golang.org/protobuf/encoding/protojson" marshaler. // It supports the full functionality of protobuf unlike JSONBuiltin. // // The NewDecoder method returns a DecoderWrapper, so the underlying // *json.Decoder methods can be used. type JSONPb struct { protojson.MarshalOptions protojson.UnmarshalOptions } // ContentType always returns "application/json". func (*JSONPb) ContentType(_ interface{}) string { return "application/json" } // Marshal marshals "v" into JSON. func (j *JSONPb) Marshal(v interface{}) ([]byte, error) { var buf bytes.Buffer if err := j.marshalTo(&buf, v); err != nil { return nil, err } return buf.Bytes(), nil } func (j *JSONPb) marshalTo(w io.Writer, v interface{}) error { p, ok := v.(proto.Message) if !ok { buf, err := j.marshalNonProtoField(v) if err != nil { return err } if j.Indent != "" { b := &bytes.Buffer{} if err := json.Indent(b, buf, "", j.Indent); err != nil { return err } buf = b.Bytes() } _, err = w.Write(buf) return err } b, err := j.MarshalOptions.Marshal(p) if err != nil { return err } _, err = w.Write(b) return err } var ( // protoMessageType is stored to prevent constant lookup of the same type at runtime. protoMessageType = reflect.TypeFor[proto.Message]() ) // marshalNonProto marshals a non-message field of a protobuf message. // This function does not correctly marshal arbitrary data structures into JSON, // it is only capable of marshaling non-message field values of protobuf, // i.e. primitive types, enums; pointers to primitives or enums; maps from // integer/string types to primitives/enums/pointers to messages. func (j *JSONPb) marshalNonProtoField(v interface{}) ([]byte, error) { if v == nil { return []byte("null"), nil } rv := reflect.ValueOf(v) for rv.Kind() == reflect.Ptr { if rv.IsNil() { return []byte("null"), nil } rv = rv.Elem() } if rv.Kind() == reflect.Slice { if rv.IsNil() { if j.EmitUnpopulated { return []byte("[]"), nil } return []byte("null"), nil } if rv.Type().Elem().Implements(protoMessageType) { var buf bytes.Buffer if err := buf.WriteByte('['); err != nil { return nil, err } for i := 0; i < rv.Len(); i++ { if i != 0 { if err := buf.WriteByte(','); err != nil { return nil, err } } if err := j.marshalTo(&buf, rv.Index(i).Interface().(proto.Message)); err != nil { return nil, err } } if err := buf.WriteByte(']'); err != nil { return nil, err } return buf.Bytes(), nil } if rv.Type().Elem().Implements(typeProtoEnum) { var buf bytes.Buffer if err := buf.WriteByte('['); err != nil { return nil, err } for i := 0; i < rv.Len(); i++ { if i != 0 { if err := buf.WriteByte(','); err != nil { return nil, err } } var err error if j.UseEnumNumbers { _, err = buf.WriteString(strconv.FormatInt(rv.Index(i).Int(), 10)) } else { _, err = buf.WriteString("\"" + rv.Index(i).Interface().(protoEnum).String() + "\"") } if err != nil { return nil, err } } if err := buf.WriteByte(']'); err != nil { return nil, err } return buf.Bytes(), nil } } if rv.Kind() == reflect.Map { m := make(map[string]*json.RawMessage) for _, k := range rv.MapKeys() { buf, err := j.Marshal(rv.MapIndex(k).Interface()) if err != nil { return nil, err } m[fmt.Sprintf("%v", k.Interface())] = (*json.RawMessage)(&buf) } return json.Marshal(m) } if enum, ok := rv.Interface().(protoEnum); ok && !j.UseEnumNumbers { return json.Marshal(enum.String()) } return json.Marshal(rv.Interface()) } // Unmarshal unmarshals JSON "data" into "v" func (j *JSONPb) Unmarshal(data []byte, v interface{}) error { return unmarshalJSONPb(data, j.UnmarshalOptions, v) } // NewDecoder returns a Decoder which reads JSON stream from "r". func (j *JSONPb) NewDecoder(r io.Reader) Decoder { d := json.NewDecoder(r) return DecoderWrapper{ Decoder: d, UnmarshalOptions: j.UnmarshalOptions, } } // DecoderWrapper is a wrapper around a *json.Decoder that adds // support for protos to the Decode method. type DecoderWrapper struct { *json.Decoder protojson.UnmarshalOptions } // Decode wraps the embedded decoder's Decode method to support // protos using a jsonpb.Unmarshaler. func (d DecoderWrapper) Decode(v interface{}) error { return decodeJSONPb(d.Decoder, d.UnmarshalOptions, v) } // NewEncoder returns an Encoder which writes JSON stream into "w". func (j *JSONPb) NewEncoder(w io.Writer) Encoder { return EncoderFunc(func(v interface{}) error { if err := j.marshalTo(w, v); err != nil { return err } // mimic json.Encoder by adding a newline (makes output // easier to read when it contains multiple encoded items) _, err := w.Write(j.Delimiter()) return err }) } func unmarshalJSONPb(data []byte, unmarshaler protojson.UnmarshalOptions, v interface{}) error { d := json.NewDecoder(bytes.NewReader(data)) return decodeJSONPb(d, unmarshaler, v) } func decodeJSONPb(d *json.Decoder, unmarshaler protojson.UnmarshalOptions, v interface{}) error { p, ok := v.(proto.Message) if !ok { return decodeNonProtoField(d, unmarshaler, v) } // Decode into bytes for marshalling var b json.RawMessage if err := d.Decode(&b); err != nil { return err } return unmarshaler.Unmarshal([]byte(b), p) } func decodeNonProtoField(d *json.Decoder, unmarshaler protojson.UnmarshalOptions, v interface{}) error { rv := reflect.ValueOf(v) if rv.Kind() != reflect.Ptr { return fmt.Errorf("%T is not a pointer", v) } for rv.Kind() == reflect.Ptr { if rv.IsNil() { rv.Set(reflect.New(rv.Type().Elem())) } if rv.Type().ConvertibleTo(typeProtoMessage) { // Decode into bytes for marshalling var b json.RawMessage if err := d.Decode(&b); err != nil { return err } return unmarshaler.Unmarshal([]byte(b), rv.Interface().(proto.Message)) } rv = rv.Elem() } if rv.Kind() == reflect.Map { if rv.IsNil() { rv.Set(reflect.MakeMap(rv.Type())) } conv, ok := convFromType[rv.Type().Key().Kind()] if !ok { return fmt.Errorf("unsupported type of map field key: %v", rv.Type().Key()) } m := make(map[string]*json.RawMessage) if err := d.Decode(&m); err != nil { return err } for k, v := range m { result := conv.Call([]reflect.Value{reflect.ValueOf(k)}) if err := result[1].Interface(); err != nil { return err.(error) } bk := result[0] bv := reflect.New(rv.Type().Elem()) if v == nil { null := json.RawMessage("null") v = &null } if err := unmarshalJSONPb([]byte(*v), unmarshaler, bv.Interface()); err != nil { return err } rv.SetMapIndex(bk, bv.Elem()) } return nil } if rv.Kind() == reflect.Slice { if rv.Type().Elem().Kind() == reflect.Uint8 { var sl []byte if err := d.Decode(&sl); err != nil { return err } if sl != nil { rv.SetBytes(sl) } return nil } var sl []json.RawMessage if err := d.Decode(&sl); err != nil { return err } if sl != nil { rv.Set(reflect.MakeSlice(rv.Type(), 0, 0)) } for _, item := range sl { bv := reflect.New(rv.Type().Elem()) if err := unmarshalJSONPb([]byte(item), unmarshaler, bv.Interface()); err != nil { return err } rv.Set(reflect.Append(rv, bv.Elem())) } return nil } if _, ok := rv.Interface().(protoEnum); ok { var repr interface{} if err := d.Decode(&repr); err != nil { return err } switch v := repr.(type) { case string: // TODO(yugui) Should use proto.StructProperties? return fmt.Errorf("unmarshaling of symbolic enum %q not supported: %T", repr, rv.Interface()) case float64: rv.Set(reflect.ValueOf(int32(v)).Convert(rv.Type())) return nil default: return fmt.Errorf("cannot assign %#v into Go type %T", repr, rv.Interface()) } } return d.Decode(v) } type protoEnum interface { fmt.Stringer EnumDescriptor() ([]byte, []int) } var typeProtoEnum = reflect.TypeFor[protoEnum]() var typeProtoMessage = reflect.TypeFor[proto.Message]() // Delimiter for newline encoded JSON streams. func (j *JSONPb) Delimiter() []byte { return []byte("\n") } var ( convFromType = map[reflect.Kind]reflect.Value{ reflect.String: reflect.ValueOf(String), reflect.Bool: reflect.ValueOf(Bool), reflect.Float64: reflect.ValueOf(Float64), reflect.Float32: reflect.ValueOf(Float32), reflect.Int64: reflect.ValueOf(Int64), reflect.Int32: reflect.ValueOf(Int32), reflect.Uint64: reflect.ValueOf(Uint64), reflect.Uint32: reflect.ValueOf(Uint32), reflect.Slice: reflect.ValueOf(Bytes), } ) ================================================ FILE: runtime/marshal_jsonpb_test.go ================================================ package runtime_test import ( "bytes" "reflect" "strconv" "strings" "testing" "github.com/google/go-cmp/cmp" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime/internal/examplepb" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/testing/protocmp" "google.golang.org/protobuf/types/known/durationpb" "google.golang.org/protobuf/types/known/emptypb" "google.golang.org/protobuf/types/known/structpb" "google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/wrapperspb" ) func TestJSONPbMarshal(t *testing.T) { msg := examplepb.ABitOfEverything{ SingleNested: &examplepb.ABitOfEverything_Nested{}, RepeatedStringValue: []string{}, MappedStringValue: map[string]string{}, MappedNestedValue: map[string]*examplepb.ABitOfEverything_Nested{}, RepeatedEnumValue: []examplepb.NumericEnum{}, TimestampValue: ×tamppb.Timestamp{}, Uuid: "6EC2446F-7E89-4127-B3E6-5C05E6BECBA7", Nested: []*examplepb.ABitOfEverything_Nested{ { Name: "foo", Amount: 12345, }, }, Uint64Value: 0xFFFFFFFFFFFFFFFF, EnumValue: examplepb.NumericEnum_ONE, OneofValue: &examplepb.ABitOfEverything_OneofString{ OneofString: "bar", }, MapValue: map[string]examplepb.NumericEnum{ "a": examplepb.NumericEnum_ONE, "b": examplepb.NumericEnum_ZERO, }, RepeatedEnumAnnotation: []examplepb.NumericEnum{}, EnumValueAnnotation: examplepb.NumericEnum_ONE, RepeatedStringAnnotation: []string{}, RepeatedNestedAnnotation: []*examplepb.ABitOfEverything_Nested{}, NestedAnnotation: &examplepb.ABitOfEverything_Nested{}, } for i, spec := range []struct { useEnumNumbers, emitUnpopulated bool indent string useProtoNames bool verifier func(json string) }{ { verifier: func(json string) { if !strings.Contains(json, "ONE") { t.Errorf(`strings.Contains(%q, "ONE") = false; want true`, json) } if want := "uint64Value"; !strings.Contains(json, want) { t.Errorf(`strings.Contains(%q, %q) = false; want true`, json, want) } }, }, { useEnumNumbers: true, verifier: func(json string) { if strings.Contains(json, "ONE") { t.Errorf(`strings.Contains(%q, "ONE") = true; want false`, json) } }, }, { emitUnpopulated: true, verifier: func(json string) { if want := `"sfixed32Value"`; !strings.Contains(json, want) { t.Errorf(`strings.Contains(%q, %q) = false; want true`, json, want) } }, }, { indent: "\t\t", verifier: func(json string) { if want := "\t\t\"amount\":"; !strings.Contains(json, want) { t.Errorf(`strings.Contains(%q, %q) = false; want true`, json, want) } }, }, { useProtoNames: true, verifier: func(json string) { if want := "uint64_value"; !strings.Contains(json, want) { t.Errorf(`strings.Contains(%q, %q) = false; want true`, json, want) } }, }, } { t.Run(strconv.Itoa(i), func(t *testing.T) { m := runtime.JSONPb{ MarshalOptions: protojson.MarshalOptions{ EmitUnpopulated: spec.emitUnpopulated, Indent: spec.indent, UseProtoNames: spec.useProtoNames, UseEnumNumbers: spec.useEnumNumbers, }, } buf, err := m.Marshal(&msg) if err != nil { t.Errorf("m.Marshal(%v) failed with %v; want success; spec=%v", &msg, err, spec) } var got examplepb.ABitOfEverything unmarshaler := &protojson.UnmarshalOptions{} if err = unmarshaler.Unmarshal(buf, &got); err != nil { t.Errorf("jsonpb.UnmarshalString(%q, &got) failed with %v; want success; spec=%v", string(buf), err, spec) } if diff := cmp.Diff(&got, &msg, protocmp.Transform()); diff != "" { t.Errorf("case %d: spec=%v; %s", i, spec, diff) } if spec.verifier != nil { spec.verifier(string(buf)) } }) } } func TestJSONPbMarshalFields(t *testing.T) { var m runtime.JSONPb m.UseEnumNumbers = true // builtin fixtures include an enum, expected to be marshaled as int for _, spec := range builtinFieldFixtures { m.Indent = spec.indent buf, err := m.Marshal(spec.data) if err != nil { t.Errorf("m.Marshal(%#v) failed with %v; want success", spec.data, err) } if got, want := string(buf), spec.json; got != want { t.Errorf("m.Marshal(%#v) = %q; want %q", spec.data, got, want) } } // Reset m.Indent to ensure no unintended indentation settings carry over to subsequent tests m.Indent = "" nums := []examplepb.NumericEnum{examplepb.NumericEnum_ZERO, examplepb.NumericEnum_ONE} buf, err := m.Marshal(nums) if err != nil { t.Errorf("m.Marshal(%#v) failed with %v; want success", nums, err) } if got, want := string(buf), `[0,1]`; got != want { t.Errorf("m.Marshal(%#v) = %q; want %q", nums, got, want) } m.UseEnumNumbers = false buf, err = m.Marshal(examplepb.NumericEnum_ONE) if err != nil { t.Errorf("m.Marshal(%#v) failed with %v; want success", examplepb.NumericEnum_ONE, err) } if got, want := string(buf), `"ONE"`; got != want { t.Errorf("m.Marshal(%#v) = %q; want %q", examplepb.NumericEnum_ONE, got, want) } buf, err = m.Marshal(nums) if err != nil { t.Errorf("m.Marshal(%#v) failed with %v; want success", nums, err) } if got, want := string(buf), `["ZERO","ONE"]`; got != want { t.Errorf("m.Marshal(%#v) = %q; want %q", nums, got, want) } } func TestJSONPbUnmarshal(t *testing.T) { var ( m runtime.JSONPb got examplepb.ABitOfEverything ) for i, data := range []string{ `{ "uuid": "6EC2446F-7E89-4127-B3E6-5C05E6BECBA7", "nested": [ {"name": "foo", "amount": 12345} ], "uint64Value": 18446744073709551615, "enumValue": "ONE", "oneofString": "bar", "mapValue": { "a": 1, "b": 0 } }`, `{ "uuid": "6EC2446F-7E89-4127-B3E6-5C05E6BECBA7", "nested": [ {"name": "foo", "amount": 12345} ], "uint64Value": "18446744073709551615", "enumValue": "ONE", "oneofString": "bar", "mapValue": { "a": 1, "b": 0 } }`, `{ "uuid": "6EC2446F-7E89-4127-B3E6-5C05E6BECBA7", "nested": [ {"name": "foo", "amount": 12345} ], "uint64Value": 18446744073709551615, "enumValue": 1, "oneofString": "bar", "mapValue": { "a": 1, "b": 0 } }`, } { if err := m.Unmarshal([]byte(data), &got); err != nil { t.Errorf("case %d: m.Unmarshal(%q, &got) failed with %v; want success", i, data, err) } want := examplepb.ABitOfEverything{ Uuid: "6EC2446F-7E89-4127-B3E6-5C05E6BECBA7", Nested: []*examplepb.ABitOfEverything_Nested{ { Name: "foo", Amount: 12345, }, }, Uint64Value: 0xFFFFFFFFFFFFFFFF, EnumValue: examplepb.NumericEnum_ONE, OneofValue: &examplepb.ABitOfEverything_OneofString{ OneofString: "bar", }, MapValue: map[string]examplepb.NumericEnum{ "a": examplepb.NumericEnum_ONE, "b": examplepb.NumericEnum_ZERO, }, } if diff := cmp.Diff(&got, &want, protocmp.Transform()); diff != "" { t.Errorf("case %d: %s", i, diff) } } } func TestJSONPbUnmarshalFields(t *testing.T) { var m runtime.JSONPb for _, fixt := range fieldFixtures { if fixt.skipUnmarshal { continue } dest := reflect.New(reflect.TypeOf(fixt.data)) if err := m.Unmarshal([]byte(fixt.json), dest.Interface()); err != nil { t.Errorf("m.Unmarshal(%q, %T) failed with %v; want success", fixt.json, dest.Interface(), err) } if diff := cmp.Diff(dest.Elem().Interface(), fixt.data, protocmp.Transform()); diff != "" { t.Errorf("dest = %#v; want %#v; input = %v", dest.Elem().Interface(), fixt.data, fixt.json) } } } func TestJSONPbEncoder(t *testing.T) { msg := examplepb.ABitOfEverything{ SingleNested: &examplepb.ABitOfEverything_Nested{}, RepeatedStringValue: []string{}, MappedStringValue: map[string]string{}, MappedNestedValue: map[string]*examplepb.ABitOfEverything_Nested{}, RepeatedEnumValue: []examplepb.NumericEnum{}, TimestampValue: ×tamppb.Timestamp{}, Uuid: "6EC2446F-7E89-4127-B3E6-5C05E6BECBA7", Nested: []*examplepb.ABitOfEverything_Nested{ { Name: "foo", Amount: 12345, }, }, Uint64Value: 0xFFFFFFFFFFFFFFFF, OneofValue: &examplepb.ABitOfEverything_OneofString{ OneofString: "bar", }, MapValue: map[string]examplepb.NumericEnum{ "a": examplepb.NumericEnum_ONE, "b": examplepb.NumericEnum_ZERO, }, RepeatedEnumAnnotation: []examplepb.NumericEnum{}, EnumValueAnnotation: examplepb.NumericEnum_ONE, RepeatedStringAnnotation: []string{}, RepeatedNestedAnnotation: []*examplepb.ABitOfEverything_Nested{}, NestedAnnotation: &examplepb.ABitOfEverything_Nested{}, } for i, spec := range []struct { useEnumNumbers, emitUnpopulated bool indent string useProtoNames bool verifier func(json string) }{ { verifier: func(json string) { if !strings.Contains(json, "ONE") { t.Errorf(`strings.Contains(%q, "ONE") = false; want true`, json) } if want := "uint64Value"; !strings.Contains(json, want) { t.Errorf(`strings.Contains(%q, %q) = false; want true`, json, want) } }, }, { useEnumNumbers: true, verifier: func(json string) { if strings.Contains(json, "ONE") { t.Errorf(`strings.Contains(%q, "ONE") = true; want false`, json) } }, }, { emitUnpopulated: true, verifier: func(json string) { if want := `"sfixed32Value"`; !strings.Contains(json, want) { t.Errorf(`strings.Contains(%q, %q) = false; want true`, json, want) } }, }, { indent: "\t\t", verifier: func(json string) { if want := "\t\t\"amount\":"; !strings.Contains(json, want) { t.Errorf(`strings.Contains(%q, %q) = false; want true`, json, want) } }, }, { useProtoNames: true, verifier: func(json string) { if want := "uint64_value"; !strings.Contains(json, want) { t.Errorf(`strings.Contains(%q, %q) = false; want true`, json, want) } }, }, } { m := runtime.JSONPb{ MarshalOptions: protojson.MarshalOptions{ EmitUnpopulated: spec.emitUnpopulated, Indent: spec.indent, UseProtoNames: spec.useProtoNames, UseEnumNumbers: spec.useEnumNumbers, }, } var buf bytes.Buffer enc := m.NewEncoder(&buf) if err := enc.Encode(&msg); err != nil { t.Errorf("enc.Encode(%v) failed with %v; want success; spec=%v", &msg, err, spec) } var got examplepb.ABitOfEverything unmarshaler := &protojson.UnmarshalOptions{} if err := unmarshaler.Unmarshal(buf.Bytes(), &got); err != nil { t.Errorf("jsonpb.UnmarshalString(%q, &got) failed with %v; want success; spec=%v", buf.String(), err, spec) } if diff := cmp.Diff(&got, &msg, protocmp.Transform()); diff != "" { t.Errorf("case %d: %s", i, diff) } if spec.verifier != nil { spec.verifier(buf.String()) } } } func TestJSONPbEncoderFields(t *testing.T) { var m runtime.JSONPb for _, fixt := range fieldFixtures { var buf bytes.Buffer enc := m.NewEncoder(&buf) if err := enc.Encode(fixt.data); err != nil { t.Errorf("enc.Encode(%#v) failed with %v; want success", fixt.data, err) } if got, want := buf.String(), fixt.json+string(m.Delimiter()); got != want { t.Errorf("enc.Encode(%#v) = %q; want %q", fixt.data, got, want) } } m.UseEnumNumbers = true buf, err := m.Marshal(examplepb.NumericEnum_ONE) if err != nil { t.Errorf("m.Marshal(%#v) failed with %v; want success", examplepb.NumericEnum_ONE, err) } if got, want := string(buf), "1"; got != want { t.Errorf("m.Marshal(%#v) = %q; want %q", examplepb.NumericEnum_ONE, got, want) } } func TestJSONPbDecoder(t *testing.T) { var ( m runtime.JSONPb got examplepb.ABitOfEverything ) for _, data := range []string{ `{ "uuid": "6EC2446F-7E89-4127-B3E6-5C05E6BECBA7", "nested": [ {"name": "foo", "amount": 12345} ], "uint64Value": 18446744073709551615, "enumValue": "ONE", "oneofString": "bar", "mapValue": { "a": 1, "b": 0 } }`, `{ "uuid": "6EC2446F-7E89-4127-B3E6-5C05E6BECBA7", "nested": [ {"name": "foo", "amount": 12345} ], "uint64Value": "18446744073709551615", "enumValue": "ONE", "oneofString": "bar", "mapValue": { "a": 1, "b": 0 } }`, `{ "uuid": "6EC2446F-7E89-4127-B3E6-5C05E6BECBA7", "nested": [ {"name": "foo", "amount": 12345} ], "uint64Value": 18446744073709551615, "enumValue": 1, "oneofString": "bar", "mapValue": { "a": 1, "b": 0 } }`, } { r := strings.NewReader(data) dec := m.NewDecoder(r) if err := dec.Decode(&got); err != nil { t.Errorf("m.Unmarshal(&got) failed with %v; want success; data=%q", err, data) } want := examplepb.ABitOfEverything{ Uuid: "6EC2446F-7E89-4127-B3E6-5C05E6BECBA7", Nested: []*examplepb.ABitOfEverything_Nested{ { Name: "foo", Amount: 12345, }, }, Uint64Value: 0xFFFFFFFFFFFFFFFF, EnumValue: examplepb.NumericEnum_ONE, OneofValue: &examplepb.ABitOfEverything_OneofString{ OneofString: "bar", }, MapValue: map[string]examplepb.NumericEnum{ "a": examplepb.NumericEnum_ONE, "b": examplepb.NumericEnum_ZERO, }, } if diff := cmp.Diff(&got, &want, protocmp.Transform()); diff != "" { t.Errorf("data %q: %s", data, diff) } } } func TestJSONPbDecoderFields(t *testing.T) { var m runtime.JSONPb for _, fixt := range fieldFixtures { if fixt.skipUnmarshal { continue } dest := reflect.New(reflect.TypeOf(fixt.data)) dec := m.NewDecoder(strings.NewReader(fixt.json)) if err := dec.Decode(dest.Interface()); err != nil { t.Errorf("dec.Decode(%T) failed with %v; want success; input = %q", dest.Interface(), err, fixt.json) } if got, want := dest.Elem().Interface(), fixt.data; !reflect.DeepEqual(got, want) { t.Errorf("dest = %#v; want %#v; input = %v", got, want, fixt.json) } } } func TestJSONPbDecoderUnknownField(t *testing.T) { var ( m = runtime.JSONPb{ UnmarshalOptions: protojson.UnmarshalOptions{ DiscardUnknown: false, }, } got examplepb.ABitOfEverything ) data := `{ "uuid": "6EC2446F-7E89-4127-B3E6-5C05E6BECBA7", "unknownField": "111" }` r := strings.NewReader(data) dec := m.NewDecoder(r) if err := dec.Decode(&got); err == nil { t.Errorf("m.Unmarshal(&got) not failed; want `unknown field` error; data=%q", data) } } var ( fieldFixtures = []struct { data interface{} json string skipUnmarshal bool }{ {data: int32(1), json: "1"}, {data: proto.Int32(1), json: "1"}, {data: int64(1), json: "1"}, {data: proto.Int64(1), json: "1"}, {data: uint32(1), json: "1"}, {data: proto.Uint32(1), json: "1"}, {data: uint64(1), json: "1"}, {data: proto.Uint64(1), json: "1"}, {data: "abc", json: `"abc"`}, {data: []byte("abc"), json: `"YWJj"`}, {data: []byte{}, json: `""`}, {data: proto.String("abc"), json: `"abc"`}, {data: float32(1.5), json: "1.5"}, {data: proto.Float32(1.5), json: "1.5"}, {data: float64(1.5), json: "1.5"}, {data: proto.Float64(1.5), json: "1.5"}, {data: true, json: "true"}, {data: false, json: "false"}, {data: (*string)(nil), json: "null"}, { data: examplepb.NumericEnum_ONE, json: `"ONE"`, // TODO(yugui) support unmarshaling of symbolic enum skipUnmarshal: true, }, { data: (*examplepb.NumericEnum)(proto.Int32(int32(examplepb.NumericEnum_ONE))), json: `"ONE"`, // TODO(yugui) support unmarshaling of symbolic enum skipUnmarshal: true, }, { data: map[string]int32{ "foo": 1, }, json: `{"foo":1}`, }, { data: map[string]*examplepb.SimpleMessage{ "foo": {Id: "bar"}, }, json: `{"foo":{"id":"bar"}}`, }, { data: map[int32]*examplepb.SimpleMessage{ 1: {Id: "foo"}, }, json: `{"1":{"id":"foo"}}`, }, { data: map[bool]*examplepb.SimpleMessage{ true: {Id: "foo"}, }, json: `{"true":{"id":"foo"}}`, }, { data: &durationpb.Duration{ Seconds: 123, Nanos: 456000000, }, json: `"123.456s"`, }, { data: ×tamppb.Timestamp{ Seconds: 1462875553, Nanos: 123000000, }, json: `"2016-05-10T10:19:13.123Z"`, }, { data: new(emptypb.Empty), json: "{}", }, { data: &structpb.Value{ Kind: new(structpb.Value_NullValue), }, json: "null", skipUnmarshal: true, }, { data: &structpb.Value{ Kind: &structpb.Value_NumberValue{ NumberValue: 123.4, }, }, json: "123.4", skipUnmarshal: true, }, { data: &structpb.Value{ Kind: &structpb.Value_StringValue{ StringValue: "abc", }, }, json: `"abc"`, skipUnmarshal: true, }, { data: &structpb.Value{ Kind: &structpb.Value_BoolValue{ BoolValue: true, }, }, json: "true", skipUnmarshal: true, }, { data: &structpb.Struct{ Fields: map[string]*structpb.Value{ "foo_bar": { Kind: &structpb.Value_BoolValue{ BoolValue: true, }, }, }, }, json: `{"foo_bar":true}`, skipUnmarshal: true, }, { data: wrapperspb.Bool(true), json: "true", }, { data: wrapperspb.Double(123.456), json: "123.456", }, { data: wrapperspb.Float(123.456), json: "123.456", }, { data: wrapperspb.Int32(-123), json: "-123", }, { data: wrapperspb.Int64(-123), json: `"-123"`, }, { data: wrapperspb.UInt32(123), json: "123", }, { data: wrapperspb.UInt64(123), json: `"123"`, }, // TODO(yugui) Add other well-known types once jsonpb supports them } ) func TestJSONPbUnmarshalNullField(t *testing.T) { var out map[string]interface{} const json = `{"foo": null}` marshaler := &runtime.JSONPb{} if err := marshaler.Unmarshal([]byte(json), &out); err != nil { t.Fatalf("unexpected error: %v", err) } value, hasKey := out["foo"] if !hasKey { t.Fatalf("unmarshaled map did not have key 'foo'") } if value != nil { t.Fatalf("unexpected value: %v", value) } } func TestJSONPbMarshalResponseBodies(t *testing.T) { marshaler := &runtime.JSONPb{} for i, spec := range []struct { input interface{} emitUnpopulated bool verifier func(*testing.T, interface{}, []byte) }{ { input: &examplepb.ResponseBodyOut{ Response: &examplepb.ResponseBodyOut_Response{Data: "abcdef"}, }, verifier: func(t *testing.T, input interface{}, json []byte) { var out examplepb.ResponseBodyOut err := marshaler.Unmarshal(json, &out) if err != nil { t.Fatalf("unexpected error: %v", err) } diff := cmp.Diff(input, &out, protocmp.Transform()) if diff != "" { t.Errorf("json not equal:\n%s", diff) } }, }, { emitUnpopulated: true, input: &examplepb.ResponseBodyOut{}, verifier: func(t *testing.T, input interface{}, json []byte) { var out examplepb.ResponseBodyOut err := marshaler.Unmarshal(json, &out) if err != nil { t.Fatalf("unexpected error: %v", err) } diff := cmp.Diff(input, &out, protocmp.Transform()) if diff != "" { t.Errorf("json not equal:\n%s", diff) } }, }, { input: &examplepb.RepeatedResponseBodyOut_Response{}, verifier: func(t *testing.T, input interface{}, json []byte) { var out examplepb.RepeatedResponseBodyOut_Response err := marshaler.Unmarshal(json, &out) if err != nil { t.Fatalf("unexpected error: %v", err) } diff := cmp.Diff(input, &out, protocmp.Transform()) if diff != "" { t.Errorf("json not equal:\n%s", diff) } }, }, { emitUnpopulated: true, input: &examplepb.RepeatedResponseBodyOut_Response{}, verifier: func(t *testing.T, input interface{}, json []byte) { var out examplepb.RepeatedResponseBodyOut_Response err := marshaler.Unmarshal(json, &out) if err != nil { t.Fatalf("unexpected error: %v", err) } diff := cmp.Diff(input, &out, protocmp.Transform()) if diff != "" { t.Errorf("json not equal:\n%s", diff) } }, }, { input: ([]*examplepb.RepeatedResponseBodyOut_Response)(nil), verifier: func(t *testing.T, input interface{}, json []byte) { var out []*examplepb.RepeatedResponseBodyOut_Response err := marshaler.Unmarshal(json, &out) if err != nil { t.Fatalf("unexpected error: %v", err) } diff := cmp.Diff(input, out, protocmp.Transform()) if diff != "" { t.Errorf("json not equal:\n%s", diff) } }, }, { emitUnpopulated: true, input: ([]*examplepb.RepeatedResponseBodyOut_Response)(nil), verifier: func(t *testing.T, _ interface{}, json []byte) { var out []*examplepb.RepeatedResponseBodyOut_Response err := marshaler.Unmarshal(json, &out) if err != nil { t.Fatalf("unexpected error: %v", err) } diff := cmp.Diff([]*examplepb.RepeatedResponseBodyOut_Response{}, out, protocmp.Transform()) if diff != "" { t.Errorf("json not equal:\n%s", diff) } }, }, { input: []*examplepb.RepeatedResponseBodyOut_Response{}, verifier: func(t *testing.T, input interface{}, json []byte) { var out []*examplepb.RepeatedResponseBodyOut_Response err := marshaler.Unmarshal(json, &out) if err != nil { t.Fatalf("unexpected error: %v", err) } diff := cmp.Diff(input, out, protocmp.Transform()) if diff != "" { t.Errorf("json not equal:\n%s", diff) } }, }, { input: []string{"something"}, verifier: func(t *testing.T, input interface{}, json []byte) { var out []string err := marshaler.Unmarshal(json, &out) if err != nil { t.Fatalf("unexpected error: %v", err) } diff := cmp.Diff(input, out, protocmp.Transform()) if diff != "" { t.Errorf("json not equal:\n%s", diff) } }, }, { input: []string{}, verifier: func(t *testing.T, input interface{}, json []byte) { var out []string err := marshaler.Unmarshal(json, &out) if err != nil { t.Fatalf("unexpected error: %v", err) } diff := cmp.Diff(input, out, protocmp.Transform()) if diff != "" { t.Errorf("json not equal:\n%s", diff) } }, }, { input: ([]string)(nil), verifier: func(t *testing.T, input interface{}, json []byte) { var out []string err := marshaler.Unmarshal(json, &out) if err != nil { t.Fatalf("unexpected error: %v", err) } diff := cmp.Diff(input, out, protocmp.Transform()) if diff != "" { t.Errorf("json not equal:\n%s", diff) } }, }, { emitUnpopulated: true, input: ([]string)(nil), verifier: func(t *testing.T, _ interface{}, json []byte) { var out []string err := marshaler.Unmarshal(json, &out) if err != nil { t.Fatalf("unexpected error: %v", err) } diff := cmp.Diff([]string{}, out, protocmp.Transform()) if diff != "" { t.Errorf("json not equal:\n%s", diff) } }, }, { input: []*examplepb.RepeatedResponseBodyOut_Response{ {}, { Data: "abc", Type: examplepb.RepeatedResponseBodyOut_Response_A, }, }, verifier: func(t *testing.T, input interface{}, json []byte) { var out []*examplepb.RepeatedResponseBodyOut_Response err := marshaler.Unmarshal(json, &out) if err != nil { t.Fatalf("unexpected error: %v", err) } diff := cmp.Diff(input, out, protocmp.Transform()) if diff != "" { t.Errorf("json not equal:\n%s", diff) } }, }, { emitUnpopulated: true, input: []*examplepb.RepeatedResponseBodyOut_Response{ {}, { Data: "abc", Type: examplepb.RepeatedResponseBodyOut_Response_B, }, }, verifier: func(t *testing.T, input interface{}, json []byte) { var out []*examplepb.RepeatedResponseBodyOut_Response err := marshaler.Unmarshal(json, &out) if err != nil { t.Fatalf("unexpected error: %v", err) } diff := cmp.Diff(input, out, protocmp.Transform()) if diff != "" { t.Errorf("json not equal:\n%s", diff) } }, }, } { t.Run(strconv.Itoa(i), func(t *testing.T) { m := runtime.JSONPb{ MarshalOptions: protojson.MarshalOptions{ EmitUnpopulated: spec.emitUnpopulated, }, } val := spec.input buf, err := m.Marshal(val) if err != nil { t.Errorf("m.Marshal(%v) failed with %v; want success; spec=%v", val, err, spec) } if spec.verifier != nil { spec.verifier(t, spec.input, buf) } }) } } ================================================ FILE: runtime/marshal_proto.go ================================================ package runtime import ( "errors" "io" "google.golang.org/protobuf/proto" ) // ProtoMarshaller is a Marshaller which marshals/unmarshals into/from serialize proto bytes type ProtoMarshaller struct{} // ContentType always returns "application/octet-stream". func (*ProtoMarshaller) ContentType(_ interface{}) string { return "application/octet-stream" } // Marshal marshals "value" into Proto func (*ProtoMarshaller) Marshal(value interface{}) ([]byte, error) { message, ok := value.(proto.Message) if !ok { return nil, errors.New("unable to marshal non proto field") } return proto.Marshal(message) } // Unmarshal unmarshals proto "data" into "value" func (*ProtoMarshaller) Unmarshal(data []byte, value interface{}) error { message, ok := value.(proto.Message) if !ok { return errors.New("unable to unmarshal non proto field") } return proto.Unmarshal(data, message) } // NewDecoder returns a Decoder which reads proto stream from "reader". func (marshaller *ProtoMarshaller) NewDecoder(reader io.Reader) Decoder { return DecoderFunc(func(value interface{}) error { buffer, err := io.ReadAll(reader) if err != nil { return err } return marshaller.Unmarshal(buffer, value) }) } // NewEncoder returns an Encoder which writes proto stream into "writer". func (marshaller *ProtoMarshaller) NewEncoder(writer io.Writer) Encoder { return EncoderFunc(func(value interface{}) error { buffer, err := marshaller.Marshal(value) if err != nil { return err } if _, err := writer.Write(buffer); err != nil { return err } return nil }) } ================================================ FILE: runtime/marshal_proto_test.go ================================================ package runtime_test import ( "bytes" "testing" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime/internal/examplepb" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/timestamppb" ) var message = &examplepb.ABitOfEverything{ SingleNested: &examplepb.ABitOfEverything_Nested{}, RepeatedStringValue: nil, MappedStringValue: nil, MappedNestedValue: nil, RepeatedEnumValue: nil, TimestampValue: ×tamppb.Timestamp{}, Uuid: "6EC2446F-7E89-4127-B3E6-5C05E6BECBA7", Nested: []*examplepb.ABitOfEverything_Nested{ { Name: "foo", Amount: 12345, }, }, Uint64Value: 0xFFFFFFFFFFFFFFFF, EnumValue: examplepb.NumericEnum_ONE, OneofValue: &examplepb.ABitOfEverything_OneofString{ OneofString: "bar", }, MapValue: map[string]examplepb.NumericEnum{ "a": examplepb.NumericEnum_ONE, "b": examplepb.NumericEnum_ZERO, }, } func TestProtoMarshalUnmarshal(t *testing.T) { marshaller := runtime.ProtoMarshaller{} // Marshal buffer, err := marshaller.Marshal(message) if err != nil { t.Fatalf("Marshalling returned error: %s", err.Error()) } // Unmarshal unmarshalled := &examplepb.ABitOfEverything{} err = marshaller.Unmarshal(buffer, unmarshalled) if err != nil { t.Fatalf("Unmarshalling returned error: %s", err.Error()) } if !proto.Equal(unmarshalled, message) { t.Errorf( "Unmarshalled didn't match original message: (original = %v) != (unmarshalled = %v)", unmarshalled, message, ) } } func TestProtoEncoderDecodert(t *testing.T) { marshaller := runtime.ProtoMarshaller{} var buf bytes.Buffer encoder := marshaller.NewEncoder(&buf) decoder := marshaller.NewDecoder(&buf) // Encode err := encoder.Encode(message) if err != nil { t.Fatalf("Encoding returned error: %s", err.Error()) } // Decode unencoded := &examplepb.ABitOfEverything{} err = decoder.Decode(unencoded) if err != nil { t.Fatalf("Unmarshalling returned error: %s", err.Error()) } if !proto.Equal(unencoded, message) { t.Errorf( "Unencoded didn't match original message: (original = %v) != (unencoded = %v)", unencoded, message, ) } } ================================================ FILE: runtime/marshaler.go ================================================ package runtime import ( "io" ) // Marshaler defines a conversion between byte sequence and gRPC payloads / fields. type Marshaler interface { // Marshal marshals "v" into byte sequence. Marshal(v interface{}) ([]byte, error) // Unmarshal unmarshals "data" into "v". // "v" must be a pointer value. Unmarshal(data []byte, v interface{}) error // NewDecoder returns a Decoder which reads byte sequence from "r". NewDecoder(r io.Reader) Decoder // NewEncoder returns an Encoder which writes bytes sequence into "w". NewEncoder(w io.Writer) Encoder // ContentType returns the Content-Type which this marshaler is responsible for. // The parameter describes the type which is being marshalled, which can sometimes // affect the content type returned. ContentType(v interface{}) string } // Decoder decodes a byte sequence type Decoder interface { Decode(v interface{}) error } // Encoder encodes gRPC payloads / fields into byte sequence. type Encoder interface { Encode(v interface{}) error } // DecoderFunc adapts an decoder function into Decoder. type DecoderFunc func(v interface{}) error // Decode delegates invocations to the underlying function itself. func (f DecoderFunc) Decode(v interface{}) error { return f(v) } // EncoderFunc adapts an encoder function into Encoder type EncoderFunc func(v interface{}) error // Encode delegates invocations to the underlying function itself. func (f EncoderFunc) Encode(v interface{}) error { return f(v) } // Delimited defines the streaming delimiter. type Delimited interface { // Delimiter returns the record separator for the stream. Delimiter() []byte } // StreamContentType defines the streaming content type. type StreamContentType interface { // StreamContentType returns the content type for a stream. This shares the // same behaviour as for `Marshaler.ContentType`, but is called, if present, // in the case of a streamed response. StreamContentType(v interface{}) string } ================================================ FILE: runtime/marshaler_registry.go ================================================ package runtime import ( "errors" "mime" "net/http" "google.golang.org/grpc/grpclog" "google.golang.org/protobuf/encoding/protojson" ) // MIMEWildcard is the fallback MIME type used for requests which do not match // a registered MIME type. const MIMEWildcard = "*" var ( acceptHeader = http.CanonicalHeaderKey("Accept") contentTypeHeader = http.CanonicalHeaderKey("Content-Type") defaultMarshaler = &HTTPBodyMarshaler{ Marshaler: &JSONPb{ MarshalOptions: protojson.MarshalOptions{ EmitUnpopulated: true, }, UnmarshalOptions: protojson.UnmarshalOptions{ DiscardUnknown: true, }, }, } ) // MarshalerForRequest returns the inbound/outbound marshalers for this request. // It checks the registry on the ServeMux for the MIME type set by the Content-Type header. // If it isn't set (or the request Content-Type is empty), checks for "*". // If there are multiple Content-Type headers set, choose the first one that it can // exactly match in the registry. // Otherwise, it follows the above logic for "*"/InboundMarshaler/OutboundMarshaler. func MarshalerForRequest(mux *ServeMux, r *http.Request) (inbound Marshaler, outbound Marshaler) { for _, acceptVal := range r.Header[acceptHeader] { if m, ok := mux.marshalers.mimeMap[acceptVal]; ok { outbound = m break } } for _, contentTypeVal := range r.Header[contentTypeHeader] { contentType, _, err := mime.ParseMediaType(contentTypeVal) if err != nil { grpclog.Errorf("Failed to parse Content-Type %s: %v", contentTypeVal, err) continue } if m, ok := mux.marshalers.mimeMap[contentType]; ok { inbound = m break } } if inbound == nil { inbound = mux.marshalers.mimeMap[MIMEWildcard] } if outbound == nil { outbound = inbound } return inbound, outbound } // marshalerRegistry is a mapping from MIME types to Marshalers. type marshalerRegistry struct { mimeMap map[string]Marshaler } // add adds a marshaler for a case-sensitive MIME type string ("*" to match any // MIME type). func (m marshalerRegistry) add(mime string, marshaler Marshaler) error { if len(mime) == 0 { return errors.New("empty MIME type") } m.mimeMap[mime] = marshaler return nil } // makeMarshalerMIMERegistry returns a new registry of marshalers. // It allows for a mapping of case-sensitive Content-Type MIME type string to runtime.Marshaler interfaces. // // For example, you could allow the client to specify the use of the runtime.JSONPb marshaler // with an "application/jsonpb" Content-Type and the use of the runtime.JSONBuiltin marshaler // with an "application/json" Content-Type. // "*" can be used to match any Content-Type. // This can be attached to a ServerMux with the marshaler option. func makeMarshalerMIMERegistry() marshalerRegistry { return marshalerRegistry{ mimeMap: map[string]Marshaler{ MIMEWildcard: defaultMarshaler, }, } } // WithMarshalerOption returns a ServeMuxOption which associates inbound and outbound // Marshalers to a MIME type in mux. func WithMarshalerOption(mime string, marshaler Marshaler) ServeMuxOption { return func(mux *ServeMux) { if err := mux.marshalers.add(mime, marshaler); err != nil { panic(err) } } } ================================================ FILE: runtime/marshaler_registry_test.go ================================================ package runtime_test import ( "context" "errors" "fmt" "io" "net/http" "testing" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" ) func TestMarshalerForRequest(t *testing.T) { ctx := context.Background() r, err := http.NewRequestWithContext(ctx, "GET", "http://example.com", nil) if err != nil { t.Fatalf(`http.NewRequest("GET", "http://example.com", nil) failed with %v; want success`, err) } mux := runtime.NewServeMux() r.Header.Set("Accept", "application/x-out") r.Header.Set("Content-Type", "application/x-in") in, out := runtime.MarshalerForRequest(mux, r) if _, ok := in.(*runtime.HTTPBodyMarshaler); !ok { t.Errorf("in = %#v; want a runtime.HTTPBodyMarshaler", in) } if _, ok := out.(*runtime.HTTPBodyMarshaler); !ok { t.Errorf("out = %#v; want a runtime.HTTPBodyMarshaler", in) } marshalers := []dummyMarshaler{0, 1, 2} specs := []struct { opt runtime.ServeMuxOption wantIn runtime.Marshaler wantOut runtime.Marshaler }{ // The option with wildcard overwrites the default configuration { opt: runtime.WithMarshalerOption(runtime.MIMEWildcard, &marshalers[0]), wantIn: &marshalers[0], wantOut: &marshalers[0], }, // You can specify a marshaler for a specific MIME type. // The output marshaler follows the input one unless specified. { opt: runtime.WithMarshalerOption("application/x-in", &marshalers[1]), wantIn: &marshalers[1], wantOut: &marshalers[1], }, // You can also separately specify an output marshaler { opt: runtime.WithMarshalerOption("application/x-out", &marshalers[2]), wantIn: &marshalers[1], wantOut: &marshalers[2], }, } for i, spec := range specs { var opts []runtime.ServeMuxOption for _, s := range specs[:i+1] { opts = append(opts, s.opt) } mux = runtime.NewServeMux(opts...) in, out = runtime.MarshalerForRequest(mux, r) if got, want := in, spec.wantIn; got != want { t.Errorf("in = %#v; want %#v", got, want) } if got, want := out, spec.wantOut; got != want { t.Errorf("out = %#v; want %#v", got, want) } } r.Header.Set("Content-Type", "application/x-in; charset=UTF-8") in, out = runtime.MarshalerForRequest(mux, r) if got, want := in, &marshalers[1]; got != want { t.Errorf("in = %#v; want %#v", got, want) } if got, want := out, &marshalers[2]; got != want { t.Errorf("out = %#v; want %#v", got, want) } r.Header.Set("Content-Type", "application/x-another") r.Header.Set("Accept", "application/x-another") in, out = runtime.MarshalerForRequest(mux, r) if got, want := in, &marshalers[0]; got != want { t.Errorf("in = %#v; want %#v", got, want) } if got, want := out, &marshalers[0]; got != want { t.Errorf("out = %#v; want %#v", got, want) } } type dummyMarshaler int func (dummyMarshaler) ContentType(_ interface{}) string { return "" } func (dummyMarshaler) Marshal(interface{}) ([]byte, error) { return nil, errors.New("not implemented") } func (dummyMarshaler) Unmarshal([]byte, interface{}) error { return errors.New("not implemented") } func (dummyMarshaler) NewDecoder(r io.Reader) runtime.Decoder { return dummyDecoder{} } func (dummyMarshaler) NewEncoder(w io.Writer) runtime.Encoder { return dummyEncoder{} } func (m dummyMarshaler) GoString() string { return fmt.Sprintf("dummyMarshaler(%d)", m) } type dummyDecoder struct{} func (dummyDecoder) Decode(interface{}) error { return errors.New("not implemented") } type dummyEncoder struct{} func (dummyEncoder) Encode(interface{}) error { return errors.New("not implemented") } ================================================ FILE: runtime/mux.go ================================================ package runtime import ( "context" "errors" "fmt" "net/http" "net/textproto" "regexp" "strings" "github.com/grpc-ecosystem/grpc-gateway/v2/internal/httprule" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/health/grpc_health_v1" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) // UnescapingMode defines the behavior of ServeMux when unescaping path parameters. type UnescapingMode int const ( // UnescapingModeLegacy is the default V2 behavior, which escapes the entire // path string before doing any routing. UnescapingModeLegacy UnescapingMode = iota // UnescapingModeAllExceptReserved unescapes all path parameters except RFC 6570 // reserved characters. UnescapingModeAllExceptReserved // UnescapingModeAllExceptSlash unescapes URL path parameters except path // separators, which will be left as "%2F". UnescapingModeAllExceptSlash // UnescapingModeAllCharacters unescapes all URL path parameters. UnescapingModeAllCharacters // UnescapingModeDefault is the default escaping type. // TODO(v3): default this to UnescapingModeAllExceptReserved per grpc-httpjson-transcoding's // reference implementation UnescapingModeDefault = UnescapingModeLegacy ) var encodedPathSplitter = regexp.MustCompile("(/|%2F)") // A HandlerFunc handles a specific pair of path pattern and HTTP method. type HandlerFunc func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) // A Middleware handler wraps another HandlerFunc to do some pre- and/or post-processing of the request. This is used as an alternative to gRPC interceptors when using the direct-to-implementation // registration methods. It is generally recommended to use gRPC client or server interceptors instead // where possible. type Middleware func(HandlerFunc) HandlerFunc // ServeMux is a request multiplexer for grpc-gateway. // It matches http requests to patterns and invokes the corresponding handler. type ServeMux struct { // handlers maps HTTP method to a list of handlers. handlers map[string][]handler middlewares []Middleware forwardResponseOptions []func(context.Context, http.ResponseWriter, proto.Message) error forwardResponseRewriter ForwardResponseRewriter marshalers marshalerRegistry incomingHeaderMatcher HeaderMatcherFunc outgoingHeaderMatcher HeaderMatcherFunc outgoingTrailerMatcher HeaderMatcherFunc metadataAnnotators []func(context.Context, *http.Request) metadata.MD errorHandler ErrorHandlerFunc streamErrorHandler StreamErrorHandlerFunc routingErrorHandler RoutingErrorHandlerFunc disablePathLengthFallback bool disableHTTPMethodOverride bool unescapingMode UnescapingMode writeContentLength bool disableChunkedEncoding bool } // ServeMuxOption is an option that can be given to a ServeMux on construction. type ServeMuxOption func(*ServeMux) // ForwardResponseRewriter is the signature of a function that is capable of rewriting messages // before they are forwarded in a unary, stream, or error response. type ForwardResponseRewriter func(ctx context.Context, response proto.Message) (any, error) // WithForwardResponseRewriter returns a ServeMuxOption that allows for implementers to insert logic // that can rewrite the final response before it is forwarded. // // The response rewriter function is called during unary message forwarding, stream message // forwarding and when errors are being forwarded. // // NOTE: Using this option will likely make what is generated by `protoc-gen-openapiv2` incorrect. // Since this option involves making runtime changes to the response shape or type. func WithForwardResponseRewriter(fwdResponseRewriter ForwardResponseRewriter) ServeMuxOption { return func(sm *ServeMux) { sm.forwardResponseRewriter = fwdResponseRewriter } } // WithForwardResponseOption returns a ServeMuxOption representing the forwardResponseOption. // // forwardResponseOption is an option that will be called on the relevant context.Context, // http.ResponseWriter, and proto.Message before every forwarded response. // // The message may be nil in the case where just a header is being sent. func WithForwardResponseOption(forwardResponseOption func(context.Context, http.ResponseWriter, proto.Message) error) ServeMuxOption { return func(serveMux *ServeMux) { serveMux.forwardResponseOptions = append(serveMux.forwardResponseOptions, forwardResponseOption) } } // WithUnescapingMode sets the escaping type. See the definitions of UnescapingMode // for more information. func WithUnescapingMode(mode UnescapingMode) ServeMuxOption { return func(serveMux *ServeMux) { serveMux.unescapingMode = mode } } // WithMiddlewares sets server middleware for all handlers. This is useful as an alternative to gRPC // interceptors when using the direct-to-implementation registration methods and cannot rely // on gRPC interceptors. It's recommended to use gRPC interceptors instead if possible. func WithMiddlewares(middlewares ...Middleware) ServeMuxOption { return func(serveMux *ServeMux) { serveMux.middlewares = append(serveMux.middlewares, middlewares...) } } // WithDisableChunkedEncoding disables the Transfer-Encoding: chunked header // for streaming responses. This is useful for streaming implementations that use // Content-Length, which is mutually exclusive with Transfer-Encoding:chunked. // Note that this option will not automatically add Content-Length headers, so it should be used with caution. func WithDisableChunkedEncoding() ServeMuxOption { return func(mux *ServeMux) { mux.disableChunkedEncoding = true } } // SetQueryParameterParser sets the query parameter parser, used to populate message from query parameters. // Configuring this will mean the generated OpenAPI output is no longer correct, and it should be // done with careful consideration. func SetQueryParameterParser(queryParameterParser QueryParameterParser) ServeMuxOption { return func(serveMux *ServeMux) { currentQueryParser = queryParameterParser } } // HeaderMatcherFunc checks whether a header key should be forwarded to/from gRPC context. type HeaderMatcherFunc func(string) (string, bool) // DefaultHeaderMatcher is used to pass http request headers to/from gRPC context. This adds permanent HTTP header // keys (as specified by the IANA, e.g: Accept, Cookie, Host) to the gRPC metadata with the grpcgateway- prefix. If you want to know which headers are considered permanent, you can view the isPermanentHTTPHeader function. // HTTP headers that start with 'Grpc-Metadata-' are mapped to gRPC metadata after removing the prefix 'Grpc-Metadata-'. // Other headers are not added to the gRPC metadata. func DefaultHeaderMatcher(key string) (string, bool) { switch key = textproto.CanonicalMIMEHeaderKey(key); { case isPermanentHTTPHeader(key): return MetadataPrefix + key, true case strings.HasPrefix(key, MetadataHeaderPrefix): return key[len(MetadataHeaderPrefix):], true } return "", false } func defaultOutgoingHeaderMatcher(key string) (string, bool) { return fmt.Sprintf("%s%s", MetadataHeaderPrefix, key), true } func defaultOutgoingTrailerMatcher(key string) (string, bool) { return fmt.Sprintf("%s%s", MetadataTrailerPrefix, key), true } // WithIncomingHeaderMatcher returns a ServeMuxOption representing a headerMatcher for incoming request to gateway. // // This matcher will be called with each header in http.Request. If matcher returns true, that header will be // passed to gRPC context. To transform the header before passing to gRPC context, matcher should return the modified header. func WithIncomingHeaderMatcher(fn HeaderMatcherFunc) ServeMuxOption { for _, header := range fn.matchedMalformedHeaders() { grpclog.Warningf("The configured forwarding filter would allow %q to be sent to the gRPC server, which will likely cause errors. See https://github.com/grpc/grpc-go/pull/4803#issuecomment-986093310 for more information.", header) } return func(mux *ServeMux) { mux.incomingHeaderMatcher = fn } } // matchedMalformedHeaders returns the malformed headers that would be forwarded to gRPC server. func (fn HeaderMatcherFunc) matchedMalformedHeaders() []string { if fn == nil { return nil } headers := make([]string, 0) for header := range malformedHTTPHeaders { out, accept := fn(header) if accept && isMalformedHTTPHeader(out) { headers = append(headers, out) } } return headers } // WithOutgoingHeaderMatcher returns a ServeMuxOption representing a headerMatcher for outgoing response from gateway. // // This matcher will be called with each header in response header metadata. If matcher returns true, that header will be // passed to http response returned from gateway. To transform the header before passing to response, // matcher should return the modified header. func WithOutgoingHeaderMatcher(fn HeaderMatcherFunc) ServeMuxOption { return func(mux *ServeMux) { mux.outgoingHeaderMatcher = fn } } // WithOutgoingTrailerMatcher returns a ServeMuxOption representing a headerMatcher for outgoing response from gateway. // // This matcher will be called with each header in response trailer metadata. If matcher returns true, that header will be // passed to http response returned from gateway. To transform the header before passing to response, // matcher should return the modified header. func WithOutgoingTrailerMatcher(fn HeaderMatcherFunc) ServeMuxOption { return func(mux *ServeMux) { mux.outgoingTrailerMatcher = fn } } // WithMetadata returns a ServeMuxOption for passing metadata to a gRPC context. // // This can be used by services that need to read from http.Request and modify gRPC context. A common use case // is reading token from cookie and adding it in gRPC context. func WithMetadata(annotator func(context.Context, *http.Request) metadata.MD) ServeMuxOption { return func(serveMux *ServeMux) { serveMux.metadataAnnotators = append(serveMux.metadataAnnotators, annotator) } } // WithErrorHandler returns a ServeMuxOption for configuring a custom error handler. // // This can be used to configure a custom error response. func WithErrorHandler(fn ErrorHandlerFunc) ServeMuxOption { return func(serveMux *ServeMux) { serveMux.errorHandler = fn } } // WithStreamErrorHandler returns a ServeMuxOption that will use the given custom stream // error handler, which allows for customizing the error trailer for server-streaming // calls. // // For stream errors that occur before any response has been written, the mux's // ErrorHandler will be invoked. However, once data has been written, the errors must // be handled differently: they must be included in the response body. The response body's // final message will include the error details returned by the stream error handler. func WithStreamErrorHandler(fn StreamErrorHandlerFunc) ServeMuxOption { return func(serveMux *ServeMux) { serveMux.streamErrorHandler = fn } } // WithRoutingErrorHandler returns a ServeMuxOption for configuring a custom error handler to handle http routing errors. // // Method called for errors which can happen before gRPC route selected or executed. // The following error codes: StatusMethodNotAllowed StatusNotFound StatusBadRequest func WithRoutingErrorHandler(fn RoutingErrorHandlerFunc) ServeMuxOption { return func(serveMux *ServeMux) { serveMux.routingErrorHandler = fn } } // WithDisablePathLengthFallback returns a ServeMuxOption for disable path length fallback. func WithDisablePathLengthFallback() ServeMuxOption { return func(serveMux *ServeMux) { serveMux.disablePathLengthFallback = true } } // WithDisableHTTPMethodOverride returns a ServeMuxOption that disables the // X-HTTP-Method-Override header handling. // // When this option is used, the mux will no longer allow POST requests with // the X-HTTP-Method-Override header to override the HTTP method. The path // length fallback (POST with application/x-www-form-urlencoded falling back // to a matching GET handler) is not affected by this option. func WithDisableHTTPMethodOverride() ServeMuxOption { return func(serveMux *ServeMux) { serveMux.disableHTTPMethodOverride = true } } // WithWriteContentLength returns a ServeMuxOption to enable writing content length on non-streaming responses func WithWriteContentLength() ServeMuxOption { return func(serveMux *ServeMux) { serveMux.writeContentLength = true } } // WithHealthEndpointAt returns a ServeMuxOption that will add an endpoint to the created ServeMux at the path specified by endpointPath. // When called the handler will forward the request to the upstream grpc service health check (defined in the // gRPC Health Checking Protocol). // // See here https://grpc-ecosystem.github.io/grpc-gateway/docs/operations/health_check/ for more information on how // to setup the protocol in the grpc server. // // If you define a service as query parameter, this will also be forwarded as service in the HealthCheckRequest. func WithHealthEndpointAt(healthCheckClient grpc_health_v1.HealthClient, endpointPath string) ServeMuxOption { return func(s *ServeMux) { // error can be ignored since pattern is definitely valid _ = s.HandlePath( http.MethodGet, endpointPath, func(w http.ResponseWriter, r *http.Request, _ map[string]string, ) { _, outboundMarshaler := MarshalerForRequest(s, r) annotatedContext, err := AnnotateContext(r.Context(), s, r, grpc_health_v1.Health_Check_FullMethodName, WithHTTPPathPattern(endpointPath)) if err != nil { s.errorHandler(r.Context(), s, outboundMarshaler, w, r, err) return } var md ServerMetadata resp, err := healthCheckClient.Check(annotatedContext, &grpc_health_v1.HealthCheckRequest{ Service: r.URL.Query().Get("service"), }, grpc.Header(&md.HeaderMD), grpc.Trailer(&md.TrailerMD)) annotatedContext = NewServerMetadataContext(annotatedContext, md) if err != nil { s.errorHandler(annotatedContext, s, outboundMarshaler, w, r, err) return } w.Header().Set("Content-Type", "application/json") if resp.GetStatus() != grpc_health_v1.HealthCheckResponse_SERVING { switch resp.GetStatus() { case grpc_health_v1.HealthCheckResponse_NOT_SERVING, grpc_health_v1.HealthCheckResponse_UNKNOWN: err = status.Error(codes.Unavailable, resp.String()) case grpc_health_v1.HealthCheckResponse_SERVICE_UNKNOWN: err = status.Error(codes.NotFound, resp.String()) } s.errorHandler(annotatedContext, s, outboundMarshaler, w, r, err) return } _ = outboundMarshaler.NewEncoder(w).Encode(resp) }) } } // WithHealthzEndpoint returns a ServeMuxOption that will add a /healthz endpoint to the created ServeMux. // // See WithHealthEndpointAt for the general implementation. func WithHealthzEndpoint(healthCheckClient grpc_health_v1.HealthClient) ServeMuxOption { return WithHealthEndpointAt(healthCheckClient, "/healthz") } // NewServeMux returns a new ServeMux whose internal mapping is empty. func NewServeMux(opts ...ServeMuxOption) *ServeMux { serveMux := &ServeMux{ handlers: make(map[string][]handler), forwardResponseOptions: make([]func(context.Context, http.ResponseWriter, proto.Message) error, 0), forwardResponseRewriter: func(ctx context.Context, response proto.Message) (any, error) { return response, nil }, marshalers: makeMarshalerMIMERegistry(), errorHandler: DefaultHTTPErrorHandler, streamErrorHandler: DefaultStreamErrorHandler, routingErrorHandler: DefaultRoutingErrorHandler, unescapingMode: UnescapingModeDefault, } for _, opt := range opts { opt(serveMux) } if serveMux.incomingHeaderMatcher == nil { serveMux.incomingHeaderMatcher = DefaultHeaderMatcher } if serveMux.outgoingHeaderMatcher == nil { serveMux.outgoingHeaderMatcher = defaultOutgoingHeaderMatcher } if serveMux.outgoingTrailerMatcher == nil { serveMux.outgoingTrailerMatcher = defaultOutgoingTrailerMatcher } return serveMux } // Handle associates "h" to the pair of HTTP method and path pattern. func (s *ServeMux) Handle(meth string, pat Pattern, h HandlerFunc) { if len(s.middlewares) > 0 { h = chainMiddlewares(s.middlewares)(h) } s.handlers[meth] = append([]handler{{pat: pat, h: h}}, s.handlers[meth]...) } // HandlePath allows users to configure custom path handlers. // refer: https://grpc-ecosystem.github.io/grpc-gateway/docs/operations/inject_router/ func (s *ServeMux) HandlePath(meth string, pathPattern string, h HandlerFunc) error { compiler, err := httprule.Parse(pathPattern) if err != nil { return fmt.Errorf("parsing path pattern: %w", err) } tp := compiler.Compile() pattern, err := NewPattern(tp.Version, tp.OpCodes, tp.Pool, tp.Verb) if err != nil { return fmt.Errorf("creating new pattern: %w", err) } s.Handle(meth, pattern, h) return nil } // ServeHTTP dispatches the request to the first handler whose pattern matches to r.Method and r.URL.Path. func (s *ServeMux) ServeHTTP(w http.ResponseWriter, r *http.Request) { ctx := r.Context() path := r.URL.Path if !strings.HasPrefix(path, "/") { _, outboundMarshaler := MarshalerForRequest(s, r) s.routingErrorHandler(ctx, s, outboundMarshaler, w, r, http.StatusBadRequest) return } // TODO(v3): remove UnescapingModeLegacy if s.unescapingMode != UnescapingModeLegacy && r.URL.RawPath != "" { path = r.URL.RawPath } if override := r.Header.Get("X-HTTP-Method-Override"); override != "" && !s.disableHTTPMethodOverride && s.isPathLengthFallback(r) { if err := r.ParseForm(); err != nil { _, outboundMarshaler := MarshalerForRequest(s, r) sterr := status.Error(codes.InvalidArgument, err.Error()) s.errorHandler(ctx, s, outboundMarshaler, w, r, sterr) return } r.Method = strings.ToUpper(override) } var pathComponents []string // since in UnescapeModeLegacy, the URL will already have been fully unescaped, if we also split on "%2F" // in this escaping mode we would be double unescaping but in UnescapingModeAllCharacters, we still do as the // path is the RawPath (i.e. unescaped). That does mean that the behavior of this function will change its default // behavior when the UnescapingModeDefault gets changed from UnescapingModeLegacy to UnescapingModeAllExceptReserved if s.unescapingMode == UnescapingModeAllCharacters { pathComponents = encodedPathSplitter.Split(path[1:], -1) } else { pathComponents = strings.Split(path[1:], "/") } lastPathComponent := pathComponents[len(pathComponents)-1] for _, h := range s.handlers[r.Method] { // If the pattern has a verb, explicitly look for a suffix in the last // component that matches a colon plus the verb. This allows us to // handle some cases that otherwise can't be correctly handled by the // former LastIndex case, such as when the verb literal itself contains // a colon. This should work for all cases that have run through the // parser because we know what verb we're looking for, however, there // are still some cases that the parser itself cannot disambiguate. See // the comment there if interested. var verb string patVerb := h.pat.Verb() idx := -1 if patVerb != "" && strings.HasSuffix(lastPathComponent, ":"+patVerb) { idx = len(lastPathComponent) - len(patVerb) - 1 } if idx == 0 { _, outboundMarshaler := MarshalerForRequest(s, r) s.routingErrorHandler(ctx, s, outboundMarshaler, w, r, http.StatusNotFound) return } comps := make([]string, len(pathComponents)) copy(comps, pathComponents) if idx > 0 { comps[len(comps)-1], verb = lastPathComponent[:idx], lastPathComponent[idx+1:] } pathParams, err := h.pat.MatchAndEscape(comps, verb, s.unescapingMode) if err != nil { var mse MalformedSequenceError if ok := errors.As(err, &mse); ok { _, outboundMarshaler := MarshalerForRequest(s, r) s.errorHandler(ctx, s, outboundMarshaler, w, r, &HTTPStatusError{ HTTPStatus: http.StatusBadRequest, Err: mse, }) } continue } s.handleHandler(h, w, r, pathParams) return } // if no handler has found for the request, lookup for other methods // to handle POST -> GET fallback if the request is subject to path // length fallback. // Note we are not eagerly checking the request here as we want to return the // right HTTP status code, and we need to process the fallback candidates in // order to do that. for m, handlers := range s.handlers { if m == r.Method { continue } for _, h := range handlers { var verb string patVerb := h.pat.Verb() idx := -1 if patVerb != "" && strings.HasSuffix(lastPathComponent, ":"+patVerb) { idx = len(lastPathComponent) - len(patVerb) - 1 } comps := make([]string, len(pathComponents)) copy(comps, pathComponents) if idx > 0 { comps[len(comps)-1], verb = lastPathComponent[:idx], lastPathComponent[idx+1:] } pathParams, err := h.pat.MatchAndEscape(comps, verb, s.unescapingMode) if err != nil { var mse MalformedSequenceError if ok := errors.As(err, &mse); ok { _, outboundMarshaler := MarshalerForRequest(s, r) s.errorHandler(ctx, s, outboundMarshaler, w, r, &HTTPStatusError{ HTTPStatus: http.StatusBadRequest, Err: mse, }) } continue } // X-HTTP-Method-Override is optional. Always allow fallback to POST. // Also, only consider POST -> GET fallbacks, and avoid falling back to // potentially dangerous operations like DELETE. if s.isPathLengthFallback(r) && m == http.MethodGet { if err := r.ParseForm(); err != nil { _, outboundMarshaler := MarshalerForRequest(s, r) sterr := status.Error(codes.InvalidArgument, err.Error()) s.errorHandler(ctx, s, outboundMarshaler, w, r, sterr) return } s.handleHandler(h, w, r, pathParams) return } _, outboundMarshaler := MarshalerForRequest(s, r) s.routingErrorHandler(ctx, s, outboundMarshaler, w, r, http.StatusMethodNotAllowed) return } } _, outboundMarshaler := MarshalerForRequest(s, r) s.routingErrorHandler(ctx, s, outboundMarshaler, w, r, http.StatusNotFound) } // GetForwardResponseOptions returns the ForwardResponseOptions associated with this ServeMux. func (s *ServeMux) GetForwardResponseOptions() []func(context.Context, http.ResponseWriter, proto.Message) error { return s.forwardResponseOptions } func (s *ServeMux) isPathLengthFallback(r *http.Request) bool { return !s.disablePathLengthFallback && r.Method == "POST" && r.Header.Get("Content-Type") == "application/x-www-form-urlencoded" } type handler struct { pat Pattern h HandlerFunc } func (s *ServeMux) handleHandler(h handler, w http.ResponseWriter, r *http.Request, pathParams map[string]string) { h.h(w, r.WithContext(withHTTPPattern(r.Context(), h.pat)), pathParams) } func chainMiddlewares(mws []Middleware) Middleware { return func(next HandlerFunc) HandlerFunc { for i := len(mws); i > 0; i-- { next = mws[i-1](next) } return next } } ================================================ FILE: runtime/mux_internal_test.go ================================================ package runtime import ( "sort" "testing" ) func TestWithIncomingHeaderMatcher_matchedMalformedHeaders(t *testing.T) { tests := []struct { name string matcher HeaderMatcherFunc want []string }{ { "nil matcher returns nothing", nil, nil, }, { "default matcher returns nothing", DefaultHeaderMatcher, nil, }, { "passthrough matcher returns all malformed headers", func(s string) (string, bool) { return s, true }, []string{"connection"}, }, } sliceEqual := func(a, b []string) bool { if len(a) != len(b) { return false } sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) sort.Slice(b, func(i, j int) bool { return a[i] < a[j] }) for idx := range a { if a[idx] != b[idx] { return false } } return true } for _, tt := range tests { out := tt.matcher.matchedMalformedHeaders() if !sliceEqual(tt.want, out) { t.Errorf("matchedMalformedHeaders not match; Want %v; got %v", tt.want, out) } } } ================================================ FILE: runtime/mux_test.go ================================================ package runtime_test import ( "bytes" "context" "fmt" "net/http" "net/http/httptest" "net/url" "strconv" "strings" "testing" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/health/grpc_health_v1" "google.golang.org/grpc/status" ) func TestMuxServeHTTP(t *testing.T) { type stubPattern struct { method string ops []int pool []string verb string } for i, spec := range []struct { patterns []stubPattern reqMethod string reqPath string headers map[string]string respStatus int respContent string disablePathLengthFallback bool unescapingMode runtime.UnescapingMode }{ { patterns: nil, reqMethod: "GET", reqPath: "/", respStatus: http.StatusNotFound, }, { patterns: []stubPattern{ { method: "GET", ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"foo"}, }, }, reqMethod: "GET", reqPath: "/foo", respStatus: http.StatusOK, respContent: "GET /foo", }, { patterns: []stubPattern{ { method: "GET", ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"foo"}, }, }, reqMethod: "GET", reqPath: "/bar", respStatus: http.StatusNotFound, }, { patterns: []stubPattern{ { method: "GET", ops: []int{int(utilities.OpPush), 0}, }, { method: "GET", ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"foo"}, }, }, reqMethod: "GET", reqPath: "/foo", respStatus: http.StatusOK, respContent: "GET /foo", }, { patterns: []stubPattern{ { method: "GET", ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"foo"}, }, { method: "POST", ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"foo"}, }, }, reqMethod: "POST", reqPath: "/foo", respStatus: http.StatusOK, respContent: "POST /foo", }, { patterns: []stubPattern{ { method: "GET", ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"foo"}, }, }, reqMethod: "DELETE", reqPath: "/foo", respStatus: http.StatusNotImplemented, }, { patterns: []stubPattern{ { method: "POST", ops: []int{int(utilities.OpLitPush), 0, int(utilities.OpPush), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1}, pool: []string{"foo", "id"}, verb: "archive", }, }, reqMethod: "DELETE", reqPath: "/foo/bar:archive", respStatus: http.StatusNotImplemented, }, { patterns: []stubPattern{ { method: "GET", ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"foo"}, }, }, reqMethod: "POST", reqPath: "/foo", headers: map[string]string{ "Content-Type": "application/x-www-form-urlencoded", }, respStatus: http.StatusOK, respContent: "GET /foo", }, { patterns: []stubPattern{ { method: "GET", ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"foo"}, }, }, reqMethod: "POST", reqPath: "/foo", headers: map[string]string{ "Content-Type": "application/x-www-form-urlencoded", }, respStatus: http.StatusNotImplemented, disablePathLengthFallback: true, }, { patterns: []stubPattern{ { method: "GET", ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"foo"}, }, { method: "POST", ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"foo"}, }, }, reqMethod: "POST", reqPath: "/foo", headers: map[string]string{ "Content-Type": "application/x-www-form-urlencoded", }, respStatus: http.StatusOK, respContent: "POST /foo", disablePathLengthFallback: true, }, { patterns: []stubPattern{ { method: "GET", ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"foo"}, }, { method: "POST", ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"foo"}, }, }, reqMethod: "POST", reqPath: "/foo", headers: map[string]string{ "Content-Type": "application/x-www-form-urlencoded", "X-HTTP-Method-Override": "GET", }, respStatus: http.StatusOK, respContent: "GET /foo", }, { patterns: []stubPattern{ { method: "GET", ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"foo"}, }, }, reqMethod: "POST", reqPath: "/foo", headers: map[string]string{ "Content-Type": "application/x-www-form-urlencoded", }, respStatus: http.StatusOK, respContent: "GET /foo", }, { patterns: []stubPattern{ { method: "DELETE", ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"foo"}, }, { method: "PUT", ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"foo"}, }, { method: "PATCH", ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"foo"}, }, }, reqMethod: "POST", reqPath: "/foo", headers: map[string]string{ "Content-Type": "application/x-www-form-urlencoded", }, respStatus: http.StatusNotImplemented, }, { patterns: []stubPattern{ { method: "GET", ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"foo"}, }, }, reqMethod: "POST", reqPath: "/foo", headers: map[string]string{ "Content-Type": "application/json", }, respStatus: http.StatusNotImplemented, }, { patterns: []stubPattern{ { method: "POST", ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"foo"}, verb: "bar", }, }, reqMethod: "POST", reqPath: "/foo:bar", headers: map[string]string{ "Content-Type": "application/json", }, respStatus: http.StatusOK, respContent: "POST /foo:bar", }, { patterns: []stubPattern{ { method: "GET", ops: []int{int(utilities.OpLitPush), 0, int(utilities.OpPush), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1}, pool: []string{"foo", "id"}, }, { method: "GET", ops: []int{int(utilities.OpLitPush), 0, int(utilities.OpPush), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1}, pool: []string{"foo", "id"}, verb: "verb", }, }, reqMethod: "GET", reqPath: "/foo/bar:verb", headers: map[string]string{ "Content-Type": "application/json", }, respStatus: http.StatusOK, respContent: "GET /foo/{id=*}:verb", }, { patterns: []stubPattern{ { method: "GET", ops: []int{int(utilities.OpLitPush), 0, int(utilities.OpPush), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1}, pool: []string{"foo", "id"}, }, }, reqMethod: "GET", reqPath: "/foo/bar", headers: map[string]string{ "Content-Type": "application/json", }, respStatus: http.StatusOK, respContent: "GET /foo/{id=*}", }, { patterns: []stubPattern{ { method: "GET", ops: []int{int(utilities.OpLitPush), 0, int(utilities.OpPush), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1}, pool: []string{"foo", "id"}, }, }, reqMethod: "GET", reqPath: "/foo/bar:123", headers: map[string]string{ "Content-Type": "application/json", }, respStatus: http.StatusOK, respContent: "GET /foo/{id=*}", }, { patterns: []stubPattern{ { method: "POST", ops: []int{int(utilities.OpLitPush), 0, int(utilities.OpPush), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1}, pool: []string{"foo", "id"}, }, { method: "POST", ops: []int{int(utilities.OpLitPush), 0, int(utilities.OpPush), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1}, pool: []string{"foo", "id"}, verb: "verb", }, }, reqMethod: "POST", reqPath: "/foo/bar:verb", headers: map[string]string{ "Content-Type": "application/json", }, respStatus: http.StatusOK, respContent: "POST /foo/{id=*}:verb", }, { patterns: []stubPattern{ { method: "GET", ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"foo"}, }, }, reqMethod: "POST", reqPath: "foo", headers: map[string]string{ "Content-Type": "application/json", }, respStatus: http.StatusBadRequest, }, { patterns: []stubPattern{ { method: "POST", ops: []int{int(utilities.OpLitPush), 0, int(utilities.OpPush), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1}, pool: []string{"foo", "id"}, }, { method: "POST", ops: []int{int(utilities.OpLitPush), 0, int(utilities.OpPush), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1}, pool: []string{"foo", "id"}, verb: "verb:subverb", }, }, reqMethod: "POST", reqPath: "/foo/bar:verb:subverb", headers: map[string]string{ "Content-Type": "application/json", }, respStatus: http.StatusOK, respContent: "POST /foo/{id=*}:verb:subverb", }, { patterns: []stubPattern{ { method: "GET", ops: []int{int(utilities.OpLitPush), 0, int(utilities.OpPush), 1, int(utilities.OpCapture), 1, int(utilities.OpLitPush), 2}, pool: []string{"foo", "id", "bar"}, }, }, reqMethod: "POST", reqPath: "/foo/404%2fwith%2Fspace/bar", headers: map[string]string{ "Content-Type": "application/json", }, respStatus: http.StatusNotFound, unescapingMode: runtime.UnescapingModeLegacy, }, { patterns: []stubPattern{ { method: "GET", ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpPush), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1, int(utilities.OpLitPush), 2}, pool: []string{"foo", "id", "bar"}, }, }, reqMethod: "GET", reqPath: "/foo/success%2fwith%2Fspace/bar", headers: map[string]string{ "Content-Type": "application/json", }, respStatus: http.StatusOK, unescapingMode: runtime.UnescapingModeAllExceptReserved, respContent: "GET /foo/{id=*}/bar", }, { patterns: []stubPattern{ { method: "GET", ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpPush), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1, int(utilities.OpLitPush), 2}, pool: []string{"foo", "id", "bar"}, }, }, reqMethod: "GET", reqPath: "/foo/success%2fwith%2Fspace/bar", headers: map[string]string{ "Content-Type": "application/json", }, respStatus: http.StatusNotFound, unescapingMode: runtime.UnescapingModeAllCharacters, }, { patterns: []stubPattern{ { method: "GET", ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpPush), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1, int(utilities.OpLitPush), 2}, pool: []string{"foo", "id", "bar"}, }, }, reqMethod: "GET", reqPath: "/foo/success%2fwith%2Fspace/bar", headers: map[string]string{ "Content-Type": "application/json", }, respStatus: http.StatusNotFound, unescapingMode: runtime.UnescapingModeLegacy, }, { patterns: []stubPattern{ { method: "GET", ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpPushM), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1, }, pool: []string{"foo", "id", "bar"}, }, }, reqMethod: "GET", reqPath: "/foo/success%2fwith%2Fspace", headers: map[string]string{ "Content-Type": "application/json", }, respStatus: http.StatusOK, unescapingMode: runtime.UnescapingModeAllExceptReserved, respContent: "GET /foo/{id=**}", }, { patterns: []stubPattern{ { method: "POST", ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpLitPush), 1, int(utilities.OpLitPush), 2, int(utilities.OpPush), 0, int(utilities.OpConcatN), 2, int(utilities.OpCapture), 3, }, pool: []string{"api", "v1", "organizations", "name"}, verb: "action", }, }, reqMethod: "POST", reqPath: "/api/v1/" + url.QueryEscape("organizations/foo") + ":action", headers: map[string]string{ "Content-Type": "application/json", }, respStatus: http.StatusOK, unescapingMode: runtime.UnescapingModeAllCharacters, respContent: "POST /api/v1/{name=organizations/*}:action", }, { patterns: []stubPattern{ { method: "POST", ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpLitPush), 1, int(utilities.OpLitPush), 2, }, pool: []string{"api", "v1", "organizations"}, verb: "verb", }, { method: "POST", ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpLitPush), 1, int(utilities.OpLitPush), 2, }, pool: []string{"api", "v1", "organizations"}, verb: "", }, { method: "POST", ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpLitPush), 1, int(utilities.OpLitPush), 2, }, pool: []string{"api", "v1", "dummies"}, verb: "verb", }, }, reqMethod: "POST", reqPath: "/api/v1/organizations:verb", headers: map[string]string{ "Content-Type": "application/json", }, respStatus: http.StatusOK, unescapingMode: runtime.UnescapingModeAllCharacters, respContent: "POST /api/v1/organizations:verb", }, } { t.Run(strconv.Itoa(i), func(t *testing.T) { var opts []runtime.ServeMuxOption opts = append(opts, runtime.WithUnescapingMode(spec.unescapingMode)) if spec.disablePathLengthFallback { opts = append(opts, runtime.WithDisablePathLengthFallback(), ) } mux := runtime.NewServeMux(opts...) for _, p := range spec.patterns { func(p stubPattern) { pat, err := runtime.NewPattern(1, p.ops, p.pool, p.verb) if err != nil { t.Fatalf("runtime.NewPattern(1, %#v, %#v, %q) failed with %v; want success", p.ops, p.pool, p.verb, err) } mux.Handle(p.method, pat, func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) { _, _ = fmt.Fprintf(w, "%s %s", p.method, pat.String()) }) }(p) } reqUrl := fmt.Sprintf("https://host.example%s", spec.reqPath) ctx := context.Background() r, err := http.NewRequestWithContext(ctx, spec.reqMethod, reqUrl, bytes.NewReader(nil)) if err != nil { t.Fatalf("http.NewRequest(%q, %q, nil) failed with %v; want success", spec.reqMethod, reqUrl, err) } for name, value := range spec.headers { r.Header.Set(name, value) } w := httptest.NewRecorder() mux.ServeHTTP(w, r) if got, want := w.Code, spec.respStatus; got != want { t.Errorf("w.Code = %d; want %d; patterns=%v; req=%v", got, want, spec.patterns, r) } if spec.respContent != "" { if got, want := w.Body.String(), spec.respContent; got != want { t.Errorf("w.Body = %q; want %q; patterns=%v; req=%v", got, want, spec.patterns, r) } } }) } } func TestServeHTTP_WithMethodOverrideAndFormParsing(t *testing.T) { r := httptest.NewRequest("POST", "/foo", strings.NewReader("bar=hoge")) r.Header.Set("Content-Type", "application/x-www-form-urlencoded") r.Header.Set("X-HTTP-Method-Override", "GET") w := httptest.NewRecorder() runtime.NewServeMux().ServeHTTP(w, r) if r.FormValue("bar") != "hoge" { t.Error("form is not parsed") } } var defaultHeaderMatcherTests = []struct { name string in string outValue string outValid bool }{ { "permanent HTTP header should return prefixed", "Accept", "grpcgateway-Accept", true, }, { "key prefixed with MetadataHeaderPrefix should return without the prefix", "Grpc-Metadata-Custom-Header", "Custom-Header", true, }, { "non-permanent HTTP header key without prefix should not return", "Custom-Header", "", false, }, } func TestDefaultHeaderMatcher(t *testing.T) { for _, tt := range defaultHeaderMatcherTests { t.Run(tt.name, func(t *testing.T) { out, valid := runtime.DefaultHeaderMatcher(tt.in) if out != tt.outValue { t.Errorf("got %v, want %v", out, tt.outValue) } if valid != tt.outValid { t.Errorf("got %v, want %v", valid, tt.outValid) } }) } } var defaultRouteMatcherTests = []struct { name string method string path string valid bool }{ { "Test route /", "GET", "/", true, }, { "Simple Endpoint", "GET", "/v1/{bucket}/do:action", true, }, { "Complex Endpoint", "POST", "/v1/b/{bucket_name=buckets/*}/o/{name}", true, }, { "Wildcard Endpoint", "GET", "/v1/endpoint/*", true, }, { "Invalid Endpoint", "POST", "v1/b/:name/do", false, }, } func TestServeMux_HandlePath(t *testing.T) { mux := runtime.NewServeMux() testFn := func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) { } for _, tt := range defaultRouteMatcherTests { t.Run(tt.name, func(t *testing.T) { err := mux.HandlePath(tt.method, tt.path, testFn) if tt.valid && err != nil { t.Errorf("The route %v with method %v and path %v invalid, got %v", tt.name, tt.method, tt.path, err) } if !tt.valid && err == nil { t.Errorf("The route %v with method %v and path %v should be invalid", tt.name, tt.method, tt.path) } }) } } var healthCheckTests = []struct { name string code codes.Code status grpc_health_v1.HealthCheckResponse_ServingStatus httpStatusCode int }{ { "Test grpc error code", codes.NotFound, grpc_health_v1.HealthCheckResponse_UNKNOWN, http.StatusNotFound, }, { "Test HealthCheckResponse_SERVING", codes.OK, grpc_health_v1.HealthCheckResponse_SERVING, http.StatusOK, }, { "Test HealthCheckResponse_NOT_SERVING", codes.OK, grpc_health_v1.HealthCheckResponse_NOT_SERVING, http.StatusServiceUnavailable, }, { "Test HealthCheckResponse_UNKNOWN", codes.OK, grpc_health_v1.HealthCheckResponse_UNKNOWN, http.StatusServiceUnavailable, }, { "Test HealthCheckResponse_SERVICE_UNKNOWN", codes.OK, grpc_health_v1.HealthCheckResponse_SERVICE_UNKNOWN, http.StatusNotFound, }, } func TestWithHealthzEndpoint_codes(t *testing.T) { for _, tt := range healthCheckTests { t.Run(tt.name, func(t *testing.T) { mux := runtime.NewServeMux(runtime.WithHealthzEndpoint(&dummyHealthCheckClient{status: tt.status, code: tt.code})) r := httptest.NewRequest(http.MethodGet, "/healthz", nil) rr := httptest.NewRecorder() mux.ServeHTTP(rr, r) if rr.Code != tt.httpStatusCode { t.Errorf( "result http status code for grpc code %q and status %q should be %d, got %d", tt.code, tt.status, tt.httpStatusCode, rr.Code, ) } }) } } func TestWithHealthEndpointAt_consistentWithHealthz(t *testing.T) { const endpointPath = "/healthz" r := httptest.NewRequest(http.MethodGet, endpointPath, nil) for _, tt := range healthCheckTests { tt := tt t.Run(tt.name, func(t *testing.T) { client := &dummyHealthCheckClient{ status: tt.status, code: tt.code, } w := httptest.NewRecorder() runtime.NewServeMux( runtime.WithHealthEndpointAt(client, endpointPath), ).ServeHTTP(w, r) refW := httptest.NewRecorder() runtime.NewServeMux( runtime.WithHealthzEndpoint(client), ).ServeHTTP(refW, r) if w.Code != refW.Code { t.Errorf( "result http status code for grpc code %q and status %q should be equal to %d, but got %d", tt.code, tt.status, refW.Code, w.Code, ) } }) } } func TestWithHealthzEndpoint_serviceParam(t *testing.T) { service := "test" // trigger error to output service in body dummyClient := dummyHealthCheckClient{status: grpc_health_v1.HealthCheckResponse_UNKNOWN, code: codes.Unknown} mux := runtime.NewServeMux(runtime.WithHealthzEndpoint(&dummyClient)) r := httptest.NewRequest(http.MethodGet, "/healthz?service="+service, nil) rr := httptest.NewRecorder() mux.ServeHTTP(rr, r) if !strings.Contains(rr.Body.String(), service) { t.Errorf( "service query parameter should be translated to HealthCheckRequest: expected %s to contain %s", rr.Body.String(), service, ) } } func TestWithHealthzEndpoint_header(t *testing.T) { for _, tt := range healthCheckTests { t.Run(tt.name, func(t *testing.T) { mux := runtime.NewServeMux(runtime.WithHealthzEndpoint(&dummyHealthCheckClient{status: tt.status, code: tt.code})) r := httptest.NewRequest(http.MethodGet, "/healthz", nil) rr := httptest.NewRecorder() mux.ServeHTTP(rr, r) if actualHeader := rr.Header().Get("Content-Type"); actualHeader != "application/json" { t.Errorf( "result http header Content-Type for grpc code %q and status %q should be application/json, got %s", tt.code, tt.status, actualHeader, ) } }) } } var _ grpc_health_v1.HealthClient = (*dummyHealthCheckClient)(nil) type dummyHealthCheckClient struct { status grpc_health_v1.HealthCheckResponse_ServingStatus code codes.Code } func (g *dummyHealthCheckClient) Check(ctx context.Context, r *grpc_health_v1.HealthCheckRequest, opts ...grpc.CallOption) (*grpc_health_v1.HealthCheckResponse, error) { if g.code != codes.OK { return nil, status.Error(g.code, r.GetService()) } return &grpc_health_v1.HealthCheckResponse{Status: g.status}, nil } func (g *dummyHealthCheckClient) Watch(ctx context.Context, r *grpc_health_v1.HealthCheckRequest, opts ...grpc.CallOption) (grpc_health_v1.Health_WatchClient, error) { return nil, status.Error(codes.Unimplemented, "unimplemented") } func (g *dummyHealthCheckClient) List(ctx context.Context, r *grpc_health_v1.HealthListRequest, opts ...grpc.CallOption) (*grpc_health_v1.HealthListResponse, error) { return nil, status.Error(codes.Unimplemented, "unimplemented") } func TestServeMux_HandleMiddlewares(t *testing.T) { var mws []int mux := runtime.NewServeMux(runtime.WithMiddlewares( func(next runtime.HandlerFunc) runtime.HandlerFunc { return func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) { mws = append(mws, 1) next(w, r, pathParams) } }, func(next runtime.HandlerFunc) runtime.HandlerFunc { return func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) { mws = append(mws, 2) next(w, r, pathParams) } }, )) err := mux.HandlePath("GET", "/test", func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) { if len(mws) == 0 { t.Errorf("middlewares not called") } else if mws[0] != 1 { t.Errorf("first middleware is not called first") } else if mws[1] != 2 { t.Errorf("second middleware is not called the second") } }) if err != nil { t.Errorf("The route test with method GET and path /test invalid, got %v", err) } r := httptest.NewRequest("GET", "/test", nil) w := httptest.NewRecorder() mux.ServeHTTP(w, r) if w.Code != 200 { t.Errorf("request not processed") } } func TestServeMux_InjectPattern(t *testing.T) { mux := runtime.NewServeMux() err := mux.HandlePath("GET", "/test", func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) { p, ok := runtime.HTTPPattern(r.Context()) if !ok { t.Errorf("pattern is not injected") } if p.String() != "/test" { t.Errorf("pattern not /test") } }) if err != nil { t.Errorf("The route test with method GET and path /test invalid, got %v", err) } r := httptest.NewRequest("GET", "/test", nil) w := httptest.NewRecorder() mux.ServeHTTP(w, r) if w.Code != 200 { t.Errorf("request not processed") } } func TestServeHTTP_WithDisableHTTPMethodOverride(t *testing.T) { // When WithDisableHTTPMethodOverride is set, X-HTTP-Method-Override // header should be ignored and the request should match the POST // handler directly. mux := runtime.NewServeMux(runtime.WithDisableHTTPMethodOverride()) pat, err := runtime.NewPattern(1, []int{int(utilities.OpLitPush), 0}, []string{"foo"}, "") if err != nil { t.Fatalf("runtime.NewPattern failed: %v", err) } mux.Handle("GET", pat, func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) { _, _ = fmt.Fprintf(w, "GET /foo") }) postPat, err := runtime.NewPattern(1, []int{int(utilities.OpLitPush), 0}, []string{"foo"}, "") if err != nil { t.Fatalf("runtime.NewPattern failed: %v", err) } mux.Handle("POST", postPat, func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) { _, _ = fmt.Fprintf(w, "POST /foo") }) r := httptest.NewRequest("POST", "https://host.example/foo", bytes.NewReader(nil)) r.Header.Set("Content-Type", "application/x-www-form-urlencoded") r.Header.Set("X-HTTP-Method-Override", "GET") w := httptest.NewRecorder() mux.ServeHTTP(w, r) if got, want := w.Code, http.StatusOK; got != want { t.Errorf("w.Code = %d; want %d", got, want) } if got, want := w.Body.String(), "POST /foo"; got != want { t.Errorf("w.Body = %q; want %q", got, want) } } ================================================ FILE: runtime/pattern.go ================================================ package runtime import ( "errors" "fmt" "strconv" "strings" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc/grpclog" ) var ( // ErrNotMatch indicates that the given HTTP request path does not match to the pattern. ErrNotMatch = errors.New("not match to the path pattern") // ErrInvalidPattern indicates that the given definition of Pattern is not valid. ErrInvalidPattern = errors.New("invalid pattern") ) type MalformedSequenceError string func (e MalformedSequenceError) Error() string { return "malformed path escape " + strconv.Quote(string(e)) } type op struct { code utilities.OpCode operand int } // Pattern is a template pattern of http request paths defined in // https://github.com/googleapis/googleapis/blob/master/google/api/http.proto type Pattern struct { // ops is a list of operations ops []op // pool is a constant pool indexed by the operands or vars. pool []string // vars is a list of variables names to be bound by this pattern vars []string // stacksize is the max depth of the stack stacksize int // tailLen is the length of the fixed-size segments after a deep wildcard tailLen int // verb is the VERB part of the path pattern. It is empty if the pattern does not have VERB part. verb string } // NewPattern returns a new Pattern from the given definition values. // "ops" is a sequence of op codes. "pool" is a constant pool. // "verb" is the verb part of the pattern. It is empty if the pattern does not have the part. // "version" must be 1 for now. // It returns an error if the given definition is invalid. func NewPattern(version int, ops []int, pool []string, verb string) (Pattern, error) { if version != 1 { grpclog.Errorf("unsupported version: %d", version) return Pattern{}, ErrInvalidPattern } l := len(ops) if l%2 != 0 { grpclog.Errorf("odd number of ops codes: %d", l) return Pattern{}, ErrInvalidPattern } var ( typedOps []op stack, maxstack int tailLen int pushMSeen bool vars []string ) for i := 0; i < l; i += 2 { op := op{code: utilities.OpCode(ops[i]), operand: ops[i+1]} switch op.code { case utilities.OpNop: continue case utilities.OpPush: if pushMSeen { tailLen++ } stack++ case utilities.OpPushM: if pushMSeen { grpclog.Error("pushM appears twice") return Pattern{}, ErrInvalidPattern } pushMSeen = true stack++ case utilities.OpLitPush: if op.operand < 0 || len(pool) <= op.operand { grpclog.Errorf("negative literal index: %d", op.operand) return Pattern{}, ErrInvalidPattern } if pushMSeen { tailLen++ } stack++ case utilities.OpConcatN: if op.operand <= 0 { grpclog.Errorf("negative concat size: %d", op.operand) return Pattern{}, ErrInvalidPattern } stack -= op.operand if stack < 0 { grpclog.Error("stack underflow") return Pattern{}, ErrInvalidPattern } stack++ case utilities.OpCapture: if op.operand < 0 || len(pool) <= op.operand { grpclog.Errorf("variable name index out of bound: %d", op.operand) return Pattern{}, ErrInvalidPattern } v := pool[op.operand] op.operand = len(vars) vars = append(vars, v) stack-- if stack < 0 { grpclog.Error("stack underflow") return Pattern{}, ErrInvalidPattern } default: grpclog.Errorf("invalid opcode: %d", op.code) return Pattern{}, ErrInvalidPattern } if maxstack < stack { maxstack = stack } typedOps = append(typedOps, op) } return Pattern{ ops: typedOps, pool: pool, vars: vars, stacksize: maxstack, tailLen: tailLen, verb: verb, }, nil } // MustPattern is a helper function which makes it easier to call NewPattern in variable initialization. func MustPattern(p Pattern, err error) Pattern { if err != nil { grpclog.Fatalf("Pattern initialization failed: %v", err) } return p } // MatchAndEscape examines components to determine if they match to a Pattern. // MatchAndEscape will return an error if no Patterns matched or if a pattern // matched but contained malformed escape sequences. If successful, the function // returns a mapping from field paths to their captured values. func (p Pattern) MatchAndEscape(components []string, verb string, unescapingMode UnescapingMode) (map[string]string, error) { if p.verb != verb { if p.verb != "" { return nil, ErrNotMatch } if len(components) == 0 { components = []string{":" + verb} } else { components = append([]string{}, components...) components[len(components)-1] += ":" + verb } } var pos int stack := make([]string, 0, p.stacksize) captured := make([]string, len(p.vars)) l := len(components) for _, op := range p.ops { var err error switch op.code { case utilities.OpNop: continue case utilities.OpPush, utilities.OpLitPush: if pos >= l { return nil, ErrNotMatch } c := components[pos] if op.code == utilities.OpLitPush { if lit := p.pool[op.operand]; c != lit { return nil, ErrNotMatch } } else if op.code == utilities.OpPush { if c, err = unescape(c, unescapingMode, false); err != nil { return nil, err } } stack = append(stack, c) pos++ case utilities.OpPushM: end := len(components) if end < pos+p.tailLen { return nil, ErrNotMatch } end -= p.tailLen c := strings.Join(components[pos:end], "/") if c, err = unescape(c, unescapingMode, true); err != nil { return nil, err } stack = append(stack, c) pos = end case utilities.OpConcatN: n := op.operand l := len(stack) - n stack = append(stack[:l], strings.Join(stack[l:], "/")) case utilities.OpCapture: n := len(stack) - 1 captured[op.operand] = stack[n] stack = stack[:n] } } if pos < l { return nil, ErrNotMatch } bindings := make(map[string]string) for i, val := range captured { bindings[p.vars[i]] = val } return bindings, nil } // MatchAndEscape examines components to determine if they match to a Pattern. // It will never perform per-component unescaping (see: UnescapingModeLegacy). // MatchAndEscape will return an error if no Patterns matched. If successful, // the function returns a mapping from field paths to their captured values. // // Deprecated: Use MatchAndEscape. func (p Pattern) Match(components []string, verb string) (map[string]string, error) { return p.MatchAndEscape(components, verb, UnescapingModeDefault) } // Verb returns the verb part of the Pattern. func (p Pattern) Verb() string { return p.verb } func (p Pattern) String() string { var stack []string for _, op := range p.ops { switch op.code { case utilities.OpNop: continue case utilities.OpPush: stack = append(stack, "*") case utilities.OpLitPush: stack = append(stack, p.pool[op.operand]) case utilities.OpPushM: stack = append(stack, "**") case utilities.OpConcatN: n := op.operand l := len(stack) - n stack = append(stack[:l], strings.Join(stack[l:], "/")) case utilities.OpCapture: n := len(stack) - 1 stack[n] = fmt.Sprintf("{%s=%s}", p.vars[op.operand], stack[n]) } } segs := strings.Join(stack, "/") if p.verb != "" { return fmt.Sprintf("/%s:%s", segs, p.verb) } return "/" + segs } /* * The following code is adopted and modified from Go's standard library * and carries the attached license. * * Copyright 2009 The Go Authors. All rights reserved. * Use of this source code is governed by a BSD-style * license that can be found in the LICENSE file. */ // ishex returns whether or not the given byte is a valid hex character func ishex(c byte) bool { switch { case '0' <= c && c <= '9': return true case 'a' <= c && c <= 'f': return true case 'A' <= c && c <= 'F': return true } return false } func isRFC6570Reserved(c byte) bool { switch c { case '!', '#', '$', '&', '\'', '(', ')', '*', '+', ',', '/', ':', ';', '=', '?', '@', '[', ']': return true default: return false } } // unhex converts a hex point to the bit representation func unhex(c byte) byte { switch { case '0' <= c && c <= '9': return c - '0' case 'a' <= c && c <= 'f': return c - 'a' + 10 case 'A' <= c && c <= 'F': return c - 'A' + 10 } return 0 } // shouldUnescapeWithMode returns true if the character is escapable with the // given mode func shouldUnescapeWithMode(c byte, mode UnescapingMode) bool { switch mode { case UnescapingModeAllExceptReserved: if isRFC6570Reserved(c) { return false } case UnescapingModeAllExceptSlash: if c == '/' { return false } case UnescapingModeAllCharacters: return true } return true } // unescape unescapes a path string using the provided mode func unescape(s string, mode UnescapingMode, multisegment bool) (string, error) { // TODO(v3): remove UnescapingModeLegacy if mode == UnescapingModeLegacy { return s, nil } if !multisegment { mode = UnescapingModeAllCharacters } // Count %, check that they're well-formed. n := 0 for i := 0; i < len(s); { if s[i] == '%' { n++ if i+2 >= len(s) || !ishex(s[i+1]) || !ishex(s[i+2]) { s = s[i:] if len(s) > 3 { s = s[:3] } return "", MalformedSequenceError(s) } i += 3 } else { i++ } } if n == 0 { return s, nil } var t strings.Builder t.Grow(len(s)) for i := 0; i < len(s); i++ { switch s[i] { case '%': c := unhex(s[i+1])<<4 | unhex(s[i+2]) if shouldUnescapeWithMode(c, mode) { t.WriteByte(c) i += 2 continue } fallthrough default: t.WriteByte(s[i]) } } return t.String(), nil } ================================================ FILE: runtime/pattern_test.go ================================================ package runtime import ( "errors" "fmt" "reflect" "strings" "testing" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" ) const ( validVersion = 1 anything = 0 ) func TestNewPattern(t *testing.T) { for _, spec := range []struct { ops []int pool []string verb string stackSizeWant, tailLenWant int }{ {}, { ops: []int{int(utilities.OpNop), anything}, stackSizeWant: 0, tailLenWant: 0, }, { ops: []int{int(utilities.OpPush), anything}, stackSizeWant: 1, tailLenWant: 0, }, { ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"abc"}, stackSizeWant: 1, tailLenWant: 0, }, { ops: []int{int(utilities.OpPushM), anything}, stackSizeWant: 1, tailLenWant: 0, }, { ops: []int{ int(utilities.OpPush), anything, int(utilities.OpConcatN), 1, }, stackSizeWant: 1, tailLenWant: 0, }, { ops: []int{ int(utilities.OpPush), anything, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 0, }, pool: []string{"abc"}, stackSizeWant: 1, tailLenWant: 0, }, { ops: []int{ int(utilities.OpPush), anything, int(utilities.OpLitPush), 0, int(utilities.OpLitPush), 1, int(utilities.OpPushM), anything, int(utilities.OpConcatN), 2, int(utilities.OpCapture), 2, }, pool: []string{"lit1", "lit2", "var1"}, stackSizeWant: 4, tailLenWant: 0, }, { ops: []int{ int(utilities.OpPushM), anything, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 2, int(utilities.OpLitPush), 0, int(utilities.OpLitPush), 1, }, pool: []string{"lit1", "lit2", "var1"}, stackSizeWant: 2, tailLenWant: 2, }, { ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpLitPush), 1, int(utilities.OpPushM), anything, int(utilities.OpLitPush), 2, int(utilities.OpConcatN), 3, int(utilities.OpLitPush), 3, int(utilities.OpCapture), 4, }, pool: []string{"lit1", "lit2", "lit3", "lit4", "var1"}, stackSizeWant: 4, tailLenWant: 2, }, { ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"abc"}, verb: "LOCK", stackSizeWant: 1, tailLenWant: 0, }, } { pat, err := NewPattern(validVersion, spec.ops, spec.pool, spec.verb) if err != nil { t.Errorf("NewPattern(%d, %v, %q, %q) failed with %v; want success", validVersion, spec.ops, spec.pool, spec.verb, err) continue } if got, want := pat.stacksize, spec.stackSizeWant; got != want { t.Errorf("pat.stacksize = %d; want %d", got, want) } if got, want := pat.tailLen, spec.tailLenWant; got != want { t.Errorf("pat.stacksize = %d; want %d", got, want) } } } func TestNewPatternWithWrongOp(t *testing.T) { for _, spec := range []struct { ops []int pool []string verb string }{ { // op code out of bound ops: []int{-1, anything}, }, { // op code out of bound ops: []int{int(utilities.OpEnd), 0}, }, { // odd number of items ops: []int{int(utilities.OpPush)}, }, { // negative index ops: []int{int(utilities.OpLitPush), -1}, pool: []string{"abc"}, }, { // index out of bound ops: []int{int(utilities.OpLitPush), 1}, pool: []string{"abc"}, }, { // negative # of segments ops: []int{int(utilities.OpConcatN), -1}, pool: []string{"abc"}, }, { // negative index ops: []int{int(utilities.OpCapture), -1}, pool: []string{"abc"}, }, { // index out of bound ops: []int{int(utilities.OpCapture), 1}, pool: []string{"abc"}, }, { // pushM appears twice ops: []int{ int(utilities.OpPushM), anything, int(utilities.OpLitPush), 0, int(utilities.OpPushM), anything, }, pool: []string{"abc"}, }, } { _, err := NewPattern(validVersion, spec.ops, spec.pool, spec.verb) if err == nil { t.Errorf("NewPattern(%d, %v, %q, %q) succeeded; want failure with %v", validVersion, spec.ops, spec.pool, spec.verb, ErrInvalidPattern) continue } if !errors.Is(err, ErrInvalidPattern) { t.Errorf("NewPattern(%d, %v, %q, %q) failed with %v; want failure with %v", validVersion, spec.ops, spec.pool, spec.verb, err, ErrInvalidPattern) continue } } } func TestNewPatternWithStackUnderflow(t *testing.T) { for _, spec := range []struct { ops []int pool []string verb string }{ { ops: []int{int(utilities.OpConcatN), 1}, }, { ops: []int{int(utilities.OpCapture), 0}, pool: []string{"abc"}, }, } { _, err := NewPattern(validVersion, spec.ops, spec.pool, spec.verb) if err == nil { t.Errorf("NewPattern(%d, %v, %q, %q) succeeded; want failure with %v", validVersion, spec.ops, spec.pool, spec.verb, ErrInvalidPattern) continue } if !errors.Is(err, ErrInvalidPattern) { t.Errorf("NewPattern(%d, %v, %q, %q) failed with %v; want failure with %v", validVersion, spec.ops, spec.pool, spec.verb, err, ErrInvalidPattern) continue } } } func TestMatch(t *testing.T) { for _, spec := range []struct { ops []int pool []string verb string match []string notMatch []string }{ { match: []string{""}, notMatch: []string{"example"}, }, { ops: []int{int(utilities.OpNop), anything}, match: []string{""}, notMatch: []string{"example", "path/to/example"}, }, { ops: []int{int(utilities.OpPush), anything}, match: []string{"abc", "def"}, notMatch: []string{"", "abc/def"}, }, { ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"v1"}, match: []string{"v1"}, notMatch: []string{"", "v2"}, }, { ops: []int{int(utilities.OpPushM), anything}, match: []string{"", "abc", "abc/def", "abc/def/ghi"}, }, { ops: []int{ int(utilities.OpPushM), anything, int(utilities.OpLitPush), 0, }, pool: []string{"tail"}, match: []string{"tail", "abc/tail", "abc/def/tail"}, notMatch: []string{ "", "abc", "abc/def", "tail/extra", "abc/tail/extra", "abc/def/tail/extra", }, }, { ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpLitPush), 1, int(utilities.OpPush), anything, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 2, }, pool: []string{"v1", "bucket", "name"}, match: []string{"v1/bucket/my-bucket", "v1/bucket/our-bucket"}, notMatch: []string{ "", "v1", "v1/bucket", "v2/bucket/my-bucket", "v1/pubsub/my-topic", }, }, { ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpLitPush), 1, int(utilities.OpPushM), anything, int(utilities.OpConcatN), 2, int(utilities.OpCapture), 2, }, pool: []string{"v1", "o", "name"}, match: []string{ "v1/o", "v1/o/my-bucket", "v1/o/our-bucket", "v1/o/my-bucket/dir", "v1/o/my-bucket/dir/dir2", "v1/o/my-bucket/dir/dir2/obj", }, notMatch: []string{ "", "v1", "v2/o/my-bucket", "v1/b/my-bucket", }, }, { ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpLitPush), 1, int(utilities.OpPush), anything, int(utilities.OpConcatN), 2, int(utilities.OpCapture), 2, int(utilities.OpLitPush), 3, int(utilities.OpPush), anything, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 4, }, pool: []string{"v2", "b", "name", "o", "oname"}, match: []string{ "v2/b/my-bucket/o/obj", "v2/b/our-bucket/o/obj", "v2/b/my-bucket/o/dir", }, notMatch: []string{ "", "v2", "v2/b", "v2/b/my-bucket", "v2/b/my-bucket/o", }, }, { ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"v1"}, verb: "LOCK", match: []string{"v1:LOCK"}, notMatch: []string{"v1", "LOCK"}, }, } { pat, err := NewPattern(validVersion, spec.ops, spec.pool, spec.verb) if err != nil { t.Errorf("NewPattern(%d, %v, %q, %q) failed with %v; want success", validVersion, spec.ops, spec.pool, spec.verb, err) continue } for _, path := range spec.match { _, err = pat.Match(segments(path)) if err != nil { t.Errorf("pat.Match(%q) failed with %v; want success; pattern = (%v, %q)", path, err, spec.ops, spec.pool) } } for _, path := range spec.notMatch { _, err = pat.Match(segments(path)) if err == nil { t.Errorf("pat.Match(%q) succeeded; want failure with %v; pattern = (%v, %q)", path, ErrNotMatch, spec.ops, spec.pool) continue } if !errors.Is(err, ErrNotMatch) { t.Errorf("pat.Match(%q) failed with %v; want failure with %v; pattern = (%v, %q)", spec.notMatch, err, ErrNotMatch, spec.ops, spec.pool) } } } } func TestMatchWithBinding(t *testing.T) { for _, spec := range []struct { ops []int pool []string path string verb string mode UnescapingMode want map[string]string }{ { want: make(map[string]string), }, { ops: []int{int(utilities.OpNop), anything}, want: make(map[string]string), }, { ops: []int{int(utilities.OpPush), anything}, path: "abc", want: make(map[string]string), }, { ops: []int{int(utilities.OpPush), anything}, verb: "LOCK", path: "abc:LOCK", want: make(map[string]string), }, { ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"endpoint"}, path: "endpoint", want: make(map[string]string), }, { ops: []int{int(utilities.OpPushM), anything}, path: "abc/def/ghi", want: make(map[string]string), }, { ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpLitPush), 1, int(utilities.OpPush), anything, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 2, }, pool: []string{"v1", "bucket", "name"}, path: "v1/bucket/my-bucket", want: map[string]string{ "name": "my-bucket", }, }, { ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpLitPush), 1, int(utilities.OpPush), anything, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 2, }, pool: []string{"v1", "bucket", "name"}, verb: "LOCK", path: "v1/bucket/my-bucket:LOCK", want: map[string]string{ "name": "my-bucket", }, }, { ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpLitPush), 1, int(utilities.OpPushM), anything, int(utilities.OpConcatN), 2, int(utilities.OpCapture), 2, }, pool: []string{"v1", "o", "name"}, path: "v1/o/my-bucket/dir/dir2/obj", want: map[string]string{ "name": "o/my-bucket/dir/dir2/obj", }, }, { ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpLitPush), 1, int(utilities.OpPushM), anything, int(utilities.OpLitPush), 2, int(utilities.OpConcatN), 3, int(utilities.OpCapture), 4, int(utilities.OpLitPush), 3, }, pool: []string{"v1", "o", ".ext", "tail", "name"}, path: "v1/o/my-bucket/dir/dir2/obj/.ext/tail", want: map[string]string{ "name": "o/my-bucket/dir/dir2/obj/.ext", }, }, { ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpLitPush), 1, int(utilities.OpPush), anything, int(utilities.OpConcatN), 2, int(utilities.OpCapture), 2, int(utilities.OpLitPush), 3, int(utilities.OpPush), anything, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 4, }, pool: []string{"v2", "b", "name", "o", "oname"}, path: "v2/b/my-bucket/o/obj", want: map[string]string{ "name": "b/my-bucket", "oname": "obj", }, }, { ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpPush), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1, int(utilities.OpLitPush), 2, }, pool: []string{"foo", "id", "bar"}, path: "foo/part1%2Fpart2/bar", want: map[string]string{ "id": "part1/part2", }, mode: UnescapingModeAllExceptReserved, }, { ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpPushM), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1, }, pool: []string{"foo", "id"}, path: "foo/test%2Fbar", want: map[string]string{ "id": "test%2Fbar", }, mode: UnescapingModeAllExceptReserved, }, { ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpPushM), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1, }, pool: []string{"foo", "id"}, path: "foo/test%2Fbar", want: map[string]string{ "id": "test/bar", }, mode: UnescapingModeAllCharacters, }, } { pat, err := NewPattern(validVersion, spec.ops, spec.pool, spec.verb) if err != nil { t.Errorf("NewPattern(%d, %v, %q, %q) failed with %v; want success", validVersion, spec.ops, spec.pool, spec.verb, err) continue } components, verb := segments(spec.path) got, err := pat.MatchAndEscape(components, verb, spec.mode) if err != nil { t.Errorf("pat.Match(%q) failed with %v; want success; pattern = (%v, %q)", spec.path, err, spec.ops, spec.pool) } if !reflect.DeepEqual(got, spec.want) { t.Errorf("pat.Match(%q) = %q; want %q; pattern = (%v, %q)", spec.path, got, spec.want, spec.ops, spec.pool) } } } func segments(path string) (components []string, verb string) { if path == "" { return nil, "" } components = strings.Split(path, "/") l := len(components) c := components[l-1] if idx := strings.LastIndex(c, ":"); idx >= 0 { components[l-1], verb = c[:idx], c[idx+1:] } return components, verb } func TestPatternString(t *testing.T) { for _, spec := range []struct { ops []int pool []string want string }{ { want: "/", }, { ops: []int{int(utilities.OpNop), anything}, want: "/", }, { ops: []int{int(utilities.OpPush), anything}, want: "/*", }, { ops: []int{int(utilities.OpLitPush), 0}, pool: []string{"endpoint"}, want: "/endpoint", }, { ops: []int{int(utilities.OpPushM), anything}, want: "/**", }, { ops: []int{ int(utilities.OpPush), anything, int(utilities.OpConcatN), 1, }, want: "/*", }, { ops: []int{ int(utilities.OpPush), anything, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 0, }, pool: []string{"name"}, want: "/{name=*}", }, { ops: []int{ int(utilities.OpLitPush), 0, int(utilities.OpLitPush), 1, int(utilities.OpPush), anything, int(utilities.OpConcatN), 2, int(utilities.OpCapture), 2, int(utilities.OpLitPush), 3, int(utilities.OpPushM), anything, int(utilities.OpLitPush), 4, int(utilities.OpConcatN), 3, int(utilities.OpCapture), 6, int(utilities.OpLitPush), 5, }, pool: []string{"v1", "buckets", "bucket_name", "objects", ".ext", "tail", "name"}, want: "/v1/{bucket_name=buckets/*}/{name=objects/**/.ext}/tail", }, } { p, err := NewPattern(validVersion, spec.ops, spec.pool, "") if err != nil { t.Errorf("NewPattern(%d, %v, %q, %q) failed with %v; want success", validVersion, spec.ops, spec.pool, "", err) continue } if got, want := p.String(), spec.want; got != want { t.Errorf("%#v.String() = %q; want %q", p, got, want) } verb := "LOCK" p, err = NewPattern(validVersion, spec.ops, spec.pool, verb) if err != nil { t.Errorf("NewPattern(%d, %v, %q, %q) failed with %v; want success", validVersion, spec.ops, spec.pool, verb, err) continue } if got, want := p.String(), fmt.Sprintf("%s:%s", spec.want, verb); got != want { t.Errorf("%#v.String() = %q; want %q", p, got, want) } } } ================================================ FILE: runtime/proto2_convert.go ================================================ package runtime import ( "google.golang.org/protobuf/proto" ) // StringP returns a pointer to a string whose pointee is same as the given string value. func StringP(val string) (*string, error) { return proto.String(val), nil } // BoolP parses the given string representation of a boolean value, // and returns a pointer to a bool whose value is same as the parsed value. func BoolP(val string) (*bool, error) { b, err := Bool(val) if err != nil { return nil, err } return proto.Bool(b), nil } // Float64P parses the given string representation of a floating point number, // and returns a pointer to a float64 whose value is same as the parsed number. func Float64P(val string) (*float64, error) { f, err := Float64(val) if err != nil { return nil, err } return proto.Float64(f), nil } // Float32P parses the given string representation of a floating point number, // and returns a pointer to a float32 whose value is same as the parsed number. func Float32P(val string) (*float32, error) { f, err := Float32(val) if err != nil { return nil, err } return proto.Float32(f), nil } // Int64P parses the given string representation of an integer // and returns a pointer to an int64 whose value is same as the parsed integer. func Int64P(val string) (*int64, error) { i, err := Int64(val) if err != nil { return nil, err } return proto.Int64(i), nil } // Int32P parses the given string representation of an integer // and returns a pointer to an int32 whose value is same as the parsed integer. func Int32P(val string) (*int32, error) { i, err := Int32(val) if err != nil { return nil, err } return proto.Int32(i), err } // Uint64P parses the given string representation of an integer // and returns a pointer to a uint64 whose value is same as the parsed integer. func Uint64P(val string) (*uint64, error) { i, err := Uint64(val) if err != nil { return nil, err } return proto.Uint64(i), err } // Uint32P parses the given string representation of an integer // and returns a pointer to a uint32 whose value is same as the parsed integer. func Uint32P(val string) (*uint32, error) { i, err := Uint32(val) if err != nil { return nil, err } return proto.Uint32(i), err } ================================================ FILE: runtime/query.go ================================================ package runtime import ( "errors" "fmt" "net/url" "regexp" "strconv" "strings" "time" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/grpc/grpclog" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/reflect/protoregistry" "google.golang.org/protobuf/types/known/durationpb" field_mask "google.golang.org/protobuf/types/known/fieldmaskpb" "google.golang.org/protobuf/types/known/structpb" "google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/wrapperspb" ) var valuesKeyRegexp = regexp.MustCompile(`^(.*)\[(.*)\]$`) var currentQueryParser QueryParameterParser = &DefaultQueryParser{} // QueryParameterParser defines interface for all query parameter parsers type QueryParameterParser interface { Parse(msg proto.Message, values url.Values, filter *utilities.DoubleArray) error } // PopulateQueryParameters parses query parameters // into "msg" using current query parser func PopulateQueryParameters(msg proto.Message, values url.Values, filter *utilities.DoubleArray) error { return currentQueryParser.Parse(msg, values, filter) } // DefaultQueryParser is a QueryParameterParser which implements the default // query parameters parsing behavior. // // See https://github.com/grpc-ecosystem/grpc-gateway/issues/2632 for more context. type DefaultQueryParser struct{} // Parse populates "values" into "msg". // A value is ignored if its key starts with one of the elements in "filter". func (*DefaultQueryParser) Parse(msg proto.Message, values url.Values, filter *utilities.DoubleArray) error { for key, values := range values { if match := valuesKeyRegexp.FindStringSubmatch(key); len(match) == 3 { key = match[1] values = append([]string{match[2]}, values...) } msgValue := msg.ProtoReflect() fieldPath := normalizeFieldPath(msgValue, strings.Split(key, ".")) if filter.HasCommonPrefix(fieldPath) { continue } if err := populateFieldValueFromPath(msgValue, fieldPath, values); err != nil { return err } } return nil } // PopulateFieldFromPath sets a value in a nested Protobuf structure. func PopulateFieldFromPath(msg proto.Message, fieldPathString string, value string) error { fieldPath := strings.Split(fieldPathString, ".") return populateFieldValueFromPath(msg.ProtoReflect(), fieldPath, []string{value}) } func normalizeFieldPath(msgValue protoreflect.Message, fieldPath []string) []string { newFieldPath := make([]string, 0, len(fieldPath)) for i, fieldName := range fieldPath { fields := msgValue.Descriptor().Fields() fieldDesc := fields.ByTextName(fieldName) if fieldDesc == nil { fieldDesc = fields.ByJSONName(fieldName) } if fieldDesc == nil { // return initial field path values if no matching message field was found return fieldPath } newFieldPath = append(newFieldPath, string(fieldDesc.Name())) // If this is the last element, we're done if i == len(fieldPath)-1 { break } // Only singular message fields are allowed if fieldDesc.Message() == nil || fieldDesc.Cardinality() == protoreflect.Repeated { return fieldPath } // Get the nested message msgValue = msgValue.Get(fieldDesc).Message() } return newFieldPath } func populateFieldValueFromPath(msgValue protoreflect.Message, fieldPath []string, values []string) error { if len(fieldPath) < 1 { return errors.New("no field path") } if len(values) < 1 { return errors.New("no value provided") } var fieldDescriptor protoreflect.FieldDescriptor for i, fieldName := range fieldPath { fields := msgValue.Descriptor().Fields() // Get field by name fieldDescriptor = fields.ByName(protoreflect.Name(fieldName)) if fieldDescriptor == nil { fieldDescriptor = fields.ByJSONName(fieldName) if fieldDescriptor == nil { // We're not returning an error here because this could just be // an extra query parameter that isn't part of the request. grpclog.Infof("field not found in %q: %q", msgValue.Descriptor().FullName(), strings.Join(fieldPath, ".")) return nil } } // Check if oneof already set if of := fieldDescriptor.ContainingOneof(); of != nil && !of.IsSynthetic() { if f := msgValue.WhichOneof(of); f != nil { if fieldDescriptor.Message() == nil || fieldDescriptor.FullName() != f.FullName() { return fmt.Errorf("field already set for oneof %q", of.FullName().Name()) } } } // If this is the last element, we're done if i == len(fieldPath)-1 { break } // Only singular message fields are allowed if fieldDescriptor.Message() == nil || fieldDescriptor.Cardinality() == protoreflect.Repeated { return fmt.Errorf("invalid path: %q is not a message", fieldName) } // Get the nested message msgValue = msgValue.Mutable(fieldDescriptor).Message() } switch { case fieldDescriptor.IsList(): return populateRepeatedField(fieldDescriptor, msgValue.Mutable(fieldDescriptor).List(), values) case fieldDescriptor.IsMap(): return populateMapField(fieldDescriptor, msgValue.Mutable(fieldDescriptor).Map(), values) } if len(values) > 1 { return fmt.Errorf("too many values for field %q: %s", fieldDescriptor.FullName().Name(), strings.Join(values, ", ")) } return populateField(fieldDescriptor, msgValue, values[0]) } func populateField(fieldDescriptor protoreflect.FieldDescriptor, msgValue protoreflect.Message, value string) error { v, err := parseField(fieldDescriptor, value) if err != nil { return fmt.Errorf("parsing field %q: %w", fieldDescriptor.FullName().Name(), err) } msgValue.Set(fieldDescriptor, v) return nil } func populateRepeatedField(fieldDescriptor protoreflect.FieldDescriptor, list protoreflect.List, values []string) error { for _, value := range values { v, err := parseField(fieldDescriptor, value) if err != nil { return fmt.Errorf("parsing list %q: %w", fieldDescriptor.FullName().Name(), err) } list.Append(v) } return nil } func populateMapField(fieldDescriptor protoreflect.FieldDescriptor, mp protoreflect.Map, values []string) error { if len(values) != 2 { return fmt.Errorf("more than one value provided for key %q in map %q", values[0], fieldDescriptor.FullName()) } key, err := parseField(fieldDescriptor.MapKey(), values[0]) if err != nil { return fmt.Errorf("parsing map key %q: %w", fieldDescriptor.FullName().Name(), err) } value, err := parseField(fieldDescriptor.MapValue(), values[1]) if err != nil { return fmt.Errorf("parsing map value %q: %w", fieldDescriptor.FullName().Name(), err) } mp.Set(key.MapKey(), value) return nil } func parseField(fieldDescriptor protoreflect.FieldDescriptor, value string) (protoreflect.Value, error) { switch fieldDescriptor.Kind() { case protoreflect.BoolKind: v, err := strconv.ParseBool(value) if err != nil { return protoreflect.Value{}, err } return protoreflect.ValueOfBool(v), nil case protoreflect.EnumKind: enum, err := protoregistry.GlobalTypes.FindEnumByName(fieldDescriptor.Enum().FullName()) if err != nil { if errors.Is(err, protoregistry.NotFound) { return protoreflect.Value{}, fmt.Errorf("enum %q is not registered", fieldDescriptor.Enum().FullName()) } return protoreflect.Value{}, fmt.Errorf("failed to look up enum: %w", err) } // Look for enum by name v := enum.Descriptor().Values().ByName(protoreflect.Name(value)) if v == nil { i, err := strconv.Atoi(value) if err != nil { return protoreflect.Value{}, fmt.Errorf("%q is not a valid value", value) } // Look for enum by number if v = enum.Descriptor().Values().ByNumber(protoreflect.EnumNumber(i)); v == nil { return protoreflect.Value{}, fmt.Errorf("%q is not a valid value", value) } } return protoreflect.ValueOfEnum(v.Number()), nil case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind: v, err := strconv.ParseInt(value, 10, 32) if err != nil { return protoreflect.Value{}, err } return protoreflect.ValueOfInt32(int32(v)), nil case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind: v, err := strconv.ParseInt(value, 10, 64) if err != nil { return protoreflect.Value{}, err } return protoreflect.ValueOfInt64(v), nil case protoreflect.Uint32Kind, protoreflect.Fixed32Kind: v, err := strconv.ParseUint(value, 10, 32) if err != nil { return protoreflect.Value{}, err } return protoreflect.ValueOfUint32(uint32(v)), nil case protoreflect.Uint64Kind, protoreflect.Fixed64Kind: v, err := strconv.ParseUint(value, 10, 64) if err != nil { return protoreflect.Value{}, err } return protoreflect.ValueOfUint64(v), nil case protoreflect.FloatKind: v, err := strconv.ParseFloat(value, 32) if err != nil { return protoreflect.Value{}, err } return protoreflect.ValueOfFloat32(float32(v)), nil case protoreflect.DoubleKind: v, err := strconv.ParseFloat(value, 64) if err != nil { return protoreflect.Value{}, err } return protoreflect.ValueOfFloat64(v), nil case protoreflect.StringKind: return protoreflect.ValueOfString(value), nil case protoreflect.BytesKind: v, err := Bytes(value) if err != nil { return protoreflect.Value{}, err } return protoreflect.ValueOfBytes(v), nil case protoreflect.MessageKind, protoreflect.GroupKind: return parseMessage(fieldDescriptor.Message(), value) default: panic(fmt.Sprintf("unknown field kind: %v", fieldDescriptor.Kind())) } } func parseMessage(msgDescriptor protoreflect.MessageDescriptor, value string) (protoreflect.Value, error) { var msg proto.Message switch msgDescriptor.FullName() { case "google.protobuf.Timestamp": t, err := time.Parse(time.RFC3339Nano, value) if err != nil { return protoreflect.Value{}, err } timestamp := timestamppb.New(t) if ok := timestamp.IsValid(); !ok { return protoreflect.Value{}, fmt.Errorf("%s before 0001-01-01", value) } msg = timestamp case "google.protobuf.Duration": d, err := time.ParseDuration(value) if err != nil { return protoreflect.Value{}, err } msg = durationpb.New(d) case "google.protobuf.DoubleValue": v, err := strconv.ParseFloat(value, 64) if err != nil { return protoreflect.Value{}, err } msg = wrapperspb.Double(v) case "google.protobuf.FloatValue": v, err := strconv.ParseFloat(value, 32) if err != nil { return protoreflect.Value{}, err } msg = wrapperspb.Float(float32(v)) case "google.protobuf.Int64Value": v, err := strconv.ParseInt(value, 10, 64) if err != nil { return protoreflect.Value{}, err } msg = wrapperspb.Int64(v) case "google.protobuf.Int32Value": v, err := strconv.ParseInt(value, 10, 32) if err != nil { return protoreflect.Value{}, err } msg = wrapperspb.Int32(int32(v)) case "google.protobuf.UInt64Value": v, err := strconv.ParseUint(value, 10, 64) if err != nil { return protoreflect.Value{}, err } msg = wrapperspb.UInt64(v) case "google.protobuf.UInt32Value": v, err := strconv.ParseUint(value, 10, 32) if err != nil { return protoreflect.Value{}, err } msg = wrapperspb.UInt32(uint32(v)) case "google.protobuf.BoolValue": v, err := strconv.ParseBool(value) if err != nil { return protoreflect.Value{}, err } msg = wrapperspb.Bool(v) case "google.protobuf.StringValue": msg = wrapperspb.String(value) case "google.protobuf.BytesValue": v, err := Bytes(value) if err != nil { return protoreflect.Value{}, err } msg = wrapperspb.Bytes(v) case "google.protobuf.FieldMask": fm := &field_mask.FieldMask{} fm.Paths = append(fm.Paths, strings.Split(value, ",")...) msg = fm case "google.protobuf.Value": var v structpb.Value if err := protojson.Unmarshal([]byte(value), &v); err != nil { return protoreflect.Value{}, err } msg = &v case "google.protobuf.Struct": var v structpb.Struct if err := protojson.Unmarshal([]byte(value), &v); err != nil { return protoreflect.Value{}, err } msg = &v default: return protoreflect.Value{}, fmt.Errorf("unsupported message type: %q", string(msgDescriptor.FullName())) } return protoreflect.ValueOfMessage(msg.ProtoReflect()), nil } ================================================ FILE: runtime/query_fuzz_test.go ================================================ //go:build go1.18 // +build go1.18 package runtime_test import ( "net/url" "testing" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime/internal/examplepb" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" ) func FuzzPopulateQueryParameters(f *testing.F) { f.Add("bool_value=true&bytes_value=YWJjMTIzIT8kKiYoKSctPUB-&double_value=2.5&duration_value=13h0m0s&enum_value=1&fieldmask_value=float_value%2Cdouble_value&float_value=1.5&int32_value=-2&int64_value=-1&map_value10%5Bkey%5D=1.5&map_value11%5B1.5%5D=value&map_value12%5Bkey%5D=2.5&map_value13%5B2.5%5D=value&map_value14%5Bkey%5D=true&map_value15%5Btrue%5D=value&map_value16%5Bkey%5D=2&map_value2%5Bkey%5D=-2&map_value3%5B-2%5D=value&map_value4%5Bkey%5D=-1&map_value5%5B-1%5D=value&map_value6%5Bkey%5D=3&map_value7%5B3%5D=value&map_value8%5Bkey%5D=4&map_value9%5B4%5D=value&map_value%5Bfourth%5D=&map_value%5Bkey%5D=value&map_value%5Bsecond%5D=bar&map_value%5Bthird%5D=zzz&map_value%5B~%21%40%23%24%25%5E%26%2A%28%29%5D=value&repeated_enum=1&repeated_enum=2&repeated_enum=0&repeated_message=1&repeated_message=2&repeated_message=3&repeated_value=a&repeated_value=b&repeated_value=c&string_value=str&struct_value=%7B%22a%22%3A%7B%22b%22%3A1%7D%7D&struct_value_value=%7B%22a%22%3A%7B%22b%22%3A1%7D%7D×tamp_value=2016-12-15T12%3A23%3A32.000000049Z&uint32_value=4&uint64_value=3&wrapper_bool_value=true&wrapper_bytes_value=YWJjMTIzIT8kKiYoKSctPUB-&wrapper_double_value=2.5&wrapper_float_value=1.5&wrapper_int32_value=-2&wrapper_int64_value=-1&wrapper_string_value=str&wrapper_u_int32_value=4&wrapper_u_int64_value=3") f.Add("boolValue=true&bytesValue=Ynl0ZXM%3D&doubleValue=2.5&durationValue=13h0m0s&enumValue=1&fieldmaskValue=float_value%2Cdouble_value&floatValue=1.5&int32Value=-2&int64Value=-1&repeatedEnum=1&repeatedEnum=2&repeatedEnum=0&repeatedValue=a&repeatedValue=b&repeatedValue=c&stringValue=str&struct_value=%7B%7D&struct_value_value=%22%22×tampValue=2016-12-15T12%3A23%3A32.000000049Z&uint32Value=4&uint64Value=3&wrapperBoolValue=true&wrapperBytesValue=Ynl0ZXM%3D&wrapperDoubleValue=2.5&wrapperFloatValue=1.5&wrapperInt32Value=-2&wrapperInt64Value=-1&wrapperStringValue=str&wrapperUInt32Value=4&wrapperUInt64Value=3") f.Add("enum_value=Z&repeated_enum=X&repeated_enum=2&repeated_enum=0&struct_value=%7B%22c%22%3A%5B1%2C2%5D%2C%22d%22%3A%5B%7B%22e%22%3A1%2C%22f%22%3A%7B%7D%7D%5D%7D&struct_value_value=%7B%7D") f.Add("struct_value_value=%5B%5D") f.Add("bool_value=true&double_value=2.5&float_value=1.5&int32_value=-2&int64_value=-1&repeated_value=a&repeated_value=b&repeated_value=c&string_value=str&uint32_value=4&uint64_value=3") f.Add("boolValue=true&doubleValue=2.5&floatValue=1.5&int32Value=-2&int64Value=-1&repeatedValue=a&repeatedValue=b&repeatedValue=c&stringValue=str&uint32Value=4&uint64Value=") f.Add("nested.nested.map_value%5Bfirst%5D=foo&nested.nested.map_value%5Bsecond%5D=bar&nested.nested.nested.repeated_value=a&nested.nested.nested.repeated_value=b&nested.nested.nested.repeated_value=c&nested.nested.nested.string_value=s&nested.nested.string_value=t&nested.string_value=u") f.Add("oneof_string_value=foobar") f.Add("nested_oneof_value_one.int64Value=-1&nested_oneof_value_one.string_value=foo") f.Fuzz(func(t *testing.T, query string) { in := &examplepb.ABitOfEverything{} values, err := url.ParseQuery(query) if err != nil { return } err = runtime.PopulateQueryParameters(in, values, utilities.NewDoubleArray(nil)) if err != nil { return } }) } ================================================ FILE: runtime/query_test.go ================================================ package runtime_test import ( "errors" "net/url" "strconv" "testing" "time" "github.com/google/go-cmp/cmp" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime/internal/examplepb" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/testing/protocmp" "google.golang.org/protobuf/types/known/durationpb" field_mask "google.golang.org/protobuf/types/known/fieldmaskpb" "google.golang.org/protobuf/types/known/structpb" "google.golang.org/protobuf/types/known/timestamppb" "google.golang.org/protobuf/types/known/wrapperspb" ) func BenchmarkPopulateQueryParameters(b *testing.B) { timeT := time.Date(2016, time.December, 15, 12, 23, 32, 49, time.UTC) timeStr := timeT.Format(time.RFC3339Nano) durationT := 13 * time.Hour durationStr := durationT.String() fieldmaskStr := "float_value,double_value" msg := &examplepb.Proto3Message{} values := url.Values{ "float_value": {"1.5"}, "double_value": {"2.5"}, "int64_value": {"-1"}, "int32_value": {"-2"}, "uint64_value": {"3"}, "uint32_value": {"4"}, "bool_value": {"true"}, "string_value": {"str"}, "bytes_value": {"Ynl0ZXM="}, "repeated_value": {"a", "b", "c"}, "enum_value": {"1"}, "repeated_enum": {"1", "2", "0"}, "timestamp_value": {timeStr}, "duration_value": {durationStr}, "fieldmask_value": {fieldmaskStr}, "optional_string_value": {"optional-str"}, "wrapper_float_value": {"1.5"}, "wrapper_double_value": {"2.5"}, "wrapper_int64_value": {"-1"}, "wrapper_int32_value": {"-2"}, "wrapper_u_int64_value": {"3"}, "wrapper_u_int32_value": {"4"}, "wrapper_bool_value": {"true"}, "wrapper_string_value": {"str"}, "wrapper_bytes_value": {"Ynl0ZXM="}, "map_value[key]": {"value"}, "map_value[second]": {"bar"}, "map_value[third]": {"zzz"}, "map_value[fourth]": {""}, `map_value[~!@#$%^&*()]`: {"value"}, "map_value2[key]": {"-2"}, "map_value3[-2]": {"value"}, "map_value4[key]": {"-1"}, "map_value5[-1]": {"value"}, "map_value6[key]": {"3"}, "map_value7[3]": {"value"}, "map_value8[key]": {"4"}, "map_value9[4]": {"value"}, "map_value10[key]": {"1.5"}, "map_value11[1.5]": {"value"}, "map_value12[key]": {"2.5"}, "map_value13[2.5]": {"value"}, "map_value14[key]": {"true"}, "map_value15[true]": {"value"}, } filter := utilities.NewDoubleArray([][]string{ {"bool_value"}, {"repeated_value"}, }) for i := 0; i < b.N; i++ { _ = runtime.PopulateQueryParameters(msg, values, filter) } } func TestPopulateParameters(t *testing.T) { timeT := time.Date(2016, time.December, 15, 12, 23, 32, 49, time.UTC) timeStr := timeT.Format(time.RFC3339Nano) timePb := timestamppb.New(timeT) durationT := 13 * time.Hour durationStr := durationT.String() durationPb := durationpb.New(durationT) optionalStr := "str" fieldmaskStr := "float_value,double_value" fieldmaskPb := &field_mask.FieldMask{Paths: []string{"float_value", "double_value"}} structValueJsonStrings := []string{`{"a":{"b":1}}`, `""`, "{}", "[]", "true", "0"} structValueValues := make([]*structpb.Value, len(structValueJsonStrings)) for i := range structValueValues { structValueValues[i] = &structpb.Value{} err := structValueValues[i].UnmarshalJSON([]byte(structValueJsonStrings[i])) if err != nil { t.Errorf("build struct.Value value failed: %s", err.Error()) } } structJsonStrings := []string{`{"a":{"b":1}}`, "{}", `{"c":[1,2],"d":[{"e":1,"f":{}}]}`} structValues := make([]*structpb.Struct, len(structJsonStrings)) for i := range structValues { structValues[i] = &structpb.Struct{} err := structValues[i].UnmarshalJSON([]byte(structJsonStrings[i])) if err != nil { t.Errorf("build struct.Struct value failed: %s", err.Error()) } } for i, spec := range []struct { values url.Values filter *utilities.DoubleArray want proto.Message wanterr error }{ { values: url.Values{ "float_value": {"1.5"}, "double_value": {"2.5"}, "int64_value": {"-1"}, "int32_value": {"-2"}, "uint64_value": {"3"}, "uint32_value": {"4"}, "bool_value": {"true"}, "string_value": {"str"}, "bytes_value": {"YWJjMTIzIT8kKiYoKSctPUB-"}, "repeated_value": {"a", "b", "c"}, "optional_value": {optionalStr}, "repeated_message": {"1", "2", "3"}, "enum_value": {"1"}, "repeated_enum": {"1", "2", "0"}, "timestamp_value": {timeStr}, "duration_value": {durationStr}, "fieldmask_value": {fieldmaskStr}, "wrapper_float_value": {"1.5"}, "wrapper_double_value": {"2.5"}, "wrapper_int64_value": {"-1"}, "wrapper_int32_value": {"-2"}, "wrapper_u_int64_value": {"3"}, "wrapper_u_int32_value": {"4"}, "wrapper_bool_value": {"true"}, "wrapper_string_value": {"str"}, "wrapper_bytes_value": {"YWJjMTIzIT8kKiYoKSctPUB-"}, "map_value[key]": {"value"}, "map_value[second]": {"bar"}, "map_value[third]": {"zzz"}, "map_value[fourth]": {""}, `map_value[~!@#$%^&*()]`: {"value"}, "map_value2[key]": {"-2"}, "map_value3[-2]": {"value"}, "map_value4[key]": {"-1"}, "map_value5[-1]": {"value"}, "map_value6[key]": {"3"}, "map_value7[3]": {"value"}, "map_value8[key]": {"4"}, "map_value9[4]": {"value"}, "map_value10[key]": {"1.5"}, "map_value11[1.5]": {"value"}, "map_value12[key]": {"2.5"}, "map_value13[2.5]": {"value"}, "map_value14[key]": {"true"}, "map_value15[true]": {"value"}, "map_value16[key]": {"2"}, "struct_value_value": {structValueJsonStrings[0]}, "struct_value": {structJsonStrings[0]}, }, filter: utilities.NewDoubleArray(nil), want: &examplepb.Proto3Message{ FloatValue: 1.5, DoubleValue: 2.5, Int64Value: -1, Int32Value: -2, Uint64Value: 3, Uint32Value: 4, BoolValue: true, StringValue: "str", BytesValue: []byte("abc123!?$*&()'-=@~"), RepeatedValue: []string{"a", "b", "c"}, OptionalValue: &optionalStr, RepeatedMessage: []*wrapperspb.UInt64Value{{Value: 1}, {Value: 2}, {Value: 3}}, EnumValue: examplepb.EnumValue_Y, RepeatedEnum: []examplepb.EnumValue{examplepb.EnumValue_Y, examplepb.EnumValue_Z, examplepb.EnumValue_X}, TimestampValue: timePb, DurationValue: durationPb, FieldmaskValue: fieldmaskPb, WrapperFloatValue: wrapperspb.Float(1.5), WrapperDoubleValue: wrapperspb.Double(2.5), WrapperInt64Value: wrapperspb.Int64(-1), WrapperInt32Value: wrapperspb.Int32(-2), WrapperUInt64Value: wrapperspb.UInt64(3), WrapperUInt32Value: wrapperspb.UInt32(4), WrapperBoolValue: wrapperspb.Bool(true), WrapperStringValue: wrapperspb.String("str"), WrapperBytesValue: wrapperspb.Bytes([]byte("abc123!?$*&()'-=@~")), MapValue: map[string]string{ "key": "value", "second": "bar", "third": "zzz", "fourth": "", `~!@#$%^&*()`: "value", }, MapValue2: map[string]int32{"key": -2}, MapValue3: map[int32]string{-2: "value"}, MapValue4: map[string]int64{"key": -1}, MapValue5: map[int64]string{-1: "value"}, MapValue6: map[string]uint32{"key": 3}, MapValue7: map[uint32]string{3: "value"}, MapValue8: map[string]uint64{"key": 4}, MapValue9: map[uint64]string{4: "value"}, MapValue10: map[string]float32{"key": 1.5}, MapValue12: map[string]float64{"key": 2.5}, MapValue14: map[string]bool{"key": true}, MapValue15: map[bool]string{true: "value"}, MapValue16: map[string]*wrapperspb.UInt64Value{"key": {Value: 2}}, StructValueValue: structValueValues[0], StructValue: structValues[0], }, }, { values: url.Values{ "floatValue": {"1.5"}, "doubleValue": {"2.5"}, "int64Value": {"-1"}, "int32Value": {"-2"}, "uint64Value": {"3"}, "uint32Value": {"4"}, "boolValue": {"true"}, "stringValue": {"str"}, "bytesValue": {"Ynl0ZXM="}, "repeatedValue": {"a", "b", "c"}, "enumValue": {"1"}, "repeatedEnum": {"1", "2", "0"}, "timestampValue": {timeStr}, "durationValue": {durationStr}, "fieldmaskValue": {fieldmaskStr}, "wrapperFloatValue": {"1.5"}, "wrapperDoubleValue": {"2.5"}, "wrapperInt64Value": {"-1"}, "wrapperInt32Value": {"-2"}, "wrapperUInt64Value": {"3"}, "wrapperUInt32Value": {"4"}, "wrapperBoolValue": {"true"}, "wrapperStringValue": {"str"}, "wrapperBytesValue": {"Ynl0ZXM="}, "struct_value_value": {structValueJsonStrings[1]}, "struct_value": {structJsonStrings[1]}, }, filter: utilities.NewDoubleArray(nil), want: &examplepb.Proto3Message{ FloatValue: 1.5, DoubleValue: 2.5, Int64Value: -1, Int32Value: -2, Uint64Value: 3, Uint32Value: 4, BoolValue: true, StringValue: "str", BytesValue: []byte("bytes"), RepeatedValue: []string{"a", "b", "c"}, EnumValue: examplepb.EnumValue_Y, RepeatedEnum: []examplepb.EnumValue{examplepb.EnumValue_Y, examplepb.EnumValue_Z, examplepb.EnumValue_X}, TimestampValue: timePb, DurationValue: durationPb, FieldmaskValue: fieldmaskPb, WrapperFloatValue: wrapperspb.Float(1.5), WrapperDoubleValue: wrapperspb.Double(2.5), WrapperInt64Value: wrapperspb.Int64(-1), WrapperInt32Value: wrapperspb.Int32(-2), WrapperUInt64Value: wrapperspb.UInt64(3), WrapperUInt32Value: wrapperspb.UInt32(4), WrapperBoolValue: wrapperspb.Bool(true), WrapperStringValue: wrapperspb.String("str"), WrapperBytesValue: wrapperspb.Bytes([]byte("bytes")), StructValueValue: structValueValues[1], StructValue: structValues[1], }, }, { values: url.Values{ "enum_value": {"Z"}, "repeated_enum": {"X", "2", "0"}, "struct_value_value": {structValueJsonStrings[2]}, "struct_value": {structJsonStrings[2]}, }, filter: utilities.NewDoubleArray(nil), want: &examplepb.Proto3Message{ EnumValue: examplepb.EnumValue_Z, RepeatedEnum: []examplepb.EnumValue{examplepb.EnumValue_X, examplepb.EnumValue_Z, examplepb.EnumValue_X}, StructValueValue: structValueValues[2], StructValue: structValues[2], }, }, { values: url.Values{ "struct_value_value": {structValueJsonStrings[3]}, }, filter: utilities.NewDoubleArray(nil), want: &examplepb.Proto3Message{ StructValueValue: structValueValues[3], }, }, { values: url.Values{ "struct_value_value": {structValueJsonStrings[4]}, }, filter: utilities.NewDoubleArray(nil), want: &examplepb.Proto3Message{ StructValueValue: structValueValues[4], }, }, { values: url.Values{ "struct_value_value": {structValueJsonStrings[5]}, }, filter: utilities.NewDoubleArray(nil), want: &examplepb.Proto3Message{ StructValueValue: structValueValues[5], }, }, { values: url.Values{ "float_value": {"1.5"}, "double_value": {"2.5"}, "int64_value": {"-1"}, "int32_value": {"-2"}, "uint64_value": {"3"}, "uint32_value": {"4"}, "bool_value": {"true"}, "string_value": {"str"}, "repeated_value": {"a", "b", "c"}, }, filter: utilities.NewDoubleArray(nil), want: &examplepb.Proto2Message{ FloatValue: proto.Float32(1.5), DoubleValue: proto.Float64(2.5), Int64Value: proto.Int64(-1), Int32Value: proto.Int32(-2), Uint64Value: proto.Uint64(3), Uint32Value: proto.Uint32(4), BoolValue: proto.Bool(true), StringValue: proto.String("str"), RepeatedValue: []string{"a", "b", "c"}, }, }, { values: url.Values{ "floatValue": {"1.5"}, "doubleValue": {"2.5"}, "int64Value": {"-1"}, "int32Value": {"-2"}, "uint64Value": {"3"}, "uint32Value": {"4"}, "boolValue": {"true"}, "stringValue": {"str"}, "repeatedValue": {"a", "b", "c"}, }, filter: utilities.NewDoubleArray(nil), want: &examplepb.Proto2Message{ FloatValue: proto.Float32(1.5), DoubleValue: proto.Float64(2.5), Int64Value: proto.Int64(-1), Int32Value: proto.Int32(-2), Uint64Value: proto.Uint64(3), Uint32Value: proto.Uint32(4), BoolValue: proto.Bool(true), StringValue: proto.String("str"), RepeatedValue: []string{"a", "b", "c"}, }, }, { values: url.Values{ "nested.nested.nested.repeated_value": {"a", "b", "c"}, "nested.nested.nested.string_value": {"s"}, "nested.nested.string_value": {"t"}, "nested.string_value": {"u"}, "nested.nested.map_value[first]": {"foo"}, "nested.nested.map_value[second]": {"bar"}, }, filter: utilities.NewDoubleArray(nil), want: &examplepb.Proto3Message{ Nested: &examplepb.Proto3Message{ Nested: &examplepb.Proto3Message{ MapValue: map[string]string{ "first": "foo", "second": "bar", }, Nested: &examplepb.Proto3Message{ RepeatedValue: []string{"a", "b", "c"}, StringValue: "s", }, StringValue: "t", }, StringValue: "u", }, }, }, { values: url.Values{ "oneof_string_value": {"foobar"}, }, filter: utilities.NewDoubleArray(nil), want: &examplepb.Proto3Message{ OneofValue: &examplepb.Proto3Message_OneofStringValue{ OneofStringValue: "foobar", }, }, }, { values: url.Values{ "oneofStringValue": {"foobar"}, }, filter: utilities.NewDoubleArray(nil), want: &examplepb.Proto3Message{ OneofValue: &examplepb.Proto3Message_OneofStringValue{ OneofStringValue: "foobar", }, }, }, { values: url.Values{ "oneof_bool_value": {"true"}, }, filter: utilities.NewDoubleArray(nil), want: &examplepb.Proto3Message{ OneofValue: &examplepb.Proto3Message_OneofBoolValue{ OneofBoolValue: true, }, }, }, { values: url.Values{ "nested_oneof_value_one.int64Value": {"-1"}, "nested_oneof_value_one.string_value": {"foo"}, }, filter: utilities.NewDoubleArray(nil), want: &examplepb.Proto3Message{ NestedOneofValue: &examplepb.Proto3Message_NestedOneofValueOne{ NestedOneofValueOne: &examplepb.Proto3Message{ Int64Value: -1, StringValue: "foo", }, }, }, }, { // Error on "null" values: url.Values{ "timestampValue": {"null"}, }, filter: utilities.NewDoubleArray(nil), want: &examplepb.Proto3Message{}, wanterr: errors.New(`parsing field "timestamp_value": parsing time "null" as "2006-01-02T15:04:05.999999999Z07:00": cannot parse "null" as "2006"`), }, { // Error on "null" values: url.Values{ "durationValue": {"null"}, }, filter: utilities.NewDoubleArray(nil), want: &examplepb.Proto3Message{}, wanterr: errors.New(`parsing field "duration_value": time: invalid duration "null"`), }, { // Don't allow setting a oneof more than once values: url.Values{ "oneof_bool_value": {"true"}, "oneof_string_value": {"foobar"}, }, filter: utilities.NewDoubleArray(nil), want: &examplepb.Proto3Message{}, wanterr: errors.New("field already set for oneof \"oneof_value\""), }, { // Don't allow setting a oneof more than once values: url.Values{ "nested_oneof_int32_value": {"10"}, "nested_oneof_value_one.int32Value": {"-1"}, }, filter: utilities.NewDoubleArray(nil), want: &examplepb.Proto3Message{}, wanterr: errors.New("field already set for oneof \"nested_oneof_value\""), }, { // Don't allow setting a oneof more than once values: url.Values{ "nested_oneof_value_one.int32Value": {"-1"}, "nested_oneof_int32_value": {"10"}, }, filter: utilities.NewDoubleArray(nil), want: &examplepb.Proto3Message{}, wanterr: errors.New("field already set for oneof \"nested_oneof_value\""), }, { // Error when there are too many values values: url.Values{ "uint64_value": {"1", "2"}, }, filter: utilities.NewDoubleArray(nil), want: &examplepb.Proto3Message{}, wanterr: errors.New("too many values for field \"uint64_value\": 1, 2"), }, { // Error when dereferencing a list of messages values: url.Values{ "repeated_message.value": {"1"}, }, filter: utilities.NewDoubleArray(nil), want: &examplepb.Proto3Message{}, wanterr: errors.New("invalid path: \"repeated_message\" is not a message"), }, { values: url.Values{ "timestampValue": {"0000-01-01T00:00:00.00Z"}, }, filter: utilities.NewDoubleArray(nil), want: &examplepb.Proto3Message{}, wanterr: errors.New(`parsing field "timestamp_value": 0000-01-01T00:00:00.00Z before 0001-01-01`), }, } { t.Run(strconv.Itoa(i), func(t *testing.T) { msg := spec.want.ProtoReflect().New().Interface() err := runtime.PopulateQueryParameters(msg, spec.values, spec.filter) if spec.wanterr != nil { if err == nil || err.Error() != spec.wanterr.Error() { t.Errorf("runtime.PopulateQueryParameters(msg, %v, %v) failed with %q; want error %q", spec.values, spec.filter, err, spec.wanterr) } return } if err != nil { t.Errorf("runtime.PopulateQueryParameters(msg, %v, %v) failed with %v; want success", spec.values, spec.filter, err) return } if diff := cmp.Diff(spec.want, msg, protocmp.Transform()); diff != "" { t.Errorf("runtime.PopulateQueryParameters(msg, %v, %v): %s", spec.values, spec.filter, diff) } }) } } func TestPopulateParametersWithFilters(t *testing.T) { for _, spec := range []struct { values url.Values filter *utilities.DoubleArray want proto.Message }{ { values: url.Values{ "bool_value": {"true"}, "string_value": {"str"}, "repeated_value": {"a", "b", "c"}, }, filter: utilities.NewDoubleArray([][]string{ {"bool_value"}, {"repeated_value"}, }), want: &examplepb.Proto3Message{ StringValue: "str", }, }, { values: url.Values{ "nested.nested.bool_value": {"true"}, "nested.nested.string_value": {"str"}, "nested.string_value": {"str"}, "string_value": {"str"}, }, filter: utilities.NewDoubleArray([][]string{ {"nested"}, }), want: &examplepb.Proto3Message{ StringValue: "str", }, }, { values: url.Values{ "nested.nested.bool_value": {"true"}, "nested.nested.string_value": {"str"}, "nested.string_value": {"str"}, "string_value": {"str"}, }, filter: utilities.NewDoubleArray([][]string{ {"nested", "nested"}, }), want: &examplepb.Proto3Message{ Nested: &examplepb.Proto3Message{ StringValue: "str", }, StringValue: "str", }, }, { values: url.Values{ "nested.nested.bool_value": {"true"}, "nested.nested.string_value": {"str"}, "nested.string_value": {"str"}, "string_value": {"str"}, }, filter: utilities.NewDoubleArray([][]string{ {"nested", "nested", "string_value"}, }), want: &examplepb.Proto3Message{ Nested: &examplepb.Proto3Message{ StringValue: "str", Nested: &examplepb.Proto3Message{ BoolValue: true, }, }, StringValue: "str", }, }, } { msg := spec.want.ProtoReflect().New().Interface() err := runtime.PopulateQueryParameters(msg, spec.values, spec.filter) if err != nil { t.Errorf("runtime.PoplateQueryParameters(msg, %v, %v) failed with %v; want success", spec.values, spec.filter, err) continue } if got, want := msg, spec.want; !proto.Equal(got, want) { t.Errorf("runtime.PopulateQueryParameters(msg, %v, %v = %v; want %v", spec.values, spec.filter, got, want) } } } func TestPopulateQueryParametersWithInvalidNestedParameters(t *testing.T) { for _, spec := range []struct { msg proto.Message values url.Values filter *utilities.DoubleArray }{ { msg: &examplepb.Proto3Message{}, values: url.Values{ "float_value.nested": {"test"}, }, filter: utilities.NewDoubleArray(nil), }, { msg: &examplepb.Proto3Message{}, values: url.Values{ "double_value.nested": {"test"}, }, filter: utilities.NewDoubleArray(nil), }, { msg: &examplepb.Proto3Message{}, values: url.Values{ "int64_value.nested": {"test"}, }, filter: utilities.NewDoubleArray(nil), }, { msg: &examplepb.Proto3Message{}, values: url.Values{ "int32_value.nested": {"test"}, }, filter: utilities.NewDoubleArray(nil), }, { msg: &examplepb.Proto3Message{}, values: url.Values{ "uint64_value.nested": {"test"}, }, filter: utilities.NewDoubleArray(nil), }, { msg: &examplepb.Proto3Message{}, values: url.Values{ "uint32_value.nested": {"test"}, }, filter: utilities.NewDoubleArray(nil), }, { msg: &examplepb.Proto3Message{}, values: url.Values{ "bool_value.nested": {"test"}, }, filter: utilities.NewDoubleArray(nil), }, { msg: &examplepb.Proto3Message{}, values: url.Values{ "string_value.nested": {"test"}, }, filter: utilities.NewDoubleArray(nil), }, { msg: &examplepb.Proto3Message{}, values: url.Values{ "repeated_value.nested": {"test"}, }, filter: utilities.NewDoubleArray(nil), }, { msg: &examplepb.Proto3Message{}, values: url.Values{ "enum_value.nested": {"test"}, }, filter: utilities.NewDoubleArray(nil), }, { msg: &examplepb.Proto3Message{}, values: url.Values{ "enum_value.nested": {"test"}, }, filter: utilities.NewDoubleArray(nil), }, { msg: &examplepb.Proto3Message{}, values: url.Values{ "repeated_enum.nested": {"test"}, }, filter: utilities.NewDoubleArray(nil), }, } { spec.msg = spec.msg.ProtoReflect().New().Interface() err := runtime.PopulateQueryParameters(spec.msg, spec.values, spec.filter) if err == nil { t.Errorf("runtime.PopulateQueryParameters(msg, %v, %v) did not fail; want error", spec.values, spec.filter) } } } ================================================ FILE: utilities/BUILD.bazel ================================================ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") package(default_visibility = ["//visibility:public"]) go_library( name = "utilities", srcs = [ "doc.go", "pattern.go", "readerfactory.go", "string_array_flag.go", "trie.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/v2/utilities", ) go_test( name = "utilities_test", size = "small", srcs = [ "string_array_flag_test.go", "trie_test.go", ], deps = [":utilities"], ) alias( name = "go_default_library", actual = ":utilities", visibility = ["//visibility:public"], ) ================================================ FILE: utilities/doc.go ================================================ // Package utilities provides members for internal use in grpc-gateway. package utilities ================================================ FILE: utilities/pattern.go ================================================ package utilities // OpCode is an opcode of compiled path patterns. type OpCode int // These constants are the valid values of OpCode. const ( // OpNop does nothing OpNop = OpCode(iota) // OpPush pushes a component to stack OpPush // OpLitPush pushes a component to stack if it matches to the literal OpLitPush // OpPushM concatenates the remaining components and pushes it to stack OpPushM // OpConcatN pops N items from stack, concatenates them and pushes it back to stack OpConcatN // OpCapture pops an item and binds it to the variable OpCapture // OpEnd is the least positive invalid opcode. OpEnd ) ================================================ FILE: utilities/readerfactory.go ================================================ package utilities import ( "bytes" "io" ) // IOReaderFactory takes in an io.Reader and returns a function that will allow you to create a new reader that begins // at the start of the stream func IOReaderFactory(r io.Reader) (func() io.Reader, error) { b, err := io.ReadAll(r) if err != nil { return nil, err } return func() io.Reader { return bytes.NewReader(b) }, nil } ================================================ FILE: utilities/string_array_flag.go ================================================ package utilities import ( "flag" "strings" ) // flagInterface is a cut down interface to `flag` type flagInterface interface { Var(value flag.Value, name string, usage string) } // StringArrayFlag defines a flag with the specified name and usage string. // The return value is the address of a `StringArrayFlags` variable that stores the repeated values of the flag. func StringArrayFlag(f flagInterface, name string, usage string) *StringArrayFlags { value := &StringArrayFlags{} f.Var(value, name, usage) return value } // StringArrayFlags is a wrapper of `[]string` to provider an interface for `flag.Var` type StringArrayFlags []string // String returns a string representation of `StringArrayFlags` func (i *StringArrayFlags) String() string { return strings.Join(*i, ",") } // Set appends a value to `StringArrayFlags` func (i *StringArrayFlags) Set(value string) error { *i = append(*i, value) return nil } ================================================ FILE: utilities/string_array_flag_test.go ================================================ package utilities_test import ( "flag" "reflect" "testing" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" ) func TestStringArrayFlag(t *testing.T) { tests := []struct { name string flags []string want string }{ { name: "No Value", flags: []string{}, want: "", }, { name: "Single Value", flags: []string{"--my_flag=1"}, want: "1", }, { name: "Repeated Value", flags: []string{"--my_flag=1", "--my_flag=2"}, want: "1,2", }, { name: "Repeated Same Value", flags: []string{"--my_flag=1", "--my_flag=1"}, want: "1,1", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { flagSet := flag.NewFlagSet("test", flag.PanicOnError) result := utilities.StringArrayFlag(flagSet, "my_flag", "repeated flag") if err := flagSet.Parse(tt.flags); err != nil { t.Errorf("flagSet.Parse() failed with %v", err) } if !reflect.DeepEqual(result.String(), tt.want) { t.Errorf("StringArrayFlag() = %v, want %v", result.String(), tt.want) } }) } } ================================================ FILE: utilities/trie.go ================================================ package utilities import ( "sort" ) // DoubleArray is a Double Array implementation of trie on sequences of strings. type DoubleArray struct { // Encoding keeps an encoding from string to int Encoding map[string]int // Base is the base array of Double Array Base []int // Check is the check array of Double Array Check []int } // NewDoubleArray builds a DoubleArray from a set of sequences of strings. func NewDoubleArray(seqs [][]string) *DoubleArray { da := &DoubleArray{Encoding: make(map[string]int)} if len(seqs) == 0 { return da } encoded := registerTokens(da, seqs) sort.Sort(byLex(encoded)) root := node{row: -1, col: -1, left: 0, right: len(encoded)} addSeqs(da, encoded, 0, root) for i := len(da.Base); i > 0; i-- { if da.Check[i-1] != 0 { da.Base = da.Base[:i] da.Check = da.Check[:i] break } } return da } func registerTokens(da *DoubleArray, seqs [][]string) [][]int { var result [][]int for _, seq := range seqs { encoded := make([]int, 0, len(seq)) for _, token := range seq { if _, ok := da.Encoding[token]; !ok { da.Encoding[token] = len(da.Encoding) } encoded = append(encoded, da.Encoding[token]) } result = append(result, encoded) } for i := range result { result[i] = append(result[i], len(da.Encoding)) } return result } type node struct { row, col int left, right int } func (n node) value(seqs [][]int) int { return seqs[n.row][n.col] } func (n node) children(seqs [][]int) []*node { var result []*node lastVal := int(-1) last := new(node) for i := n.left; i < n.right; i++ { if lastVal == seqs[i][n.col+1] { continue } last.right = i last = &node{ row: i, col: n.col + 1, left: i, } result = append(result, last) } last.right = n.right return result } func addSeqs(da *DoubleArray, seqs [][]int, pos int, n node) { ensureSize(da, pos) children := n.children(seqs) var i int for i = 1; ; i++ { ok := func() bool { for _, child := range children { code := child.value(seqs) j := i + code ensureSize(da, j) if da.Check[j] != 0 { return false } } return true }() if ok { break } } da.Base[pos] = i for _, child := range children { code := child.value(seqs) j := i + code da.Check[j] = pos + 1 } terminator := len(da.Encoding) for _, child := range children { code := child.value(seqs) if code == terminator { continue } j := i + code addSeqs(da, seqs, j, *child) } } func ensureSize(da *DoubleArray, i int) { for i >= len(da.Base) { da.Base = append(da.Base, make([]int, len(da.Base)+1)...) da.Check = append(da.Check, make([]int, len(da.Check)+1)...) } } type byLex [][]int func (l byLex) Len() int { return len(l) } func (l byLex) Swap(i, j int) { l[i], l[j] = l[j], l[i] } func (l byLex) Less(i, j int) bool { si := l[i] sj := l[j] var k int for k = 0; k < len(si) && k < len(sj); k++ { if si[k] < sj[k] { return true } if si[k] > sj[k] { return false } } return k < len(sj) } // HasCommonPrefix determines if any sequence in the DoubleArray is a prefix of the given sequence. func (da *DoubleArray) HasCommonPrefix(seq []string) bool { if len(da.Base) == 0 { return false } var i int for _, t := range seq { code, ok := da.Encoding[t] if !ok { break } j := da.Base[i] + code if len(da.Check) <= j || da.Check[j] != i+1 { break } i = j } j := da.Base[i] + len(da.Encoding) if len(da.Check) <= j || da.Check[j] != i+1 { return false } return true } ================================================ FILE: utilities/trie_test.go ================================================ package utilities_test import ( "reflect" "testing" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" ) func TestMaxCommonPrefix(t *testing.T) { for _, spec := range []struct { da utilities.DoubleArray tokens []string want bool }{ { da: utilities.DoubleArray{}, tokens: nil, want: false, }, { da: utilities.DoubleArray{}, tokens: []string{"foo"}, want: false, }, { da: utilities.DoubleArray{ Encoding: map[string]int{ "foo": 0, }, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}, }, tokens: nil, want: false, }, { da: utilities.DoubleArray{ Encoding: map[string]int{ "foo": 0, }, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}, }, tokens: []string{"foo"}, want: true, }, { da: utilities.DoubleArray{ Encoding: map[string]int{ "foo": 0, }, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}, }, tokens: []string{"bar"}, want: false, }, { // foo|bar da: utilities.DoubleArray{ Encoding: map[string]int{ "foo": 0, "bar": 1, }, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}, // 0: ^ // 1: ^foo // 2: ^bar // 3: ^foo$ // 4: ^bar$ }, tokens: []string{"foo"}, want: true, }, { // foo|bar da: utilities.DoubleArray{ Encoding: map[string]int{ "foo": 0, "bar": 1, }, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}, // 0: ^ // 1: ^foo // 2: ^bar // 3: ^foo$ // 4: ^bar$ }, tokens: []string{"bar"}, want: true, }, { // foo|bar da: utilities.DoubleArray{ Encoding: map[string]int{ "foo": 0, "bar": 1, }, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}, // 0: ^ // 1: ^foo // 2: ^bar // 3: ^foo$ // 4: ^bar$ }, tokens: []string{"something-else"}, want: false, }, { // foo|bar da: utilities.DoubleArray{ Encoding: map[string]int{ "foo": 0, "bar": 1, }, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}, // 0: ^ // 1: ^foo // 2: ^bar // 3: ^foo$ // 4: ^bar$ }, tokens: []string{"foo", "bar"}, want: true, }, { // foo|foo\.bar|bar da: utilities.DoubleArray{ Encoding: map[string]int{ "foo": 0, "bar": 1, }, Base: []int{1, 3, 1, 0, 4, 0, 0}, Check: []int{0, 1, 1, 3, 2, 2, 5}, // 0: ^ // 1: ^foo // 2: ^bar // 3: ^bar$ // 4: ^foo.bar // 5: ^foo$ // 6: ^foo.bar$ }, tokens: []string{"foo"}, want: true, }, { // foo|foo\.bar|bar da: utilities.DoubleArray{ Encoding: map[string]int{ "foo": 0, "bar": 1, }, Base: []int{1, 3, 1, 0, 4, 0, 0}, Check: []int{0, 1, 1, 3, 2, 2, 5}, // 0: ^ // 1: ^foo // 2: ^bar // 3: ^bar$ // 4: ^foo.bar // 5: ^foo$ // 6: ^foo.bar$ }, tokens: []string{"foo", "bar"}, want: true, }, { // foo|foo\.bar|bar da: utilities.DoubleArray{ Encoding: map[string]int{ "foo": 0, "bar": 1, }, Base: []int{1, 3, 1, 0, 4, 0, 0}, Check: []int{0, 1, 1, 3, 2, 2, 5}, // 0: ^ // 1: ^foo // 2: ^bar // 3: ^bar$ // 4: ^foo.bar // 5: ^foo$ // 6: ^foo.bar$ }, tokens: []string{"bar"}, want: true, }, { // foo|foo\.bar|bar da: utilities.DoubleArray{ Encoding: map[string]int{ "foo": 0, "bar": 1, }, Base: []int{1, 3, 1, 0, 4, 0, 0}, Check: []int{0, 1, 1, 3, 2, 2, 5}, // 0: ^ // 1: ^foo // 2: ^bar // 3: ^bar$ // 4: ^foo.bar // 5: ^foo$ // 6: ^foo.bar$ }, tokens: []string{"something-else"}, want: false, }, { // foo|foo\.bar|bar da: utilities.DoubleArray{ Encoding: map[string]int{ "foo": 0, "bar": 1, }, Base: []int{1, 3, 1, 0, 4, 0, 0}, Check: []int{0, 1, 1, 3, 2, 2, 5}, // 0: ^ // 1: ^foo // 2: ^bar // 3: ^bar$ // 4: ^foo.bar // 5: ^foo$ // 6: ^foo.bar$ }, tokens: []string{"foo", "bar", "baz"}, want: true, }, } { got := spec.da.HasCommonPrefix(spec.tokens) if got != spec.want { t.Errorf("%#v.HasCommonPrefix(%v) = %v; want %v", spec.da, spec.tokens, got, spec.want) } } } func TestAdd(t *testing.T) { for _, spec := range []struct { tokens [][]string want utilities.DoubleArray }{ { want: utilities.DoubleArray{ Encoding: make(map[string]int), }, }, { tokens: [][]string{{"foo"}}, want: utilities.DoubleArray{ Encoding: map[string]int{"foo": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}, // 0: ^ // 1: ^foo // 2: ^foo$ }, }, { tokens: [][]string{{"foo"}, {"bar"}}, want: utilities.DoubleArray{ Encoding: map[string]int{ "foo": 0, "bar": 1, }, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}, // 0: ^ // 1: ^foo // 2: ^bar // 3: ^foo$ // 4: ^bar$ }, }, { tokens: [][]string{{"foo", "bar"}, {"foo", "baz"}}, want: utilities.DoubleArray{ Encoding: map[string]int{ "foo": 0, "bar": 1, "baz": 2, }, Base: []int{1, 1, 1, 2, 0, 0}, Check: []int{0, 1, 2, 2, 3, 4}, // 0: ^ // 1: ^foo // 2: ^foo.bar // 3: ^foo.baz // 4: ^foo.bar$ // 5: ^foo.baz$ }, }, { tokens: [][]string{{"foo", "bar"}, {"foo", "baz"}, {"qux"}}, want: utilities.DoubleArray{ Encoding: map[string]int{ "foo": 0, "bar": 1, "baz": 2, "qux": 3, }, Base: []int{1, 1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 2, 2, 1, 3, 4, 5}, // 0: ^ // 1: ^foo // 2: ^foo.bar // 3: ^foo.baz // 4: ^qux // 5: ^foo.bar$ // 6: ^foo.baz$ // 7: ^qux$ }, }, { tokens: [][]string{ {"foo", "bar"}, {"foo", "baz", "bar"}, {"qux", "foo"}, }, want: utilities.DoubleArray{ Encoding: map[string]int{ "foo": 0, "bar": 1, "baz": 2, "qux": 3, }, Base: []int{1, 1, 1, 5, 8, 0, 3, 0, 5, 0}, Check: []int{0, 1, 2, 2, 1, 3, 4, 7, 5, 9}, // 0: ^ // 1: ^foo // 2: ^foo.bar // 3: ^foo.baz // 4: ^qux // 5: ^foo.bar$ // 6: ^foo.baz.bar // 7: ^foo.baz.bar$ // 8: ^qux.foo // 9: ^qux.foo$ }, }, } { da := utilities.NewDoubleArray(spec.tokens) if got, want := da.Encoding, spec.want.Encoding; !reflect.DeepEqual(got, want) { t.Errorf("da.Encoding = %v; want %v; tokens = %#v", got, want, spec.tokens) } if got, want := da.Base, spec.want.Base; !compareArray(got, want) { t.Errorf("da.Base = %v; want %v; tokens = %#v", got, want, spec.tokens) } if got, want := da.Check, spec.want.Check; !compareArray(got, want) { t.Errorf("da.Check = %v; want %v; tokens = %#v", got, want, spec.tokens) } } } func compareArray(got, want []int) bool { var i int for i = 0; i < len(got) && i < len(want); i++ { if got[i] != want[i] { return false } } if i < len(want) { return false } for ; i < len(got); i++ { if got[i] != 0 { return false } } return true }