ahmetb / gen-crd-api-reference-docs

API Reference Docs generator for Kubernetes CRDs (used by Knative, Kubeflow and others)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The typeDisplayName (rendered name of Type) is not correct when it is of type Slice of Pointers

AxiomSamarth opened this issue · comments

One more level of dereferencing is required when the type is slice so as to handle the type like Slice of Pointers better.

Currently, the tool is not creating the correct display type for api fields of type slice of pointers, that is - []*Type. The reference spec is here for the types defined here

The display type of []*GCPDisks should have ideally shown up as either []*GCPDisks (for developer persona) or []GCPDisks (for operator persona) instead of []*github.com/gardener/machine-controller-manager-provider-gcp/pkg/gcp/apis/v1.GCPDisk.

In the main.go here, if the type is a Slice & specifically Slice of Pointers (i.e, Type.Elem.Kind is Pointer), then we have to add another deferencing on t.Elem and return the pointer name.

I faced this issue with my project related types which has one level deferencing of type []*Type.

However, there can be a scenario of any level of pointers. For example - []**Type or []***Type or []****Type. So, I have now proposed in PR #37 a generic solution which renders the typeDisplayName of the type for any levels of pointers when the type is Slice of Pointers :)

Kindly review! cc: @ahmetb

Closing the issue as PR #37 is now merged! Thank you for guiding me through.