Skip to content

Commit a2b2179

Browse files
authored
fix: add api_version breadcrumb to client docs (#4018)
Adds simple breadcrumb comment to client class commentary including the `google.api.api_version` value that this client was generated based on and sends in its requests, as per AIP-4236. This breadcrumb will allow client users to reference the API version used by the client in other API artifacts e.g. product documentation. Fixes internal tracking bug http://b/467138606, child of http://b/467065424.
1 parent afedc76 commit a2b2179

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/comment/ServiceClientCommentComposer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ public static List<CommentStatement> createClassHeaderComments(
114114
classHeaderJavadocBuilder = classHeaderJavadocBuilder.addUnescapedComment(descriptionComment);
115115
}
116116

117+
// Include google.api.api_version breadcrumb comment.
118+
if (service.hasApiVersion()) {
119+
classHeaderJavadocBuilder.addParagraph(
120+
String.format("This client uses %s version %s.", service.name(), service.apiVersion()));
121+
}
122+
117123
// Service introduction.
118124
classHeaderJavadocBuilder.addParagraph(SERVICE_DESCRIPTION_INTRO_STRING);
119125
classHeaderJavadocBuilder.addSampleCode(classMethodSampleCode);

gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/EchoClient.golden

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ import javax.annotation.Generated;
3030

3131
// AUTO-GENERATED DOCUMENTATION AND CLASS.
3232
/**
33-
* This class provides the ability to make remote calls to the backing service through method calls
34-
* that map to API methods. Sample code to get started:
33+
* This client uses Echo version foo_version_for_tests.
34+
*
35+
* <p>This class provides the ability to make remote calls to the backing service through method
36+
* calls that map to API methods. Sample code to get started:
3537
*
3638
* <pre>{@code
3739
* // This snippet has been automatically generated and should be regarded as a code template only.

java-showcase/gapic-showcase/src/main/java/com/google/showcase/v1beta1/EchoClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
* 'x-goog-request-params' metadata key on any method to have the values echoed in the response
6060
* headers.
6161
*
62+
* <p>This client uses Echo version v1_20240408.
63+
*
6264
* <p>This class provides the ability to make remote calls to the backing service through method
6365
* calls that map to API methods. Sample code to get started:
6466
*

0 commit comments

Comments
 (0)