reference-docs icon indicating copy to clipboard operation
reference-docs copied to clipboard

Use OpenAPI V3 for documentation generation

Open Jefftree opened this issue 1 year ago • 7 comments

OpenAPI V3 has been GA for a couple of releases and it would be great if we could generate documentation based on OpenAPI V3 instead of V2. kubectl-validate has samples of how to fetch the OpenAPI V3 schemas from the k/k repo. https://github.com/kubernetes-sigs/kubectl-validate/tree/main/pkg/openapiclient

The benefit is that V3 schemas are more rich, include additional information like field defaults, field nullable, oneof, etc.

Jefftree avatar Jul 04 '24 16:07 Jefftree

We shouldn't label this using the Kubernetes definition of help wanted, even if we do welcome help.

See https://www.kubernetes.dev/docs/guide/help-wanted/

sftim avatar Jul 04 '24 20:07 sftim

There doesn't seem a stable package for parsing OpenAPI v3. The go-openapi project explicitly states that it doesn't support v3. The specv3 subproject has not been updated for many years.

If we take a step back and see what are the benefits v3 brings to us, we can see little. The V3 spec complicates the parsing of an API spec, it introduces more ambiguity (yes, I'm talking about "oneOf", "anyOf") for code generators. If there ARE some benefits that I'm unaware of, please let us know. Maybe it worth develop a new parser for OpenAPI v3, who knows? However, at this stage, OpenAPI v3 doesn't worth this effort.

tengqm avatar Jul 05 '24 00:07 tengqm

Full OpenAPI V3 Kubernetes support was introduced in v1.27

We do not use go-openapi and have our own library in kube-openapi and client-go. This has full OpenAPI V3 support with additional features like caching and automatic GV parsing.

For the documentation generation, a live cluster is probably not needed and we can go purely based off the generated OpenAPI V3 files in k/k (https://github.com/kubernetes/kubernetes/tree/master/api/openapi-spec/v3). The project kubectl-validate already has code querying this repo (https://github.com/kubernetes-sigs/kubectl-validate/blob/main/pkg/openapiclient/github_builtins.go#L39) and it shouldn't be too difficult duplicating this IMO.

Jefftree avatar Jul 05 '24 14:07 Jefftree

Help, especially around defining the work and helping break it into approachable chunks, is very welcome.

sftim avatar Jul 05 '24 14:07 sftim

Again, what are the benefits of OpenAPI v3 bring to the table? Say, it introduces "oneOf", "allOf" or "anyOf" to the spec. However, it is not used anywhere in a meaningful way other than the "IntOrString" data type. Nullable is another feature always mentioned by people. But the spec is not using it anywhere other than the CRD itself. Migrating the parser to V3 is not a trivial task. We have to weigh the benefits against the efforts. In fact, it is not a migration, it means reworking the parser.

tengqm avatar Jul 05 '24 23:07 tengqm

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Oct 03 '24 23:10 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Nov 03 '24 00:11 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-triage-robot avatar Dec 03 '24 01:12 k8s-triage-robot

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

k8s-ci-robot avatar Dec 03 '24 01:12 k8s-ci-robot