-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathoauth_flows.go
42 lines (38 loc) · 1.14 KB
/
oauth_flows.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package openapi
import "github.com/nasa9084/go-openapi/oauth"
// codebeat:disable[TOO_MANY_IVARS]
// OAuthFlows Object
type OAuthFlows struct {
Implicit *OAuthFlow
Password *OAuthFlow
ClientCredentials *OAuthFlow `yaml:"clientCredentials"`
AuthorizationCode *OAuthFlow `yaml:"authorizationCode"`
}
// Validate the values of OAuthFlows Object.
func (oauthFlows OAuthFlows) Validate() error {
if oauthFlows.Implicit != nil {
oauthFlows.Implicit.SetFlowType(oauth.ImplicitFlow)
if err := oauthFlows.Implicit.Validate(); err != nil {
return err
}
}
if oauthFlows.Password != nil {
oauthFlows.Password.SetFlowType(oauth.PasswordFlow)
if err := oauthFlows.Password.Validate(); err != nil {
return err
}
}
if oauthFlows.ClientCredentials != nil {
oauthFlows.ClientCredentials.SetFlowType(oauth.ClientCredentialsFlow)
if err := oauthFlows.ClientCredentials.Validate(); err != nil {
return err
}
}
if oauthFlows.AuthorizationCode != nil {
oauthFlows.AuthorizationCode.SetFlowType(oauth.AuthorizationCodeFlow)
if err := oauthFlows.AuthorizationCode.Validate(); err != nil {
return err
}
}
return nil
}