2 Copyright 2017 The Kubernetes Authors.
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
8 http://www.apache.org/licenses/LICENSE-2.0
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.
19 // JSONSchemaProps is a JSON-Schema following Specification Draft 4 (http://json-schema.org/).
20 type JSONSchemaProps struct {
21 ID string `json:"id,omitempty" protobuf:"bytes,1,opt,name=id"`
22 Schema JSONSchemaURL `json:"$schema,omitempty" protobuf:"bytes,2,opt,name=schema"`
23 Ref *string `json:"$ref,omitempty" protobuf:"bytes,3,opt,name=ref"`
24 Description string `json:"description,omitempty" protobuf:"bytes,4,opt,name=description"`
25 Type string `json:"type,omitempty" protobuf:"bytes,5,opt,name=type"`
26 Format string `json:"format,omitempty" protobuf:"bytes,6,opt,name=format"`
27 Title string `json:"title,omitempty" protobuf:"bytes,7,opt,name=title"`
28 Default *JSON `json:"default,omitempty" protobuf:"bytes,8,opt,name=default"`
29 Maximum *float64 `json:"maximum,omitempty" protobuf:"bytes,9,opt,name=maximum"`
30 ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty" protobuf:"bytes,10,opt,name=exclusiveMaximum"`
31 Minimum *float64 `json:"minimum,omitempty" protobuf:"bytes,11,opt,name=minimum"`
32 ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty" protobuf:"bytes,12,opt,name=exclusiveMinimum"`
33 MaxLength *int64 `json:"maxLength,omitempty" protobuf:"bytes,13,opt,name=maxLength"`
34 MinLength *int64 `json:"minLength,omitempty" protobuf:"bytes,14,opt,name=minLength"`
35 Pattern string `json:"pattern,omitempty" protobuf:"bytes,15,opt,name=pattern"`
36 MaxItems *int64 `json:"maxItems,omitempty" protobuf:"bytes,16,opt,name=maxItems"`
37 MinItems *int64 `json:"minItems,omitempty" protobuf:"bytes,17,opt,name=minItems"`
38 UniqueItems bool `json:"uniqueItems,omitempty" protobuf:"bytes,18,opt,name=uniqueItems"`
39 MultipleOf *float64 `json:"multipleOf,omitempty" protobuf:"bytes,19,opt,name=multipleOf"`
40 Enum []JSON `json:"enum,omitempty" protobuf:"bytes,20,rep,name=enum"`
41 MaxProperties *int64 `json:"maxProperties,omitempty" protobuf:"bytes,21,opt,name=maxProperties"`
42 MinProperties *int64 `json:"minProperties,omitempty" protobuf:"bytes,22,opt,name=minProperties"`
43 Required []string `json:"required,omitempty" protobuf:"bytes,23,rep,name=required"`
44 Items *JSONSchemaPropsOrArray `json:"items,omitempty" protobuf:"bytes,24,opt,name=items"`
45 AllOf []JSONSchemaProps `json:"allOf,omitempty" protobuf:"bytes,25,rep,name=allOf"`
46 OneOf []JSONSchemaProps `json:"oneOf,omitempty" protobuf:"bytes,26,rep,name=oneOf"`
47 AnyOf []JSONSchemaProps `json:"anyOf,omitempty" protobuf:"bytes,27,rep,name=anyOf"`
48 Not *JSONSchemaProps `json:"not,omitempty" protobuf:"bytes,28,opt,name=not"`
49 Properties map[string]JSONSchemaProps `json:"properties,omitempty" protobuf:"bytes,29,rep,name=properties"`
50 AdditionalProperties *JSONSchemaPropsOrBool `json:"additionalProperties,omitempty" protobuf:"bytes,30,opt,name=additionalProperties"`
51 PatternProperties map[string]JSONSchemaProps `json:"patternProperties,omitempty" protobuf:"bytes,31,rep,name=patternProperties"`
52 Dependencies JSONSchemaDependencies `json:"dependencies,omitempty" protobuf:"bytes,32,opt,name=dependencies"`
53 AdditionalItems *JSONSchemaPropsOrBool `json:"additionalItems,omitempty" protobuf:"bytes,33,opt,name=additionalItems"`
54 Definitions JSONSchemaDefinitions `json:"definitions,omitempty" protobuf:"bytes,34,opt,name=definitions"`
55 ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty" protobuf:"bytes,35,opt,name=externalDocs"`
56 Example *JSON `json:"example,omitempty" protobuf:"bytes,36,opt,name=example"`
59 // JSON represents any valid JSON value.
60 // These types are supported: bool, int64, float64, string, []interface{}, map[string]interface{} and nil.
62 Raw []byte `protobuf:"bytes,1,opt,name=raw"`
65 // OpenAPISchemaType is used by the kube-openapi generator when constructing
66 // the OpenAPI spec of this type.
68 // See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators
69 func (_ JSON) OpenAPISchemaType() []string {
70 // TODO: return actual types when anyOf is supported
74 // OpenAPISchemaFormat is used by the kube-openapi generator when constructing
75 // the OpenAPI spec of this type.
76 func (_ JSON) OpenAPISchemaFormat() string { return "" }
78 // JSONSchemaURL represents a schema url.
79 type JSONSchemaURL string
81 // JSONSchemaPropsOrArray represents a value that can either be a JSONSchemaProps
82 // or an array of JSONSchemaProps. Mainly here for serialization purposes.
83 type JSONSchemaPropsOrArray struct {
84 Schema *JSONSchemaProps `protobuf:"bytes,1,opt,name=schema"`
85 JSONSchemas []JSONSchemaProps `protobuf:"bytes,2,rep,name=jSONSchemas"`
88 // OpenAPISchemaType is used by the kube-openapi generator when constructing
89 // the OpenAPI spec of this type.
91 // See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators
92 func (_ JSONSchemaPropsOrArray) OpenAPISchemaType() []string {
93 // TODO: return actual types when anyOf is supported
97 // OpenAPISchemaFormat is used by the kube-openapi generator when constructing
98 // the OpenAPI spec of this type.
99 func (_ JSONSchemaPropsOrArray) OpenAPISchemaFormat() string { return "" }
101 // JSONSchemaPropsOrBool represents JSONSchemaProps or a boolean value.
102 // Defaults to true for the boolean property.
103 type JSONSchemaPropsOrBool struct {
104 Allows bool `protobuf:"varint,1,opt,name=allows"`
105 Schema *JSONSchemaProps `protobuf:"bytes,2,opt,name=schema"`
108 // OpenAPISchemaType is used by the kube-openapi generator when constructing
109 // the OpenAPI spec of this type.
111 // See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators
112 func (_ JSONSchemaPropsOrBool) OpenAPISchemaType() []string {
113 // TODO: return actual types when anyOf is supported
117 // OpenAPISchemaFormat is used by the kube-openapi generator when constructing
118 // the OpenAPI spec of this type.
119 func (_ JSONSchemaPropsOrBool) OpenAPISchemaFormat() string { return "" }
121 // JSONSchemaDependencies represent a dependencies property.
122 type JSONSchemaDependencies map[string]JSONSchemaPropsOrStringArray
124 // JSONSchemaPropsOrStringArray represents a JSONSchemaProps or a string array.
125 type JSONSchemaPropsOrStringArray struct {
126 Schema *JSONSchemaProps `protobuf:"bytes,1,opt,name=schema"`
127 Property []string `protobuf:"bytes,2,rep,name=property"`
130 // OpenAPISchemaType is used by the kube-openapi generator when constructing
131 // the OpenAPI spec of this type.
133 // See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators
134 func (_ JSONSchemaPropsOrStringArray) OpenAPISchemaType() []string {
135 // TODO: return actual types when anyOf is supported
139 // OpenAPISchemaFormat is used by the kube-openapi generator when constructing
140 // the OpenAPI spec of this type.
141 func (_ JSONSchemaPropsOrStringArray) OpenAPISchemaFormat() string { return "" }
143 // JSONSchemaDefinitions contains the models explicitly defined in this spec.
144 type JSONSchemaDefinitions map[string]JSONSchemaProps
146 // ExternalDocumentation allows referencing an external resource for extended documentation.
147 type ExternalDocumentation struct {
148 Description string `json:"description,omitempty" protobuf:"bytes,1,opt,name=description"`
149 URL string `json:"url,omitempty" protobuf:"bytes,2,opt,name=url"`