For resource discovery, Accept header sent by kubectl does not match documentation

Background: I’m building a tool that must find ALL resources in a k8s cluster. To that end, I’m trying to use the aggregated resource discovery API.

The documentation for the aggregated discovery API says this:

You can access the data by requesting the respective endpoints with an Accept header indicating the aggregated discovery resource: Accept: application/json;v=v2;g=apidiscovery.k8s.io;as=APIGroupDiscoveryList

I was confused by the v= component. What does v=v2 mean? Will it only return v2 resources? But I checked and I get resources from other versions. Maybe it’s just a constant.

I wanted to make sure, so I checked how kubectl calls this API, using the command:

kubectl api-resources -v=8 # -v=8 prints the curl commands

But this left me with even more questions. When Kubectl sends the requests, it actually uses a much more complicated Accept header structure:

application/json;
g=apidiscovery.k8s.io;v=v2;as=APIGroupDiscoveryList,application/json;
g=apidiscovery.k8s.io;v=v2beta1;as=APIGroupDiscoveryList,application/json

Which is different from the structure specified in the documentation. This header seems to suggest a structure with two subclauses, and each subclause has its own mime type:

group (g) version (v) as as.contentType?
apidiscovery.k8s.io v2 APIGroupDiscoveryList application/json
apidiscovery.k8s.io v2beta1 APIGroupDiscoveryList application/json

Why is this alternative structure used? Why are two version clauses specified? Why does each subclause have its own mime type?

My interpretation is that the mimetype specifically refers to that of APIGroupDiscoveryList. But if so, will using a different mime type for a subclause return a response with mixed mime types?

Will not specifying multiple version clauses in this way cause me to miss some resources, such as ones with alpha/beta versions?

This behavior is consistent across multiple kubectl versions, cluster implementations, and host operating systems.

Relevant info

Kubernetes version: 1.32
Cluster implementations: microk8s and minikube
Kubectl versions: 1.32 and 1.30