Skip to content

Commit

Permalink
nitpicking
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
  • Loading branch information
fenollp committed Jun 23, 2023
1 parent beda4b6 commit 3f0edcb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions maps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ func (${name} ${type}) JSONLookup(token string) (interface{}, error) {
}
if v != nil {
if v.Ref != "" {
return &Ref{Ref: v.Ref}, nil
if ref := v.Ref; ref != "" {
return &Ref{Ref: ref}, nil
}
return v, nil
}
Expand Down
2 changes: 1 addition & 1 deletion openapi3/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ func (components *Components) Validate(ctx context.Context, opts ...ValidationOp
}
sort.Strings(responses)
for _, k := range responses {
v := components.Responses.Value(k)
if err = ValidateIdentifier(k); err != nil {
return fmt.Errorf("response %q: %w", k, err)
}
v := components.Responses.Value(k)
if err = v.Validate(ctx); err != nil {
return fmt.Errorf("response %q: %w", k, err)
}
Expand Down
12 changes: 6 additions & 6 deletions openapi3/maplike.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ func (responses *Responses) JSONLookup(token string) (interface{}, error) {
}

if v != nil {
if v.Ref != "" {
return &Ref{Ref: v.Ref}, nil
if ref := v.Ref; ref != "" {
return &Ref{Ref: ref}, nil
}
return v, nil
}
Expand Down Expand Up @@ -176,8 +176,8 @@ func (callback *Callback) JSONLookup(token string) (interface{}, error) {
}

if v != nil {
if v.Ref != "" {
return &Ref{Ref: v.Ref}, nil
if ref := v.Ref; ref != "" {
return &Ref{Ref: ref}, nil
}
return v, nil
}
Expand Down Expand Up @@ -290,8 +290,8 @@ func (paths *Paths) JSONLookup(token string) (interface{}, error) {
}

if v != nil {
if v.Ref != "" {
return &Ref{Ref: v.Ref}, nil
if ref := v.Ref; ref != "" {
return &Ref{Ref: ref}, nil
}
return v, nil
}
Expand Down
3 changes: 3 additions & 0 deletions openapi3/openapi3.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ func (doc *T) AddOperation(path string, method string, operation *Operation) {
pathItem := doc.Paths.Value(path)
if pathItem == nil {
pathItem = &PathItem{}
if doc.Paths == nil {
doc.Paths = NewPaths()
}
doc.Paths.Set(path, pathItem)
}
pathItem.SetOperation(method, operation)
Expand Down

0 comments on commit 3f0edcb

Please sign in to comment.