Update dependencies

This commit is contained in:
James
2017-08-16 11:15:14 -07:00
parent b9c0374fe3
commit f46ea14760
1220 changed files with 142690 additions and 47576 deletions

View File

@@ -0,0 +1,8 @@
{
"swagger": "2.0",
"info": {
"title": "empty-paths",
"version": "79.2.1"
},
"paths": {}
}

View File

@@ -32,6 +32,19 @@ func Mixin(primary *spec.Swagger, mixins ...*spec.Swagger) []string {
if primary.Paths == nil {
primary.Paths = &spec.Paths{Paths: make(map[string]spec.PathItem)}
}
if primary.Paths.Paths == nil {
primary.Paths.Paths = make(map[string]spec.PathItem)
}
if primary.Definitions == nil {
primary.Definitions = make(spec.Definitions)
}
if primary.Parameters == nil {
primary.Parameters = make(map[string]spec.Parameter)
}
if primary.Responses == nil {
primary.Responses = make(map[string]spec.Response)
}
for i, m := range mixins {
for k, v := range m.Definitions {
// assume name collisions represent IDENTICAL type. careful.

View File

@@ -3,10 +3,11 @@ package analysis
import "testing"
const (
widgetFile = "fixtures/widget-crud.yml"
fooFile = "fixtures/foo-crud.yml"
barFile = "fixtures/bar-crud.yml"
noPathsFile = "fixtures/no-paths.yml"
widgetFile = "fixtures/widget-crud.yml"
fooFile = "fixtures/foo-crud.yml"
barFile = "fixtures/bar-crud.yml"
noPathsFile = "fixtures/no-paths.yml"
emptyPathsFile = "fixtures/empty-paths.json"
)
func TestMixin(t *testing.T) {
@@ -49,4 +50,15 @@ func TestMixin(t *testing.T) {
t.Errorf("TestMixin: Expected 2 top level responses in merged, got %v\n", len(primary.Responses))
}
// test that adding paths to a primary with no paths works (was NPE)
emptyPaths, err := loadSpec(emptyPathsFile)
if err != nil {
t.Fatalf("Could not load '%v': %v\n", emptyPathsFile, err)
}
collisions = Mixin(emptyPaths, primary)
if len(collisions) != 0 {
t.Errorf("TestMixin: Expected 0 collisions, got %v\n%v", len(collisions), collisions)
}
}

View File

@@ -1,5 +1,7 @@
language: go
dist: trusty
go:
- 1.7.x
- 1.8.x
install:
- go get -u github.com/axw/gocov/gocov

View File

@@ -0,0 +1,9 @@
// +build go1.8
package middleware
import "net/url"
func pathUnescape(path string) (string, error) {
return url.PathUnescape(path)
}

View File

@@ -0,0 +1,9 @@
// +build !go1.8
package middleware
import "net/url"
func pathUnescape(path string) (string, error) {
return url.QueryUnescape(path)
}

View File

@@ -16,7 +16,6 @@ package middleware
import (
"net/http"
"net/url"
fpath "path"
"regexp"
"strings"
@@ -182,7 +181,7 @@ func (d *defaultRouter) Lookup(method, path string) (*MatchedRoute, bool) {
debugLog("found a route for %s %s with %d parameters", method, path, len(entry.Parameters))
var params RouteParams
for _, p := range rp {
v, err := url.PathUnescape(p.Value)
v, err := pathUnescape(p.Value)
if err != nil {
debugLog("failed to escape %q: %v", p.Value, err)
v = p.Value

View File

@@ -41,6 +41,7 @@ func TestContentTypeValidation(t *testing.T) {
recorder = httptest.NewRecorder()
request, _ = http.NewRequest("POST", "/api/pets", nil)
request.Header.Add("content-type", "application(")
request.Header.Add("Accept", "application/json")
request.ContentLength = 1
mw.ServeHTTP(recorder, request)

View File

@@ -120,7 +120,8 @@ func NewRef(refURI string) (Ref, error) {
return Ref{Ref: ref}, nil
}
// MustCreateRef creates a ref object but
// MustCreateRef creates a ref object but panics when refURI is invalid.
// Use the NewRef method for a version that returns an error.
func MustCreateRef(refURI string) Ref {
return Ref{Ref: jsonreference.MustCreateRef(refURI)}
}