Skip to content

Commit c424e33

Browse files
authored
fix: add api_version to gapic_metadata.json (#2476)
1 parent b58591d commit c424e33

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

gapic/schema/api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,9 @@ def gapic_metadata(self, options: Options) -> gapic_metadata_pb2.GapicMetadata:
676676
for service in sorted(self.services.values(), key=lambda s: s.name):
677677
service_desc = gm.services.get_or_create(service.name)
678678

679+
if service.version:
680+
service_desc.api_version = service.version
681+
679682
# At least one of "grpc" or "rest" is guaranteed to be present because
680683
# of the way that Options instances are created.
681684
# This assumes the options are generated by the class method factory.

tests/unit/schema/test_api.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,6 +1908,10 @@ def test_map_field_name_disambiguation():
19081908

19091909

19101910
def test_gapic_metadata():
1911+
apiVersion = "2025-11-03"
1912+
serviceOptions = descriptor_pb2.ServiceOptions()
1913+
serviceOptions.Extensions[client_pb2.api_version] = apiVersion
1914+
19111915
api_schema = api.API.build(
19121916
file_descriptors=[
19131917
descriptor_pb2.FileDescriptorProto(
@@ -1941,6 +1945,7 @@ def test_gapic_metadata():
19411945
output_type="animalia.mollusca.v1.Mollusc",
19421946
),
19431947
],
1948+
options=serviceOptions,
19441949
),
19451950
descriptor_pb2.ServiceDescriptorProto(
19461951
name="Octopus",
@@ -1997,6 +2002,7 @@ def test_gapic_metadata():
19972002
}
19982003
),
19992004
"Squid": gapic_metadata_pb2.GapicMetadata.ServiceForTransport(
2005+
api_version=apiVersion,
20002006
clients={
20012007
"grpc": gapic_metadata_pb2.GapicMetadata.ServiceAsClient(
20022008
library_client="SquidClient",
@@ -2026,7 +2032,7 @@ def test_gapic_metadata():
20262032
),
20272033
},
20282034
),
2029-
}
2035+
},
20302036
),
20312037
},
20322038
)
@@ -2060,6 +2066,7 @@ def test_gapic_metadata():
20602066
}
20612067
),
20622068
"Squid": gapic_metadata_pb2.GapicMetadata.ServiceForTransport(
2069+
api_version=apiVersion,
20632070
clients={
20642071
"rest": gapic_metadata_pb2.GapicMetadata.ServiceAsClient(
20652072
library_client="SquidClient",
@@ -2075,7 +2082,7 @@ def test_gapic_metadata():
20752082
),
20762083
},
20772084
),
2078-
}
2085+
},
20792086
),
20802087
},
20812088
)
@@ -2131,6 +2138,7 @@ def test_gapic_metadata():
21312138
}
21322139
),
21332140
"Squid": gapic_metadata_pb2.GapicMetadata.ServiceForTransport(
2141+
api_version=apiVersion,
21342142
clients={
21352143
"grpc": gapic_metadata_pb2.GapicMetadata.ServiceAsClient(
21362144
library_client="SquidClient",
@@ -2174,7 +2182,7 @@ def test_gapic_metadata():
21742182
),
21752183
},
21762184
),
2177-
}
2185+
},
21782186
),
21792187
},
21802188
)

0 commit comments

Comments
 (0)