Skip to content

Commit

Permalink
fix(spec): marshal OAuthFlow's scopes as an empty map if nil (#87)
Browse files Browse the repository at this point in the history
The field is required by the spec, and may be empty.

closes #86
  • Loading branch information
wI2L authored Sep 6, 2022
1 parent 1f5d47b commit 80afc14
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions openapi/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,16 @@ type OAuthFlow struct {
Scopes map[string]string `json:"scopes,omitempty" yaml:"scopes,omitempty"`
}

// MarshalYAML implements yaml.Marshaler for OAuthFlow.
func (f OAuthFlow) MarshalYAML() ([]byte, error) {
type flow OAuthFlow
if f.Scopes == nil {
// The field is REQUIRED and MAY be empty according to the spec.
f.Scopes = map[string]string{}
}
return json.Marshal(flow(f))
}

// SecurityRequirement represents the security object in the API specification.
type SecurityRequirement map[string][]string

Expand Down

0 comments on commit 80afc14

Please sign in to comment.