| 1 |
/* |
| 2 |
Copyright 2019 The Kubernetes Authors. |
| 3 |
|
| 4 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
you may not use this file except in compliance with the License. |
| 6 |
You may obtain a copy of the License at |
| 7 |
|
| 8 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
|
| 10 |
Unless required by applicable law or agreed to in writing, software |
| 11 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
See the License for the specific language governing permissions and |
| 14 |
limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
package custom |
| 18 |
|
| 19 |
import ( |
| 20 |
"k8s.io/kube-openapi/pkg/common" |
| 21 |
"k8s.io/kube-openapi/pkg/validation/spec" |
| 22 |
) |
| 23 |
|
| 24 |
// +k8s:openapi-gen=true |
| 25 |
type Bal struct{} |
| 26 |
|
| 27 |
func (_ Bal) OpenAPIV3Definition() common.OpenAPIDefinition { |
| 28 |
return common.OpenAPIDefinition{ |
| 29 |
Schema: spec.Schema{ |
| 30 |
SchemaProps: spec.SchemaProps{ |
| 31 |
Type: []string{"string"}, |
| 32 |
}, |
| 33 |
}, |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
// +k8s:openapi-gen=true |
| 38 |
type Bac struct{} |
| 39 |
|
| 40 |
func (_ Bac) OpenAPIV3Definition() common.OpenAPIDefinition { |
| 41 |
return common.OpenAPIDefinition{ |
| 42 |
Schema: spec.Schema{ |
| 43 |
SchemaProps: spec.SchemaProps{ |
| 44 |
Type: []string{"object"}, |
| 45 |
}, |
| 46 |
}, |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
func (_ Bac) OpenAPIDefinition() common.OpenAPIDefinition { |
| 51 |
return common.OpenAPIDefinition{ |
| 52 |
Schema: spec.Schema{ |
| 53 |
SchemaProps: spec.SchemaProps{ |
| 54 |
Type: []string{"string"}, |
| 55 |
}, |
| 56 |
}, |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
// +k8s:openapi-gen=true |
| 61 |
type Bah struct{} |
| 62 |
|
| 63 |
func (_ Bah) OpenAPIV3Definition() common.OpenAPIDefinition { |
| 64 |
return common.OpenAPIDefinition{ |
| 65 |
Schema: spec.Schema{ |
| 66 |
SchemaProps: spec.SchemaProps{ |
| 67 |
Type: []string{"object"}, |
| 68 |
}, |
| 69 |
}, |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
func (_ Bah) OpenAPISchemaType() []string { |
| 74 |
return []string{"test-type"} |
| 75 |
} |
| 76 |
|
| 77 |
func (_ Bah) OpenAPISchemaFormat() string { |
| 78 |
return "test-format" |
| 79 |
} |
| 80 |
|
| 81 |
// FooV3OneOf has an OpenAPIV3OneOfTypes method |
| 82 |
// +k8s:openapi-gen=true |
| 83 |
type FooV3OneOf struct{} |
| 84 |
|
| 85 |
func (FooV3OneOf) OpenAPIV3OneOfTypes() []string { |
| 86 |
return []string{"number", "string"} |
| 87 |
} |
| 88 |
func (FooV3OneOf) OpenAPISchemaType() []string { |
| 89 |
return []string{"string"} |
| 90 |
} |
| 91 |
func (FooV3OneOf) OpenAPISchemaFormat() string { |
| 92 |
return "string" |
| 93 |
} |