diff --git a/.schema/api.swagger.json b/.schema/api.swagger.json index dfc8cc8b61da..1df9c674337f 100755 --- a/.schema/api.swagger.json +++ b/.schema/api.swagger.json @@ -2210,6 +2210,10 @@ }, "recoveryFlowMethod": { "type": "object", + "required": [ + "method", + "config" + ], "properties": { "config": { "$ref": "#/definitions/recoveryFlowMethodConfig" @@ -2308,6 +2312,10 @@ }, "registrationFlowMethod": { "type": "object", + "required": [ + "method", + "config" + ], "properties": { "config": { "$ref": "#/definitions/registrationFlowMethodConfig" @@ -2471,6 +2479,10 @@ }, "settingsFlowMethod": { "type": "object", + "required": [ + "method", + "config" + ], "properties": { "config": { "$ref": "#/definitions/FlowMethodConfig" @@ -2547,6 +2559,10 @@ }, "verificationFlowMethod": { "type": "object", + "required": [ + "method", + "config" + ], "properties": { "config": { "$ref": "#/definitions/verificationFlowMethodConfig" diff --git a/internal/httpclient/models/recovery_flow_method.go b/internal/httpclient/models/recovery_flow_method.go index 2c6539f134d2..e93df2082b02 100644 --- a/internal/httpclient/models/recovery_flow_method.go +++ b/internal/httpclient/models/recovery_flow_method.go @@ -9,6 +9,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" + "github.com/go-openapi/validate" ) // RecoveryFlowMethod recovery flow method @@ -17,10 +18,12 @@ import ( type RecoveryFlowMethod struct { // config - Config *RecoveryFlowMethodConfig `json:"config,omitempty"` + // Required: true + Config *RecoveryFlowMethodConfig `json:"config"` // Method contains the request credentials type. - Method string `json:"method,omitempty"` + // Required: true + Method *string `json:"method"` } // Validate validates this recovery flow method @@ -31,6 +34,10 @@ func (m *RecoveryFlowMethod) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateMethod(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -39,8 +46,8 @@ func (m *RecoveryFlowMethod) Validate(formats strfmt.Registry) error { func (m *RecoveryFlowMethod) validateConfig(formats strfmt.Registry) error { - if swag.IsZero(m.Config) { // not required - return nil + if err := validate.Required("config", "body", m.Config); err != nil { + return err } if m.Config != nil { @@ -55,6 +62,15 @@ func (m *RecoveryFlowMethod) validateConfig(formats strfmt.Registry) error { return nil } +func (m *RecoveryFlowMethod) validateMethod(formats strfmt.Registry) error { + + if err := validate.Required("method", "body", m.Method); err != nil { + return err + } + + return nil +} + // MarshalBinary interface implementation func (m *RecoveryFlowMethod) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/internal/httpclient/models/registration_flow_method.go b/internal/httpclient/models/registration_flow_method.go index 11c49dc2d4f7..99f50031de5e 100644 --- a/internal/httpclient/models/registration_flow_method.go +++ b/internal/httpclient/models/registration_flow_method.go @@ -9,6 +9,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" + "github.com/go-openapi/validate" ) // RegistrationFlowMethod registration flow method @@ -17,10 +18,12 @@ import ( type RegistrationFlowMethod struct { // config - Config *RegistrationFlowMethodConfig `json:"config,omitempty"` + // Required: true + Config *RegistrationFlowMethodConfig `json:"config"` // method - Method CredentialsType `json:"method,omitempty"` + // Required: true + Method CredentialsType `json:"method"` } // Validate validates this registration flow method @@ -43,8 +46,8 @@ func (m *RegistrationFlowMethod) Validate(formats strfmt.Registry) error { func (m *RegistrationFlowMethod) validateConfig(formats strfmt.Registry) error { - if swag.IsZero(m.Config) { // not required - return nil + if err := validate.Required("config", "body", m.Config); err != nil { + return err } if m.Config != nil { @@ -61,10 +64,6 @@ func (m *RegistrationFlowMethod) validateConfig(formats strfmt.Registry) error { func (m *RegistrationFlowMethod) validateMethod(formats strfmt.Registry) error { - if swag.IsZero(m.Method) { // not required - return nil - } - if err := m.Method.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("method") diff --git a/internal/httpclient/models/settings_flow_method.go b/internal/httpclient/models/settings_flow_method.go index 073ac8629a73..cf38c9a031c3 100644 --- a/internal/httpclient/models/settings_flow_method.go +++ b/internal/httpclient/models/settings_flow_method.go @@ -9,6 +9,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" + "github.com/go-openapi/validate" ) // SettingsFlowMethod settings flow method @@ -17,10 +18,12 @@ import ( type SettingsFlowMethod struct { // config - Config *FlowMethodConfig `json:"config,omitempty"` + // Required: true + Config *FlowMethodConfig `json:"config"` // Method is the name of this flow method. - Method string `json:"method,omitempty"` + // Required: true + Method *string `json:"method"` } // Validate validates this settings flow method @@ -31,6 +34,10 @@ func (m *SettingsFlowMethod) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateMethod(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -39,8 +46,8 @@ func (m *SettingsFlowMethod) Validate(formats strfmt.Registry) error { func (m *SettingsFlowMethod) validateConfig(formats strfmt.Registry) error { - if swag.IsZero(m.Config) { // not required - return nil + if err := validate.Required("config", "body", m.Config); err != nil { + return err } if m.Config != nil { @@ -55,6 +62,15 @@ func (m *SettingsFlowMethod) validateConfig(formats strfmt.Registry) error { return nil } +func (m *SettingsFlowMethod) validateMethod(formats strfmt.Registry) error { + + if err := validate.Required("method", "body", m.Method); err != nil { + return err + } + + return nil +} + // MarshalBinary interface implementation func (m *SettingsFlowMethod) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/internal/httpclient/models/verification_flow_method.go b/internal/httpclient/models/verification_flow_method.go index 320749f5210a..ae4bf2b20503 100644 --- a/internal/httpclient/models/verification_flow_method.go +++ b/internal/httpclient/models/verification_flow_method.go @@ -9,6 +9,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" + "github.com/go-openapi/validate" ) // VerificationFlowMethod verification flow method @@ -17,10 +18,12 @@ import ( type VerificationFlowMethod struct { // config - Config *VerificationFlowMethodConfig `json:"config,omitempty"` + // Required: true + Config *VerificationFlowMethodConfig `json:"config"` // Method contains the request credentials type. - Method string `json:"method,omitempty"` + // Required: true + Method *string `json:"method"` } // Validate validates this verification flow method @@ -31,6 +34,10 @@ func (m *VerificationFlowMethod) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateMethod(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -39,8 +46,8 @@ func (m *VerificationFlowMethod) Validate(formats strfmt.Registry) error { func (m *VerificationFlowMethod) validateConfig(formats strfmt.Registry) error { - if swag.IsZero(m.Config) { // not required - return nil + if err := validate.Required("config", "body", m.Config); err != nil { + return err } if m.Config != nil { @@ -55,6 +62,15 @@ func (m *VerificationFlowMethod) validateConfig(formats strfmt.Registry) error { return nil } +func (m *VerificationFlowMethod) validateMethod(formats strfmt.Registry) error { + + if err := validate.Required("method", "body", m.Method); err != nil { + return err + } + + return nil +} + // MarshalBinary interface implementation func (m *VerificationFlowMethod) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/selfservice/flow/recovery/flow_method.go b/selfservice/flow/recovery/flow_method.go index 4d204971348b..20ebceab810a 100644 --- a/selfservice/flow/recovery/flow_method.go +++ b/selfservice/flow/recovery/flow_method.go @@ -15,9 +15,13 @@ import ( // swagger:model recoveryFlowMethod type FlowMethod struct { // Method contains the request credentials type. + // + // required: true Method string `json:"method" db:"method"` // Config is the credential type's config. + // + // required: true Config *FlowMethodConfig `json:"config" db:"config"` // ID is a helper struct field for gobuffalo.pop. diff --git a/selfservice/flow/registration/flow_method.go b/selfservice/flow/registration/flow_method.go index 5027e3aeb1d0..bbad4c186d36 100644 --- a/selfservice/flow/registration/flow_method.go +++ b/selfservice/flow/registration/flow_method.go @@ -16,9 +16,13 @@ import ( // swagger:model registrationFlowMethod type FlowMethod struct { // Method contains the flow method's credentials type. + // + // required: true Method identity.CredentialsType `json:"method" faker:"string" db:"method"` // Config is the credential type's config. + // + // required: true Config *FlowMethodConfig `json:"config" db:"config"` // ID is a helper struct field for gobuffalo.pop. diff --git a/selfservice/flow/settings/flow_method.go b/selfservice/flow/settings/flow_method.go index a27ce12e73a6..a86a7cac69ba 100644 --- a/selfservice/flow/settings/flow_method.go +++ b/selfservice/flow/settings/flow_method.go @@ -15,9 +15,13 @@ import ( // swagger:model settingsFlowMethod type FlowMethod struct { // Method is the name of this flow method. + // + // required: true Method string `json:"method" db:"method"` // Config is the credential type's config. + // + // required: true Config *FlowMethodConfig `json:"config" db:"config"` // ID is a helper struct field for gobuffalo.pop. diff --git a/selfservice/flow/verification/flow_method.go b/selfservice/flow/verification/flow_method.go index 5cdecdde3977..de5a1010552f 100644 --- a/selfservice/flow/verification/flow_method.go +++ b/selfservice/flow/verification/flow_method.go @@ -15,9 +15,13 @@ import ( // swagger:model verificationFlowMethod type FlowMethod struct { // Method contains the request credentials type. + // + // required: true Method string `json:"method" db:"method"` // Config is the credential type's config. + // + // required: true Config *FlowMethodConfig `json:"config" db:"config"` // ID is a helper struct field for gobuffalo.pop. diff --git a/selfservice/strategy/oidc/strategy_settings_test.go b/selfservice/strategy/oidc/strategy_settings_test.go index c13170c9c0d7..98d0c97d1853 100644 --- a/selfservice/strategy/oidc/strategy_settings_test.go +++ b/selfservice/strategy/oidc/strategy_settings_test.go @@ -189,7 +189,7 @@ func TestSettingsStrategy(t *testing.T) { assert.EqualValues(t, req.IssuedAt, time.Time(*rs.Payload.IssuedAt)) require.NotNil(t, identity.CredentialsTypeOIDC.String(), rs.Payload.Methods[identity.CredentialsTypeOIDC.String()]) - require.EqualValues(t, identity.CredentialsTypeOIDC.String(), rs.Payload.Methods[identity.CredentialsTypeOIDC.String()].Method) + require.EqualValues(t, identity.CredentialsTypeOIDC.String(), *rs.Payload.Methods[identity.CredentialsTypeOIDC.String()].Method) require.EqualValues(t, publicTS.URL+oidc.SettingsPath+"?flow="+req.ID.String(), *rs.Payload.Methods[identity.CredentialsTypeOIDC.String()].Config.Action) })