google / google/gnostic-models

OpenAPI v3 Schema defaults cannot contain any value

Open
#11 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
20
Forks
11
PR merge metrics
No merged PRs in 30d

Description

Hi! 👋

Kubernetes both OpenAPI v2 and v3 side-by-side, but moving more and more towards v3, especially for CustomResourceDefinitions (CRDs). In CRDs you can specify a default value for a property.

Kubernetes has it's own meta-library kube-openapi, which has a [translation layer for the OpenAPI schema](https://pkg.go.dev/k8s.io/kube-openapi@v0.0.0-20240812233141-91dab695df6f/pkg/validation/spec#SchemaProps). However, the proto models from this library are used.

In v2 of the proto models of this library, Schema.default is of the Any type, exactly as per the spec's `There are no restrictions placed on the value of this keyword [default].`.
However, in v3, this is hard-coded to only be a number, string or bool, which [breaks round-tripping between JSON and protobuf in Kubernetes](https://github.com/kubernetes/kubernetes/pull/126731).

Would it be possible to support also objects and arrays in the v3 default proto encoding to be compliant with the spec?
Thanks for the consideration!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.