Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixup some coding style divergences #760

Merged
merged 1 commit into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions openapi3/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ func (loader *Loader) resolveCallbackRef(doc *T, component *CallbackRef, documen
if err != nil {
return err
}
if err := loader.resolveCallbackRef(doc, &resolved, componentPath); err != nil {
if err = loader.resolveCallbackRef(doc, &resolved, componentPath); err != nil {
return err
}
component.Value = resolved.Value
Expand All @@ -890,8 +890,7 @@ func (loader *Loader) resolveCallbackRef(doc *T, component *CallbackRef, documen
}

for _, pathItem := range *value {
err := loader.resolvePathItemRef(doc, pathItem, documentPath)
if err != nil {
if err = loader.resolvePathItemRef(doc, pathItem, documentPath); err != nil {
return err
}
}
Expand Down Expand Up @@ -964,8 +963,7 @@ func (loader *Loader) resolvePathItemRef(doc *T, pathItem *PathItem, documentPat
*pathItem = p
} else {
var resolved PathItem
doc, documentPath, err = loader.resolveComponent(doc, ref, documentPath, &resolved)
if err != nil {
if doc, documentPath, err = loader.resolveComponent(doc, ref, documentPath, &resolved); err != nil {
return err
}
*pathItem = resolved
Expand Down
7 changes: 3 additions & 4 deletions openapi3/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -1124,9 +1124,9 @@ func (schema *Schema) visitJSON(settings *schemaValidationSettings, value interf
// Catch slice of non-empty interface type
if reflect.TypeOf(value).Kind() == reflect.Slice {
valueR := reflect.ValueOf(value)
newValue := make([]interface{}, valueR.Len())
newValue := make([]interface{}, 0, valueR.Len())
for i := 0; i < valueR.Len(); i++ {
newValue[i] = valueR.Index(i).Interface()
newValue = append(newValue, valueR.Index(i).Interface())
}
return schema.visitJSONArray(settings, newValue)
}
Expand All @@ -1146,8 +1146,7 @@ func (schema *Schema) visitSetOperations(settings *schemaValidationSettings, val
switch c := value.(type) {
case json.Number:
var f float64
f, err = strconv.ParseFloat(c.String(), 64)
if err != nil {
if f, err = strconv.ParseFloat(c.String(), 64); err != nil {
return err
}
if v == f {
Expand Down