Skip to content

Commit 34ee8b0

Browse files
Merge pull request #412 from pespantelis/main
chore(parser): omit empty values for security schema fields
2 parents 5407019 + e529458 commit 34ee8b0

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

openapi/parser/parse_security.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ func (p *parser) parseSecurityRequirements(requirements ogen.SecurityRequirement
6060
return nil, errors.Wrapf(err, "resolve %q", requirementName)
6161
}
6262

63+
var flows ogen.OAuthFlows
64+
if spec.Flows != nil {
65+
flows = *spec.Flows
66+
}
67+
6368
result = append(result, openapi.SecurityRequirements{
6469
Scopes: scopes,
6570
Name: requirementName,
@@ -70,7 +75,7 @@ func (p *parser) parseSecurityRequirements(requirements ogen.SecurityRequirement
7075
In: spec.In,
7176
Scheme: spec.Scheme,
7277
BearerFormat: spec.BearerFormat,
73-
Flows: cloneOAuthFlows(spec.Flows),
78+
Flows: cloneOAuthFlows(flows),
7479
OpenIDConnectURL: spec.OpenIDConnectURL,
7580
},
7681
})

security_spec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ type SecuritySchema struct {
1818
// by an authorization server, so this information is primarily for documentation purposes.
1919
BearerFormat string `json:"bearerFormat,omitempty"`
2020
// An object containing configuration information for the flow types supported.
21-
Flows OAuthFlows `json:"flows"`
21+
Flows *OAuthFlows `json:"flows,omitempty"`
2222
// OpenId Connect URL to discover OAuth2 configuration values.
2323
// This MUST be in the form of a URL. The OpenID Connect standard requires the use of TLS.
24-
OpenIDConnectURL string `json:"openIdConnectUrl"`
24+
OpenIDConnectURL string `json:"openIdConnectUrl,omitempty"`
2525
}
2626

2727
// OAuthFlows allows configuration of the supported OAuth Flows.

0 commit comments

Comments
 (0)