Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions gapic/schema/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 11 additions & 3 deletions tests/unit/schema/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -1941,6 +1945,7 @@ def test_gapic_metadata():
output_type="animalia.mollusca.v1.Mollusc",
),
],
options=serviceOptions,
),
descriptor_pb2.ServiceDescriptorProto(
name="Octopus",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -2026,7 +2032,7 @@ def test_gapic_metadata():
),
},
),
}
},
),
},
)
Expand Down Expand Up @@ -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",
Expand All @@ -2075,7 +2082,7 @@ def test_gapic_metadata():
),
},
),
}
},
),
},
)
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -2174,7 +2182,7 @@ def test_gapic_metadata():
),
},
),
}
},
),
},
)
Expand Down
Loading