Customize OpenAPI definition types

customize intstr, unversioned.time, and quantity OpenAPI definitions.
This commit is contained in:
mbohlool
2016-09-01 15:21:30 -07:00
parent 54fee8c253
commit 6ba271b9ae
3 changed files with 43 additions and 0 deletions

View File

@@ -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