diff --git a/pkg/api/resource/quantity.go b/pkg/api/resource/quantity.go index 823dd5ef70e..0bb8250ca36 100644 --- a/pkg/api/resource/quantity.go +++ b/pkg/api/resource/quantity.go @@ -27,7 +27,9 @@ import ( flag "github.com/spf13/pflag" + "github.com/go-openapi/spec" inf "gopkg.in/inf.v0" + "k8s.io/kubernetes/cmd/libs/go2idl/openapi-gen/generators/common" ) // Quantity is a fixed-point representation of a number. @@ -395,6 +397,18 @@ func (q Quantity) DeepCopy() Quantity { return q } +// OpenAPIDefinition returns openAPI definition for this type. +func (_ Quantity) OpenAPIDefinition() common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + } +} + // CanonicalizeBytes returns the canonical form of q and its suffix (see comment on Quantity). // // Note about BinarySI: diff --git a/pkg/api/unversioned/time.go b/pkg/api/unversioned/time.go index 7e6281a2052..83e8bb46582 100644 --- a/pkg/api/unversioned/time.go +++ b/pkg/api/unversioned/time.go @@ -20,6 +20,9 @@ import ( "encoding/json" "time" + "k8s.io/kubernetes/cmd/libs/go2idl/openapi-gen/generators/common" + + "github.com/go-openapi/spec" "github.com/google/gofuzz" ) @@ -142,6 +145,17 @@ func (t Time) MarshalJSON() ([]byte, error) { return json.Marshal(t.UTC().Format(time.RFC3339)) } +func (_ Time) OpenAPIDefinition() common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "date-time", + }, + }, + } +} + // MarshalQueryParameter converts to a URL query parameter value func (t Time) MarshalQueryParameter() (string, error) { if t.IsZero() { diff --git a/pkg/util/intstr/intstr.go b/pkg/util/intstr/intstr.go index 59e7a066336..569dfa24a2d 100644 --- a/pkg/util/intstr/intstr.go +++ b/pkg/util/intstr/intstr.go @@ -23,6 +23,9 @@ import ( "strconv" "strings" + "k8s.io/kubernetes/cmd/libs/go2idl/openapi-gen/generators/common" + + "github.com/go-openapi/spec" "github.com/google/gofuzz" ) @@ -34,6 +37,7 @@ import ( // // +protobuf=true // +protobuf.options.(gogoproto.goproto_stringer)=false +// +k8s:openapi-gen=true type IntOrString struct { Type Type `protobuf:"varint,1,opt,name=type,casttype=Type"` IntVal int32 `protobuf:"varint,2,opt,name=intVal"` @@ -101,6 +105,17 @@ func (intstr IntOrString) MarshalJSON() ([]byte, error) { } } +func (_ IntOrString) OpenAPIDefinition() common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "int-or-string", + }, + }, + } +} + func (intstr *IntOrString) Fuzz(c fuzz.Continue) { if intstr == nil { return