Skip to content

Commit

Permalink
Merge branch 'getkin:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
slessard authored Mar 31, 2022
2 parents 543f56e + 8287d36 commit e320853
Show file tree
Hide file tree
Showing 12 changed files with 659 additions and 132 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ jobs:
- run: go fmt ./...
- run: git --no-pager diff --exit-code

- if: runner.os == 'Linux'
run: go test ./...
env:
GOARCH: '386'
- run: go test ./...
- run: go test -v -run TestRaceyPatternSchema -race ./...
env:
Expand Down
1 change: 1 addition & 0 deletions openapi2/openapi2.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ type Operation struct {
Responses map[string]*Response `json:"responses" yaml:"responses"`
Consumes []string `json:"consumes,omitempty" yaml:"consumes,omitempty"`
Produces []string `json:"produces,omitempty" yaml:"produces,omitempty"`
Schemes []string `json:"schemes,omitempty" yaml:"schemes,omitempty"`
Security *SecurityRequirements `json:"security,omitempty" yaml:"security,omitempty"`
}

Expand Down
2 changes: 1 addition & 1 deletion openapi3filter/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var _ interface{ Unwrap() error } = RequestError{}
func (err *RequestError) Error() string {
reason := err.Reason
if e := err.Err; e != nil {
if len(reason) == 0 {
if len(reason) == 0 || reason == e.Error() {
reason = e.Error()
} else {
reason += ": " + e.Error()
Expand Down
105 changes: 105 additions & 0 deletions openapi3filter/fixtures/petstore.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,111 @@
]
}
},
"/pets/": {
"get": {
"tags": [
"pet"
],
"summary": "Find pets by the specified filters",
"description": "Returns a list of pets that comply with the specified filters",
"operationId": "findPets",
"parameters": [
{
"name": "status",
"in": "query",
"description": "Status values that need to be considered for filter",
"required": false,
"explode": true,
"allowEmptyValue": true,
"schema": {
"type": "array",
"items": {
"type": "string",
"enum": [
"available",
"pending",
"sold"
],
"default": "available"
}
}
},
{
"name": "tags",
"in": "query",
"description": "Tags to filter by",
"required": false,
"explode": true,
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
},
{
"name": "kind",
"in": "query",
"description": "Kinds to filter by",
"required": false,
"explode": false,
"style": "pipeDelimited",
"schema": {
"type": "array",
"items": {
"type": "string",
"enum": [
"dog",
"cat",
"turtle",
"bird,with,commas"
]
}
}
}
],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/xml": {
"schema": {
"type": "array",
"items": {
"allOf": [
{"$ref": "#/components/schemas/Pet"},
{"$ref": "#/components/schemas/PetRequiredProperties"}
]
}
}
},
"application/json": {
"schema": {
"type": "array",
"items": {
"allOf": [
{"$ref": "#/components/schemas/Pet"},
{"$ref": "#/components/schemas/PetRequiredProperties"}
]
}
}
}
}
},
"400": {
"description": "Invalid status value"
}
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets"
]
}
]
}
},
"/pet/findByTags": {
"get": {
"tags": [
Expand Down
12 changes: 12 additions & 0 deletions openapi3filter/internal.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package openapi3filter

import (
"reflect"
"strings"
)

Expand All @@ -11,3 +12,14 @@ func parseMediaType(contentType string) string {
}
return contentType[:i]
}

func isNilValue(value interface{}) bool {
if value == nil {
return true
}
switch reflect.TypeOf(value).Kind() {
case reflect.Ptr, reflect.Map, reflect.Array, reflect.Chan, reflect.Slice:
return reflect.ValueOf(value).IsNil()
}
return false
}
2 changes: 1 addition & 1 deletion openapi3filter/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ paths:
// requests.
squareHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
xParam := path.Base(r.URL.Path)
x, err := strconv.Atoi(xParam)
x, err := strconv.ParseInt(xParam, 10, 64)
if err != nil {
panic(err)
}
Expand Down
Loading

0 comments on commit e320853

Please sign in to comment.