Skip to content

Commit eb84dd8

Browse files
authored
chore: Fix comments/imports (#789)
* Format yaml * Format imports * Fix comments * Format yamls * Tidy * Renames * Generate * Revert generated
1 parent 4707e22 commit eb84dd8

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

oapi_validate.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import (
1818
"context"
1919
"errors"
2020
"fmt"
21-
"os"
2221
"net/http"
22+
"os"
2323
"strings"
2424

2525
"github.com/getkin/kin-openapi/openapi3"
@@ -34,7 +34,7 @@ const (
3434
UserDataKey = "oapi-codegen/user-data"
3535
)
3636

37-
// Create validator middleware from a YAML file path
37+
// OapiValidatorFromYamlFile creates a validator middleware from a YAML file path
3838
func OapiValidatorFromYamlFile(path string) (gin.HandlerFunc, error) {
3939
data, err := os.ReadFile(path)
4040
if err != nil {
@@ -49,7 +49,7 @@ func OapiValidatorFromYamlFile(path string) (gin.HandlerFunc, error) {
4949
return OapiRequestValidator(swagger), nil
5050
}
5151

52-
// This is an gin middleware function which validates incoming HTTP requests
52+
// OapiRequestValidator is an gin middleware function which validates incoming HTTP requests
5353
// to make sure that they conform to the given OAPI 3.0 specification. When
5454
// OAPI validation fails on the request, we return an HTTP/400 with error message
5555
func OapiRequestValidator(swagger *openapi3.T) gin.HandlerFunc {
@@ -72,7 +72,7 @@ type Options struct {
7272
MultiErrorHandler MultiErrorHandler
7373
}
7474

75-
// Create a validator from a swagger object, with validation options
75+
// OapiRequestValidatorWithOptions creates a validator from a swagger object, with validation options
7676
func OapiRequestValidatorWithOptions(swagger *openapi3.T, options *Options) gin.HandlerFunc {
7777
router, err := gorillamux.NewRouter(swagger)
7878
if err != nil {
@@ -156,7 +156,7 @@ func ValidateRequestFromContext(c *gin.Context, router routers.Router, options *
156156
return nil
157157
}
158158

159-
// Helper function to get the echo context from within requests. It returns
159+
// GetGinContext gets the echo context from within requests. It returns
160160
// nil if not found or wrong type.
161161
func GetGinContext(c context.Context) *gin.Context {
162162
iface := c.Value(GinContextKey)

oapi_validate_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@ import (
2525
"net/url"
2626
"testing"
2727

28+
"github.com/deepmap/oapi-codegen/pkg/testutil"
2829
"github.com/getkin/kin-openapi/openapi3"
2930
"github.com/getkin/kin-openapi/openapi3filter"
3031
"github.com/gin-gonic/gin"
3132
"github.com/stretchr/testify/assert"
3233
"github.com/stretchr/testify/require"
33-
34-
"github.com/deepmap/oapi-codegen/pkg/testutil"
3534
)
3635

3736
//go:embed test_spec.yaml
@@ -206,7 +205,7 @@ func TestOapiRequestValidator(t *testing.T) {
206205
}
207206

208207
func TestOapiRequestValidatorWithOptionsMultiError(t *testing.T) {
209-
swagger, err := openapi3.NewLoader().LoadFromData([]byte(testSchema))
208+
swagger, err := openapi3.NewLoader().LoadFromData(testSchema)
210209
require.NoError(t, err, "Error initializing swagger")
211210

212211
g := gin.New()
@@ -309,7 +308,7 @@ func TestOapiRequestValidatorWithOptionsMultiError(t *testing.T) {
309308
}
310309

311310
func TestOapiRequestValidatorWithOptionsMultiErrorAndCustomHandler(t *testing.T) {
312-
swagger, err := openapi3.NewLoader().LoadFromData([]byte(testSchema))
311+
swagger, err := openapi3.NewLoader().LoadFromData(testSchema)
313312
require.NoError(t, err, "Error initializing swagger")
314313

315314
g := gin.New()

test_spec.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ paths:
8686
maximum: 100
8787
responses:
8888
'200':
89-
description: success
90-
content:
91-
application/json:
92-
schema:
93-
properties:
94-
name:
95-
type: string
96-
id:
97-
type: integer
89+
description: success
90+
content:
91+
application/json:
92+
schema:
93+
properties:
94+
name:
95+
type: string
96+
id:
97+
type: integer
9898
components:
9999
securitySchemes:
100100
BearerAuth:

0 commit comments

Comments
 (0)