k8s-openapi icon indicating copy to clipboard operation
k8s-openapi copied to clipboard

Allow skipping client generation

Open MikailBag opened this issue 4 years ago • 2 comments

This is a draft because currently, it still fails on metrics.k8s.io.

MikailBag avatar Jun 22 '21 09:06 MikailBag

So, with k3d & k3s v1.20.2, the error is definition io.k8s.apimachinery.pkg.apis.meta.v1.APIGroup_v2 is a Resource but its URL path segment and scope could not be inferred.

/openapi/v2 contains the following (inside paths):

{
// ...
    "/apis/metrics.k8s.io/": {
        "get": {
            "description": "get information of a group",
            "consumes": [
                "application/json",
                "application/yaml",
                "application/vnd.kubernetes.protobuf"
            ],
            "produces": [
                "application/json",
                "application/yaml",
                "application/vnd.kubernetes.protobuf"
            ],
            "schemes": [
                "https"
            ],
            "tags": [
                "metrics"
            ],
            "operationId": "getMetricsAPIGroup",
            "responses": {
                "200": {
                    "description": "OK",
                    "schema": {
                        "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.APIGroup_v2"
                    }
                }
            }
        }
    }
}
// ...

So I conclude k8s-openapi failure here is legitimate: for some reason schema contains two metav1.APIGroups copied.

I will check if the same happens in other distributions.

MikailBag avatar Jun 29 '21 09:06 MikailBag

It'll need to be treated like the regular APIGroup - https://github.com/Arnavion/k8s-openapi/blob/445e89ec444ebb1c68e61361e64eec4c4a3f4785/k8s-openapi-codegen-common/src/lib.rs#L452-L456

Arnavion avatar Jun 29 '21 14:06 Arnavion