Debian Codegraph @

test/integration/pkg/generated/openapi_generated.go

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