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

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
Ken Huang 2024-07-03 03:52:14 +09:00 committed by GitHub
parent 6897b06b03
commit 2bc5e01121
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 12 deletions

View File

@ -278,23 +278,25 @@ public enum ApiKeys {
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();
}

View File

@ -27,6 +27,7 @@ import java.util.HashSet;
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;
@ -87,4 +88,15 @@ public class ApiKeysTest {
"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);
}
}
}
}

View File

@ -200,7 +200,7 @@ Kafka request. SASL/GSSAPI authentication is performed starting with this packet
<!--#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>