Debian Codegraph @

test/integration/pkg/generated/openapi_generated.go

raw
1 //go:build !ignore_autogenerated
2 // +build !ignore_autogenerated
3
4 /*
5 Copyright The Kubernetes Authors.
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 */
19
20 // Code generated by openapi-gen. DO NOT EDIT.
21
22 package generated
23
24 import (
25 common "k8s.io/kube-openapi/pkg/common"
26 spec "k8s.io/kube-openapi/pkg/validation/spec"
27 custom "k8s.io/kube-openapi/test/integration/testdata/custom"
28 defaults "k8s.io/kube-openapi/test/integration/testdata/defaults"
29 enumtype "k8s.io/kube-openapi/test/integration/testdata/enumtype"
30 valuevalidation "k8s.io/kube-openapi/test/integration/testdata/valuevalidation"
31 ptr "k8s.io/utils/ptr"
32 )
33
34 func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition {
35 return map[string]common.OpenAPIDefinition{
36 "k8s.io/kube-openapi/test/integration/testdata/custom.Bac": common.EmbedOpenAPIDefinitionIntoV2Extension(custom.Bac{}.OpenAPIV3Definition(), custom.Bac{}.OpenAPIDefinition()),
37 "k8s.io/kube-openapi/test/integration/testdata/custom.Bah": schema_test_integration_testdata_custom_Bah(ref),
38 "k8s.io/kube-openapi/test/integration/testdata/custom.Bak": custom.Bak{}.OpenAPIDefinition(),
39 "k8s.io/kube-openapi/test/integration/testdata/custom.Bal": custom.Bal{}.OpenAPIV3Definition(),
40 "k8s.io/kube-openapi/test/integration/testdata/custom.FooV3OneOf": schema_test_integration_testdata_custom_FooV3OneOf(ref),
41 "k8s.io/kube-openapi/test/integration/testdata/defaults.Defaulted": schema_test_integration_testdata_defaults_Defaulted(ref),
42 "k8s.io/kube-openapi/test/integration/testdata/defaults.SubStruct": schema_test_integration_testdata_defaults_SubStruct(ref),
43 "k8s.io/kube-openapi/test/integration/testdata/dummytype.Bar": schema_test_integration_testdata_dummytype_Bar(ref),
44 "k8s.io/kube-openapi/test/integration/testdata/dummytype.Baz": schema_test_integration_testdata_dummytype_Baz(ref),
45 "k8s.io/kube-openapi/test/integration/testdata/dummytype.Foo": schema_test_integration_testdata_dummytype_Foo(ref),
46 "k8s.io/kube-openapi/test/integration/testdata/dummytype.StatusError": schema_test_integration_testdata_dummytype_StatusError(ref),
47 "k8s.io/kube-openapi/test/integration/testdata/dummytype.Waldo": schema_test_integration_testdata_dummytype_Waldo(ref),
48 "k8s.io/kube-openapi/test/integration/testdata/enumtype.FruitsBasket": schema_test_integration_testdata_enumtype_FruitsBasket(ref),
49 "k8s.io/kube-openapi/test/integration/testdata/listtype.AtomicList": schema_test_integration_testdata_listtype_AtomicList(ref),
50 "k8s.io/kube-openapi/test/integration/testdata/listtype.Item": schema_test_integration_testdata_listtype_Item(ref),
51 "k8s.io/kube-openapi/test/integration/testdata/listtype.MapList": schema_test_integration_testdata_listtype_MapList(ref),
52 "k8s.io/kube-openapi/test/integration/testdata/listtype.SetList": schema_test_integration_testdata_listtype_SetList(ref),
53 "k8s.io/kube-openapi/test/integration/testdata/listtype.UntypedList": schema_test_integration_testdata_listtype_UntypedList(ref),
54 "k8s.io/kube-openapi/test/integration/testdata/maptype.AtomicMap": schema_test_integration_testdata_maptype_AtomicMap(ref),
55 "k8s.io/kube-openapi/test/integration/testdata/maptype.GranularMap": schema_test_integration_testdata_maptype_GranularMap(ref),
56 "k8s.io/kube-openapi/test/integration/testdata/structtype.AtomicStruct": schema_test_integration_testdata_structtype_AtomicStruct(ref),
57 "k8s.io/kube-openapi/test/integration/testdata/structtype.ContainedStruct": schema_test_integration_testdata_structtype_ContainedStruct(ref),
58 "k8s.io/kube-openapi/test/integration/testdata/structtype.DeclaredAtomicStruct": schema_test_integration_testdata_structtype_DeclaredAtomicStruct(ref),
59 "k8s.io/kube-openapi/test/integration/testdata/structtype.FieldLevelOverrideStruct": schema_test_integration_testdata_structtype_FieldLevelOverrideStruct(ref),
60 "k8s.io/kube-openapi/test/integration/testdata/structtype.GranularStruct": schema_test_integration_testdata_structtype_GranularStruct(ref),
61 "k8s.io/kube-openapi/test/integration/testdata/uniontype.InlinedUnion": schema_test_integration_testdata_uniontype_InlinedUnion(ref),
62 "k8s.io/kube-openapi/test/integration/testdata/uniontype.TopLevelUnion": schema_test_integration_testdata_uniontype_TopLevelUnion(ref),
63 "k8s.io/kube-openapi/test/integration/testdata/uniontype.Union": schema_test_integration_testdata_uniontype_Union(ref),
64 "k8s.io/kube-openapi/test/integration/testdata/uniontype.Union2": schema_test_integration_testdata_uniontype_Union2(ref),
65 "k8s.io/kube-openapi/test/integration/testdata/valuevalidation.Foo": schema_test_integration_testdata_valuevalidation_Foo(ref),
66 "k8s.io/kube-openapi/test/integration/testdata/valuevalidation.Foo2": schema_test_integration_testdata_valuevalidation_Foo2(ref),
67 "k8s.io/kube-openapi/test/integration/testdata/valuevalidation.Foo3": schema_test_integration_testdata_valuevalidation_Foo3(ref),
68 "k8s.io/kube-openapi/test/integration/testdata/valuevalidation.Foo4": valuevalidation.Foo4{}.OpenAPIDefinition(),
69 "k8s.io/kube-openapi/test/integration/testdata/valuevalidation.Foo5": schema_test_integration_testdata_valuevalidation_Foo5(ref),
70 }
71 }
72
73 func schema_test_integration_testdata_custom_Bah(ref common.ReferenceCallback) common.OpenAPIDefinition {
74 return common.EmbedOpenAPIDefinitionIntoV2Extension(custom.Bah{}.OpenAPIV3Definition(), common.OpenAPIDefinition{
75 Schema: spec.Schema{
76 SchemaProps: spec.SchemaProps{
77 Type: custom.Bah{}.OpenAPISchemaType(),
78 Format: custom.Bah{}.OpenAPISchemaFormat(),
79 },
80 },
81 })
82 }
83
84 func schema_test_integration_testdata_custom_FooV3OneOf(ref common.ReferenceCallback) common.OpenAPIDefinition {
85 return common.EmbedOpenAPIDefinitionIntoV2Extension(common.OpenAPIDefinition{
86 Schema: spec.Schema{
87 SchemaProps: spec.SchemaProps{
88 Description: "FooV3OneOf has an OpenAPIV3OneOfTypes method",
89 OneOf: common.GenerateOpenAPIV3OneOfSchema(custom.FooV3OneOf{}.OpenAPIV3OneOfTypes()),
90 Format: custom.FooV3OneOf{}.OpenAPISchemaFormat(),
91 },
92 },
93 }, common.OpenAPIDefinition{
94 Schema: spec.Schema{
95 SchemaProps: spec.SchemaProps{
96 Description: "FooV3OneOf has an OpenAPIV3OneOfTypes method",
97 Type: custom.FooV3OneOf{}.OpenAPISchemaType(),
98 Format: custom.FooV3OneOf{}.OpenAPISchemaFormat(),
99 },
100 },
101 })
102 }
103
104 func schema_test_integration_testdata_defaults_Defaulted(ref common.ReferenceCallback) common.OpenAPIDefinition {
105 return common.OpenAPIDefinition{
106 Schema: spec.Schema{
107 SchemaProps: spec.SchemaProps{
108 Type: []string{"object"},
109 Properties: map[string]spec.Schema{
110 "Field": {
111 SchemaProps: spec.SchemaProps{
112 Default: "bar",
113 Type: []string{"string"},
114 Format: "",
115 },
116 },
117 "OtherField": {
118 SchemaProps: spec.SchemaProps{
119 Default: 0,
120 Type: []string{"integer"},
121 Format: "int32",
122 },
123 },
124 "List": {
125 SchemaProps: spec.SchemaProps{
126 Default: []interface{}{"foo", "bar"},
127 Type: []string{"array"},
128 Items: &spec.SchemaOrArray{
129 Schema: &spec.Schema{
130 SchemaProps: spec.SchemaProps{
131 Type: []string{"string"},
132 Format: "",
133 },
134 },
135 },
136 },
137 },
138 "Sub": {
139 SchemaProps: spec.SchemaProps{
140 Default: map[string]interface{}{"I": 5, "S": "foo"},
141 Ref: ref("k8s.io/kube-openapi/test/integration/testdata/defaults.SubStruct"),
142 },
143 },
144 "OtherSub": {
145 SchemaProps: spec.SchemaProps{
146 Default: map[string]interface{}{},
147 Ref: ref("k8s.io/kube-openapi/test/integration/testdata/defaults.SubStruct"),
148 },
149 },
150 "Map": {
151 SchemaProps: spec.SchemaProps{
152 Default: map[string]interface{}{"foo": "bar"},
153 Type: []string{"object"},
154 AdditionalProperties: &spec.SchemaOrBool{
155 Allows: true,
156 Schema: &spec.Schema{
157 SchemaProps: spec.SchemaProps{
158 Type: []string{"string"},
159 Format: "",
160 },
161 },
162 },
163 },
164 },
165 "localSymbolReference": {
166 SchemaProps: spec.SchemaProps{
167 Default: defaults.ConstantValue,
168 Type: []string{"string"},
169 Format: "",
170 },
171 },
172 "fullyQualifiedSymbolReference": {
173 SchemaProps: spec.SchemaProps{
174 Default: defaults.ConstantValue,
175 Type: []string{"string"},
176 Format: "",
177 },
178 },
179 "externalSymbolReference": {
180 SchemaProps: spec.SchemaProps{
181 Default: enumtype.FruitApple,
182 Type: []string{"string"},
183 Format: "",
184 },
185 },
186 "pointerConversionSymbolReference": {
187 SchemaProps: spec.SchemaProps{
188 Default: enumtype.FruitApple,
189 Type: []string{"string"},
190 Format: "",
191 },
192 },
193 "defaultedAliasSymbolReference": {
194 SchemaProps: spec.SchemaProps{
195 Default: defaults.ConstantValue,
196 Type: []string{"string"},
197 Format: "",
198 },
199 },
200 },
201 Required: []string{"OtherField", "List", "Sub", "OtherSub", "Map"},
202 },
203 },
204 Dependencies: []string{
205 "k8s.io/kube-openapi/test/integration/testdata/defaults.SubStruct"},
206 }
207 }
208
209 func schema_test_integration_testdata_defaults_SubStruct(ref common.ReferenceCallback) common.OpenAPIDefinition {
210 return common.OpenAPIDefinition{
211 Schema: spec.Schema{
212 SchemaProps: spec.SchemaProps{
213 Type: []string{"object"},
214 Properties: map[string]spec.Schema{
215 "S": {
216 SchemaProps: spec.SchemaProps{
217 Default: "",
218 Type: []string{"string"},
219 Format: "",
220 },
221 },
222 "I": {
223 SchemaProps: spec.SchemaProps{
224 Default: 1,
225 Type: []string{"integer"},
226 Format: "int32",
227 },
228 },
229 },
230 Required: []string{"S"},
231 },
232 },
233 }
234 }
235
236 func schema_test_integration_testdata_dummytype_Bar(ref common.ReferenceCallback) common.OpenAPIDefinition {
237 return common.OpenAPIDefinition{
238 Schema: spec.Schema{
239 SchemaProps: spec.SchemaProps{
240 Type: []string{"object"},
241 Properties: map[string]spec.Schema{
242 "ViolationBehind": {
243 SchemaProps: spec.SchemaProps{
244 Default: false,
245 Type: []string{"boolean"},
246 Format: "",
247 },
248 },
249 "Violation": {
250 SchemaProps: spec.SchemaProps{
251 Default: false,
252 Type: []string{"boolean"},
253 Format: "",
254 },
255 },
256 },
257 Required: []string{"ViolationBehind", "Violation"},
258 },
259 },
260 }
261 }
262
263 func schema_test_integration_testdata_dummytype_Baz(ref common.ReferenceCallback) common.OpenAPIDefinition {
264 return common.OpenAPIDefinition{
265 Schema: spec.Schema{
266 SchemaProps: spec.SchemaProps{
267 Type: []string{"object"},
268 Properties: map[string]spec.Schema{
269 "Violation": {
270 SchemaProps: spec.SchemaProps{
271 Default: false,
272 Type: []string{"boolean"},
273 Format: "",
274 },
275 },
276 "ViolationBehind": {
277 SchemaProps: spec.SchemaProps{
278 Default: false,
279 Type: []string{"boolean"},
280 Format: "",
281 },
282 },
283 },
284 Required: []string{"Violation", "ViolationBehind"},
285 },
286 },
287 }
288 }
289
290 func schema_test_integration_testdata_dummytype_Foo(ref common.ReferenceCallback) common.OpenAPIDefinition {
291 return common.OpenAPIDefinition{
292 Schema: spec.Schema{
293 SchemaProps: spec.SchemaProps{
294 Type: []string{"object"},
295 Properties: map[string]spec.Schema{
296 "Second": {
297 SchemaProps: spec.SchemaProps{
298 Default: "",
299 Type: []string{"string"},
300 Format: "",
301 },
302 },
303 "First": {
304 SchemaProps: spec.SchemaProps{
305 Default: 0,
306 Type: []string{"integer"},
307 Format: "int32",
308 },
309 },
310 },
311 Required: []string{"Second", "First"},
312 },
313 },
314 }
315 }
316
317 func schema_test_integration_testdata_dummytype_StatusError(ref common.ReferenceCallback) common.OpenAPIDefinition {
318 return common.OpenAPIDefinition{
319 Schema: spec.Schema{
320 SchemaProps: spec.SchemaProps{
321 Type: []string{"object"},
322 Properties: map[string]spec.Schema{
323 "Code": {
324 SchemaProps: spec.SchemaProps{
325 Default: 0,
326 Type: []string{"integer"},
327 Format: "int32",
328 },
329 },
330 "Message": {
331 SchemaProps: spec.SchemaProps{
332 Default: "",
333 Type: []string{"string"},
334 Format: "",
335 },
336 },
337 },
338 Required: []string{"Code", "Message"},
339 },
340 },
341 }
342 }
343
344 func schema_test_integration_testdata_dummytype_Waldo(ref common.ReferenceCallback) common.OpenAPIDefinition {
345 return common.OpenAPIDefinition{
346 Schema: spec.Schema{
347 SchemaProps: spec.SchemaProps{
348 Type: []string{"object"},
349 Properties: map[string]spec.Schema{
350 "First": {
351 SchemaProps: spec.SchemaProps{
352 Default: 0,
353 Type: []string{"integer"},
354 Format: "int32",
355 },
356 },
357 "Second": {
358 SchemaProps: spec.SchemaProps{
359 Default: "",
360 Type: []string{"string"},
361 Format: "",
362 },
363 },
364 },
365 Required: []string{"First", "Second"},
366 },
367 },
368 }
369 }
370
371 func schema_test_integration_testdata_enumtype_FruitsBasket(ref common.ReferenceCallback) common.OpenAPIDefinition {
372 return common.OpenAPIDefinition{
373 Schema: spec.Schema{
374 SchemaProps: spec.SchemaProps{
375 Description: "FruitsBasket is the type that contains the enum type.",
376 Type: []string{"object"},
377 Properties: map[string]spec.Schema{
378 "content": {
379 SchemaProps: spec.SchemaProps{
380 Description: "Possible enum values:\n - `\"apple\"` is the Apple\n - `\"banana\"` is the Banana\n - `\"onigiri\"` is the Rice ball that does not seem to belong to a fruits basket but has a long comment that is so long that it spans multiple lines",
381 Default: "",
382 Type: []string{"string"},
383 Format: "",
384 Enum: []interface{}{"apple", "banana", "onigiri"},
385 },
386 },
387 "count": {
388 SchemaProps: spec.SchemaProps{
389 Default: 0,
390 Type: []string{"integer"},
391 Format: "int32",
392 },
393 },
394 },
395 Required: []string{"content", "count"},
396 },
397 },
398 }
399 }
400
401 func schema_test_integration_testdata_listtype_AtomicList(ref common.ReferenceCallback) common.OpenAPIDefinition {
402 return common.OpenAPIDefinition{
403 Schema: spec.Schema{
404 SchemaProps: spec.SchemaProps{
405 Type: []string{"object"},
406 Properties: map[string]spec.Schema{
407 "Field": {
408 VendorExtensible: spec.VendorExtensible{
409 Extensions: spec.Extensions{
410 "x-kubernetes-list-type": "atomic",
411 },
412 },
413 SchemaProps: spec.SchemaProps{
414 Type: []string{"array"},
415 Items: &spec.SchemaOrArray{
416 Schema: &spec.Schema{
417 SchemaProps: spec.SchemaProps{
418 Type: []string{"string"},
419 Format: "",
420 },
421 },
422 },
423 },
424 },
425 },
426 Required: []string{"Field"},
427 },
428 },
429 }
430 }
431
432 func schema_test_integration_testdata_listtype_Item(ref common.ReferenceCallback) common.OpenAPIDefinition {
433 return common.OpenAPIDefinition{
434 Schema: spec.Schema{
435 SchemaProps: spec.SchemaProps{
436 Type: []string{"object"},
437 Properties: map[string]spec.Schema{
438 "Protocol": {
439 SchemaProps: spec.SchemaProps{
440 Default: "",
441 Type: []string{"string"},
442 Format: "",
443 },
444 },
445 "Port": {
446 SchemaProps: spec.SchemaProps{
447 Default: 0,
448 Type: []string{"integer"},
449 Format: "int32",
450 },
451 },
452 "a": {
453 SchemaProps: spec.SchemaProps{
454 Default: 0,
455 Type: []string{"integer"},
456 Format: "int32",
457 },
458 },
459 "b": {
460 SchemaProps: spec.SchemaProps{
461 Type: []string{"integer"},
462 Format: "int32",
463 },
464 },
465 "c": {
466 SchemaProps: spec.SchemaProps{
467 Default: 0,
468 Type: []string{"integer"},
469 Format: "int32",
470 },
471 },
472 },
473 Required: []string{"Protocol", "Port"},
474 },
475 },
476 }
477 }
478
479 func schema_test_integration_testdata_listtype_MapList(ref common.ReferenceCallback) common.OpenAPIDefinition {
480 return common.OpenAPIDefinition{
481 Schema: spec.Schema{
482 SchemaProps: spec.SchemaProps{
483 Type: []string{"object"},
484 Properties: map[string]spec.Schema{
485 "Field": {
486 VendorExtensible: spec.VendorExtensible{
487 Extensions: spec.Extensions{
488 "x-kubernetes-list-map-keys": []interface{}{
489 "port",
490 },
491 "x-kubernetes-list-type": "map",
492 },
493 },
494 SchemaProps: spec.SchemaProps{
495 Type: []string{"array"},
496 Items: &spec.SchemaOrArray{
497 Schema: &spec.Schema{
498 SchemaProps: spec.SchemaProps{
499 Ref: ref("k8s.io/kube-openapi/test/integration/testdata/listtype.Item"),
500 },
501 },
502 },
503 },
504 },
505 },
506 Required: []string{"Field"},
507 },
508 },
509 Dependencies: []string{
510 "k8s.io/kube-openapi/test/integration/testdata/listtype.Item"},
511 }
512 }
513
514 func schema_test_integration_testdata_listtype_SetList(ref common.ReferenceCallback) common.OpenAPIDefinition {
515 return common.OpenAPIDefinition{
516 Schema: spec.Schema{
517 SchemaProps: spec.SchemaProps{
518 Type: []string{"object"},
519 Properties: map[string]spec.Schema{
520 "Field": {
521 VendorExtensible: spec.VendorExtensible{
522 Extensions: spec.Extensions{
523 "x-kubernetes-list-type": "set",
524 },
525 },
526 SchemaProps: spec.SchemaProps{
527 Type: []string{"array"},
528 Items: &spec.SchemaOrArray{
529 Schema: &spec.Schema{
530 SchemaProps: spec.SchemaProps{
531 Type: []string{"string"},
532 Format: "",
533 },
534 },
535 },
536 },
537 },
538 },
539 Required: []string{"Field"},
540 },
541 },
542 }
543 }
544
545 func schema_test_integration_testdata_listtype_UntypedList(ref common.ReferenceCallback) common.OpenAPIDefinition {
546 return common.OpenAPIDefinition{
547 Schema: spec.Schema{
548 SchemaProps: spec.SchemaProps{
549 Type: []string{"object"},
550 Properties: map[string]spec.Schema{
551 "Field": {
552 SchemaProps: spec.SchemaProps{
553 Type: []string{"array"},
554 Items: &spec.SchemaOrArray{
555 Schema: &spec.Schema{
556 SchemaProps: spec.SchemaProps{
557 Type: []string{"string"},
558 Format: "",
559 },
560 },
561 },
562 },
563 },
564 },
565 Required: []string{"Field"},
566 },
567 },
568 }
569 }
570
571 func schema_test_integration_testdata_maptype_AtomicMap(ref common.ReferenceCallback) common.OpenAPIDefinition {
572 return common.OpenAPIDefinition{
573 Schema: spec.Schema{
574 SchemaProps: spec.SchemaProps{
575 Type: []string{"object"},
576 Properties: map[string]spec.Schema{
577 "KeyValue": {
578 VendorExtensible: spec.VendorExtensible{
579 Extensions: spec.Extensions{
580 "x-kubernetes-map-type": "atomic",
581 },
582 },
583 SchemaProps: spec.SchemaProps{
584 Type: []string{"object"},
585 AdditionalProperties: &spec.SchemaOrBool{
586 Allows: true,
587 Schema: &spec.Schema{
588 SchemaProps: spec.SchemaProps{
589 Type: []string{"string"},
590 Format: "",
591 },
592 },
593 },
594 },
595 },
596 },
597 Required: []string{"KeyValue"},
598 },
599 },
600 }
601 }
602
603 func schema_test_integration_testdata_maptype_GranularMap(ref common.ReferenceCallback) common.OpenAPIDefinition {
604 return common.OpenAPIDefinition{
605 Schema: spec.Schema{
606 SchemaProps: spec.SchemaProps{
607 Type: []string{"object"},
608 Properties: map[string]spec.Schema{
609 "KeyValue": {
610 VendorExtensible: spec.VendorExtensible{
611 Extensions: spec.Extensions{
612 "x-kubernetes-map-type": "granular",
613 },
614 },
615 SchemaProps: spec.SchemaProps{
616 Type: []string{"object"},
617 AdditionalProperties: &spec.SchemaOrBool{
618 Allows: true,
619 Schema: &spec.Schema{
620 SchemaProps: spec.SchemaProps{
621 Type: []string{"string"},
622 Format: "",
623 },
624 },
625 },
626 },
627 },
628 },
629 Required: []string{"KeyValue"},
630 },
631 },
632 }
633 }
634
635 func schema_test_integration_testdata_structtype_AtomicStruct(ref common.ReferenceCallback) common.OpenAPIDefinition {
636 return common.OpenAPIDefinition{
637 Schema: spec.Schema{
638 SchemaProps: spec.SchemaProps{
639 Type: []string{"object"},
640 Properties: map[string]spec.Schema{
641 "Field": {
642 VendorExtensible: spec.VendorExtensible{
643 Extensions: spec.Extensions{
644 "x-kubernetes-map-type": "atomic",
645 },
646 },
647 SchemaProps: spec.SchemaProps{
648 Default: map[string]interface{}{},
649 Ref: ref("k8s.io/kube-openapi/test/integration/testdata/structtype.ContainedStruct"),
650 },
651 },
652 "OtherField": {
653 SchemaProps: spec.SchemaProps{
654 Default: 0,
655 Type: []string{"integer"},
656 Format: "int32",
657 },
658 },
659 },
660 Required: []string{"Field", "OtherField"},
661 },
662 },
663 Dependencies: []string{
664 "k8s.io/kube-openapi/test/integration/testdata/structtype.ContainedStruct"},
665 }
666 }
667
668 func schema_test_integration_testdata_structtype_ContainedStruct(ref common.ReferenceCallback) common.OpenAPIDefinition {
669 return common.OpenAPIDefinition{
670 Schema: spec.Schema{
671 SchemaProps: spec.SchemaProps{
672 Type: []string{"object"},
673 },
674 },
675 }
676 }
677
678 func schema_test_integration_testdata_structtype_DeclaredAtomicStruct(ref common.ReferenceCallback) common.OpenAPIDefinition {
679 return common.OpenAPIDefinition{
680 Schema: spec.Schema{
681 SchemaProps: spec.SchemaProps{
682 Type: []string{"object"},
683 Properties: map[string]spec.Schema{
684 "Field": {
685 SchemaProps: spec.SchemaProps{
686 Default: 0,
687 Type: []string{"integer"},
688 Format: "int32",
689 },
690 },
691 },
692 Required: []string{"Field"},
693 },
694 VendorExtensible: spec.VendorExtensible{
695 Extensions: spec.Extensions{
696 "x-kubernetes-map-type": "atomic",
697 },
698 },
699 },
700 }
701 }
702
703 func schema_test_integration_testdata_structtype_FieldLevelOverrideStruct(ref common.ReferenceCallback) common.OpenAPIDefinition {
704 return common.OpenAPIDefinition{
705 Schema: spec.Schema{
706 SchemaProps: spec.SchemaProps{
707 Type: []string{"object"},
708 Properties: map[string]spec.Schema{
709 "Field": {
710 VendorExtensible: spec.VendorExtensible{
711 Extensions: spec.Extensions{
712 "x-kubernetes-map-type": "atomic",
713 },
714 },
715 SchemaProps: spec.SchemaProps{
716 Default: map[string]interface{}{},
717 Ref: ref("k8s.io/kube-openapi/test/integration/testdata/structtype.DeclaredAtomicStruct"),
718 },
719 },
720 "OtherField": {
721 SchemaProps: spec.SchemaProps{
722 Default: 0,
723 Type: []string{"integer"},
724 Format: "int32",
725 },
726 },
727 },
728 Required: []string{"Field", "OtherField"},
729 },
730 },
731 Dependencies: []string{
732 "k8s.io/kube-openapi/test/integration/testdata/structtype.DeclaredAtomicStruct"},
733 }
734 }
735
736 func schema_test_integration_testdata_structtype_GranularStruct(ref common.ReferenceCallback) common.OpenAPIDefinition {
737 return common.OpenAPIDefinition{
738 Schema: spec.Schema{
739 SchemaProps: spec.SchemaProps{
740 Type: []string{"object"},
741 Properties: map[string]spec.Schema{
742 "Field": {
743 VendorExtensible: spec.VendorExtensible{
744 Extensions: spec.Extensions{
745 "x-kubernetes-map-type": "granular",
746 },
747 },
748 SchemaProps: spec.SchemaProps{
749 Default: map[string]interface{}{},
750 Ref: ref("k8s.io/kube-openapi/test/integration/testdata/structtype.ContainedStruct"),
751 },
752 },
753 "OtherField": {
754 SchemaProps: spec.SchemaProps{
755 Default: 0,
756 Type: []string{"integer"},
757 Format: "int32",
758 },
759 },
760 },
761 Required: []string{"Field", "OtherField"},
762 },
763 },
764 Dependencies: []string{
765 "k8s.io/kube-openapi/test/integration/testdata/structtype.ContainedStruct"},
766 }
767 }
768
769 func schema_test_integration_testdata_uniontype_InlinedUnion(ref common.ReferenceCallback) common.OpenAPIDefinition {
770 return common.OpenAPIDefinition{
771 Schema: spec.Schema{
772 SchemaProps: spec.SchemaProps{
773 Type: []string{"object"},
774 Properties: map[string]spec.Schema{
775 "name": {
776 SchemaProps: spec.SchemaProps{
777 Default: "",
778 Type: []string{"string"},
779 Format: "",
780 },
781 },
782 "field1": {
783 SchemaProps: spec.SchemaProps{
784 Type: []string{"integer"},
785 Format: "int32",
786 },
787 },
788 "field2": {
789 SchemaProps: spec.SchemaProps{
790 Type: []string{"integer"},
791 Format: "int32",
792 },
793 },
794 "unionType": {
795 SchemaProps: spec.SchemaProps{
796 Default: "",
797 Type: []string{"string"},
798 Format: "",
799 },
800 },
801 "fieldA": {
802 SchemaProps: spec.SchemaProps{
803 Type: []string{"integer"},
804 Format: "int32",
805 },
806 },
807 "fieldB": {
808 SchemaProps: spec.SchemaProps{
809 Type: []string{"integer"},
810 Format: "int32",
811 },
812 },
813 "type": {
814 SchemaProps: spec.SchemaProps{
815 Default: "",
816 Type: []string{"string"},
817 Format: "",
818 },
819 },
820 "alpha": {
821 SchemaProps: spec.SchemaProps{
822 Type: []string{"integer"},
823 Format: "int32",
824 },
825 },
826 "beta": {
827 SchemaProps: spec.SchemaProps{
828 Type: []string{"integer"},
829 Format: "int32",
830 },
831 },
832 },
833 Required: []string{"name", "type"},
834 },
835 VendorExtensible: spec.VendorExtensible{
836 Extensions: spec.Extensions{
837 "x-kubernetes-unions": []interface{}{
838 map[string]interface{}{
839 "discriminator": "unionType",
840 "fields-to-discriminateBy": map[string]interface{}{
841 "fieldA": "FieldA",
842 "fieldB": "FieldB",
843 },
844 },
845 map[string]interface{}{
846 "discriminator": "type",
847 "fields-to-discriminateBy": map[string]interface{}{
848 "alpha": "Alpha",
849 "beta": "Beta",
850 },
851 },
852 map[string]interface{}{
853 "fields-to-discriminateBy": map[string]interface{}{
854 "field1": "Field1",
855 "field2": "Field2",
856 },
857 },
858 },
859 },
860 },
861 },
862 }
863 }
864
865 func schema_test_integration_testdata_uniontype_TopLevelUnion(ref common.ReferenceCallback) common.OpenAPIDefinition {
866 return common.OpenAPIDefinition{
867 Schema: spec.Schema{
868 SchemaProps: spec.SchemaProps{
869 Type: []string{"object"},
870 Properties: map[string]spec.Schema{
871 "name": {
872 SchemaProps: spec.SchemaProps{
873 Default: "",
874 Type: []string{"string"},
875 Format: "",
876 },
877 },
878 "unionType": {
879 SchemaProps: spec.SchemaProps{
880 Default: "",
881 Type: []string{"string"},
882 Format: "",
883 },
884 },
885 "fieldA": {
886 SchemaProps: spec.SchemaProps{
887 Type: []string{"integer"},
888 Format: "int32",
889 },
890 },
891 "fieldB": {
892 SchemaProps: spec.SchemaProps{
893 Type: []string{"integer"},
894 Format: "int32",
895 },
896 },
897 },
898 Required: []string{"name"},
899 },
900 VendorExtensible: spec.VendorExtensible{
901 Extensions: spec.Extensions{
902 "x-kubernetes-unions": []interface{}{
903 map[string]interface{}{
904 "discriminator": "unionType",
905 "fields-to-discriminateBy": map[string]interface{}{
906 "fieldA": "FieldA",
907 "fieldB": "FieldB",
908 },
909 },
910 },
911 },
912 },
913 },
914 }
915 }
916
917 func schema_test_integration_testdata_uniontype_Union(ref common.ReferenceCallback) common.OpenAPIDefinition {
918 return common.OpenAPIDefinition{
919 Schema: spec.Schema{
920 SchemaProps: spec.SchemaProps{
921 Type: []string{"object"},
922 Properties: map[string]spec.Schema{
923 "unionType": {
924 SchemaProps: spec.SchemaProps{
925 Default: "",
926 Type: []string{"string"},
927 Format: "",
928 },
929 },
930 "fieldA": {
931 SchemaProps: spec.SchemaProps{
932 Type: []string{"integer"},
933 Format: "int32",
934 },
935 },
936 "fieldB": {
937 SchemaProps: spec.SchemaProps{
938 Type: []string{"integer"},
939 Format: "int32",
940 },
941 },
942 },
943 },
944 VendorExtensible: spec.VendorExtensible{
945 Extensions: spec.Extensions{
946 "x-kubernetes-unions": []interface{}{
947 map[string]interface{}{
948 "discriminator": "unionType",
949 "fields-to-discriminateBy": map[string]interface{}{
950 "fieldA": "FieldA",
951 "fieldB": "FieldB",
952 },
953 },
954 },
955 },
956 },
957 },
958 }
959 }
960
961 func schema_test_integration_testdata_uniontype_Union2(ref common.ReferenceCallback) common.OpenAPIDefinition {
962 return common.OpenAPIDefinition{
963 Schema: spec.Schema{
964 SchemaProps: spec.SchemaProps{
965 Type: []string{"object"},
966 Properties: map[string]spec.Schema{
967 "type": {
968 SchemaProps: spec.SchemaProps{
969 Default: "",
970 Type: []string{"string"},
971 Format: "",
972 },
973 },
974 "alpha": {
975 SchemaProps: spec.SchemaProps{
976 Type: []string{"integer"},
977 Format: "int32",
978 },
979 },
980 "beta": {
981 SchemaProps: spec.SchemaProps{
982 Type: []string{"integer"},
983 Format: "int32",
984 },
985 },
986 },
987 Required: []string{"type"},
988 },
989 VendorExtensible: spec.VendorExtensible{
990 Extensions: spec.Extensions{
991 "x-kubernetes-unions": []interface{}{
992 map[string]interface{}{
993 "discriminator": "type",
994 "fields-to-discriminateBy": map[string]interface{}{
995 "alpha": "Alpha",
996 "beta": "Beta",
997 },
998 },
999 },
1000 },
1001 },
1002 },
1003 }
1004 }
1005
1006 func schema_test_integration_testdata_valuevalidation_Foo(ref common.ReferenceCallback) common.OpenAPIDefinition {
1007 return common.OpenAPIDefinition{
1008 Schema: spec.Schema{
1009 SchemaProps: spec.SchemaProps{
1010 Type: []string{"object"},
1011 MinProperties: ptr.To[int64](1),
1012 MaxProperties: ptr.To[int64](5),
1013 Properties: map[string]spec.Schema{
1014 "StringValue": {
1015 SchemaProps: spec.SchemaProps{
1016 MinLength: ptr.To[int64](1),
1017 MaxLength: ptr.To[int64](5),
1018 Pattern: "^a.*b$",
1019 Type: []string{"string"},
1020 Format: "",
1021 },
1022 },
1023 "NumberValue": {
1024 SchemaProps: spec.SchemaProps{
1025 Minimum: ptr.To[float64](1),
1026 Maximum: ptr.To[float64](5),
1027 ExclusiveMinimum: true,
1028 ExclusiveMaximum: true,
1029 MultipleOf: ptr.To[float64](2),
1030 Type: []string{"number"},
1031 Format: "double",
1032 },
1033 },
1034 "ArrayValue": {
1035 SchemaProps: spec.SchemaProps{
1036 MinItems: ptr.To[int64](1),
1037 MaxItems: ptr.To[int64](5),
1038 UniqueItems: true,
1039 Type: []string{"array"},
1040 Items: &spec.SchemaOrArray{
1041 Schema: &spec.Schema{
1042 SchemaProps: spec.SchemaProps{
1043 Type: []string{"string"},
1044 Format: "",
1045 },
1046 },
1047 },
1048 },
1049 },
1050 "MapValue": {
1051 SchemaProps: spec.SchemaProps{
1052 MinProperties: ptr.To[int64](1),
1053 MaxProperties: ptr.To[int64](5),
1054 Type: []string{"object"},
1055 AdditionalProperties: &spec.SchemaOrBool{
1056 Allows: true,
1057 Schema: &spec.Schema{
1058 SchemaProps: spec.SchemaProps{
1059 Type: []string{"string"},
1060 Format: "",
1061 },
1062 },
1063 },
1064 },
1065 },
1066 "celField": {
1067 VendorExtensible: spec.VendorExtensible{
1068 Extensions: spec.Extensions{
1069 "x-kubernetes-validations": []interface{}{map[string]interface{}{"message": "string message", "rule": "self.length() > 0"}, map[string]interface{}{"messageExpression": "self + ' hello'", "rule": "self.length() % 2 == 0"}},
1070 },
1071 },
1072 SchemaProps: spec.SchemaProps{
1073 Default: "",
1074 Type: []string{"string"},
1075 Format: "",
1076 },
1077 },
1078 },
1079 Required: []string{"ArrayValue", "MapValue"},
1080 },
1081 VendorExtensible: spec.VendorExtensible{
1082 Extensions: spec.Extensions{
1083 "x-kubernetes-validations": []interface{}{map[string]interface{}{"message": "foo", "rule": "self == oldSelf"}},
1084 },
1085 },
1086 },
1087 }
1088 }
1089
1090 func schema_test_integration_testdata_valuevalidation_Foo2(ref common.ReferenceCallback) common.OpenAPIDefinition {
1091 return common.EmbedOpenAPIDefinitionIntoV2Extension(valuevalidation.Foo2{}.OpenAPIV3Definition(), common.OpenAPIDefinition{
1092 Schema: spec.Schema{
1093 SchemaProps: spec.SchemaProps{
1094 Description: "This one has an open API v3 definition",
1095 Type: valuevalidation.Foo2{}.OpenAPISchemaType(),
1096 Format: valuevalidation.Foo2{}.OpenAPISchemaFormat(),
1097 MaxProperties: ptr.To[int64](5),
1098 },
1099 VendorExtensible: spec.VendorExtensible{
1100 Extensions: spec.Extensions{
1101 "x-kubernetes-validations": []interface{}{map[string]interface{}{"message": "foo2", "rule": "self == oldSelf"}},
1102 },
1103 },
1104 },
1105 })
1106 }
1107
1108 func schema_test_integration_testdata_valuevalidation_Foo3(ref common.ReferenceCallback) common.OpenAPIDefinition {
1109 return common.EmbedOpenAPIDefinitionIntoV2Extension(common.OpenAPIDefinition{
1110 Schema: spec.Schema{
1111 SchemaProps: spec.SchemaProps{
1112 Description: "This one has a OneOf",
1113 OneOf: common.GenerateOpenAPIV3OneOfSchema(valuevalidation.Foo3{}.OpenAPIV3OneOfTypes()),
1114 Format: valuevalidation.Foo3{}.OpenAPISchemaFormat(),
1115 MaxProperties: ptr.To[int64](5),
1116 },
1117 VendorExtensible: spec.VendorExtensible{
1118 Extensions: spec.Extensions{
1119 "x-kubernetes-validations": []interface{}{map[string]interface{}{"message": "foo3", "rule": "self == oldSelf"}},
1120 },
1121 },
1122 },
1123 }, common.OpenAPIDefinition{
1124 Schema: spec.Schema{
1125 SchemaProps: spec.SchemaProps{
1126 Description: "This one has a OneOf",
1127 Type: valuevalidation.Foo3{}.OpenAPISchemaType(),
1128 Format: valuevalidation.Foo3{}.OpenAPISchemaFormat(),
1129 MaxProperties: ptr.To[int64](5),
1130 },
1131 VendorExtensible: spec.VendorExtensible{
1132 Extensions: spec.Extensions{
1133 "x-kubernetes-validations": []interface{}{map[string]interface{}{"message": "foo3", "rule": "self == oldSelf"}},
1134 },
1135 },
1136 },
1137 })
1138 }
1139
1140 func schema_test_integration_testdata_valuevalidation_Foo5(ref common.ReferenceCallback) common.OpenAPIDefinition {
1141 return common.EmbedOpenAPIDefinitionIntoV2Extension(valuevalidation.Foo5{}.OpenAPIV3Definition(), common.OpenAPIDefinition{
1142 Schema: spec.Schema{
1143 SchemaProps: spec.SchemaProps{
1144 Type: valuevalidation.Foo5{}.OpenAPISchemaType(),
1145 Format: valuevalidation.Foo5{}.OpenAPISchemaFormat(),
1146 MinProperties: ptr.To[int64](1),
1147 MaxProperties: ptr.To[int64](5),
1148 },
1149 VendorExtensible: spec.VendorExtensible{
1150 Extensions: spec.Extensions{
1151 "x-kubernetes-validations": []interface{}{map[string]interface{}{"message": "foo5", "rule": "self == oldSelf"}},
1152 },
1153 },
1154 },
1155 })
1156 }