Skip to content

Commit 337db7a

Browse files
authored
Relax OpenAPI validation for some objects that can be Unmarshaled as two different types (#167)
1 parent d4781e3 commit 337db7a

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

model/states.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ type BaseState struct {
6060
// +optional
6161
OnErrors []OnError `json:"onErrors,omitempty" validate:"omitempty,dive"`
6262
// Next transition of the workflow after the time delay.
63+
// +kubebuilder:validation:Schemaless
64+
// +kubebuilder:pruning:PreserveUnknownFields
6365
// +optional
6466
Transition *Transition `json:"transition,omitempty"`
6567
// State data filter.
@@ -72,6 +74,8 @@ type BaseState struct {
7274
// +optional
7375
UsedForCompensation bool `json:"usedForCompensation,omitempty"`
7476
// State end definition.
77+
// +kubebuilder:validation:Schemaless
78+
// +kubebuilder:pruning:PreserveUnknownFields
7579
// +optional
7680
End *End `json:"end,omitempty"`
7781
// Metadata information.

model/switch_state.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,13 @@ type SwitchState struct {
4040
type DefaultCondition struct {
4141
// Serverless workflow states can have one or more incoming and outgoing transitions (from/to other states).
4242
// Each state can define a transition definition that is used to determine which state to transition to next.
43+
// +kubebuilder:validation:Schemaless
44+
// +kubebuilder:pruning:PreserveUnknownFields
4345
// +optional
4446
Transition *Transition `json:"transition,omitempty"`
4547
// If this state an end state
48+
// +kubebuilder:validation:Schemaless
49+
// +kubebuilder:pruning:PreserveUnknownFields
4650
// +optional
4751
End *End `json:"end,omitempty"`
4852
}
@@ -101,12 +105,20 @@ type EventCondition struct {
101105
// +optional
102106
EventDataFilter *EventDataFilter `json:"eventDataFilter,omitempty"`
103107
// Metadata information.
108+
// +kubebuilder:validation:Schemaless
109+
// +kubebuilder:pruning:PreserveUnknownFields
104110
// +optional
105111
Metadata Metadata `json:"metadata,omitempty"`
106112
// TODO End or Transition needs to be exclusive tag, one or another should be set.
107113
// Explicit transition to end
114+
// +kubebuilder:validation:Schemaless
115+
// +kubebuilder:pruning:PreserveUnknownFields
116+
// +optional
108117
End *End `json:"end" validate:"omitempty"`
109118
// Workflow transition if condition is evaluated to true
119+
// +kubebuilder:validation:Schemaless
120+
// +kubebuilder:pruning:PreserveUnknownFields
121+
// +optional
110122
Transition *Transition `json:"transition" validate:"omitempty"`
111123
}
112124

model/workflow.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ type InvokeKind string
2626
const (
2727
// InvokeKindSync meaning that worfklow execution should wait until the target completes.
2828
InvokeKindSync InvokeKind = "sync"
29-
30-
// InvokeKindAsync meaning that workflow execution should just invoke the target and should not wait until its completion.
29+
// InvokeKindAsync meaning that workflow execution should just invoke the target and should not wait until its
30+
// completion.
3131
InvokeKindAsync InvokeKind = "async"
3232
)
3333

@@ -75,6 +75,8 @@ type BaseWorkflow struct {
7575
// +optional
7676
Version string `json:"version" validate:"omitempty,min=1"`
7777
// Workflow start definition.
78+
// +kubebuilder:validation:Schemaless
79+
// +kubebuilder:pruning:PreserveUnknownFields
7880
// +optional
7981
Start *Start `json:"start,omitempty"`
8082
// Annotations List of helpful terms describing the workflows intended purpose, subject areas, or other important
@@ -112,6 +114,8 @@ type BaseWorkflow struct {
112114
// +optional
113115
KeepActive bool `json:"keepActive,omitempty"`
114116
// Metadata custom information shared with the runtime.
117+
// +kubebuilder:validation:Schemaless
118+
// +kubebuilder:pruning:PreserveUnknownFields
115119
// +optional
116120
Metadata Metadata `json:"metadata,omitempty"`
117121
// AutoRetries If set to true, actions should automatically be retried on unchecked errors. Default is false
@@ -120,6 +124,8 @@ type BaseWorkflow struct {
120124
// Auth definitions can be used to define authentication information that should be applied to resources defined
121125
// in the operation property of function definitions. It is not used as authentication information for the
122126
// function invocation, but just to access the resource containing the function invocation information.
127+
// +kubebuilder:validation:Schemaless
128+
// +kubebuilder:pruning:PreserveUnknownFields
123129
// +optional
124130
Auth AuthArray `json:"auth,omitempty" validate:"omitempty"`
125131
}
@@ -524,9 +530,17 @@ type OnError struct {
524530
ErrorRef string `json:"errorRef,omitempty"`
525531
// ErrorRefs References one or more workflow error definitions. Used if errorRef is not used
526532
ErrorRefs []string `json:"errorRefs,omitempty"`
527-
// Transition to next state to handle the error. If retryRef is defined, this transition is taken only if retries were unsuccessful.
533+
// Transition to next state to handle the error. If retryRef is defined, this transition is taken only if
534+
// retries were unsuccessful.
535+
// +kubebuilder:validation:Schemaless
536+
// +kubebuilder:pruning:PreserveUnknownFields
537+
// +optional
528538
Transition *Transition `json:"transition,omitempty"`
529-
// End workflow execution in case of this error. If retryRef is defined, this ends workflow only if retries were unsuccessful.
539+
// End workflow execution in case of this error. If retryRef is defined, this ends workflow only if
540+
// retries were unsuccessful.
541+
// +kubebuilder:validation:Schemaless
542+
// +kubebuilder:pruning:PreserveUnknownFields
543+
// +optional
530544
End *End `json:"end,omitempty"`
531545
}
532546

0 commit comments

Comments
 (0)