Skip to content

Commit 605c952

Browse files
luksastaebler
authored andcommitted
Fix required fields in OpenAPI schema (openshift#1602)
* Fix openapi schema (some fields are unnecessarily marked as required) * Add +optional to all Spec and Status properties
1 parent 899ca21 commit 605c952

File tree

2 files changed

+92
-37
lines changed

2 files changed

+92
-37
lines changed

Diff for: pkg/apis/servicecatalog/v1beta1/types.go

+61-14
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,19 @@ import (
2929
// ClusterServiceClasses for use in the service catalog.
3030
type ClusterServiceBroker struct {
3131
metav1.TypeMeta `json:",inline"`
32+
3233
// Non-namespaced. The name of this resource in etcd is in ObjectMeta.Name.
34+
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
35+
// +optional
3336
metav1.ObjectMeta `json:"metadata,omitempty"`
3437

35-
Spec ClusterServiceBrokerSpec `json:"spec"`
36-
Status ClusterServiceBrokerStatus `json:"status"`
38+
// Spec defines the behavior of the broker.
39+
// +optional
40+
Spec ClusterServiceBrokerSpec `json:"spec,omitempty"`
41+
42+
// Status represents the current status of a broker.
43+
// +optional
44+
Status ClusterServiceBrokerStatus `json:"status,omitempty"`
3745
}
3846

3947
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
@@ -66,6 +74,7 @@ type ClusterServiceBrokerSpec struct {
6674

6775
// RelistBehavior specifies the type of relist behavior the catalog should
6876
// exhibit when relisting ClusterServiceClasses available from a broker.
77+
// +optional
6978
RelistBehavior ServiceBrokerRelistBehavior `json:"relistBehavior"`
7079

7180
// RelistDuration is the frequency by which a controller will relist the
@@ -226,11 +235,20 @@ type ClusterServiceClassList struct {
226235

227236
// ClusterServiceClass represents an offering in the service catalog.
228237
type ClusterServiceClass struct {
229-
metav1.TypeMeta `json:",inline"`
238+
metav1.TypeMeta `json:",inline"`
239+
240+
// Non-namespaced. The name of this resource in etcd is in ObjectMeta.Name.
241+
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
242+
// +optional
230243
metav1.ObjectMeta `json:"metadata,omitempty"`
231244

232-
Spec ClusterServiceClassSpec `json:"spec"`
233-
Status ClusterServiceClassStatus `json:"status"`
245+
// Spec defines the behavior of the service class.
246+
// +optional
247+
Spec ClusterServiceClassSpec `json:"spec,omitempty"`
248+
249+
// Status represents the current status of the service class.
250+
// +optional
251+
Status ClusterServiceClassStatus `json:"status,omitempty"`
234252
}
235253

236254
// ClusterServiceClassSpec represents details about the ClusterServicePlan
@@ -321,11 +339,20 @@ type ClusterServicePlanList struct {
321339

322340
// ClusterServicePlan represents a tier of a ServiceClass.
323341
type ClusterServicePlan struct {
324-
metav1.TypeMeta `json:",inline"`
342+
metav1.TypeMeta `json:",inline"`
343+
344+
// Non-namespaced. The name of this resource in etcd is in ObjectMeta.Name.
345+
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
346+
// +optional
325347
metav1.ObjectMeta `json:"metadata,omitempty"`
326348

327-
Spec ClusterServicePlanSpec `json:"spec"`
328-
Status ClusterServicePlanStatus `json:"status"`
349+
// Spec defines the behavior of the service plan.
350+
// +optional
351+
Spec ClusterServicePlanSpec `json:"spec,omitempty"`
352+
353+
// Status represents the current status of the service plan.
354+
// +optional
355+
Status ClusterServicePlanStatus `json:"status,omitempty"`
329356
}
330357

331358
// ClusterServicePlanSpec represents details about a ClusterServicePlan.
@@ -428,11 +455,20 @@ type ExtraValue []string
428455
// the ServiceInstance should have the plan and/or parameters updated at the
429456
// ClusterServiceBroker.
430457
type ServiceInstance struct {
431-
metav1.TypeMeta `json:",inline"`
458+
metav1.TypeMeta `json:",inline"`
459+
460+
// The name of this resource in etcd is in ObjectMeta.Name.
461+
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
462+
// +optional
432463
metav1.ObjectMeta `json:"metadata,omitempty"`
433464

434-
Spec ServiceInstanceSpec `json:"spec"`
435-
Status ServiceInstanceStatus `json:"status"`
465+
// Spec defines the behavior of the service instance.
466+
// +optional
467+
Spec ServiceInstanceSpec `json:"spec,omitempty"`
468+
469+
// Status represents the current status of a service instance.
470+
// +optional
471+
Status ServiceInstanceStatus `json:"status,omitempty"`
436472
}
437473

438474
// PlanReference defines the user specification for the desired
@@ -511,6 +547,7 @@ type ServiceInstanceSpec struct {
511547
// ExternalID is the identity of this object for use with the OSB SB API.
512548
//
513549
// Immutable.
550+
// +optional
514551
ExternalID string `json:"externalID"`
515552

516553
// Currently, this field is ALPHA: it may change or disappear at any time
@@ -692,11 +729,20 @@ type ServiceBindingList struct {
692729
// ServiceBinding represents a "used by" relationship between an application and an
693730
// ServiceInstance.
694731
type ServiceBinding struct {
695-
metav1.TypeMeta `json:",inline"`
732+
metav1.TypeMeta `json:",inline"`
733+
734+
// The name of this resource in etcd is in ObjectMeta.Name.
735+
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
736+
// +optional
696737
metav1.ObjectMeta `json:"metadata,omitempty"`
697738

698-
Spec ServiceBindingSpec `json:"spec"`
699-
Status ServiceBindingStatus `json:"status"`
739+
// Spec represents the desired state of a ServiceBinding.
740+
// +optional
741+
Spec ServiceBindingSpec `json:"spec,omitempty"`
742+
743+
// Status represents the current status of a ServiceBinding.
744+
// +optional
745+
Status ServiceBindingStatus `json:"status,omitempty"`
700746
}
701747

702748
// ServiceBindingSpec represents the desired state of a
@@ -738,6 +784,7 @@ type ServiceBindingSpec struct {
738784
// ExternalID is the identity of this object for use with the OSB API.
739785
//
740786
// Immutable.
787+
// +optional
741788
ExternalID string `json:"externalID"`
742789

743790
// Currently, this field is ALPHA: it may change or disappear at any time

Diff for: pkg/openapi/openapi_generated.go

+31-23
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,23 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
100100
},
101101
"metadata": {
102102
SchemaProps: spec.SchemaProps{
103-
Description: "Non-namespaced. The name of this resource in etcd is in ObjectMeta.Name.",
103+
Description: "Non-namespaced. The name of this resource in etcd is in ObjectMeta.Name. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata",
104104
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
105105
},
106106
},
107107
"spec": {
108108
SchemaProps: spec.SchemaProps{
109-
Ref: ref("github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ClusterServiceBrokerSpec"),
109+
Description: "Spec defines the behavior of the broker.",
110+
Ref: ref("github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ClusterServiceBrokerSpec"),
110111
},
111112
},
112113
"status": {
113114
SchemaProps: spec.SchemaProps{
114-
Ref: ref("github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ClusterServiceBrokerStatus"),
115+
Description: "Status represents the current status of a broker.",
116+
Ref: ref("github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ClusterServiceBrokerStatus"),
115117
},
116118
},
117119
},
118-
Required: []string{"spec", "status"},
119120
},
120121
},
121122
Dependencies: []string{
@@ -217,7 +218,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
217218
},
218219
},
219220
},
220-
Required: []string{"url", "relistBehavior"},
221+
Required: []string{"url"},
221222
},
222223
},
223224
Dependencies: []string{
@@ -287,21 +288,23 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
287288
},
288289
"metadata": {
289290
SchemaProps: spec.SchemaProps{
290-
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
291+
Description: "Non-namespaced. The name of this resource in etcd is in ObjectMeta.Name. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata",
292+
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
291293
},
292294
},
293295
"spec": {
294296
SchemaProps: spec.SchemaProps{
295-
Ref: ref("github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ClusterServiceClassSpec"),
297+
Description: "Spec defines the behavior of the service class.",
298+
Ref: ref("github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ClusterServiceClassSpec"),
296299
},
297300
},
298301
"status": {
299302
SchemaProps: spec.SchemaProps{
300-
Ref: ref("github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ClusterServiceClassStatus"),
303+
Description: "Status represents the current status of the service class.",
304+
Ref: ref("github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ClusterServiceClassStatus"),
301305
},
302306
},
303307
},
304-
Required: []string{"spec", "status"},
305308
},
306309
},
307310
Dependencies: []string{
@@ -484,21 +487,23 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
484487
},
485488
"metadata": {
486489
SchemaProps: spec.SchemaProps{
487-
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
490+
Description: "Non-namespaced. The name of this resource in etcd is in ObjectMeta.Name. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata",
491+
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
488492
},
489493
},
490494
"spec": {
491495
SchemaProps: spec.SchemaProps{
492-
Ref: ref("github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ClusterServicePlanSpec"),
496+
Description: "Spec defines the behavior of the service plan.",
497+
Ref: ref("github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ClusterServicePlanSpec"),
493498
},
494499
},
495500
"status": {
496501
SchemaProps: spec.SchemaProps{
497-
Ref: ref("github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ClusterServicePlanStatus"),
502+
Description: "Status represents the current status of the service plan.",
503+
Ref: ref("github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ClusterServicePlanStatus"),
498504
},
499505
},
500506
},
501-
Required: []string{"spec", "status"},
502507
},
503508
},
504509
Dependencies: []string{
@@ -791,21 +796,23 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
791796
},
792797
"metadata": {
793798
SchemaProps: spec.SchemaProps{
794-
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
799+
Description: "The name of this resource in etcd is in ObjectMeta.Name. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata",
800+
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
795801
},
796802
},
797803
"spec": {
798804
SchemaProps: spec.SchemaProps{
799-
Ref: ref("github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ServiceBindingSpec"),
805+
Description: "Spec represents the desired state of a ServiceBinding.",
806+
Ref: ref("github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ServiceBindingSpec"),
800807
},
801808
},
802809
"status": {
803810
SchemaProps: spec.SchemaProps{
804-
Ref: ref("github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ServiceBindingStatus"),
811+
Description: "Status represents the current status of a ServiceBinding.",
812+
Ref: ref("github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ServiceBindingStatus"),
805813
},
806814
},
807815
},
808-
Required: []string{"spec", "status"},
809816
},
810817
},
811818
Dependencies: []string{
@@ -981,7 +988,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
981988
},
982989
},
983990
},
984-
Required: []string{"instanceRef", "externalID"},
991+
Required: []string{"instanceRef"},
985992
},
986993
},
987994
Dependencies: []string{
@@ -1161,21 +1168,23 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
11611168
},
11621169
"metadata": {
11631170
SchemaProps: spec.SchemaProps{
1164-
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
1171+
Description: "The name of this resource in etcd is in ObjectMeta.Name. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata",
1172+
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
11651173
},
11661174
},
11671175
"spec": {
11681176
SchemaProps: spec.SchemaProps{
1169-
Ref: ref("github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ServiceInstanceSpec"),
1177+
Description: "Spec defines the behavior of the service instance.",
1178+
Ref: ref("github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ServiceInstanceSpec"),
11701179
},
11711180
},
11721181
"status": {
11731182
SchemaProps: spec.SchemaProps{
1174-
Ref: ref("github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ServiceInstanceStatus"),
1183+
Description: "Status represents the current status of a service instance.",
1184+
Ref: ref("github.com/kubernetes-incubator/service-catalog/pkg/apis/servicecatalog/v1beta1.ServiceInstanceStatus"),
11751185
},
11761186
},
11771187
},
1178-
Required: []string{"spec", "status"},
11791188
},
11801189
},
11811190
Dependencies: []string{
@@ -1400,7 +1409,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
14001409
},
14011410
},
14021411
},
1403-
Required: []string{"externalID"},
14041412
},
14051413
},
14061414
Dependencies: []string{

0 commit comments

Comments
 (0)