Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KAFKA-17051: ApiKeys#toHtml should exclude the APIs having unstable latest version #16480

Merged
merged 9 commits into from
Jul 2, 2024
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
24 changes: 13 additions & 11 deletions clients/src/main/java/org/apache/kafka/common/protocol/ApiKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,23 +278,25 @@ public boolean inScope(ApiMessageType.ListenerType listener) {
return messageType.listeners().contains(listener);
}

private static String toHtml() {
static String toHtml() {
final StringBuilder b = new StringBuilder();
b.append("<table class=\"data-table\"><tbody>\n");
b.append("<tr>");
b.append("<th>Name</th>\n");
b.append("<th>Key</th>\n");
b.append("</tr>");
for (ApiKeys key : clientApis()) {
b.append("<tr>\n");
b.append("<td>");
b.append("<a href=\"#The_Messages_" + key.name + "\">" + key.name + "</a>");
b.append("</td>");
b.append("<td>");
b.append(key.id);
b.append("</td>");
b.append("</tr>\n");
}
clientApis().stream()
.filter(apiKey -> !apiKey.messageType.latestVersionUnstable())
.forEach(apiKey -> {
b.append("<tr>\n");
b.append("<td>");
b.append("<a href=\"#The_Messages_" + apiKey.name + "\">" + apiKey.name + "</a>");
b.append("</td>");
b.append("<td>");
b.append(apiKey.id);
b.append("</td>");
b.append("</tr>\n");
});
b.append("</tbody></table>\n");
return b.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.Set;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand Down Expand Up @@ -87,4 +88,15 @@ public void testApiScope() {
"Found some APIs missing scope definition");
}

@Test
public void testHtmlOnlyHaveStableApi() {
String html = ApiKeys.toHtml();
for (ApiKeys apiKeys : ApiKeys.clientApis()) {
if (apiKeys.messageType.latestVersionUnstable()) {
assertFalse(html.contains("The_Messages_" + apiKeys.name), "Html should not contain unstable api: " + apiKeys.name);
} else {
assertTrue(html.contains("The_Messages_" + apiKeys.name), "Html should contain stable api: " + apiKeys.name);
}
}
}
}
2 changes: 1 addition & 1 deletion docs/protocol.html
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ <h5 class="anchor-heading"><a id="protocol_error_codes" class="anchor-link"></a>
<!--#include virtual="generated/protocol_errors.html" -->

<h5 class="anchor-heading"><a id="protocol_api_keys" class="anchor-link"></a><a href="#protocol_api_keys">Api Keys</a></h5>
<p>The following are the numeric codes that the ApiKey in the request can take for each of the below request types.</p>
<p>The following are the numeric codes that the stable ApiKey in the request can take for each of the below request types.</p>
<!--#include virtual="generated/protocol_api_keys.html" -->

<h4 class="anchor-heading"><a id="protocol_messages" class="anchor-link"></a><a href="#protocol_messages">The Messages</a></h4>
Expand Down