@@ -20,11 +20,23 @@ enum NormalEnum {
2020 D ,
2121}
2222
23+ #[ derive( Serialize , Deserialize , Debug , Clone , JsonSchema ) ]
24+ pub enum NormalEnumWithoutDescriptions {
25+ A ,
26+ B ,
27+ C ,
28+ D ,
29+ }
30+
2331/// A complex enum with unit and struct variants
2432#[ derive( Serialize , Deserialize , Debug , Clone , JsonSchema ) ]
2533enum ComplexEnum {
2634 Normal ( NormalEnum ) ,
27- Hardcore { hard : String , core : NormalEnum } ,
35+ Hardcore {
36+ hard : String ,
37+ core : NormalEnum ,
38+ without_description : NormalEnumWithoutDescriptions ,
39+ } ,
2840}
2941
3042/// An untagged enum with a nested enum inside
@@ -60,6 +72,26 @@ struct OptionalEnumTestSpec {
6072 foo : Option < NormalEnum > ,
6173}
6274
75+ #[ derive( CustomResource , Serialize , Deserialize , Debug , Clone , JsonSchema ) ]
76+ #[ kube(
77+ group = "clux.dev" ,
78+ version = "v1" ,
79+ kind = "NormalEnumWithoutDescriptionsTest"
80+ ) ]
81+ struct NormalEnumWithoutDescriptionsTestSpec {
82+ foo : NormalEnumWithoutDescriptions ,
83+ }
84+
85+ #[ derive( CustomResource , Serialize , Deserialize , Debug , Clone , JsonSchema ) ]
86+ #[ kube(
87+ group = "clux.dev" ,
88+ version = "v1" ,
89+ kind = "OptionalEnumWithoutDescriptionsTest"
90+ ) ]
91+ struct OptionalEnumWithoutDescriptionsTestSpec {
92+ foo : Option < NormalEnumWithoutDescriptions > ,
93+ }
94+
6395#[ derive( CustomResource , Serialize , Deserialize , Debug , Clone , JsonSchema ) ]
6496#[ kube( group = "clux.dev" , version = "v1" , kind = "ComplexEnumTest" ) ]
6597struct ComplexEnumTestSpec {
@@ -98,6 +130,16 @@ fn print_crds() {
98130 println ! ( "---" ) ;
99131 println ! ( "{}" , serde_yaml:: to_string( & OptionalEnumTest :: crd( ) ) . unwrap( ) ) ;
100132 println ! ( "---" ) ;
133+ println ! (
134+ "{}" ,
135+ serde_yaml:: to_string( & NormalEnumWithoutDescriptionsTest :: crd( ) ) . unwrap( )
136+ ) ;
137+ println ! ( "---" ) ;
138+ println ! (
139+ "{}" ,
140+ serde_yaml:: to_string( & OptionalEnumWithoutDescriptionsTest :: crd( ) ) . unwrap( )
141+ ) ;
142+ println ! ( "---" ) ;
101143 println ! ( "{}" , serde_yaml:: to_string( & ComplexEnumTest :: crd( ) ) . unwrap( ) ) ;
102144 println ! ( "---" ) ;
103145 println ! (
@@ -249,6 +291,135 @@ fn optional_enum() {
249291}
250292
251293
294+ #[ test]
295+ fn normal_enum_without_descriptions ( ) {
296+ assert_json_eq ! (
297+ NormalEnumWithoutDescriptionsTest :: crd( ) ,
298+ json!(
299+ {
300+ "apiVersion" : "apiextensions.k8s.io/v1" ,
301+ "kind" : "CustomResourceDefinition" ,
302+ "metadata" : {
303+ "name" : "normalenumwithoutdescriptionstests.clux.dev"
304+ } ,
305+ "spec" : {
306+ "group" : "clux.dev" ,
307+ "names" : {
308+ "categories" : [ ] ,
309+ "kind" : "NormalEnumWithoutDescriptionsTest" ,
310+ "plural" : "normalenumwithoutdescriptionstests" ,
311+ "shortNames" : [ ] ,
312+ "singular" : "normalenumwithoutdescriptionstest"
313+ } ,
314+ "scope" : "Cluster" ,
315+ "versions" : [
316+ {
317+ "additionalPrinterColumns" : [ ] ,
318+ "name" : "v1" ,
319+ "schema" : {
320+ "openAPIV3Schema" : {
321+ "description" : "Auto-generated derived type for NormalEnumWithoutDescriptionsTestSpec via `CustomResource`" ,
322+ "properties" : {
323+ "spec" : {
324+ "properties" : {
325+ "foo" : {
326+ "enum" : [
327+ "A" ,
328+ "B" ,
329+ "C" ,
330+ "D"
331+ ] ,
332+ "type" : "string"
333+ }
334+ } ,
335+ "required" : [
336+ "foo"
337+ ] ,
338+ "type" : "object"
339+ }
340+ } ,
341+ "required" : [
342+ "spec"
343+ ] ,
344+ "title" : "NormalEnumWithoutDescriptionsTest" ,
345+ "type" : "object"
346+ }
347+ } ,
348+ "served" : true ,
349+ "storage" : true ,
350+ "subresources" : { }
351+ }
352+ ]
353+ }
354+ }
355+ )
356+ ) ;
357+ }
358+
359+ #[ test]
360+ fn optional_enum_without_descriptions ( ) {
361+ assert_json_eq ! (
362+ OptionalEnumWithoutDescriptionsTest :: crd( ) ,
363+ json!(
364+ {
365+ "apiVersion" : "apiextensions.k8s.io/v1" ,
366+ "kind" : "CustomResourceDefinition" ,
367+ "metadata" : {
368+ "name" : "optionalenumwithoutdescriptionstests.clux.dev"
369+ } ,
370+ "spec" : {
371+ "group" : "clux.dev" ,
372+ "names" : {
373+ "categories" : [ ] ,
374+ "kind" : "OptionalEnumWithoutDescriptionsTest" ,
375+ "plural" : "optionalenumwithoutdescriptionstests" ,
376+ "shortNames" : [ ] ,
377+ "singular" : "optionalenumwithoutdescriptionstest"
378+ } ,
379+ "scope" : "Cluster" ,
380+ "versions" : [
381+ {
382+ "additionalPrinterColumns" : [ ] ,
383+ "name" : "v1" ,
384+ "schema" : {
385+ "openAPIV3Schema" : {
386+ "description" : "Auto-generated derived type for OptionalEnumWithoutDescriptionsTestSpec via `CustomResource`" ,
387+ "properties" : {
388+ "spec" : {
389+ "properties" : {
390+ "foo" : {
391+ "enum" : [
392+ "A" ,
393+ "B" ,
394+ "C" ,
395+ "D" ,
396+ // Note there is *no* null list entry here
397+ ] ,
398+ "nullable" : true ,
399+ "type" : "string"
400+ }
401+ } ,
402+ "type" : "object"
403+ }
404+ } ,
405+ "required" : [
406+ "spec"
407+ ] ,
408+ "title" : "OptionalEnumWithoutDescriptionsTest" ,
409+ "type" : "object"
410+ }
411+ } ,
412+ "served" : true ,
413+ "storage" : true ,
414+ "subresources" : { }
415+ }
416+ ]
417+ }
418+ }
419+ )
420+ ) ;
421+ }
422+
252423#[ test]
253424fn complex_enum ( ) {
254425 assert_json_eq ! ( ComplexEnumTest :: crd( ) , json!( 42 ) ) ;
0 commit comments