Skip to content

Commit

Permalink
fix: correct password and profile swagger annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Oct 13, 2020
1 parent a8ae759 commit 668c184
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 52 deletions.
68 changes: 41 additions & 27 deletions .schema/api.swagger.json
Expand Up @@ -1061,8 +1061,7 @@
"name": "Payload",
"in": "body",
"schema": {
"type": "object",
"additionalProperties": true
"type": "object"
}
}
],
Expand Down Expand Up @@ -1324,6 +1323,21 @@
],
"summary": "Complete Settings Flow with Profile Method",
"operationId": "completeSelfServiceSettingsFlowWithProfileMethod",
"parameters": [
{
"type": "string",
"description": "Flow is flow ID.",
"name": "flow",
"in": "query"
},
{
"name": "Payload",
"in": "body",
"schema": {
"type": "object"
}
}
],
"responses": {
"200": {
"description": "settingsFlow",
Expand Down Expand Up @@ -1728,30 +1742,6 @@
"type": "string",
"title": "CredentialsType represents several different credential types, like password credentials, passwordless credentials,"
},
"FlowMethodConfig": {
"type": "object",
"required": [
"action",
"method",
"fields"
],
"properties": {
"action": {
"description": "Action should be used as the form action URL `\u003cform action=\"{{ .Action }}\" method=\"post\"\u003e`.",
"type": "string"
},
"fields": {
"$ref": "#/definitions/formFields"
},
"messages": {
"$ref": "#/definitions/Messages"
},
"method": {
"description": "Method is the form method (e.g. POST)",
"type": "string"
}
}
},
"ID": {
"type": "integer",
"format": "int64"
Expand Down Expand Up @@ -2506,14 +2496,38 @@
],
"properties": {
"config": {
"$ref": "#/definitions/FlowMethodConfig"
"$ref": "#/definitions/settingsFlowMethodConfig"
},
"method": {
"description": "Method is the name of this flow method.",
"type": "string"
}
}
},
"settingsFlowMethodConfig": {
"type": "object",
"required": [
"action",
"method",
"fields"
],
"properties": {
"action": {
"description": "Action should be used as the form action URL `\u003cform action=\"{{ .Action }}\" method=\"post\"\u003e`.",
"type": "string"
},
"fields": {
"$ref": "#/definitions/formFields"
},
"messages": {
"$ref": "#/definitions/Messages"
},
"method": {
"description": "Method is the form method (e.g. POST)",
"type": "string"
}
}
},
"settingsViaApiResponse": {
"description": "The Response for Settings Flows via API",
"type": "object",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/httpclient/models/settings_flow_method.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/testhelpers/selfservice_settings.go
Expand Up @@ -98,14 +98,14 @@ func ExpectURL(isAPI bool, api, browser string) string {
return browser
}

func GetSettingsFlowMethodConfig(t *testing.T, rs *models.SettingsFlow, id string) *models.FlowMethodConfig {
func GetSettingsFlowMethodConfig(t *testing.T, rs *models.SettingsFlow, id string) *models.SettingsFlowMethodConfig {
require.NotEmpty(t, rs.Methods[id])
require.NotEmpty(t, rs.Methods[id].Config)
require.NotEmpty(t, rs.Methods[id].Config.Action)
return rs.Methods[id].Config
}

func GetSettingsFlowMethodConfigDeprecated(t *testing.T, primaryUser *http.Client, ts *httptest.Server, id string) *models.FlowMethodConfig {
func GetSettingsFlowMethodConfigDeprecated(t *testing.T, primaryUser *http.Client, ts *httptest.Server, id string) *models.SettingsFlowMethodConfig {
rs := InitializeSettingsFlowViaBrowser(t, primaryUser, ts)

require.NotEmpty(t, rs.Payload.Methods[id])
Expand Down Expand Up @@ -228,7 +228,7 @@ func AddAndLoginIdentities(t *testing.T, reg *driver.RegistryDefault, public *ht
func SettingsMakeRequest(
t *testing.T,
isAPI bool,
f *models.FlowMethodConfig,
f *models.SettingsFlowMethodConfig,
hc *http.Client,
values string,
) (string, *http.Response) {
Expand Down
2 changes: 1 addition & 1 deletion selfservice/flow/settings/flow_method.go
Expand Up @@ -70,7 +70,7 @@ type FlowMethodConfigurator interface {
form.MessageAdder
}

// swagger:type settingsFlowMethodConfig
// swagger:model settingsFlowMethodConfig
type FlowMethodConfig struct {
// swagger:ignore
FlowMethodConfigurator
Expand Down
2 changes: 1 addition & 1 deletion selfservice/strategy/password/registration.go
Expand Up @@ -99,7 +99,7 @@ type completeSelfServiceRegistrationFlowWithPasswordMethodParameters struct {
Flow string `json:"flow"`

// in: body
Payload map[string]interface{}
Payload interface{}
}

// swagger:route POST /self-service/registration/methods/password public completeSelfServiceRegistrationFlowWithPasswordMethod
Expand Down
2 changes: 1 addition & 1 deletion selfservice/strategy/password/settings_test.go
Expand Up @@ -263,7 +263,7 @@ func TestSettings(t *testing.T) {
viper.Set(configuration.ViperKeySelfServiceSettingsAfter+"."+configuration.DefaultBrowserReturnURL, rts.URL+"/return-ts")
defer viper.Set(configuration.ViperKeySelfServiceSettingsAfter, nil)

var run = func(t *testing.T, f *models.FlowMethodConfig, isAPI bool, c *http.Client, id *identity.Identity) {
var run = func(t *testing.T, f *models.SettingsFlowMethodConfig, isAPI bool, c *http.Client, id *identity.Identity) {
values := testhelpers.SDKFormFieldsToURLValues(f.Fields)
values.Set("password", randx.MustString(16, randx.AlphaNum))
_, res := testhelpers.SettingsMakeRequest(t, isAPI, f, c, testhelpers.EncodeFormAsJSON(t, isAPI, values))
Expand Down
13 changes: 13 additions & 0 deletions selfservice/strategy/profile/strategy.go
Expand Up @@ -82,6 +82,7 @@ func (s *Strategy) SettingsStrategyID() string {
}

func (s *Strategy) RegisterSettingsRoutes(public *x.RouterPublic) {
s.d.CSRFHandler().ExemptPath(RouteSettings)
public.POST(RouteSettings, s.d.SessionHandler().IsAuthenticated(s.handleSubmit, settings.OnUnauthenticated(s.c, s.d)))
public.GET(RouteSettings, s.d.SessionHandler().IsAuthenticated(s.handleSubmit, settings.OnUnauthenticated(s.c, s.d)))
}
Expand Down Expand Up @@ -117,6 +118,18 @@ func (s *Strategy) PopulateSettingsMethod(r *http.Request, id *identity.Identity
return nil
}

// nolint:deadcode,unused
// swagger:parameters completeSelfServiceSettingsFlowWithProfileMethod
type completeSelfServiceSettingsFlowWithProfileMethodParameters struct {
// Flow is flow ID.
//
// in: query
Flow string `json:"flow"`

// in: body
Payload interface{}
}

// swagger:route POST /self-service/settings/methods/profile public completeSelfServiceSettingsFlowWithProfileMethod
//
// Complete Settings Flow with Profile Method
Expand Down

0 comments on commit 668c184

Please sign in to comment.