From 1f0588d6565cbf1cb3d524db8d8308dcea65edde Mon Sep 17 00:00:00 2001 From: Noah Dietz Date: Mon, 3 Nov 2025 23:21:45 +0000 Subject: [PATCH 1/2] fix: add api_version to gapic_metadata.json --- gapic/schema/api.py | 3 +++ tests/unit/schema/test_api.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/gapic/schema/api.py b/gapic/schema/api.py index 6fe99b73d1..b05f6b6dec 100644 --- a/gapic/schema/api.py +++ b/gapic/schema/api.py @@ -676,6 +676,9 @@ def gapic_metadata(self, options: Options) -> gapic_metadata_pb2.GapicMetadata: for service in sorted(self.services.values(), key=lambda s: s.name): service_desc = gm.services.get_or_create(service.name) + if service.version: + service_desc.api_version = service.version + # At least one of "grpc" or "rest" is guaranteed to be present because # of the way that Options instances are created. # This assumes the options are generated by the class method factory. diff --git a/tests/unit/schema/test_api.py b/tests/unit/schema/test_api.py index 8b399c54d5..aae1f15f10 100644 --- a/tests/unit/schema/test_api.py +++ b/tests/unit/schema/test_api.py @@ -1908,6 +1908,10 @@ def test_map_field_name_disambiguation(): def test_gapic_metadata(): + apiVersion = "2025-11-03" + serviceOptions = descriptor_pb2.ServiceOptions() + serviceOptions.Extensions[client_pb2.api_version] = apiVersion + api_schema = api.API.build( file_descriptors=[ descriptor_pb2.FileDescriptorProto( @@ -1941,6 +1945,7 @@ def test_gapic_metadata(): output_type="animalia.mollusca.v1.Mollusc", ), ], + options=serviceOptions, ), descriptor_pb2.ServiceDescriptorProto( name="Octopus", @@ -1997,6 +2002,7 @@ def test_gapic_metadata(): } ), "Squid": gapic_metadata_pb2.GapicMetadata.ServiceForTransport( + api_version=apiVersion, clients={ "grpc": gapic_metadata_pb2.GapicMetadata.ServiceAsClient( library_client="SquidClient", @@ -2060,6 +2066,7 @@ def test_gapic_metadata(): } ), "Squid": gapic_metadata_pb2.GapicMetadata.ServiceForTransport( + api_version=apiVersion, clients={ "rest": gapic_metadata_pb2.GapicMetadata.ServiceAsClient( library_client="SquidClient", @@ -2131,6 +2138,7 @@ def test_gapic_metadata(): } ), "Squid": gapic_metadata_pb2.GapicMetadata.ServiceForTransport( + api_version=apiVersion, clients={ "grpc": gapic_metadata_pb2.GapicMetadata.ServiceAsClient( library_client="SquidClient", From c083349a32b99d02c812f5402e533baf1c1f2bf8 Mon Sep 17 00:00:00 2001 From: Noah Dietz Date: Mon, 10 Nov 2025 22:27:30 +0000 Subject: [PATCH 2/2] fix formatting --- tests/unit/schema/test_api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/schema/test_api.py b/tests/unit/schema/test_api.py index aae1f15f10..300e8cab89 100644 --- a/tests/unit/schema/test_api.py +++ b/tests/unit/schema/test_api.py @@ -2032,7 +2032,7 @@ def test_gapic_metadata(): ), }, ), - } + }, ), }, ) @@ -2082,7 +2082,7 @@ def test_gapic_metadata(): ), }, ), - } + }, ), }, ) @@ -2182,7 +2182,7 @@ def test_gapic_metadata(): ), }, ), - } + }, ), }, )