From f2db1d48a70c2107022311b098480069669ef275 Mon Sep 17 00:00:00 2001 From: Alano Terblanche <18033717+Benehiko@users.noreply.github.com> Date: Tue, 22 Aug 2023 14:14:31 +0200 Subject: [PATCH] fix: sdk login and registrion should contain code method --- .schema/openapi/patches/selfservice.yaml | 4 +++ .../client-go/model_update_login_flow_body.go | 30 +++++++++++++++++++ .../model_update_registration_flow_body.go | 30 +++++++++++++++++++ .../model_update_login_flow_body.go | 30 +++++++++++++++++++ .../model_update_registration_flow_body.go | 30 +++++++++++++++++++ spec/api.json | 8 +++++ 6 files changed, 132 insertions(+) diff --git a/.schema/openapi/patches/selfservice.yaml b/.schema/openapi/patches/selfservice.yaml index 102c1fe60deb..a966cf27401e 100644 --- a/.schema/openapi/patches/selfservice.yaml +++ b/.schema/openapi/patches/selfservice.yaml @@ -17,6 +17,7 @@ - "$ref": "#/components/schemas/updateRegistrationFlowWithPasswordMethod" - "$ref": "#/components/schemas/updateRegistrationFlowWithOidcMethod" - "$ref": "#/components/schemas/updateRegistrationFlowWithWebAuthnMethod" + - "$ref": "#/components/schemas/updateRegistrationFlowWithCodeMethod" - op: add path: /components/schemas/updateRegistrationFlowBody/discriminator value: @@ -25,6 +26,7 @@ password: "#/components/schemas/updateRegistrationFlowWithPasswordMethod" oidc: "#/components/schemas/updateRegistrationFlowWithOidcMethod" webauthn: "#/components/schemas/updateRegistrationFlowWithWebAuthnMethod" + code: "#/components/schemas/updateRegistrationFlowWithCodeMethod" - op: add path: /components/schemas/registrationFlowState/enum value: @@ -44,6 +46,7 @@ - "$ref": "#/components/schemas/updateLoginFlowWithTotpMethod" - "$ref": "#/components/schemas/updateLoginFlowWithWebAuthnMethod" - "$ref": "#/components/schemas/updateLoginFlowWithLookupSecretMethod" + - "$ref": "#/components/schemas/updateLoginFlowWithCodeMethod" - op: add path: /components/schemas/updateLoginFlowBody/discriminator value: @@ -54,6 +57,7 @@ totp: "#/components/schemas/updateLoginFlowWithTotpMethod" webauthn: "#/components/schemas/updateLoginFlowWithWebAuthnMethod" lookup_secret: "#/components/schemas/updateLoginFlowWithLookupSecretMethod" + code: "#/components/schemas/updateLoginFlowWithCodeMethod" - op: add path: /components/schemas/loginFlowState/enum value: diff --git a/internal/client-go/model_update_login_flow_body.go b/internal/client-go/model_update_login_flow_body.go index 1aa032062a4b..36033328e78d 100644 --- a/internal/client-go/model_update_login_flow_body.go +++ b/internal/client-go/model_update_login_flow_body.go @@ -18,6 +18,7 @@ import ( // UpdateLoginFlowBody - struct for UpdateLoginFlowBody type UpdateLoginFlowBody struct { + UpdateLoginFlowWithCodeMethod *UpdateLoginFlowWithCodeMethod UpdateLoginFlowWithLookupSecretMethod *UpdateLoginFlowWithLookupSecretMethod UpdateLoginFlowWithOidcMethod *UpdateLoginFlowWithOidcMethod UpdateLoginFlowWithPasswordMethod *UpdateLoginFlowWithPasswordMethod @@ -25,6 +26,13 @@ type UpdateLoginFlowBody struct { UpdateLoginFlowWithWebAuthnMethod *UpdateLoginFlowWithWebAuthnMethod } +// UpdateLoginFlowWithCodeMethodAsUpdateLoginFlowBody is a convenience function that returns UpdateLoginFlowWithCodeMethod wrapped in UpdateLoginFlowBody +func UpdateLoginFlowWithCodeMethodAsUpdateLoginFlowBody(v *UpdateLoginFlowWithCodeMethod) UpdateLoginFlowBody { + return UpdateLoginFlowBody{ + UpdateLoginFlowWithCodeMethod: v, + } +} + // UpdateLoginFlowWithLookupSecretMethodAsUpdateLoginFlowBody is a convenience function that returns UpdateLoginFlowWithLookupSecretMethod wrapped in UpdateLoginFlowBody func UpdateLoginFlowWithLookupSecretMethodAsUpdateLoginFlowBody(v *UpdateLoginFlowWithLookupSecretMethod) UpdateLoginFlowBody { return UpdateLoginFlowBody{ @@ -64,6 +72,19 @@ func UpdateLoginFlowWithWebAuthnMethodAsUpdateLoginFlowBody(v *UpdateLoginFlowWi func (dst *UpdateLoginFlowBody) UnmarshalJSON(data []byte) error { var err error match := 0 + // try to unmarshal data into UpdateLoginFlowWithCodeMethod + err = newStrictDecoder(data).Decode(&dst.UpdateLoginFlowWithCodeMethod) + if err == nil { + jsonUpdateLoginFlowWithCodeMethod, _ := json.Marshal(dst.UpdateLoginFlowWithCodeMethod) + if string(jsonUpdateLoginFlowWithCodeMethod) == "{}" { // empty struct + dst.UpdateLoginFlowWithCodeMethod = nil + } else { + match++ + } + } else { + dst.UpdateLoginFlowWithCodeMethod = nil + } + // try to unmarshal data into UpdateLoginFlowWithLookupSecretMethod err = newStrictDecoder(data).Decode(&dst.UpdateLoginFlowWithLookupSecretMethod) if err == nil { @@ -131,6 +152,7 @@ func (dst *UpdateLoginFlowBody) UnmarshalJSON(data []byte) error { if match > 1 { // more than 1 match // reset to nil + dst.UpdateLoginFlowWithCodeMethod = nil dst.UpdateLoginFlowWithLookupSecretMethod = nil dst.UpdateLoginFlowWithOidcMethod = nil dst.UpdateLoginFlowWithPasswordMethod = nil @@ -147,6 +169,10 @@ func (dst *UpdateLoginFlowBody) UnmarshalJSON(data []byte) error { // Marshal data from the first non-nil pointers in the struct to JSON func (src UpdateLoginFlowBody) MarshalJSON() ([]byte, error) { + if src.UpdateLoginFlowWithCodeMethod != nil { + return json.Marshal(&src.UpdateLoginFlowWithCodeMethod) + } + if src.UpdateLoginFlowWithLookupSecretMethod != nil { return json.Marshal(&src.UpdateLoginFlowWithLookupSecretMethod) } @@ -175,6 +201,10 @@ func (obj *UpdateLoginFlowBody) GetActualInstance() interface{} { if obj == nil { return nil } + if obj.UpdateLoginFlowWithCodeMethod != nil { + return obj.UpdateLoginFlowWithCodeMethod + } + if obj.UpdateLoginFlowWithLookupSecretMethod != nil { return obj.UpdateLoginFlowWithLookupSecretMethod } diff --git a/internal/client-go/model_update_registration_flow_body.go b/internal/client-go/model_update_registration_flow_body.go index 1a662fc62416..0e36a95f635f 100644 --- a/internal/client-go/model_update_registration_flow_body.go +++ b/internal/client-go/model_update_registration_flow_body.go @@ -18,11 +18,19 @@ import ( // UpdateRegistrationFlowBody - Update Registration Request Body type UpdateRegistrationFlowBody struct { + UpdateRegistrationFlowWithCodeMethod *UpdateRegistrationFlowWithCodeMethod UpdateRegistrationFlowWithOidcMethod *UpdateRegistrationFlowWithOidcMethod UpdateRegistrationFlowWithPasswordMethod *UpdateRegistrationFlowWithPasswordMethod UpdateRegistrationFlowWithWebAuthnMethod *UpdateRegistrationFlowWithWebAuthnMethod } +// UpdateRegistrationFlowWithCodeMethodAsUpdateRegistrationFlowBody is a convenience function that returns UpdateRegistrationFlowWithCodeMethod wrapped in UpdateRegistrationFlowBody +func UpdateRegistrationFlowWithCodeMethodAsUpdateRegistrationFlowBody(v *UpdateRegistrationFlowWithCodeMethod) UpdateRegistrationFlowBody { + return UpdateRegistrationFlowBody{ + UpdateRegistrationFlowWithCodeMethod: v, + } +} + // UpdateRegistrationFlowWithOidcMethodAsUpdateRegistrationFlowBody is a convenience function that returns UpdateRegistrationFlowWithOidcMethod wrapped in UpdateRegistrationFlowBody func UpdateRegistrationFlowWithOidcMethodAsUpdateRegistrationFlowBody(v *UpdateRegistrationFlowWithOidcMethod) UpdateRegistrationFlowBody { return UpdateRegistrationFlowBody{ @@ -48,6 +56,19 @@ func UpdateRegistrationFlowWithWebAuthnMethodAsUpdateRegistrationFlowBody(v *Upd func (dst *UpdateRegistrationFlowBody) UnmarshalJSON(data []byte) error { var err error match := 0 + // try to unmarshal data into UpdateRegistrationFlowWithCodeMethod + err = newStrictDecoder(data).Decode(&dst.UpdateRegistrationFlowWithCodeMethod) + if err == nil { + jsonUpdateRegistrationFlowWithCodeMethod, _ := json.Marshal(dst.UpdateRegistrationFlowWithCodeMethod) + if string(jsonUpdateRegistrationFlowWithCodeMethod) == "{}" { // empty struct + dst.UpdateRegistrationFlowWithCodeMethod = nil + } else { + match++ + } + } else { + dst.UpdateRegistrationFlowWithCodeMethod = nil + } + // try to unmarshal data into UpdateRegistrationFlowWithOidcMethod err = newStrictDecoder(data).Decode(&dst.UpdateRegistrationFlowWithOidcMethod) if err == nil { @@ -89,6 +110,7 @@ func (dst *UpdateRegistrationFlowBody) UnmarshalJSON(data []byte) error { if match > 1 { // more than 1 match // reset to nil + dst.UpdateRegistrationFlowWithCodeMethod = nil dst.UpdateRegistrationFlowWithOidcMethod = nil dst.UpdateRegistrationFlowWithPasswordMethod = nil dst.UpdateRegistrationFlowWithWebAuthnMethod = nil @@ -103,6 +125,10 @@ func (dst *UpdateRegistrationFlowBody) UnmarshalJSON(data []byte) error { // Marshal data from the first non-nil pointers in the struct to JSON func (src UpdateRegistrationFlowBody) MarshalJSON() ([]byte, error) { + if src.UpdateRegistrationFlowWithCodeMethod != nil { + return json.Marshal(&src.UpdateRegistrationFlowWithCodeMethod) + } + if src.UpdateRegistrationFlowWithOidcMethod != nil { return json.Marshal(&src.UpdateRegistrationFlowWithOidcMethod) } @@ -123,6 +149,10 @@ func (obj *UpdateRegistrationFlowBody) GetActualInstance() interface{} { if obj == nil { return nil } + if obj.UpdateRegistrationFlowWithCodeMethod != nil { + return obj.UpdateRegistrationFlowWithCodeMethod + } + if obj.UpdateRegistrationFlowWithOidcMethod != nil { return obj.UpdateRegistrationFlowWithOidcMethod } diff --git a/internal/httpclient/model_update_login_flow_body.go b/internal/httpclient/model_update_login_flow_body.go index 1aa032062a4b..36033328e78d 100644 --- a/internal/httpclient/model_update_login_flow_body.go +++ b/internal/httpclient/model_update_login_flow_body.go @@ -18,6 +18,7 @@ import ( // UpdateLoginFlowBody - struct for UpdateLoginFlowBody type UpdateLoginFlowBody struct { + UpdateLoginFlowWithCodeMethod *UpdateLoginFlowWithCodeMethod UpdateLoginFlowWithLookupSecretMethod *UpdateLoginFlowWithLookupSecretMethod UpdateLoginFlowWithOidcMethod *UpdateLoginFlowWithOidcMethod UpdateLoginFlowWithPasswordMethod *UpdateLoginFlowWithPasswordMethod @@ -25,6 +26,13 @@ type UpdateLoginFlowBody struct { UpdateLoginFlowWithWebAuthnMethod *UpdateLoginFlowWithWebAuthnMethod } +// UpdateLoginFlowWithCodeMethodAsUpdateLoginFlowBody is a convenience function that returns UpdateLoginFlowWithCodeMethod wrapped in UpdateLoginFlowBody +func UpdateLoginFlowWithCodeMethodAsUpdateLoginFlowBody(v *UpdateLoginFlowWithCodeMethod) UpdateLoginFlowBody { + return UpdateLoginFlowBody{ + UpdateLoginFlowWithCodeMethod: v, + } +} + // UpdateLoginFlowWithLookupSecretMethodAsUpdateLoginFlowBody is a convenience function that returns UpdateLoginFlowWithLookupSecretMethod wrapped in UpdateLoginFlowBody func UpdateLoginFlowWithLookupSecretMethodAsUpdateLoginFlowBody(v *UpdateLoginFlowWithLookupSecretMethod) UpdateLoginFlowBody { return UpdateLoginFlowBody{ @@ -64,6 +72,19 @@ func UpdateLoginFlowWithWebAuthnMethodAsUpdateLoginFlowBody(v *UpdateLoginFlowWi func (dst *UpdateLoginFlowBody) UnmarshalJSON(data []byte) error { var err error match := 0 + // try to unmarshal data into UpdateLoginFlowWithCodeMethod + err = newStrictDecoder(data).Decode(&dst.UpdateLoginFlowWithCodeMethod) + if err == nil { + jsonUpdateLoginFlowWithCodeMethod, _ := json.Marshal(dst.UpdateLoginFlowWithCodeMethod) + if string(jsonUpdateLoginFlowWithCodeMethod) == "{}" { // empty struct + dst.UpdateLoginFlowWithCodeMethod = nil + } else { + match++ + } + } else { + dst.UpdateLoginFlowWithCodeMethod = nil + } + // try to unmarshal data into UpdateLoginFlowWithLookupSecretMethod err = newStrictDecoder(data).Decode(&dst.UpdateLoginFlowWithLookupSecretMethod) if err == nil { @@ -131,6 +152,7 @@ func (dst *UpdateLoginFlowBody) UnmarshalJSON(data []byte) error { if match > 1 { // more than 1 match // reset to nil + dst.UpdateLoginFlowWithCodeMethod = nil dst.UpdateLoginFlowWithLookupSecretMethod = nil dst.UpdateLoginFlowWithOidcMethod = nil dst.UpdateLoginFlowWithPasswordMethod = nil @@ -147,6 +169,10 @@ func (dst *UpdateLoginFlowBody) UnmarshalJSON(data []byte) error { // Marshal data from the first non-nil pointers in the struct to JSON func (src UpdateLoginFlowBody) MarshalJSON() ([]byte, error) { + if src.UpdateLoginFlowWithCodeMethod != nil { + return json.Marshal(&src.UpdateLoginFlowWithCodeMethod) + } + if src.UpdateLoginFlowWithLookupSecretMethod != nil { return json.Marshal(&src.UpdateLoginFlowWithLookupSecretMethod) } @@ -175,6 +201,10 @@ func (obj *UpdateLoginFlowBody) GetActualInstance() interface{} { if obj == nil { return nil } + if obj.UpdateLoginFlowWithCodeMethod != nil { + return obj.UpdateLoginFlowWithCodeMethod + } + if obj.UpdateLoginFlowWithLookupSecretMethod != nil { return obj.UpdateLoginFlowWithLookupSecretMethod } diff --git a/internal/httpclient/model_update_registration_flow_body.go b/internal/httpclient/model_update_registration_flow_body.go index 1a662fc62416..0e36a95f635f 100644 --- a/internal/httpclient/model_update_registration_flow_body.go +++ b/internal/httpclient/model_update_registration_flow_body.go @@ -18,11 +18,19 @@ import ( // UpdateRegistrationFlowBody - Update Registration Request Body type UpdateRegistrationFlowBody struct { + UpdateRegistrationFlowWithCodeMethod *UpdateRegistrationFlowWithCodeMethod UpdateRegistrationFlowWithOidcMethod *UpdateRegistrationFlowWithOidcMethod UpdateRegistrationFlowWithPasswordMethod *UpdateRegistrationFlowWithPasswordMethod UpdateRegistrationFlowWithWebAuthnMethod *UpdateRegistrationFlowWithWebAuthnMethod } +// UpdateRegistrationFlowWithCodeMethodAsUpdateRegistrationFlowBody is a convenience function that returns UpdateRegistrationFlowWithCodeMethod wrapped in UpdateRegistrationFlowBody +func UpdateRegistrationFlowWithCodeMethodAsUpdateRegistrationFlowBody(v *UpdateRegistrationFlowWithCodeMethod) UpdateRegistrationFlowBody { + return UpdateRegistrationFlowBody{ + UpdateRegistrationFlowWithCodeMethod: v, + } +} + // UpdateRegistrationFlowWithOidcMethodAsUpdateRegistrationFlowBody is a convenience function that returns UpdateRegistrationFlowWithOidcMethod wrapped in UpdateRegistrationFlowBody func UpdateRegistrationFlowWithOidcMethodAsUpdateRegistrationFlowBody(v *UpdateRegistrationFlowWithOidcMethod) UpdateRegistrationFlowBody { return UpdateRegistrationFlowBody{ @@ -48,6 +56,19 @@ func UpdateRegistrationFlowWithWebAuthnMethodAsUpdateRegistrationFlowBody(v *Upd func (dst *UpdateRegistrationFlowBody) UnmarshalJSON(data []byte) error { var err error match := 0 + // try to unmarshal data into UpdateRegistrationFlowWithCodeMethod + err = newStrictDecoder(data).Decode(&dst.UpdateRegistrationFlowWithCodeMethod) + if err == nil { + jsonUpdateRegistrationFlowWithCodeMethod, _ := json.Marshal(dst.UpdateRegistrationFlowWithCodeMethod) + if string(jsonUpdateRegistrationFlowWithCodeMethod) == "{}" { // empty struct + dst.UpdateRegistrationFlowWithCodeMethod = nil + } else { + match++ + } + } else { + dst.UpdateRegistrationFlowWithCodeMethod = nil + } + // try to unmarshal data into UpdateRegistrationFlowWithOidcMethod err = newStrictDecoder(data).Decode(&dst.UpdateRegistrationFlowWithOidcMethod) if err == nil { @@ -89,6 +110,7 @@ func (dst *UpdateRegistrationFlowBody) UnmarshalJSON(data []byte) error { if match > 1 { // more than 1 match // reset to nil + dst.UpdateRegistrationFlowWithCodeMethod = nil dst.UpdateRegistrationFlowWithOidcMethod = nil dst.UpdateRegistrationFlowWithPasswordMethod = nil dst.UpdateRegistrationFlowWithWebAuthnMethod = nil @@ -103,6 +125,10 @@ func (dst *UpdateRegistrationFlowBody) UnmarshalJSON(data []byte) error { // Marshal data from the first non-nil pointers in the struct to JSON func (src UpdateRegistrationFlowBody) MarshalJSON() ([]byte, error) { + if src.UpdateRegistrationFlowWithCodeMethod != nil { + return json.Marshal(&src.UpdateRegistrationFlowWithCodeMethod) + } + if src.UpdateRegistrationFlowWithOidcMethod != nil { return json.Marshal(&src.UpdateRegistrationFlowWithOidcMethod) } @@ -123,6 +149,10 @@ func (obj *UpdateRegistrationFlowBody) GetActualInstance() interface{} { if obj == nil { return nil } + if obj.UpdateRegistrationFlowWithCodeMethod != nil { + return obj.UpdateRegistrationFlowWithCodeMethod + } + if obj.UpdateRegistrationFlowWithOidcMethod != nil { return obj.UpdateRegistrationFlowWithOidcMethod } diff --git a/spec/api.json b/spec/api.json index f5fef9928588..803097adcd78 100644 --- a/spec/api.json +++ b/spec/api.json @@ -2397,6 +2397,7 @@ "updateLoginFlowBody": { "discriminator": { "mapping": { + "code": "#/components/schemas/updateLoginFlowWithCodeMethod", "lookup_secret": "#/components/schemas/updateLoginFlowWithLookupSecretMethod", "oidc": "#/components/schemas/updateLoginFlowWithOidcMethod", "password": "#/components/schemas/updateLoginFlowWithPasswordMethod", @@ -2420,6 +2421,9 @@ }, { "$ref": "#/components/schemas/updateLoginFlowWithLookupSecretMethod" + }, + { + "$ref": "#/components/schemas/updateLoginFlowWithCodeMethod" } ] }, @@ -2663,6 +2667,7 @@ "description": "Update Registration Request Body", "discriminator": { "mapping": { + "code": "#/components/schemas/updateRegistrationFlowWithCodeMethod", "oidc": "#/components/schemas/updateRegistrationFlowWithOidcMethod", "password": "#/components/schemas/updateRegistrationFlowWithPasswordMethod", "webauthn": "#/components/schemas/updateRegistrationFlowWithWebAuthnMethod" @@ -2678,6 +2683,9 @@ }, { "$ref": "#/components/schemas/updateRegistrationFlowWithWebAuthnMethod" + }, + { + "$ref": "#/components/schemas/updateRegistrationFlowWithCodeMethod" } ] },