Skip to content

Commit b9385a3

Browse files
committed
fixed linting and formatting issues
1 parent 363307f commit b9385a3

File tree

5 files changed

+13
-18
lines changed

5 files changed

+13
-18
lines changed

parameters/header_parameters.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ package parameters
55

66
import (
77
"fmt"
8-
lowbase "github.com/pb33f/libopenapi/datamodel/low/base"
98
"net/http"
109
"strconv"
1110
"strings"
1211

12+
lowbase "github.com/pb33f/libopenapi/datamodel/low/base"
13+
1314
"github.com/pb33f/libopenapi/datamodel/high/base"
1415

1516
v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
@@ -152,7 +153,6 @@ func (v *paramValidator) ValidateHeaderParamsWithPathItem(request *http.Request,
152153
param,
153154
p.Name,
154155
lowbase.SchemaLabel, p.Name, helpers.ParameterValidation, helpers.ParameterValidationHeader, v.options)...)
155-
156156
}
157157
} else {
158158
if p.Required != nil && *p.Required {

parameters/validate_parameter_test.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package parameters
22

33
import (
4-
"github.com/pb33f/libopenapi"
5-
"github.com/stretchr/testify/assert"
64
"net/http"
75
"testing"
86

7+
"github.com/pb33f/libopenapi"
8+
"github.com/stretchr/testify/assert"
9+
910
"github.com/stretchr/testify/require"
1011
)
1112

@@ -18,7 +19,6 @@ func Test_ForceCompilerError(t *testing.T) {
1819
}
1920

2021
func TestHeaderSchemaNoType(t *testing.T) {
21-
2222
bytes := []byte(`{
2323
"openapi": "3.0.0",
2424
"info": {
@@ -90,7 +90,7 @@ func TestHeaderSchemaNoType(t *testing.T) {
9090

9191
v3Model.Model.Servers = nil
9292
// render the document back to bytes and reload the model.
93-
_, doc, v3Model, errs = doc.RenderAndReload()
93+
_, _, v3Model, _ = doc.RenderAndReload()
9494

9595
validator := NewParameterValidator(&v3Model.Model)
9696

@@ -102,11 +102,9 @@ func TestHeaderSchemaNoType(t *testing.T) {
102102
assert.Len(t, valErrs[0].SchemaValidationErrors, 2)
103103
assert.Equal(t, "got string, want boolean", valErrs[0].SchemaValidationErrors[0].Reason)
104104
assert.Equal(t, "got string, want integer", valErrs[0].SchemaValidationErrors[1].Reason)
105-
106105
}
107106

108107
func TestHeaderSchemaNoType_AllPoly(t *testing.T) {
109-
110108
bytes := []byte(`{
111109
"openapi": "3.0.0",
112110
"info": {
@@ -183,7 +181,7 @@ func TestHeaderSchemaNoType_AllPoly(t *testing.T) {
183181

184182
v3Model.Model.Servers = nil
185183
// render the document back to bytes and reload the model.
186-
_, doc, v3Model, errs = doc.RenderAndReload()
184+
_, _, v3Model, _ = doc.RenderAndReload()
187185

188186
validator := NewParameterValidator(&v3Model.Model)
189187

responses/validate_headers.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ package responses
55

66
import (
77
"fmt"
8+
"net/http"
9+
"strings"
10+
811
"github.com/pb33f/libopenapi-validator/helpers"
912
"github.com/pb33f/libopenapi-validator/parameters"
1013
v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
1114
lowv3 "github.com/pb33f/libopenapi/datamodel/low/v3"
1215
"github.com/pb33f/libopenapi/orderedmap"
1316

14-
"net/http"
15-
"strings"
16-
1717
"github.com/pb33f/libopenapi-validator/config"
1818
"github.com/pb33f/libopenapi-validator/errors"
1919
)
@@ -73,12 +73,10 @@ func ValidateResponseHeaders(
7373
if header.model.Schema != nil {
7474
schema := header.model.Schema.Schema()
7575
if schema != nil && header.model.Required {
76-
7776
for _, headerValue := range header.value {
7877
validationErrors = append(validationErrors,
7978
parameters.ValidateParameterSchema(schema, nil, headerValue, "header",
8079
"response header", h, helpers.ResponseBodyValidation, lowv3.HeadersLabel, options)...)
81-
8280
}
8381
}
8482
}

responses/validate_headers_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
package responses
55

66
import (
7-
"github.com/pb33f/libopenapi"
8-
"github.com/stretchr/testify/assert"
97
"net/http"
108
"net/http/httptest"
119
"testing"
10+
11+
"github.com/pb33f/libopenapi"
12+
"github.com/stretchr/testify/assert"
1213
)
1314

1415
func TestValidateResponseHeaders(t *testing.T) {
@@ -81,5 +82,4 @@ paths:
8182
assert.Len(t, errors, 1)
8283
assert.Equal(t, errors[0].Message, "header 'chicken-nuggets' failed to validate")
8384
assert.Equal(t, errors[0].Reason, "response header 'chicken-nuggets' is defined as an integer, however it failed to pass a schema validation")
84-
8585
}

validator_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1728,7 +1728,6 @@ components:
17281728
$ref: '#/components/schemas/Error'`
17291729

17301730
document, err := libopenapi.NewDocument([]byte(spec))
1731-
17321731
if err != nil {
17331732
panic(fmt.Sprintf("failed to create new document: %v\n", err))
17341733
}

0 commit comments

Comments
 (0)