diff --git a/src/Generation/MethodDetails.php b/src/Generation/MethodDetails.php index 1cc679f77..7ba72c1dc 100644 --- a/src/Generation/MethodDetails.php +++ b/src/Generation/MethodDetails.php @@ -536,6 +536,11 @@ public function isStreaming(): bool $this->methodType === static::CLIENT_STREAMING; } + public function isServerStreaming(): bool + { + return $this->methodType === static::SERVER_STREAMING; + } + public function isMixin(): bool { return $this->mixinServiceFullname !== null; diff --git a/src/Generation/ResourcesGenerator.php b/src/Generation/ResourcesGenerator.php index 81f0c06e5..c4caf11d6 100644 --- a/src/Generation/ResourcesGenerator.php +++ b/src/Generation/ResourcesGenerator.php @@ -210,7 +210,7 @@ public static function generateRestConfig(ServiceDetails $serviceDetails, Servic private static function compileRestConfigInterfaces(ServiceDetails $serviceDetails, ServiceYamlConfig $serviceYamlConfig) { return $serviceDetails->methods - ->filter(fn ($method) => !is_null($method->httpRule) && !$method->isStreaming() && !$method->isMixin()) + ->filter(fn ($method) => !is_null($method->httpRule) && ($method->isServerStreaming() || !$method->isStreaming()) && !$method->isMixin()) ->map(fn ($method) => [$serviceDetails->serviceName, $method, $method->httpRule]) ->concat($serviceYamlConfig->httpRules->map(fn ($x) => [ Vector::new(explode('.', $x->getSelector()))->skipLast(1)->join('.'), diff --git a/tests/Unit/ProtoTests/BasicServerStreaming/basic-server-streaming.proto b/tests/Unit/ProtoTests/BasicServerStreaming/basic-server-streaming.proto index cdec4bdf4..3e0a3136c 100644 --- a/tests/Unit/ProtoTests/BasicServerStreaming/basic-server-streaming.proto +++ b/tests/Unit/ProtoTests/BasicServerStreaming/basic-server-streaming.proto @@ -4,13 +4,19 @@ package testing.basicserverstreaming; option php_namespace = "Testing\\BasicServerStreaming"; +import "google/api/annotations.proto"; import "google/api/client.proto"; import "google/api/field_behavior.proto"; service BasicServerStreaming { option (google.api.default_host) = "serverstreaming.example.com"; - rpc MethodServer(Request) returns(stream Response); + rpc MethodServer(Request) returns(stream Response) { + option (google.api.http) = { + post: "/path:serverStreaming" + body: "*" + }; + }; rpc MethodEmpty(EmptyRequest) returns(stream Response); } diff --git a/tests/Unit/ProtoTests/BasicServerStreaming/out/src/resources/basic_server_streaming_rest_client_config.php b/tests/Unit/ProtoTests/BasicServerStreaming/out/src/resources/basic_server_streaming_rest_client_config.php index f066b83ba..df28fbaf7 100644 --- a/tests/Unit/ProtoTests/BasicServerStreaming/out/src/resources/basic_server_streaming_rest_client_config.php +++ b/tests/Unit/ProtoTests/BasicServerStreaming/out/src/resources/basic_server_streaming_rest_client_config.php @@ -1,5 +1,13 @@ [], + 'interfaces' => [ + 'testing.basicserverstreaming.BasicServerStreaming' => [ + 'MethodServer' => [ + 'method' => 'post', + 'uriTemplate' => '/path:serverStreaming', + 'body' => '*', + ], + ], + ], ];